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 790149 - vaapipostproc: Does not maintain aspect ratio when scaling
vaapipostproc: Does not maintain aspect ratio when scaling
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer-vaapi
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-11-10 01:30 UTC by Nicolas Dufresne (ndufresne)
Modified: 2018-11-03 15:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
vaapipostproc: if no p-a-r in out caps define a range (1.35 KB, patch)
2018-01-18 19:46 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
vaapipostproc: remove spurious code (1007 bytes, patch)
2018-01-18 19:46 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
vaapipostproc: keep the display's pixel aspect ratio (5.78 KB, patch)
2018-01-18 19:47 UTC, Víctor Manuel Jáquez Leal
reviewed Details | Review

Description Nicolas Dufresne (ndufresne) 2017-11-10 01:30:05 UTC
When vaapipostproc is being used (notably through vaapidecodebin), the vaapipostproc may endup scaling the video. The problem is that the scaling does not maintain the aspect ratio, which is totally unexpected default behaviour. On can illustrace this with a non scaling display sink.

gst-launch-1.0 videotestsrc ! video/x-raw,width=320,height=240 ! vaapipostproc ! ximagesink

In comparison with:

gst-launch-1.0 videotestsrc ! video/x-raw,width=320,height=240 ! videoscale ! ximagesink
Comment 1 Víctor Manuel Jáquez Leal 2017-11-15 11:16:18 UTC
I don't deny there might be a problem handling the display-aspect-ratio with vaapipostproc, but I can't reproduce it, in my setup, with those examples.
Comment 2 Nicolas Dufresne (ndufresne) 2017-11-15 13:56:14 UTC
I didn't check yet, but Wich layer of abstraction take care of that ? If it's not reliable it might be something inside the driver, with different bug depending on the driver version ?
Comment 3 Víctor Manuel Jáquez Leal 2017-11-15 16:38:15 UTC
oops! I can reproduce it!
Comment 4 Nicolas Dufresne (ndufresne) 2017-11-19 18:23:52 UTC
Just to keep the ball rolling, can vaapipostproc add black bars, top/bottom or left/right depending ?

I'm asking because scalers have two options:

a) they maintain aspect ratio by negotiating output caps that do respect it
b) scale to the negotiated output size, and add black borders as needed
Comment 5 Nicolas Dufresne (ndufresne) 2017-12-06 20:26:42 UTC
Any answer to my question ?
Comment 6 Víctor Manuel Jáquez Leal 2017-12-07 14:57:49 UTC
(In reply to Nicolas Dufresne (stormer) from comment #4)
> Just to keep the ball rolling, can vaapipostproc add black bars, top/bottom
> or left/right depending ?
> 
> I'm asking because scalers have two options:
> 
> a) they maintain aspect ratio by negotiating output caps that do respect it
> b) scale to the negotiated output size, and add black borders as needed

Honestly, I don't know for sure, I've never tried. But, reading the gstvaapifilter code, and the VA-API, it seems possible to do option b):

https://cgit.freedesktop.org/gstreamer/gstreamer-vaapi/tree/gst-libs/gst/vaapi/gstvaapifilter.c#n1444

Since it is possible to set a destine rectangle with a specified background color.
Comment 7 Víctor Manuel Jáquez Leal 2018-01-18 19:46:38 UTC
Created attachment 367036 [details] [review]
vaapipostproc: if no p-a-r in out caps define a range

Instead of copying the pixel-aspect-ratio from the sink caps, define
an open range for the src caps pixel-aspect-ratio. Later it will be
defined.
Comment 8 Víctor Manuel Jáquez Leal 2018-01-18 19:46:47 UTC
Created attachment 367037 [details] [review]
vaapipostproc: remove spurious code

This assignation is dead code, since gst_video_info_from_caps() set
to 1 by default.
Comment 9 Víctor Manuel Jáquez Leal 2018-01-18 19:47:03 UTC
Created attachment 367038 [details] [review]
vaapipostproc: keep the display's pixel aspect ratio

Before vaapipostproc will resize the video frame to the window size,
but that broke the display's pixel aspect ratio form the original
video.

This patch will honor the original pixel-aspect-ratio by setting a
target rectangle within the output surface, that means black borders.
Comment 10 Víctor Manuel Jáquez Leal 2018-01-18 19:50:01 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #9)
> Created attachment 367038 [details] [review] [review]
> vaapipostproc: keep the display's pixel aspect ratio
> 
> Before vaapipostproc will resize the video frame to the window size,
> but that broke the display's pixel aspect ratio form the original
> video.
> 
> This patch will honor the original pixel-aspect-ratio by setting a
> target rectangle within the output surface, that means black borders.

This patch works regular with intel-vaapi-driver, it shows some artifacts and the image is not centered.

In the case of mesa amd driver, it is worse since it crashes.

Dunno, perhaps it is a code path no quite tested by drivers. Still, it seems the correct way to do it.
Comment 11 Víctor Manuel Jáquez Leal 2018-01-23 10:47:07 UTC
Attachment 367036 [details] pushed as ea9c52e - vaapipostproc: if no p-a-r in out caps define a range
Attachment 367037 [details] pushed as da77fd5 - vaapipostproc: remove spurious code
Comment 12 Nicolas Dufresne (ndufresne) 2018-02-22 21:29:25 UTC
Review of attachment 367038 [details] [review]:

I think we should get that in before 1.14.
Comment 13 Nicolas Dufresne (ndufresne) 2018-02-22 21:37:30 UTC
Ok, after testing more myself, I agree with you, we'll need to debug the driver, I had a complete system hang and had to reboot:

vainfo: VA-API version: 0.40 (libva )
vainfo: Driver version: Intel i965 driver for Intel(R) Ivybridge Mobile - 1.8.3
Comment 14 Nicolas Dufresne (ndufresne) 2018-02-22 21:37:58 UTC
Review of attachment 367038 [details] [review]:

Again, I don't see anything ovbiously wrong in the this code though ...
Comment 15 GStreamer system administrator 2018-11-03 15:52:08 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/74.