Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1016)

Side by Side Diff: media/filters/vp9_raw_bits_reader.cc

Issue 1258083003: Add VP9 raw bits reader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copyright; nits Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698