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

Side by Side Diff: media/filters/h264_to_annex_b_bitstream_converter.cc

Issue 1107593004: Disregard trailing null bytes when locating RBSP stop bits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update bitstream converter as well. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/h264_to_annex_b_bitstream_converter.h" 5 #include "media/filters/h264_to_annex_b_bitstream_converter.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/filters/h264_parser.h" 10 #include "media/filters/h264_parser.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 258 }
259 // Successful conversion, output the freshly allocated bitstream buffer. 259 // Successful conversion, output the freshly allocated bitstream buffer.
260 *output_size = static_cast<uint32_t>(outscan - output); 260 *output_size = static_cast<uint32_t>(outscan - output);
261 return true; 261 return true;
262 } 262 }
263 263
264 bool H264ToAnnexBBitstreamConverter::WriteParamSet( 264 bool H264ToAnnexBBitstreamConverter::WriteParamSet(
265 const std::vector<uint8_t>& param_set, 265 const std::vector<uint8_t>& param_set,
266 uint8_t** out, 266 uint8_t** out,
267 uint32_t* out_size) const { 267 uint32_t* out_size) const {
268 // Strip trailing null bytes.
269 uint32_t size = param_set.size();
Pawel Osciak 2016/03/01 08:56:21 s/uint32_t/size_t/
sandersd (OOO until July 31) 2016/03/17 19:07:51 Done.
270 while (size && param_set[size - 1] == 0)
271 size--;
272 if (!size)
273 return false;
274
275 // Verify space.
268 uint32_t bytes_left = *out_size; 276 uint32_t bytes_left = *out_size;
269 if (bytes_left < kParamSetStartCodeSize || 277 if (bytes_left < kParamSetStartCodeSize ||
270 bytes_left - kParamSetStartCodeSize < param_set.size()) { 278 bytes_left - kParamSetStartCodeSize < size) {
271 return false; 279 return false;
272 } 280 }
273 281
274 uint8_t* start = *out; 282 uint8_t* start = *out;
275 uint8_t* buf = start; 283 uint8_t* buf = start;
276 284
277 // Write the 4 byte Annex B start code. 285 // Write the 4 byte Annex B start code.
278 *buf++ = 0; // zero byte 286 *buf++ = 0; // zero byte
279 memcpy(buf, kStartCodePrefix, sizeof(kStartCodePrefix)); 287 memcpy(buf, kStartCodePrefix, sizeof(kStartCodePrefix));
280 buf += sizeof(kStartCodePrefix); 288 buf += sizeof(kStartCodePrefix);
281 289
282 memcpy(buf, &param_set[0], param_set.size()); 290 // Copy the data.
283 buf += param_set.size(); 291 memcpy(buf, &param_set[0], size);
292 buf += size;
284 293
285 *out = buf; 294 *out = buf;
286 *out_size -= buf - start; 295 *out_size -= buf - start;
287 return true; 296 return true;
288 } 297 }
289 298
290 } // namespace media 299 } // namespace media
OLDNEW
« media/filters/h264_bit_reader.cc ('K') | « media/filters/h264_bit_reader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698