Commit 125c0fca authored by Monty Montgomery's avatar Monty Montgomery Committed by Christopher Montgomery

Separate quantizers used for quantization from RDO

Generalize quantizer setup so that quantization and TX can use
different coefficient shifts/scalings without inpacting RDO lambda
generation.

This patch is documentaiton + a minor refactor setting up later
work; it causes no functional change.

monty-daalaTX-fulltest-Daalabaseline-o1f@2017-11-07T00:01:20.779Z ->
 monty-daalaTX-fulltest-DaalaRDO-o1f@2017-11-07T00:02:31.347Z

PSNR | PSNR Cb | PSNR Cr | PSNR HVS | SSIM | MS SSIM | CIEDE 2000
 N/A |  0.0000 |  0.0000 |      N/A |  N/A |     N/A |        N/A
(note-- the numbers above were collected using --cpu-used=3, which
 appears to be newly broken.)

monty-daalaTX-fulltest-Daalabaseline-o1f4@2017-11-07T05:59:16.553Z ->
 monty-daalaTX-fulltest-DaalaRDO-o1f4@2017-11-07T05:59:50.180Z

  PSNR | PSNR Cb | PSNR Cr | PSNR HVS |   SSIM | MS SSIM | CIEDE 2000
0.0000 |  0.0000 |  0.0000 |   0.0000 | 0.0000 |  0.0000 |     0.0000

monty-daalaTX-fulltest-Daalabaseline-s1@2017-11-07T00:01:46.582Z ->
 monty-daalaTX-fulltest-DaalaRDO-s1@2017-11-07T00:02:56.282Z

  PSNR | PSNR Cb | PSNR Cr | PSNR HVS |   SSIM | MS SSIM | CIEDE 2000
0.0000 |  0.0000 |  0.0000 |   0.0000 | 0.0000 |  0.0000 |     0.0000

Change-Id: Ia5a3c052eacd17184ca1b0fe6d032cfb9afdb77f
parent 848f7bc7
...@@ -521,10 +521,14 @@ typedef struct macroblockd_plane { ...@@ -521,10 +521,14 @@ typedef struct macroblockd_plane {
struct buf_2d pre[2]; struct buf_2d pre[2];
ENTROPY_CONTEXT *above_context; ENTROPY_CONTEXT *above_context;
ENTROPY_CONTEXT *left_context; ENTROPY_CONTEXT *left_context;
int16_t seg_dequant[MAX_SEGMENTS][2];
// The dequantizers below are true dequntizers used only in the
// dequantization process. They have the same coefficient
// shift/scale as TX.
int16_t seg_dequant_QTX[MAX_SEGMENTS][2];
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
dequant_val_type_nuq seg_dequant_nuq[MAX_SEGMENTS][QUANT_PROFILES] dequant_val_type_nuq seg_dequant_nuq_QTX[MAX_SEGMENTS][QUANT_PROFILES]
[COEF_BANDS]; [COEF_BANDS];
#endif #endif
uint8_t *color_index_map; uint8_t *color_index_map;
...@@ -539,11 +543,12 @@ typedef struct macroblockd_plane { ...@@ -539,11 +543,12 @@ typedef struct macroblockd_plane {
qm_val_t *seg_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL]; qm_val_t *seg_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
qm_val_t *seg_qmatrix[MAX_SEGMENTS][TX_SIZES_ALL]; qm_val_t *seg_qmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
#endif #endif
// encoder
const int16_t *dequant; // the 'dequantizers' below are not literal dequantizer values.
#if CONFIG_NEW_QUANT // They're used by encoder RDO to generate ad-hoc lambda values.
const dequant_val_type_nuq *dequant_val_nuq[QUANT_PROFILES]; // They use a hardwired Q3 coeff shift and do not necessarily match
#endif // CONFIG_NEW_QUANT // the TX scale in use.
const int16_t *dequant_Q3;
#if CONFIG_DIST_8X8 #if CONFIG_DIST_8X8
DECLARE_ALIGNED(16, int16_t, pred[MAX_SB_SQUARE]); DECLARE_ALIGNED(16, int16_t, pred[MAX_SB_SQUARE]);
......
...@@ -300,8 +300,12 @@ typedef struct AV1Common { ...@@ -300,8 +300,12 @@ typedef struct AV1Common {
int y_dc_delta_q; int y_dc_delta_q;
int uv_dc_delta_q; int uv_dc_delta_q;
int uv_ac_delta_q; int uv_ac_delta_q;
int16_t y_dequant[MAX_SEGMENTS][2];
int16_t uv_dequant[MAX_SEGMENTS][2]; // The dequantizers below are true dequntizers used only in the
// dequantization process. They have the same coefficient
// shift/scale as TX.
int16_t y_dequant_QTX[MAX_SEGMENTS][2];
int16_t uv_dequant_QTX[MAX_SEGMENTS][2];
#if CONFIG_AOM_QM #if CONFIG_AOM_QM
// Global quant matrix tables // Global quant matrix tables
...@@ -320,8 +324,10 @@ typedef struct AV1Common { ...@@ -320,8 +324,10 @@ typedef struct AV1Common {
int max_qmlevel; int max_qmlevel;
#endif #endif
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
dequant_val_type_nuq y_dequant_nuq[MAX_SEGMENTS][QUANT_PROFILES][COEF_BANDS]; dequant_val_type_nuq y_dequant_nuq_QTX[MAX_SEGMENTS][QUANT_PROFILES]
dequant_val_type_nuq uv_dequant_nuq[MAX_SEGMENTS][QUANT_PROFILES][COEF_BANDS]; [COEF_BANDS];
dequant_val_type_nuq uv_dequant_nuq_QTX[MAX_SEGMENTS][QUANT_PROFILES]
[COEF_BANDS];
#endif #endif
/* We allocate a MODE_INFO struct for each macroblock, together with /* We allocate a MODE_INFO struct for each macroblock, together with
...@@ -678,24 +684,26 @@ static INLINE void av1_init_macroblockd(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -678,24 +684,26 @@ static INLINE void av1_init_macroblockd(AV1_COMMON *cm, MACROBLOCKD *xd,
xd->plane[i].dqcoeff = dqcoeff; xd->plane[i].dqcoeff = dqcoeff;
xd->above_context[i] = cm->above_context[i]; xd->above_context[i] = cm->above_context[i];
if (xd->plane[i].plane_type == PLANE_TYPE_Y) { if (xd->plane[i].plane_type == PLANE_TYPE_Y) {
memcpy(xd->plane[i].seg_dequant, cm->y_dequant, sizeof(cm->y_dequant)); memcpy(xd->plane[i].seg_dequant_QTX, cm->y_dequant_QTX,
sizeof(cm->y_dequant_QTX));
#if CONFIG_AOM_QM #if CONFIG_AOM_QM
memcpy(xd->plane[i].seg_iqmatrix, cm->y_iqmatrix, sizeof(cm->y_iqmatrix)); memcpy(xd->plane[i].seg_iqmatrix, cm->y_iqmatrix, sizeof(cm->y_iqmatrix));
#endif #endif
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
memcpy(xd->plane[i].seg_dequant_nuq, cm->y_dequant_nuq, memcpy(xd->plane[i].seg_dequant_nuq_QTX, cm->y_dequant_nuq_QTX,
sizeof(cm->y_dequant_nuq)); sizeof(cm->y_dequant_nuq_QTX));
#endif #endif
} else { } else {
memcpy(xd->plane[i].seg_dequant, cm->uv_dequant, sizeof(cm->uv_dequant)); memcpy(xd->plane[i].seg_dequant_QTX, cm->uv_dequant_QTX,
sizeof(cm->uv_dequant_QTX));
#if CONFIG_AOM_QM #if CONFIG_AOM_QM
memcpy(xd->plane[i].seg_iqmatrix, cm->uv_iqmatrix, memcpy(xd->plane[i].seg_iqmatrix, cm->uv_iqmatrix,
sizeof(cm->uv_iqmatrix)); sizeof(cm->uv_iqmatrix));
#endif #endif
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
memcpy(xd->plane[i].seg_dequant_nuq, cm->uv_dequant_nuq, memcpy(xd->plane[i].seg_dequant_nuq_QTX, cm->uv_dequant_nuq_QTX,
sizeof(cm->uv_dequant_nuq)); sizeof(cm->uv_dequant_nuq_QTX));
#endif #endif
} }
} }
......
...@@ -457,6 +457,14 @@ static void decode_mbmi_block(AV1Decoder *const pbi, MACROBLOCKD *const xd, ...@@ -457,6 +457,14 @@ static void decode_mbmi_block(AV1Decoder *const pbi, MACROBLOCKD *const xd,
aom_merge_corrupted_flag(&xd->corrupted, reader_corrupted_flag); aom_merge_corrupted_flag(&xd->corrupted, reader_corrupted_flag);
} }
// Converts a Q3 quantizer lookup from static configuration to the
// actual TX scaling in use
static int dequant_Q3_to_QTX(int q3, int bd) {
// Right now, TX scale in use is still Q3
(void)bd;
return q3;
}
static void decode_token_and_recon_block(AV1Decoder *const pbi, static void decode_token_and_recon_block(AV1Decoder *const pbi,
MACROBLOCKD *const xd, int mi_row, MACROBLOCKD *const xd, int mi_row,
int mi_col, aom_reader *r, int mi_col, aom_reader *r,
...@@ -488,11 +496,12 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi, ...@@ -488,11 +496,12 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
for (j = 0; j < MAX_MB_PLANE; ++j) { for (j = 0; j < MAX_MB_PLANE; ++j) {
const int dc_delta_q = j == 0 ? cm->y_dc_delta_q : cm->uv_dc_delta_q; const int dc_delta_q = j == 0 ? cm->y_dc_delta_q : cm->uv_dc_delta_q;
const int ac_delta_q = j == 0 ? 0 : cm->uv_ac_delta_q; const int ac_delta_q = j == 0 ? 0 : cm->uv_ac_delta_q;
xd->plane[j].seg_dequant_QTX[i][0] = dequant_Q3_to_QTX(
xd->plane[j].seg_dequant[i][0] = av1_dc_quant(current_qindex, dc_delta_q, cm->bit_depth),
av1_dc_quant(current_qindex, dc_delta_q, cm->bit_depth); cm->bit_depth);
xd->plane[j].seg_dequant[i][1] = xd->plane[j].seg_dequant_QTX[i][1] = dequant_Q3_to_QTX(
av1_ac_quant(current_qindex, ac_delta_q, cm->bit_depth); av1_ac_quant(current_qindex, ac_delta_q, cm->bit_depth),
cm->bit_depth);
} }
} }
} }
...@@ -1359,12 +1368,14 @@ static void setup_segmentation_dequant(AV1_COMMON *const cm) { ...@@ -1359,12 +1368,14 @@ static void setup_segmentation_dequant(AV1_COMMON *const cm) {
const int max_segments = cm->seg.enabled ? MAX_SEGMENTS : 1; const int max_segments = cm->seg.enabled ? MAX_SEGMENTS : 1;
for (int i = 0; i < max_segments; ++i) { for (int i = 0; i < max_segments; ++i) {
const int qindex = av1_get_qindex(&cm->seg, i, cm->base_qindex); const int qindex = av1_get_qindex(&cm->seg, i, cm->base_qindex);
cm->y_dequant[i][0] = av1_dc_quant(qindex, cm->y_dc_delta_q, cm->bit_depth); cm->y_dequant_QTX[i][0] = dequant_Q3_to_QTX(
cm->y_dequant[i][1] = av1_ac_quant(qindex, 0, cm->bit_depth); av1_dc_quant(qindex, cm->y_dc_delta_q, cm->bit_depth), cm->bit_depth);
cm->uv_dequant[i][0] = cm->y_dequant_QTX[i][1] = dequant_Q3_to_QTX(
av1_dc_quant(qindex, cm->uv_dc_delta_q, cm->bit_depth); av1_ac_quant(qindex, 0, cm->bit_depth), cm->bit_depth);
cm->uv_dequant[i][1] = cm->uv_dequant_QTX[i][0] = dequant_Q3_to_QTX(
av1_ac_quant(qindex, cm->uv_ac_delta_q, cm->bit_depth); av1_dc_quant(qindex, cm->uv_dc_delta_q, cm->bit_depth), cm->bit_depth);
cm->uv_dequant_QTX[i][1] = dequant_Q3_to_QTX(
av1_ac_quant(qindex, cm->uv_ac_delta_q, cm->bit_depth), cm->bit_depth);
#if CONFIG_AOM_QM #if CONFIG_AOM_QM
const int lossless = qindex == 0 && cm->y_dc_delta_q == 0 && const int lossless = qindex == 0 && cm->y_dc_delta_q == 0 &&
cm->uv_dc_delta_q == 0 && cm->uv_ac_delta_q == 0; cm->uv_dc_delta_q == 0 && cm->uv_ac_delta_q == 0;
...@@ -1381,10 +1392,10 @@ static void setup_segmentation_dequant(AV1_COMMON *const cm) { ...@@ -1381,10 +1392,10 @@ static void setup_segmentation_dequant(AV1_COMMON *const cm) {
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
for (int dq = 0; dq < QUANT_PROFILES; dq++) { for (int dq = 0; dq < QUANT_PROFILES; dq++) {
for (int b = 0; b < COEF_BANDS; ++b) { for (int b = 0; b < COEF_BANDS; ++b) {
av1_get_dequant_val_nuq(cm->y_dequant[i][b != 0], b, av1_get_dequant_val_nuq(cm->y_dequant_QTX[i][b != 0], b,
cm->y_dequant_nuq[i][dq][b], NULL, dq); cm->y_dequant_nuq_QTX[i][dq][b], NULL, dq);
av1_get_dequant_val_nuq(cm->uv_dequant[i][b != 0], b, av1_get_dequant_val_nuq(cm->uv_dequant_QTX[i][b != 0], b,
cm->uv_dequant_nuq[i][dq][b], NULL, dq); cm->uv_dequant_nuq_QTX[i][dq][b], NULL, dq);
} }
} }
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
......
...@@ -65,7 +65,8 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -65,7 +65,8 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
const int seg_eob = tx_size_2d[tx_size]; const int seg_eob = tx_size_2d[tx_size];
int c = 0; int c = 0;
int update_eob = -1; int update_eob = -1;
const int16_t *const dequant = xd->plane[plane].seg_dequant[mbmi->segment_id]; const int16_t *const dequant =
xd->plane[plane].seg_dequant_QTX[mbmi->segment_id];
const int shift = av1_get_tx_scale(tx_size); const int shift = av1_get_tx_scale(tx_size);
const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
const int height = tx_size_high[tx_size]; const int height = tx_size_high[tx_size];
......
...@@ -356,7 +356,7 @@ int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane, ...@@ -356,7 +356,7 @@ int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
TX_TYPE tx_type, int16_t *max_scan_line, TX_TYPE tx_type, int16_t *max_scan_line,
aom_reader *r, int seg_id) { aom_reader *r, int seg_id) {
struct macroblockd_plane *const pd = &xd->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane];
const int16_t *const dequant = pd->seg_dequant[seg_id]; const int16_t *const dequant = pd->seg_dequant_QTX[seg_id];
const int ctx = const int ctx =
get_entropy_context(tx_size, pd->above_context + x, pd->left_context + y); get_entropy_context(tx_size, pd->above_context + x, pd->left_context + y);
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
...@@ -372,7 +372,7 @@ int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane, ...@@ -372,7 +372,7 @@ int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
const int eob = const int eob =
decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size, tx_type, dequant, decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size, tx_type, dequant,
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
pd->seg_dequant_nuq[seg_id][dq], pd->seg_dequant_nuq_QTX[seg_id][dq],
#else #else
#if CONFIG_AOM_QM #if CONFIG_AOM_QM
pd->seg_iqmatrix[seg_id], pd->seg_iqmatrix[seg_id],
......
...@@ -61,8 +61,8 @@ int ifd_inspect(insp_frame_data *fd, void *decoder) { ...@@ -61,8 +61,8 @@ int ifd_inspect(insp_frame_data *fd, void *decoder) {
int i, j; int i, j;
for (i = 0; i < MAX_SEGMENTS; i++) { for (i = 0; i < MAX_SEGMENTS; i++) {
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
fd->y_dequant[i][j] = cm->y_dequant[i][j]; fd->y_dequant[i][j] = cm->y_dequant_QTX[i][j];
fd->uv_dequant[i][j] = cm->uv_dequant[i][j]; fd->uv_dequant[i][j] = cm->uv_dequant_QTX[i][j];
} }
} }
for (j = 0; j < cm->mi_rows; j++) { for (j = 0; j < cm->mi_rows; j++) {
......
This diff is collapsed.
...@@ -36,11 +36,13 @@ typedef struct QUANT_PARAM { ...@@ -36,11 +36,13 @@ typedef struct QUANT_PARAM {
typedef void (*AV1_QUANT_FACADE)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, typedef void (*AV1_QUANT_FACADE)(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const MACROBLOCK_PLANE *p, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const SCAN_ORDER *sc, const SCAN_ORDER *sc,
const QUANT_PARAM *qparam); const QUANT_PARAM *qparam);
// The QUANTS structure is used only for internal quantizer setup in
// av1_quantize.c.
// All of its fields use the same coefficient shift/scaling at TX.
typedef struct { typedef struct {
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
DECLARE_ALIGNED( DECLARE_ALIGNED(
...@@ -69,14 +71,25 @@ typedef struct { ...@@ -69,14 +71,25 @@ typedef struct {
DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]); DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]);
} QUANTS; } QUANTS;
// The Dequants structure is used only for internal quantizer setup in
// av1_quantize.c.
// Fields are sufffixed according to whether or not they're expressed in
// the same coefficient shift/precision as TX or a fixed Q3 format.
typedef struct { typedef struct {
DECLARE_ALIGNED(16, int16_t, y_dequant[QINDEX_RANGE][8]); // 8: SIMD width DECLARE_ALIGNED(16, int16_t,
DECLARE_ALIGNED(16, int16_t, uv_dequant[QINDEX_RANGE][8]); // 8: SIMD width y_dequant_QTX[QINDEX_RANGE][8]); // 8: SIMD width
DECLARE_ALIGNED(16, int16_t,
uv_dequant_QTX[QINDEX_RANGE][8]); // 8: SIMD width
DECLARE_ALIGNED(16, int16_t, y_dequant_Q3[QINDEX_RANGE][8]); // 8: SIMD width
DECLARE_ALIGNED(16, int16_t,
uv_dequant_Q3[QINDEX_RANGE][8]); // 8: SIMD width
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
DECLARE_ALIGNED(16, dequant_val_type_nuq, DECLARE_ALIGNED(
y_dequant_val_nuq[QUANT_PROFILES][QINDEX_RANGE][COEF_BANDS]); 16, dequant_val_type_nuq,
DECLARE_ALIGNED(16, dequant_val_type_nuq, y_dequant_val_nuq_QTX[QUANT_PROFILES][QINDEX_RANGE][COEF_BANDS]);
uv_dequant_val_nuq[QUANT_PROFILES][QINDEX_RANGE][COEF_BANDS]); DECLARE_ALIGNED(
16, dequant_val_type_nuq,
uv_dequant_val_nuq_QTX[QUANT_PROFILES][QINDEX_RANGE][COEF_BANDS]);
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
} Dequants; } Dequants;
...@@ -105,51 +118,42 @@ void av1_quantize_skip(intptr_t n_coeffs, tran_low_t *qcoeff_ptr, ...@@ -105,51 +118,42 @@ void av1_quantize_skip(intptr_t n_coeffs, tran_low_t *qcoeff_ptr,
void av1_quantize_fp_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs, void av1_quantize_fp_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr, const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const SCAN_ORDER *sc, const QUANT_PARAM *qparam); const SCAN_ORDER *sc, const QUANT_PARAM *qparam);
void av1_quantize_b_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs, void av1_quantize_b_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr, const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd, tran_low_t *dqcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
uint16_t *eob_ptr, const SCAN_ORDER *sc, const SCAN_ORDER *sc, const QUANT_PARAM *qparam);
const QUANT_PARAM *qparam);
void av1_quantize_dc_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs, void av1_quantize_dc_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr, const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const SCAN_ORDER *sc, const QUANT_PARAM *qparam); const SCAN_ORDER *sc, const QUANT_PARAM *qparam);
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
void av1_quantize_fp_nuq_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs, void av1_quantize_fp_nuq_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const MACROBLOCK_PLANE *p, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const MACROBLOCKD_PLANE *pd, uint16_t *eob_ptr, const SCAN_ORDER *sc,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const SCAN_ORDER *sc,
const QUANT_PARAM *qparam); const QUANT_PARAM *qparam);
void av1_quantize_b_nuq_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs, void av1_quantize_b_nuq_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const MACROBLOCK_PLANE *p, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const MACROBLOCKD_PLANE *pd, uint16_t *eob_ptr, const SCAN_ORDER *sc,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const QUANT_PARAM *qparam);
const SCAN_ORDER *sc, const QUANT_PARAM *qparam);
void av1_quantize_dc_nuq_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs, void av1_quantize_dc_nuq_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const MACROBLOCK_PLANE *p, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const MACROBLOCKD_PLANE *pd, uint16_t *eob_ptr, const SCAN_ORDER *sc,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const SCAN_ORDER *sc,
const QUANT_PARAM *qparam); const QUANT_PARAM *qparam);
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
void av1_highbd_quantize_fp_facade(const tran_low_t *coeff_ptr, void av1_highbd_quantize_fp_facade(const tran_low_t *coeff_ptr,
intptr_t n_coeffs, const MACROBLOCK_PLANE *p, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const SCAN_ORDER *sc, const SCAN_ORDER *sc,
const QUANT_PARAM *qparam); const QUANT_PARAM *qparam);
...@@ -157,7 +161,6 @@ void av1_highbd_quantize_fp_facade(const tran_low_t *coeff_ptr, ...@@ -157,7 +161,6 @@ void av1_highbd_quantize_fp_facade(const tran_low_t *coeff_ptr,
void av1_highbd_quantize_b_facade(const tran_low_t *coeff_ptr, void av1_highbd_quantize_b_facade(const tran_low_t *coeff_ptr,
intptr_t n_coeffs, const MACROBLOCK_PLANE *p, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const SCAN_ORDER *sc, const SCAN_ORDER *sc,
const QUANT_PARAM *qparam); const QUANT_PARAM *qparam);
...@@ -165,7 +168,6 @@ void av1_highbd_quantize_b_facade(const tran_low_t *coeff_ptr, ...@@ -165,7 +168,6 @@ void av1_highbd_quantize_b_facade(const tran_low_t *coeff_ptr,
void av1_highbd_quantize_dc_facade(const tran_low_t *coeff_ptr, void av1_highbd_quantize_dc_facade(const tran_low_t *coeff_ptr,
intptr_t n_coeffs, const MACROBLOCK_PLANE *p, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, tran_low_t *qcoeff_ptr,
const MACROBLOCKD_PLANE *pd,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
const SCAN_ORDER *sc, const SCAN_ORDER *sc,
const QUANT_PARAM *qparam); const QUANT_PARAM *qparam);
...@@ -173,21 +175,18 @@ void av1_highbd_quantize_dc_facade(const tran_low_t *coeff_ptr, ...@@ -173,21 +175,18 @@ void av1_highbd_quantize_dc_facade(const tran_low_t *coeff_ptr,
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
void av1_highbd_quantize_fp_nuq_facade( void av1_highbd_quantize_fp_nuq_facade(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p, const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const SCAN_ORDER *sc, const SCAN_ORDER *sc, const QUANT_PARAM *qparam);
const QUANT_PARAM *qparam);
void av1_highbd_quantize_b_nuq_facade( void av1_highbd_quantize_b_nuq_facade(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p, const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const SCAN_ORDER *sc, const SCAN_ORDER *sc, const QUANT_PARAM *qparam);
const QUANT_PARAM *qparam);
void av1_highbd_quantize_dc_nuq_facade( void av1_highbd_quantize_dc_nuq_facade(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p, const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p,
tran_low_t *qcoeff_ptr, const MACROBLOCKD_PLANE *pd, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const SCAN_ORDER *sc, const SCAN_ORDER *sc, const QUANT_PARAM *qparam);
const QUANT_PARAM *qparam);
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -41,14 +41,19 @@ typedef struct macroblock_plane { ...@@ -41,14 +41,19 @@ typedef struct macroblock_plane {
struct buf_2d src; struct buf_2d src;
// Quantizer setings // Quantizer setings
const int16_t *quant_fp; // These are used/accessed only in the quantization process
const int16_t *round_fp; // RDO does not / must not depend on any of these values
const int16_t *quant; // All values below share the coefficient scale/shift used in TX
const int16_t *quant_shift; const int16_t *quant_fp_QTX;
const int16_t *zbin; const int16_t *round_fp_QTX;
const int16_t *round; const int16_t *quant_QTX;
const int16_t *quant_shift_QTX;
const int16_t *zbin_QTX;
const int16_t *round_QTX;
const int16_t *dequant_QTX;
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
const cuml_bins_type_nuq *cuml_bins_nuq[QUANT_PROFILES]; const cuml_bins_type_nuq *cuml_bins_nuq[QUANT_PROFILES];
const dequant_val_type_nuq *dequant_val_nuq_QTX[QUANT_PROFILES];
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
} MACROBLOCK_PLANE; } MACROBLOCK_PLANE;
......
...@@ -136,7 +136,7 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, ...@@ -136,7 +136,7 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
const tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block); const tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
const int16_t *const dequant_ptr = pd->dequant; const int16_t *const dequant_ptr = p->dequant_QTX;
const uint8_t *const band_translate = get_band_translate(tx_size); const uint8_t *const band_translate = get_band_translate(tx_size);
const TX_TYPE tx_type = const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size); av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
...@@ -154,7 +154,7 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, ...@@ -154,7 +154,7 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
#endif #endif
#if CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT
int dq = get_dq_profile_from_ctx(mb->qindex, ctx, ref, plane_type); int dq = get_dq_profile_from_ctx(mb->qindex, ctx, ref, plane_type);
const dequant_val_type_nuq *dequant_val = pd->dequant_val_nuq[dq]; const dequant_val_type_nuq *dequant_val = p->dequant_val_nuq_QTX[dq];
#endif // CONFIG_NEW_QUANT #endif // CONFIG_NEW_QUANT
int64_t rd_cost0, rd_cost1; int64_t rd_cost0, rd_cost1;
int16_t t0, t1; int16_t t0, t1;
...@@ -568,7 +568,7 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block, ...@@ -568,7 +568,7 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
if (xform_quant_idx != AV1_XFORM_QUANT_SKIP_QUANT) { if (xform_quant_idx != AV1_XFORM_QUANT_SKIP_QUANT) {
if (LIKELY(!x->skip_block)) { if (LIKELY(!x->skip_block)) {
quant_func_list[xform_quant_idx][is_hbd]( quant_func_list[xform_quant_idx][is_hbd](
coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order, &qparam); coeff, tx2d_size, p, qcoeff, dqcoeff, eob, scan_order, &qparam);
} else { } else {
av1_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob); av1_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob);
} }
......
...@@ -1893,7 +1893,7 @@ int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane, ...@@ -1893,7 +1893,7 @@ int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane,
tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
const tran_low_t *tcoeff = BLOCK_OFFSET(p->coeff, block); const tran_low_t *tcoeff = BLOCK_OFFSET(p->coeff, block);
const int16_t *dequant = pd->dequant; const int16_t *dequant = p->dequant_QTX;
const int seg_eob = tx_size_2d[tx_size]; const int seg_eob = tx_size_2d[tx_size];
const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
const int stride = 1 << bwl; const int stride = 1 << bwl;
......
...@@ -1539,7 +1539,7 @@ static void model_rd_from_sse(const AV1_COMP *const cpi, ...@@ -1539,7 +1539,7 @@ static void model_rd_from_sse(const AV1_COMP *const cpi,
// Fast approximate the modelling function. // Fast approximate the modelling function.
if (cpi->sf.simple_model_rd_from_var) { if (cpi->sf.simple_model_rd_from_var) {
const int64_t square_error = sse; const int64_t square_error = sse;
int quantizer = (pd->dequant[1] >> dequant_shift); int quantizer = (pd->dequant_Q3[1] >> dequant_shift);
if (quantizer < 120) if (quantizer < 120)
*rate = (int)((square_error * (280 - quantizer)) >> *rate = (int)((square_error * (280 - quantizer)) >>
...@@ -1549,7 +1549,8 @@ static void model_rd_from_sse(const AV1_COMP *const cpi, ...@@ -1549,7 +1549,8 @@ static void model_rd_from_sse(const AV1_COMP *const cpi,
*dist = (square_error * quantizer) >> 8; *dist = (square_error * quantizer) >> 8;
} else { } else {
av1_model_rd_from_var_lapndz(sse, num_pels_log2_lookup[bsize], av1_model_rd_from_var_lapndz(sse, num_pels_log2_lookup[bsize],
pd->dequant[1] >> dequant_shift, rate, dist); pd->dequant_Q3[1] >> dequant_shift, rate,
dist);
} }
*dist <<= 4; *dist <<= 4;
......
...@@ -130,7 +130,7 @@ class QuantizeTest : public ::testing::TestWithParam<QuantizeParam> { ...@@ -130,7 +130,7 @@ class QuantizeTest : public ::testing::TestWithParam<QuantizeParam> {
} }
const int16_t *quant_shift = qtab_->quant.y_quant_shift[q]; const int16_t *quant_shift = qtab_->quant.y_quant_shift[q];
const int16_t *dequant = qtab_->dequant.y_dequant[q]; const int16_t *dequant = qtab_->dequant.y_dequant_QTX[q];
for (int i = 0; i < test_num; ++i) { for (int i = 0; i < test_num; ++i) {
if (is_loop) FillCoeffRandom(); if (is_loop) FillCoeffRandom();
...@@ -276,7 +276,7 @@ TEST_P(QuantizeTest, DISABLED_Speed) { ...@@ -276,7 +276,7 @@ TEST_P(QuantizeTest, DISABLED_Speed) {
const int16_t *round_fp = qtab_->quant.y_round_fp[q]; const int16_t *round_fp = qtab_->quant.y_round_fp[q];
const int16_t *quant_fp = qtab_->quant.y_quant_fp[q]; const int16_t *quant_fp = qtab_->quant.y_quant_fp[q];
const int16_t *quant_shift = qtab_->quant.y_quant_shift[q]; const int16_t *quant_shift = qtab_->quant.y_quant_shift[q];
const int16_t *dequant = qtab_->dequant.y_dequant[q]; const int16_t *dequant = qtab_->dequant.y_dequant_QTX[q];
const int kNumTests = 5000000; const int kNumTests = 5000000;
aom_usec_timer timer; aom_usec_timer timer;
......
Markdown is supported
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