From b20c6fe6c4f87790a7d2c011c7d3b2d96f8151e4 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Mon, 29 Jun 2020 13:25:39 -0400 Subject: [PATCH] v4l2slh264dec: Renew bitstream buffer after submitting slice Submitting a slice actually clears the bitstream buffer. Ensure we have a newly allocated bitstream buffer for the next slice. Part-of: --- sys/v4l2codecs/gstv4l2codech264dec.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/v4l2codecs/gstv4l2codech264dec.c b/sys/v4l2codecs/gstv4l2codech264dec.c index eec5c44eb2..0f00d5a796 100644 --- a/sys/v4l2codecs/gstv4l2codech264dec.c +++ b/sys/v4l2codecs/gstv4l2codech264dec.c @@ -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;