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 767086 - v4l2src: pushes incomplete raw video buffers
v4l2src: pushes incomplete raw video buffers
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal major
: 1.8.2
Assigned To: Josep Torra Valles
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-05-31 19:23 UTC by Josep Torra Valles
Modified: 2016-06-07 21:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
v4l2src: check for valid size on raw video buffers (1.53 KB, patch)
2016-05-31 19:39 UTC, Josep Torra Valles
committed Details | Review

Description Josep Torra Valles 2016-05-31 19:23:32 UTC
With Inogeni 4K2USB3 (uvc device) sometime we push few raw video buffers that smaller than expected at the beginning of the stream. This leads to downstream elements to fail mapping the buffer.

GST_DEBUG=v4l2src:6,v4l2bufferpool:6,v4l2allocator:6 gst-launch-1.0 -q --gst-debug-no-color v4l2src ! video/x-raw, format=NV12, width=1920, height=1080, framerate=\(GstFraction\)60/1 ! queue ! vaapih264enc ! fakesink 2> ~/gst.log

```
0:00:01.022924707  3537      0x2571ad0 DEBUG         v4l2bufferpool gstv4l2bufferpool.c:945:gst_v4l2_buffer_pool_flush_stop:<v4l2src0:pool:src> stop flushing
0:00:01.023306617  3537      0x2571ad0 DEBUG         v4l2bufferpool gstv4l2bufferpool.c:623:gst_v4l2_buffer_pool_streamon:<v4l2src0:pool:src> Started streaming
0:00:01.023517695  3537      0x2571ad0 DEBUG         v4l2bufferpool gstv4l2bufferpool.c:1300:gst_v4l2_buffer_pool_acquire_buffer:<v4l2src0:pool:src> acquire
0:00:01.023577922  3537      0x2571ad0 LOG           v4l2bufferpool gstv4l2bufferpool.c:1017:gst_v4l2_buffer_pool_poll:<v4l2src0:pool:src> polling device
0:00:01.023637313  3537      0x2571ad0 LOG           v4l2bufferpool gstv4l2bufferpool.c:1149:gst_v4l2_buffer_pool_dqbuf:<v4l2src0:pool:src> dequeueing a buffer
0:00:01.023705512  3537      0x2571ad0 LOG            v4l2allocator gstv4l2allocator.c:1306:gst_v4l2_allocator_dqbuf:<v4l2src0:pool:src:allocator> dequeued buffer 0 (flags 0x12005)
0:00:01.023755785  3537      0x2571ad0 DEBUG          v4l2allocator gstv4l2allocator.c:1310:gst_v4l2_allocator_dqbuf:<v4l2src0:pool:src:allocator> driver pretends buffer is queued even if dequeue succeeded
0:00:01.023792180  3537      0x2571ad0 LOG           v4l2bufferpool gstv4l2bufferpool.c:1181:gst_v4l2_buffer_pool_dqbuf:<v4l2src0:pool:src> dequeued buffer 0x7f3c10024020 seq:0 (ix=0), mem 0x256bd80 used 16092, plane=0, flags 00012001, ts 0:13:49.994804000, pool-queued=1, buffer=0x7f3c10024020
0:00:01.023878313  3537      0x2571ad0 DEBUG         v4l2bufferpool gstv4l2bufferpool.c:1704:gst_v4l2_buffer_pool_process:<v4l2src0:pool:src> process buffer 0x7f3c1fffed08
0:00:01.023942762  3537      0x2571ad0 DEBUG                v4l2src gstv4l2src.c:774:gst_v4l2src_create:<v4l2src0> ts: 0:13:49.994804000 now 0:13:49.995415403 delay 0:00:00.000611403
0:00:01.024030202  3537      0x2571ad0 INFO                 v4l2src gstv4l2src.c:810:gst_v4l2src_create:<v4l2src0> sync to 0:00:00.016666666 out ts 0:00:00.746377358
0:00:01.024271077  3537      0x2571ad0 DEBUG         v4l2bufferpool gstv4l2bufferpool.c:1300:gst_v4l2_buffer_pool_acquire_buffer:<v4l2src0:pool:src> acquire
0:00:01.024349631  3537      0x2571ad0 LOG           v4l2bufferpool gstv4l2bufferpool.c:1017:gst_v4l2_buffer_pool_poll:<v4l2src0:pool:src> polling device
0:00:01.024337878  3537      0x2571a30 ERROR                default video-frame.c:161:gst_video_frame_map_id: failed to map video frame plane 1
0:00:01.031779897  3537      0x2571ad0 LOG           v4l2bufferpool gstv4l2bufferpool.c:1149:gst_v4l2_buffer_pool_dqbuf:<v4l2src0:pool:src> dequeueing a buffer
0:00:01.031839315  3537      0x2571ad0 LOG            v4l2allocator gstv4l2allocator.c:1306:gst_v4l2_allocator_dqbuf:<v4l2src0:pool:src:allocator> dequeued buffer 1 (flags 0x12005)
0:00:01.031879412  3537      0x2571ad0 DEBUG          v4l2allocator gstv4l2allocator.c:1310:gst_v4l2_allocator_dqbuf:<v4l2src0:pool:src:allocator> driver pretends buffer is queued even if dequeue succeeded
0:00:01.031909941  3537      0x2571ad0 LOG           v4l2bufferpool gstv4l2bufferpool.c:1181:gst_v4l2_buffer_pool_dqbuf:<v4l2src0:pool:src> dequeued buffer 0x7f3c10024130 seq:1 (ix=1), mem 0x256bea0 used 3110400, plane=0, flags 00012001, ts 0:13:49.994840000, pool-queued=0, buffer=0x7f3c10024130
0:00:01.031970462  3537      0x2571ad0 DEBUG         v4l2bufferpool gstv4l2bufferpool.c:1704:gst_v4l2_buffer_pool_process:<v4l2src0:pool:src> process buffer 0x7f3c1fffed08
0:00:01.032002386  3537      0x2571ad0 DEBUG         v4l2bufferpool gstv4l2bufferpool.c:675:gst_v4l2_buffer_pool_resurect_buffer:<v4l2src0:pool:src> A buffer was lost, reallocating it
0:00:01.032032683  3537      0x2571ad0 DEBUG         v4l2bufferpool gstv4l2bufferpool.c:1300:gst_v4l2_buffer_pool_acquire_buffer:<v4l2src0:pool:src> acquire
```
Comment 1 Josep Torra Valles 2016-05-31 19:39:18 UTC
Created attachment 328843 [details] [review]
v4l2src: check for valid size on raw video buffers

Proposed fix.
Comment 2 Nicolas Dufresne (ndufresne) 2016-05-31 20:22:38 UTC
Review of attachment 328843 [details] [review]:

::: sys/v4l2/gstv4l2bufferpool.c
@@ +1738,3 @@
+            if (GST_VIDEO_INFO_FORMAT (&obj->info) != GST_VIDEO_FORMAT_ENCODED
+                && size < GST_VIDEO_INFO_SIZE (&obj->info)) {
+              goto buffer_corrupted;

Sounds safe, we should warn about the fact that this is a driver bug also. Want to add that ? I'm fine with merging as-is too.
Comment 3 Josep Torra Valles 2016-05-31 20:25:25 UTC
(In reply to Nicolas Dufresne (stormer) from comment #2)
> Sounds safe, we should warn about the fact that this is a driver bug also.
> Want to add that ? I'm fine with merging as-is too.

Tomorrow I'll add a GST_WARNING message and I'll push it then.
Comment 4 Josep Torra Valles 2016-06-01 15:37:38 UTC
commit b7866315a6c9004c5e0c201e55107ecd81951cdc
Author: Josep Torra <adn770@gmail.com>
Date:   Tue May 31 21:34:04 2016 +0200

    v4l2src: check for valid size on raw video buffers
    
    Discard buffers that doesn't contain enough data when dealing
    with raw video inputs.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767086
Comment 5 Nicolas Dufresne (ndufresne) 2016-06-01 17:53:14 UTC
I'd like to backport this one into 1.8, let me know if you have any concerns.
Comment 6 Nicolas Dufresne (ndufresne) 2016-06-07 21:23:32 UTC
Branch: 1.8
Commit: c26f5b6222c4b5d2d5d95555b24d9f058454ebbe