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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: media/base/bit_reader.cc
diff --git a/media/base/bit_reader.cc b/media/base/bit_reader.cc
new file mode 100644
index 0000000000000000000000000000000000000000..709d5ae87c59d47148ffb630666d98778a540c7c
--- /dev/null
+++ b/media/base/bit_reader.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/bit_reader.h"
+
+namespace media {
+
+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_
+ 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.
+
+ data_ = data;
+ bytes_left_ = size;
+ 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.
+
+ UpdateCurrByte();
+}
+
+BitReader::~BitReader() {}
+
+void BitReader::UpdateCurrByte() {
+ DCHECK_EQ(num_remaining_bits_in_curr_byte_, 0);
+
+ 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.
+ return;
+
+ // Load a new byte and advance pointers.
+ curr_byte_ = *data_;
+ ++data_;
+ --bytes_left_;
+ num_remaining_bits_in_curr_byte_ = 8;
+}
+
+bool BitReader::SkipBits(int num_bits) {
+ int dummy;
+ const int kDummySize = static_cast<int>(sizeof(dummy)) * 8;
+
+ while (num_bits > kDummySize) {
+ if (ReadBits(kDummySize, &dummy)) {
+ num_bits -= kDummySize;
+ } else {
+ return false;
+ }
+ }
+
+ return ReadBits(num_bits, &dummy);
+}
+
+off_t BitReader::NumBitsLeft() const {
+ return (num_remaining_bits_in_curr_byte_ + bytes_left_ * 8);
+}
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698