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

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

Issue 1258083004: Add a Vp9Parser implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ReadBool, fix compile warning 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
« no previous file with comments | « media/filters/vp9_raw_bits_reader.h ('k') | media/filters/vp9_raw_bits_reader_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/vp9_raw_bits_reader.h" 5 #include "media/filters/vp9_raw_bits_reader.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/bit_reader.h" 10 #include "media/base/bit_reader.h"
11 11
12 namespace media { 12 namespace media {
13 13
14 Vp9RawBitsReader::Vp9RawBitsReader() : valid_(true) {} 14 Vp9RawBitsReader::Vp9RawBitsReader() : valid_(true) {}
15 15
16 Vp9RawBitsReader::~Vp9RawBitsReader() {} 16 Vp9RawBitsReader::~Vp9RawBitsReader() {}
17 17
18 void Vp9RawBitsReader::Initialize(const uint8_t* data, size_t size) { 18 void Vp9RawBitsReader::Initialize(const uint8_t* data, size_t size) {
19 DCHECK(data); 19 DCHECK(data);
20 reader_.reset(new BitReader(data, size)); 20 reader_.reset(new BitReader(data, size));
21 valid_ = true; 21 valid_ = true;
22 } 22 }
23 23
24 int Vp9RawBitsReader::ReadBit() { 24 bool Vp9RawBitsReader::ReadBool() {
25 DCHECK(reader_); 25 DCHECK(reader_);
26 int value = 0; 26 int value = 0;
27 valid_ = valid_ && reader_->ReadBits(1, &value); 27 valid_ = valid_ && reader_->ReadBits(1, &value);
28 return value; 28 return value == 1;
29 } 29 }
30 30
31 int Vp9RawBitsReader::ReadLiteral(int bits) { 31 int Vp9RawBitsReader::ReadLiteral(int bits) {
32 DCHECK(reader_); 32 DCHECK(reader_);
33 int value = 0; 33 int value = 0;
34 DCHECK_LT(static_cast<size_t>(bits), sizeof(value) * 8); 34 DCHECK_LT(static_cast<size_t>(bits), sizeof(value) * 8);
35 valid_ = valid_ && reader_->ReadBits(bits, &value); 35 valid_ = valid_ && reader_->ReadBits(bits, &value);
36 return value; 36 return value;
37 } 37 }
38 38
39 int Vp9RawBitsReader::ReadSignedLiteral(int bits) { 39 int Vp9RawBitsReader::ReadSignedLiteral(int bits) {
40 int value = ReadLiteral(bits); 40 int value = ReadLiteral(bits);
41 return ReadBit() ? -value : value; 41 return ReadBool() ? -value : value;
42 } 42 }
43 43
44 size_t Vp9RawBitsReader::GetBytesRead() const { 44 size_t Vp9RawBitsReader::GetBytesRead() const {
45 DCHECK(reader_); 45 DCHECK(reader_);
46 return (reader_->bits_read() + 7) / 8; 46 return (reader_->bits_read() + 7) / 8;
47 } 47 }
48 48
49 } // namespace media 49 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/vp9_raw_bits_reader.h ('k') | media/filters/vp9_raw_bits_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698