diff --git a/gst-libs/gst/video/gstbasevideoencoder.c b/gst-libs/gst/video/gstbasevideoencoder.c index 346cf2f68f..a7fe6d99f8 100644 --- a/gst-libs/gst/video/gstbasevideoencoder.c +++ b/gst-libs/gst/video/gstbasevideoencoder.c @@ -97,6 +97,8 @@ gst_base_video_encoder_sink_setcaps (GstPad * pad, GstCaps * caps) { GstBaseVideoEncoder *base_video_encoder; GstBaseVideoEncoderClass *base_video_encoder_class; + GstStructure *structure; + GstVideoState *state; gboolean ret; base_video_encoder = GST_BASE_VIDEO_ENCODER (gst_pad_get_parent (pad)); @@ -105,7 +107,31 @@ gst_base_video_encoder_sink_setcaps (GstPad * pad, GstCaps * caps) GST_DEBUG ("setcaps"); - gst_base_video_state_from_caps (&base_video_encoder->state, caps); + state = &base_video_encoder->state; + structure = gst_caps_get_structure (caps, 0); + + gst_video_format_parse_caps (caps, &state->format, + &state->width, &state->height); + + state->fps_n = 0; + state->fps_d = 1; + gst_video_parse_caps_framerate (caps, &state->fps_n, &state->fps_d); + if (state->fps_d == 0) { + state->fps_n = 0; + state->fps_d = 1; + } + + state->par_n = 1; + state->par_d = 1; + gst_video_parse_caps_pixel_aspect_ratio (caps, &state->par_n, &state->par_d); + + state->have_interlaced = gst_structure_get_boolean (structure, + "interlaced", &state->interlaced); + + state->clean_width = state->width; + state->clean_height = state->height; + state->clean_offset_left = 0; + state->clean_offset_top = 0; ret = base_video_encoder_class->set_format (base_video_encoder, &base_video_encoder->state); diff --git a/gst-libs/gst/video/gstbasevideoutils.c b/gst-libs/gst/video/gstbasevideoutils.c index 6ab93d98e8..4ccdd58c5e 100644 --- a/gst-libs/gst/video/gstbasevideoutils.c +++ b/gst-libs/gst/video/gstbasevideoutils.c @@ -121,35 +121,6 @@ gst_base_video_encoded_video_convert (GstVideoState * state, return res; } -gboolean -gst_base_video_state_from_caps (GstVideoState * state, GstCaps * caps) -{ - - gst_video_format_parse_caps (caps, &state->format, - &state->width, &state->height); - - if (!gst_video_parse_caps_framerate (caps, &state->fps_n, &state->fps_d)) - return FALSE; - - state->par_n = 1; - state->par_d = 1; - gst_video_parse_caps_pixel_aspect_ratio (caps, &state->par_n, &state->par_d); - - { - GstStructure *structure = gst_caps_get_structure (caps, 0); - state->interlaced = FALSE; - gst_structure_get_boolean (structure, "interlaced", &state->interlaced); - } - - state->clean_width = state->width; - state->clean_height = state->height; - state->clean_offset_left = 0; - state->clean_offset_top = 0; - - /* FIXME need better error handling */ - return TRUE; -} - GstClockTime gst_video_state_get_timestamp (const GstVideoState * state, GstSegment * segment, int frame_number) @@ -164,4 +135,3 @@ gst_video_state_get_timestamp (const GstVideoState * state, state->fps_d * GST_SECOND, state->fps_n); } } - diff --git a/gst-libs/gst/video/gstbasevideoutils.h b/gst-libs/gst/video/gstbasevideoutils.h index 6d83742913..f644218c32 100644 --- a/gst-libs/gst/video/gstbasevideoutils.h +++ b/gst-libs/gst/video/gstbasevideoutils.h @@ -87,9 +87,6 @@ gboolean gst_base_video_encoded_video_convert (GstVideoState *state, GstFormat src_format, gint64 src_value, GstFormat * dest_format, gint64 *dest_value); -gboolean gst_base_video_state_from_caps (GstVideoState *state, - GstCaps *caps); - GstClockTime gst_video_state_get_timestamp (const GstVideoState *state, GstSegment *segment, int frame_number);