ext/mpeg2dec/gstmpeg2dec.*: Prefer the container's PAR over the stream's PAR if it's given in the srcpad caps. Fixes ...

Original commit message from CVS:
Patch by: Robin Stocker <robin at nibor dot org>
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_init),
(handle_sequence), (gst_mpeg2dec_setcaps):
* ext/mpeg2dec/gstmpeg2dec.h:
Prefer the container's PAR over the stream's PAR if it's
given in the srcpad caps. Fixes bug #556184.
This commit is contained in:
Robin Stocker 2008-10-14 12:51:41 +00:00 committed by Sebastian Dröge
parent 793cdeb880
commit ac40f11552
3 changed files with 41 additions and 2 deletions

View file

@ -1,3 +1,13 @@
2008-10-14 Sebastian Dröge <slomo@circular-chaos.org>
Patch by: Robin Stocker <robin at nibor dot org>
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_init),
(handle_sequence), (gst_mpeg2dec_setcaps):
* ext/mpeg2dec/gstmpeg2dec.h:
Prefer the container's PAR over the stream's PAR if it's
given in the srcpad caps. Fixes bug #556184.
2008-10-13 Stefan Kost <ensonic@users.sf.net>
* ext/a52dec/Makefile.am:

View file

@ -115,6 +115,7 @@ static GstStateChangeReturn gst_mpeg2dec_change_state (GstElement * element,
GstStateChange transition);
static gboolean gst_mpeg2dec_sink_event (GstPad * pad, GstEvent * event);
static gboolean gst_mpeg2dec_setcaps (GstPad * pad, GstCaps * caps);
static GstFlowReturn gst_mpeg2dec_chain (GstPad * pad, GstBuffer * buf);
static void clear_buffers (GstMpeg2dec * mpeg2dec);
@ -216,6 +217,8 @@ gst_mpeg2dec_init (GstMpeg2dec * mpeg2dec)
#endif
gst_pad_set_event_function (mpeg2dec->sinkpad,
GST_DEBUG_FUNCPTR (gst_mpeg2dec_sink_event));
gst_pad_set_setcaps_function (mpeg2dec->sinkpad,
GST_DEBUG_FUNCPTR (gst_mpeg2dec_setcaps));
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->sinkpad);
mpeg2dec->srcpad =
@ -627,12 +630,16 @@ handle_sequence (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
mpeg2dec->width = info->sequence->picture_width;
mpeg2dec->height = info->sequence->picture_height;
mpeg2dec->pixel_width = info->sequence->pixel_width;
mpeg2dec->pixel_height = info->sequence->pixel_height;
mpeg2dec->decoded_width = info->sequence->width;
mpeg2dec->decoded_height = info->sequence->height;
mpeg2dec->total_frames = 0;
/* don't take the sequence PAR if we already have one from the sink caps */
if (!mpeg2dec->have_par) {
mpeg2dec->pixel_width = info->sequence->pixel_width;
mpeg2dec->pixel_height = info->sequence->pixel_height;
}
/* mpeg2 video can only be from 16x16 to 4096x4096. Everything
* else is a corrupted files */
if (mpeg2dec->width > 4096 || mpeg2dec->width < 16 ||
@ -1296,6 +1303,25 @@ newseg_wrong_format:
}
}
static gboolean
gst_mpeg2dec_setcaps (GstPad * pad, GstCaps * caps)
{
GstMpeg2dec *mpeg2dec;
GstStructure *s;
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
s = gst_caps_get_structure (caps, 0);
/* parse the par, this overrides the encoded par */
mpeg2dec->have_par = gst_structure_get_fraction (s, "pixel-aspect-ratio",
&mpeg2dec->pixel_width, &mpeg2dec->pixel_height);
gst_object_unref (mpeg2dec);
return TRUE;
}
static gboolean
gst_mpeg2dec_sink_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
GstFormat * dest_format, gint64 * dest_value)

View file

@ -123,6 +123,9 @@ struct _GstMpeg2dec {
GList *gather;
GList *decode;
GList *queued;
/* whether we have a pixel aspect ratio from the sink caps */
gboolean have_par;
};
struct _GstMpeg2decClass {