From: Linjie Fu <linjie.justin.fu@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Linjie Fu <linjie.justin.fu@gmail.com> Subject: [FFmpeg-devel] [PATCH] libavfilter/vf_pad: Try round up w/h for odd resolution to avoid failure Date: Sun, 1 May 2022 17:10:35 +0800 Message-ID: <20220501091035.68362-1-linjie.justin.fu@gmail.com> (raw) Try round_up output w/h for the clips with odd resolution to avoid failure if no padding is required(e.g. iw/ih+0+0). $ffmpeg -i input.mp4 -vf "scale=1241x1234,pad=iw+0+0:ih+3+3:0:3" -f null - Before: Round down to 1240x1234 and failed since s->w < inlink->w (e.g. 1240 < 1241) [Parsed_pad_1 @ 0x7f849090f840] Padded dimensions cannot be smaller than input dimensions. [Parsed_pad_1 @ 0x7f849090f840] Failed to configure input pad on Parsed_pad_1 Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:0 Conversion failed! After: Try to Round up for odd resolution (1241x1234 -> 1242x1240) Stream #0:0(und): Video: wrapped_avframe, yuv420p(tv, progressive), 1242x1240 Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com> --- libavfilter/vf_pad.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index e52f7284d4..c9a0a75630 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -107,6 +107,7 @@ static int config_input(AVFilterLink *inlink) AVFilterContext *ctx = inlink->dst; PadContext *s = ctx->priv; AVRational adjusted_aspect = s->aspect; + int round_w, round_h; int ret; double var_values[VARS_NB], res; char *expr; @@ -178,9 +179,13 @@ static int config_input(AVFilterLink *inlink) if (s->y < 0 || s->y + inlink->h > s->h) s->y = var_values[VAR_Y] = (s->h - inlink->h) / 2; - s->w = ff_draw_round_to_sub(&s->draw, 0, -1, s->w); - s->h = ff_draw_round_to_sub(&s->draw, 1, -1, s->h); - /* sanity check params */ + round_w = ff_draw_round_to_sub(&s->draw, 0, -1, s->w); + round_h = ff_draw_round_to_sub(&s->draw, 1, -1, s->h); + + s->w = round_w < inlink->w ? ff_draw_round_to_sub(&s->draw, 0, 1, s->w) : round_w; + s->h = round_h < inlink->h ? ff_draw_round_to_sub(&s->draw, 0, 1, s->h) : round_h; + + /* sanity check params */ if (s->w < inlink->w || s->h < inlink->h) { av_log(ctx, AV_LOG_ERROR, "Padded dimensions cannot be smaller than input dimensions.\n"); return AVERROR(EINVAL); -- 2.31.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2022-05-01 9:12 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220501091035.68362-1-linjie.justin.fu@gmail.com \ --to=linjie.justin.fu@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git