v4l2codecs: h264: Only set SPS control if needed

Given V4L2 controls are cached in V4L2, there is no need
to set them if they don't change. Set the SPS control
only if a new sequence was received by the parser.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1624>
This commit is contained in:
Ezequiel Garcia 2020-09-30 14:34:15 -03:00 committed by GStreamer Merge Bot
parent ae9411e334
commit 78756ecba9

View file

@ -74,6 +74,7 @@ struct _GstV4l2CodecH264Dec
gint min_pool_size;
gboolean has_videometa;
gboolean need_negotiation;
gboolean need_sequence;
gboolean copy_frames;
struct v4l2_ctrl_h264_sps sps;
@ -789,6 +790,7 @@ gst_v4l2_codec_h264_dec_new_sequence (GstH264Decoder * decoder,
}
gst_v4l2_codec_h264_dec_fill_sequence (self, sps);
self->need_sequence = TRUE;
if (negotiation_needed) {
self->need_negotiation = TRUE;
@ -1016,11 +1018,6 @@ gst_v4l2_codec_h264_dec_submit_bitstream (GstV4l2CodecH264Dec * self,
/* *INDENT-OFF* */
struct v4l2_ext_control control[] = {
{
.id = V4L2_CID_STATELESS_H264_SPS,
.ptr = &self->sps,
.size = sizeof (self->sps),
},
{
.id = V4L2_CID_STATELESS_H264_PPS,
.ptr = &self->pps,
@ -1038,6 +1035,7 @@ gst_v4l2_codec_h264_dec_submit_bitstream (GstV4l2CodecH264Dec * self,
},
{ },
{ },
{ },
};
/* *INDENT-ON* */
@ -1073,8 +1071,16 @@ gst_v4l2_codec_h264_dec_submit_bitstream (GstV4l2CodecH264Dec * self,
goto done;
}
/* Always set SPS, PPS, SCALING_MATRIX and DECODE_PARAMS */
count = 4;
/* Always set PPS, SCALING_MATRIX and DECODE_PARAMS */
count = 3;
if (self->need_sequence) {
control[count].id = V4L2_CID_STATELESS_H264_SPS;
control[count].ptr = &self->sps;
control[count].size = sizeof (self->sps);
count++;
self->need_sequence = FALSE;
}
/* If it's not slice-based then it doesn't support per-slice controls. */
if (is_slice_based (self)) {