input_frame_validation.patch (1755B)
1 # HG changeset patch 2 # User Randell Jesup <rjesup@jesup.org> 3 # Parent 1b77af186da211485fa9c5573d843d96c708a829 4 Bug 1263384: validate input frames against configured resolution in vp8 r=rillian 5 6 MozReview-Commit-ID: BxDCnJe0mzs 7 8 diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c 9 --- a/vp8/vp8_cx_iface.c 10 +++ b/vp8/vp8_cx_iface.c 11 @@ -989,20 +989,29 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx, 12 &ctx->cpi->common.error, VPX_CODEC_INVALID_PARAM, 13 "conversion of relative pts + duration to ticks would overflow"); 14 } 15 dst_end_time_stamp = 16 pts_end * ctx->timestamp_ratio.num / ctx->timestamp_ratio.den; 17 18 res = image2yuvconfig(img, &sd); 19 20 - if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags, &sd, 21 - dst_time_stamp, dst_end_time_stamp)) { 22 - VP8_COMP *cpi = (VP8_COMP *)ctx->cpi; 23 - res = update_error_state(ctx, &cpi->common.error); 24 + if (sd.y_width != ctx->cfg.g_w || sd.y_height != ctx->cfg.g_h) { 25 + /* from vpx_encoder.h for g_w/g_h: 26 + "Note that the frames passed as input to the encoder must have this 27 + resolution" 28 + */ 29 + ctx->base.err_detail = "Invalid input frame resolution"; 30 + res = VPX_CODEC_INVALID_PARAM; 31 + } else { 32 + if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags, 33 + &sd, dst_time_stamp, dst_end_time_stamp)) { 34 + VP8_COMP *cpi = (VP8_COMP *)ctx->cpi; 35 + res = update_error_state(ctx, &cpi->common.error); 36 + } 37 } 38 39 /* reset for next frame */ 40 ctx->next_frame_flag = 0; 41 } 42 43 cx_data = ctx->cx_data; 44 cx_data_sz = ctx->cx_data_sz;