if (!gst_va_decoder_close (base->decoder))
return FALSE;
- if (base->output_state)
- gst_video_codec_state_unref (base->output_state);
- base->output_state = NULL;
+ g_clear_pointer (&base->output_state, gst_video_codec_state_unref);
+ g_clear_pointer (&base->input_state, gst_video_codec_state_unref);
if (base->other_pool)
gst_buffer_pool_set_active (base->other_pool, FALSE);
(element))->set_context (element, context);
}
+static gboolean
+gst_va_base_dec_negotiate (GstVideoDecoder * decoder)
+{
+ GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
+
+ /* Ignore downstream renegotiation request. */
+ if (!base->need_negotiation)
+ return TRUE;
+
+ base->need_negotiation = FALSE;
+
+ if (!gst_va_decoder_config_is_equal (base->decoder, base->profile,
+ base->rt_format, base->width, base->height)) {
+ if (gst_va_decoder_is_open (base->decoder) &&
+ !gst_va_decoder_close (base->decoder))
+ return FALSE;
+ if (!gst_va_decoder_open (base->decoder, base->profile, base->rt_format))
+ return FALSE;
+ if (!gst_va_decoder_set_frame_size (base->decoder, base->width,
+ base->height))
+ return FALSE;
+ }
+
+ if (!gst_va_base_dec_set_output_state (base))
+ return FALSE;
+
+ return GST_VIDEO_DECODER_CLASS (GST_VA_BASE_DEC_GET_PARENT_CLASS (decoder))
+ ->negotiate (decoder);
+}
+
void
gst_va_base_dec_init (GstVaBaseDec * base, GstDebugCategory * cat)
{
base->debug_category = cat;
+ gst_video_info_init (&base->output_info);
}
void
decoder_class->sink_query = GST_DEBUG_FUNCPTR (gst_va_base_dec_sink_query);
decoder_class->decide_allocation =
GST_DEBUG_FUNCPTR (gst_va_base_dec_decide_allocation);
+ decoder_class->negotiate = GST_DEBUG_FUNCPTR (gst_va_base_dec_negotiate);
g_object_class_install_property (object_class, GST_VA_DEC_PROP_DEVICE_PATH,
g_param_spec_string ("device-path", "Device Path",
src_vinfo = &base->output_state->info;
gst_video_info_set_format (&dest_vinfo, GST_VIDEO_INFO_FORMAT (src_vinfo),
- base->width, base->height);
+ GST_VIDEO_INFO_WIDTH (src_vinfo), GST_VIDEO_INFO_HEIGHT (src_vinfo));
ret = gst_buffer_pool_acquire_buffer (base->other_pool, &buffer, NULL);
if (ret != GST_FLOW_OK)
} else {
/* gst_video_frame_copy can crop this, but does not know, so let
* make it think it's all right */
- GST_VIDEO_INFO_WIDTH (&src_frame.info) = base->width;
- GST_VIDEO_INFO_HEIGHT (&src_frame.info) = base->height;
+ GST_VIDEO_INFO_WIDTH (&src_frame.info) = GST_VIDEO_INFO_WIDTH (src_vinfo);
+ GST_VIDEO_INFO_HEIGHT (&src_frame.info) = GST_VIDEO_INFO_HEIGHT (src_vinfo);
if (!gst_video_frame_copy (&dest_frame, &src_frame)) {
gst_video_frame_unmap (&src_frame);
return gst_video_decoder_allocate_output_frame (vdec, frame);
return GST_FLOW_OK;
}
+
+gboolean
+gst_va_base_dec_set_output_state (GstVaBaseDec * base)
+{
+ GstVideoDecoder *decoder = GST_VIDEO_DECODER (base);
+ GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN;
+ GstCapsFeatures *capsfeatures = NULL;
+ GstVideoInfo *info = &base->output_info;
+
+ if (base->output_state)
+ gst_video_codec_state_unref (base->output_state);
+
+ gst_va_base_dec_get_preferred_format_and_caps_features (base, &format,
+ &capsfeatures);
+ if (format == GST_VIDEO_FORMAT_UNKNOWN)
+ return FALSE;
+
+ base->output_state =
+ gst_video_decoder_set_interlaced_output_state (decoder, format,
+ GST_VIDEO_INFO_INTERLACE_MODE (info), GST_VIDEO_INFO_WIDTH (info),
+ GST_VIDEO_INFO_HEIGHT (info), base->input_state);
+
+ /* set caps feature */
+ base->output_state->caps = gst_video_info_to_caps (&base->output_state->info);
+ if (capsfeatures)
+ gst_caps_set_features_simple (base->output_state->caps, capsfeatures);
+
+ GST_INFO_OBJECT (base, "Negotiated caps %" GST_PTR_FORMAT,
+ base->output_state->caps);
+
+ return TRUE;
+}