Commit 1e150c77 authored by Angie Chiang's avatar Angie Chiang
Browse files

Pass AV1_COMMON into block encoding functions

Those functions include optimize_b, av1_encode_block_intra,
av1_xform_quant and av1_xform_quant_fp

This CL doesn't change any coding behavior. It is to facilitate the
following implementation of adaptive scan order experiment.

Change-Id: I0836e558b94e196a02c830a856be305afe20472b
parent dd41baba
......@@ -3068,7 +3068,8 @@ static void encode_superblock(const AV1_COMP *const cpi, ThreadData *td,
int plane;
mbmi->skip = 1;
for (plane = 0; plane < MAX_MB_PLANE; ++plane)
av1_encode_intra_block_plane(x, AOMMAX(bsize, BLOCK_8X8), plane);
av1_encode_intra_block_plane((AV1_COMMON *)cm, x,
AOMMAX(bsize, BLOCK_8X8), plane);
#if CONFIG_PALETTE
if (bsize >= BLOCK_8X8 && output_enabled) {
for (plane = 0; plane <= 1; ++plane) {
......@@ -3105,7 +3106,7 @@ static void encode_superblock(const AV1_COMP *const cpi, ThreadData *td,
av1_build_obmc_inter_predictors_sb(cm, xd, mi_row, mi_col);
#endif // CONFIG_MOTION_VAR
av1_encode_sb(x, AOMMAX(bsize, BLOCK_8X8));
av1_encode_sb((AV1_COMMON *)cm, x, AOMMAX(bsize, BLOCK_8X8));
av1_tokenize_sb(cpi, td, t, !output_enabled, AOMMAX(bsize, BLOCK_8X8));
}
......
......@@ -87,8 +87,8 @@ static int trellis_get_coeff_context(const int16_t *scan, const int16_t *nb,
return pt;
}
static int optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size,
int ctx) {
static int optimize_b(const AV1_COMMON *const 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];
......@@ -126,6 +126,7 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size,
#else
const int *cat6_high_cost = av1_get_high_cost_table(8);
#endif
(void)cm;
assert((!type && !plane) || (type && plane));
assert(eob <= default_eob);
......@@ -331,8 +332,9 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size,
// TODO(sarahparker) refactor fwd quant functions to use fwd_txfm fns in
// hybrid_fwd_txfm.c
void av1_xform_quant_fp(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size) {
void av1_xform_quant_fp(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size) {
MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &xd->plane[plane];
......@@ -351,6 +353,7 @@ void av1_xform_quant_fp(MACROBLOCK *x, int plane, int block, int blk_row,
const qm_val_t *iqmatrix = pd->seg_iqmatrix[seg_id][is_intra][tx_size];
#endif
const int16_t *src_diff;
(void)cm;
/*
FWD_TXFM_PARAM fwd_txfm_param;
......@@ -588,8 +591,9 @@ void av1_xform_quant_dc(MACROBLOCK *x, int plane, int block, int blk_row,
}
}
void av1_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size) {
void av1_xform_quant(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size) {
MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &xd->plane[plane];
......@@ -616,6 +620,8 @@ void av1_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
fwd_txfm_param.rd_transform = x->use_lp32x32fdct;
fwd_txfm_param.lossless = xd->lossless[seg_id];
(void)cm;
src_diff = &p->src_diff[4 * (blk_row * diff_stride + blk_col)];
#if CONFIG_AOM_HIGHBITDEPTH
......@@ -717,6 +723,7 @@ void av1_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
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;
const AV1_COMMON *const cm = args->cm;
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
struct optimize_ctx *const ctx = args->ctx;
......@@ -738,7 +745,7 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
*a = *l = 0;
return;
} else {
av1_xform_quant_fp(x, plane, block, blk_row, blk_col, plane_bsize,
av1_xform_quant_fp(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size);
}
} else {
......@@ -747,7 +754,7 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
(plane << 2) + (block >> (tx_size_1d_in_unit_log2[tx_size] << 1));
if (x->skip_txfm[txfm_blk_index] == SKIP_TXFM_NONE) {
// full forward transform and quantization
av1_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize,
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size);
} else if (x->skip_txfm[txfm_blk_index] == SKIP_TXFM_AC_ONLY) {
// fast path forward transform and quantization
......@@ -760,13 +767,14 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
return;
}
} 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);
}
}
if (x->optimize) {
const int combined_ctx = combine_entropy_contexts(*a, *l);
*a = *l = optimize_b(x, plane, block, tx_size, combined_ctx) > 0;
*a = *l = optimize_b(cm, x, plane, block, tx_size, combined_ctx) > 0;
} else {
*a = *l = p->eobs[block] > 0;
}
......@@ -828,10 +836,17 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
}
}
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];
......@@ -839,7 +854,7 @@ static void encode_block_pass1(int plane, int block, int blk_row, int blk_col,
uint8_t *dst;
dst = &pd->dst.buf[4 * blk_row * pd->dst.stride + 4 * blk_col];
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);
if (p->eobs[block] > 0) {
#if CONFIG_AOM_HIGHBITDEPTH
......@@ -862,17 +877,18 @@ static void encode_block_pass1(int plane, int block, int blk_row, int blk_col,
}
}
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 };
struct encode_b_args arg = { cm, x, &ctx, &mbmi->skip };
int plane;
mbmi->skip = 1;
......@@ -899,6 +915,7 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
void *arg) {
struct encode_b_args *const args = arg;
MACROBLOCK *const x = args->x;
AV1_COMMON *cm = args->cm;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
struct macroblock_plane *const p = &x->plane[plane];
......@@ -934,6 +951,8 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
fwd_txfm_param.rd_transform = x->use_lp32x32fdct;
fwd_txfm_param.lossless = xd->lossless[seg_id];
(void)cm;
dst = &pd->dst.buf[4 * (blk_row * dst_stride + blk_col)];
src = &p->src.buf[4 * (blk_row * src_stride + blk_col)];
src_diff = &p->src_diff[4 * (blk_row * diff_stride + blk_col)];
......@@ -1071,9 +1090,10 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
if (*eob) *(args->skip) = 0;
}
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) {
const MACROBLOCKD *const xd = &x->e_mbd;
struct encode_b_args arg = { x, NULL, &xd->mi[0]->mbmi.skip };
struct encode_b_args arg = { cm, x, NULL, &xd->mi[0]->mbmi.skip };
av1_foreach_transformed_block_in_plane(xd, bsize, plane,
av1_encode_block_intra, &arg);
......
......@@ -13,6 +13,7 @@
#define AV1_ENCODER_ENCODEMB_H_
#include "./aom_config.h"
#include "av1/common/onyxc_int.h"
#include "av1/encoder/block.h"
#ifdef __cplusplus
......@@ -20,25 +21,29 @@ extern "C" {
#endif
struct encode_b_args {
AV1_COMMON *cm;
MACROBLOCK *x;
struct optimize_ctx *ctx;
int8_t *skip;
};
void av1_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize);
void av1_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize);
void av1_xform_quant_fp(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size);
void av1_encode_sb(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize);
void av1_encode_sby_pass1(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize);
void av1_xform_quant_fp(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size);
void av1_xform_quant_dc(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size);
void av1_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row,
int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size);
void av1_xform_quant(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size);
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);
#ifdef __cplusplus
} // extern "C"
......
......@@ -577,7 +577,7 @@ void av1_first_pass(AV1_COMP *cpi, const struct lookahead_entry *source) {
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);
av1_encode_intra_block_plane(cm, x, bsize, 0);
this_error = aom_get_mb_ss(x->plane[0].src_diff);
// Keep a record of blocks that have almost no intra error residual
......@@ -798,7 +798,7 @@ void av1_first_pass(AV1_COMP *cpi, const struct lookahead_entry *source) {
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;
......
......@@ -513,6 +513,7 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const AV1_COMMON *const cm = args->cm;
int64_t rd1, rd2, rd;
int rate;
int64_t dist;
......@@ -521,7 +522,7 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
if (args->exit_early) return;
if (!is_inter_block(mbmi)) {
struct encode_b_args b_args = { x, NULL, &mbmi->skip };
struct encode_b_args b_args = { (AV1_COMMON *)cm, x, NULL, &mbmi->skip };
av1_encode_block_intra(plane, block, blk_row, blk_col, plane_bsize, tx_size,
&b_args);
dist_block(x, plane, block, tx_size, &dist, &sse);
......@@ -530,7 +531,8 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
(block >> (tx_size_1d_in_unit_log2[tx_size] * 2))] ==
SKIP_TXFM_NONE) {
// full forward transform and quantization
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);
dist_block(x, plane, block, tx_size, &dist, &sse);
} else if (x->skip_txfm[(plane << 2) +
(block >> (tx_size_1d_in_unit_log2[tx_size] *
......@@ -566,7 +568,8 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
}
} else {
// full forward transform and quantization
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);
dist_block(x, plane, block, tx_size, &dist, &sse);
}
......@@ -4699,7 +4702,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
}
#endif // CONFIG_EXT_INTRA
distortion2 = distortion_y + distortion_uv;
av1_encode_intra_block_plane(x, bsize, 0);
av1_encode_intra_block_plane((AV1_COMMON *)cm, x, bsize, 0);
} else {
#if CONFIG_REF_MV
int_mv backup_ref_mv[2];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment