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 753824 - assrender: render overlay using the video output window size
assrender: render overlay using the video output window size
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal enhancement
: 1.7.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 604138 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-08-19 13:05 UTC by Arnaud Vrac
Modified: 2018-05-04 11:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
handle reconfigure event on source pad (4.61 KB, patch)
2015-08-19 13:06 UTC, Arnaud Vrac
none Details | Review
render the subtitles with the proper aspect (3.55 KB, patch)
2015-08-19 13:06 UTC, Arnaud Vrac
none Details | Review
use the window size from downstream (4.70 KB, patch)
2015-08-19 13:06 UTC, Arnaud Vrac
none Details | Review
render the subtitles with the proper aspect (3.55 KB, patch)
2015-08-19 16:12 UTC, Arnaud Vrac
none Details | Review
improve negotiation (12.15 KB, patch)
2015-08-19 16:12 UTC, Arnaud Vrac
none Details | Review
use the window size from downstream (5.18 KB, patch)
2015-08-19 16:12 UTC, Arnaud Vrac
none Details | Review
video: store overlay composition rectangle render geometry as floating point (16.90 KB, patch)
2015-08-21 12:20 UTC, Arnaud Vrac
none Details | Review
assrender: render the subtitles with the proper aspect (3.55 KB, patch)
2015-09-28 12:50 UTC, Arnaud Vrac
committed Details | Review
assrender: improve overlay composition meta negotiation (12.15 KB, patch)
2015-09-28 12:51 UTC, Arnaud Vrac
committed Details | Review
assrender: use the window size from downstream (5.36 KB, patch)
2015-09-28 12:51 UTC, Arnaud Vrac
committed Details | Review

Description Arnaud Vrac 2015-08-19 13:05:47 UTC
Here is a series of patches to render the overlay to at the resolution of the video output window, like it was done recently in basetextoverlay. The output looks much better when the video is scaled up, and the performance is better when the video is scaled down.
Comment 1 Arnaud Vrac 2015-08-19 13:06:04 UTC
Created attachment 309581 [details] [review]
handle reconfigure event on source pad
Comment 2 Arnaud Vrac 2015-08-19 13:06:23 UTC
Created attachment 309582 [details] [review]
render the subtitles with the proper aspect
Comment 3 Arnaud Vrac 2015-08-19 13:06:37 UTC
Created attachment 309583 [details] [review]
use the window size from downstream
Comment 4 Sebastian Dröge (slomo) 2015-08-19 13:46:56 UTC
Review of attachment 309583 [details] [review]:

::: ext/assrender/gstassrender.c
@@ +792,3 @@
+  guint frame_height = render->window_height;
+
+  if (video_aspect >= window_aspect)

Why? Add a comment at least :)
Comment 5 Arnaud Vrac 2015-08-19 16:11:20 UTC
You're right, I should have tested more before posting the patches. I've also found cases where negotiation would fail, so I've copied the negotation function from basetextoverlay, which was improved a lot recently.

Unfortunately I cannot seem to be able to use the gl elements, so I cannot test against them. For some reason they use mesa drivers instead of my nvidia drivers. I've tested against a custom sink though, that does handle overlay composition.
Comment 6 Arnaud Vrac 2015-08-19 16:12:00 UTC
Created attachment 309613 [details] [review]
render the subtitles with the proper aspect
Comment 7 Arnaud Vrac 2015-08-19 16:12:19 UTC
Created attachment 309614 [details] [review]
improve negotiation
Comment 8 Arnaud Vrac 2015-08-19 16:12:38 UTC
Created attachment 309616 [details] [review]
use the window size from downstream
Comment 9 Nicolas Dufresne (ndufresne) 2015-08-19 22:30:59 UTC
Did some testing here, there seems to be negotiation issues, could not find why yes. Then I managed to force it upload for now, so I could test the rendering. It seems that the render layout (and wrapping) changes depending on the display size. This should never ever happen.

Short story, this patchset need serious testing.
Comment 10 Arnaud Vrac 2015-08-20 07:36:50 UTC
As discussed on IRC, the negotiation issue is a bug in the gl elements which also affects textoverlay (Bug #753850).

I disabled hinting in libass and I get better results at small sizes.

However, I don't believe it's possible to get pixel perfect rendering with the current overlay API, because of rounding errors. This is because the overlay rectangle render geometry is converted to video coordinates. Then the sink will convert the rectangle render geometry back to window coordinates, resulting in a loss of precision.

This wouldn't matter if the overlay rectangle had a constant size, however assrender tries to minimize the composition rectangle size, by computing the bounding box of the rendered image in the video. Since the bounding box can change between each frame, this can lead in slight shifts between frames.

Two solutions:
 - add an api to set floating point render size on the overlay rectangles
 - just allocate overlay rectangles of the full frame size, but it wastes a lot of memory and slows down rendering.
Comment 11 Sebastian Dröge (slomo) 2015-08-20 07:39:56 UTC
(In reply to Arnaud Vrac from comment #10)

> Two solutions:
>  - add an api to set floating point render size on the overlay rectangles

I think this sounds like the best solution, and is consistent with e.g. the navigation events.
Comment 12 Arnaud Vrac 2015-08-20 16:05:27 UTC
Any idea how I can name those functions ? ;)
Comment 13 Arnaud Vrac 2015-08-21 12:20:40 UTC
Created attachment 309812 [details] [review]
video: store overlay composition rectangle render geometry as floating point

I haven't added a gst_video_overlay_rectangle_new_raw version that uses floating point coordinates.
Comment 14 Arnaud Vrac 2015-09-28 12:50:57 UTC
Created attachment 312295 [details] [review]
assrender: render the subtitles with the proper aspect
Comment 15 Arnaud Vrac 2015-09-28 12:51:32 UTC
Created attachment 312297 [details] [review]
assrender: improve overlay composition meta negotiation
Comment 16 Arnaud Vrac 2015-09-28 12:51:55 UTC
Created attachment 312298 [details] [review]
assrender: use the window size from downstream
Comment 17 Arnaud Vrac 2015-09-28 12:53:20 UTC
I've rebased the patches against master (1.7). Please ignore the gst-video patch for now, it's only useful when an element wants to transform the overlay composition before the sink.
Comment 18 Sebastian Dröge (slomo) 2015-10-02 14:18:59 UTC
Comment on attachment 312298 [details] [review]
assrender: use the window size from downstream

commit ecdc7bb37d896e9bd2da2593157b460bca0d42e0
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Wed Aug 19 17:18:31 2015 +0200

    assrender: Use the window size from downstream
    
    This allows rendering the overlay at a resolution matching the video
    resolution.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=753824

commit f021d32beffc74026cbae891c234dd105c1fcf65
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Thu Sep 4 18:16:00 2014 +0200

    assrender: Improve negotiation
    
    This is mostly a copy/paste of the negotiation function in
    basetextoverlay, which was improved recently to handle many more cases.
    
    This will allow us to negotiate a window size with downstream.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=753824

commit 31c69023738b13f2809a292dba04ddf852d474b5
Author: Arnaud Vrac <avrac@freebox.fr>
Date:   Wed Aug 19 13:44:35 2015 +0200

    assrender: render the subtitles with the proper aspect
    
    This bumps the libass version requirement to 0.10.2.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=753824
Comment 19 Sebastian Dröge (slomo) 2015-10-02 14:19:27 UTC
Can you move the rectangle patch into a new bug? Thanks :)
Comment 20 Edward Hervey 2018-05-04 11:25:13 UTC
*** Bug 604138 has been marked as a duplicate of this bug. ***