Mercurial > libavformat.hg
changeset 6481:123ebc5da327 libavformat
Fix aspect ratio for files that have it stored in
ff_asf_extended_content_header.
Patch by Richard Buteau, rbuteau rgbnetworks com
author | cehoyos |
---|---|
date | Thu, 23 Sep 2010 03:40:06 +0000 |
parents | d55dd9679e52 |
children | c59fad269e39 |
files | asfdec.c |
diffstat | 1 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/asfdec.c Tue Sep 21 22:21:12 2010 +0000 +++ b/asfdec.c Thu Sep 23 03:40:06 2010 +0000 @@ -467,7 +467,15 @@ value_len = get_le16(pb); if (!value_type && value_len%2) value_len += 1; - get_tag(s, name, value_type, value_len); + /** + * My sample has that stream set to 0 maybe that mean the container. + * Asf stream count start at 1. I am using 0 to the container value since it's unused + */ + if (!strcmp(name, "AspectRatioX")){ + dar[0].num= get_value(s->pb, value_type); + } else if(!strcmp(name, "AspectRatioY")){ + dar[0].den= get_value(s->pb, value_type); + } else get_tag(s, name, value_type, value_len); } } else if (!guidcmp(&g, &ff_asf_metadata_header)) { int n, stream_num, name_len, value_len, value_type, value_num; @@ -626,11 +634,16 @@ AVStream *st = s->streams[stream_num]; if (!st->codec->bit_rate) st->codec->bit_rate = bitrate[i]; - if (dar[i].num > 0 && dar[i].den > 0) + if (dar[i].num > 0 && dar[i].den > 0){ av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den, dar[i].num, dar[i].den, INT_MAX); -//av_log(s, AV_LOG_ERROR, "dar %d:%d sar=%d:%d\n", dar[i].num, dar[i].den, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); + } else if ((dar[0].num > 0) && (dar[0].den > 0) && (st->codec->codec_type==CODEC_TYPE_VIDEO)) // Use ASF container value if the stream doesn't AR set. + av_reduce(&st->sample_aspect_ratio.num, + &st->sample_aspect_ratio.den, + dar[0].num, dar[0].den, INT_MAX); + +//av_log(s, AV_LOG_INFO, "i=%d, st->codec->codec_type:%d, dar %d:%d sar=%d:%d\n", i, st->codec->codec_type, dar[i].num, dar[i].den, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); // copy and convert language codes to the frontend if (asf->streams[i].stream_language_index < 128) {