177, 182, 186, 191, 196, 201, 206, 211, 216, 221, 226, 232, 237, 242, 248, 253,
};
+/* Not a general-purpose function; multiplies input by -1/6 to convert
+ * qp to qscale. */
static ALWAYS_INLINE int x264_exp2fix8( float x )
{
- int i, f;
- x += 8;
- if( x <= 0 ) return 0;
- if( x >= 16 ) return 0xffff;
- i = x;
- f = (x-i)*64;
- return (exp2_lut[f]+256) << i >> 8;
+ if( x >= 512.f/6.f ) return 0;
+ if( x <= -512.f/6.f ) return 0xffff;
+ int i = x*(-64.f/6.f) + 512;
+ return (exp2_lut[i&63]+256) << (i>>6) >> 8;
}
static const float log2_lut[128] = {
frame->f_qp_offset[mb_x + mb_y*h->mb.i_mb_stride] =
frame->f_qp_offset_aq[mb_x + mb_y*h->mb.i_mb_stride] = qp_adj;
if( h->frames.b_have_lowres )
- frame->i_inv_qscale_factor[mb_x + mb_y*h->mb.i_mb_stride] = x264_exp2fix8(qp_adj*(-1.f/6.f));
+ frame->i_inv_qscale_factor[mb_x + mb_y*h->mb.i_mb_stride] = x264_exp2fix8(qp_adj);
}
}
int i_mb_xy = h->mb.i_mb_x + h->mb.i_mb_y*h->mb.i_mb_stride;
int i_mb_cost = frames[b]->lowres_costs[b-p0][p1-b][i_mb_xy];
float qp_adj = frames[b]->f_qp_offset[i_mb_xy];
- i_mb_cost = (i_mb_cost * x264_exp2fix8(qp_adj*(-1.f/6.f)) + 128) >> 8;
+ i_mb_cost = (i_mb_cost * x264_exp2fix8(qp_adj) + 128) >> 8;
row_satd[ h->mb.i_mb_y ] += i_mb_cost;
if( (h->mb.i_mb_y > 0 && h->mb.i_mb_y < h->sps->i_mb_height - 1 &&
h->mb.i_mb_x > 0 && h->mb.i_mb_x < h->sps->i_mb_width - 1) ||
memcpy( frame->f_qp_offset, frame->f_qp_offset_aq, sizeof( frame->f_qp_offset ) );
else
{
+ /* Allow the strength to be adjusted via qcompress, since the two
+ * concepts are very similar. */
+ float strength = 5.0f * (1.0f - h->param.rc.f_qcompress);
for( mb_index = 0; mb_index < h->mb.i_mb_count; mb_index++ )
{
int intra_cost = (frame->i_intra_cost[mb_index] * frame->i_inv_qscale_factor[mb_index]+128)>>8;
{
int propagate_cost = frame->i_propagate_cost[mb_index];
float log2_ratio = x264_log2(intra_cost + propagate_cost) - x264_log2(intra_cost);
- /* Allow the constant to be adjusted via qcompress, since the two
- * concepts are very similar. */
- frame->f_qp_offset[mb_index] = frame->f_qp_offset_aq[mb_index] - 5.0 * (1.0 - h->param.rc.f_qcompress) * log2_ratio;
+ frame->f_qp_offset[mb_index] = frame->f_qp_offset_aq[mb_index] - strength * log2_ratio;
}
}
}