[FFmpeg-devel] [PATCH] avfilter/pad: round output width/height up instead of down. Fixes bugs #1618 and #8475.

Ivan Middleton ivan.middleton at gmail.com
Mon Jan 27 05:53:18 EET 2020


The pad filter is currently broken for cases where all of the following hold:

(1) chroma subsampling exists (very common),

(2) an input dimension is odd (uncommon), and

(3) the corresponding output dimension is either the same as the input,
or an expression like "ow-iw" or "oh-ih" is used to place the image at
the right/bottom edge and the extra padding is even in size.

The cause of the breakage is essentially that the output width and
height are being rounded downward, causing the image to exceed the
padded area slightly.

It seems best to me to simply round the output width/height up instead 
of down, so I've attached a patch to do that. This fixes bugs #1618 and
#8475.

Commands to reproduce the bug:

# create 15x15 test jpeg with 4:2:0 subsampling
ffmpeg -f lavfi -i color=red:15x15,format=rgb24 -vframes 1 -vf format=yuvj420p red.jpg

# output size = input size. fails
ffmpeg -i red.jpg -vf pad=iw:ih:0:0 pad1.png

# input at bottom right of output. fails
ffmpeg -i red.jpg -vf pad=iw+16:ih+16:ow-iw:oh-ih pad2.png

Ivan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avfilter-pad-round-output-width-height-up-instead-of.patch
Type: text/x-diff
Size: 1124 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200126/8113bc53/attachment.patch>


More information about the ffmpeg-devel mailing list