[FFmpeg-devel] [PATCH] rmdec.c: correctly skip indexes
Ronald S. Bultje
rsbultje
Tue Mar 10 04:57:58 CET 2009
Hi,
On Mon, Mar 9, 2009 at 6:14 PM, Reimar D?ffinger
<Reimar.Doeffinger at gmx.de> wrote:
> The indendation is off. Also I think moving the 20 to the other side
> obfuscates things. Consider of maybe this is better:
[..]
Almost copied, I kept the n_pkts variable because I'd like to print it
in the log msg if output is wrong, and renamed the fixed_len variable
to something more sensible (expected_len).
See attached, thanks for the comments. :-).
Ronald
-------------- next part --------------
Index: ffmpeg-svn/libavformat/rmdec.c
===================================================================
--- ffmpeg-svn.orig/libavformat/rmdec.c 2009-03-09 23:54:17.000000000 -0400
+++ ffmpeg-svn/libavformat/rmdec.c 2009-03-09 23:55:56.000000000 -0400
@@ -440,7 +440,19 @@
state= (state<<8) + get_byte(pb);
if(state == MKBETAG('I', 'N', 'D', 'X')){
- len = get_be16(pb) - 6;
+ int n_pkts, expected_len;
+ len = get_be32(pb);
+ url_fskip(pb, 2);
+ n_pkts = get_be32(pb);
+ expected_len = 20 + n_pkts * 14;
+ if (len == 20)
+ /* some files don't add index entries to chunk size... */
+ len = expected_len;
+ else if (len != expected_len)
+ av_log(s, AV_LOG_WARNING,
+ "Index size %d (%d pkts) is wrong, should be %d.\n",
+ len, n_pkts, expected_len);
+ len -= 14; // we already read part of the index header
if(len<0)
continue;
goto skip;
More information about the ffmpeg-devel
mailing list