[FFmpeg-devel] [PATCH2/3] asfdec.c doesn't detect aspect ratio properly in some case
Richard Buteau
rbuteau
Tue Sep 21 19:15:38 CEST 2010
Hi all,
In some case ASF file don't have aspect ratio set in
ff_asf_metadata_header but in ff_asf_extended_content_header.
The results was a stretch out file.
This patch extract that aspect ratio info and pass it down to the
container.
Richard
diff -uNr -x .svn -x '*.d' ffmpeg/libavformat/asfdec.c
ffmpeg.asfAR/libavformat/asfdec.c
--- ffmpeg/libavformat/asfdec.c 2010-09-14 13:04:36.000000000 -0500
+++ ffmpeg.asfAR/libavformat/asfdec.c 2010-09-21 11:54:10.000000000
-0500
@@ -467,6 +467,12 @@
value_len = get_le16(pb);
if (!value_type && value_len%2)
value_len += 1;
+ int stream_num=0; //Ideally we should find the
video stream and set it there. My sample has that stream set to 0 maybe
that mean the container.
+ if (!strcmp(name, "AspectRatioX"))
+ dar[stream_num].num= get_value(s->pb,
value_type);
+ else if(!strcmp(name, "AspectRatioY"))
+ dar[stream_num].den= get_value(s->pb,
value_type);
+ else
get_tag(s, name, value_type, value_len);
}
} else if (!guidcmp(&g, &ff_asf_metadata_header)) {
@@ -630,7 +636,12 @@
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) //Use 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_ERROR, "i=%d, dar %d:%d sar=%d:%d\n", i, 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) {
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: asfAR.patch.txt
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100921/634f8e88/attachment.txt>
More information about the ffmpeg-devel
mailing list