From 89e2912bada430273a6219919366cadad87eb210 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 2 Oct 2004 14:10:19 +0000 Subject: [PATCH] gst-libs/gst/riff/riff-media.c: Add DIB fourcc (raw, palettized 8-bit RGB). Original commit message from CVS: * gst-libs/gst/riff/riff-media.c: (gst_riff_create_video_caps_with_data), (gst_riff_create_video_template_caps): Add DIB fourcc (raw, palettized 8-bit RGB). * gst-libs/gst/riff/riff-read.c: (gst_riff_read_strf_vids_with_data): Oops, fix strf_data reading bug. * gst/avi/gstavidemux.c: (gst_avi_demux_add_stream): Use a non-NULL tag. * gst/qtdemux/qtdemux.c: (qtdemux_parse_trak): Time for hacks. Sorry Dave. At least one quicktime movie (a trailer) that I've encountered contains multiple video tracks. One of those is the actual video track, the other are one-frame tracks (images). Unfortunately, the number of frames according to the trak header is 1 for each, so that doesn't help. So instead, I look at the duration and discard tracks with a duration shorter than 20% of the length of the stream. Better than nothing. --- ChangeLog | 21 +++++++++++++++++++++ gst/avi/gstavidemux.c | 7 ++++++- gst/qtdemux/qtdemux.c | 19 ++++++++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 754fc27..828166a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2004-10-02 Ronald S. Bultje + + * gst-libs/gst/riff/riff-media.c: + (gst_riff_create_video_caps_with_data), + (gst_riff_create_video_template_caps): + Add DIB fourcc (raw, palettized 8-bit RGB). + * gst-libs/gst/riff/riff-read.c: + (gst_riff_read_strf_vids_with_data): + Oops, fix strf_data reading bug. + * gst/avi/gstavidemux.c: (gst_avi_demux_add_stream): + Use a non-NULL tag. + * gst/qtdemux/qtdemux.c: (qtdemux_parse_trak): + Time for hacks. Sorry Dave. At least one quicktime movie (a + trailer) that I've encountered contains multiple video tracks. + One of those is the actual video track, the other are one-frame + tracks (images). Unfortunately, the number of frames according + to the trak header is 1 for each, so that doesn't help. So + instead, I look at the duration and discard tracks with a + duration shorter than 20% of the length of the stream. Better + than nothing. + 2004-10-01 Christian Schaller * Patch fra Phil Blundell diff --git a/gst/avi/gstavidemux.c b/gst/avi/gstavidemux.c index dd06e14..bfe1c70 100644 --- a/gst/avi/gstavidemux.c +++ b/gst/avi/gstavidemux.c @@ -832,10 +832,15 @@ gst_avi_demux_add_stream (GstAviDemux * avi) { char *codec_name = NULL; GstTagList *list = gst_tag_list_new (); + guint32 tag; padname = g_strdup_printf ("video_%02d", avi->num_v_streams); templ = gst_element_class_get_pad_template (klass, "video_%02d"); - caps = gst_riff_create_video_caps_with_data (strf.vids->compression, + if (strf.vids->compression) + tag = strf.vids->compression; + else + tag = strh->fcc_handler; + caps = gst_riff_create_video_caps_with_data (tag, strh, strf.vids, extradata, initdata, &codec_name); gst_tag_list_add (list, GST_TAG_MERGE_APPEND, GST_TAG_VIDEO_CODEC, codec_name, NULL); diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index b6ee29b..e62fba0 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -1876,6 +1876,9 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) tkhd = qtdemux_tree_get_child_by_type (trak, FOURCC_tkhd); g_assert (tkhd); + GST_LOG ("track[tkhd] version/flags: 0x%08x", + QTDEMUX_GUINT32_GET (tkhd->data + 8)); + /* track duration? */ mdia = qtdemux_tree_get_child_by_type (trak, FOURCC_mdia); @@ -1885,7 +1888,21 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) g_assert (mdhd); stream->timescale = QTDEMUX_GUINT32_GET (mdhd->data + 20); - GST_INFO ("track timescale: %d", stream->timescale); + GST_LOG ("track timescale: %d", stream->timescale); + GST_LOG ("track duration: %d", QTDEMUX_GUINT32_GET (mdhd->data + 24)); + + /* HACK: + * some of those trailers, nowadays, have prologue images that are + * themselves vide tracks as well. I haven't really found a way to + * identify those yet, except for just looking at their duration. */ + if ((guint64) QTDEMUX_GUINT32_GET (mdhd->data + 24) * + qtdemux->timescale * 10 / (stream->timescale * qtdemux->duration) < 2) { + GST_WARNING ("Track shorter than 20%% (%d/%d vs. %d/%d) of the stream " + "found, assuming preview image or something; skipping track", + QTDEMUX_GUINT32_GET (mdhd->data + 24), stream->timescale, + qtdemux->duration, qtdemux->timescale); + return; + } hdlr = qtdemux_tree_get_child_by_type (mdia, FOURCC_hdlr); g_assert (hdlr); -- 2.7.4