v4l2codecs: Fix bytesused value

Pass the actual amount of bytes we have copied into the bitstream buffer. Also
unmap the memory before queuing.
This commit is contained in:
Nicolas Dufresne 2020-02-16 17:48:12 -05:00
parent 0d740a184e
commit b107c20198
3 changed files with 13 additions and 5 deletions

View file

@ -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;

View file

@ -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),

View file

@ -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);