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

Unified Diff: media/base/bit_reader.cc

Issue 14495010: Add UMA stats for audio/video containers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 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
« no previous file with comments | « media/base/bit_reader.h ('k') | media/base/bit_reader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/bit_reader.cc
diff --git a/media/base/bit_reader.cc b/media/base/bit_reader.cc
index ed3dc6050f1f11383db82d6784c37ff82e9d124b..9f6f4098a1f205676f508a9282540866fb094bf7 100644
--- a/media/base/bit_reader.cc
+++ b/media/base/bit_reader.cc
@@ -15,6 +15,31 @@ BitReader::BitReader(const uint8* data, off_t size)
BitReader::~BitReader() {}
+bool BitReader::SkipBits(int num_bits) {
+ DCHECK_GE(num_bits, 0);
+ DLOG_IF(INFO, num_bits > 100)
+ << "BitReader::SkipBits inefficient for large skips";
+
+ // Skip any bits in the current byte waiting to be processed, then
+ // process full bytes until less than 8 bits remaining.
+ while (num_bits > 0 && num_bits > num_remaining_bits_in_curr_byte_) {
+ num_bits -= num_remaining_bits_in_curr_byte_;
+ num_remaining_bits_in_curr_byte_ = 0;
+ UpdateCurrByte();
+
+ // If there is no more data remaining, only return true if we
+ // skipped all that were requested.
+ if (num_remaining_bits_in_curr_byte_ == 0)
+ return (num_bits == 0);
+ }
+
+ // Less than 8 bits remaining to skip. Use ReadBitsInternal to verify
+ // that the remaining bits we need exist, and adjust them as necessary
+ // for subsequent operations.
+ uint64 not_needed;
+ return ReadBitsInternal(num_bits, &not_needed);
+}
+
int BitReader::bits_available() const {
return 8 * bytes_left_ + num_remaining_bits_in_curr_byte_;
}
« no previous file with comments | « media/base/bit_reader.h ('k') | media/base/bit_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698