common/mvpred.c common/bitstream.c \
encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
encoder/set.c encoder/macroblock.c encoder/cabac.c \
+ encoder/speed.c \
encoder/cavlc.c encoder/encoder.c encoder/lookahead.c
SRCCLI = x264.c input/input.c input/timecode.c input/raw.c input/y4m.c \
param->rc.i_zones = 0;
param->rc.b_mb_tree = 1;
+ // speedcontrol
+ param->sc.f_speed = 0;
+ param->sc.i_buffer_size = 30;
+ param->sc.f_buffer_init = 0.75;
+
/* Log */
param->pf_log = x264_log_default;
param->p_log_private = NULL;
p->rc.f_complexity_blur = atof(value);
OPT("zones")
p->rc.psz_zones = strdup(value);
+ OPT("speed")
+ p->sc.f_speed = atof(value);
+ OPT("speed-bufsize")
+ p->sc.i_buffer_size = atoi(value);
+ OPT("speed-init")
+ p->sc.f_buffer_init = atof(value);
+ OPT("speed-alt-timer")
+ p->sc.b_alt_timer = atobool(value);
OPT("crop-rect")
b_error |= sscanf( value, "%u,%u,%u,%u", &p->crop_rect.i_left, &p->crop_rect.i_top,
&p->crop_rect.i_right, &p->crop_rect.i_bottom ) != 4;
if( p->b_opencl )
s += sprintf( s, "opencl=%d ", p->b_opencl );
+
+ // FIXME speedcontrol stuff
+
s += sprintf( s, "cabac=%d", p->b_cabac );
s += sprintf( s, " ref=%d", p->i_frame_reference );
s += sprintf( s, " deblock=%d:%d:%d", p->b_deblocking_filter,
} x264_lookahead_t;
typedef struct x264_ratecontrol_t x264_ratecontrol_t;
+typedef struct x264_speedcontrol_t x264_speedcontrol_t;
typedef struct x264_left_table_t
{
/* rate control encoding only */
x264_ratecontrol_t *rc;
+ x264_speedcontrol_t *sc;
/* stats */
struct
h->param.rc.f_qblur = 0;
if( h->param.rc.f_complexity_blur < 0 )
h->param.rc.f_complexity_blur = 0;
+ if( h->param.sc.i_buffer_size < 0 || h->param.sc.f_speed <= 0 )
+ h->param.sc.i_buffer_size = 0;
h->param.i_sps_id &= 31;
mbcmp_init( h );
chroma_dsp_init( h );
+ if( h->param.sc.i_buffer_size )
+ x264_speedcontrol_new( h );
+
+
p = buf + sprintf( buf, "using cpu capabilities:" );
for( int i = 0; x264_cpu_names[i].flags; i++ )
{
overhead += h->out.nal[h->out.i_nal-1].i_payload + h->out.nal[h->out.i_nal-1].i_padding + SEI_OVERHEAD;
}
+ /* Init the speed control */
+ if( h->param.sc.i_buffer_size )
+ x264_speedcontrol_frame( h );
+
/* Init the rate control */
/* FIXME: Include slice header bit cost. */
x264_ratecontrol_start( h, h->fenc->i_qpplus1, overhead*8 );
x264_noise_reduction_update( h );
+ if( h->param.sc.i_buffer_size )
+ x264_speedcontrol_frame_end( h );
+
/* ---------------------- Compute/Print statistics --------------------- */
x264_thread_sync_stat( h, h->thread[0] );
/* rc */
x264_ratecontrol_delete( h );
+ x264_speedcontrol_delete( h );
/* param */
if( h->param.rc.psz_stat_out )
void x264_threads_distribute_ratecontrol( x264_t *h );
void x264_threads_merge_ratecontrol( x264_t *h );
void x264_hrd_fullness( x264_t *h );
+
+// speedcontrol
+void x264_speedcontrol_new( x264_t *h );
+void x264_speedcontrol_delete( x264_t *h );
+void x264_speedcontrol_frame( x264_t *h );
+void x264_speedcontrol_frame_end( x264_t *h );
+
#endif
" K=<I or i> depending on open-gop setting\n"
" QPs are restricted by qpmin/qpmax.\n" );
H1( "\n" );
+
+ H1( "Speedcontrol:\n" );
+ H1( "\n" );
+ H1( " --speed <float> Automatically adjust other options to achieve this\n" );
+ H1( " fraction of realtime.\n" );
+ H1( " --speed-bufsize <int> Averaging period for speed. (in frames) [%d]\n", defaults->sc.i_buffer_size );
+ H1( "\n" );
+
H1( "Analysis:\n" );
H1( "\n" );
H1( " -A, --partitions <string> Partitions to consider [\"p8x8,b8x8,i8x8,i4x4\"]\n"
{ "cplxblur", required_argument, NULL, 0 },
{ "zones", required_argument, NULL, 0 },
{ "qpfile", required_argument, NULL, OPT_QPFILE },
+ { "speed", required_argument, NULL, 0 },
+ { "speed-bufsize", required_argument, NULL, 0 },
{ "threads", required_argument, NULL, 0 },
{ "lookahead-threads", required_argument, NULL, 0 },
{ "sliced-threads", no_argument, NULL, 0 },
/* frame packing arrangement flag */
int i_frame_packing;
+ /* Speed control parameters */
+ struct
+ {
+ float f_speed; /* ratio from realtime */
+ int i_buffer_size; /* number of frames */
+ float f_buffer_init; /* fraction of size */
+ int b_alt_timer; /* use a different method of measuring encode time FIXME */
+ } sc;
+
/* Muxing parameters */
int b_aud; /* generate access unit delimiters */
int b_repeat_headers; /* put SPS/PPS before each keyframe */
* Returns 0 on success, negative on failure. */
int x264_encoder_invalidate_reference( x264_t *, int64_t pts );
+/* x264_speedcontrol_sync:
+ * override speedcontrol's internal clock */
+void x264_speedcontrol_sync( x264_t *, float f_buffer_fill, int i_buffer_size );
+
#ifdef __cplusplus
}
#endif