[x264-devel] commit: change DEBUG_DUMP_FRAME to run-time --dump-yuv (Loren Merritt )

git version control git at videolan.org
Tue May 20 12:08:26 CEST 2008


x264 | branch: master | Loren Merritt <pengvado at akuvian.org> | Sun May 18 06:23:57 2008 -0600| [5c257938de9e0017762395d63925a9747a0ff6e6]

change DEBUG_DUMP_FRAME to run-time --dump-yuv

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=5c257938de9e0017762395d63925a9747a0ff6e6
---

 common/common.c   |    2 ++
 encoder/encoder.c |   36 +++++++++++-------------------------
 x264.c            |    2 ++
 x264.h            |    1 +
 4 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/common/common.c b/common/common.c
index f88bf8c..8a8f660 100644
--- a/common/common.c
+++ b/common/common.c
@@ -430,6 +430,8 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
     OPT("visualize")
         p->b_visualize = atobool(value);
 #endif
+    OPT("dump-yuv")
+        p->psz_dump_yuv = strdup(value);
     OPT2("analyse", "partitions")
     {
         p->analyse.inter = 0;
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 35ebad1..807d19d 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -36,7 +36,6 @@
 #endif
 
 //#define DEBUG_MB_TYPE
-//#define DEBUG_DUMP_FRAME
 
 #define NALU_OVERHEAD 5 // startcode + NAL type costs 5 bytes per frame
 
@@ -58,27 +57,19 @@ static float x264_psnr( int64_t i_sqe, int64_t i_size )
     return (float)(-10.0 * log( f_mse ) / log( 10.0 ));
 }
 
-#ifdef DEBUG_DUMP_FRAME
-static void x264_frame_dump( x264_t *h, x264_frame_t *fr, char *name )
+static void x264_frame_dump( x264_t *h )
 {
-    FILE *f = fopen( name, "r+b" );
+    FILE *f = fopen( h->param.psz_dump_yuv, "r+b" );
     int i, y;
     if( !f )
         return;
-
     /* 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( y = 0; y < h->param.i_height / ( i == 0 ? 1 : 2 ); y++ )
-        {
-            fwrite( &fr->plane[i][y*fr->i_stride[i]], 1, h->param.i_width / ( i == 0 ? 1 : 2 ), f );
-        }
-    }
+    fseek( f, h->fdec->i_frame * h->param.i_height * h->param.i_width * 3/2, SEEK_SET );
+    for( i = 0; i < h->fdec->i_plane; i++ )
+        for( y = 0; y < h->param.i_height >> !!i; y++ )
+            fwrite( &h->fdec->plane[i][y*h->fdec->i_stride[i]], 1, h->param.i_width >> !!i, f );
     fclose( f );
 }
-#endif
 
 
 /* Fill "default" values */
@@ -698,10 +689,10 @@ x264_t *x264_encoder_open   ( x264_param_t *param )
     if( x264_ratecontrol_new( h ) < 0 )
         return NULL;
 
-#ifdef DEBUG_DUMP_FRAME
+    if( h->param.psz_dump_yuv )
     {
         /* create or truncate the reconstructed video file */
-        FILE *f = fopen( "fdec.yuv", "w" );
+        FILE *f = fopen( h->param.psz_dump_yuv, "w" );
         if( f )
             fclose( f );
         else
@@ -711,7 +702,6 @@ x264_t *x264_encoder_open   ( x264_param_t *param )
             return NULL;
         }
     }
-#endif
 
     return h;
 }
@@ -886,9 +876,7 @@ static void x264_fdec_filter_row( x264_t *h, int mb_y )
     int b_deblock = !h->sh.i_disable_deblocking_filter_idc;
     int b_end = mb_y == h->sps->i_mb_height;
     int min_y = mb_y - (1 << h->sh.b_mbaff);
-#ifndef DEBUG_DUMP_FRAME
-    b_deblock &= b_hpel;
-#endif
+    b_deblock &= b_hpel || h->param.psz_dump_yuv;
     if( mb_y & h->sh.b_mbaff )
         return;
     if( min_y < 0 )
@@ -1725,10 +1713,8 @@ static void x264_encoder_frame_end( x264_t *h, x264_t *thread_current,
 }
 #endif
 
-#ifdef DEBUG_DUMP_FRAME
-    /* Dump reconstructed frame */
-    x264_frame_dump( h, h->fdec, "fdec.yuv" );
-#endif
+    if( h->param.psz_dump_yuv )
+        x264_frame_dump( h );
 }
 
 /****************************************************************************
diff --git a/x264.c b/x264.c
index 70adb71..8484cad 100644
--- a/x264.c
+++ b/x264.c
@@ -319,6 +319,7 @@ static void Help( x264_param_t *defaults, int b_longhelp )
     H1( "      --asm <integer>         Override CPU detection\n" );
     H1( "      --no-asm                Disable all CPU optimizations\n" );
     H1( "      --visualize             Show MB types overlayed on the encoded video\n" );
+    H1( "      --dump-yuv <string>     Save reconstructed frames\n" );
     H1( "      --sps-id <integer>      Set SPS and PPS id numbers [%d]\n", defaults->i_sps_id );
     H1( "      --aud                   Use access unit delimiters\n" );
     H0( "\n" );
@@ -447,6 +448,7 @@ static int  Parse( int argc, char **argv,
             { "verbose", no_argument,       NULL, 'v' },
             { "progress",no_argument,       NULL, OPT_PROGRESS },
             { "visualize",no_argument,      NULL, OPT_VISUALIZE },
+            { "dump-yuv",required_argument, NULL, 0 },
             { "sps-id",  required_argument, NULL, 0 },
             { "aud",     no_argument,       NULL, 0 },
             { "nr",      required_argument, NULL, 0 },
diff --git a/x264.h b/x264.h
index d2c6510..c41d6f0 100644
--- a/x264.h
+++ b/x264.h
@@ -210,6 +210,7 @@ typedef struct x264_param_t
     void        *p_log_private;
     int         i_log_level;
     int         b_visualize;
+    char        *psz_dump_yuv;  /* filename for reconstructed frames */
 
     /* Encoder analyser parameters */
     struct



More information about the x264-devel mailing list