OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // uv | 308 // uv |
309 quant = i == 0 ? vp9_dc_quant(q, cm->uv_dc_delta_q) | 309 quant = i == 0 ? vp9_dc_quant(q, cm->uv_dc_delta_q) |
310 : vp9_ac_quant(q, cm->uv_ac_delta_q); | 310 : vp9_ac_quant(q, cm->uv_ac_delta_q); |
311 invert_quant(&quants->uv_quant[q][i], | 311 invert_quant(&quants->uv_quant[q][i], |
312 &quants->uv_quant_shift[q][i], quant); | 312 &quants->uv_quant_shift[q][i], quant); |
313 quants->uv_quant_fp[q][i] = (1 << 16) / quant; | 313 quants->uv_quant_fp[q][i] = (1 << 16) / quant; |
314 quants->uv_round_fp[q][i] = (qrounding_factor_fp * quant) >> 7; | 314 quants->uv_round_fp[q][i] = (qrounding_factor_fp * quant) >> 7; |
315 quants->uv_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7); | 315 quants->uv_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7); |
316 quants->uv_round[q][i] = (qrounding_factor * quant) >> 7; | 316 quants->uv_round[q][i] = (qrounding_factor * quant) >> 7; |
317 cm->uv_dequant[q][i] = quant; | 317 cm->uv_dequant[q][i] = quant; |
318 | |
319 #if CONFIG_ALPHA | |
320 // alpha | |
321 quant = i == 0 ? vp9_dc_quant(q, cm->a_dc_delta_q) | |
322 : vp9_ac_quant(q, cm->a_ac_delta_q); | |
323 invert_quant(&quants->a_quant[q][i], &quants->a_quant_shift[q][i], quant); | |
324 quants->a_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7); | |
325 quants->a_round[q][i] = (qrounding_factor * quant) >> 7; | |
326 cm->a_dequant[q][i] = quant; | |
327 #endif | |
328 } | 318 } |
329 | 319 |
330 for (i = 2; i < 8; i++) { | 320 for (i = 2; i < 8; i++) { |
331 quants->y_quant[q][i] = quants->y_quant[q][1]; | 321 quants->y_quant[q][i] = quants->y_quant[q][1]; |
332 quants->y_quant_fp[q][i] = quants->y_quant_fp[q][1]; | 322 quants->y_quant_fp[q][i] = quants->y_quant_fp[q][1]; |
333 quants->y_round_fp[q][i] = quants->y_round_fp[q][1]; | 323 quants->y_round_fp[q][i] = quants->y_round_fp[q][1]; |
334 quants->y_quant_shift[q][i] = quants->y_quant_shift[q][1]; | 324 quants->y_quant_shift[q][i] = quants->y_quant_shift[q][1]; |
335 quants->y_zbin[q][i] = quants->y_zbin[q][1]; | 325 quants->y_zbin[q][i] = quants->y_zbin[q][1]; |
336 quants->y_round[q][i] = quants->y_round[q][1]; | 326 quants->y_round[q][i] = quants->y_round[q][1]; |
337 cm->y_dequant[q][i] = cm->y_dequant[q][1]; | 327 cm->y_dequant[q][i] = cm->y_dequant[q][1]; |
338 | 328 |
339 quants->uv_quant[q][i] = quants->uv_quant[q][1]; | 329 quants->uv_quant[q][i] = quants->uv_quant[q][1]; |
340 quants->uv_quant_fp[q][i] = quants->uv_quant_fp[q][1]; | 330 quants->uv_quant_fp[q][i] = quants->uv_quant_fp[q][1]; |
341 quants->uv_round_fp[q][i] = quants->uv_round_fp[q][1]; | 331 quants->uv_round_fp[q][i] = quants->uv_round_fp[q][1]; |
342 quants->uv_quant_shift[q][i] = quants->uv_quant_shift[q][1]; | 332 quants->uv_quant_shift[q][i] = quants->uv_quant_shift[q][1]; |
343 quants->uv_zbin[q][i] = quants->uv_zbin[q][1]; | 333 quants->uv_zbin[q][i] = quants->uv_zbin[q][1]; |
344 quants->uv_round[q][i] = quants->uv_round[q][1]; | 334 quants->uv_round[q][i] = quants->uv_round[q][1]; |
345 cm->uv_dequant[q][i] = cm->uv_dequant[q][1]; | 335 cm->uv_dequant[q][i] = cm->uv_dequant[q][1]; |
346 | |
347 #if CONFIG_ALPHA | |
348 quants->a_quant[q][i] = quants->a_quant[q][1]; | |
349 quants->a_quant_shift[q][i] = quants->a_quant_shift[q][1]; | |
350 quants->a_zbin[q][i] = quants->a_zbin[q][1]; | |
351 quants->a_round[q][i] = quants->a_round[q][1]; | |
352 cm->a_dequant[q][i] = cm->a_dequant[q][1]; | |
353 #endif | |
354 } | 336 } |
355 } | 337 } |
356 } | 338 } |
357 | 339 |
358 void vp9_init_plane_quantizers(VP9_COMP *cpi, MACROBLOCK *x) { | 340 void vp9_init_plane_quantizers(VP9_COMP *cpi, MACROBLOCK *x) { |
359 const VP9_COMMON *const cm = &cpi->common; | 341 const VP9_COMMON *const cm = &cpi->common; |
360 MACROBLOCKD *const xd = &x->e_mbd; | 342 MACROBLOCKD *const xd = &x->e_mbd; |
361 QUANTS *const quants = &cpi->quants; | 343 QUANTS *const quants = &cpi->quants; |
362 const int segment_id = xd->mi[0]->mbmi.segment_id; | 344 const int segment_id = xd->mi[0]->mbmi.segment_id; |
363 const int qindex = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex); | 345 const int qindex = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex); |
(...skipping 16 matching lines...) Expand all Loading... |
380 x->plane[i].quant = quants->uv_quant[qindex]; | 362 x->plane[i].quant = quants->uv_quant[qindex]; |
381 x->plane[i].quant_fp = quants->uv_quant_fp[qindex]; | 363 x->plane[i].quant_fp = quants->uv_quant_fp[qindex]; |
382 x->plane[i].round_fp = quants->uv_round_fp[qindex]; | 364 x->plane[i].round_fp = quants->uv_round_fp[qindex]; |
383 x->plane[i].quant_shift = quants->uv_quant_shift[qindex]; | 365 x->plane[i].quant_shift = quants->uv_quant_shift[qindex]; |
384 x->plane[i].zbin = quants->uv_zbin[qindex]; | 366 x->plane[i].zbin = quants->uv_zbin[qindex]; |
385 x->plane[i].round = quants->uv_round[qindex]; | 367 x->plane[i].round = quants->uv_round[qindex]; |
386 x->plane[i].zbin_extra = (int16_t)((cm->uv_dequant[qindex][1] * zbin) >> 7); | 368 x->plane[i].zbin_extra = (int16_t)((cm->uv_dequant[qindex][1] * zbin) >> 7); |
387 xd->plane[i].dequant = cm->uv_dequant[qindex]; | 369 xd->plane[i].dequant = cm->uv_dequant[qindex]; |
388 } | 370 } |
389 | 371 |
390 #if CONFIG_ALPHA | |
391 x->plane[3].quant = quants->a_quant[qindex]; | |
392 x->plane[3].quant_shift = quants->a_quant_shift[qindex]; | |
393 x->plane[3].zbin = quants->a_zbin[qindex]; | |
394 x->plane[3].round = quants->a_round[qindex]; | |
395 x->plane[3].zbin_extra = (int16_t)((cm->a_dequant[qindex][1] * zbin) >> 7); | |
396 xd->plane[3].dequant = cm->a_dequant[qindex]; | |
397 #endif | |
398 | |
399 x->skip_block = vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP); | 372 x->skip_block = vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP); |
400 x->q_index = qindex; | 373 x->q_index = qindex; |
401 | 374 |
402 x->errorperbit = rdmult >> 6; | 375 x->errorperbit = rdmult >> 6; |
403 x->errorperbit += (x->errorperbit == 0); | 376 x->errorperbit += (x->errorperbit == 0); |
404 | 377 |
405 vp9_initialize_me_consts(cpi, x->q_index); | 378 vp9_initialize_me_consts(cpi, x->q_index); |
406 } | 379 } |
407 | 380 |
408 void vp9_update_zbin_extra(VP9_COMP *cpi, MACROBLOCK *x) { | 381 void vp9_update_zbin_extra(VP9_COMP *cpi, MACROBLOCK *x) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 423 |
451 int vp9_qindex_to_quantizer(int qindex) { | 424 int vp9_qindex_to_quantizer(int qindex) { |
452 int quantizer; | 425 int quantizer; |
453 | 426 |
454 for (quantizer = 0; quantizer < 64; ++quantizer) | 427 for (quantizer = 0; quantizer < 64; ++quantizer) |
455 if (quantizer_to_qindex[quantizer] >= qindex) | 428 if (quantizer_to_qindex[quantizer] >= qindex) |
456 return quantizer; | 429 return quantizer; |
457 | 430 |
458 return 63; | 431 return 63; |
459 } | 432 } |
OLD | NEW |