From 781a7edd5784c466a2cf294317692309e4f4ea08 Mon Sep 17 00:00:00 2001 From: gb Date: Tue, 22 Jun 2010 15:15:46 +0000 Subject: [PATCH] Add gst_base_video_decoder_update_src_caps(). Don't forcibly set "interlaced" field if upstream elements did not have any. --- gst-libs/gst/video/gstbasevideodecoder.c | 30 +++++++++++++++++++----- gst-libs/gst/video/gstbasevideodecoder.h | 1 + 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/video/gstbasevideodecoder.c b/gst-libs/gst/video/gstbasevideodecoder.c index b5c79f6b01..a66446fb0f 100644 --- a/gst-libs/gst/video/gstbasevideodecoder.c +++ b/gst-libs/gst/video/gstbasevideodecoder.c @@ -1448,18 +1448,26 @@ gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder * base_video_decoder) if (base_video_decoder->have_src_caps) return; - caps = gst_pad_get_allowed_caps - (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder)); - if (!caps) - goto null_caps; - if (gst_caps_is_empty (caps)) - goto empty_caps; + caps = GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder)); + if (caps) + caps = gst_caps_copy (caps); + else { + caps = gst_pad_get_allowed_caps + (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder)); + if (!caps) + goto null_caps; + if (gst_caps_is_empty (caps)) + goto empty_caps; + } gst_caps_set_simple (caps, "width", G_TYPE_INT, state->width, "height", G_TYPE_INT, state->height, "framerate", GST_TYPE_FRACTION, state->fps_n, state->fps_d, "pixel-aspect-ratio", GST_TYPE_FRACTION, state->par_n, state->par_d, + NULL); + if (state->have_interlaced) + gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, state->interlaced, NULL); gst_pad_fixate_caps (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder), caps); @@ -1482,6 +1490,16 @@ empty_caps: return; } +void +gst_base_video_decoder_update_src_caps (GstBaseVideoDecoder * + base_video_decoder) +{ + g_return_if_fail (GST_IS_BASE_VIDEO_DECODER (base_video_decoder)); + + base_video_decoder->have_src_caps = FALSE; + gst_base_video_decoder_set_src_caps (base_video_decoder); +} + GstFlowReturn gst_base_video_decoder_alloc_src_frame (GstBaseVideoDecoder * base_video_decoder, GstVideoFrame * frame) diff --git a/gst-libs/gst/video/gstbasevideodecoder.h b/gst-libs/gst/video/gstbasevideodecoder.h index 02f1fd3a7f..656eb40a6e 100644 --- a/gst-libs/gst/video/gstbasevideodecoder.h +++ b/gst-libs/gst/video/gstbasevideodecoder.h @@ -167,6 +167,7 @@ void gst_base_video_decoder_lost_sync (GstBaseVideoDecoder *base_video_decoder); void gst_base_video_decoder_set_sync_point (GstBaseVideoDecoder *base_video_decoder); void gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder *base_video_decoder); +void gst_base_video_decoder_update_src_caps (GstBaseVideoDecoder *base_video_decoder); GstFlowReturn gst_base_video_decoder_alloc_src_frame (GstBaseVideoDecoder *base_video_decoder, GstVideoFrame *frame);