From fd694d840adc5e975b05094501d44b83eeccb926 Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Sun, 16 Jan 2022 15:51:32 +0300 Subject: [PATCH] v4l2codecs: h264: Set frame type flags V4L spec now requires decode_params flags to be set in accordance to the frame's type. In particular this is required by H.264 decoder of NVIDIA Tegra SoC to operate properly. Set the flags based on type of parsed slices. Part-of: --- .../sys/v4l2codecs/gstv4l2codech264dec.c | 10 ++++++++++ .../sys/v4l2codecs/linux/v4l2-controls.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c index 406ed79eb9..1b21a8dde1 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c @@ -1291,6 +1291,16 @@ gst_v4l2_codec_h264_dec_decode_slice (GstH264Decoder * decoder, slice->nalu.size); self->bitstream_map.size += nal_size; + switch (slice->header.type % 5) { + case GST_H264_P_SLICE: + self->decode_params.flags |= V4L2_H264_DECODE_PARAM_FLAG_PFRAME; + break; + + case GST_H264_B_SLICE: + self->decode_params.flags |= V4L2_H264_DECODE_PARAM_FLAG_BFRAME; + break; + } + return GST_FLOW_OK; } diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/linux/v4l2-controls.h b/subprojects/gst-plugins-bad/sys/v4l2codecs/linux/v4l2-controls.h index 8fd9a218e5..aebabaca24 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/linux/v4l2-controls.h +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/linux/v4l2-controls.h @@ -1560,6 +1560,8 @@ struct v4l2_h264_dpb_entry { #define V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC 0x01 #define V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC 0x02 #define V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD 0x04 +#define V4L2_H264_DECODE_PARAM_FLAG_PFRAME 0x08 +#define V4L2_H264_DECODE_PARAM_FLAG_BFRAME 0x10 #define V4L2_CID_STATELESS_H264_DECODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 7) /**