Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 bits_read() const { | |
| 37 return bit_reader_core_.bits_read(); | |
| 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|, | |
| 44 // then the value in |*out| is not valid. | |
| 45 int ReadUE(uint32* out); | |
|
damienv1
2014/01/13 22:41:06
bool ReadUE(uint32* out, int* code_size = NULL);
| |
| 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 | |
| 56 // Pointer to the next unread byte in the stream. | |
| 57 const uint8* data_; | |
| 58 | |
| 59 // Bytes left in the stream. | |
| 60 int bytes_left_; | |
| 61 | |
| 62 // Array used to return some bytes when some start code emulation prevention | |
| 63 // bytes are detected. | |
| 64 uint8 data_window_[8]; | |
| 65 | |
| 66 // Last two bytes read from the stream. | |
| 67 uint32 prev_two_bytes_; | |
| 68 | |
| 69 BitReaderCore bit_reader_core_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(BitReaderH264); | |
| 72 }; | |
| 73 | |
| 74 } // namespace media | |
| 75 | |
| 76 #endif // MEDIA_BASE_BIT_READER_H264_H_ | |
| OLD | NEW |