diff options
author | Luciana Fujii Pontello <lucianafujii@collabora.co.uk> | 2011-11-16 00:03:12 -0500 |
---|---|---|
committer | Alessandro Decina <alessandro.d@gmail.com> | 2011-12-01 08:23:22 +0100 |
commit | 6d85d4882aafbdc5701551923b76dafa353dd332 (patch) | |
tree | d7b8e3bf603ca9717ecd219b6689b6e9b7fa3434 /gst | |
parent | 467fd98e5b55522cccdec8a69e7cd706132b7b03 (diff) | |
download | gstreamer-plugins-bad-6d85d4882aafbdc5701551923b76dafa353dd332.tar.gz |
h264parse: respect pixel-aspect-ratio
Parse pixel-aspect-ratio in vui information.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/videoparsers/gsth264parse.c | 19 | ||||
-rw-r--r-- | gst/videoparsers/gsth264parse.h | 1 |
2 files changed, 19 insertions, 1 deletions
diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index b8feb37e4..6e9f907ad 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -193,6 +193,8 @@ gst_h264_parse_reset (GstH264Parse * h264parse) h264parse->height = 0; h264parse->fps_num = 0; h264parse->fps_den = 0; + h264parse->sar_width = 0; + h264parse->sar_height = 0; gst_buffer_replace (&h264parse->codec_data, NULL); h264parse->nal_length_size = 4; h264parse->packetized = FALSE; @@ -861,7 +863,10 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) caps = gst_caps_copy (sink_caps); } else if (G_UNLIKELY (h264parse->width != sps->width || h264parse->height != sps->height || h264parse->fps_num != sps->fps_num - || h264parse->fps_den != sps->fps_den || modified)) { + || h264parse->fps_den != sps->fps_den || + h264parse->sar_width != sps->vui_parameters.sar_width || + h264parse->sar_height != sps->vui_parameters.sar_height + || modified)) { caps = gst_caps_copy (sink_caps); /* sps should give this */ gst_caps_set_simple (caps, "width", G_TYPE_INT, sps->width, @@ -878,6 +883,13 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) gst_base_parse_set_frame_rate (GST_BASE_PARSE (h264parse), h264parse->fps_num, h264parse->fps_den, 0, 0); } + if ((sps->vui_parameters.sar_width > 0 && + sps->vui_parameters.sar_height > 0) && + (h264parse->sar_width != sps->vui_parameters.sar_width || + h264parse->sar_height != sps->vui_parameters.sar_height)) { + h264parse->sar_width = sps->vui_parameters.sar_width; + h264parse->sar_height = sps->vui_parameters.sar_height; + } } if (caps) { @@ -886,6 +898,9 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) gst_h264_parse_get_string (h264parse, TRUE, h264parse->format), "alignment", G_TYPE_STRING, gst_h264_parse_get_string (h264parse, FALSE, h264parse->align), NULL); + if (h264parse->sar_width > 0 && h264parse->sar_height > 0) + gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION, + h264parse->sar_width, h264parse->sar_height, NULL); if (buf) { gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buf, NULL); gst_buffer_replace (&h264parse->codec_data, buf); @@ -1223,6 +1238,8 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps) gst_structure_get_int (str, "height", &h264parse->height); gst_structure_get_fraction (str, "framerate", &h264parse->fps_num, &h264parse->fps_den); + gst_structure_get_fraction (str, "pixel-aspect-ratio", &h264parse->sar_width, + &h264parse->sar_height); /* get upstream format and align from caps */ gst_h264_parse_format_from_caps (caps, &format, &align); diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h index e013a3fac..d311dd09e 100644 --- a/gst/videoparsers/gsth264parse.h +++ b/gst/videoparsers/gsth264parse.h @@ -58,6 +58,7 @@ struct _GstH264Parse /* stream */ gint width, height; gint fps_num, fps_den; + gint sar_width, sar_height; GstBuffer *codec_data; guint nal_length_size; gboolean packetized; |