pad filter fails in certain edge cases because of rounding
|Reported by:||Ivan Middleton||Owned by:|
|Blocking:||Reproduced by developer:||no|
|Analyzed by developer:||no|
In certain cases, the
pad filter fails to configure itself properly. Here's an example, using imagemagick to create an appropriate test file:
$ convert -size 15x15 xc:red -sampling-factor 4:2:0 red.jpg $ ffmpeg -i red.jpg -vf pad=iw+16:ih+16:ow-iw:oh-ih pad.png ... ...Input area 16:16:31:31 not within the padded area 0:0:30:30...
It seems like
oh-ih should always work as values of
y; this should put the image in the lower right corner.
The failure occurs because the values of
w:h:x:y are first computed as
31:31:16:16 and then rounded down (via
30:30:16:16 due to chroma considerations. Since the values of
h have shrunk but
y have not, the image is no longer validly placed.
A possible solution is to round off
h before evaluating
y. In my example, this would result in
w:h being evaluated as
31:31 and rounded to
x:y being evaluated as
15:15 and rounded to