ref: 5de7e16ca2b65e834293fab25d8c820329a18193
parent: 94fa3bcc06778fb1ba26cb4a8e515c58dcc962eb
author: Dmitry Kovalev <dkovalev@google.com>
date: Mon Apr 22 10:08:41 EDT 2013
Adding get_scan_{4x4, 8x8, 16x16} functions. Change-Id: Id4306ef6d65d4a3984aed50b775bdf48d4f6c438
--- a/vp9/common/vp9_entropy.c
+++ b/vp9/common/vp9_entropy.c
@@ -12,7 +12,6 @@
#include <stdio.h>
#include "vp9/common/vp9_entropy.h"
-#include "string.h"
#include "vp9/common/vp9_blockd.h"
#include "vp9/common/vp9_onyxc_int.h"
#include "vp9/common/vp9_entropymode.h"
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -223,6 +223,39 @@
#endif // CONFIG_CODE_ZEROGROUP
+static INLINE const int* get_scan_4x4(TX_TYPE tx_type) {
+ switch (tx_type) {
+ case ADST_DCT:
+ return vp9_row_scan_4x4;
+ case DCT_ADST:
+ return vp9_col_scan_4x4;
+ default:
+ return vp9_default_zig_zag1d_4x4;
+ }
+}
+
+static INLINE const int* get_scan_8x8(TX_TYPE tx_type) {
+ switch (tx_type) {
+ case ADST_DCT:
+ return vp9_row_scan_8x8;
+ case DCT_ADST:
+ return vp9_col_scan_8x8;
+ default:
+ return vp9_default_zig_zag1d_8x8;
+ }
+}
+
+static INLINE const int* get_scan_16x16(TX_TYPE tx_type) {
+ switch (tx_type) {
+ case ADST_DCT:
+ return vp9_row_scan_16x16;
+ case DCT_ADST:
+ return vp9_col_scan_16x16;
+ default:
+ return vp9_default_zig_zag1d_16x16;
+ }
+}
+
#include "vp9/common/vp9_coefupdateprobs.h"
#endif // VP9_COMMON_VP9_ENTROPY_H_
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -165,17 +165,7 @@
case TX_4X4: {
tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_4x4(xd, block_idx) : DCT_DCT;
- switch (tx_type) {
- default:
- scan = vp9_default_zig_zag1d_4x4;
- break;
- case ADST_DCT:
- scan = vp9_row_scan_4x4;
- break;
- case DCT_ADST:
- scan = vp9_col_scan_4x4;
- break;
- }
+ scan = get_scan_4x4(tx_type);
above_ec = A0[aidx] != 0;
left_ec = L0[lidx] != 0;
coef_probs = fc->coef_probs_4x4;
@@ -194,17 +184,7 @@
const int y = block_idx - x;
tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT;
- switch (tx_type) {
- default:
- scan = vp9_default_zig_zag1d_8x8;
- break;
- case ADST_DCT:
- scan = vp9_row_scan_8x8;
- break;
- case DCT_ADST:
- scan = vp9_col_scan_8x8;
- break;
- }
+ scan = get_scan_8x8(tx_type);
coef_probs = fc->coef_probs_8x8;
coef_counts = fc->coef_counts_8x8;
above_ec = (A0[aidx] + A0[aidx + 1]) != 0;
@@ -223,17 +203,7 @@
const int y = block_idx - x;
tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT;
- switch (tx_type) {
- default:
- scan = vp9_default_zig_zag1d_16x16;
- break;
- case ADST_DCT:
- scan = vp9_row_scan_16x16;
- break;
- case DCT_ADST:
- scan = vp9_col_scan_16x16;
- break;
- }
+ scan = get_scan_16x16(tx_type);
coef_probs = fc->coef_probs_16x16;
coef_counts = fc->coef_counts_16x16;
if (type == PLANE_TYPE_UV) {
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -335,13 +335,7 @@
case TX_4X4: {
const TX_TYPE tx_type = get_tx_type_4x4(xd, ib);
default_eob = 16;
- if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_4x4;
- } else if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_4x4;
- } else {
- scan = vp9_default_zig_zag1d_4x4;
- }
+ scan = get_scan_4x4(tx_type);
break;
}
case TX_8X8: {
@@ -349,13 +343,7 @@
const int sz = 3 + mb_width_log2(sb_type);
const int x = ib & ((1 << sz) - 1), y = ib - x;
const TX_TYPE tx_type = get_tx_type_8x8(xd, y + (x >> 1));
- if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_8x8;
- } else if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_8x8;
- } else {
- scan = vp9_default_zig_zag1d_8x8;
- }
+ scan = get_scan_8x8(tx_type);
default_eob = 64;
break;
}
@@ -364,13 +352,7 @@
const int sz = 4 + mb_width_log2(sb_type);
const int x = ib & ((1 << sz) - 1), y = ib - x;
const TX_TYPE tx_type = get_tx_type_16x16(xd, y + (x >> 2));
- if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_16x16;
- } else if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_16x16;
- } else {
- scan = vp9_default_zig_zag1d_16x16;
- }
+ scan = get_scan_16x16(tx_type);
default_eob = 256;
break;
}
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -44,20 +44,8 @@
uint8_t *quant_shift_ptr = b->quant_shift;
int16_t *dequant_ptr = d->dequant;
int zbin_oq_value = b->zbin_extra;
- const int *pt_scan;
+ const int *pt_scan = get_scan_4x4(tx_type);
- switch (tx_type) {
- case ADST_DCT:
- pt_scan = vp9_row_scan_4x4;
- break;
- case DCT_ADST:
- pt_scan = vp9_col_scan_4x4;
- break;
- default:
- pt_scan = vp9_default_zig_zag1d_4x4;
- break;
- }
-
vpx_memset(qcoeff_ptr, 0, 32);
vpx_memset(dqcoeff_ptr, 0, 32);
@@ -165,20 +153,8 @@
pb_idx.block, 16);
BLOCK *const b = &mb->block[c_idx];
BLOCKD *const d = &xd->block[c_idx];
- const int *pt_scan;
+ const int *pt_scan = get_scan_8x8(tx_type);
- switch (tx_type) {
- case ADST_DCT:
- pt_scan = vp9_row_scan_8x8;
- break;
- case DCT_ADST:
- pt_scan = vp9_col_scan_8x8;
- break;
- default:
- pt_scan = vp9_default_zig_zag1d_8x8;
- break;
- }
-
if (c_idx == 0) assert(pb_idx.plane == 0);
if (c_idx == 16) assert(pb_idx.plane == 1);
if (c_idx == 20) assert(pb_idx.plane == 2);
@@ -313,19 +289,7 @@
const int c_idx = plane_idx(pb_idx.plane);
BLOCK *const b = &mb->block[c_idx];
BLOCKD *const d = &xd->block[c_idx];
- const int *pt_scan;
-
- switch (tx_type) {
- case ADST_DCT:
- pt_scan = vp9_row_scan_16x16;
- break;
- case DCT_ADST:
- pt_scan = vp9_col_scan_16x16;
- break;
- default:
- pt_scan = vp9_default_zig_zag1d_16x16;
- break;
- }
+ const int *pt_scan = get_scan_16x16(tx_type);
if (c_idx == 0) assert(pb_idx.plane == 0);
if (c_idx == 16) assert(pb_idx.plane == 1);
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -352,13 +352,7 @@
l_ec = *l;
coef_probs = cm->fc.coef_probs_4x4;
seg_eob = 16;
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_4x4;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_4x4;
- } else {
- scan = vp9_default_zig_zag1d_4x4;
- }
+ scan = get_scan_4x4(tx_type);
#if CONFIG_CODE_ZEROGROUP
zpc_probs = &cm->fc.zpc_probs_4x4;
#endif
@@ -372,13 +366,7 @@
get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT;
a_ec = (a[0] + a[1]) != 0;
l_ec = (l[0] + l[1]) != 0;
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_8x8;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_8x8;
- } else {
- scan = vp9_default_zig_zag1d_8x8;
- }
+ scan = get_scan_8x8(tx_type);
coef_probs = cm->fc.coef_probs_8x8;
seg_eob = 64;
#if CONFIG_CODE_ZEROGROUP
@@ -392,13 +380,7 @@
const int x = ib & ((1 << sz) - 1), y = ib - x;
TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT;
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_16x16;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_16x16;
- } else {
- scan = vp9_default_zig_zag1d_16x16;
- }
+ scan = get_scan_16x16(tx_type);
coef_probs = cm->fc.coef_probs_16x16;
seg_eob = 256;
if (type == PLANE_TYPE_UV) {
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -204,14 +204,7 @@
a_ec = *a;
l_ec = *l;
seg_eob = 16;
- scan = vp9_default_zig_zag1d_4x4;
- if (tx_type != DCT_DCT) {
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_4x4;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_4x4;
- }
- }
+ scan = get_scan_4x4(tx_type);
counts = cpi->coef_counts_4x4;
coef_probs = cpi->common.fc.coef_probs_4x4;
#if CONFIG_CODE_ZEROGROUP
@@ -228,14 +221,7 @@
a_ec = (a[0] + a[1]) != 0;
l_ec = (l[0] + l[1]) != 0;
seg_eob = 64;
- scan = vp9_default_zig_zag1d_8x8;
- if (tx_type != DCT_DCT) {
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_8x8;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_8x8;
- }
- }
+ scan = get_scan_8x8(tx_type);
counts = cpi->coef_counts_8x8;
coef_probs = cpi->common.fc.coef_probs_8x8;
#if CONFIG_CODE_ZEROGROUP
@@ -257,14 +243,7 @@
l_ec = (l[0] + l[1] + l1[0] + l1[1]) != 0;
}
seg_eob = 256;
- scan = vp9_default_zig_zag1d_16x16;
- if (tx_type != DCT_DCT) {
- if (tx_type == ADST_DCT) {
- scan = vp9_row_scan_16x16;
- } else if (tx_type == DCT_ADST) {
- scan = vp9_col_scan_16x16;
- }
- }
+ scan = get_scan_16x16(tx_type);
counts = cpi->coef_counts_16x16;
coef_probs = cpi->common.fc.coef_probs_16x16;
#if CONFIG_CODE_ZEROGROUP
--
⑨