OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_FILTERS_VP9_RAW_BITS_READER_ |
| 6 #define MEDIA_FILTERS_VP9_RAW_BITS_READER_ |
| 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "media/base/media_export.h" |
| 14 |
| 15 namespace media { |
| 16 |
| 17 class BitReader; |
| 18 |
| 19 // A class to read raw bits stream. See VP9 spec, "RAW-BITS DECODING" section |
| 20 // for detail. |
| 21 class MEDIA_EXPORT Vp9RawBitsReader { |
| 22 public: |
| 23 Vp9RawBitsReader(); |
| 24 ~Vp9RawBitsReader(); |
| 25 |
| 26 // |data| is the input buffer with |size| bytes. |
| 27 void Initialize(const uint8_t* data, size_t size); |
| 28 |
| 29 // Returns true if none of the reads since the last Initialize() call has |
| 30 // gone beyond the end of available data. |
| 31 bool IsValid() const { return valid_; } |
| 32 |
| 33 // Returns how many bytes were read since the last Initialize() call. |
| 34 // Partial bytes will be counted as one byte. For example, it will return 1 |
| 35 // if 3 bits were read. |
| 36 size_t GetBytesRead() const; |
| 37 |
| 38 // Reads one bit. |
| 39 // If the read goes beyond the end of buffer, the return value is undefined. |
| 40 int ReadBit(); |
| 41 |
| 42 // Reads a literal with |bits| bits. |
| 43 // If the read goes beyond the end of buffer, the return value is undefined. |
| 44 int ReadLiteral(int bits); |
| 45 |
| 46 // Reads a signed literal with |bits| bits (not including the sign bit). |
| 47 // If the read goes beyond the end of buffer, the return value is undefined. |
| 48 int ReadSignedLiteral(int bits); |
| 49 |
| 50 private: |
| 51 scoped_ptr<BitReader> reader_; |
| 52 |
| 53 // Indicates if none of the reads since the last Initialize() call has gone |
| 54 // beyond the end of available data. |
| 55 bool valid_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(Vp9RawBitsReader); |
| 58 }; |
| 59 |
| 60 } // namespace media |
| 61 |
| 62 #endif // MEDIA_FILTERS_VP9_RAW_BITS_READER_ |
OLD | NEW |