/*****************************************************************************
* analyse.c: macroblock analysis
*****************************************************************************
- * Copyright (C) 2003-2014 x264 project
+ * Copyright (C) 2003-2015 x264 project
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Loren Merritt <lorenm@u.washington.edu>
static UNUSED x264_pthread_mutex_t cost_ref_mutex = X264_PTHREAD_MUTEX_INITIALIZER;
static uint16_t x264_cost_i4x4_mode[(QP_MAX+2)*32];
-float *x264_analyse_prepare_costs( x264_t *h )
-{
- float *logs = x264_malloc( (2*4*2048+1)*sizeof(float) );
- if( !logs )
- return NULL;
- logs[0] = 0.718f;
- for( int i = 1; i <= 2*4*2048; i++ )
- logs[i] = log2f(i+1)*2 + 1.718f;
- return logs;
-}
-
-int x264_analyse_init_costs( x264_t *h, float *logs, int qp )
+static int init_costs( x264_t *h, float *logs, int qp )
{
int lambda = x264_lambda_tab[qp];
if( h->cost_mv[qp] )
return -1;
}
+int x264_analyse_init_costs( x264_t *h )
+{
+ float *logs = x264_malloc( (2*4*2048+1) * sizeof(float) );
+ if( !logs )
+ return -1;
+
+ logs[0] = 0.718f;
+ for( int i = 1; i <= 2*4*2048; i++ )
+ logs[i] = log2f( i+1 ) * 2.0f + 1.718f;
+
+ for( int qp = X264_MIN( h->param.rc.i_qp_min, QP_MAX_SPEC ); qp <= h->param.rc.i_qp_max; qp++ )
+ if( init_costs( h, logs, qp ) )
+ goto fail;
+
+ if( init_costs( h, logs, X264_LOOKAHEAD_QP ) )
+ goto fail;
+
+ x264_free( logs );
+ return 0;
+fail:
+ x264_free( logs );
+ return -1;
+}
+
void x264_analyse_free_costs( x264_t *h )
{
for( int i = 0; i < QP_MAX+1; i++ )
/* non-RD PCM decision is inaccurate (as is psy-rd), so don't do it.
* PCM cost can overflow with high lambda2, so cap it at COST_MAX. */
uint64_t pcm_cost = ((uint64_t)X264_PCM_COST*a->i_lambda2 + 128) >> 8;
- a->i_satd_pcm = !h->param.b_avcintra_compat && !h->mb.i_psy_rd && a->i_mbrd && pcm_cost < COST_MAX ? pcm_cost : COST_MAX;
+ a->i_satd_pcm = !h->param.i_avcintra_class && !h->mb.i_psy_rd && a->i_mbrd && pcm_cost < COST_MAX ? pcm_cost : COST_MAX;
a->b_fast_intra = 0;
a->b_avoid_topright = 0;
/*---------------- Try all mode and calculate their score ---------------*/
/* Disabled i16x16 for AVC-Intra compat */
- if( !h->param.b_avcintra_compat )
+ if( !h->param.i_avcintra_class )
{
const int8_t *predict_mode = predict_16x16_mode_available( h->mb.i_neighbour_intra );