Chromium Code Reviews| 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 #include "media/filters/vp9_raw_bits_reader.h" | |
| 6 | |
| 7 #include <limits.h> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "media/base/bit_reader.h" | |
| 11 | |
| 12 namespace media { | |
| 13 | |
| 14 Vp9RawBitsReader::Vp9RawBitsReader() : out_of_buffer_(false) {} | |
| 15 | |
| 16 Vp9RawBitsReader::~Vp9RawBitsReader() {} | |
| 17 | |
| 18 void Vp9RawBitsReader::Initialize(const uint8_t* data, size_t size) { | |
| 19 DCHECK(data); | |
| 20 reader_.reset(new BitReader(data, size)); | |
| 21 out_of_buffer_ = false; | |
| 22 } | |
| 23 | |
| 24 int Vp9RawBitsReader::ReadBit() { | |
| 25 DCHECK(reader_); | |
| 26 int value = 0; | |
| 27 out_of_buffer_ = !reader_->ReadBits(1, &value); | |
| 28 return value; | |
| 29 } | |
| 30 | |
| 31 int Vp9RawBitsReader::ReadLiteral(int bits) { | |
| 32 DCHECK(reader_); | |
| 33 int value = 0; | |
| 34 out_of_buffer_ = !reader_->ReadBits(bits, &value); | |
|
Owen Lin
2015/08/01 11:35:37
Use out_of_buffer |= !reader_->ReadBits ...
It loo
Pawel Osciak
2015/08/02 10:46:11
Good idea, and you could also instead of out_of_bu
kcwu
2015/08/03 07:10:13
Done.
| |
| 35 return value; | |
| 36 } | |
| 37 | |
| 38 int Vp9RawBitsReader::ReadSignedLiteral(int bits) { | |
| 39 int value = ReadLiteral(bits); | |
| 40 return ReadBit() ? -value : value; | |
| 41 } | |
| 42 | |
| 43 size_t Vp9RawBitsReader::GetBytesRead() const { | |
| 44 DCHECK(reader_); | |
| 45 return (reader_->bits_read() + 7) / 8; | |
| 46 } | |
| 47 | |
| 48 } // namespace media | |
| OLD | NEW |