static const cli_pulldown_t pulldown_values[] =
{
- [X264_PULLDOWN_22] = {1, {TB}, 2.0},
+ [X264_PULLDOWN_22] = {1, {TB}, 1.0},
[X264_PULLDOWN_32] = {4, {TBT, BT, BTB, TB}, 1.25},
[X264_PULLDOWN_64] = {2, {PIC_STRUCT_DOUBLE, PIC_STRUCT_TRIPLE}, 1.0},
[X264_PULLDOWN_DOUBLE] = {1, {PIC_STRUCT_DOUBLE}, 2.0},
" stillimage,psnr,ssim\n"
" - other tunings: fastdecode,zerolatency\n" );
H2( " --slow-firstpass Don't force these faster settings with --pass 1:\n"
- " --no-8x8dct --me dia --partitions none --ref 1\n"
- " --subme {2 if >2 else unchanged} --trellis 0\n" );
+ " --no-8x8dct --me dia --partitions none\n"
+ " --ref 1 --subme {2 if >2 else unchanged}\n"
+ " --trellis 0 --fast-pskip\n" );
else H1( " --slow-firstpass Don't force faster settings with --pass 1\n" );
H0( "\n" );
H0( "Frame-type options:\n" );
H0( " --tff Enable interlaced mode (top field first)\n" );
H0( " --bff Enable interlaced mode (bottom field first)\n" );
H2( " --constrained-intra Enable constrained intra prediction.\n" );
+ H0( " --pulldown <string> Use soft pulldown to change frame rate\n"
+ " - none, 22, 32, 64, double, triple, euro (requires cfr input)\n" );
+ H2( " --fake-interlaced Flag stream as interlaced but encode progressive.\n"
+ " Makes it possible to encode 25p and 30p Blu-Ray\n"
+ " streams. Ignored in interlaced mode.\n" );
H0( "\n" );
H0( "Ratecontrol:\n" );
H0( "\n" );
H2( " --timebase <int/int> Specify timebase numerator and denominator\n"
" <integer> Specify timebase numerator for input timecode file\n"
" or specify timebase denominator for other input\n" );
- H0( " --pulldown <string> Use soft pulldown to change frame rate\n"
- " - none, 22, 32, 64, double, triple, euro (requires cfr input)\n" );
H0( "\n" );
}
{ "pic-struct", no_argument, NULL, 0 },
{ "nal-hrd", required_argument, NULL, 0 },
{ "pulldown", required_argument, NULL, OPT_PULLDOWN },
+ { "fake-interlaced", no_argument, NULL, 0 },
{0, 0, 0, 0}
};
}
if( !tcfile_name && input_opt.timebase )
{
- int i_user_timebase_num;
- int i_user_timebase_den;
- int ret = sscanf( input_opt.timebase, "%d/%d", &i_user_timebase_num, &i_user_timebase_den );
+ uint64_t i_user_timebase_num;
+ uint64_t i_user_timebase_den;
+ int ret = sscanf( input_opt.timebase, "%"SCNu64"/%"SCNu64, &i_user_timebase_num, &i_user_timebase_den );
if( !ret )
{
fprintf( stderr, "x264 [error]: invalid argument: timebase = %s\n", input_opt.timebase );
else if( ret == 1 )
{
i_user_timebase_num = param->i_timebase_num;
- i_user_timebase_den = atoi( input_opt.timebase );
+ i_user_timebase_den = strtoul( input_opt.timebase, NULL, 10 );
+ }
+ if( i_user_timebase_num > UINT32_MAX || i_user_timebase_den > UINT32_MAX )
+ {
+ fprintf( stderr, "x264 [error]: timebase you specified exceeds H.264 maximum\n" );
+ return -1;
}
opt->timebase_convert_multiplier = ((double)i_user_timebase_den / param->i_timebase_den)
* ((double)param->i_timebase_num / i_user_timebase_num);
* Encode:
*****************************************************************************/
-static int Encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic, int64_t *last_pts )
+static int Encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic, int64_t *last_dts )
{
x264_picture_t pic_out;
x264_nal_t *nal;
if( i_frame_size )
{
i_frame_size = output.write_frame( hout, nal[0].p_payload, i_frame_size, &pic_out );
- *last_pts = pic_out.i_pts;
+ *last_dts = pic_out.i_dts;
}
return i_frame_size;
}
-static void Print_status( int64_t i_start, int i_frame, int i_frame_total, int64_t i_file, x264_param_t *param, int64_t last_pts )
+static void Print_status( int64_t i_start, int i_frame, int i_frame_total, int64_t i_file, x264_param_t *param, int64_t last_ts )
{
char buf[200];
int64_t i_elapsed = x264_mdate() - i_start;
double fps = i_elapsed > 0 ? i_frame * 1000000. / i_elapsed : 0;
- double bitrate = (double) i_file * 8 / ( (double) last_pts * 1000 * param->i_timebase_num / param->i_timebase_den );
+ double bitrate;
+ if( last_ts )
+ bitrate = (double) i_file * 8 / ( (double) last_ts * 1000 * param->i_timebase_num / param->i_timebase_den );
+ else
+ bitrate = (double) i_file * 8 / ( (double) 1000 * param->i_fps_den / param->i_fps_num );
if( i_frame_total )
{
int eta = i_elapsed * (i_frame_total - i_frame) / ((int64_t)i_frame * 1000000);
int64_t i_file = 0;
int i_frame_size;
int i_update_interval;
- int64_t last_pts = 0;
+ int64_t last_dts = 0;
+ int64_t prev_dts = 0;
+ int64_t first_dts = 0;
# define MAX_PTS_WARNING 3 /* arbitrary */
int pts_warning_cnt = 0;
int64_t largest_pts = -1;
pic.i_qpplus1 = 0;
}
- i_frame_size = Encode_frame( h, opt->hout, &pic, &last_pts );
+ prev_dts = last_dts;
+ i_frame_size = Encode_frame( h, opt->hout, &pic, &last_dts );
if( i_frame_size < 0 )
return -1;
i_file += i_frame_size;
if( i_frame_size )
+ {
i_frame_output++;
+ if( i_frame_output == 1 )
+ first_dts = prev_dts = last_dts;
+ }
i_frame++;
/* update status line (up to 1000 times per input file) */
if( opt->b_progress && i_frame_output % i_update_interval == 0 && i_frame_output )
- Print_status( i_start, i_frame_output, i_frame_total, i_file, param, last_pts );
+ Print_status( i_start, i_frame_output, i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
}
/* Flush delayed frames */
while( !b_ctrl_c && x264_encoder_delayed_frames( h ) )
{
- i_frame_size = Encode_frame( h, opt->hout, NULL, &last_pts );
+ prev_dts = last_dts;
+ i_frame_size = Encode_frame( h, opt->hout, NULL, &last_dts );
if( i_frame_size < 0 )
return -1;
i_file += i_frame_size;
if( i_frame_size )
+ {
i_frame_output++;
+ if( i_frame_output == 1 )
+ first_dts = prev_dts = last_dts;
+ }
if( opt->b_progress && i_frame_output % i_update_interval == 0 && i_frame_output )
- Print_status( i_start, i_frame_output, i_frame_total, i_file, param, last_pts );
+ Print_status( i_start, i_frame_output, i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
}
if( pts_warning_cnt >= MAX_PTS_WARNING && param->i_log_level < X264_LOG_DEBUG )
fprintf( stderr, "x264 [warning]: %d suppressed nonmonotonic pts warnings\n", pts_warning_cnt-MAX_PTS_WARNING );
/* duration algorithm fails when only 1 frame is output */
if( i_frame_output == 1 )
duration = (double)param->i_fps_den / param->i_fps_num;
+ else if( b_ctrl_c )
+ duration = (double)(2 * last_dts - prev_dts - first_dts) * param->i_timebase_num / param->i_timebase_den;
else
duration = (double)(2 * largest_pts - second_largest_pts) * param->i_timebase_num / param->i_timebase_den;
if( !(opt->i_pulldown && !param->b_vfr_input) )