Commit 3021ba55 authored by Hua, Chunbo's avatar Hua, Chunbo Committed by Commit Bot

[webcodecs] Fix the buffer size issue during H.264 conversion.

Between AnnexB and AVCC bitstream formats, the start code length and
the nal size length can be different. Here to retry the conversion
if the output buffer size is too small.

Bug: 1119636
Change-Id: I517e81ef152a19b577fa04a60297f1dc35b1aeb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508998Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Reviewed-by: default avatarEugene Zemtsov <eugene@chromium.org>
Commit-Queue: Chunbo Hua <chunbo.hua@intel.com>
Cr-Commit-Position: refs/heads/master@{#822960}
parent c460c9b0
......@@ -366,6 +366,19 @@ void VideoEncodeAcceleratorAdapter::BitstreamBufferReady(
h264_converter_->ConvertChunk(base::span<uint8_t>(src, result.size),
base::span<uint8_t>(dst.get(), dst_size),
&config_changed, &actual_output_size);
if (status.code() == StatusCode::kH264BufferTooSmall) {
// Between AnnexB and AVCC bitstream formats, the start code length and
// the nal size length can be different. See H.264 specification at
// http://www.itu.int/rec/T-REC-H.264. Retry the conversion if the output
// buffer size is too small.
dst_size = actual_output_size;
dst.reset(new uint8_t[dst_size]);
status = h264_converter_->ConvertChunk(
base::span<uint8_t>(src, result.size),
base::span<uint8_t>(dst.get(), dst_size), &config_changed,
&actual_output_size);
}
if (!status.is_ok()) {
LOG(ERROR) << status.message();
NotifyError(VideoEncodeAccelerator::kPlatformFailureError);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment