mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-30 12:44:07 +00:00
Changed final cost (and transform skip) error function from SAD to SSD
This commit is contained in:
parent
a14fb14e33
commit
0da8071300
|
@ -1945,19 +1945,23 @@ void encode_transform_tree(encoder_control* encoder, int32_t x, int32_t y, uint8
|
|||
dequant(encoder, temp_coeff2, pre_quant_coeff, 4, 4, 0, cur_cu->type);
|
||||
itransform2d(temp_block2,pre_quant_coeff,width,0);
|
||||
|
||||
|
||||
// SAD between reconstruction and original + sum of coeffs
|
||||
// SSD between reconstruction and original + sum of coeffs
|
||||
for (i = 0; i < 16; i++) {
|
||||
cost += abs((int)temp_block[i] - (int)block[i]);
|
||||
cost += temp_coeff[i]*temp_coeff[i];
|
||||
int diff = temp_block[i]-block[i];
|
||||
cost += diff*diff;
|
||||
coeffcost += abs((int)temp_coeff[i]);
|
||||
|
||||
cost2 += abs((int)temp_block2[i] - (int)block[i]);
|
||||
cost2 += temp_coeff2[i]*temp_coeff2[i];
|
||||
diff = temp_block2[i] - block[i];
|
||||
cost2 += diff*diff;
|
||||
coeffcost2 += abs((int)temp_coeff2[i]);
|
||||
}
|
||||
cost += (1 + coeffcost + (coeffcost>>1))*((int)g_cur_lambda_cost+0.5);
|
||||
cost2 += (coeffcost2 + (coeffcost2>>1))*((int)g_cur_lambda_cost+0.5);
|
||||
|
||||
cur_cu->intra[PU_INDEX(x_pu, y_pu)].tr_skip = (cost < cost2);
|
||||
}
|
||||
|
||||
// Transform and quant residual to coeffs
|
||||
if(width == 4 && cur_cu->intra[PU_INDEX(x_pu, y_pu)].tr_skip) {
|
||||
transformskip(block,pre_quant_coeff,width);
|
||||
} else {
|
||||
|
|
15
src/search.c
15
src/search.c
|
@ -722,7 +722,7 @@ static int search_cu_intra(encoder_control *encoder,
|
|||
* Calculate "final cost" for the block
|
||||
* \return Cost of block
|
||||
*
|
||||
* Take SAD between reconstruction and original and add cost from
|
||||
* Take SSD between reconstruction and original and add cost from
|
||||
* coding (bitcost * lambda) and cost for coding coefficients (estimated
|
||||
* here as (coefficient_sum * 1.5) * lambda)
|
||||
*/
|
||||
|
@ -738,18 +738,21 @@ static int lcu_get_final_cost(encoder_control *encoder,
|
|||
int x,y;
|
||||
cur_cu = &lcu->cu[LCU_CU_OFFSET+(x_local>>3) + (y_local>>3)*LCU_T_CU_WIDTH];
|
||||
|
||||
// SAD between reconstruction and original + sum of coeffs
|
||||
// SSD between reconstruction and original + sum of coeffs
|
||||
for (y = y_local; y < y_local+width; ++y) {
|
||||
for (x = x_local; x < x_local+width; ++x) {
|
||||
cost += abs((int)lcu->rec.y[y * LCU_WIDTH + x] - (int)lcu->ref.y[y * LCU_WIDTH + x]);
|
||||
int diff = (int)lcu->rec.y[y * LCU_WIDTH + x] - (int)lcu->ref.y[y * LCU_WIDTH + x];
|
||||
cost += diff*diff;
|
||||
coeff_cost += abs((int)lcu->coeff.y[y * LCU_WIDTH + x]);
|
||||
}
|
||||
}
|
||||
// Chroma SAD + sum of coeffs
|
||||
// Chroma SSD + sum of coeffs
|
||||
for (y = y_local>>1; y < (y_local+width)>>1; ++y) {
|
||||
for (x = x_local>>1; x < (x_local+width)>>1; ++x) {
|
||||
cost += abs((int)lcu->rec.u[y * (LCU_WIDTH>>1) + x] - (int)lcu->ref.u[y * (LCU_WIDTH>>1) + x]);
|
||||
cost += abs((int)lcu->rec.v[y * (LCU_WIDTH>>1) + x] - (int)lcu->ref.v[y * (LCU_WIDTH>>1) + x]);
|
||||
int diff = (int)lcu->rec.u[y * (LCU_WIDTH>>1) + x] - (int)lcu->ref.u[y * (LCU_WIDTH>>1) + x];
|
||||
cost += diff*diff;
|
||||
diff = (int)lcu->rec.v[y * (LCU_WIDTH>>1) + x] - (int)lcu->ref.v[y * (LCU_WIDTH>>1) + x];
|
||||
cost += diff*diff;
|
||||
|
||||
coeff_cost += abs((int)lcu->coeff.u[y * (LCU_WIDTH>>1) + x]);
|
||||
coeff_cost += abs((int)lcu->coeff.v[y * (LCU_WIDTH>>1) + x]);
|
||||
|
|
Loading…
Reference in a new issue