*/
static inline float qp2qscale( float qp )
{
- return 0.85f * powf( 2.0f, ( qp - 12.0f ) / 6.0f );
+ return 0.85f * powf( 2.0f, ( qp - (12.0f + QP_BD_OFFSET) ) / 6.0f );
}
static inline float qscale2qp( float qscale )
{
- return 12.0f + 6.0f * log2f( qscale/0.85f );
+ return (12.0f + QP_BD_OFFSET) + 6.0f * log2f( qscale/0.85f );
}
/* Texture bitrate is not quite inversely proportional to qscale,
h->mb.ip_offset = rc->ip_offset + 0.5;
rc->lstep = pow( 2, h->param.rc.i_qp_step / 6.0 );
- rc->last_qscale = qp2qscale( 26 );
+ rc->last_qscale = qp2qscale( 26 + QP_BD_OFFSET );
int num_preds = h->param.b_sliced_threads * h->param.i_threads + 1;
CHECKED_MALLOC( rc->pred, 5 * sizeof(predictor_t) * num_preds );
CHECKED_MALLOC( rc->pred_b_from_p, sizeof(predictor_t) );
{
ratecontrol_entry_t *rce = &rc->entry[i];
rce->pict_type = SLICE_TYPE_P;
- rce->qscale = rce->new_qscale = qp2qscale( 20 );
+ rce->qscale = rce->new_qscale = qp2qscale( 20 + QP_BD_OFFSET );
rce->misc_bits = rc->nmb + 10;
rce->new_qp = 0;
}
}
}
- i_icost += intra_penalty + lowres_penalty;
+ i_icost = ((i_icost + intra_penalty) >> (BIT_DEPTH - 8)) + lowres_penalty;
fenc->i_intra_cost[i_mb_xy] = i_icost;
int i_icost_aq = i_icost;
if( h->param.rc.i_aq_mode )
output_intra[COST_EST_AQ] += i_icost_aq;
}
}
- i_bcost += lowres_penalty;
+ i_bcost = (i_bcost >> (BIT_DEPTH - 8)) + lowres_penalty;
/* forbid intra-mbs in B-frames, because it's rare and not worth checking */
/* FIXME: Should we still forbid them now that we cache intra scores? */
}
}
- if( BIT_DEPTH > 8 )
- for( int y = 0; y < h->mb.i_mb_height; y++ )
- h->fdec->i_row_satd[y] >>= (BIT_DEPTH - 8);
-
- return cost >> (BIT_DEPTH - 8);
+ return cost;
}