v4l2codecs: h264: Only slice-based need SLICE_PARAMS and PRED_WEIGHTS
Frame-based decoding mode doesn't require SLICE_PARAMS and PRED_WEIGHTS controls. Moreover, if the driver doesn't support these two controls, trying to set them will fail. Fix this by only setting these on slice-based decoding mode. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1624>
This commit is contained in:
parent
010565eb7f
commit
ae9411e334
@ -126,22 +126,22 @@ gst_v4l2_decoder_h264_api_check (GstV4l2CodecH264Dec * self)
|
|||||||
unsigned int size;
|
unsigned int size;
|
||||||
} controls[] = {
|
} controls[] = {
|
||||||
{
|
{
|
||||||
.id = V4L2_CID_MPEG_VIDEO_H264_SPS,
|
.id = V4L2_CID_STATELESS_H264_SPS,
|
||||||
.size = sizeof(struct v4l2_ctrl_h264_sps),
|
.size = sizeof(struct v4l2_ctrl_h264_sps),
|
||||||
}, {
|
}, {
|
||||||
.id = V4L2_CID_MPEG_VIDEO_H264_PPS,
|
.id = V4L2_CID_STATELESS_H264_PPS,
|
||||||
.size = sizeof(struct v4l2_ctrl_h264_pps),
|
.size = sizeof(struct v4l2_ctrl_h264_pps),
|
||||||
}, {
|
}, {
|
||||||
.id = V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX,
|
.id = V4L2_CID_STATELESS_H264_SCALING_MATRIX,
|
||||||
.size = sizeof(struct v4l2_ctrl_h264_scaling_matrix),
|
.size = sizeof(struct v4l2_ctrl_h264_scaling_matrix),
|
||||||
}, {
|
}, {
|
||||||
.id = V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS,
|
.id = V4L2_CID_STATELESS_H264_DECODE_PARAMS,
|
||||||
.size = sizeof(struct v4l2_ctrl_h264_decode_params),
|
.size = sizeof(struct v4l2_ctrl_h264_decode_params),
|
||||||
}, {
|
}, {
|
||||||
.id = V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS,
|
.id = V4L2_CID_STATELESS_H264_SLICE_PARAMS,
|
||||||
.size = sizeof(struct v4l2_ctrl_h264_slice_params),
|
.size = sizeof(struct v4l2_ctrl_h264_slice_params),
|
||||||
}, {
|
}, {
|
||||||
.id = V4L2_CID_MPEG_VIDEO_H264_PRED_WEIGHTS,
|
.id = V4L2_CID_STATELESS_H264_PRED_WEIGHTS,
|
||||||
.size = sizeof(struct v4l2_ctrl_h264_pred_weights),
|
.size = sizeof(struct v4l2_ctrl_h264_pred_weights),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1012,6 +1012,7 @@ gst_v4l2_codec_h264_dec_submit_bitstream (GstV4l2CodecH264Dec * self,
|
|||||||
GstV4l2Request *prev_request, *request = NULL;
|
GstV4l2Request *prev_request, *request = NULL;
|
||||||
gsize bytesused;
|
gsize bytesused;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
guint count;
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
struct v4l2_ext_control control[] = {
|
struct v4l2_ext_control control[] = {
|
||||||
@ -1030,22 +1031,13 @@ gst_v4l2_codec_h264_dec_submit_bitstream (GstV4l2CodecH264Dec * self,
|
|||||||
.ptr = &self->scaling_matrix,
|
.ptr = &self->scaling_matrix,
|
||||||
.size = sizeof (self->scaling_matrix),
|
.size = sizeof (self->scaling_matrix),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
.id = V4L2_CID_STATELESS_H264_SLICE_PARAMS,
|
|
||||||
.ptr = self->slice_params->data,
|
|
||||||
.size = g_array_get_element_size (self->slice_params)
|
|
||||||
* self->num_slices,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.id = V4L2_CID_STATELESS_H264_PRED_WEIGHTS,
|
|
||||||
.ptr = &self->pred_weight,
|
|
||||||
.size = sizeof (self->pred_weight),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
.id = V4L2_CID_STATELESS_H264_DECODE_PARAMS,
|
.id = V4L2_CID_STATELESS_H264_DECODE_PARAMS,
|
||||||
.ptr = &self->decode_params,
|
.ptr = &self->decode_params,
|
||||||
.size = sizeof (self->decode_params),
|
.size = sizeof (self->decode_params),
|
||||||
},
|
},
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
};
|
};
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
@ -1081,8 +1073,24 @@ gst_v4l2_codec_h264_dec_submit_bitstream (GstV4l2CodecH264Dec * self,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_v4l2_decoder_set_controls (self->decoder, request, control,
|
/* Always set SPS, PPS, SCALING_MATRIX and DECODE_PARAMS */
|
||||||
G_N_ELEMENTS (control))) {
|
count = 4;
|
||||||
|
|
||||||
|
/* If it's not slice-based then it doesn't support per-slice controls. */
|
||||||
|
if (is_slice_based (self)) {
|
||||||
|
control[count].id = V4L2_CID_STATELESS_H264_SLICE_PARAMS;
|
||||||
|
control[count].ptr = self->slice_params->data;
|
||||||
|
control[count].size = g_array_get_element_size (self->slice_params)
|
||||||
|
* self->num_slices;
|
||||||
|
count++;
|
||||||
|
|
||||||
|
control[count].id = V4L2_CID_STATELESS_H264_PRED_WEIGHTS;
|
||||||
|
control[count].ptr = &self->pred_weight;
|
||||||
|
control[count].size = sizeof (self->pred_weight);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gst_v4l2_decoder_set_controls (self->decoder, request, control, count)) {
|
||||||
GST_ELEMENT_ERROR (self, RESOURCE, WRITE,
|
GST_ELEMENT_ERROR (self, RESOURCE, WRITE,
|
||||||
("Driver did not accept the bitstream parameters."), (NULL));
|
("Driver did not accept the bitstream parameters."), (NULL));
|
||||||
goto done;
|
goto done;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user