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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/h264_bit_reader.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/h264_to_annex_b_bitstream_converter.cc
diff --git a/media/filters/h264_to_annex_b_bitstream_converter.cc b/media/filters/h264_to_annex_b_bitstream_converter.cc
index e4860ecf8713b4773f8f6f3945dd7c8dc353c1c1..adec45cfa63d15b80da1bf01781e0af443d2b98a 100644
--- a/media/filters/h264_to_annex_b_bitstream_converter.cc
+++ b/media/filters/h264_to_annex_b_bitstream_converter.cc
@@ -265,9 +265,17 @@ bool H264ToAnnexBBitstreamConverter::WriteParamSet(
const std::vector<uint8_t>& param_set,
uint8_t** out,
uint32_t* out_size) const {
+ // Strip trailing null bytes.
+ size_t size = param_set.size();
+ while (size && param_set[size - 1] == 0)
+ size--;
+ if (!size)
+ return false;
+
+ // Verify space.
uint32_t bytes_left = *out_size;
if (bytes_left < kParamSetStartCodeSize ||
- bytes_left - kParamSetStartCodeSize < param_set.size()) {
+ bytes_left - kParamSetStartCodeSize < size) {
return false;
}
@@ -279,8 +287,9 @@ bool H264ToAnnexBBitstreamConverter::WriteParamSet(
memcpy(buf, kStartCodePrefix, sizeof(kStartCodePrefix));
buf += sizeof(kStartCodePrefix);
- memcpy(buf, &param_set[0], param_set.size());
- buf += param_set.size();
+ // Copy the data.
+ memcpy(buf, &param_set[0], size);
+ buf += size;
*out = buf;
*out_size -= buf - start;
« no previous file with comments | « media/filters/h264_bit_reader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698