v4l2slh264dec: Renew bitstream buffer after submitting slice
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Mon, 29 Jun 2020 17:25:39 +0000 (13:25 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 2 Jul 2020 16:21:51 +0000 (12:21 -0400)
Submitting a slice actually clears the bitstream buffer. Ensure we
have a newly allocated bitstream buffer for the next slice.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1395>

sys/v4l2codecs/gstv4l2codech264dec.c

index eec5c44..0f00d5a 100644 (file)
@@ -1041,20 +1041,25 @@ gst_v4l2_codec_h264_dec_decode_slice (GstH264Decoder * decoder,
   GstV4l2CodecH264Dec *self = GST_V4L2_CODEC_H264_DEC (decoder);
   gsize sc_off = 0;
   gsize nal_size;
-  guint8 *bitstream_data = self->bitstream_map.data + self->bitstream_map.size;
+  guint8 *bitstream_data;
 
   if (is_slice_based (self)) {
-    /* In slice mode, we submit the pending slice asking the acceletator to hold
-     * on the picture */
-    if (self->bitstream_map.size)
-      gst_v4l2_codec_h264_dec_submit_bitstream (self, picture,
-          V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF);
+    if (self->bitstream_map.size) {
+      /* In slice mode, we submit the pending slice asking the accelerator to
+       * hold on the picture */
+      if (!gst_v4l2_codec_h264_dec_submit_bitstream (self, picture,
+              V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF)
+          || !gst_v4l2_codec_h264_dec_ensure_bitstream (self))
+        return FALSE;
+    }
 
     gst_v4l2_codec_h264_dec_fill_slice_params (self, slice);
     gst_v4l2_codec_h264_dec_fill_references (self, ref_pic_list0,
         ref_pic_list1);
   }
 
+  bitstream_data = self->bitstream_map.data + self->bitstream_map.size;
+
   if (needs_start_codes (self))
     sc_off = 3;
   nal_size = sc_off + slice->nalu.size;