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/memory/scoped_ptr.h" | |
| 10 #include "media/base/bit_reader_core.h" | |
| 11 #include "media/base/media_export.h" | |
| 12 | |
| 13 namespace media { | |
| 14 | |
| 15 class MEDIA_EXPORT BitReaderH264 | |
| 16 : private BitReaderCore::ByteStreamProvider { | |
|
damienv1
2013/12/28 06:27:40
Should be NON_EXPORTED_BASE(private BitReaderCore:
| |
| 17 public: | |
| 18 // Initialize the reader to start reading at |data|, |size| being size | |
| 19 // of |data| in bytes. | |
| 20 BitReaderH264(const uint8* data, int size); | |
| 21 virtual ~BitReaderH264(); | |
| 22 | |
| 23 template<typename T> bool ReadBits(int num_bits, T* out) { | |
| 24 return bit_reader_core_.ReadBits(num_bits, out); | |
| 25 } | |
| 26 | |
| 27 bool ReadFlag(bool* flag) { | |
| 28 return bit_reader_core_.ReadFlag(flag); | |
| 29 } | |
| 30 | |
| 31 bool SkipBits(int num_bits) { | |
| 32 return bit_reader_core_.SkipBits(num_bits); | |
| 33 } | |
| 34 | |
| 35 int GetBitCount() { | |
| 36 return bit_reader_core_.GetBitCount(); | |
| 37 } | |
| 38 | |
| 39 // Read an unsigned exp-golomb value. | |
| 40 // Return a negative number if the value cannot be read. | |
| 41 // Return the number of bits used by the exp-golomb code. | |
| 42 // Note: it is up to the caller to check for a possible overflow | |
| 43 // based on the returned exp-golomb code size. | |
| 44 int ReadUE(uint32* out); | |
| 45 | |
| 46 // See the definition of more_rbsp_data() in spec. | |
| 47 bool HasMoreRBSPData(); | |
| 48 | |
| 49 private: | |
| 50 // BitReaderCore::ByteStreamProvider implementation. | |
| 51 virtual int GetBytes(int max_n, const uint8** out) OVERRIDE; | |
| 52 virtual int GetBytesLeft() const OVERRIDE; | |
| 53 | |
| 54 // Pointer to the next unread byte in the stream. | |
| 55 const uint8* data_; | |
| 56 | |
| 57 // Bytes left in the stream. | |
| 58 int bytes_left_; | |
| 59 | |
| 60 // Array used to return some bytes when some start code emulation prevention | |
| 61 // bytes are detected. | |
| 62 uint8 data_window_[8]; | |
| 63 | |
| 64 // Last two bytes read from the stream. | |
| 65 uint32 prev_two_bytes_; | |
| 66 | |
| 67 BitReaderCore bit_reader_core_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(BitReaderH264); | |
| 70 }; | |
| 71 | |
| 72 } // namespace media | |
| 73 | |
| 74 #endif // MEDIA_BASE_BIT_READER_H264_H_ | |
| OLD | NEW |