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..ca04c7a1720a79073913b8e01f54cd80e62887ea |
--- /dev/null |
+++ b/media/base/bit_reader_h264.h |
@@ -0,0 +1,74 @@ |
+// 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/memory/scoped_ptr.h" |
+#include "media/base/bit_reader_core.h" |
+#include "media/base/media_export.h" |
+ |
+namespace media { |
+ |
+class MEDIA_EXPORT BitReaderH264 |
+ : private BitReaderCore::ByteStreamProvider { |
damienv1
2013/12/28 06:27:40
Should be NON_EXPORTED_BASE(private BitReaderCore:
|
+ 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 GetBitCount() { |
+ return bit_reader_core_.GetBitCount(); |
+ } |
+ |
+ // 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: it is up to the caller to check for a possible overflow |
+ // based on the returned exp-golomb code size. |
+ int ReadUE(uint32* out); |
+ |
+ // See the definition of more_rbsp_data() in spec. |
+ bool HasMoreRBSPData(); |
+ |
+ private: |
+ // BitReaderCore::ByteStreamProvider implementation. |
+ virtual int GetBytes(int max_n, const uint8** out) OVERRIDE; |
+ virtual int GetBytesLeft() const 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_ |