#endif
//#define DEBUG_MB_TYPE
-//#define DEBUG_DUMP_FRAME
#define NALU_OVERHEAD 5 // startcode + NAL type costs 5 bytes per frame
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 */
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
return NULL;
}
}
-#endif
return h;
}
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 )
}
#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 );
}
/****************************************************************************
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" );
{ "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 },