Fix aspect ratio for files that have it stored in

ff_asf_extended_content_header.
Fixes issue 690.

Patch by Richard Buteau, rbuteau rgbnetworks com

Originally committed as revision 25158 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Richard Buteau 2010-09-23 03:40:06 +00:00 committed by Carl Eugen Hoyos
parent 9c193cc47c
commit 6ac6e3d123
1 changed files with 16 additions and 3 deletions

View File

@ -467,7 +467,15 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
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 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
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) {