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 729896 - glupload: Ignores stride when uploading raw data
glupload: Ignores stride when uploading raw data
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal blocker
: 1.3.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-05-09 22:22 UTC by Nicolas Dufresne (ndufresne)
Modified: 2014-05-13 15:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gl/upload: update the videoinfo on mapping the video frame (1.67 KB, patch)
2014-05-11 00:32 UTC, Matthew Waters (ystreet00)
needs-work Details | Review
gl/upload: update the videoinfo on mapping the video frame (1.04 KB, patch)
2014-05-11 02:51 UTC, Matthew Waters (ystreet00)
committed Details | Review
glmemory: Fix handling of stride with alignement larger then 8 (1.96 KB, patch)
2014-05-12 23:50 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review
gl/colorconvert: use the texture scaling from the glmemory (6.45 KB, patch)
2014-05-13 01:09 UTC, Matthew Waters (ystreet00)
none Details | Review
gl/colorconvert: use the texture scaling from the glmemory (7.36 KB, patch)
2014-05-13 04:06 UTC, Matthew Waters (ystreet00)
committed Details | Review

Description Nicolas Dufresne (ndufresne) 2014-05-09 22:22:36 UTC
The stride is not handled properly in gst_gl_memory_wrapped_texture(), which end up with an out texture size smaller then required, and a silent failure follows.

I've already added a fix to update the video_info base on the info optain by doing gst_video_frame_map (take video info into account), but the rest of the code does not seem to follow very well and need more attention.
Comment 1 Nicolas Dufresne (ndufresne) 2014-05-09 23:03:12 UTC
commit afea9c6fe17f4508670cc2221147f2d2a5cca6f5
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Fri May 9 18:59:46 2014 -0400

    gl: Fix some of the error handling

It does not fail silently anymore, it actually display something but stride is clearly wrong.
Comment 2 Matthew Waters (ystreet00) 2014-05-10 12:07:13 UTC
Every time the format can change, one should call gst_gl_upload_set_format which should deinit the GL resources and recreate (at the correct size) on the next _draw call (only if required).
Comment 3 Matthew Waters (ystreet00) 2014-05-10 13:01:27 UTC
gst_gl_memory_wrapped_texture is currently only ever used for the output texture of the converted video frame which doesn't need any special stride information associated with it.

That doesn't mean that we don't need to add a stride argument to the function definition like all the other glmemory functions.  It would be useful for the download case where we need to pack the data according to the stride.
Comment 4 Nicolas Dufresne (ndufresne) 2014-05-10 16:44:20 UTC
Ok, this mean the texture is created too soon. Because you only get the video meta on first frame. Also, you have no guaranty that it won't change over time. So what we probably need is to call gst_gl_upload_set_format() everytime and add the intelligence to not do anything if nothing important changed (I guess size is what we need to watch for right ?).

This matches with the problems I'm getting. We can revert the patch to update the video info, this seemed more right, but is wrong as you mentioned.
Comment 5 Matthew Waters (ystreet00) 2014-05-10 23:34:41 UTC
Simply call gst_gl_upload_set_format whenever the size/format may change.  It should perform all of that :).
Comment 6 Matthew Waters (ystreet00) 2014-05-11 00:32:05 UTC
Created attachment 276306 [details] [review]
gl/upload: update the videoinfo on mapping the video frame
Comment 7 Nicolas Dufresne (ndufresne) 2014-05-11 01:00:40 UTC
Review of attachment 276306 [details] [review]:

Indeed, just noticed now the call to gst_video_info_is_equal (&upload->in_info, in_info) (which I didn't know existed ;-P). Thanks again for your time.
Comment 8 Nicolas Dufresne (ndufresne) 2014-05-11 01:02:18 UTC
Review of attachment 276306 [details] [review]:

Indeed, just noticed now the call to gst_video_info_is_equal (&upload->in_info, in_info) (which I didn't know existed ;-P). Thanks again for your time.
Comment 9 Nicolas Dufresne (ndufresne) 2014-05-11 01:02:18 UTC
Review of attachment 276306 [details] [review]:

Indeed, just noticed now the call to gst_video_info_is_equal (&upload->in_info, in_info) (which I didn't know existed ;-P). Thanks again for your time.
Comment 10 Nicolas Dufresne (ndufresne) 2014-05-11 01:02:18 UTC
Review of attachment 276306 [details] [review]:

Indeed, just noticed now the call to gst_video_info_is_equal (&upload->in_info, in_info) (which I didn't know existed ;-P). Thanks again for your time.
Comment 11 Nicolas Dufresne (ndufresne) 2014-05-11 01:02:18 UTC
Review of attachment 276306 [details] [review]:

Indeed, just noticed now the call to gst_video_info_is_equal (&upload->in_info, in_info) (which I didn't know existed ;-P). Thanks again for your time.
Comment 12 Nicolas Dufresne (ndufresne) 2014-05-11 01:02:18 UTC
Review of attachment 276306 [details] [review]:

Indeed, just noticed now the call to gst_video_info_is_equal (&upload->in_info, in_info) (which I didn't know existed ;-P). Thanks again for your time.
Comment 13 Nicolas Dufresne (ndufresne) 2014-05-11 01:02:18 UTC
Review of attachment 276306 [details] [review]:

Indeed, just noticed now the call to gst_video_info_is_equal (&upload->in_info, in_info) (which I didn't know existed ;-P). Thanks again for your time.
Comment 14 Nicolas Dufresne (ndufresne) 2014-05-11 01:02:18 UTC
Review of attachment 276306 [details] [review]:

Indeed, just noticed now the call to gst_video_info_is_equal (&upload->in_info, in_info) (which I didn't know existed ;-P). Thanks again for your time
Comment 15 Nicolas Dufresne (ndufresne) 2014-05-11 01:05:07 UTC
Review of attachment 276306 [details] [review]:

Sorry for the noise, it's wall all unresponsive and then got that. Though I found a problem in the patch.

::: gst-libs/gst/gl/gstglupload.c
@@ +335,2 @@
   /* update the video info from the one updated by frame_map using video meta */
+  gst_gl_upload_set_format (upload, &v_info);

Actually, that's going to set the old config again.
Comment 16 Nicolas Dufresne (ndufresne) 2014-05-11 01:06:15 UTC
just doing gst_gl_upload_set_format (upload, &frame->info) should do.
Comment 17 Nicolas Dufresne (ndufresne) 2014-05-11 01:18:58 UTC
The missing detail is that in gst_video_frame_map(), the info reference is not modified. Instead a copy is made and update, and found in frame->info.
Comment 18 Matthew Waters (ystreet00) 2014-05-11 02:51:07 UTC
Created attachment 276309 [details] [review]
gl/upload: update the videoinfo on mapping the video frame

Ah!  I did not know that.
Comment 19 Nicolas Dufresne (ndufresne) 2014-05-11 21:16:10 UTC
Review of attachment 276309 [details] [review]:

Excellent !
Comment 20 Matthew Waters (ystreet00) 2014-05-12 12:14:22 UTC
commit f14e5ea02702f1cbfce013f7161a45615d609dcf
Author: Matthew Waters <ystreet00@gmail.com>
Date:   Sun May 11 12:48:52 2014 +1000

    gl/upload: update the video info on mapping a video frame
    
    The buffer should contain the most specific data on how the data is
    formatted.  We should use this information.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729896
Comment 21 Nicolas Dufresne (ndufresne) 2014-05-12 16:50:28 UTC
Reopening, as the stride handling is still broken. Looks like the information is set correctly, but something fails using it a bit deeper.

The bug isn't fixed for gl_upload_meta where the we do endup doing a real upload (even though I doubt we'll have special strides).

For the handling of video meta, when we do upload, I'm wondering if we need of not to correctly copy the stride and offset over.
Comment 22 Nicolas Dufresne (ndufresne) 2014-05-12 22:28:03 UTC
Still not fixed, but found this important issue:

commit e0cfd6e26b53b9530b0a3494b883c490714b8da7
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Mon May 12 13:18:50 2014 -0400

    video-info: Also check the stride and offset are equal
    
    gst_video_info_is_equal() was not checking if stride and offset
    had changed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729896


Which cause the old config to remain. After this change we would failed, cause texture was gone.

commit 2d0a791348c0a37cc90c99741cd64527d90d7826
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Mon May 12 13:50:47 2014 -0400

    glupload: Ensure we still have a texture after upload_set_format()
    
    gst_gl_upload_set_format() resets the upload, hence the texture.
    So we need to ensure we have a texture after this call when
    uploading.

And I added patches to address the issue I mentioned.

commit 864e1511c7cf38c1c24e1c41816bb75f71f52916
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Mon May 12 12:59:59 2014 -0400

    glupload: Correctly update the video info from video meta
    
    Using gst_video_info_set_format() isn't complete when updating
    a video info from video meta.

commit 4f84a6124a719c2a9c927b5e91b36f5d5b20d617
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Mon May 12 12:57:18 2014 -0400

    glupload: Correctly update video info in upload fallback
    
    When the upload accelerated method fails, we fallback to an upload,
    but the video info was not correctly updated.

But sadly, I still get stride issues.
Comment 23 Nicolas Dufresne (ndufresne) 2014-05-12 22:47:06 UTC
Should have done that before, but reading the doc:

Specifies the alignment requirements for the start of each pixel row in memory.
     The allowable values are
              1 (byte-alignment),
              2 (rows aligned to even-numbered bytes),
              4 (word-alignment), and
              8 (rows start on double-word boundaries).

And I need 16 pixels alignment (BGRA), which would mean an invalid value or 64 bytes. I guess for this case we need a fallback, e.g. use the coordinate scaling in place.
Comment 24 Matthew Waters (ystreet00) 2014-05-12 22:52:25 UTC
That's what gst_gl_color_convert_set_texture_scaling() is for :).  But it seems to not be used for GLES2 :/
Comment 25 Nicolas Dufresne (ndufresne) 2014-05-12 23:48:59 UTC
Hey, that's what I found, but the method we use is wrong. The indexer will not skip lines correctly. I've did an experiment when I create a larger texture, and it works, but scaling seems ignored.
Comment 26 Nicolas Dufresne (ndufresne) 2014-05-12 23:50:15 UTC
Created attachment 276417 [details] [review]
glmemory: Fix handling of stride with alignement larger then 8
Comment 27 Nicolas Dufresne (ndufresne) 2014-05-13 00:07:43 UTC
Looks like this patch is nearly correct. What's wrong now is the scaling implementation in the converter. I'd op for removing the set_scaling() and update the scaling uniforms in _preform() from the memory values (something we don't do at the moment).
Comment 28 Matthew Waters (ystreet00) 2014-05-13 00:26:16 UTC
Review of attachment 276417 [details] [review]:

Looks good
Comment 29 Matthew Waters (ystreet00) 2014-05-13 01:09:53 UTC
Created attachment 276420 [details] [review]
gl/colorconvert: use the texture scaling from the glmemory
Comment 30 Matthew Waters (ystreet00) 2014-05-13 04:06:58 UTC
Created attachment 276430 [details] [review]
gl/colorconvert: use the texture scaling from the glmemory

Should also remove the function definition in the header.
Comment 31 Nicolas Dufresne (ndufresne) 2014-05-13 15:46:00 UTC
Comment on attachment 276417 [details] [review]
glmemory: Fix handling of stride with alignement larger then 8

commit d4bcef3204709159713ff1630978ecac0bd91dc9
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Mon May 12 19:29:45 2014 -0400

    glmemory: Fix handling of stride with alignement larger then 8
    
    Setting a scaled factor for X coordinate is not enough as the indexer
    will still think stride is shorter and will not fully skip it. Instead,
    update width, so the lines are as expected. Combined with the scale, it
    will hide the cropped portion.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729896
Comment 32 Nicolas Dufresne (ndufresne) 2014-05-13 15:46:23 UTC
Comment on attachment 276430 [details] [review]
gl/colorconvert: use the texture scaling from the glmemory

commit 1e90a68aec966d6a56e839db1cf759716b5583d8
Author: Matthew Waters <ystreet00@gmail.com>
Date:   Tue May 13 10:53:19 2014 +1000

    gl/colorconvert: use the texture scaling from the gl memory
    
    The colorconvert values were not being used at all.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729896
Comment 33 Nicolas Dufresne (ndufresne) 2014-05-13 15:47:30 UTC
Works now, and it's all clean, no green border, no visible rounding issue in general. Thanks for the good help.