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 731672 - omxvideodec: uses non-standard stride without videometa
omxvideodec: uses non-standard stride without videometa
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-omx
1.2.4
Other Linux
: Normal major
: 1.2.0
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-06-15 00:39 UTC by m][sko
Modified: 2014-07-23 08:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
debug init in omxbufferpool (1.03 KB, patch)
2014-06-22 21:13 UTC, m][sko
committed Details | Review
add videometa properly (811 bytes, patch)
2014-06-22 21:16 UTC, m][sko
needs-work Details | Review

Description m][sko 2014-06-15 00:39:18 UTC
I just try this simple pipeline in my raspberry pi
omxvideodec ! videoscale ! width=half, height=half ! omxh264enc
and it looks like videoscale generate wired or shifted image
and
nearest-neighbour segfault

omx is from git master
Comment 1 m][sko 2014-06-19 08:30:42 UTC
better bug-report

ORC_CODE=emulate \
GST_DEBUG="*:3,omxvideodec:5,omxh264dec:5,omxbufferpool:5" \
gst-launch-1.0  uridecodebin uri="http://live.mdragon.org/test_omx/test.ts" use-buffering=true name=demux  \
 ! tee name="decdata" \
 ! videoconvert \
 ! pngenc \
 ! multifilesink location="%03d.png" sync=true \
 2>&1

and one of the output file
http://live.mdragon.org/test_omx/001.png
Comment 2 Nicolas Dufresne (ndufresne) 2014-06-19 12:40:58 UTC
I think you forgot to attach the logs. Would it be possible to run the same pipeline with the -v option, so we see the formats being negotiated. Also, adding videoconvert traces could help. This looks like a stride issue, we would need a trace to validate that.
Comment 3 Nicolas Dufresne (ndufresne) 2014-06-19 12:42:24 UTC
(oh, and please make sure this isn't fixed in latest 1.2.4 stable release)
Comment 4 Aurélien Zanelli 2014-06-19 14:08:48 UTC
On my side I made a quick test on 1.3.1 on RPi with the following pipeline using the ts file provided:
gst-launch-1.0 filesrc location=~/tmp/test.ts ! tsdemux ! mpegvideoparse ! omxmpeg2videodec ! filesink location= /mnt/nfs/out/out.yuv

And the results is bad. So I think videoconvert is not involved
For information, the negotiated caps between omxvideodec and filesink are:
width: 720
height: 576
format: I420

By the way, I test with some other H264 or MPEG2 files which have the same definition and their output are also bad.
Like Nicolas, I think it's a stride issue. If I have some time, I will check stride handling in omxvideodec.
Comment 5 Nicolas Dufresne (ndufresne) 2014-06-19 15:32:39 UTC
Thanks for the great feed back. Let us know you finding. If videoconvert does not do anything, I would definitely check the stride. Anyone knows the HW required alignment ? This would mean something larger then 16 bytes.
Comment 6 Aurélien Zanelli 2014-06-20 09:59:35 UTC
RPi HW decoder output the video frame with a stride of 736. So it seems that RPi adds padding to align on 32 bytes.
Comment 7 Nicolas Dufresne (ndufresne) 2014-06-20 11:54:24 UTC
Great, very good start! Next step would be to check that GstVideoMeta is added to the buffers, and that the stride in it matches.
Comment 8 m][sko 2014-06-21 17:15:49 UTC
http://cgit.freedesktop.org/gstreamer/gst-omx/tree/omx/gstomxbufferpool.c#n285

should be

pool->add_videometa =
        gst_buffer_pool_config_has_option (config,
        GST_BUFFER_POOL_OPTION_VIDEO_META) == 0;
Comment 9 m][sko 2014-06-22 21:13:10 UTC
Created attachment 278956 [details] [review]
debug init in omxbufferpool
Comment 10 m][sko 2014-06-22 21:16:12 UTC
Created attachment 278957 [details] [review]
add videometa properly
Comment 11 Nicolas Dufresne (ndufresne) 2014-06-23 01:27:18 UTC
Review of attachment 278957 [details] [review]:

::: omx/gstomxbufferpool.c
@@ +290,3 @@
     pool->add_videometa =
         gst_buffer_pool_config_has_option (config,
+        GST_BUFFER_POOL_OPTION_VIDEO_META) == 0;

No, I doubt this is correct. We should add video meta if the option is enabled (not the opposite). Check where the pool is being configured, and make sure we do enable this option. Also, in this case we strictly need vieometa, if downstream don't support that meta we should fail cleanly. Same thing for encoder, if upstream wants to take the pool, but did not enable the meta, we should fail somehow.
Comment 12 Aurélien Zanelli 2014-06-23 08:22:21 UTC
My previous test did not work because filesink doesn't support video meta.
On 1.3.1, videoscale and videoconvert handle video meta unless they are set in passthrough mode.

By the way, Nicolas is right, we should only add video meta if the option is enabled in the pool.

(In reply to comment #11)
> Review of attachment 278957 [details] [review]:
> 
> ::: omx/gstomxbufferpool.c
> @@ +290,3 @@
>      pool->add_videometa =
>          gst_buffer_pool_config_has_option (config,
> +        GST_BUFFER_POOL_OPTION_VIDEO_META) == 0;
> 
> No, I doubt this is correct. We should add video meta if the option is enabled
> (not the opposite).
I agree with that.

> Also, in this case we strictly need vieometa, if
> downstream don't support that meta we should fail cleanly. Same thing for
> encoder, if upstream wants to take the pool, but did not enable the meta, we
> should fail somehow.
If we fail, we won't be able to use filesink or other elements which don't handle video stride. Maybe, we can rather do something in the decoder, or we can handle the stride meta in videoscale/videoconvert/... if downstream element doesn't support even if no other conversion is needed.
Comment 13 m][sko 2014-06-23 10:13:41 UTC
How can I check if downstream element support videometa?

videoscale/videoconvert support videometa
Comment 14 Nicolas Dufresne (ndufresne) 2014-06-23 18:09:35 UTC
(In reply to comment #12)
> > Also, in this case we strictly need vieometa, if
> > downstream don't support that meta we should fail cleanly. Same thing for
> > encoder, if upstream wants to take the pool, but did not enable the meta, we
> > should fail somehow.
> If we fail, we won't be able to use filesink or other elements which don't
> handle video stride. Maybe, we can rather do something in the decoder, or we
> can handle the stride meta in videoscale/videoconvert/... if downstream element
> doesn't support even if no other conversion is needed.

Sorry, my response was clearly incomplete. GstVideoFrame and gst_video_frame_copy() will allow to copy from one stride to another. Just create a frame with "normal" stride, and copy to it as a slow-path fallback. We shouldn't care much about performance, writing raw to filesink is only useful for testing.
Comment 15 Nicolas Dufresne (ndufresne) 2014-06-23 18:14:13 UTC
(In reply to comment #13)
> How can I check if downstream element support videometa?
> 
> videoscale/videoconvert support videometa

If you need example, I have implemented this in -good/sys/v4l2.

has_video_meta =
      gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
Comment 16 Sebastian Dröge (slomo) 2014-06-24 11:07:58 UTC
(In reply to comment #6)
> RPi HW decoder output the video frame with a stride of 736. So it seems that
> RPi adds padding to align on 32 bytes.

The code in gst_omx_buffer_pool_alloc_buffer() should take care of that in theory. However we need a fallback case here if downstream does not support the video meta. Which in your case all elements do? Would be good to see why omxh264dec does not see that

But as Nicolas said, you can easily implement the fallback case with gst_video_frame_copy()... or just reuse gst_omx_video_dec_fill_buffer() which is in the decoder and encoder already.

Can you check if that makes it work for you?
Comment 17 Sebastian Dröge (slomo) 2014-06-24 11:09:07 UTC
Ah, the tee element makes the videometa go away in your case.
Comment 18 Sebastian Dröge (slomo) 2014-06-24 11:56:10 UTC
Yes, the problem is the tee. It works without but not with tee... because tee currently can't aggregate the ALLOCATION queries and as such just drops it.

Which then means that omxvideodec can't use the videometa... but currently it does not convert the stride to the default GStreamer stride.
Comment 19 Sebastian Dröge (slomo) 2014-06-24 13:12:17 UTC
commit 4593f434a06d8d3b46338e0762e93c558ea4e58d
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Tue Jun 24 14:52:58 2014 +0200

    omxbufferpool: Copy buffers if the stride does not match and we can't use video meta
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731672
Comment 20 m][sko 2014-06-25 06:49:06 UTC
If I add videometa(with my patch) to omxbuferrpool it works fine with tee and without frame copy.
Are you sure that tee don't pass videometa?
Comment 21 Sebastian Dröge (slomo) 2014-06-25 07:19:08 UTC
See bug #730758

Your patch adds videometa although the ALLOCATION query says that it must not be used because of the above mentioned bug. You're just lucky that downstream of tee actually supports the videometa :)
Comment 22 m][sko 2014-06-25 08:54:23 UTC
But after your patch it really do frame copy,
even if videoconvert support videometa
Comment 23 Sebastian Dröge (slomo) 2014-06-25 09:00:30 UTC
Yes, but only if there is a tee involved. Due to the tee the decoders gets told that it can't use videometa, no matter what other elements are there. See bug #730758

Once that bug is fixed there will be no copying unless necessary.