From 72880921b4c3bfd255c84746730200107b79221e Mon Sep 17 00:00:00 2001 From: Chun-Min Chang Date: Fri, 12 May 2023 01:08:58 +0000 Subject: [PATCH] Bug 1831930 - Apply local patches to libvpx r=webrtc-reviewers,ng Apply local patches by running `./mach vendor media/libvpx/moz.yaml --patch-mode-only` Differential Revision: https://phabricator.services.mozilla.com/D177514 --- media/libvpx/libvpx/vp8/vp8_cx_iface.c | 17 +++++++++++++---- media/libvpx/libvpx/vp9/vp9_cx_iface.c | 19 ++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/media/libvpx/libvpx/vp8/vp8_cx_iface.c b/media/libvpx/libvpx/vp8/vp8_cx_iface.c index 0821eef026ce..e2b75a3b21cb 100644 --- a/media/libvpx/libvpx/vp8/vp8_cx_iface.c +++ b/media/libvpx/libvpx/vp8/vp8_cx_iface.c @@ -948,10 +948,19 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx, if (img != NULL) { res = image2yuvconfig(img, &sd); - if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags, &sd, - dst_time_stamp, dst_end_time_stamp)) { - VP8_COMP *cpi = (VP8_COMP *)ctx->cpi; - res = update_error_state(ctx, &cpi->common.error); + if (sd.y_width != ctx->cfg.g_w || sd.y_height != ctx->cfg.g_h) { + /* from vpx_encoder.h for g_w/g_h: + "Note that the frames passed as input to the encoder must have this + resolution" + */ + ctx->base.err_detail = "Invalid input frame resolution"; + res = VPX_CODEC_INVALID_PARAM; + } else { + if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags, + &sd, dst_time_stamp, dst_end_time_stamp)) { + VP8_COMP *cpi = (VP8_COMP *)ctx->cpi; + res = update_error_state(ctx, &cpi->common.error); + } } /* reset for next frame */ diff --git a/media/libvpx/libvpx/vp9/vp9_cx_iface.c b/media/libvpx/libvpx/vp9/vp9_cx_iface.c index 8f157274fb2e..1c4f438ad303 100644 --- a/media/libvpx/libvpx/vp9/vp9_cx_iface.c +++ b/media/libvpx/libvpx/vp9/vp9_cx_iface.c @@ -1375,13 +1375,22 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx, timebase_units_to_ticks(timestamp_ratio, pts + duration); res = image2yuvconfig(img, &sd); - // Store the original flags in to the frame buffer. Will extract the - // key frame flag when we actually encode this frame. - if (vp9_receive_raw_frame(cpi, flags | ctx->next_frame_flags, &sd, + if (sd.y_width != ctx->cfg.g_w || sd.y_height != ctx->cfg.g_h) { + /* from vpx_encoder.h for g_w/g_h: + "Note that the frames passed as input to the encoder must have this + resolution" + */ + ctx->base.err_detail = "Invalid input frame resolution"; + res = VPX_CODEC_INVALID_PARAM; + } else { + // Store the original flags in to the frame buffer. Will extract the + // key frame flag when we actually encode this frame. + if (vp9_receive_raw_frame(cpi, flags | ctx->next_frame_flags, &sd, dst_time_stamp, dst_end_time_stamp)) { - res = update_error_state(ctx, &cpi->common.error); + res = update_error_state(ctx, &cpi->common.error); + } + ctx->next_frame_flags = 0; } - ctx->next_frame_flags = 0; } cx_data = ctx->cx_data;