Commit 92b3ea8c authored by Loren Merritt's avatar Loren Merritt

change DEBUG_DUMP_FRAME to run-time --dump-yuv

parent cb4dc4ae
...@@ -430,6 +430,8 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value ) ...@@ -430,6 +430,8 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
OPT("visualize") OPT("visualize")
p->b_visualize = atobool(value); p->b_visualize = atobool(value);
#endif #endif
OPT("dump-yuv")
p->psz_dump_yuv = strdup(value);
OPT2("analyse", "partitions") OPT2("analyse", "partitions")
{ {
p->analyse.inter = 0; p->analyse.inter = 0;
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#endif #endif
//#define DEBUG_MB_TYPE //#define DEBUG_MB_TYPE
//#define DEBUG_DUMP_FRAME
#define NALU_OVERHEAD 5 // startcode + NAL type costs 5 bytes per 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 ) ...@@ -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 )); return (float)(-10.0 * log( f_mse ) / log( 10.0 ));
} }
#ifdef DEBUG_DUMP_FRAME static void x264_frame_dump( x264_t *h )
static void x264_frame_dump( x264_t *h, x264_frame_t *fr, char *name )
{ {
FILE *f = fopen( name, "r+b" ); FILE *f = fopen( h->param.psz_dump_yuv, "r+b" );
int i, y; int i, y;
if( !f ) if( !f )
return; return;
/* Write the frame in display order */ /* Write the frame in display order */
fseek( f, fr->i_frame * h->param.i_height * h->param.i_width * 3 / 2, SEEK_SET ); 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( i = 0; i < fr->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 );
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 );
}
}
fclose( f ); fclose( f );
} }
#endif
/* Fill "default" values */ /* Fill "default" values */
...@@ -698,10 +689,10 @@ x264_t *x264_encoder_open ( x264_param_t *param ) ...@@ -698,10 +689,10 @@ x264_t *x264_encoder_open ( x264_param_t *param )
if( x264_ratecontrol_new( h ) < 0 ) if( x264_ratecontrol_new( h ) < 0 )
return NULL; return NULL;
#ifdef DEBUG_DUMP_FRAME if( h->param.psz_dump_yuv )
{ {
/* create or truncate the reconstructed video file */ /* create or truncate the reconstructed video file */
FILE *f = fopen( "fdec.yuv", "w" ); FILE *f = fopen( h->param.psz_dump_yuv, "w" );
if( f ) if( f )
fclose( f ); fclose( f );
else else
...@@ -711,7 +702,6 @@ x264_t *x264_encoder_open ( x264_param_t *param ) ...@@ -711,7 +702,6 @@ x264_t *x264_encoder_open ( x264_param_t *param )
return NULL; return NULL;
} }
} }
#endif
return h; return h;
} }
...@@ -886,9 +876,7 @@ static void x264_fdec_filter_row( x264_t *h, int mb_y ) ...@@ -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_deblock = !h->sh.i_disable_deblocking_filter_idc;
int b_end = mb_y == h->sps->i_mb_height; int b_end = mb_y == h->sps->i_mb_height;
int min_y = mb_y - (1 << h->sh.b_mbaff); int min_y = mb_y - (1 << h->sh.b_mbaff);
#ifndef DEBUG_DUMP_FRAME b_deblock &= b_hpel || h->param.psz_dump_yuv;
b_deblock &= b_hpel;
#endif
if( mb_y & h->sh.b_mbaff ) if( mb_y & h->sh.b_mbaff )
return; return;
if( min_y < 0 ) if( min_y < 0 )
...@@ -1725,10 +1713,8 @@ static void x264_encoder_frame_end( x264_t *h, x264_t *thread_current, ...@@ -1725,10 +1713,8 @@ static void x264_encoder_frame_end( x264_t *h, x264_t *thread_current,
} }
#endif #endif
#ifdef DEBUG_DUMP_FRAME if( h->param.psz_dump_yuv )
/* Dump reconstructed frame */ x264_frame_dump( h );
x264_frame_dump( h, h->fdec, "fdec.yuv" );
#endif
} }
/**************************************************************************** /****************************************************************************
......
...@@ -319,6 +319,7 @@ static void Help( x264_param_t *defaults, int b_longhelp ) ...@@ -319,6 +319,7 @@ static void Help( x264_param_t *defaults, int b_longhelp )
H1( " --asm <integer> Override CPU detection\n" ); H1( " --asm <integer> Override CPU detection\n" );
H1( " --no-asm Disable all CPU optimizations\n" ); H1( " --no-asm Disable all CPU optimizations\n" );
H1( " --visualize Show MB types overlayed on the encoded video\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( " --sps-id <integer> Set SPS and PPS id numbers [%d]\n", defaults->i_sps_id );
H1( " --aud Use access unit delimiters\n" ); H1( " --aud Use access unit delimiters\n" );
H0( "\n" ); H0( "\n" );
...@@ -447,6 +448,7 @@ static int Parse( int argc, char **argv, ...@@ -447,6 +448,7 @@ static int Parse( int argc, char **argv,
{ "verbose", no_argument, NULL, 'v' }, { "verbose", no_argument, NULL, 'v' },
{ "progress",no_argument, NULL, OPT_PROGRESS }, { "progress",no_argument, NULL, OPT_PROGRESS },
{ "visualize",no_argument, NULL, OPT_VISUALIZE }, { "visualize",no_argument, NULL, OPT_VISUALIZE },
{ "dump-yuv",required_argument, NULL, 0 },
{ "sps-id", required_argument, NULL, 0 }, { "sps-id", required_argument, NULL, 0 },
{ "aud", no_argument, NULL, 0 }, { "aud", no_argument, NULL, 0 },
{ "nr", required_argument, NULL, 0 }, { "nr", required_argument, NULL, 0 },
......
...@@ -210,6 +210,7 @@ typedef struct x264_param_t ...@@ -210,6 +210,7 @@ typedef struct x264_param_t
void *p_log_private; void *p_log_private;
int i_log_level; int i_log_level;
int b_visualize; int b_visualize;
char *psz_dump_yuv; /* filename for reconstructed frames */
/* Encoder analyser parameters */ /* Encoder analyser parameters */
struct struct
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment