Chromium Code Reviews| Index: media/filters/vp9_raw_bits_reader.h |
| diff --git a/media/filters/vp9_raw_bits_reader.h b/media/filters/vp9_raw_bits_reader.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..99e513e163d5b463c720655b4a865eeb4558202b |
| --- /dev/null |
| +++ b/media/filters/vp9_raw_bits_reader.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2015 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_FILTERS_VP9_RAW_BITS_READER_ |
| +#define MEDIA_FILTERS_VP9_RAW_BITS_READER_ |
| + |
| +#include <stddef.h> |
| +#include <stdint.h> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "media/base/media_export.h" |
| + |
| +namespace media { |
| + |
| +class BitReader; |
| + |
| +// A class to read raw bits stream. See VP9 spec, "RAW-BITS DECODING" section |
| +// for detail. |
| +class MEDIA_EXPORT Vp9RawBitsReader { |
| + public: |
| + Vp9RawBitsReader(); |
| + ~Vp9RawBitsReader(); |
| + |
| + // |data| is the input buffer with |size| bytes. |
| + void Initialize(const uint8_t* data, size_t size); |
| + |
| + // Returns true if last reads go beyond the end of buffer. |
| + bool IsOutOfBuffer() const { return out_of_buffer_; } |
| + |
| + // Returns how many bytes read. Partial bytes will be counted as one byte. |
|
Pawel Osciak
2015/08/02 10:46:11
s/how many bytes read/how many bytes were read sin
kcwu
2015/08/03 07:10:13
Done.
|
| + // For example, it will return 1 if 3 bits read. |
|
Pawel Osciak
2015/08/02 10:46:11
s/read/were read/
kcwu
2015/08/03 07:10:13
Done.
|
| + size_t GetBytesRead() const; |
| + |
| + // Reads one bit. |
| + // If the read goes beyond the end of buffer, the return value is undefined. |
| + int ReadBit(); |
| + |
| + // Reads a literal with |bits| bits. |
| + // If the read goes beyond the end of buffer, the return value is undefined. |
| + int ReadLiteral(int bits); |
| + |
| + // Reads a signed literal with |bits| bits (not including the sign bit). |
| + // If the read goes beyond the end of buffer, the return value is undefined. |
| + int ReadSignedLiteral(int bits); |
| + |
| + private: |
| + scoped_ptr<BitReader> reader_; |
| + |
| + // Indicates error status that the caller reads beyond the end of input |
| + // buffer. |
| + bool out_of_buffer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Vp9RawBitsReader); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_FILTERS_VP9_RAW_BITS_READER_ |