From 79249be0aae8ba77d1f7685ac5b3c36a4d8552c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 15 Jul 2013 22:57:06 +0100 Subject: [PATCH] h263parse: add pixel-aspect-ratio if upstream doesn't provide one --- gst/videoparsers/gsth263parse.c | 16 ++++++++++++++-- gst/videoparsers/h263parse.c | 7 +++++++ gst/videoparsers/h263parse.h | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/gst/videoparsers/gsth263parse.c b/gst/videoparsers/gsth263parse.c index 06ff205..8d7b5e6 100644 --- a/gst/videoparsers/gsth263parse.c +++ b/gst/videoparsers/gsth263parse.c @@ -180,9 +180,9 @@ static void gst_h263_parse_set_src_caps (GstH263Parse * h263parse, const H263Params * params) { - GstStructure *st; + GstStructure *st = NULL; GstCaps *caps, *sink_caps; - gint fr_num, fr_denom; + gint fr_num, fr_denom, par_num, par_denom; g_assert (h263parse->state == PASSTHROUGH || h263parse->state == GOT_HEADER); @@ -211,6 +211,18 @@ gst_h263_parse_set_src_caps (GstH263Parse * h263parse, gst_caps_set_simple (caps, "width", G_TYPE_INT, params->width, "height", G_TYPE_INT, params->height, NULL); + if (st != NULL + && gst_structure_get_fraction (st, "pixel-aspect-ratio", &par_num, + &par_denom)) { + /* Got it in caps - nothing more to do */ + GST_DEBUG_OBJECT (h263parse, "sink caps override PAR"); + } else { + /* Caps didn't have the framerate - get it from params */ + gst_h263_parse_get_par (params, &par_num, &par_denom); + } + gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION, + par_num, par_denom, NULL); + if (h263parse->state == GOT_HEADER) { gst_caps_set_simple (caps, "annex-d", G_TYPE_BOOLEAN, (params->features & H263_OPTION_UMV_MODE), diff --git a/gst/videoparsers/h263parse.c b/gst/videoparsers/h263parse.c index b6ea4d2..bd118d3 100644 --- a/gst/videoparsers/h263parse.c +++ b/gst/videoparsers/h263parse.c @@ -668,3 +668,10 @@ gst_h263_parse_get_framerate (const H263Params * params, gint * num, *num = params->pcfnum; *denom = params->pcfdenom; } + +void +gst_h263_parse_get_par (const H263Params * params, gint * num, gint * denom) +{ + *num = params->parnum; + *denom = params->pardenom; +} diff --git a/gst/videoparsers/h263parse.h b/gst/videoparsers/h263parse.h index 0781280..72a61da 100644 --- a/gst/videoparsers/h263parse.h +++ b/gst/videoparsers/h263parse.h @@ -141,6 +141,10 @@ void gst_h263_parse_get_framerate (const H263Params * params, gint * num, gint * denom); +void gst_h263_parse_get_par (const H263Params * params, + gint * num, + gint * denom); + gint gst_h263_parse_get_profile (const H263Params * params); gint gst_h263_parse_get_level (const H263Params * params, -- 2.7.4