[x264-devel] [PATCH] test decoded pictures

Loïc Le Loarer lll+vlc at m4x.org
Fri May 19 10:21:07 CEST 2006


Hi,

Here is a patch which allows to check that the view of decoded pictures
in the encoder is the same as the decoder even when non references
frames are used (and display order is not the same as encoding order).

It also contains a document which explain how to do the comparaison
using the JM reference H264 decoder.

This is very usefull to check that any change in the encoder doesn't
break too much things.

Best regards.

-- 
Loïc

"heaven is not a place, it's a feeling"
-------------- next part --------------
diff -ruN x264.orig/doc/test_method.txt x264.new/doc/test_method.txt
--- x264.orig/doc/test_method.txt	1970-01-01 01:00:00.000000000 +0100
+++ x264.new/doc/test_method.txt	2006-05-19 10:08:52.000000000 +0200
@@ -0,0 +1,25 @@
+Here is one test method which check that the encoder
+vision of decoded pictures in the same as the decoder
+view, this ensure that there is distortion between what
+the encoder and the decoder.
+
+Install and compile x264 :
+svn co svn://svn.videolan.org/x264/trunk x264
+cd x264
+./configure
+perl -i -pe 's|//(#define DEBUG_DUMP_FRAME)|$1|' encoder/encoder.c # define DEBUG_DUMP_FRAME
+make
+cd ..
+
+Install and compile JM reference decoder :
+wget http://iphome.hhi.de/suehring/tml/download/jm10.2.zip
+unzip jm10.2.zip
+cd JM
+sh unixprep.sh
+cd ldecod
+make
+cd ../..
+
+./x264/x264 input.yuv -o output.h264 # this produce fdec.yuv
+./JM/bin/ldecod.exe -i output.h264 -o ref.yuv
+diff ref.yuv fdec.yuv
diff -ruN x264.orig/encoder/encoder.c x264.new/encoder/encoder.c
--- x264.orig/encoder/encoder.c	2006-05-19 10:05:05.000000000 +0200
+++ x264.new/encoder/encoder.c	2006-05-19 10:13:22.000000000 +0200
@@ -76,12 +76,22 @@
 }
 
 #ifdef DEBUG_DUMP_FRAME
-static void x264_frame_dump( x264_t *h, x264_frame_t *fr, char *name )
-{
-    FILE * f = fopen( name, "a" );
+#include <sys/stat.h> /* for open modes */
+#include <fcntl.h>    /* for open flags */
+static void x264_frame_dump( x264_t *h, x264_frame_t *fr, char *name, int i_frame )
+{
+    /* Open the dump frame in write mode without trunc nor append option,
+     * to allow seeking at the correct place (encoding order is different
+     * than display order).
+     * This is not possible with fopen directly, so use open system call
+     * and then fdopen to add a FILE structure on the created file descriptor.
+     */
+    int fd   = open( name, O_CREAT|O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
+    FILE * f = fdopen( fd, "w" );
     int i, y;
 
-    fseek( f, 0, SEEK_END );
+    /* Write the frame in display order */
+    i = fseek( f, i_frame * h->param.i_height * h->param.i_width * 3 / 2, SEEK_SET );
 
     for( i = 0; i < fr->i_plane; i++ )
     {
@@ -810,10 +820,8 @@
     h->i_ref0 = X264_MIN( h->i_ref0, 16 - h->i_ref1 );
 }
 
-static inline void x264_reference_update( x264_t *h )
+static inline void x264_fdec_deblock( x264_t *h )
 {
-    int i;
-
     /* apply deblocking filter to the current decoded picture */
     if( !h->sh.i_disable_deblocking_filter_idc )
     {
@@ -821,6 +829,13 @@
         x264_frame_deblocking_filter( h, h->sh.i_type );
         TIMER_STOP( i_mtime_filter );
     }
+}
+
+static inline void x264_reference_update( x264_t *h )
+{
+    int i;
+
+    x264_fdec_deblock( h );
     /* expand border */
     x264_frame_expand_border( h->fdec );
 
@@ -1479,6 +1494,10 @@
     /* handle references */
     if( i_nal_ref_idc != NAL_PRIORITY_DISPOSABLE )
         x264_reference_update( h );
+#ifdef DEBUG_DUMP_FRAME
+    else
+        x264_fdec_deblock( h );
+#endif
     x264_frame_put( h->frames.unused, h->fenc );
 
     /* increase frame count */
@@ -1585,7 +1604,7 @@
 
 #ifdef DEBUG_DUMP_FRAME
     /* Dump reconstructed frame */
-    x264_frame_dump( h, frame_psnr, "fdec.yuv" );
+    x264_frame_dump( h, frame_psnr, "fdec.yuv", h->fenc->i_frame );
 #endif
     return 0;
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.videolan.org/pipermail/x264-devel/attachments/20060519/1c697c9c/attachment.pgp 


More information about the x264-devel mailing list