summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-09-20 00:15:06 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2013-09-20 00:15:06 -0700
commit24df77e95102980e5f303b3a64a955a6e8089028 (patch)
tree37e0124766ab25570b900a57c056f702aa72331b
parentf363aa3a1503f73e2907d2d818abf76f735ed7fd (diff)
parenta23c2a9e7bcee55cedef3062e5819f696e91bfaa (diff)
downloadlibvpx-24df77e95102980e5f303b3a64a955a6e8089028.tar
libvpx-24df77e95102980e5f303b3a64a955a6e8089028.tar.gz
libvpx-24df77e95102980e5f303b3a64a955a6e8089028.tar.bz2
libvpx-24df77e95102980e5f303b3a64a955a6e8089028.zip
Merge "Adding get_scan_and_band function."
-rw-r--r--vp9/common/vp9_entropy.h46
-rw-r--r--vp9/decoder/vp9_detokenize.c4
-rw-r--r--vp9/encoder/vp9_encodemb.c26
-rw-r--r--vp9/encoder/vp9_tokenize.c9
4 files changed, 38 insertions, 47 deletions
diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h
index f138c0955..c1f2d782b 100644
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -336,45 +336,61 @@ static INLINE const int16_t* get_iscan_16x16(TX_TYPE tx_type) {
}
}
-static int get_entropy_context(const MACROBLOCKD *xd, TX_SIZE tx_size,
- PLANE_TYPE type, int block_idx,
- ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L,
- const int16_t **scan,
- const uint8_t **band_translate) {
+static int get_entropy_context(TX_SIZE tx_size,
+ ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
ENTROPY_CONTEXT above_ec = 0, left_ec = 0;
switch (tx_size) {
case TX_4X4:
+ above_ec = a[0] != 0;
+ left_ec = l[0] != 0;
+ break;
+ case TX_8X8:
+ above_ec = !!*(uint16_t *)a;
+ left_ec = !!*(uint16_t *)l;
+ break;
+ case TX_16X16:
+ above_ec = !!*(uint32_t *)a;
+ left_ec = !!*(uint32_t *)l;
+ break;
+ case TX_32X32:
+ above_ec = !!*(uint64_t *)a;
+ left_ec = !!*(uint64_t *)l;
+ break;
+ default:
+ assert(!"Invalid transform size.");
+ }
+
+ return combine_entropy_contexts(above_ec, left_ec);
+}
+
+static void get_scan_and_band(const MACROBLOCKD *xd, TX_SIZE tx_size,
+ PLANE_TYPE type, int block_idx,
+ const int16_t **scan,
+ const uint8_t **band_translate) {
+ switch (tx_size) {
+ case TX_4X4:
*scan = get_scan_4x4(get_tx_type_4x4(type, xd, block_idx));
*band_translate = vp9_coefband_trans_4x4;
- above_ec = A[0] != 0;
- left_ec = L[0] != 0;
break;
case TX_8X8:
*scan = get_scan_8x8(get_tx_type_8x8(type, xd));
*band_translate = vp9_coefband_trans_8x8plus;
- above_ec = !!*(uint16_t *)A;
- left_ec = !!*(uint16_t *)L;
break;
case TX_16X16:
*scan = get_scan_16x16(get_tx_type_16x16(type, xd));
*band_translate = vp9_coefband_trans_8x8plus;
- above_ec = !!*(uint32_t *)A;
- left_ec = !!*(uint32_t *)L;
break;
case TX_32X32:
*scan = vp9_default_scan_32x32;
*band_translate = vp9_coefband_trans_8x8plus;
- above_ec = !!*(uint64_t *)A;
- left_ec = !!*(uint64_t *)L;
break;
default:
assert(!"Invalid transform size.");
}
-
- return combine_entropy_contexts(above_ec, left_ec);
}
+
enum { VP9_COEF_UPDATE_PROB = 252 };
#endif // VP9_COMMON_VP9_ENTROPY_H_
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index cd74a0b00..3792b9c78 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -105,8 +105,8 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
const int16_t *scan, *nb;
const uint8_t *band_translate;
uint8_t token_cache[1024];
- int pt = get_entropy_context(xd, tx_size, type, block_idx, A, L,
- &scan, &band_translate);
+ int pt = get_entropy_context(tx_size, A, L);
+ get_scan_and_band(xd, tx_size, type, block_idx, &scan, &band_translate);
nb = vp9_get_coef_neighbors_handle(scan);
while (1) {
diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c
index 8dd80a53a..2c12477a7 100644
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -161,7 +161,7 @@ static void optimize_b(MACROBLOCK *mb,
int best, band, pt;
PLANE_TYPE type = pd->plane_type;
int err_mult = plane_rd_mult[type];
- int default_eob;
+ const int default_eob = 16 << (tx_size << 1);
const int16_t *scan, *nb;
const int mul = 1 + (tx_size == TX_32X32);
uint8_t token_cache[1024];
@@ -172,29 +172,7 @@ static void optimize_b(MACROBLOCK *mb,
assert((!type && !plane) || (type && plane));
dqcoeff_ptr = BLOCK_OFFSET(pd->dqcoeff, block);
qcoeff_ptr = BLOCK_OFFSET(pd->qcoeff, block);
- switch (tx_size) {
- default:
- case TX_4X4:
- default_eob = 16;
- scan = get_scan_4x4(get_tx_type_4x4(type, xd, ib));
- band_translate = vp9_coefband_trans_4x4;
- break;
- case TX_8X8:
- scan = get_scan_8x8(get_tx_type_8x8(type, xd));
- default_eob = 64;
- band_translate = vp9_coefband_trans_8x8plus;
- break;
- case TX_16X16:
- scan = get_scan_16x16(get_tx_type_16x16(type, xd));
- default_eob = 256;
- band_translate = vp9_coefband_trans_8x8plus;
- break;
- case TX_32X32:
- scan = vp9_default_scan_32x32;
- default_eob = 1024;
- band_translate = vp9_coefband_trans_8x8plus;
- break;
- }
+ get_scan_and_band(xd, tx_size, type, ib, &scan, &band_translate);
assert(eob <= default_eob);
/* Now set up a Viterbi trellis to evaluate alternative roundings. */
diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c
index 0c9bf9db2..a59f6db88 100644
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -129,18 +129,15 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
const int ref = is_inter_block(mbmi);
uint8_t token_cache[1024];
const uint8_t *band_translate;
- ENTROPY_CONTEXT *A, *L;
const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size);
int aoff, loff;
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff);
- A = pd->above_context + aoff;
- L = pd->left_context + loff;
-
assert((!type && !plane) || (type && plane));
- pt = get_entropy_context(xd, tx_size, type, block, A, L,
- &scan, &band_translate);
+ pt = get_entropy_context(tx_size, pd->above_context + aoff,
+ pd->left_context + loff);
+ get_scan_and_band(xd, tx_size, type, block, &scan, &band_translate);
nb = vp9_get_coef_neighbors_handle(scan);
c = 0;
do {