summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vp9/common/vp9_entropy.h12
-rw-r--r--vp9/common/vp9_enums.h3
-rw-r--r--vp9/common/vp9_findnearmv.c54
-rw-r--r--vp9/common/vp9_pred_common.c4
-rw-r--r--vp9/common/vp9_pred_common.h2
-rw-r--r--vp9/common/vp9_scan.c212
-rw-r--r--vp9/common/vp9_scan.h174
-rw-r--r--vp9/decoder/vp9_decodemv.c18
-rw-r--r--vp9/decoder/vp9_detokenize.c6
-rw-r--r--vp9/encoder/vp9_encodemb.c52
-rw-r--r--vp9/encoder/vp9_rdopt.c27
-rw-r--r--vp9/encoder/vp9_segmentation.c2
-rw-r--r--vp9/encoder/vp9_tokenize.c7
-rw-r--r--vp9/vp9_dx_iface.c20
-rw-r--r--vpx/vp8dx.h4
-rw-r--r--vpx_ports/x86.h10
-rw-r--r--vpx_scale/generic/yv12extend.c15
-rw-r--r--vpxdec.c20
18 files changed, 239 insertions, 403 deletions
diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h
index b98bef0c6..92a6c592a 100644
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -185,22 +185,18 @@ static int get_entropy_context(TX_SIZE tx_size, const ENTROPY_CONTEXT *a,
return combine_entropy_contexts(above_ec, left_ec);
}
-static void get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size,
- PLANE_TYPE type, int block_idx,
- const int16_t **scan, const int16_t **scan_nb) {
+static const scan_order *get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size,
+ PLANE_TYPE type, int block_idx) {
const MODE_INFO *const mi = xd->mi_8x8[0];
const MB_MODE_INFO *const mbmi = &mi->mbmi;
- const scan_order *so;
if (is_inter_block(mbmi) || type != PLANE_TYPE_Y_WITH_DC || xd->lossless) {
- so = &inter_scan_orders[tx_size];
+ return &vp9_default_scan_orders[tx_size];
} else {
const MB_PREDICTION_MODE mode =
mbmi->sb_type < BLOCK_8X8 ? mi->bmi[block_idx].as_mode : mbmi->mode;
- so = &intra_scan_orders[tx_size][mode];
+ return &vp9_scan_orders[tx_size][mode2txfm_map[mode]];
}
- *scan = so->scan;
- *scan_nb = so->neighbors;
}
#endif // VP9_COMMON_VP9_ENTROPY_H_
diff --git a/vp9/common/vp9_enums.h b/vp9/common/vp9_enums.h
index 1651b9050..9e4117e17 100644
--- a/vp9/common/vp9_enums.h
+++ b/vp9/common/vp9_enums.h
@@ -73,7 +73,8 @@ typedef enum {
DCT_DCT = 0, // DCT in both horizontal and vertical
ADST_DCT = 1, // ADST in vertical, DCT in horizontal
DCT_ADST = 2, // DCT in vertical, ADST in horizontal
- ADST_ADST = 3 // ADST in both directions
+ ADST_ADST = 3, // ADST in both directions
+ TX_TYPES = 4
} TX_TYPE;
typedef enum {
diff --git a/vp9/common/vp9_findnearmv.c b/vp9/common/vp9_findnearmv.c
index b91c50143..66178cd1b 100644
--- a/vp9/common/vp9_findnearmv.c
+++ b/vp9/common/vp9_findnearmv.c
@@ -36,50 +36,44 @@ void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp,
void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
const TileInfo *const tile,
- int_mv *dst_nearest,
- int_mv *dst_near,
+ int_mv *dst_nearest, int_mv *dst_near,
int block_idx, int ref_idx,
int mi_row, int mi_col) {
- int_mv dst_list[MAX_MV_REF_CANDIDATES];
int_mv mv_list[MAX_MV_REF_CANDIDATES];
MODE_INFO *const mi = xd->mi_8x8[0];
+ b_mode_info *bmi = mi->bmi;
+ int n;
assert(ref_idx == 0 || ref_idx == 1);
- assert(MAX_MV_REF_CANDIDATES == 2); // makes code here slightly easier
+ assert(MAX_MV_REF_CANDIDATES == 2);
vp9_find_mv_refs_idx(cm, xd, tile, mi, xd->last_mi,
mi->mbmi.ref_frame[ref_idx],
mv_list, block_idx, mi_row, mi_col);
- dst_list[1].as_int = 0;
+ dst_near->as_int = 0;
if (block_idx == 0) {
- vpx_memcpy(dst_list, mv_list, MAX_MV_REF_CANDIDATES * sizeof(int_mv));
+ dst_nearest->as_int = mv_list[0].as_int;
+ dst_near->as_int = mv_list[1].as_int;
} else if (block_idx == 1 || block_idx == 2) {
- int dst = 0, n;
- b_mode_info *bmi = mi->bmi;
-
- dst_list[dst++].as_int = bmi[0].as_mv[ref_idx].as_int;
- for (n = 0; dst < MAX_MV_REF_CANDIDATES &&
- n < MAX_MV_REF_CANDIDATES; n++)
- if (mv_list[n].as_int != dst_list[0].as_int)
- dst_list[dst++].as_int = mv_list[n].as_int;
+ dst_nearest->as_int = bmi[0].as_mv[ref_idx].as_int;
+ for (n = 0; n < MAX_MV_REF_CANDIDATES; ++n)
+ if (dst_nearest->as_int != mv_list[n].as_int) {
+ dst_near->as_int = mv_list[n].as_int;
+ break;
+ }
} else {
- int dst = 0, n;
- b_mode_info *bmi = mi->bmi;
-
+ int_mv candidates[2 + MAX_MV_REF_CANDIDATES] = { bmi[1].as_mv[ref_idx],
+ bmi[0].as_mv[ref_idx],
+ mv_list[0],
+ mv_list[1] };
assert(block_idx == 3);
- dst_list[dst++].as_int = bmi[2].as_mv[ref_idx].as_int;
- if (dst_list[0].as_int != bmi[1].as_mv[ref_idx].as_int)
- dst_list[dst++].as_int = bmi[1].as_mv[ref_idx].as_int;
- if (dst < MAX_MV_REF_CANDIDATES &&
- dst_list[0].as_int != bmi[0].as_mv[ref_idx].as_int)
- dst_list[dst++].as_int = bmi[0].as_mv[ref_idx].as_int;
- for (n = 0; dst < MAX_MV_REF_CANDIDATES &&
- n < MAX_MV_REF_CANDIDATES; n++)
- if (mv_list[n].as_int != dst_list[0].as_int)
- dst_list[dst++].as_int = mv_list[n].as_int;
+ dst_nearest->as_int = bmi[2].as_mv[ref_idx].as_int;
+ for (n = 0; n < 2 + MAX_MV_REF_CANDIDATES; ++n) {
+ if (dst_nearest->as_int != candidates[n].as_int) {
+ dst_near->as_int = candidates[n].as_int;
+ break;
+ }
+ }
}
-
- dst_nearest->as_int = dst_list[0].as_int;
- dst_near->as_int = dst_list[1].as_int;
}
diff --git a/vp9/common/vp9_pred_common.c b/vp9/common/vp9_pred_common.c
index 6018e1775..22b66b57a 100644
--- a/vp9/common/vp9_pred_common.c
+++ b/vp9/common/vp9_pred_common.c
@@ -396,10 +396,6 @@ unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd) {
return above_context + left_context > max_tx_size;
}
-void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, uint8_t pred_flag) {
- xd->mi_8x8[0]->mbmi.seg_id_predicted = pred_flag;
-}
-
int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids,
BLOCK_SIZE bsize, int mi_row, int mi_col) {
const int mi_offset = mi_row * cm->mi_cols + mi_col;
diff --git a/vp9/common/vp9_pred_common.h b/vp9/common/vp9_pred_common.h
index 919093080..b6f18e323 100644
--- a/vp9/common/vp9_pred_common.h
+++ b/vp9/common/vp9_pred_common.h
@@ -40,8 +40,6 @@ static INLINE vp9_prob vp9_get_pred_prob_seg_id(struct segmentation *seg,
return seg->pred_probs[vp9_get_pred_context_seg_id(xd)];
}
-void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, uint8_t pred_flag);
-
static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) {
const MODE_INFO *const above_mi = get_above_mi(xd);
const MODE_INFO *const left_mi = get_left_mi(xd);
diff --git a/vp9/common/vp9_scan.c b/vp9/common/vp9_scan.c
index f62150fd4..1ec5a0cf3 100644
--- a/vp9/common/vp9_scan.c
+++ b/vp9/common/vp9_scan.c
@@ -12,28 +12,28 @@
#include "vp9/common/vp9_scan.h"
-DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_4x4[16]) = {
+DECLARE_ALIGNED(16, static const int16_t, default_scan_4x4[16]) = {
0, 4, 1, 5,
8, 2, 12, 9,
3, 6, 13, 10,
7, 14, 11, 15,
};
-DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_4x4[16]) = {
+DECLARE_ALIGNED(16, static const int16_t, col_scan_4x4[16]) = {
0, 4, 8, 1,
12, 5, 9, 2,
13, 6, 10, 3,
7, 14, 11, 15,
};
-DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_4x4[16]) = {
+DECLARE_ALIGNED(16, static const int16_t, row_scan_4x4[16]) = {
0, 1, 4, 2,
5, 3, 6, 8,
9, 7, 12, 10,
13, 11, 14, 15,
};
-DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_8x8[64]) = {
+DECLARE_ALIGNED(16, static const int16_t, default_scan_8x8[64]) = {
0, 8, 1, 16, 9, 2, 17, 24,
10, 3, 18, 25, 32, 11, 4, 26,
33, 19, 40, 12, 34, 27, 5, 41,
@@ -44,7 +44,7 @@ DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_8x8[64]) = {
46, 39, 61, 54, 47, 62, 55, 63,
};
-DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_8x8[64]) = {
+DECLARE_ALIGNED(16, static const int16_t, col_scan_8x8[64]) = {
0, 8, 16, 1, 24, 9, 32, 17,
2, 40, 25, 10, 33, 18, 48, 3,
26, 41, 11, 56, 19, 34, 4, 49,
@@ -55,7 +55,7 @@ DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_8x8[64]) = {
31, 61, 39, 54, 47, 62, 55, 63,
};
-DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_8x8[64]) = {
+DECLARE_ALIGNED(16, static const int16_t, row_scan_8x8[64]) = {
0, 1, 2, 8, 9, 3, 16, 10,
4, 17, 11, 24, 5, 18, 25, 12,
19, 26, 32, 6, 13, 20, 33, 27,
@@ -66,7 +66,7 @@ DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_8x8[64]) = {
60, 39, 61, 47, 54, 55, 62, 63,
};
-DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_16x16[256]) = {
+DECLARE_ALIGNED(16, static const int16_t, default_scan_16x16[256]) = {
0, 16, 1, 32, 17, 2, 48, 33, 18, 3, 64, 34, 49, 19, 65, 80,
50, 4, 35, 66, 20, 81, 96, 51, 5, 36, 82, 97, 67, 112, 21, 52,
98, 37, 83, 113, 6, 68, 128, 53, 22, 99, 114, 84, 7, 129, 38, 69,
@@ -87,7 +87,7 @@ DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_16x16[256]) = {
255,
};
-DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_16x16[256]) = {
+DECLARE_ALIGNED(16, static const int16_t, col_scan_16x16[256]) = {
0, 16, 32, 48, 1, 64, 17, 80, 33, 96, 49, 2, 65, 112, 18, 81,
34, 128, 50, 97, 3, 66, 144, 19, 113, 35, 82, 160, 98, 51, 129, 4,
67, 176, 20, 114, 145, 83, 36, 99, 130, 52, 192, 5, 161, 68, 115, 21,
@@ -108,7 +108,7 @@ DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_16x16[256]) = {
255,
};
-DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_16x16[256]) = {
+DECLARE_ALIGNED(16, static const int16_t, row_scan_16x16[256]) = {
0, 1, 2, 16, 3, 17, 4, 18, 32, 5, 33, 19, 6, 34, 48, 20,
49, 7, 35, 21, 50, 64, 8, 36, 65, 22, 51, 37, 80, 9, 66, 52,
23, 38, 81, 67, 10, 53, 24, 82, 68, 96, 39, 11, 54, 83, 97, 69,
@@ -130,7 +130,7 @@ DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_16x16[256]) = {
255,
};
-DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_32x32[1024]) = {
+DECLARE_ALIGNED(16, static const int16_t, default_scan_32x32[1024]) = {
0, 32, 1, 64, 33, 2, 96, 65, 34, 128, 3, 97, 66, 160,
129, 35, 98, 4, 67, 130, 161, 192, 36, 99, 224, 5, 162, 193,
68, 131, 37, 100,
@@ -233,95 +233,69 @@ DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_32x32[1024]) = {
// in {top, left, topleft, topright, bottomleft} order
// for each position in raster scan order.
// -1 indicates the neighbor does not exist.
-DECLARE_ALIGNED(16, int16_t,
- vp9_default_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
-DECLARE_ALIGNED(16, int16_t,
- vp9_col_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
-DECLARE_ALIGNED(16, int16_t,
- vp9_row_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
-DECLARE_ALIGNED(16, int16_t,
- vp9_col_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
-DECLARE_ALIGNED(16, int16_t,
- vp9_row_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
-DECLARE_ALIGNED(16, int16_t,
- vp9_default_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
-DECLARE_ALIGNED(16, int16_t,
- vp9_col_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
-DECLARE_ALIGNED(16, int16_t,
- vp9_row_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
-DECLARE_ALIGNED(16, int16_t,
- vp9_default_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
-DECLARE_ALIGNED(16, int16_t,
- vp9_default_scan_32x32_neighbors[1025 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t,
+ default_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t,
+ col_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t,
+ row_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t,
+ col_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t,
+ row_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t,
+ default_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t,
+ col_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t,
+ row_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t,
+ default_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t,
+ default_scan_32x32_neighbors[1025 * MAX_NEIGHBORS]);
+DECLARE_ALIGNED(16, static int16_t, vp9_default_iscan_4x4[16]);
+DECLARE_ALIGNED(16, static int16_t, vp9_col_iscan_4x4[16]);
+DECLARE_ALIGNED(16, static int16_t, vp9_row_iscan_4x4[16]);
+DECLARE_ALIGNED(16, static int16_t, vp9_col_iscan_8x8[64]);
+DECLARE_ALIGNED(16, static int16_t, vp9_row_iscan_8x8[64]);
+DECLARE_ALIGNED(16, static int16_t, vp9_default_iscan_8x8[64]);
+DECLARE_ALIGNED(16, static int16_t, vp9_col_iscan_16x16[256]);
+DECLARE_ALIGNED(16, static int16_t, vp9_row_iscan_16x16[256]);
+DECLARE_ALIGNED(16, static int16_t, vp9_default_iscan_16x16[256]);
+DECLARE_ALIGNED(16, static int16_t, vp9_default_iscan_32x32[1024]);
-DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_4x4[16]);
-DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_4x4[16]);
-DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_4x4[16]);
-DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_8x8[64]);
-DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_8x8[64]);
-DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_8x8[64]);
-DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_16x16[256]);
-DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_16x16[256]);
-DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_16x16[256]);
-DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_32x32[1024]);
-
-const scan_order inter_scan_orders[TX_SIZES] = {
- {vp9_default_scan_4x4, vp9_default_scan_4x4_neighbors}, // NEWMV
- {vp9_default_scan_8x8, vp9_default_scan_8x8_neighbors}, // NEWMV
- {vp9_default_scan_16x16, vp9_default_scan_16x16_neighbors}, // NEWMV
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // NEWMV
+const scan_order vp9_default_scan_orders[TX_SIZES] = {
+ {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+ {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+ {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+ {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
};
-const scan_order intra_scan_orders[TX_SIZES][INTRA_MODES] = {
- { // 4X4
- {vp9_default_scan_4x4, vp9_default_scan_4x4_neighbors}, // DC
- {vp9_row_scan_4x4, vp9_row_scan_4x4_neighbors}, // V
- {vp9_col_scan_4x4, vp9_col_scan_4x4_neighbors}, // H
- {vp9_default_scan_4x4, vp9_default_scan_4x4_neighbors}, // D45
- {vp9_default_scan_4x4, vp9_default_scan_4x4_neighbors}, // D135
- {vp9_row_scan_4x4, vp9_row_scan_4x4_neighbors}, // D117
- {vp9_col_scan_4x4, vp9_col_scan_4x4_neighbors}, // D153
- {vp9_col_scan_4x4, vp9_col_scan_4x4_neighbors}, // D207
- {vp9_row_scan_4x4, vp9_row_scan_4x4_neighbors}, // D63
- {vp9_default_scan_4x4, vp9_default_scan_4x4_neighbors}, // TM
- }, { // 8x8
- {vp9_default_scan_8x8, vp9_default_scan_8x8_neighbors}, // DC
- {vp9_row_scan_8x8, vp9_row_scan_8x8_neighbors}, // V
- {vp9_col_scan_8x8, vp9_col_scan_8x8_neighbors}, // H
- {vp9_default_scan_8x8, vp9_default_scan_8x8_neighbors}, // D45
- {vp9_default_scan_8x8, vp9_default_scan_8x8_neighbors}, // D135
- {vp9_row_scan_8x8, vp9_row_scan_8x8_neighbors}, // D117
- {vp9_col_scan_8x8, vp9_col_scan_8x8_neighbors}, // D153
- {vp9_col_scan_8x8, vp9_col_scan_8x8_neighbors}, // D207
- {vp9_row_scan_8x8, vp9_row_scan_8x8_neighbors}, // D63
- {vp9_default_scan_8x8, vp9_default_scan_8x8_neighbors}, // TM
- }, { // 16x16
- {vp9_default_scan_16x16, vp9_default_scan_16x16_neighbors}, // DC
- {vp9_row_scan_16x16, vp9_row_scan_16x16_neighbors}, // V
- {vp9_col_scan_16x16, vp9_col_scan_16x16_neighbors}, // H
- {vp9_default_scan_16x16, vp9_default_scan_16x16_neighbors}, // D45
- {vp9_default_scan_16x16, vp9_default_scan_16x16_neighbors}, // D135
- {vp9_row_scan_16x16, vp9_row_scan_16x16_neighbors}, // D117
- {vp9_col_scan_16x16, vp9_col_scan_16x16_neighbors}, // D153
- {vp9_col_scan_16x16, vp9_col_scan_16x16_neighbors}, // D207
- {vp9_row_scan_16x16, vp9_row_scan_16x16_neighbors}, // D63
- {vp9_default_scan_16x16, vp9_default_scan_16x16_neighbors}, // TM
- }, { // 32x32
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // DC
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // V
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // H
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // D45
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // D135
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // D117
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // D153
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // D207
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // D63
- {vp9_default_scan_32x32, vp9_default_scan_32x32_neighbors}, // TM
+const scan_order vp9_scan_orders[TX_SIZES][TX_TYPES] = {
+ { // TX_4X4
+ {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors},
+ {row_scan_4x4, vp9_row_iscan_4x4, row_scan_4x4_neighbors},
+ {col_scan_4x4, vp9_col_iscan_4x4, col_scan_4x4_neighbors},
+ {default_scan_4x4, vp9_default_iscan_4x4, default_scan_4x4_neighbors}
+ }, { // TX_8X8
+ {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors},
+ {row_scan_8x8, vp9_row_iscan_8x8, row_scan_8x8_neighbors},
+ {col_scan_8x8, vp9_col_iscan_8x8, col_scan_8x8_neighbors},
+ {default_scan_8x8, vp9_default_iscan_8x8, default_scan_8x8_neighbors}
+ }, { // TX_16X16
+ {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors},
+ {row_scan_16x16, vp9_row_iscan_16x16, row_scan_16x16_neighbors},
+ {col_scan_16x16, vp9_col_iscan_16x16, col_scan_16x16_neighbors},
+ {default_scan_16x16, vp9_default_iscan_16x16, default_scan_16x16_neighbors}
+ }, { // TX_32X32
+ {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+ {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+ {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
+ {default_scan_32x32, vp9_default_iscan_32x32, default_scan_32x32_neighbors},
}
};
-
static int find_in_scan(const int16_t *scan, int l, int idx) {
int n, l2 = l * l;
for (n = 0; n < l2; n++) {
@@ -332,9 +306,9 @@ static int find_in_scan(const int16_t *scan, int l, int idx) {
assert(0);
return -1;
}
-static void init_scan_neighbors(const int16_t *scan,
- int16_t *iscan,
- int l, int16_t *neighbors) {
+
+static void init_scan_neighbors(const int16_t *scan, int16_t *iscan, int l,
+ int16_t *neighbors) {
int l2 = l * l;
int n, i, j;
@@ -358,15 +332,15 @@ static void init_scan_neighbors(const int16_t *scan,
// use the combination of the two as a context.
int a = (i - 1) * l + j;
int b = i * l + j - 1;
- if (scan == vp9_col_scan_4x4 || scan == vp9_col_scan_8x8 ||
- scan == vp9_col_scan_16x16) {
+ if (scan == col_scan_4x4 || scan == col_scan_8x8 ||
+ scan == col_scan_16x16) {
// in the col/row scan cases (as well as left/top edge cases), we set
// both contexts to the same value, so we can branchlessly do a+b+1>>1
// which automatically becomes a if a == b
neighbors[MAX_NEIGHBORS * n + 0] =
neighbors[MAX_NEIGHBORS * n + 1] = a;
- } else if (scan == vp9_row_scan_4x4 || scan == vp9_row_scan_8x8 ||
- scan == vp9_row_scan_16x16) {
+ } else if (scan == row_scan_4x4 || scan == row_scan_8x8 ||
+ scan == row_scan_16x16) {
neighbors[MAX_NEIGHBORS * n + 0] =
neighbors[MAX_NEIGHBORS * n + 1] = b;
} else {
@@ -390,24 +364,24 @@ static void init_scan_neighbors(const int16_t *scan,
}
void vp9_init_neighbors() {
- init_scan_neighbors(vp9_default_scan_4x4, vp9_default_iscan_4x4, 4,
- vp9_default_scan_4x4_neighbors);
- init_scan_neighbors(vp9_row_scan_4x4, vp9_row_iscan_4x4, 4,
- vp9_row_scan_4x4_neighbors);
- init_scan_neighbors(vp9_col_scan_4x4, vp9_col_iscan_4x4, 4,
- vp9_col_scan_4x4_neighbors);
- init_scan_neighbors(vp9_default_scan_8x8, vp9_default_iscan_8x8, 8,
- vp9_default_scan_8x8_neighbors);
- init_scan_neighbors(vp9_row_scan_8x8, vp9_row_iscan_8x8, 8,
- vp9_row_scan_8x8_neighbors);
- init_scan_neighbors(vp9_col_scan_8x8, vp9_col_iscan_8x8, 8,
- vp9_col_scan_8x8_neighbors);
- init_scan_neighbors(vp9_default_scan_16x16, vp9_default_iscan_16x16, 16,
- vp9_default_scan_16x16_neighbors);
- init_scan_neighbors(vp9_row_scan_16x16, vp9_row_iscan_16x16, 16,
- vp9_row_scan_16x16_neighbors);
- init_scan_neighbors(vp9_col_scan_16x16, vp9_col_iscan_16x16, 16,
- vp9_col_scan_16x16_neighbors);
- init_scan_neighbors(vp9_default_scan_32x32, vp9_default_iscan_32x32, 32,
- vp9_default_scan_32x32_neighbors);
+ init_scan_neighbors(default_scan_4x4, vp9_default_iscan_4x4, 4,
+ default_scan_4x4_neighbors);
+ init_scan_neighbors(row_scan_4x4, vp9_row_iscan_4x4, 4,
+ row_scan_4x4_neighbors);
+ init_scan_neighbors(col_scan_4x4, vp9_col_iscan_4x4, 4,
+ col_scan_4x4_neighbors);
+ init_scan_neighbors(default_scan_8x8, vp9_default_iscan_8x8, 8,
+ default_scan_8x8_neighbors);
+ init_scan_neighbors(row_scan_8x8, vp9_row_iscan_8x8, 8,
+ row_scan_8x8_neighbors);
+ init_scan_neighbors(col_scan_8x8, vp9_col_iscan_8x8, 8,
+ col_scan_8x8_neighbors);
+ init_scan_neighbors(default_scan_16x16, vp9_default_iscan_16x16, 16,
+ default_scan_16x16_neighbors);
+ init_scan_neighbors(row_scan_16x16, vp9_row_iscan_16x16, 16,
+ row_scan_16x16_neighbors);
+ init_scan_neighbors(col_scan_16x16, vp9_col_iscan_16x16, 16,
+ col_scan_16x16_neighbors);
+ init_scan_neighbors(default_scan_32x32, vp9_default_iscan_32x32, 32,
+ default_scan_32x32_neighbors);
}
diff --git a/vp9/common/vp9_scan.h b/vp9/common/vp9_scan.h
index 98fc607ca..efab48bfc 100644
--- a/vp9/common/vp9_scan.h
+++ b/vp9/common/vp9_scan.h
@@ -19,184 +19,16 @@
#define MAX_NEIGHBORS 2
-extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_4x4[16]);
-extern DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_4x4[16]);
-extern DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_4x4[16]);
-
-extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_8x8[64]);
-extern DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_8x8[64]);
-extern DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_8x8[64]);
-
-extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_16x16[256]);
-extern DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_16x16[256]);
-extern DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_16x16[256]);
-
-extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_32x32[1024]);
-
-extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_4x4[16]);
-extern DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_4x4[16]);
-extern DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_4x4[16]);
-
-extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_8x8[64]);
-extern DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_8x8[64]);
-extern DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_8x8[64]);
-
-extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_16x16[256]);
-extern DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_16x16[256]);
-extern DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_16x16[256]);
-
-extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_32x32[1024]);
-
-extern DECLARE_ALIGNED(16, int16_t,
- vp9_default_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
-extern DECLARE_ALIGNED(16, int16_t,
- vp9_col_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
-extern DECLARE_ALIGNED(16, int16_t,
- vp9_row_scan_4x4_neighbors[17 * MAX_NEIGHBORS]);
-extern DECLARE_ALIGNED(16, int16_t,
- vp9_col_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
-extern DECLARE_ALIGNED(16, int16_t,
- vp9_row_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
-extern DECLARE_ALIGNED(16, int16_t,
- vp9_default_scan_8x8_neighbors[65 * MAX_NEIGHBORS]);
-extern DECLARE_ALIGNED(16, int16_t,
- vp9_col_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
-extern DECLARE_ALIGNED(16, int16_t,
- vp9_row_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
-extern DECLARE_ALIGNED(16, int16_t,
- vp9_default_scan_16x16_neighbors[257 * MAX_NEIGHBORS]);
-extern DECLARE_ALIGNED(16, int16_t,
- vp9_default_scan_32x32_neighbors[1025 * MAX_NEIGHBORS]);
-
void vp9_init_neighbors();
typedef struct {
const int16_t *scan;
+ const int16_t *iscan;
const int16_t *neighbors;
} scan_order;
-extern const scan_order intra_scan_orders[TX_SIZES][INTRA_MODES];
-extern const scan_order inter_scan_orders[TX_SIZES];
-
-static INLINE const int16_t* 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_scan_4x4;
- }
-}
-
-static INLINE void get_scan_nb_4x4(TX_TYPE tx_type,
- const int16_t **scan, const int16_t **nb) {
- switch (tx_type) {
- case ADST_DCT:
- *scan = vp9_row_scan_4x4;
- *nb = vp9_row_scan_4x4_neighbors;
- break;
- case DCT_ADST:
- *scan = vp9_col_scan_4x4;
- *nb = vp9_col_scan_4x4_neighbors;
- break;
- default:
- *scan = vp9_default_scan_4x4;
- *nb = vp9_default_scan_4x4_neighbors;
- break;
- }
-}
-
-static INLINE const int16_t* get_iscan_4x4(TX_TYPE tx_type) {
- switch (tx_type) {
- case ADST_DCT:
- return vp9_row_iscan_4x4;
- case DCT_ADST:
- return vp9_col_iscan_4x4;
- default:
- return vp9_default_iscan_4x4;
- }
-}
-
-static INLINE const int16_t* 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_scan_8x8;
- }
-}
-
-static INLINE void get_scan_nb_8x8(TX_TYPE tx_type,
- const int16_t **scan, const int16_t **nb) {
- switch (tx_type) {
- case ADST_DCT:
- *scan = vp9_row_scan_8x8;
- *nb = vp9_row_scan_8x8_neighbors;
- break;
- case DCT_ADST:
- *scan = vp9_col_scan_8x8;
- *nb = vp9_col_scan_8x8_neighbors;
- break;
- default:
- *scan = vp9_default_scan_8x8;
- *nb = vp9_default_scan_8x8_neighbors;
- break;
- }
-}
-
-static INLINE const int16_t* get_iscan_8x8(TX_TYPE tx_type) {
- switch (tx_type) {
- case ADST_DCT:
- return vp9_row_iscan_8x8;
- case DCT_ADST:
- return vp9_col_iscan_8x8;
- default:
- return vp9_default_iscan_8x8;
- }
-}
-
-static INLINE const int16_t* 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_scan_16x16;
- }
-}
-
-static INLINE void get_scan_nb_16x16(TX_TYPE tx_type,
- const int16_t **scan, const int16_t **nb) {
- switch (tx_type) {
- case ADST_DCT:
- *scan = vp9_row_scan_16x16;
- *nb = vp9_row_scan_16x16_neighbors;
- break;
- case DCT_ADST:
- *scan = vp9_col_scan_16x16;
- *nb = vp9_col_scan_16x16_neighbors;
- break;
- default:
- *scan = vp9_default_scan_16x16;
- *nb = vp9_default_scan_16x16_neighbors;
- break;
- }
-}
-
-static INLINE const int16_t* get_iscan_16x16(TX_TYPE tx_type) {
- switch (tx_type) {
- case ADST_DCT:
- return vp9_row_iscan_16x16;
- case DCT_ADST:
- return vp9_col_iscan_16x16;
- default:
- return vp9_default_iscan_16x16;
- }
-}
+extern const scan_order vp9_default_scan_orders[TX_SIZES];
+extern const scan_order vp9_scan_orders[TX_SIZES][TX_TYPES];
static INLINE int get_coef_context(const int16_t *neighbors,
const uint8_t *token_cache, int c) {
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index 9c1f61000..75f0ae865 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -123,23 +123,23 @@ static int read_intra_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd,
static int read_inter_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd,
int mi_row, int mi_col, vp9_reader *r) {
struct segmentation *const seg = &cm->seg;
- const BLOCK_SIZE bsize = xd->mi_8x8[0]->mbmi.sb_type;
- int pred_segment_id, segment_id;
+ MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi;
+ const BLOCK_SIZE bsize = mbmi->sb_type;
+ int predicted_segment_id, segment_id;
if (!seg->enabled)
return 0; // Default for disabled segmentation
- pred_segment_id = vp9_get_segment_id(cm, cm->last_frame_seg_map,
- bsize, mi_row, mi_col);
+ predicted_segment_id = vp9_get_segment_id(cm, cm->last_frame_seg_map,
+ bsize, mi_row, mi_col);
if (!seg->update_map)
- return pred_segment_id;
+ return predicted_segment_id;
if (seg->temporal_update) {
const vp9_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd);
- const int pred_flag = vp9_read(r, pred_prob);
- vp9_set_pred_flag_seg_id(xd, pred_flag);
- segment_id = pred_flag ? pred_segment_id
- : read_segment_id(r, seg);
+ mbmi->seg_id_predicted = vp9_read(r, pred_prob);
+ segment_id = mbmi->seg_id_predicted ? predicted_segment_id
+ : read_segment_id(r, seg);
} else {
segment_id = read_segment_id(r, seg);
}
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index f6219c527..214c1c198 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -108,14 +108,16 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
counts->coef[tx_size][type][ref];
unsigned int (*eob_branch_count)[PREV_COEF_CONTEXTS] =
counts->eob_branch[tx_size][type][ref];
- const int16_t *scan, *nb;
const uint8_t *cat6;
const uint8_t *band_translate = get_band_translate(tx_size);
const int dq_shift = (tx_size == TX_32X32);
+ const scan_order *so = get_scan(xd, tx_size, type, block_idx);
+ const int16_t *scan = so->scan;
+ const int16_t *nb = so->neighbors;
int v;
int16_t dqv = dq[0];
- get_scan(xd, tx_size, type, block_idx, &scan, &nb);
+
while (c < seg_eob) {
int val;
diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c
index 22ab26daf..88cf11214 100644
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -152,16 +152,18 @@ static void optimize_b(MACROBLOCK *mb,
PLANE_TYPE type = pd->plane_type;
int err_mult = plane_rd_mult[type];
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];
const int16_t *dequant_ptr = pd->dequant;
const uint8_t *const band_translate = get_band_translate(tx_size);
+ const scan_order *so = get_scan(xd, tx_size, type, block);
+ const int16_t *scan = so->scan;
+ const int16_t *nb = so->neighbors;
assert((!type && !plane) || (type && plane));
dqcoeff_ptr = BLOCK_OFFSET(pd->dqcoeff, block);
qcoeff_ptr = BLOCK_OFFSET(pd->qcoeff, block);
- get_scan(xd, tx_size, type, block, &scan, &nb);
assert(eob <= default_eob);
/* Now set up a Viterbi trellis to evaluate alternative roundings. */
@@ -368,7 +370,7 @@ void vp9_xform_quant(int plane, int block, BLOCK_SIZE plane_bsize,
int16_t *coeff = BLOCK_OFFSET(p->coeff, block);
int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block);
int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
- const int16_t *scan, *iscan;
+ const scan_order *so;
uint16_t *eob = &pd->eobs[block];
const int bwl = b_width_log2(plane_bsize), bw = 1 << bwl;
const int twl = bwl - tx_size, twmask = (1 << twl) - 1;
@@ -377,8 +379,7 @@ void vp9_xform_quant(int plane, int block, BLOCK_SIZE plane_bsize,
switch (tx_size) {
case TX_32X32:
- scan = vp9_default_scan_32x32;
- iscan = vp9_default_iscan_32x32;
+ so = &vp9_default_scan_orders[TX_32X32];
block >>= 6;
xoff = 32 * (block & twmask);
yoff = 32 * (block >> twl);
@@ -389,11 +390,11 @@ void vp9_xform_quant(int plane, int block, BLOCK_SIZE plane_bsize,
vp9_fdct32x32(src_diff, coeff, bw * 4);
vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff, dqcoeff,
- pd->dequant, p->zbin_extra, eob, scan, iscan);
+ pd->dequant, p->zbin_extra, eob, so->scan,
+ so->iscan);
break;
case TX_16X16:
- scan = vp9_default_scan_16x16;
- iscan = vp9_default_iscan_16x16;
+ so = &vp9_default_scan_orders[TX_16X16];
block >>= 4;
xoff = 16 * (block & twmask);
yoff = 16 * (block >> twl);
@@ -401,11 +402,10 @@ void vp9_xform_quant(int plane, int block, BLOCK_SIZE plane_bsize,
vp9_fdct16x16(src_diff, coeff, bw * 4);
vp9_quantize_b(coeff, 256, x->skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff, dqcoeff,
- pd->dequant, p->zbin_extra, eob, scan, iscan);
+ pd->dequant, p->zbin_extra, eob, so->scan, so->iscan);
break;
case TX_8X8:
- scan = vp9_default_scan_8x8;
- iscan = vp9_default_iscan_8x8;
+ so = &vp9_default_scan_orders[TX_8X8];
block >>= 2;
xoff = 8 * (block & twmask);
yoff = 8 * (block >> twl);
@@ -413,18 +413,17 @@ void vp9_xform_quant(int plane, int block, BLOCK_SIZE plane_bsize,
vp9_fdct8x8(src_diff, coeff, bw * 4);
vp9_quantize_b(coeff, 64, x->skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff, dqcoeff,
- pd->dequant, p->zbin_extra, eob, scan, iscan);
+ pd->dequant, p->zbin_extra, eob, so->scan, so->iscan);
break;
case TX_4X4:
- scan = vp9_default_scan_4x4;
- iscan = vp9_default_iscan_4x4;
+ so = &vp9_default_scan_orders[TX_4X4];
xoff = 4 * (block & twmask);
yoff = 4 * (block >> twl);
src_diff = p->src_diff + 4 * bw * yoff + xoff;
x->fwd_txm4x4(src_diff, coeff, bw * 4);
vp9_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff, dqcoeff,
- pd->dequant, p->zbin_extra, eob, scan, iscan);
+ pd->dequant, p->zbin_extra, eob, so->scan, so->iscan);
break;
default:
assert(0);
@@ -547,7 +546,7 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
int16_t *coeff = BLOCK_OFFSET(p->coeff, block);
int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block);
int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
- const int16_t *scan, *iscan;
+ const scan_order *so;
TX_TYPE tx_type;
MB_PREDICTION_MODE mode;
const int bwl = b_width_log2(plane_bsize);
@@ -569,8 +568,7 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
switch (tx_size) {
case TX_32X32:
- scan = vp9_default_scan_32x32;
- iscan = vp9_default_iscan_32x32;
+ so = &vp9_default_scan_orders[TX_32X32];
mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
block >>= 6;
vp9_predict_intra_block(xd, block, bwl, TX_32X32, mode,
@@ -585,15 +583,15 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
vp9_fdct32x32(src_diff, coeff, diff_stride);
vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff, dqcoeff,
- pd->dequant, p->zbin_extra, eob, scan, iscan);
+ pd->dequant, p->zbin_extra, eob, so->scan,
+ so->iscan);
}
if (!x->skip_encode && *eob)
vp9_idct32x32_add(dqcoeff, dst, pd->dst.stride, *eob);
break;
case TX_16X16:
tx_type = get_tx_type_16x16(pd->plane_type, xd);
- scan = get_scan_16x16(tx_type);
- iscan = get_iscan_16x16(tx_type);
+ so = &vp9_scan_orders[TX_16X16][tx_type];
mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
block >>= 4;
vp9_predict_intra_block(xd, block, bwl, TX_16X16, mode,
@@ -604,15 +602,14 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
vp9_fht16x16(tx_type, src_diff, coeff, diff_stride);
vp9_quantize_b(coeff, 256, x->skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff, dqcoeff,
- pd->dequant, p->zbin_extra, eob, scan, iscan);
+ pd->dequant, p->zbin_extra, eob, so->scan, so->iscan);
}
if (!x->skip_encode && *eob)
vp9_iht16x16_add(tx_type, dqcoeff, dst, pd->dst.stride, *eob);
break;
case TX_8X8:
tx_type = get_tx_type_8x8(pd->plane_type, xd);
- scan = get_scan_8x8(tx_type);
- iscan = get_iscan_8x8(tx_type);
+ so = &vp9_scan_orders[TX_8X8][tx_type];
mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
block >>= 2;
vp9_predict_intra_block(xd, block, bwl, TX_8X8, mode,
@@ -623,15 +620,14 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
vp9_fht8x8(tx_type, src_diff, coeff, diff_stride);
vp9_quantize_b(coeff, 64, x->skip_block, p->zbin, p->round, p->quant,
p->quant_shift, qcoeff, dqcoeff,
- pd->dequant, p->zbin_extra, eob, scan, iscan);
+ pd->dequant, p->zbin_extra, eob, so->scan, so->iscan);
}
if (!x->skip_encode && *eob)
vp9_iht8x8_add(tx_type, dqcoeff, dst, pd->dst.stride, *eob);
break;
case TX_4X4:
tx_type = get_tx_type_4x4(pd->plane_type, xd, block);
- scan = get_scan_4x4(tx_type);
- iscan = get_iscan_4x4(tx_type);
+ so = &vp9_scan_orders[TX_4X4][tx_type];
if (mbmi->sb_type < BLOCK_8X8 && plane == 0)
mode = xd->mi_8x8[0]->bmi[block].as_mode;
else
@@ -649,7 +645,7 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
x->fwd_txm4x4(src_diff, coeff, diff_stride);
vp9_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round, p->quant,
p->quant_shift, qcoeff, dqcoeff,
- pd->dequant, p->zbin_extra, eob, scan, iscan);
+ pd->dequant, p->zbin_extra, eob, so->scan, so->iscan);
}
if (!x->skip_encode && *eob) {
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 8905225ef..fde84298f 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -682,6 +682,7 @@ static void txfm_rd_in_plane(MACROBLOCK *x,
const BLOCK_SIZE bs = get_plane_block_size(bsize, pd);
const int num_4x4_w = num_4x4_blocks_wide_lookup[bs];
const int num_4x4_h = num_4x4_blocks_high_lookup[bs];
+ const scan_order *so;
init_rdcost_stack(x, tx_size, num_4x4_w, num_4x4_h,
ref_best_rd, rd_stack);
@@ -692,7 +693,9 @@ static void txfm_rd_in_plane(MACROBLOCK *x,
pd->above_context, pd->left_context,
num_4x4_w, num_4x4_h);
- get_scan(xd, tx_size, pd->plane_type, 0, &rd_stack->scan, &rd_stack->nb);
+ so = get_scan(xd, tx_size, pd->plane_type, 0);
+ rd_stack->scan = so->scan;
+ rd_stack->nb = so->neighbors;
foreach_transformed_block_in_plane(xd, bsize, plane,
block_yrd_txfm, rd_stack);
@@ -1069,8 +1072,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib,
for (idy = 0; idy < num_4x4_blocks_high; ++idy) {
for (idx = 0; idx < num_4x4_blocks_wide; ++idx) {
int64_t ssz;
- const int16_t *scan;
- const int16_t *nb;
+ const scan_order *so;
const uint8_t *src = src_init + idx * 4 + idy * 4 * src_stride;
uint8_t *dst = dst_init + idx * 4 + idy * 4 * dst_stride;
const int block = ib + idy * 2 + idx;
@@ -1088,17 +1090,17 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib,
dst, dst_stride);
tx_type = get_tx_type_4x4(PLANE_TYPE_Y_WITH_DC, xd, block);
- get_scan_nb_4x4(tx_type, &scan, &nb);
+ so = &vp9_scan_orders[TX_4X4][tx_type];
if (tx_type != DCT_DCT)
vp9_short_fht4x4(src_diff, coeff, 8, tx_type);
else
x->fwd_txm4x4(src_diff, coeff, 8);
- vp9_regular_quantize_b_4x4(x, 4, block, scan, get_iscan_4x4(tx_type));
+ vp9_regular_quantize_b_4x4(x, 4, block, so->scan, so->iscan);
- ratey += cost_coeffs(x, 0, block,
- tempa + idx, templ + idy, TX_4X4, scan, nb);
+ ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
+ so->scan, so->neighbors);
distortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, block),
16, &ssz) >> 2;
if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd)
@@ -1559,6 +1561,7 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi,
pd->dst.stride)];
int64_t thisdistortion = 0, thissse = 0;
int thisrate = 0, ref;
+ const scan_order *so = &vp9_default_scan_orders[TX_4X4];
const int is_compound = has_second_ref(&mi->mbmi);
for (ref = 0; ref < 1 + is_compound; ++ref) {
const uint8_t *pre = &pd->pre[ref].buf[raster_block_offset(BLOCK_8X8, i,
@@ -1585,16 +1588,12 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi,
coeff = BLOCK_OFFSET(p->coeff, k);
x->fwd_txm4x4(raster_block_offset_int16(BLOCK_8X8, k, p->src_diff),
coeff, 8);
- vp9_regular_quantize_b_4x4(x, 4, k, get_scan_4x4(DCT_DCT),
- get_iscan_4x4(DCT_DCT));
+ vp9_regular_quantize_b_4x4(x, 4, k, so->scan, so->iscan);
thisdistortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, k),
16, &ssz);
thissse += ssz;
- thisrate += cost_coeffs(x, 0, k,
- ta + (k & 1),
- tl + (k >> 1), TX_4X4,
- vp9_default_scan_4x4,
- vp9_default_scan_4x4_neighbors);
+ thisrate += cost_coeffs(x, 0, k, ta + (k & 1), tl + (k >> 1), TX_4X4,
+ so->scan, so->neighbors);
rd1 = RDCOST(x->rdmult, x->rddiv, thisrate, thisdistortion >> 2);
rd2 = RDCOST(x->rdmult, x->rddiv, 0, thissse >> 2);
rd = MIN(rd1, rd2);
diff --git a/vp9/encoder/vp9_segmentation.c b/vp9/encoder/vp9_segmentation.c
index 24f011f83..a9cdc9a67 100644
--- a/vp9/encoder/vp9_segmentation.c
+++ b/vp9/encoder/vp9_segmentation.c
@@ -149,7 +149,7 @@ static void count_segs(VP9_COMP *cpi, const TileInfo *const tile,
// Store the prediction status for this mb and update counts
// as appropriate
- vp9_set_pred_flag_seg_id(xd, pred_flag);
+ xd->mi_8x8[0]->mbmi.seg_id_predicted = pred_flag;
temporal_predictor_count[pred_context][pred_flag]++;
if (!pred_flag)
diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c
index c7336d003..3f1cc6fe8 100644
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -112,11 +112,13 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
const int segment_id = mbmi->segment_id;
const int16_t *scan, *nb;
+ const scan_order *so;
vp9_coeff_count *const counts = cpi->coef_counts[tx_size];
vp9_coeff_probs_model *const coef_probs = cpi->common.fc.coef_probs[tx_size];
const int ref = is_inter_block(mbmi);
const uint8_t *const band_translate = get_band_translate(tx_size);
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);
@@ -124,7 +126,10 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
pt = get_entropy_context(tx_size, pd->above_context + aoff,
pd->left_context + loff);
- get_scan(xd, tx_size, type, block, &scan, &nb);
+ so = get_scan(xd, tx_size, type, block);
+ scan = so->scan;
+ nb = so->neighbors;
+
c = 0;
do {
const int band = band_translate[c];
diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c
index 5dacab454..fde73e4ab 100644
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -668,6 +668,25 @@ static vpx_codec_err_t get_frame_corrupted(vpx_codec_alg_priv_t *ctx,
}
}
+static vpx_codec_err_t get_display_size(vpx_codec_alg_priv_t *ctx,
+ int ctrl_id,
+ va_list args) {
+ int *const display_size = va_arg(args, int *);
+
+ if (display_size) {
+ const VP9D_COMP *const pbi = (VP9D_COMP *)ctx->pbi;
+ if (pbi) {
+ display_size[0] = pbi->common.display_width;
+ display_size[1] = pbi->common.display_height;
+ } else {
+ return VPX_CODEC_ERROR;
+ }
+ return VPX_CODEC_OK;
+ } else {
+ return VPX_CODEC_INVALID_PARAM;
+ }
+}
+
static vpx_codec_err_t set_invert_tile_order(vpx_codec_alg_priv_t *ctx,
int ctr_id,
va_list args) {
@@ -686,6 +705,7 @@ static vpx_codec_ctrl_fn_map_t ctf_maps[] = {
{VP8D_GET_LAST_REF_UPDATES, get_last_ref_updates},
{VP8D_GET_FRAME_CORRUPTED, get_frame_corrupted},
{VP9_GET_REFERENCE, get_reference},
+ {VP9D_GET_DISPLAY_SIZE, get_display_size},
{VP9_INVERT_TILE_DECODE_ORDER, set_invert_tile_order},
{ -1, NULL},
};
diff --git a/vpx/vp8dx.h b/vpx/vp8dx.h
index d3093c48c..b457b9302 100644
--- a/vpx/vp8dx.h
+++ b/vpx/vp8dx.h
@@ -73,6 +73,9 @@ enum vp8_dec_control_id {
*/
VP8D_SET_DECRYPTOR,
+ /** control function to get the display dimensions for the current frame. */
+ VP9D_GET_DISPLAY_SIZE,
+
/** For testing. */
VP9_INVERT_TILE_DECODE_ORDER,
@@ -105,6 +108,7 @@ VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *)
VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *)
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *)
VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vp8_decrypt_init *)
+VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *)
VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int)
/*! @} - end defgroup vp8_decoder */
diff --git a/vpx_ports/x86.h b/vpx_ports/x86.h
index e5e97e706..fdbed2524 100644
--- a/vpx_ports/x86.h
+++ b/vpx_ports/x86.h
@@ -71,6 +71,7 @@ typedef enum {
#endif
#else /* end __SUNPRO__ */
#if ARCH_X86_64
+#if defined(_MSC_VER) && _MSC_VER > 1500
void __cpuidex(int CPUInfo[4], int info_type, int ecxvalue);
#pragma intrinsic(__cpuidex)
#define cpuid(func, func2, a, b, c, d) do {\
@@ -79,6 +80,15 @@ void __cpuidex(int CPUInfo[4], int info_type, int ecxvalue);
a = regs[0]; b = regs[1]; c = regs[2]; d = regs[3];\
} while(0)
#else
+void __cpuid(int CPUInfo[4], int info_type);
+#pragma intrinsic(__cpuid)
+#define cpuid(func, func2, a, b, c, d) do {\
+ int regs[4];\
+ __cpuid(regs, func); \
+ a = regs[0]; b = regs[1]; c = regs[2]; d = regs[3];\
+ } while (0)
+#endif
+#else
#define cpuid(func, func2, a, b, c, d)\
__asm mov eax, func\
__asm mov ecx, func2\
diff --git a/vpx_scale/generic/yv12extend.c b/vpx_scale/generic/yv12extend.c
index f2aec2b7a..7896dfee6 100644
--- a/vpx_scale/generic/yv12extend.c
+++ b/vpx_scale/generic/yv12extend.c
@@ -84,14 +84,13 @@ void vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) {
static void extend_frame(YV12_BUFFER_CONFIG *const ybf,
int subsampling_x, int subsampling_y,
int ext_size) {
- const int c_w = (ybf->y_crop_width + subsampling_x) >> subsampling_x;
- const int c_h = (ybf->y_crop_height + subsampling_y) >> subsampling_y;
- const int c_et = ext_size >> subsampling_y;
- const int c_el = ext_size >> subsampling_x;
- const int c_eb = (ext_size + ybf->y_height - ybf->y_crop_height +
- subsampling_y) >> subsampling_y;
- const int c_er = (ext_size + ybf->y_width - ybf->y_crop_width +
- subsampling_x) >> subsampling_x;
+ const int c_w = ybf->uv_crop_width;
+ const int c_h = ybf->uv_crop_height;
+ const int c_ext_size = ext_size >> 1;
+ const int c_et = c_ext_size;
+ const int c_el = c_ext_size;
+ const int c_eb = c_ext_size + ybf->uv_height - ybf->uv_crop_height;
+ const int c_er = c_ext_size + ybf->uv_width - ybf->uv_crop_width;
assert(ybf->y_height - ybf->y_crop_height < 16);
assert(ybf->y_width - ybf->y_crop_width < 16);
diff --git a/vpxdec.c b/vpxdec.c
index dc2eec826..622a4610d 100644
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -426,7 +426,6 @@ int main_loop(int argc, const char **argv_) {
int frames_corrupted = 0;
int dec_flags = 0;
int do_scale = 0;
- int stream_w = 0, stream_h = 0;
vpx_image_t *scaled_img = NULL;
int frame_avail, got_data;
@@ -771,9 +770,18 @@ int main_loop(int argc, const char **argv_) {
}
if (do_scale) {
+ int stream_w = 0, stream_h = 0;
if (img && frame_out == 1) {
- stream_w = img->d_w;
- stream_h = img->d_h;
+ int display_size[2];
+ if (vpx_codec_control(&decoder, VP9D_GET_DISPLAY_SIZE,
+ display_size)) {
+ // Fallback to use raw image size if display size not available.
+ stream_w = img->d_w;
+ stream_h = img->d_h;
+ } else {
+ stream_w = display_size[0];
+ stream_h = display_size[1];
+ }
scaled_img = vpx_img_alloc(NULL, VPX_IMG_FMT_I420,
stream_w, stream_h, 16);
}
@@ -794,7 +802,6 @@ int main_loop(int argc, const char **argv_) {
img = scaled_img;
}
}
-
if (img) {
unsigned int y;
char out_fn[PATH_MAX];
@@ -857,7 +864,8 @@ int main_loop(int argc, const char **argv_) {
fail:
if (vpx_codec_destroy(&decoder)) {
- fprintf(stderr, "Failed to destroy decoder: %s\n", vpx_codec_error(&decoder));
+ fprintf(stderr, "Failed to destroy decoder: %s\n",
+ vpx_codec_error(&decoder));
return EXIT_FAILURE;
}
@@ -869,6 +877,8 @@ fail:
else
free(buf);
+ if (scaled_img) vpx_img_free(scaled_img);
+
fclose(infile);
free(argv);