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

Side by Side Diff: media/base/bit_reader.cc

Issue 10780026: Add HE AAC support to ISO BMFF. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove unused functions and variables. Created 8 years, 5 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 (c) 2012 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/base/bit_reader.h"
6
7 namespace media {
8
9 BitReader::BitReader(const uint8* data, off_t size) {
acolwell GONE FROM CHROMIUM 2012/07/17 22:38:21 nit: off_t -> int here and on bytes_left_
10 DCHECK(data != NULL || size == 0); // Data cannot be NULL if size is not 0.
Ami GONE FROM CHROMIUM 2012/07/17 23:22:18 Comment isn't adding value.
Ami GONE FROM CHROMIUM 2012/07/17 23:22:18 What's the value of supporting empty buffers? I su
xiaomings 2012/07/19 00:16:32 Done.
xiaomings 2012/07/19 00:16:32 Done.
11
12 data_ = data;
13 bytes_left_ = size;
14 num_remaining_bits_in_curr_byte_ = 0;
Ami GONE FROM CHROMIUM 2012/07/17 23:22:18 These three assignments belong in an initializer l
xiaomings 2012/07/19 00:16:32 Done.
15
16 UpdateCurrByte();
17 }
18
19 BitReader::~BitReader() {}
20
21 void BitReader::UpdateCurrByte() {
22 DCHECK_EQ(num_remaining_bits_in_curr_byte_, 0);
23
24 if (bytes_left_ < 1)
Ami GONE FROM CHROMIUM 2012/07/17 23:22:18 Can this ever be negative? Why not ==0 for clarit
xiaomings 2012/07/19 00:16:32 Done.
25 return;
26
27 // Load a new byte and advance pointers.
28 curr_byte_ = *data_;
29 ++data_;
30 --bytes_left_;
31 num_remaining_bits_in_curr_byte_ = 8;
32 }
33
34 bool BitReader::SkipBits(int num_bits) {
35 int dummy;
36 const int kDummySize = static_cast<int>(sizeof(dummy)) * 8;
37
38 while (num_bits > kDummySize) {
39 if (ReadBits(kDummySize, &dummy)) {
40 num_bits -= kDummySize;
41 } else {
42 return false;
43 }
44 }
45
46 return ReadBits(num_bits, &dummy);
47 }
48
49 off_t BitReader::NumBitsLeft() const {
50 return (num_remaining_bits_in_curr_byte_ + bytes_left_ * 8);
51 }
52
53 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698