[FFmpeg-devel] [RFC] RM muxer fix

Kostya kostya.shishkov
Thu Nov 1 11:07:23 CET 2007


On Wed, Oct 31, 2007 at 08:28:52PM +0100, Michael Niedermayer wrote:
> Hi
> 
> On Tue, Oct 23, 2007 at 02:06:31PM +0300, Kostya wrote:
> > As spotted by Benoit, current regression tests fail
> > in part of RM testing.
> > 
> > That happens because lavf RM muxer generates very
> > incorrect data (length and position values).
> 
> no, a segfault in the rm demuxer is a bug in the rm demuxer and no
> change to the muxer can fix it!
> also we cannot drop support for old rm files, correct or not
> 
> this patch is "on hold" until the demxuer is fixed and the regression
> tests pass again

Here are two alternative patches to make muxer write correct packets
with either correct length or as a whole frame.
Regression values were taken on x86_64.
 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
-------------- next part --------------
Index: tests/rotozoom.regression.ref
===================================================================
--- tests/rotozoom.regression.ref	(revision 10851)
+++ tests/rotozoom.regression.ref	(working copy)
@@ -117,12 +117,12 @@
 8334488 ./tests/data/a-jpegls.avi
 a63d4e3ea1f0b0c0d44821da9e09b8f4 *./tests/data/out.yuv
 stddev:  0.67 PSNR:51.57 bytes:7602176
-989a42671603dc1a7e6b156dccf0e820 *./tests/data/a-rv10.rm
-154330 ./tests/data/a-rv10.rm
+a3b3ec3c820c2721710f394a9dd3a502 *./tests/data/a-rv10.rm
+154080 ./tests/data/a-rv10.rm
 61213b91b359697ebcefb9e0a53ac54a *./tests/data/out.yuv
 stddev:  5.43 PSNR:33.41 bytes:7602176
-1b1cbff8e78602de498b4314cb991e72 *./tests/data/a-rv20.rm
-132754 ./tests/data/a-rv20.rm
+1a35de23f0fbfb5dbf8d30ef37918a39 *./tests/data/a-rv20.rm
+132504 ./tests/data/a-rv20.rm
 c66afdcc0daac2f1b4167b9811968877 *./tests/data/out.yuv
 stddev:  5.42 PSNR:33.44 bytes:7602176
 4eb34d2de25f67a2706456e999338fe9 *./tests/data/a-asv1.avi
Index: tests/libav.regression.ref
===================================================================
--- tests/libav.regression.ref	(revision 10851)
+++ tests/libav.regression.ref	(working copy)
@@ -5,8 +5,8 @@
 786446e80ead936e5faa8f5908f19281 *./tests/data/b-libav.asf
 339775 ./tests/data/b-libav.asf
 ./tests/data/b-libav.asf CRC=0x74113749
-1ce78eeb6881ffe5b649a9b5105de919 *./tests/data/b-libav.rm
-355405 ./tests/data/b-libav.rm
+428169e93b86276440355a99562b2899 *./tests/data/b-libav.rm
+355280 ./tests/data/b-libav.rm
 bdb7484c68db722f66ba1630cf79844c *./tests/data/b-libav.mpg
 378880 ./tests/data/b-libav.mpg
 ./tests/data/b-libav.mpg CRC=0x2b71a386
Index: tests/ffmpeg.regression.ref
===================================================================
--- tests/ffmpeg.regression.ref	(revision 10851)
+++ tests/ffmpeg.regression.ref	(working copy)
@@ -117,12 +117,12 @@
 9086676 ./tests/data/a-jpegls.avi
 0f8637e9b861230aff9894825af83720 *./tests/data/out.yuv
 stddev:  2.84 PSNR:39.04 bytes:7602176
-7eee6367442884321e27d15a26bc032a *./tests/data/a-rv10.rm
-667915 ./tests/data/a-rv10.rm
+0b3ac644ac21652240e24479fccf8243 *./tests/data/a-rv10.rm
+667665 ./tests/data/a-rv10.rm
 d507be4253a9c8211a3738c58ba28118 *./tests/data/out.yuv
 stddev:  8.06 PSNR:29.99 bytes:7602176
-55c73229105f35cbb06ee0dda215df2f *./tests/data/a-rv20.rm
-640856 ./tests/data/a-rv20.rm
+119de1f2f5e942e0ec07321a84d2086c *./tests/data/a-rv20.rm
+640606 ./tests/data/a-rv20.rm
 297dc46da1a256c0a97158c036c30c7f *./tests/data/out.yuv
 stddev:  8.26 PSNR:29.77 bytes:7602176
 d13292f4583618d1b7b525a9ee010dff *./tests/data/a-asv1.avi
Index: libavformat/rmenc.c
===================================================================
--- libavformat/rmenc.c	(revision 10864)
+++ libavformat/rmenc.c	(working copy)
@@ -348,7 +348,7 @@
 
     /* Well, I spent some time finding the meaning of these bits. I am
        not sure I understood everything, but it works !! */
-#if 1
+#if 0
     write_packet_header(s, stream, size + 7, key_frame);
     /* bit 7: '1' if final packet of a frame converted in several packets */
     put_byte(pb, 0x81);
@@ -363,10 +363,8 @@
     put_be16(pb, 0x4000 + (size));              /* offset from the start or the end */
 #else
     /* full frame */
-    write_packet_header(s, size + 6);
-    put_byte(pb, 0xc0);
-    put_be16(pb, 0x4000 + size); /* total frame size */
-    put_be16(pb, 0x4000 + packet_number * 126); /* position in stream */
+    write_packet_header(s, stream, size + 2, key_frame);
+    put_byte(pb, 0x40);
 #endif
     put_byte(pb, stream->nb_frames & 0xff);
 
-------------- next part --------------
Index: tests/libav.regression.ref
===================================================================
--- tests/libav.regression.ref	(revision 10851)
+++ tests/libav.regression.ref	(working copy)
@@ -5,8 +5,8 @@
 786446e80ead936e5faa8f5908f19281 *./tests/data/b-libav.asf
 339775 ./tests/data/b-libav.asf
 ./tests/data/b-libav.asf CRC=0x74113749
-1ce78eeb6881ffe5b649a9b5105de919 *./tests/data/b-libav.rm
-355405 ./tests/data/b-libav.rm
+c351132527ccb1e8cab06cc0822fde23 *./tests/data/b-libav.rm
+355417 ./tests/data/b-libav.rm
 bdb7484c68db722f66ba1630cf79844c *./tests/data/b-libav.mpg
 378880 ./tests/data/b-libav.mpg
 ./tests/data/b-libav.mpg CRC=0x2b71a386
Index: tests/ffmpeg.regression.ref
===================================================================
--- tests/ffmpeg.regression.ref	(revision 10851)
+++ tests/ffmpeg.regression.ref	(working copy)
@@ -117,12 +117,12 @@
 9086676 ./tests/data/a-jpegls.avi
 0f8637e9b861230aff9894825af83720 *./tests/data/out.yuv
 stddev:  2.84 PSNR:39.04 bytes:7602176
-7eee6367442884321e27d15a26bc032a *./tests/data/a-rv10.rm
-667915 ./tests/data/a-rv10.rm
+99ef24bf57718fd29a7a91b22af2b3fe *./tests/data/a-rv10.rm
+667935 ./tests/data/a-rv10.rm
 d507be4253a9c8211a3738c58ba28118 *./tests/data/out.yuv
 stddev:  8.06 PSNR:29.99 bytes:7602176
-55c73229105f35cbb06ee0dda215df2f *./tests/data/a-rv20.rm
-640856 ./tests/data/a-rv20.rm
+d1caf150a7b53db8fd5eb8c1d0701daf *./tests/data/a-rv20.rm
+640876 ./tests/data/a-rv20.rm
 297dc46da1a256c0a97158c036c30c7f *./tests/data/out.yuv
 stddev:  8.26 PSNR:29.77 bytes:7602176
 d13292f4583618d1b7b525a9ee010dff *./tests/data/a-asv1.avi
Index: libavformat/rmenc.c
===================================================================
--- libavformat/rmenc.c	(revision 10851)
+++ libavformat/rmenc.c	(working copy)
@@ -349,7 +349,7 @@
     /* Well, I spent some time finding the meaning of these bits. I am
        not sure I understood everything, but it works !! */
 #if 1
-    write_packet_header(s, stream, size + 7, key_frame);
+    write_packet_header(s, stream, size + 7 + (size >= 0x4000)*4, key_frame);
     /* bit 7: '1' if final packet of a frame converted in several packets */
     put_byte(pb, 0x81);
     /* bit 7: '1' if I frame. bits 6..0 : sequence number in current
@@ -359,8 +359,13 @@
     } else {
         put_byte(pb, 0x01);
     }
-    put_be16(pb, 0x4000 + (size)); /* total frame size */
-    put_be16(pb, 0x4000 + (size));              /* offset from the start or the end */
+    if(size >= 0x4000){
+        put_be32(pb, (size)); /* total frame size */
+        put_be32(pb, (size));              /* offset from the start or the end */    
+    }else{
+        put_be16(pb, 0x4000 | (size)); /* total frame size */
+        put_be16(pb, 0x4000 | (size));              /* offset from the start or the end */
+    }
 #else
     /* full frame */
     write_packet_header(s, size + 6);



More information about the ffmpeg-devel mailing list