Chromium Code Reviews| Index: media/base/bit_reader_h264.h |
| diff --git a/media/base/bit_reader_h264.h b/media/base/bit_reader_h264.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1a2505d1c7e896a84ab0bef29a49375c6d83d6c3 |
| --- /dev/null |
| +++ b/media/base/bit_reader_h264.h |
| @@ -0,0 +1,76 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_BASE_BIT_READER_H264_H_ |
| +#define MEDIA_BASE_BIT_READER_H264_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "media/base/bit_reader_core.h" |
| +#include "media/base/media_export.h" |
| + |
| +namespace media { |
| + |
| +class MEDIA_EXPORT BitReaderH264 |
| + : NON_EXPORTED_BASE(private BitReaderCore::ByteStreamProvider) { |
| + public: |
| + // Initialize the reader to start reading at |data|, |size| being size |
| + // of |data| in bytes. |
| + BitReaderH264(const uint8* data, int size); |
| + virtual ~BitReaderH264(); |
| + |
| + template<typename T> bool ReadBits(int num_bits, T* out) { |
| + return bit_reader_core_.ReadBits(num_bits, out); |
| + } |
| + |
| + bool ReadFlag(bool* flag) { |
| + return bit_reader_core_.ReadFlag(flag); |
| + } |
| + |
| + bool SkipBits(int num_bits) { |
| + return bit_reader_core_.SkipBits(num_bits); |
| + } |
| + |
| + int bits_read() const { |
| + return bit_reader_core_.bits_read(); |
| + } |
| + |
| + // Read an unsigned exp-golomb value. |
| + // Return a negative number if the value cannot be read. |
| + // Return the number of bits used by the exp-golomb code. |
| + // Note: if the number of bits is greater than |kMaxExpGolombCodeSize|, |
| + // then the value in |*out| is not valid. |
| + int ReadUE(uint32* out); |
|
damienv1
2014/01/13 22:41:06
bool ReadUE(uint32* out, int* code_size = NULL);
|
| + |
| + // See the definition of more_rbsp_data() in spec. |
| + bool HasMoreRBSPData(); |
| + |
| + static const int kMaxExpGolombCodeSize; |
| + |
| + private: |
| + // BitReaderCore::ByteStreamProvider implementation. |
| + virtual int GetBytes(int max_n, const uint8** out) OVERRIDE; |
| + |
| + // Pointer to the next unread byte in the stream. |
| + const uint8* data_; |
| + |
| + // Bytes left in the stream. |
| + int bytes_left_; |
| + |
| + // Array used to return some bytes when some start code emulation prevention |
| + // bytes are detected. |
| + uint8 data_window_[8]; |
| + |
| + // Last two bytes read from the stream. |
| + uint32 prev_two_bytes_; |
| + |
| + BitReaderCore bit_reader_core_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BitReaderH264); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_BASE_BIT_READER_H264_H_ |