Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1206)

Side by Side Diff: media/base/bit_reader_h264.h

Issue 112343011: Split the bit reader functionalities from the byte stream provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation warning on windows & Add more unit tests Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_BIT_READER_H264_H_
6 #define MEDIA_BASE_BIT_READER_H264_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "media/base/bit_reader_core.h"
12 #include "media/base/media_export.h"
13
14 namespace media {
15
16 class MEDIA_EXPORT BitReaderH264
17 : NON_EXPORTED_BASE(private BitReaderCore::ByteStreamProvider) {
18 public:
19 // Initialize the reader to start reading at |data|, |size| being size
20 // of |data| in bytes.
21 BitReaderH264(const uint8* data, int size);
22 virtual ~BitReaderH264();
23
24 template<typename T> bool ReadBits(int num_bits, T* out) {
25 return bit_reader_core_.ReadBits(num_bits, out);
26 }
27
28 bool ReadFlag(bool* flag) {
29 return bit_reader_core_.ReadFlag(flag);
30 }
31
32 bool SkipBits(int num_bits) {
33 return bit_reader_core_.SkipBits(num_bits);
34 }
35
36 int GetBitCount() {
acolwell GONE FROM CHROMIUM 2014/01/06 22:44:06 s/GetBitCount/bits_read/ for similar reasons as in
damienv1 2014/01/07 00:19:40 OK I can do it since this is the chromium style.
37 return bit_reader_core_.GetBitCount();
38 }
39
40 // Read an unsigned exp-golomb value.
41 // Return a negative number if the value cannot be read.
42 // Return the number of bits used by the exp-golomb code.
43 // Note: if the number of bits is greater than |kMaxExpGolombCodeSize|,
acolwell GONE FROM CHROMIUM 2014/01/06 22:44:06 This seems like a weird API. Why not simply make t
damienv1 2014/01/07 00:19:40 This allows the user of this class to differentiat
44 // then the value in |*out| is not valid.
45 int ReadUE(uint32* out);
46
47 // See the definition of more_rbsp_data() in spec.
48 bool HasMoreRBSPData();
49
50 static const int kMaxExpGolombCodeSize;
51
52 private:
53 // BitReaderCore::ByteStreamProvider implementation.
54 virtual int GetBytes(int max_n, const uint8** out) OVERRIDE;
55 virtual int GetBytesLeft() const OVERRIDE;
56
57 // Pointer to the next unread byte in the stream.
58 const uint8* data_;
59
60 // Bytes left in the stream.
61 int bytes_left_;
62
63 // Array used to return some bytes when some start code emulation prevention
64 // bytes are detected.
65 uint8 data_window_[8];
66
67 // Last two bytes read from the stream.
68 uint32 prev_two_bytes_;
69
70 BitReaderCore bit_reader_core_;
71
72 DISALLOW_COPY_AND_ASSIGN(BitReaderH264);
73 };
74
75 } // namespace media
76
77 #endif // MEDIA_BASE_BIT_READER_H264_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698