basevideodecoder: really and only set src pad caps whenever requested

... since subclass is expected to be wise enough to know when to do so.
This commit is contained in:
Mark Nauwelaerts 2011-03-30 10:18:23 +02:00
parent 550237347b
commit 1b151caf11
4 changed files with 13 additions and 36 deletions

View file

@ -382,9 +382,7 @@ parse_sequence_header (GstSchroDec * schro_dec, guint8 * data, int size)
state->par_d = video_format.aspect_ratio_denominator; state->par_d = video_format.aspect_ratio_denominator;
GST_DEBUG ("Pixel aspect ratio is %d/%d", state->par_n, state->par_d); GST_DEBUG ("Pixel aspect ratio is %d/%d", state->par_n, state->par_d);
/* FIXME state points to what is actually in the decoder */ gst_base_video_decoder_set_src_caps (GST_BASE_VIDEO_DECODER (schro_dec));
//gst_base_video_decoder_set_state (GST_BASE_VIDEO_DECODER (schro_dec),
// state);
} else { } else {
GST_WARNING ("Failed to get frame rate from sequence header"); GST_WARNING ("Failed to get frame rate from sequence header");
} }

View file

@ -399,11 +399,11 @@ gst_vp8_dec_handle_frame (GstBaseVideoDecoder * decoder, GstVideoFrame * frame)
return GST_FLOW_OK; return GST_FLOW_OK;
} }
/* should set size here */
state->width = stream_info.w; state->width = stream_info.w;
state->height = stream_info.h; state->height = stream_info.h;
state->format = GST_VIDEO_FORMAT_I420; state->format = GST_VIDEO_FORMAT_I420;
gst_vp8_dec_send_tags (dec); gst_vp8_dec_send_tags (dec);
gst_base_video_decoder_set_src_caps (decoder);
caps = vpx_codec_get_caps (&vpx_codec_vp8_dx_algo); caps = vpx_codec_get_caps (&vpx_codec_vp8_dx_algo);
@ -445,21 +445,6 @@ gst_vp8_dec_handle_frame (GstBaseVideoDecoder * decoder, GstVideoFrame * frame)
if (!GST_BUFFER_FLAG_IS_SET (frame->sink_buffer, GST_BUFFER_FLAG_DELTA_UNIT)) if (!GST_BUFFER_FLAG_IS_SET (frame->sink_buffer, GST_BUFFER_FLAG_DELTA_UNIT))
gst_base_video_decoder_set_sync_point (decoder); gst_base_video_decoder_set_sync_point (decoder);
#if 0
if (GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (decoder)) == NULL) {
GstCaps *caps;
caps = gst_video_format_new_caps (decoder->state.format,
decoder->state.width, decoder->state.height,
decoder->state.fps_n, decoder->state.fps_d,
decoder->state.par_n, decoder->state.par_d);
GST_DEBUG ("setting caps %" GST_PTR_FORMAT, caps);
gst_pad_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD (decoder), caps);
}
#endif
deadline = gst_base_video_decoder_get_max_decode_time (decoder, frame); deadline = gst_base_video_decoder_get_max_decode_time (decoder, frame);
if (deadline < 0) { if (deadline < 0) {
decoder_deadline = 1; decoder_deadline = 1;

View file

@ -1245,7 +1245,6 @@ gst_base_video_decoder_finish_frame (GstBaseVideoDecoder * base_video_decoder,
GST_BASE_VIDEO_CODEC (base_video_decoder)->time = GST_CLOCK_TIME_NONE; GST_BASE_VIDEO_CODEC (base_video_decoder)->time = GST_CLOCK_TIME_NONE;
} }
gst_base_video_decoder_set_src_caps (base_video_decoder);
gst_buffer_set_caps (src_buffer, gst_buffer_set_caps (src_buffer,
GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder))); GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder)));
@ -1583,9 +1582,6 @@ gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder * base_video_decoder)
g_return_val_if_fail (state->width != 0, FALSE); g_return_val_if_fail (state->width != 0, FALSE);
g_return_val_if_fail (state->height != 0, FALSE); g_return_val_if_fail (state->height != 0, FALSE);
if (GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder)) != NULL)
return;
/* sanitize */ /* sanitize */
if (state->fps_d == 0) { if (state->fps_d == 0) {
state->fps_n = 0; state->fps_n = 0;
@ -1599,9 +1595,6 @@ gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder * base_video_decoder)
caps = gst_video_format_new_caps (state->format, caps = gst_video_format_new_caps (state->format,
state->width, state->height, state->width, state->height,
state->fps_n, state->fps_d, state->par_n, state->par_d); state->fps_n, state->fps_d, state->par_n, state->par_d);
/* arrange for derived info */
state->bytes_per_picture =
gst_video_format_get_size (state->format, state->width, state->height);
gst_caps_set_simple (caps, "interlaced", gst_caps_set_simple (caps, "interlaced",
G_TYPE_BOOLEAN, state->interlaced, NULL); G_TYPE_BOOLEAN, state->interlaced, NULL);
@ -1610,9 +1603,12 @@ gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder * base_video_decoder)
ret = ret =
gst_pad_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder), gst_pad_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder),
caps); caps);
gst_caps_unref (caps); gst_caps_unref (caps);
/* arrange for derived info */
state->bytes_per_picture =
gst_video_format_get_size (state->format, state->width, state->height);
return ret; return ret;
} }
@ -1635,8 +1631,6 @@ gst_base_video_decoder_alloc_src_buffer (GstBaseVideoDecoder *
int num_bytes; int num_bytes;
GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state; GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
gst_base_video_decoder_set_src_caps (base_video_decoder);
num_bytes = gst_video_format_get_size (state->format, state->width, num_bytes = gst_video_format_get_size (state->format, state->width,
state->height); state->height);
GST_DEBUG ("alloc src buffer caps=%" GST_PTR_FORMAT, GST_DEBUG ("alloc src buffer caps=%" GST_PTR_FORMAT,
@ -1663,7 +1657,8 @@ gst_base_video_decoder_alloc_src_buffer (GstBaseVideoDecoder *
* *
* Helper function that uses gst_pad_alloc_buffer_and_set_caps * Helper function that uses gst_pad_alloc_buffer_and_set_caps
* to allocate a buffer to hold a video frame for @base_video_decoder's * to allocate a buffer to hold a video frame for @base_video_decoder's
* current #GstVideoState. * current #GstVideoState. Subclass should already have configured video state
* and set src pad caps.
* *
* Returns: result from pad alloc call * Returns: result from pad alloc call
*/ */
@ -1672,13 +1667,14 @@ gst_base_video_decoder_alloc_src_frame (GstBaseVideoDecoder *
base_video_decoder, GstVideoFrame * frame) base_video_decoder, GstVideoFrame * frame)
{ {
GstFlowReturn flow_ret; GstFlowReturn flow_ret;
int num_bytes;
GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state; GstVideoState *state = &GST_BASE_VIDEO_CODEC (base_video_decoder)->state;
int num_bytes = state->bytes_per_picture;
gst_base_video_decoder_set_src_caps (base_video_decoder); g_return_val_if_fail (state->bytes_per_picture != 0, GST_FLOW_ERROR);
g_return_val_if_fail (GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD
(base_video_decoder)) != NULL, GST_FLOW_ERROR);
num_bytes = gst_video_format_get_size (state->format, state->width, GST_LOG_OBJECT (base_video_decoder, "alloc buffer size %d", num_bytes);
state->height);
flow_ret = flow_ret =
gst_pad_alloc_buffer_and_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD gst_pad_alloc_buffer_and_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD
(base_video_decoder), GST_BUFFER_OFFSET_NONE, num_bytes, (base_video_decoder), GST_BUFFER_OFFSET_NONE, num_bytes,

View file

@ -109,8 +109,6 @@ struct _GstBaseVideoDecoder
/* need mark discont */ /* need mark discont */
gboolean discont; gboolean discont;
/* src caps set */
gboolean have_src_caps;
/* combine to yield (presentation) ts */ /* combine to yield (presentation) ts */
GstClockTime timestamp_offset; GstClockTime timestamp_offset;