After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 696019 - videoscale does not preserve DAR with add-borders=TRUE
videoscale does not preserve DAR with add-borders=TRUE
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
1.0.5
Other Linux
: Normal normal
: 1.0.6
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 691827 694409 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-03-17 23:50 UTC by Jan Schole
Modified: 2013-03-21 12:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Corrected calculation of DAR and border size in gst_video_scale_set_info (50.09 KB, text/x-csrc)
2013-03-17 23:50 UTC, Jan Schole
  Details
Corrected calculation of DAR and border size, now also with correct handling of same width/height, but different PAR (50.16 KB, text/x-csrc)
2013-03-18 18:55 UTC, Jan Schole
  Details
Corrected calculation of DAR and border size, now also with correct handling of same width/height, but different PAR (2.83 KB, patch)
2013-03-20 18:46 UTC, Jan Schole
none Details | Review

Description Jan Schole 2013-03-17 23:50:09 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.
Comment 1 Tim-Philipp Müller 2013-03-17 23:59:54 UTC
*** Bug 694409 has been marked as a duplicate of this bug. ***
Comment 2 Jan Schole 2013-03-18 18:52:27 UTC
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.
Comment 3 Jan Schole 2013-03-18 18:55:02 UTC
Created attachment 239178 [details]
Corrected calculation of DAR and border size, now also with correct handling of same width/height, but different PAR
Comment 4 Sebastian Dröge (slomo) 2013-03-19 13:12:37 UTC
Could you please attach that as a patch against latest GIT master? Use "git format-patch" for that
Comment 5 Jan Schole 2013-03-20 18:46:26 UTC
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.
Comment 6 Sebastian Dröge (slomo) 2013-03-21 10:16:17 UTC
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
Comment 7 Tim-Philipp Müller 2013-03-21 10:24:05 UTC
*** Bug 691827 has been marked as a duplicate of this bug. ***