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

Unified Diff: content/common/gpu/media/h264_bit_reader.cc

Issue 10753005: Add HE AAC support to ISO BMFF. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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: content/common/gpu/media/h264_bit_reader.cc
diff --git a/content/common/gpu/media/h264_bit_reader.cc b/content/common/gpu/media/h264_bit_reader.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b8d00e174a33ef36461c82dfc34b4046dc3f6fd5
--- /dev/null
+++ b/content/common/gpu/media/h264_bit_reader.cc
@@ -0,0 +1,45 @@
+// 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 "content/common/gpu/media/h264_bit_reader.h"
+
+namespace content {
+
+H264BitReader::H264BitReader() {
+}
+
+H264BitReader::~H264BitReader() {}
+
+void H264BitReader::UpdateCurrByte() {
+ DCHECK_EQ(num_remaining_bits_in_curr_byte_, 0);
+
+ if (bytes_left_ >= 1) {
+ // Emulation prevention three-byte detection.
+ // If a sequence of 0x000003 is found, skip (ignore) the last byte (0x03).
+ if (*data_ == 0x03 && Tell() >= 16 && data_[-1] == 0 && data_[-2] == 0) {
+ // Detected 0x000003, skip last byte.
+ ++data_;
+ --bytes_left_;
+ position_ += 8;
+ }
+ }
+
+ if (bytes_left_ >= 1) {
+ // Load a new byte and advance pointers.
+ curr_byte_ = *data_;
+ ++data_;
+ --bytes_left_;
+ num_remaining_bits_in_curr_byte_ = 8;
+ }
+
+ // Check if this is the end of RBSP data.
+ if (bytes_left_ == 0) {
+ while (num_remaining_bits_in_curr_byte_ != 0 && !(curr_byte_ & 0x1)) {
+ --num_remaining_bits_in_curr_byte_;
+ curr_byte_ >>= 1;
+ }
Pawel Osciak 2012/07/16 21:27:09 This is not true. There can be more than one zero-
Pawel Osciak 2012/07/16 21:30:57 Sorry, meant every last byte.
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698