diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2008-07-08 21:05:18 +0000 |
---|---|---|
committer | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2008-07-08 21:05:18 +0000 |
commit | 2c11fa8bb6c12a18c73cc60c86903d92823b5f87 (patch) | |
tree | d357d609307cbb1b7aff8065d9ca2c509383b31c | |
parent | 5251a948297fbef89e8040880e20f8f18a826c77 (diff) |
gst/qtdemux/qtdemux.c: Set pixel-aspect-ratio in caps using display width and height provided in track.
Original commit message from CVS:
* gst/qtdemux/qtdemux.c: (gst_qtdemux_add_stream),
(qtdemux_parse_trak):
Set pixel-aspect-ratio in caps using display width and height
provided in track.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | gst/qtdemux/qtdemux.c | 32 |
2 files changed, 39 insertions, 0 deletions
@@ -1,3 +1,10 @@ +2008-07-08 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> + + * gst/qtdemux/qtdemux.c: (gst_qtdemux_add_stream), + (qtdemux_parse_trak): + Set pixel-aspect-ratio in caps using display width and height + provided in track. + 2008-07-08 Sebastian Dröge <sebastian.droege@collabora.co.uk> * configure.ac: diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index c54e1deb..a273bc29 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -136,6 +136,9 @@ struct _QtDemuxStream /* video info */ gint width; gint height; + /* aspect ratio */ + gint display_width; + gint display_height; /* Numerator/denominator framerate */ gint fps_n; gint fps_d; @@ -2672,6 +2675,25 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux, "height", G_TYPE_INT, stream->height, "framerate", GST_TYPE_FRACTION, stream->fps_n, stream->fps_d, NULL); + /* calculate pixel-aspect-ratio using display width and height */ + GST_DEBUG_OBJECT (qtdemux, "video size %dx%d, target display size %dx%d", + stream->width, stream->height, + stream->display_width, stream->display_height); + + if (stream->display_width > 0 && stream->display_height > 0 && + stream->width > 0 && stream->height > 0) { + gint n, d; + + /* calculate the pixel aspect ratio using the display and pixel w/h */ + n = stream->display_width * stream->height; + d = stream->display_height * stream->width; + if (n != d) { + GST_DEBUG_OBJECT (qtdemux, "setting PAR to %d/%d", n, d); + gst_caps_set_simple (stream->caps, "pixel-aspect-ratio", + GST_TYPE_FRACTION, n, d, NULL); + } + } + depth = stream->bits_per_sample; /* more than 32 bits means grayscale */ @@ -3251,6 +3273,8 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) if (stream->subtype == FOURCC_vide) { guint32 fourcc; + const guint8 *tkhd_data = (const guint8 *) tkhd->data; + guint8 version; stream->sampled = TRUE; @@ -3269,6 +3293,14 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) GST_LOG_OBJECT (qtdemux, "frame count: %u", QT_UINT16 (stsd_data + offset + 48)); + version = QT_UINT8 (tkhd_data + 8); + if (version == 1) + offset = 96; + else + offset = 84; + stream->display_width = (guint) QT_FP32 (tkhd_data + offset); + stream->display_height = (guint) QT_FP32 (tkhd_data + offset + 4); + if (fourcc == FOURCC_drms) goto error_encrypted; |