Commit c4948f05 authored by Chris Cunningham's avatar Chris Cunningham Committed by Commit Bot

[media] vpx_video_decoder: dynamically update natural size

This changes the behavior implicit resizing of for VP8/9 video. By
implicit, we mean streams where the dimensions change without a new
MSE init segment that explicitly describes the new size.

Prior to this CL, we took whatever resolution was specified by the
container metadata and scaled any later differing resolution into an
element of that original size. Many of our decoders worked this way
before https://chromium-review.googlesource.com/c/chromium/src/+/1026992/,
which shifted the consensus is to allow dynamic resize. This CL makes
the libVPX wrapper consistent with those.

When the size changes we will update videoWidth and videoHeight and
fire a 'resize' event.

Bug: 992235
Change-Id: I5bca7a68709594500e6ec9b4e107531b41e20925
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1828226
Commit-Queue: Dan Sanders <sandersd@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701373}
parent 384bf5d9
...@@ -508,6 +508,7 @@ bool VpxVideoDecoder::CopyVpxImageToVideoFrame( ...@@ -508,6 +508,7 @@ bool VpxVideoDecoder::CopyVpxImageToVideoFrame(
// benefit, and only risk copying too much data. // benefit, and only risk copying too much data.
const gfx::Size coded_size(vpx_image->w, vpx_image->d_h); const gfx::Size coded_size(vpx_image->w, vpx_image->d_h);
const gfx::Size visible_size(vpx_image->d_w, vpx_image->d_h); const gfx::Size visible_size(vpx_image->d_w, vpx_image->d_h);
const gfx::Size natural_size(vpx_image->r_w, vpx_image->r_h);
if (memory_pool_) { if (memory_pool_) {
DCHECK_EQ(kCodecVP9, config_.codec()); DCHECK_EQ(kCodecVP9, config_.codec());
...@@ -521,19 +522,18 @@ bool VpxVideoDecoder::CopyVpxImageToVideoFrame( ...@@ -521,19 +522,18 @@ bool VpxVideoDecoder::CopyVpxImageToVideoFrame(
vpx_image_alpha->stride[VPX_PLANE_Y], vpx_image_alpha->stride[VPX_PLANE_Y],
vpx_image_alpha->d_w, vpx_image_alpha->d_h); vpx_image_alpha->d_w, vpx_image_alpha->d_h);
*video_frame = VideoFrame::WrapExternalYuvaData( *video_frame = VideoFrame::WrapExternalYuvaData(
codec_format, coded_size, gfx::Rect(visible_size), codec_format, coded_size, gfx::Rect(visible_size), natural_size,
config_.natural_size(), vpx_image->stride[VPX_PLANE_Y], vpx_image->stride[VPX_PLANE_Y], vpx_image->stride[VPX_PLANE_U],
vpx_image->stride[VPX_PLANE_U], vpx_image->stride[VPX_PLANE_V], vpx_image->stride[VPX_PLANE_V], vpx_image_alpha->stride[VPX_PLANE_Y],
vpx_image_alpha->stride[VPX_PLANE_Y], vpx_image->planes[VPX_PLANE_Y], vpx_image->planes[VPX_PLANE_Y], vpx_image->planes[VPX_PLANE_U],
vpx_image->planes[VPX_PLANE_U], vpx_image->planes[VPX_PLANE_V], vpx_image->planes[VPX_PLANE_V], alpha_plane, kNoTimestamp);
alpha_plane, kNoTimestamp);
} else { } else {
*video_frame = VideoFrame::WrapExternalYuvData( *video_frame = VideoFrame::WrapExternalYuvData(
codec_format, coded_size, gfx::Rect(visible_size), codec_format, coded_size, gfx::Rect(visible_size), natural_size,
config_.natural_size(), vpx_image->stride[VPX_PLANE_Y], vpx_image->stride[VPX_PLANE_Y], vpx_image->stride[VPX_PLANE_U],
vpx_image->stride[VPX_PLANE_U], vpx_image->stride[VPX_PLANE_V], vpx_image->stride[VPX_PLANE_V], vpx_image->planes[VPX_PLANE_Y],
vpx_image->planes[VPX_PLANE_Y], vpx_image->planes[VPX_PLANE_U], vpx_image->planes[VPX_PLANE_U], vpx_image->planes[VPX_PLANE_V],
vpx_image->planes[VPX_PLANE_V], kNoTimestamp); kNoTimestamp);
} }
if (!(*video_frame)) if (!(*video_frame))
return false; return false;
...@@ -544,8 +544,8 @@ bool VpxVideoDecoder::CopyVpxImageToVideoFrame( ...@@ -544,8 +544,8 @@ bool VpxVideoDecoder::CopyVpxImageToVideoFrame(
} }
*video_frame = frame_pool_.CreateFrame(codec_format, visible_size, *video_frame = frame_pool_.CreateFrame(codec_format, visible_size,
gfx::Rect(visible_size), gfx::Rect(visible_size), natural_size,
config_.natural_size(), kNoTimestamp); kNoTimestamp);
if (!(*video_frame)) if (!(*video_frame))
return false; return false;
......
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