GNOME Bugzilla – Bug 696019
videoscale does not preserve DAR with add-borders=TRUE
Last modified: 2013-03-21 12:47:20 UTC
Created attachment 239085 [details] Corrected calculation of DAR and border size in gst_video_scale_set_info When rescaling a video-stream from 1280x720 with PAR=1/1 to 720x576 with PAR=64/45 (both have a DAR=16/9) videoscale adds black borders, although they should be superflous, and the resulting picture is shrinked in height. This can be reproduced with gst-launch-1.0 videotestsrc ! video/x-raw, width=1280, height=720, pixel-aspect-ratio=1/1 ! videoscale add-borders=TRUE ! video/x-raw, width=720, height=576, pixel-aspect-ratio=64/45 ! autovideosink I've found the reason in gst_video_scale_set_info: The DAR on the sink side is calculated using the PAR on the src side. While checking the function, I found a second flaw: When calculating the size of the borders that should be added, the ratio of the destination width and height is calculated as the product of the DAR on the sink side and the PAR on the src side. However, one has to use the inverse of the PAR on the src side. This error results in wrong DARs, too. It can be reproduced with gst-launch-1.0 videotestsrc ! video/x-raw, width=1020, height=576, pixel-aspect-ratio=64/45 ! videoscale add-borders=TRUE ! video/x-raw, width=720, height=576, pixel-aspect-ratio=64/45 ! autovideosink The black borders are far to big. A minor correction: In the debug message at the end of the same function the PAR of the src side is used instead of the PAR of the sink side. I've put the corrections into the attached file. With these corrections the two examples work as expected.
*** Bug 694409 has been marked as a duplicate of this bug. ***
I've just found another flaw in the very same function gst_video_scale_set_info. When using caps with the same width and height but different pixel-aspect-ratio on videoscale with add-borders=TRUE, the base transform is set to passthrough mode. As a result the DAR of the picture is changed and no borders are added. This can be reconstructed with gst-launch-1.0 videotestsrc ! video/x-raw, width=720, height=576, pixel-aspect-ratio=64/45 ! videoscale add-borders=TRUE ! video/x-raw, width=720, height=576, pixel-aspect-ratio=1/1 ! autovideosink The condition for passthrough mode should be, that width and height of src and sink are identical and that no borders are to be added. I've added this correction in my second attachment.
Created attachment 239178 [details] Corrected calculation of DAR and border size, now also with correct handling of same width/height, but different PAR
Could you please attach that as a patch against latest GIT master? Use "git format-patch" for that
Created attachment 239401 [details] [review] Corrected calculation of DAR and border size, now also with correct handling of same width/height, but different PAR OK, I've created a patch against the current master. But I wasn't able to test it, since I have not installed GStreamer 1.1.0 like the configure script demanded. There have been no changes since 1.0.5 to the function I modified, though, so I hope it works.
commit 8e791d52aa7b069923faa787b7d4ad6e67b5eec2 Author: Jan Schole <jan581984@web.de> Date: Wed Mar 20 19:34:06 2013 +0100 videoscale: Correct DAR and border calculations changed: gst_video_scale_set_info in gst/videoscale/gstvideoscale.c DAR on sink side now calculated with PAR on sink side ratio of output width/height now calculated with inverse PAR additional condition that borders are 0:0 for passthrough mode https://bugzilla.gnome.org/show_bug.cgi?id=696019
*** Bug 691827 has been marked as a duplicate of this bug. ***