[FFmpeg-devel] [PATCH] avfilter/vf_pad: add aspect option

Ricardo Constantino wiiaboo at gmail.com
Mon Apr 3 21:43:17 EEST 2017


On 3 April 2017 at 19:18, Paul B Mahol <onemda at gmail.com> wrote:

> On 4/3/17, Ricardo Constantino <wiiaboo at gmail.com> wrote:
> > On 2 April 2017 at 22:13, Paul B Mahol <onemda at gmail.com> wrote:
> >
> >> On 4/2/17, Paul B Mahol <onemda at gmail.com> wrote:
> >> > Signed-off-by: Paul B Mahol <onemda at gmail.com>
> >> > ---
> >> >  doc/filters.texi     |  3 +++
> >> >  libavfilter/vf_pad.c | 14 ++++++++++++++
> >> >  2 files changed, 17 insertions(+)
> >> >
> >> > +    if (adjusted_aspect.num && adjusted_aspect.den) {
> >> > +        adjusted_aspect = av_mul_q(adjusted_aspect, av_make_q(s->w,
> >>                                                        ^ changed to
> >> sample aspect ratio locally.
> >>
>
> Have you missed what I wrote above?
>
> > Shouldn't this av_mul_q be a
> > av_div_q(adjusted_aspect, inlink->sample_aspect_ratio) instead?
> >
> > That way it won't try to expand 40/33 SAR 704x480 to 1034x480 but
> > instead leave it as 704x480.
>
> Why div_q ?
>

with av_mul_q(adjusted_aspect, inlink->sample_aspect_ratio):

$ ffmpeg -f lavfi -i "color=s=704x480,setsar=40/33" -vf
pad=aspect=16/9,scale=iw*sar:ih -vframes 1 -f null - -v verbose 2>&1 | grep
-E "(Parsed_pad|Parsed_scale)"
[Parsed_scale_1 @ 000001e46c6c60a0] w:iw*sar h:ih flags:'bicubic' interl:0
[Parsed_pad_0 @ 000001e46c6c5bc0] w:704 h:480 -> w:1034 h:480 x:0 y:0
color:0x000000FF
[Parsed_scale_1 @ 000001e46c6c60a0] w:1034 h:480 fmt:yuv420p sar:40/33 ->
w:1253 h:480 fmt:yuv420p sar:3760/3759 flags:0x4

with av_div_q(adjusted_aspect, inlink->sample_aspect_ratio):

$ ffmpeg -f lavfi -i "color=s=704x480,setsar=40/33" -vf
pad=aspect=16/9,scale=iw*sar:ih -vframes 1 -f null - -v verbose 2>&1 | grep
-E "(Parsed_pad|Parsed_scale)"
[Parsed_scale_1 @ 000001522e496720] w:iw*sar h:ih flags:'bicubic' interl:0
[Parsed_pad_0 @ 000002b8a29c8260] w:704 h:480 -> w:704 h:480 x:0 y:0
color:0x000000FF
[Parsed_scale_1 @ 000001522e496720] w:704 h:480 fmt:yuv420p sar:40/33 ->
w:853 h:480 fmt:yuv420p sar:2560/2559 flags:0x4


More information about the ffmpeg-devel mailing list