Merge "Update uv_mode_cdf tables once per frame." into nextgenv2
diff --git a/av1/common/common_data.h b/av1/common/common_data.h
index 4165e35..f068ee7 100644
--- a/av1/common/common_data.h
+++ b/av1/common/common_data.h
@@ -444,7 +444,12 @@
static const int tx_size_1d[TX_SIZES] = { 4, 8, 16, 32 };
-static const int tx_size_2d[TX_SIZES] = { 16, 64, 256, 1024 };
+static const int tx_size_2d[TX_SIZES_ALL] = {
+ 16, 64, 256, 1024,
+#if CONFIG_EXT_TX
+ 32, 32, 128, 128, 512, 512,
+#endif
+};
static const uint8_t tx_size_1d_log2[TX_SIZES] = { 2, 3, 4, 5 };
diff --git a/av1/common/scan.h b/av1/common/scan.h
index 7b6698f..407c9ec 100644
--- a/av1/common/scan.h
+++ b/av1/common/scan.h
@@ -80,8 +80,9 @@
}
#endif // CONFIG_EXT_TX
-static INLINE const SCAN_ORDER *get_scan(TX_SIZE tx_size, TX_TYPE tx_type,
- int is_inter) {
+static INLINE const SCAN_ORDER *get_scan(const AV1_COMMON *cm, TX_SIZE tx_size,
+ TX_TYPE tx_type, int is_inter) {
+ (void)cm;
#if CONFIG_EXT_TX
return is_inter ? &av1_inter_scan_orders[tx_size][tx_type]
: &av1_intra_scan_orders[tx_size][tx_type];
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index f6b9d64..44921ee 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -253,26 +253,17 @@
}
#endif // CONFIG_AOM_HIGHBITDEPTH
- if (eob == 1) {
+ // TODO(jingning): This cleans up different reset requests from various
+ // experiments, but incurs unnecessary memset size.
+ if (eob == 1)
dqcoeff[0] = 0;
- } else {
- if (tx_type == DCT_DCT && tx_size <= TX_16X16 && eob <= 10)
- memset(dqcoeff, 0, 4 * 4 * num_4x4_blocks_wide_txsize_lookup[tx_size] *
- sizeof(dqcoeff[0]));
-#if CONFIG_EXT_TX
- else
- memset(dqcoeff, 0, get_tx2d_size(tx_size) * sizeof(dqcoeff[0]));
-#else
- else if (tx_size == TX_32X32 && eob <= 34)
- memset(dqcoeff, 0, 256 * sizeof(dqcoeff[0]));
- else
- memset(dqcoeff, 0, get_tx2d_size(tx_size) * sizeof(dqcoeff[0]));
-#endif
- }
+ else
+ memset(dqcoeff, 0, tx_size_2d[tx_size] * sizeof(dqcoeff[0]));
}
}
-static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
+static void predict_and_reconstruct_intra_block(AV1_COMMON *cm,
+ MACROBLOCKD *const xd,
#if CONFIG_ANS
struct AnsDecoder *const r,
#else
@@ -296,7 +287,7 @@
if (!mbmi->skip) {
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
- const SCAN_ORDER *scan_order = get_scan(tx_size, tx_type, 0);
+ const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 0);
const int eob = av1_decode_block_tokens(
xd, plane, scan_order, col, row, tx_size, tx_type, r, mbmi->segment_id);
inverse_transform_block(xd, plane, tx_type, tx_size, dst, pd->dst.stride,
@@ -305,9 +296,9 @@
}
#if CONFIG_VAR_TX
-static void decode_reconstruct_tx(MACROBLOCKD *const xd, aom_reader *r,
- MB_MODE_INFO *const mbmi, int plane,
- BLOCK_SIZE plane_bsize, int block,
+static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
+ aom_reader *r, MB_MODE_INFO *const mbmi,
+ int plane, BLOCK_SIZE plane_bsize, int block,
int blk_row, int blk_col, TX_SIZE tx_size,
int *eob_total) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
@@ -330,7 +321,7 @@
if (tx_size == plane_tx_size) {
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, plane_tx_size);
- const SCAN_ORDER *sc = get_scan(plane_tx_size, tx_type, 1);
+ const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, 1);
const int eob =
av1_decode_block_tokens(xd, plane, sc, blk_col, blk_row, plane_tx_size,
tx_type, r, mbmi->segment_id);
@@ -353,15 +344,16 @@
if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) continue;
- decode_reconstruct_tx(xd, r, mbmi, plane, plane_bsize, block + i * step,
- offsetr, offsetc, tx_size - 1, eob_total);
+ decode_reconstruct_tx(cm, xd, r, mbmi, plane, plane_bsize,
+ block + i * step, offsetr, offsetc, tx_size - 1,
+ eob_total);
}
}
}
#endif // CONFIG_VAR_TX
#if !CONFIG_VAR_TX || CONFIG_SUPERTX || (CONFIG_EXT_TX && CONFIG_RECT_TX)
-static int reconstruct_inter_block(MACROBLOCKD *const xd,
+static int reconstruct_inter_block(AV1_COMMON *cm, MACROBLOCKD *const xd,
#if CONFIG_ANS
struct AnsDecoder *const r,
#else
@@ -373,7 +365,7 @@
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
int block_idx = (row << 1) + col;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
- const SCAN_ORDER *scan_order = get_scan(tx_size, tx_type, 1);
+ const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 1);
const int eob = av1_decode_block_tokens(xd, plane, scan_order, col, row,
tx_size, tx_type, r, segment_id);
@@ -1247,7 +1239,7 @@
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
- predict_and_reconstruct_intra_block(xd, r, mbmi, plane, row, col,
+ predict_and_reconstruct_intra_block(cm, xd, r, mbmi, plane, row, col,
tx_size);
}
} else {
@@ -1337,14 +1329,14 @@
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
- eobtotal += reconstruct_inter_block(xd, r, mbmi->segment_id,
+ eobtotal += reconstruct_inter_block(cm, xd, r, mbmi->segment_id,
plane, row, col, tx_size);
} else {
#endif
for (row = 0; row < num_4x4_h; row += bh_var_tx) {
for (col = 0; col < num_4x4_w; col += bw_var_tx) {
- decode_reconstruct_tx(xd, r, mbmi, plane, plane_bsize, block, row,
- col, max_tx_size, &eobtotal);
+ decode_reconstruct_tx(cm, xd, r, mbmi, plane, plane_bsize, block,
+ row, col, max_tx_size, &eobtotal);
block += step;
}
}
@@ -1367,8 +1359,8 @@
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
- eobtotal += reconstruct_inter_block(xd, r, mbmi->segment_id, plane,
- row, col, tx_size);
+ eobtotal += reconstruct_inter_block(cm, xd, r, mbmi->segment_id,
+ plane, row, col, tx_size);
#endif
}
}
@@ -1764,8 +1756,8 @@
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
- eobtotal += reconstruct_inter_block(xd, r, mbmi->segment_id_supertx,
- i, row, col, tx_size);
+ eobtotal += reconstruct_inter_block(
+ cm, xd, r, mbmi->segment_id_supertx, i, row, col, tx_size);
}
if (!(subsize < BLOCK_8X8) && eobtotal == 0) skip = 1;
}
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index d3b97d6..9dc6a2e 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -2213,7 +2213,7 @@
int this_rate = 0;
x->use_lp32x32fdct = cpi->sf.use_lp32x32fdct;
- av1_encode_sb_supertx(x, bsize);
+ av1_encode_sb_supertx((AV1_COMMON *)cm, x, bsize);
av1_tokenize_sb_supertx(cpi, td, tp, dry_run, bsize, rate);
if (rate) *rate += this_rate;
} else {
@@ -4489,6 +4489,10 @@
#define MIN_TRANS_THRESH 8
#define GLOBAL_MOTION_ADVANTAGE_THRESH 0.60
#define GLOBAL_MOTION_MODEL ROTZOOM
+// TODO(sarahparker) This function needs to be adjusted
+// to accomodate changes in the paraemter integerization.
+// Commenting it out until the fix is made.
+/*
static void refine_integerized_param(WarpedMotionParams *wm,
#if CONFIG_AOM_HIGHBITDEPTH
int use_hbd, int bd,
@@ -4565,6 +4569,7 @@
*param = best_param;
}
}
+*/
static void convert_to_params(const double *params, TransformationType type,
int16_t *model) {
@@ -4579,7 +4584,7 @@
GM_TRANS_DECODE_FACTOR;
for (i = 2; i < n_params; ++i) {
- diag_value = ((i && 1) ? (1 << GM_ALPHA_PREC_BITS) : 0);
+ diag_value = ((i & 1) ? (1 << GM_ALPHA_PREC_BITS) : 0);
model[i] = (int16_t)floor(params[i] * (1 << GM_ALPHA_PREC_BITS) + 0.5);
model[i] =
(int16_t)(clamp(model[i] - diag_value, GM_ALPHA_MIN, GM_ALPHA_MAX) +
@@ -4643,14 +4648,6 @@
convert_model_to_params(params, GLOBAL_MOTION_MODEL,
&cm->global_motion[frame]);
if (get_gmtype(&cm->global_motion[frame]) > GLOBAL_ZERO) {
- refine_integerized_param(
- &cm->global_motion[frame].motion_params,
-#if CONFIG_AOM_HIGHBITDEPTH
- xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
-#endif // CONFIG_AOM_HIGHBITDEPTH
- ref_buf->y_buffer, ref_buf->y_width, ref_buf->y_height,
- ref_buf->y_stride, cpi->Source->y_buffer, cpi->Source->y_width,
- cpi->Source->y_height, cpi->Source->y_stride, 3);
// compute the advantage of using gm parameters over 0 motion
erroradvantage = av1_warp_erroradv(
&cm->global_motion[frame].motion_params,
@@ -5107,7 +5104,8 @@
int plane;
mbmi->skip = 1;
for (plane = 0; plane < MAX_MB_PLANE; ++plane)
- av1_encode_intra_block_plane(x, AOMMAX(bsize, BLOCK_8X8), plane, 1);
+ av1_encode_intra_block_plane((AV1_COMMON *)cm, x,
+ AOMMAX(bsize, BLOCK_8X8), plane, 1);
if (!dry_run)
sum_intra_stats(td->counts, mi, xd->above_mi, xd->left_mi,
frame_is_intra_only(cm));
@@ -5229,7 +5227,7 @@
}
#endif // CONFIG_MOTION_VAR
- av1_encode_sb(x, AOMMAX(bsize, BLOCK_8X8));
+ av1_encode_sb((AV1_COMMON *)cm, x, AOMMAX(bsize, BLOCK_8X8));
#if CONFIG_VAR_TX
#if CONFIG_EXT_TX && CONFIG_RECT_TX
if (is_rect_tx(mbmi->tx_size))
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c
index 4ab1b48..8914ba5 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -67,8 +67,8 @@
rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1); \
}
-int av1_optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size,
- int ctx) {
+int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int block,
+ TX_SIZE tx_size, int ctx) {
MACROBLOCKD *const xd = &mb->e_mbd;
struct macroblock_plane *const p = &mb->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
@@ -86,7 +86,7 @@
const uint8_t *const band_translate = get_band_translate(tx_size);
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
- get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
+ get_scan(cm, tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
const int16_t *const scan = scan_order->scan;
const int16_t *const nb = scan_order->neighbors;
#if CONFIG_AOM_QM
@@ -432,16 +432,16 @@
FWD_TXFM_OPT_NORMAL, FWD_TXFM_OPT_NORMAL, FWD_TXFM_OPT_DC, FWD_TXFM_OPT_NORMAL
};
-void av1_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
- int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
- AV1_XFORM_QUANT xform_quant_idx) {
+void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
+ int blk_row, int blk_col, BLOCK_SIZE plane_bsize,
+ TX_SIZE tx_size, AV1_XFORM_QUANT xform_quant_idx) {
MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &xd->plane[plane];
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const int is_inter = is_inter_block(&xd->mi[0]->mbmi);
- const SCAN_ORDER *const scan_order = get_scan(tx_size, tx_type, is_inter);
+ const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, is_inter);
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
@@ -505,16 +505,16 @@
}
#if CONFIG_NEW_QUANT
-void av1_xform_quant_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
- int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
- int ctx) {
+void av1_xform_quant_nuq(const AV1_COMMON *cm, MACROBLOCK *x, int plane,
+ int block, int blk_row, int blk_col,
+ BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int ctx) {
MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &xd->plane[plane];
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const int is_inter = is_inter_block(&xd->mi[0]->mbmi);
- const SCAN_ORDER *const scan_order = get_scan(tx_size, tx_type, is_inter);
+ const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, is_inter);
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
@@ -578,16 +578,16 @@
}
}
-void av1_xform_quant_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
- int blk_col, BLOCK_SIZE plane_bsize,
- TX_SIZE tx_size, int ctx) {
+void av1_xform_quant_fp_nuq(const AV1_COMMON *cm, MACROBLOCK *x, int plane,
+ int block, int blk_row, int blk_col,
+ BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int ctx) {
MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &xd->plane[plane];
const int is_inter = is_inter_block(&xd->mi[0]->mbmi);
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
- const SCAN_ORDER *const scan_order = get_scan(tx_size, tx_type, is_inter);
+ const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, is_inter);
int dq = get_dq_profile_from_ctx(xd->qindex[xd->mi[0]->mbmi.segment_id], ctx,
is_inter, plane_type);
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
@@ -784,6 +784,7 @@
static void encode_block(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
struct encode_b_args *const args = arg;
+ AV1_COMMON *cm = args->cm;
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
int ctx;
@@ -815,10 +816,10 @@
{
#endif
#if CONFIG_NEW_QUANT
- av1_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, plane_bsize,
+ av1_xform_quant_fp_nuq(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, ctx);
#else
- av1_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
+ av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT
}
@@ -829,7 +830,7 @@
#endif
if (p->eobs[block]) {
- *a = *l = av1_optimize_b(x, plane, block, tx_size, ctx) > 0;
+ *a = *l = av1_optimize_b(cm, x, plane, block, tx_size, ctx) > 0;
} else {
*a = *l = p->eobs[block] > 0;
}
@@ -918,10 +919,17 @@
}
#endif
+typedef struct encode_block_pass1_args {
+ AV1_COMMON *cm;
+ MACROBLOCK *x;
+} encode_block_pass1_args;
+
static void encode_block_pass1(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
void *arg) {
- MACROBLOCK *const x = (MACROBLOCK *)arg;
+ encode_block_pass1_args *args = (encode_block_pass1_args *)arg;
+ AV1_COMMON *cm = args->cm;
+ MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
@@ -934,10 +942,10 @@
#if CONFIG_NEW_QUANT
ctx = 0;
- av1_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, plane_bsize,
+ av1_xform_quant_fp_nuq(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, ctx);
#else
- av1_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
+ av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_B);
#endif // CONFIG_NEW_QUANT
@@ -962,17 +970,18 @@
}
}
-void av1_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize) {
+void av1_encode_sby_pass1(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize) {
+ encode_block_pass1_args args = { cm, x };
av1_subtract_plane(x, bsize, 0);
av1_foreach_transformed_block_in_plane(&x->e_mbd, bsize, 0,
- encode_block_pass1, x);
+ encode_block_pass1, &args);
}
-void av1_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) {
+void av1_encode_sb(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize) {
MACROBLOCKD *const xd = &x->e_mbd;
struct optimize_ctx ctx;
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
- struct encode_b_args arg = { x, &ctx, &mbmi->skip, NULL, NULL, 1 };
+ struct encode_b_args arg = { cm, x, &ctx, &mbmi->skip, NULL, NULL, 1 };
int plane;
mbmi->skip = 1;
@@ -1027,11 +1036,11 @@
}
#if CONFIG_SUPERTX
-void av1_encode_sb_supertx(MACROBLOCK *x, BLOCK_SIZE bsize) {
+void av1_encode_sb_supertx(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize) {
MACROBLOCKD *const xd = &x->e_mbd;
struct optimize_ctx ctx;
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
- struct encode_b_args arg = { x, &ctx, &mbmi->skip, NULL, NULL, 1 };
+ struct encode_b_args arg = { cm, x, &ctx, &mbmi->skip, NULL, NULL, 1 };
int plane;
mbmi->skip = 1;
@@ -1058,6 +1067,7 @@
BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
void *arg) {
struct encode_b_args *const args = arg;
+ AV1_COMMON *cm = args->cm;
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
@@ -1110,19 +1120,19 @@
if (args->enable_optimize_b) {
#if CONFIG_NEW_QUANT
- av1_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, plane_bsize,
+ av1_xform_quant_fp_nuq(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, ctx);
#else // CONFIG_NEW_QUANT
- av1_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
+ av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT
if (p->eobs[block]) {
- *a = *l = av1_optimize_b(x, plane, block, tx_size, ctx) > 0;
+ *a = *l = av1_optimize_b(cm, x, plane, block, tx_size, ctx) > 0;
} else {
*a = *l = 0;
}
} else {
- av1_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
+ av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_B);
*a = *l = p->eobs[block] > 0;
}
@@ -1148,14 +1158,16 @@
}
}
-void av1_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane,
+void av1_encode_intra_block_plane(AV1_COMMON *cm, MACROBLOCK *x,
+ BLOCK_SIZE bsize, int plane,
int enable_optimize_b) {
const MACROBLOCKD *const xd = &x->e_mbd;
ENTROPY_CONTEXT ta[2 * MAX_MIB_SIZE];
ENTROPY_CONTEXT tl[2 * MAX_MIB_SIZE];
- struct encode_b_args arg = { x, NULL, &xd->mi[0]->mbmi.skip,
- ta, tl, enable_optimize_b };
+ struct encode_b_args arg = {
+ cm, x, NULL, &xd->mi[0]->mbmi.skip, ta, tl, enable_optimize_b
+ };
if (enable_optimize_b) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const TX_SIZE tx_size =
diff --git a/av1/encoder/encodemb.h b/av1/encoder/encodemb.h
index ac10f94..e9b6bc8 100644
--- a/av1/encoder/encodemb.h
+++ b/av1/encoder/encodemb.h
@@ -25,6 +25,7 @@
};
struct encode_b_args {
+ AV1_COMMON *cm;
MACROBLOCK *x;
struct optimize_ctx *ctx;
int8_t *skip;
@@ -41,38 +42,39 @@
AV1_XFORM_QUANT_LAST = 4
} AV1_XFORM_QUANT;
-void av1_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize);
+void av1_encode_sb(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize);
#if CONFIG_SUPERTX
-void av1_encode_sb_supertx(MACROBLOCK *x, BLOCK_SIZE bsize);
+void av1_encode_sb_supertx(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize);
#endif // CONFIG_SUPERTX
-void av1_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize);
-void av1_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
- int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
- AV1_XFORM_QUANT xform_quant_idx);
+void av1_encode_sby_pass1(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize);
+void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
+ int blk_row, int blk_col, BLOCK_SIZE plane_bsize,
+ TX_SIZE tx_size, AV1_XFORM_QUANT xform_quant_idx);
#if CONFIG_NEW_QUANT
-void av1_xform_quant_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
- int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
- int ctx);
+void av1_xform_quant_nuq(const AV1_COMMON *cm, MACROBLOCK *x, int plane,
+ int block, int blk_row, int blk_col,
+ BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int ctx);
void av1_xform_quant_dc_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, int ctx);
-void av1_xform_quant_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
- int blk_col, BLOCK_SIZE plane_bsize,
- TX_SIZE tx_size, int ctx);
+void av1_xform_quant_fp_nuq(const AV1_COMMON *cm, MACROBLOCK *x, int plane,
+ int block, int blk_row, int blk_col,
+ BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int ctx);
void av1_xform_quant_dc_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, int ctx);
#endif
-int av1_optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size,
- int ctx);
+int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int block,
+ TX_SIZE tx_size, int ctx);
void av1_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane);
void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg);
-void av1_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane,
+void av1_encode_intra_block_plane(AV1_COMMON *cm, MACROBLOCK *x,
+ BLOCK_SIZE bsize, int plane,
int enable_optimize_b);
#ifdef __cplusplus
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index 1e10531..466cb9c 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -590,7 +590,7 @@
xd->mi[0]->mbmi.mode = DC_PRED;
xd->mi[0]->mbmi.tx_size =
use_dc_pred ? (bsize >= BLOCK_16X16 ? TX_16X16 : TX_8X8) : TX_4X4;
- av1_encode_intra_block_plane(x, bsize, 0, 0);
+ av1_encode_intra_block_plane(cm, x, bsize, 0, 0);
this_error = aom_get_mb_ss(x->plane[0].src_diff);
// Keep a record of blocks that have almost no intra error residual
@@ -811,7 +811,7 @@
xd->mi[0]->mbmi.ref_frame[0] = LAST_FRAME;
xd->mi[0]->mbmi.ref_frame[1] = NONE;
av1_build_inter_predictors_sby(xd, mb_row << 1, mb_col << 1, bsize);
- av1_encode_sby_pass1(x, bsize);
+ av1_encode_sby_pass1(cm, x, bsize);
sum_mvr += mv.row;
sum_mvr_abs += abs(mv.row);
sum_mvc += mv.col;
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 8ba6b7b..627352b 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1122,6 +1122,7 @@
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+ const AV1_COMMON *cm = &args->cpi->common;
int64_t rd1, rd2, rd;
int rate;
int64_t dist;
@@ -1134,7 +1135,7 @@
if (!is_inter_block(mbmi)) {
struct encode_b_args b_args = {
- x, NULL, &mbmi->skip, args->t_above, args->t_left, 1
+ (AV1_COMMON *)cm, x, NULL, &mbmi->skip, args->t_above, args->t_left, 1
};
av1_encode_block_intra(plane, block, blk_row, blk_col, plane_bsize, tx_size,
&b_args);
@@ -1174,14 +1175,14 @@
} else {
// full forward transform and quantization
#if CONFIG_NEW_QUANT
- av1_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, plane_bsize,
+ av1_xform_quant_fp_nuq(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, coeff_ctx);
#else
- av1_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
+ av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT
if (x->plane[plane].eobs[block])
- av1_optimize_b(x, plane, block, tx_size, coeff_ctx);
+ av1_optimize_b(cm, x, plane, block, tx_size, coeff_ctx);
dist_block(args->cpi, x, plane, block, blk_row, blk_col, tx_size, &dist,
&sse);
}
@@ -1219,6 +1220,7 @@
int64_t *distortion, int *skippable, int64_t *sse,
int64_t ref_best_rd, int plane, BLOCK_SIZE bsize,
TX_SIZE tx_size, int use_fast_coef_casting) {
+ const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblockd_plane *const pd = &xd->plane[plane];
TX_TYPE tx_type;
@@ -1236,7 +1238,7 @@
tx_type = get_tx_type(pd->plane_type, xd, 0, tx_size);
args.scan_order =
- get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
+ get_scan(cm, tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
av1_foreach_transformed_block_in_plane(xd, bsize, plane, block_rd_txfm,
&args);
@@ -1259,6 +1261,7 @@
int64_t *sse, int64_t ref_best_rd, int plane,
BLOCK_SIZE bsize, TX_SIZE tx_size,
int use_fast_coef_casting) {
+ const AV1_COMMON *cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblockd_plane *const pd = &xd->plane[plane];
struct rdcost_block_args args;
@@ -1280,7 +1283,7 @@
tx_type = get_tx_type(pd->plane_type, xd, 0, tx_size);
args.scan_order =
- get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
+ get_scan(cm, tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
block_rd_txfm(plane, 0, 0, 0, get_plane_block_size(bsize, pd), tx_size,
&args);
@@ -1947,14 +1950,14 @@
dst_stride, xd->bd);
if (xd->lossless[xd->mi[0]->mbmi.segment_id]) {
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4);
- const SCAN_ORDER *scan_order = get_scan(TX_4X4, tx_type, 0);
+ const SCAN_ORDER *scan_order = get_scan(cm, TX_4X4, tx_type, 0);
const int coeff_ctx =
combine_entropy_contexts(*(tempa + idx), *(templ + idy));
#if CONFIG_NEW_QUANT
- av1_xform_quant_fp_nuq(x, 0, block, row + idy, col + idx, BLOCK_8X8,
- TX_4X4, coeff_ctx);
+ av1_xform_quant_fp_nuq(cm, x, 0, block, row + idy, col + idx,
+ BLOCK_8X8, TX_4X4, coeff_ctx);
#else
- av1_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8,
+ av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
TX_4X4, AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT
ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, TX_4X4,
@@ -1972,17 +1975,17 @@
int64_t dist;
unsigned int tmp;
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4);
- const SCAN_ORDER *scan_order = get_scan(TX_4X4, tx_type, 0);
+ const SCAN_ORDER *scan_order = get_scan(cm, TX_4X4, tx_type, 0);
const int coeff_ctx =
combine_entropy_contexts(*(tempa + idx), *(templ + idy));
#if CONFIG_NEW_QUANT
- av1_xform_quant_fp_nuq(x, 0, block, row + idy, col + idx, BLOCK_8X8,
- TX_4X4, coeff_ctx);
+ av1_xform_quant_fp_nuq(cm, x, 0, block, row + idy, col + idx,
+ BLOCK_8X8, TX_4X4, coeff_ctx);
#else
- av1_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8,
+ av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
TX_4X4, AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT
- av1_optimize_b(x, 0, block, TX_4X4, coeff_ctx);
+ av1_optimize_b(cm, x, 0, block, TX_4X4, coeff_ctx);
ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, TX_4X4,
scan_order->scan, scan_order->neighbors,
cpi->sf.use_fast_coef_costing);
@@ -2067,15 +2070,15 @@
if (xd->lossless[xd->mi[0]->mbmi.segment_id]) {
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4);
- const SCAN_ORDER *scan_order = get_scan(TX_4X4, tx_type, 0);
+ const SCAN_ORDER *scan_order = get_scan(cm, TX_4X4, tx_type, 0);
const int coeff_ctx =
combine_entropy_contexts(*(tempa + idx), *(templ + idy));
#if CONFIG_NEW_QUANT
- av1_xform_quant_fp_nuq(x, 0, block, row + idy, col + idx, BLOCK_8X8,
- TX_4X4, coeff_ctx);
+ av1_xform_quant_fp_nuq(cm, x, 0, block, row + idy, col + idx,
+ BLOCK_8X8, TX_4X4, coeff_ctx);
#else
- av1_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8, TX_4X4,
- AV1_XFORM_QUANT_B);
+ av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
+ TX_4X4, AV1_XFORM_QUANT_B);
#endif // CONFIG_NEW_QUANT
ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, TX_4X4,
scan_order->scan, scan_order->neighbors,
@@ -2091,17 +2094,17 @@
int64_t dist;
unsigned int tmp;
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4);
- const SCAN_ORDER *scan_order = get_scan(TX_4X4, tx_type, 0);
+ const SCAN_ORDER *scan_order = get_scan(cm, TX_4X4, tx_type, 0);
const int coeff_ctx =
combine_entropy_contexts(*(tempa + idx), *(templ + idy));
#if CONFIG_NEW_QUANT
- av1_xform_quant_fp_nuq(x, 0, block, row + idy, col + idx, BLOCK_8X8,
- TX_4X4, coeff_ctx);
+ av1_xform_quant_fp_nuq(cm, x, 0, block, row + idy, col + idx,
+ BLOCK_8X8, TX_4X4, coeff_ctx);
#else
- av1_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8, TX_4X4,
- AV1_XFORM_QUANT_FP);
+ av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
+ TX_4X4, AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT
- av1_optimize_b(x, 0, block, TX_4X4, coeff_ctx);
+ av1_optimize_b(cm, x, 0, block, TX_4X4, coeff_ctx);
ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, TX_4X4,
scan_order->scan, scan_order->neighbors,
cpi->sf.use_fast_coef_costing);
@@ -2894,7 +2897,7 @@
PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
- get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
+ get_scan(cm, tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));
BLOCK_SIZE txm_bsize = txsize_to_bsize[tx_size];
int bh = 4 * num_4x4_blocks_wide_lookup[txm_bsize];
@@ -2923,14 +2926,14 @@
max_blocks_wide += xd->mb_to_right_edge >> (5 + pd->subsampling_x);
#if CONFIG_NEW_QUANT
- av1_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, plane_bsize,
+ av1_xform_quant_fp_nuq(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, coeff_ctx);
#else
- av1_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
+ av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT
- av1_optimize_b(x, plane, block, tx_size, coeff_ctx);
+ av1_optimize_b(cm, x, plane, block, tx_size, coeff_ctx);
// TODO(any): Use dist_block to compute distortion
#if CONFIG_AOM_HIGHBITDEPTH
@@ -4361,7 +4364,7 @@
TX_SIZE tx_size = mi->mbmi.tx_size;
TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, i, tx_size);
- const SCAN_ORDER *scan_order = get_scan(tx_size, tx_type, 1);
+ const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, 1);
const int num_4x4_w = num_4x4_blocks_wide_txsize_lookup[tx_size];
const int num_4x4_h = num_4x4_blocks_high_txsize_lookup[tx_size];
@@ -4409,14 +4412,14 @@
coeff_ctx = combine_entropy_contexts(*(ta + (k & 1)), *(tl + (k >> 1)));
#endif
#if CONFIG_NEW_QUANT
- av1_xform_quant_fp_nuq(x, 0, block, idy + (i >> 1), idx + (i & 0x01),
+ av1_xform_quant_fp_nuq(cm, x, 0, block, idy + (i >> 1), idx + (i & 0x01),
BLOCK_8X8, tx_size, coeff_ctx);
#else
- av1_xform_quant(x, 0, block, idy + (i >> 1), idx + (i & 0x01), BLOCK_8X8,
- tx_size, AV1_XFORM_QUANT_FP);
+ av1_xform_quant(cm, x, 0, block, idy + (i >> 1), idx + (i & 0x01),
+ BLOCK_8X8, tx_size, AV1_XFORM_QUANT_FP);
#endif // CONFIG_NEW_QUANT
if (xd->lossless[xd->mi[0]->mbmi.segment_id] == 0)
- av1_optimize_b(x, 0, block, tx_size, coeff_ctx);
+ av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx);
dist_block(cpi, x, 0, block, idy + (i >> 1), idx + (i & 0x1), tx_size,
&dist, &ssz);
thisdistortion += dist;
@@ -8069,7 +8072,7 @@
mbmi->filter_intra_mode_info.filter_intra_mode[1]);
}
distortion2 = distortion_y + distortion_uv;
- av1_encode_intra_block_plane(x, bsize, 0, 0);
+ av1_encode_intra_block_plane((AV1_COMMON *)cm, x, bsize, 0, 0);
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
x->recon_variance = av1_high_get_sby_perpixel_variance(
@@ -8846,7 +8849,7 @@
if (this_mode != DC_PRED && this_mode != TM_PRED)
rate2 += intra_cost_penalty;
distortion2 = distortion_y + distortion_uv;
- av1_encode_intra_block_plane(x, bsize, 0, 1);
+ av1_encode_intra_block_plane((AV1_COMMON *)cm, x, bsize, 0, 1);
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
x->recon_variance = av1_high_get_sby_perpixel_variance(
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index 67f4b5d..7707e8f 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -363,7 +363,7 @@
const PLANE_TYPE type = pd->plane_type;
const int ref = is_inter_block(mbmi);
const TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size);
- const SCAN_ORDER *const scan_order = get_scan(tx_size, tx_type, ref);
+ const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, ref);
int pt = get_entropy_context(tx_size, pd->above_context + blk_col,
pd->left_context + blk_row);
int rate = av1_cost_coeffs(cm, x, plane, block, pt, tx_size, scan_order->scan,
@@ -453,6 +453,7 @@
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
struct tokenize_b_args *const args = arg;
const AV1_COMP *cpi = args->cpi;
+ const AV1_COMMON *const cm = &cpi->common;
ThreadData *const td = args->td;
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
@@ -475,7 +476,7 @@
const int16_t *scan, *nb;
const TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
- get_scan(tx_size, tx_type, is_inter_block(mbmi));
+ get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
const int ref = is_inter_block(mbmi);
unsigned int(*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
td->rd_counts.coef_counts[txsize_sqr_map[tx_size]][type][ref];
diff --git a/test/av1_inv_txfm_test.cc b/test/av1_inv_txfm_test.cc
index f637d51..ff358b6 100644
--- a/test/av1_inv_txfm_test.cc
+++ b/test/av1_inv_txfm_test.cc
@@ -184,8 +184,9 @@
// quantization with maximum allowed step sizes
test_coef_block1[0] = (output_ref_block[0] / 1336) * 1336;
for (int j = 1; j < last_nonzero_; ++j)
- test_coef_block1[get_scan(tx_size_, DCT_DCT, 0)->scan[j]] =
- (output_ref_block[j] / 1828) * 1828;
+ test_coef_block1[get_scan((const AV1_COMMON *)NULL, tx_size_, DCT_DCT,
+ 0)
+ ->scan[j]] = (output_ref_block[j] / 1828) * 1828;
}
ASM_REGISTER_STATE_CHECK(full_itxfm_(test_coef_block1, dst1, size));
@@ -235,7 +236,8 @@
max_energy_leftover = 0;
coef = 0;
}
- test_coef_block1[get_scan(tx_size_, DCT_DCT, 0)->scan[j]] = coef;
+ test_coef_block1[get_scan((const AV1_COMMON *)NULL, tx_size_, DCT_DCT, 0)
+ ->scan[j]] = coef;
}
memcpy(test_coef_block2, test_coef_block1,