From 37327082676d18ecd7515d08847048d09fba0f56 Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Wed, 22 Aug 2007 14:50:51 +0000 Subject: gst/flv/: Handle pixel aspect ratio through metadata tags like ASF does. Fluendo muxer supports this and Original commit message from CVS: 2007-08-22 Julien MOUTTE * gst/flv/gstflvdemux.c: (gst_flv_demux_cleanup), (gst_flv_demux_pull_tag): * gst/flv/gstflvdemux.h: * gst/flv/gstflvparse.c: (gst_flv_parse_metadata_item), (gst_flv_parse_tag_script), (gst_flv_parse_tag_audio), (gst_flv_parse_tag_video): Handle pixel aspect ratio through metadata tags like ASF does. Fluendo muxer supports this and Flash players can support it as well this way. --- ChangeLog | 11 +++++++++++ gst/flv/gstflvdemux.c | 3 +++ gst/flv/gstflvdemux.h | 3 +++ gst/flv/gstflvparse.c | 23 ++++++++++++++++++++++- 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6402ff67..e45aa197 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-08-22 Julien MOUTTE + + * gst/flv/gstflvdemux.c: (gst_flv_demux_cleanup), + (gst_flv_demux_pull_tag): + * gst/flv/gstflvdemux.h: + * gst/flv/gstflvparse.c: (gst_flv_parse_metadata_item), + (gst_flv_parse_tag_script), (gst_flv_parse_tag_audio), + (gst_flv_parse_tag_video): Handle pixel aspect ratio through + metadata tags like ASF does. Fluendo muxer supports this and + Flash players can support it as well this way. + 2007-08-22 Julien MOUTTE * gst/flv/gstflvdemux.c: (gst_flv_demux_pull_tag): diff --git a/gst/flv/gstflvdemux.c b/gst/flv/gstflvdemux.c index 3a644c38..b94479ea 100644 --- a/gst/flv/gstflvdemux.c +++ b/gst/flv/gstflvdemux.c @@ -90,7 +90,10 @@ gst_flv_demux_cleanup (GstFLVDemux * demux) demux->has_audio = FALSE; demux->has_video = FALSE; demux->push_tags = FALSE; + demux->got_par = FALSE; + demux->w = demux->h = 0; + demux->par_x = demux->par_y = 1; demux->video_offset = 0; demux->audio_offset = 0; demux->offset = demux->cur_tag_offset = 0; diff --git a/gst/flv/gstflvdemux.h b/gst/flv/gstflvdemux.h index c3a4cf21..29d71c59 100644 --- a/gst/flv/gstflvdemux.h +++ b/gst/flv/gstflvdemux.h @@ -92,11 +92,14 @@ struct _GstFLVDemux /* Video infos */ guint32 w; guint32 h; + guint32 par_x; + guint32 par_y; guint16 video_codec_tag; guint64 video_offset; gboolean video_need_discont; gboolean video_need_segment; gboolean video_linked; + gboolean got_par; gboolean random_access; gboolean need_header; diff --git a/gst/flv/gstflvparse.c b/gst/flv/gstflvparse.c index dd7794d1..eeb64546 100644 --- a/gst/flv/gstflvparse.c +++ b/gst/flv/gstflvparse.c @@ -123,6 +123,13 @@ gst_flv_parse_metadata_item (GstFLVDemux * demux, const guint8 * data, GST_TAG_DURATION, demux->duration, NULL); } else { if (tag_name) { + if (!strcmp (tag_name, "AspectRatioX")) { + demux->par_x = value_union.value_double; + demux->got_par = TRUE; + } else if (!strcmp (tag_name, "AspectRatioY")) { + demux->par_y = value_union.value_double; + demux->got_par = TRUE; + } if (!gst_tag_exists (tag_name)) { gst_tag_register (tag_name, GST_TAG_FLAG_META, G_TYPE_DOUBLE, tag_name, tag_name, gst_tag_merge_use_first); @@ -718,6 +725,13 @@ gst_flv_parse_tag_video (GstFLVDemux * demux, const guint8 * data, goto beach; } + gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION, + demux->par_x, demux->par_y, NULL); + + /* When we ve set pixel-aspect-ratio we use that boolean to detect a + * metadata tag that would come later and trigger a caps change */ + demux->got_par = FALSE; + gst_pad_set_caps (demux->video_pad, caps); GST_DEBUG_OBJECT (demux, "created video pad with caps %" GST_PTR_FORMAT, @@ -751,7 +765,7 @@ gst_flv_parse_tag_video (GstFLVDemux * demux, const guint8 * data, } /* Check if caps have changed */ - if (G_UNLIKELY (codec_tag != demux->video_codec_tag)) { + if (G_UNLIKELY (codec_tag != demux->video_codec_tag || demux->got_par)) { GstCaps *caps = NULL; GST_DEBUG_OBJECT (demux, "video settings have changed, changing caps"); @@ -780,6 +794,13 @@ gst_flv_parse_tag_video (GstFLVDemux * demux, const guint8 * data, goto beach; } + gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION, + demux->par_x, demux->par_y, NULL); + + /* When we ve set pixel-aspect-ratio we use that boolean to detect a + * metadata tag that would come later and trigger a caps change */ + demux->got_par = FALSE; + gst_pad_set_caps (demux->video_pad, caps); gst_caps_unref (caps); -- cgit v1.2.1