[FFmpeg-cvslog] r25158 - trunk/libavformat/asfdec.c
cehoyos
subversion
Thu Sep 23 05:40:07 CEST 2010
Author: cehoyos
Date: Thu Sep 23 05:40:06 2010
New Revision: 25158
Log:
Fix aspect ratio for files that have it stored in
ff_asf_extended_content_header.
Patch by Richard Buteau, rbuteau rgbnetworks com
Modified:
trunk/libavformat/asfdec.c
Modified: trunk/libavformat/asfdec.c
==============================================================================
--- trunk/libavformat/asfdec.c Wed Sep 22 04:18:03 2010 (r25157)
+++ trunk/libavformat/asfdec.c Thu Sep 23 05:40:06 2010 (r25158)
@@ -467,7 +467,15 @@ static int asf_read_header(AVFormatConte
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(AVFormatConte
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) {
More information about the ffmpeg-cvslog
mailing list