v4l2codecs: decoders: Introduce and use set_output_state helper class

Allowing us to avoid some code duplication. This will become more
important with upcoming changes to caps generation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6376>
This commit is contained in:
Robert Mader 2024-02-17 06:01:41 +01:00 committed by GStreamer Marge Bot
parent 84d015cabb
commit 383545d856
8 changed files with 35 additions and 30 deletions

View file

@ -334,11 +334,8 @@ done:
gst_video_codec_state_unref (self->output_state);
self->output_state =
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (self),
self->vinfo.finfo->format, self->render_width,
self->render_height, av1dec->input_state);
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
gst_v4l2_decoder_set_output_state (GST_VIDEO_DECODER (self), &self->vinfo,
self->render_width, self->render_height, av1dec->input_state);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
if (self->streaming)

View file

@ -377,15 +377,12 @@ done:
gst_video_codec_state_unref (self->output_state);
self->output_state =
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (self),
self->vinfo.finfo->format, self->display_width,
self->display_height, h264dec->input_state);
gst_v4l2_decoder_set_output_state (GST_VIDEO_DECODER (self), &self->vinfo,
self->display_width, self->display_height, h264dec->input_state);
if (self->interlaced)
self->output_state->info.interlace_mode = GST_VIDEO_INTERLACE_MODE_MIXED;
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
if (self->streaming)
return TRUE;

View file

@ -411,11 +411,8 @@ done:
gst_video_codec_state_unref (self->output_state);
self->output_state =
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (self),
self->vinfo.finfo->format, self->display_width,
self->display_height, h265dec->input_state);
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
gst_v4l2_decoder_set_output_state (GST_VIDEO_DECODER (self), &self->vinfo,
self->display_width, self->display_height, h265dec->input_state);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
if (self->streaming)

View file

@ -299,16 +299,13 @@ done:
gst_video_codec_state_unref (self->output_state);
self->output_state =
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (self),
self->vinfo.finfo->format, self->width,
self->height, mpeg2dec->input_state);
gst_v4l2_decoder_set_output_state (GST_VIDEO_DECODER (self), &self->vinfo,
self->width, self->height, mpeg2dec->input_state);
if (self->interlaced)
self->output_state->info.interlace_mode =
GST_VIDEO_INTERLACE_MODE_INTERLEAVED;
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
if (self->streaming)
return TRUE;

View file

@ -248,11 +248,8 @@ done:
gst_video_codec_state_unref (self->output_state);
self->output_state =
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (self),
self->vinfo.finfo->format, self->width,
self->height, vp8dec->input_state);
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
gst_v4l2_decoder_set_output_state (GST_VIDEO_DECODER (self), &self->vinfo,
self->width, self->height, vp8dec->input_state);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
if (self->streaming)

View file

@ -518,11 +518,8 @@ done:
gst_video_codec_state_unref (self->output_state);
self->output_state =
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (self),
self->vinfo.finfo->format, self->width,
self->height, vp9dec->input_state);
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
gst_v4l2_decoder_set_output_state (GST_VIDEO_DECODER (self), &self->vinfo,
self->width, self->height, vp9dec->input_state);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
if (self->streaming)

View file

@ -554,6 +554,23 @@ gst_v4l2_decoder_select_src_format (GstV4l2Decoder * self, GstCaps * caps,
return TRUE;
}
GstVideoCodecState *
gst_v4l2_decoder_set_output_state (GstVideoDecoder * decoder,
GstVideoInfo * vinfo, guint width, guint height,
GstVideoCodecState * reference)
{
GstVideoCodecState *state;
state = gst_video_decoder_set_output_state (decoder, vinfo->finfo->format,
width, height, reference);
state->caps = gst_video_info_to_caps (&state->info);
GST_DEBUG_OBJECT (decoder, "Setting caps: %" GST_PTR_FORMAT, state->caps);
return state;
}
gint
gst_v4l2_decoder_request_buffers (GstV4l2Decoder * self,
GstPadDirection direction, guint num_buffers)

View file

@ -74,6 +74,12 @@ gboolean gst_v4l2_decoder_select_src_format (GstV4l2Decoder * self,
GstCaps * caps,
GstVideoInfo * vinfo);
GstVideoCodecState * gst_v4l2_decoder_set_output_state (GstVideoDecoder * decoder,
GstVideoInfo * vinfo,
guint width,
guint height,
GstVideoCodecState * reference);
gint gst_v4l2_decoder_request_buffers (GstV4l2Decoder * self,
GstPadDirection direction,
guint num_buffers);