Hi, On Tue, Aug 13, 2019 at 2:30 AM Linjie Fu <linjie...@intel.com> wrote: > > According to spec, libvpx should support dynamic resolution changes. > > Add dynamic resolution encoding support in libvpx. > > Only single pass mode with no look ahead is supported for variable > resolution encoding without initialization. >
Do you mean /reinitialization/? > cmdline: > ffmpeg -noautoscale -y -i ./reinit-large_420_8-to-small_420_8.h264 > -pix_fmt yuv420p -c:v libvpx-vp9 lena.ivf > Do you have a reference command line for creating the source content? > Filed an issue in https://bugs.chromium.org/p/webm/issues/detail?id=1642 > to fix some memory problem. > It may be worth getting that bug resolved before landing this change if existing library versions are buggy. > Signed-off-by: Linjie Fu <linjie...@intel.com> > --- > libavcodec/libvpxenc.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > index feb52ea..3d2295d 100644 > --- a/libavcodec/libvpxenc.c > +++ b/libavcodec/libvpxenc.c > @@ -1067,6 +1067,28 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket > *pkt, > int res, coded_size; > vpx_enc_frame_flags_t flags = 0; > > + if (frame && (avctx->width != frame->width || > + avctx->height != frame->height)) { > + avctx->width = frame->width; > + avctx->height = frame->height; > + > + struct vpx_codec_enc_cfg new_cfg = { 0 }; > + memcpy(&new_cfg, ctx->encoder.config.enc, > + sizeof(struct vpx_codec_enc_cfg)); > + > + new_cfg.g_w = frame->width; > + new_cfg.g_h = frame->height; > + if (new_cfg.g_lag_in_frames > 1 || > + new_cfg.g_pass != VPX_RC_ONE_PASS) { > + av_log(avctx, AV_LOG_WARNING, "Only single pass mode " > + "with no look ahead is supported for variable " > + "resolution encoding without initialization.\n"); Would it be better to warn and reinitialize as in your earlier patch rather than changing the settings from the user? > + new_cfg.g_pass = VPX_RC_ONE_PASS; > + new_cfg.g_lag_in_frames = 0; > + } > + vpx_codec_enc_config_set(&ctx->encoder, &new_cfg); > + } > + > if (frame) { > rawimg = &ctx->rawimg; > rawimg->planes[VPX_PLANE_Y] = frame->data[0]; > @@ -1075,6 +1097,8 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket > *pkt, > rawimg->stride[VPX_PLANE_Y] = frame->linesize[0]; > rawimg->stride[VPX_PLANE_U] = frame->linesize[1]; > rawimg->stride[VPX_PLANE_V] = frame->linesize[2]; > + rawimg->d_w = frame->width; > + rawimg->d_h = frame->height; > if (ctx->is_alpha) { > uint8_t *u_plane, *v_plane; > rawimg_alpha = &ctx->rawimg_alpha; > -- > 2.7.4 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".