OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 18 matching lines...) Loading... | |
29 // General note: this is based off the 02/2014 version of the H.264 standard. | 29 // General note: this is based off the 02/2014 version of the H.264 standard. |
30 // You can find it on this page: | 30 // You can find it on this page: |
31 // http://www.itu.int/rec/T-REC-H.264 | 31 // http://www.itu.int/rec/T-REC-H.264 |
32 | 32 |
33 const char* sps_bytes = reinterpret_cast<const char*>(sps_); | 33 const char* sps_bytes = reinterpret_cast<const char*>(sps_); |
34 // First, parse out rbsp, which is basically the source buffer minus emulation | 34 // First, parse out rbsp, which is basically the source buffer minus emulation |
35 // bytes (the last byte of a 0x00 0x00 0x03 sequence). RBSP is defined in | 35 // bytes (the last byte of a 0x00 0x00 0x03 sequence). RBSP is defined in |
36 // section 7.3.1 of the H.264 standard. | 36 // section 7.3.1 of the H.264 standard. |
37 rtc::ByteBuffer rbsp_buffer; | 37 rtc::ByteBuffer rbsp_buffer; |
38 for (size_t i = 0; i < byte_length_;) { | 38 for (size_t i = 0; i < byte_length_;) { |
39 if (i + 3 < byte_length_ && sps_[i] == 0 && sps_[i + 1] == 0 && | 39 if (byte_length_ - i >= 3 && sps_[i] == 0 && sps_[i + 1] == 0 && |
pbos-webrtc
2015/07/09 09:20:07
Can you put a comment here saying that we check (b
| |
40 sps_[i + 2] == 3) { | 40 sps_[i + 2] == 3) { |
41 // Two rbsp bytes + the emulation byte. | 41 // Two rbsp bytes + the emulation byte. |
42 rbsp_buffer.WriteBytes(sps_bytes + i, 2); | 42 rbsp_buffer.WriteBytes(sps_bytes + i, 2); |
43 i += 3; | 43 i += 3; |
44 } else { | 44 } else { |
45 // Single rbsp byte. | 45 // Single rbsp byte. |
46 rbsp_buffer.WriteBytes(sps_bytes + i, 1); | 46 rbsp_buffer.WriteBytes(sps_bytes + i, 1); |
47 i++; | 47 i++; |
48 } | 48 } |
49 } | 49 } |
(...skipping 169 matching lines...) Loading... | |
219 // Subtract the crop for each dimension. | 219 // Subtract the crop for each dimension. |
220 width -= (frame_crop_left_offset + frame_crop_right_offset); | 220 width -= (frame_crop_left_offset + frame_crop_right_offset); |
221 height -= (frame_crop_top_offset + frame_crop_bottom_offset); | 221 height -= (frame_crop_top_offset + frame_crop_bottom_offset); |
222 | 222 |
223 width_ = width; | 223 width_ = width; |
224 height_ = height; | 224 height_ = height; |
225 return true; | 225 return true; |
226 } | 226 } |
227 | 227 |
228 } // namespace webrtc | 228 } // namespace webrtc |
OLD | NEW |