diff --git a/sys/v4l2codecs/gstv4l2codech264dec.c b/sys/v4l2codecs/gstv4l2codech264dec.c index 732b06a9f2..70660b3ab3 100644 --- a/sys/v4l2codecs/gstv4l2codech264dec.c +++ b/sys/v4l2codecs/gstv4l2codech264dec.c @@ -559,7 +559,8 @@ static void gst_v4l2_codec_h264_dec_reset_picture (GstV4l2CodecH264Dec * self) { if (self->bitstream) { - gst_memory_unmap (self->bitstream, &self->bitstream_map); + if (self->bitstream_map.memory) + gst_memory_unmap (self->bitstream, &self->bitstream_map); g_clear_pointer (&self->bitstream, gst_memory_unref); self->bitstream_map = (GstMapInfo) GST_MAP_INFO_INIT; } @@ -576,6 +577,7 @@ gst_v4l2_codec_h264_dec_end_picture (GstH264Decoder * decoder, GstV4l2Request *request; GstBuffer *buffer; GstFlowReturn flow_ret; + gsize bytesused; /* *INDENT-OFF* */ struct v4l2_ext_control control[] = { @@ -625,8 +627,12 @@ gst_v4l2_codec_h264_dec_end_picture (GstH264Decoder * decoder, return FALSE; } + bytesused = self->bitstream_map.size; + gst_memory_unmap (self->bitstream, &self->bitstream_map); + self->bitstream_map = (GstMapInfo) GST_MAP_INFO_INIT; + if (!gst_v4l2_decoder_queue_sink_mem (self->decoder, request, self->bitstream, - picture->system_frame_number)) { + picture->system_frame_number, bytesused)) { GST_ELEMENT_ERROR (decoder, RESOURCE, WRITE, ("Driver did not accept the bitstream data."), (NULL)); return FALSE; diff --git a/sys/v4l2codecs/gstv4l2decoder.c b/sys/v4l2codecs/gstv4l2decoder.c index a438108768..1ab52eaff5 100644 --- a/sys/v4l2codecs/gstv4l2decoder.c +++ b/sys/v4l2codecs/gstv4l2decoder.c @@ -354,11 +354,12 @@ gst_v4l2_decoder_export_buffer (GstV4l2Decoder * self, gboolean gst_v4l2_decoder_queue_sink_mem (GstV4l2Decoder * self, - GstV4l2Request * request, GstMemory * mem, guint32 frame_num) + GstV4l2Request * request, GstMemory * mem, guint32 frame_num, + gsize bytesused) { gint ret; struct v4l2_plane plane = { - .bytesused = gst_memory_get_sizes (mem, NULL, NULL), + .bytesused = bytesused, }; struct v4l2_buffer buf = { .type = direction_to_buffer_type (GST_PAD_SINK), diff --git a/sys/v4l2codecs/gstv4l2decoder.h b/sys/v4l2codecs/gstv4l2decoder.h index 33faed2af9..7335224f7b 100644 --- a/sys/v4l2codecs/gstv4l2decoder.h +++ b/sys/v4l2codecs/gstv4l2decoder.h @@ -69,7 +69,8 @@ gboolean gst_v4l2_decoder_export_buffer (GstV4l2Decoder * self, gboolean gst_v4l2_decoder_queue_sink_mem (GstV4l2Decoder * self, GstV4l2Request * request, GstMemory * mem, - guint32 frame_num); + guint32 frame_num, + gsize bytesused); gboolean gst_v4l2_decoder_dequeue_sink (GstV4l2Decoder * self);