OLD | NEW |
---|---|
(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 "content/common/gpu/media/h264_bit_reader.h" | |
6 | |
7 namespace content { | |
8 | |
9 H264BitReader::H264BitReader() { | |
10 } | |
11 | |
12 H264BitReader::~H264BitReader() {} | |
13 | |
14 void H264BitReader::UpdateCurrByte() { | |
15 DCHECK_EQ(num_remaining_bits_in_curr_byte_, 0); | |
16 | |
17 if (bytes_left_ >= 1) { | |
18 // Emulation prevention three-byte detection. | |
19 // If a sequence of 0x000003 is found, skip (ignore) the last byte (0x03). | |
20 if (*data_ == 0x03 && Tell() >= 16 && data_[-1] == 0 && data_[-2] == 0) { | |
21 // Detected 0x000003, skip last byte. | |
22 ++data_; | |
23 --bytes_left_; | |
24 position_ += 8; | |
25 } | |
26 } | |
27 | |
28 if (bytes_left_ >= 1) { | |
29 // Load a new byte and advance pointers. | |
30 curr_byte_ = *data_; | |
31 ++data_; | |
32 --bytes_left_; | |
33 num_remaining_bits_in_curr_byte_ = 8; | |
34 } | |
35 | |
36 // Check if this is the end of RBSP data. | |
37 if (bytes_left_ == 0) { | |
38 while (num_remaining_bits_in_curr_byte_ != 0 && !(curr_byte_ & 0x1)) { | |
39 --num_remaining_bits_in_curr_byte_; | |
40 curr_byte_ >>= 1; | |
41 } | |
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.
| |
42 } | |
43 } | |
44 | |
45 } // namespace content | |
OLD | NEW |