--- /dev/null
+Here is one test method which checks that the encoder's
+view of decoded pictures in the same as the decoder's view.
+This ensures that there is no distortion besides what is
+inherently caused by compression.
+
+# Install and compile x264 :
+svn co svn://svn.videolan.org/x264/trunk x264
+cd x264
+./configure
+perl -pi -e '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 produces fdec.yuv
+./JM/bin/ldecod.exe -i output.h264 -o ref.yuv
+diff ref.yuv fdec.yuv
#ifdef DEBUG_DUMP_FRAME
static void x264_frame_dump( x264_t *h, x264_frame_t *fr, char *name )
{
- FILE * f = fopen( name, "a" );
+ FILE *f = fopen( name, "r+b" );
int i, y;
+ if( !f )
+ return;
- fseek( f, 0, SEEK_END );
+ /* Write the frame in display order */
+ fseek( f, fr->i_frame * h->param.i_height * h->param.i_width * 3 / 2, SEEK_SET );
for( i = 0; i < fr->i_plane; i++ )
{
for( i = 1; i < param->i_threads; i++ )
h->thread[i] = x264_malloc( sizeof(x264_t) );
+#ifdef DEBUG_DUMP_FRAME
+ {
+ /* create or truncate the reconstructed video file */
+ FILE *f = fopen( "fdec.yuv", "w" );
+ if( f )
+ fclose( f );
+ else
+ {
+ x264_log( h, X264_LOG_ERROR, "can't write to fdec.yuv\n" );
+ x264_free( h );
+ return NULL;
+ }
+ }
+#endif
+
return h;
}
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 )
{
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 );
/* 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 */