Commit 17db5d00 authored by Yaowu Xu's avatar Yaowu Xu

enable bitstream lossless support

1. Added a bit in frame header to  to indicate if a frame is encoded
in lossless mode, so decoder does not make the decision based on Q0
2. Minor changes to make sure that lossy coding works same as when
the lossless experiment is not enabled.
3. Renamed function pointers for transforms to be consistent, using
prefix fwd_txm and inv_txm for forward and inverse respectively

To encode in lossless mode, using "--lossless=1 --min-q=0 --max-q=0"
with vpxenc.

Change-Id: Ifae53b26d2ffbe378d707e29d96817b8a5e6c068
parent 16f25f9d
...@@ -390,22 +390,22 @@ typedef struct macroblockd { ...@@ -390,22 +390,22 @@ typedef struct macroblockd {
int lossless; int lossless;
#endif #endif
/* Inverse transform function pointers. */ /* Inverse transform function pointers. */
void (*inv_xform4x4_1_x8)(int16_t *input, int16_t *output, int pitch); void (*inv_txm4x4_1)(int16_t *input, int16_t *output, int pitch);
void (*inv_xform4x4_x8)(int16_t *input, int16_t *output, int pitch); void (*inv_txm4x4)(int16_t *input, int16_t *output, int pitch);
void (*inv_walsh4x4_1)(int16_t *in, int16_t *out); void (*inv_2ndtxm4x4_1)(int16_t *in, int16_t *out);
void (*inv_walsh4x4_lossless)(int16_t *in, int16_t *out); void (*inv_2ndtxm4x4)(int16_t *in, int16_t *out);
void (*idct_add)(int16_t *input, const int16_t *dq, void (*itxm_add)(int16_t *input, const int16_t *dq,
uint8_t *pred, uint8_t *output, int pitch, int stride); uint8_t *pred, uint8_t *output, int pitch, int stride);
void (*dc_idct_add)(int16_t *input, const int16_t *dq, void (*dc_itxm_add)(int16_t *input, const int16_t *dq,
uint8_t *pred, uint8_t *output, int pitch, int stride, int dc); uint8_t *pred, uint8_t *output, int pitch, int stride, int dc);
void (*dc_only_idct_add)(int input_dc, uint8_t *pred_ptr, void (*dc_only_itxm_add)(int input_dc, uint8_t *pred_ptr,
uint8_t *dst_ptr, int pitch, int stride); uint8_t *dst_ptr, int pitch, int stride);
void (*dc_idct_add_y_block)(int16_t *q, const int16_t *dq, void (*dc_itxm_add_y_block)(int16_t *q, const int16_t *dq,
uint8_t *pre, uint8_t *dst, int stride, uint16_t *eobs, uint8_t *pre, uint8_t *dst, int stride, uint16_t *eobs,
const int16_t *dc); const int16_t *dc);
void (*idct_add_y_block)(int16_t *q, const int16_t *dq, void (*itxm_add_y_block)(int16_t *q, const int16_t *dq,
uint8_t *pre, uint8_t *dst, int stride, uint16_t *eobs); uint8_t *pre, uint8_t *dst, int stride, uint16_t *eobs);
void (*idct_add_uv_block)(int16_t *q, const int16_t *dq, void (*itxm_add_uv_block)(int16_t *q, const int16_t *dq,
uint8_t *pre, uint8_t *dst_u, uint8_t *dst_v, int stride, uint8_t *pre, uint8_t *dst_u, uint8_t *dst_v, int stride,
uint16_t *eobs); uint16_t *eobs);
...@@ -520,7 +520,7 @@ static TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, const BLOCKD *b) { ...@@ -520,7 +520,7 @@ static TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, const BLOCKD *b) {
return tx_type; return tx_type;
#if CONFIG_LOSSLESS #if CONFIG_LOSSLESS
if (xd->lossless) if (xd->lossless)
return tx_type; return DCT_DCT;
#endif #endif
// TODO(rbultje, debargha): Explore ADST usage for superblocks // TODO(rbultje, debargha): Explore ADST usage for superblocks
if (xd->mode_info_context->mbmi.sb_type) if (xd->mode_info_context->mbmi.sb_type)
......
...@@ -476,12 +476,13 @@ void vp9_short_inv_walsh4x4_1_x8_c(int16_t *in, int16_t *out, int pitch) { ...@@ -476,12 +476,13 @@ void vp9_short_inv_walsh4x4_1_x8_c(int16_t *in, int16_t *out, int pitch) {
} }
} }
void vp9_dc_only_inv_walsh_add_c(short input_dc, uint8_t *pred_ptr, void vp9_dc_only_inv_walsh_add_c(int input_dc, uint8_t *pred_ptr,
uint8_t *dst_ptr, uint8_t *dst_ptr,
int pitch, int stride) { int pitch, int stride) {
int r, c; int r, c;
short tmp[16]; int16_t dc = input_dc;
vp9_short_inv_walsh4x4_1_x8_c(&input_dc, tmp, 4 << 1); int16_t tmp[16];
vp9_short_inv_walsh4x4_1_x8_c(&dc, tmp, 4 << 1);
for (r = 0; r < 4; r++) { for (r = 0; r < 4; r++) {
for (c = 0; c < 4; c++) { for (c = 0; c < 4; c++) {
......
...@@ -32,9 +32,9 @@ static void recon_dcblock_8x8(MACROBLOCKD *xd) { ...@@ -32,9 +32,9 @@ static void recon_dcblock_8x8(MACROBLOCKD *xd) {
void vp9_inverse_transform_b_4x4(MACROBLOCKD *xd, int block, int pitch) { void vp9_inverse_transform_b_4x4(MACROBLOCKD *xd, int block, int pitch) {
BLOCKD *b = &xd->block[block]; BLOCKD *b = &xd->block[block];
if (b->eob <= 1) if (b->eob <= 1)
xd->inv_xform4x4_1_x8(b->dqcoeff, b->diff, pitch); xd->inv_txm4x4_1(b->dqcoeff, b->diff, pitch);
else else
xd->inv_xform4x4_x8(b->dqcoeff, b->diff, pitch); xd->inv_txm4x4(b->dqcoeff, b->diff, pitch);
} }
void vp9_inverse_transform_mby_4x4(MACROBLOCKD *xd) { void vp9_inverse_transform_mby_4x4(MACROBLOCKD *xd) {
...@@ -44,7 +44,7 @@ void vp9_inverse_transform_mby_4x4(MACROBLOCKD *xd) { ...@@ -44,7 +44,7 @@ void vp9_inverse_transform_mby_4x4(MACROBLOCKD *xd) {
if (has_2nd_order) { if (has_2nd_order) {
/* do 2nd order transform on the dc block */ /* do 2nd order transform on the dc block */
xd->inv_walsh4x4_lossless(blockd[24].dqcoeff, blockd[24].diff); xd->inv_2ndtxm4x4(blockd[24].dqcoeff, blockd[24].diff);
recon_dcblock(xd); recon_dcblock(xd);
} }
......
...@@ -123,43 +123,30 @@ static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *xd) { ...@@ -123,43 +123,30 @@ static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *xd) {
xd->block[i].dequant = pc->Y1dequant[QIndex]; xd->block[i].dequant = pc->Y1dequant[QIndex];
} }
xd->inv_txm4x4_1 = vp9_short_idct4x4llm_1;
xd->inv_txm4x4 = vp9_short_idct4x4llm;
xd->inv_2ndtxm4x4_1 = vp9_short_inv_walsh4x4_1;
xd->inv_2ndtxm4x4 = vp9_short_inv_walsh4x4;
xd->itxm_add = vp9_dequant_idct_add;
xd->dc_only_itxm_add = vp9_dc_only_idct_add_c;
xd->dc_itxm_add = vp9_dequant_dc_idct_add;
xd->dc_itxm_add_y_block = vp9_dequant_dc_idct_add_y_block;
xd->itxm_add_y_block = vp9_dequant_idct_add_y_block;
xd->itxm_add_uv_block = vp9_dequant_idct_add_uv_block;
#if CONFIG_LOSSLESS #if CONFIG_LOSSLESS
pbi->mb.lossless = 0; if (xd->lossless) {
if (!QIndex) { assert(QIndex == 0);
pbi->mb.inv_xform4x4_1_x8 = vp9_short_inv_walsh4x4_1_x8; xd->inv_txm4x4_1 = vp9_short_inv_walsh4x4_1_x8;
pbi->mb.inv_xform4x4_x8 = vp9_short_inv_walsh4x4_x8; xd->inv_txm4x4 = vp9_short_inv_walsh4x4_x8;
pbi->mb.inv_walsh4x4_1 = vp9_short_inv_walsh4x4_1_lossless; xd->inv_2ndtxm4x4_1 = vp9_short_inv_walsh4x4_1_lossless;
pbi->mb.inv_walsh4x4_lossless = vp9_short_inv_walsh4x4_lossless; xd->inv_2ndtxm4x4 = vp9_short_inv_walsh4x4_lossless;
pbi->mb.idct_add = vp9_dequant_idct_add_lossless_c; xd->itxm_add = vp9_dequant_idct_add_lossless_c;
pbi->mb.dc_only_idct_add = vp9_dc_only_inv_walsh_add_c; xd->dc_only_itxm_add = vp9_dc_only_inv_walsh_add_c;
pbi->mb.dc_idct_add = vp9_dequant_dc_idct_add_lossless_c; xd->dc_itxm_add = vp9_dequant_dc_idct_add_lossless_c;
pbi->mb.dc_idct_add_y_block = vp9_dequant_dc_idct_add_y_block_lossless_c; xd->dc_itxm_add_y_block = vp9_dequant_dc_idct_add_y_block_lossless_c;
pbi->mb.idct_add_y_block = vp9_dequant_idct_add_y_block_lossless_c; xd->itxm_add_y_block = vp9_dequant_idct_add_y_block_lossless_c;
pbi->mb.idct_add_uv_block = vp9_dequant_idct_add_uv_block_lossless_c; xd->itxm_add_uv_block = vp9_dequant_idct_add_uv_block_lossless_c;
pbi->mb.lossless = 1;
} else {
pbi->mb.inv_xform4x4_1_x8 = vp9_short_idct4x4llm_1;
pbi->mb.inv_xform4x4_x8 = vp9_short_idct4x4llm;
pbi->mb.inv_walsh4x4_1 = vp9_short_inv_walsh4x4_1;
pbi->mb.inv_walsh4x4_lossless = vp9_short_inv_walsh4x4;
pbi->mb.idct_add = vp9_dequant_idct_add;
pbi->mb.dc_only_idct_add = vp9_dc_only_idct_add_c;
pbi->mb.dc_idct_add = vp9_dequant_dc_idct_add;
pbi->mb.dc_idct_add_y_block = vp9_dequant_dc_idct_add_y_block;
pbi->mb.idct_add_y_block = vp9_dequant_idct_add_y_block;
pbi->mb.idct_add_uv_block = vp9_dequant_idct_add_uv_block;
} }
#else
pbi->mb.inv_xform4x4_1_x8 = vp9_short_idct4x4llm_1;
pbi->mb.inv_xform4x4_x8 = vp9_short_idct4x4llm;
pbi->mb.inv_walsh4x4_1 = vp9_short_inv_walsh4x4_1;
pbi->mb.inv_walsh4x4_lossless = vp9_short_inv_walsh4x4;
pbi->mb.idct_add = vp9_dequant_idct_add;
pbi->mb.dc_only_idct_add = vp9_dc_only_idct_add_c;
pbi->mb.dc_idct_add = vp9_dequant_dc_idct_add;
pbi->mb.dc_idct_add_y_block = vp9_dequant_dc_idct_add_y_block;
pbi->mb.idct_add_y_block = vp9_dequant_idct_add_y_block;
pbi->mb.idct_add_uv_block = vp9_dequant_idct_add_uv_block;
#endif #endif
for (i = 16; i < 24; i++) { for (i = 16; i < 24; i++) {
...@@ -349,15 +336,15 @@ static void decode_8x8(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -349,15 +336,15 @@ static void decode_8x8(VP9D_COMP *pbi, MACROBLOCKD *xd,
int i8x8mode = b->bmi.as_mode.first; int i8x8mode = b->bmi.as_mode.first;
b = &xd->block[16 + i]; b = &xd->block[16 + i];
vp9_intra_uv4x4_predict(xd, &xd->block[16 + i], i8x8mode, b->predictor); vp9_intra_uv4x4_predict(xd, &xd->block[16 + i], i8x8mode, b->predictor);
xd->idct_add(b->qcoeff, b->dequant, b->predictor, xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 8, b->dst_stride); *(b->base_dst) + b->dst, 8, b->dst_stride);
b = &xd->block[20 + i]; b = &xd->block[20 + i];
vp9_intra_uv4x4_predict(xd, &xd->block[20 + i], i8x8mode, b->predictor); vp9_intra_uv4x4_predict(xd, &xd->block[20 + i], i8x8mode, b->predictor);
xd->idct_add(b->qcoeff, b->dequant, b->predictor, xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 8, b->dst_stride); *(b->base_dst) + b->dst, 8, b->dst_stride);
} }
} else if (xd->mode_info_context->mbmi.mode == SPLITMV) { } else if (xd->mode_info_context->mbmi.mode == SPLITMV) {
xd->idct_add_uv_block(xd->qcoeff + 16 * 16, xd->block[16].dequant, xd->itxm_add_uv_block(xd->qcoeff + 16 * 16, xd->block[16].dequant,
xd->predictor + 16 * 16, xd->dst.u_buffer, xd->dst.v_buffer, xd->predictor + 16 * 16, xd->dst.u_buffer, xd->dst.v_buffer,
xd->dst.uv_stride, xd->eobs + 16); xd->dst.uv_stride, xd->eobs + 16);
} else { } else {
...@@ -404,17 +391,17 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -404,17 +391,17 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
*(b->base_dst) + b->dst, 16, *(b->base_dst) + b->dst, 16,
b->dst_stride, b->eob); b->dst_stride, b->eob);
} else { } else {
xd->idct_add(b->qcoeff, b->dequant, b->predictor, xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 16, b->dst_stride); *(b->base_dst) + b->dst, 16, b->dst_stride);
} }
} }
b = &xd->block[16 + i]; b = &xd->block[16 + i];
vp9_intra_uv4x4_predict(xd, b, i8x8mode, b->predictor); vp9_intra_uv4x4_predict(xd, b, i8x8mode, b->predictor);
xd->idct_add(b->qcoeff, b->dequant, b->predictor, xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 8, b->dst_stride); *(b->base_dst) + b->dst, 8, b->dst_stride);
b = &xd->block[20 + i]; b = &xd->block[20 + i];
vp9_intra_uv4x4_predict(xd, b, i8x8mode, b->predictor); vp9_intra_uv4x4_predict(xd, b, i8x8mode, b->predictor);
xd->idct_add(b->qcoeff, b->dequant, b->predictor, xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 8, b->dst_stride); *(b->base_dst) + b->dst, 8, b->dst_stride);
} }
} else if (mode == B_PRED) { } else if (mode == B_PRED) {
...@@ -438,7 +425,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -438,7 +425,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
*(b->base_dst) + b->dst, 16, b->dst_stride, *(b->base_dst) + b->dst, 16, b->dst_stride,
b->eob); b->eob);
} else { } else {
xd->idct_add(b->qcoeff, b->dequant, b->predictor, xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 16, b->dst_stride); *(b->base_dst) + b->dst, 16, b->dst_stride);
} }
} }
...@@ -448,7 +435,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -448,7 +435,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
xd->above_context->y2 = 0; xd->above_context->y2 = 0;
xd->left_context->y2 = 0; xd->left_context->y2 = 0;
vp9_build_intra_predictors_mbuv(xd); vp9_build_intra_predictors_mbuv(xd);
xd->idct_add_uv_block(xd->qcoeff + 16 * 16, xd->itxm_add_uv_block(xd->qcoeff + 16 * 16,
xd->block[16].dequant, xd->block[16].dequant,
xd->predictor + 16 * 16, xd->predictor + 16 * 16,
xd->dst.u_buffer, xd->dst.u_buffer,
...@@ -457,13 +444,13 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -457,13 +444,13 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
xd->eobs + 16); xd->eobs + 16);
} else if (mode == SPLITMV) { } else if (mode == SPLITMV) {
assert(get_2nd_order_usage(xd) == 0); assert(get_2nd_order_usage(xd) == 0);
xd->idct_add_y_block(xd->qcoeff, xd->itxm_add_y_block(xd->qcoeff,
xd->block[0].dequant, xd->block[0].dequant,
xd->predictor, xd->predictor,
xd->dst.y_buffer, xd->dst.y_buffer,
xd->dst.y_stride, xd->dst.y_stride,
xd->eobs); xd->eobs);
xd->idct_add_uv_block(xd->qcoeff + 16 * 16, xd->itxm_add_uv_block(xd->qcoeff + 16 * 16,
xd->block[16].dequant, xd->block[16].dequant,
xd->predictor + 16 * 16, xd->predictor + 16 * 16,
xd->dst.u_buffer, xd->dst.u_buffer,
...@@ -500,7 +487,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -500,7 +487,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
*(b->base_dst) + b->dst, 16, *(b->base_dst) + b->dst, 16,
b->dst_stride, b->eob); b->dst_stride, b->eob);
} else { } else {
xd->idct_add(b->qcoeff, b->dequant, b->predictor, xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 16, b->dst_stride); *(b->base_dst) + b->dst, 16, b->dst_stride);
} }
} }
...@@ -509,7 +496,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -509,7 +496,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
assert(get_2nd_order_usage(xd) == 1); assert(get_2nd_order_usage(xd) == 1);
vp9_dequantize_b(b); vp9_dequantize_b(b);
if (xd->eobs[24] > 1) { if (xd->eobs[24] > 1) {
xd->inv_walsh4x4_lossless(&b->dqcoeff[0], b->diff); xd->inv_2ndtxm4x4(&b->dqcoeff[0], b->diff);
((int *)b->qcoeff)[0] = 0; ((int *)b->qcoeff)[0] = 0;
((int *)b->qcoeff)[1] = 0; ((int *)b->qcoeff)[1] = 0;
((int *)b->qcoeff)[2] = 0; ((int *)b->qcoeff)[2] = 0;
...@@ -519,11 +506,11 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -519,11 +506,11 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
((int *)b->qcoeff)[6] = 0; ((int *)b->qcoeff)[6] = 0;
((int *)b->qcoeff)[7] = 0; ((int *)b->qcoeff)[7] = 0;
} else { } else {
xd->inv_walsh4x4_1(&b->dqcoeff[0], b->diff); xd->inv_2ndtxm4x4_1(&b->dqcoeff[0], b->diff);
((int *)b->qcoeff)[0] = 0; ((int *)b->qcoeff)[0] = 0;
} }
vp9_dequantize_b(b); vp9_dequantize_b(b);
xd->dc_idct_add_y_block(xd->qcoeff, xd->dc_itxm_add_y_block(xd->qcoeff,
xd->block[0].dequant, xd->block[0].dequant,
xd->predictor, xd->predictor,
xd->dst.y_buffer, xd->dst.y_buffer,
...@@ -531,7 +518,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -531,7 +518,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
xd->eobs, xd->eobs,
xd->block[24].diff); xd->block[24].diff);
} }
xd->idct_add_uv_block(xd->qcoeff + 16 * 16, xd->itxm_add_uv_block(xd->qcoeff + 16 * 16,
xd->block[16].dequant, xd->block[16].dequant,
xd->predictor + 16 * 16, xd->predictor + 16 * 16,
xd->dst.u_buffer, xd->dst.u_buffer,
...@@ -649,7 +636,7 @@ static void decode_4x4_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -649,7 +636,7 @@ static void decode_4x4_sb(VP9D_COMP *pbi, MACROBLOCKD *xd,
+ x_idx * 16 + (i & 3) * 4, + x_idx * 16 + (i & 3) * 4,
xd->dst.y_stride, xd->dst.y_stride, b->eob); xd->dst.y_stride, xd->dst.y_stride, b->eob);
} else { } else {
xd->idct_add( xd->itxm_add(
b->qcoeff, b->dequant, b->qcoeff, b->dequant,
xd->dst.y_buffer + (y_idx * 16 + (i / 4) * 4) * xd->dst.y_stride xd->dst.y_buffer + (y_idx * 16 + (i / 4) * 4) * xd->dst.y_stride
+ x_idx * 16 + (i & 3) * 4, + x_idx * 16 + (i & 3) * 4,
...@@ -661,7 +648,7 @@ static void decode_4x4_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -661,7 +648,7 @@ static void decode_4x4_sb(VP9D_COMP *pbi, MACROBLOCKD *xd,
} else { } else {
vp9_dequantize_b(b); vp9_dequantize_b(b);
if (xd->eobs[24] > 1) { if (xd->eobs[24] > 1) {
xd->inv_walsh4x4_lossless(&b->dqcoeff[0], b->diff); xd->inv_2ndtxm4x4(&b->dqcoeff[0], b->diff);
((int *)b->qcoeff)[0] = 0; ((int *)b->qcoeff)[0] = 0;
((int *)b->qcoeff)[1] = 0; ((int *)b->qcoeff)[1] = 0;
((int *)b->qcoeff)[2] = 0; ((int *)b->qcoeff)[2] = 0;
...@@ -671,7 +658,7 @@ static void decode_4x4_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -671,7 +658,7 @@ static void decode_4x4_sb(VP9D_COMP *pbi, MACROBLOCKD *xd,
((int *)b->qcoeff)[6] = 0; ((int *)b->qcoeff)[6] = 0;
((int *)b->qcoeff)[7] = 0; ((int *)b->qcoeff)[7] = 0;
} else { } else {
xd->inv_walsh4x4_1(&b->dqcoeff[0], b->diff); xd->inv_2ndtxm4x4_1(&b->dqcoeff[0], b->diff);
((int *)b->qcoeff)[0] = 0; ((int *)b->qcoeff)[0] = 0;
} }
vp9_dequant_dc_idct_add_y_block_4x4_inplace_c( vp9_dequant_dc_idct_add_y_block_4x4_inplace_c(
...@@ -1533,17 +1520,24 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) { ...@@ -1533,17 +1520,24 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
pc->sb64_coded = vp9_read_literal(&header_bc, 8); pc->sb64_coded = vp9_read_literal(&header_bc, 8);
pc->sb32_coded = vp9_read_literal(&header_bc, 8); pc->sb32_coded = vp9_read_literal(&header_bc, 8);
#if CONFIG_LOSSLESS
/* Read the loop filter level and type */ xd->lossless = vp9_read_bit(&header_bc);
pc->txfm_mode = vp9_read_literal(&header_bc, 2); if (xd->lossless) {
if (pc->txfm_mode == 3) pc->txfm_mode = ONLY_4X4;
pc->txfm_mode += vp9_read_bit(&header_bc); }
if (pc->txfm_mode == TX_MODE_SELECT) { else
pc->prob_tx[0] = vp9_read_literal(&header_bc, 8); #endif
pc->prob_tx[1] = vp9_read_literal(&header_bc, 8); {
pc->prob_tx[2] = vp9_read_literal(&header_bc, 8); /* Read the loop filter level and type */
pc->txfm_mode = vp9_read_literal(&header_bc, 2);
if (pc->txfm_mode == 3)
pc->txfm_mode += vp9_read_bit(&header_bc);
if (pc->txfm_mode == TX_MODE_SELECT) {
pc->prob_tx[0] = vp9_read_literal(&header_bc, 8);
pc->prob_tx[1] = vp9_read_literal(&header_bc, 8);
pc->prob_tx[2] = vp9_read_literal(&header_bc, 8);
}
} }
pc->filter_type = (LOOPFILTERTYPE) vp9_read_bit(&header_bc); pc->filter_type = (LOOPFILTERTYPE) vp9_read_bit(&header_bc);
pc->filter_level = vp9_read_literal(&header_bc, 6); pc->filter_level = vp9_read_literal(&header_bc, 6);
pc->sharpness_level = vp9_read_literal(&header_bc, 3); pc->sharpness_level = vp9_read_literal(&header_bc, 3);
......
...@@ -51,9 +51,9 @@ void vp9_dequant_dc_idct_add_y_block_4x4_inplace_c(int16_t *q, ...@@ -51,9 +51,9 @@ void vp9_dequant_dc_idct_add_y_block_4x4_inplace_c(int16_t *q,
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) { for (j = 0; j < 4; j++) {
if (*eobs++ > 1) if (*eobs++ > 1)
xd->dc_idct_add(q, dq, dst, dst, stride, stride, dc[0]); xd->dc_itxm_add(q, dq, dst, dst, stride, stride, dc[0]);
else else
xd->dc_only_idct_add(dc[0], dst, dst, stride, stride); xd->dc_only_itxm_add(dc[0], dst, dst, stride, stride);
q += 16; q += 16;
dst += 4; dst += 4;
...@@ -143,9 +143,9 @@ void vp9_dequant_idct_add_uv_block_4x4_inplace_c(int16_t *q, const int16_t *dq, ...@@ -143,9 +143,9 @@ void vp9_dequant_idct_add_uv_block_4x4_inplace_c(int16_t *q, const int16_t *dq,
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
if (*eobs++ > 1) { if (*eobs++ > 1) {
xd->idct_add(q, dq, dstu, dstu, stride, stride); xd->itxm_add(q, dq, dstu, dstu, stride, stride);
} else { } else {
xd->dc_only_idct_add(q[0]*dq[0], dstu, dstu, stride, stride); xd->dc_only_itxm_add(q[0]*dq[0], dstu, dstu, stride, stride);
((int *)q)[0] = 0; ((int *)q)[0] = 0;
} }
...@@ -159,9 +159,9 @@ void vp9_dequant_idct_add_uv_block_4x4_inplace_c(int16_t *q, const int16_t *dq, ...@@ -159,9 +159,9 @@ void vp9_dequant_idct_add_uv_block_4x4_inplace_c(int16_t *q, const int16_t *dq,
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
if (*eobs++ > 1) { if (*eobs++ > 1) {
xd->idct_add(q, dq, dstv, dstv, stride, stride); xd->itxm_add(q, dq, dstv, dstv, stride, stride);
} else { } else {
xd->dc_only_idct_add(q[0]*dq[0], dstv, dstv, stride, stride); xd->dc_only_itxm_add(q[0]*dq[0], dstv, dstv, stride, stride);
((int *)q)[0] = 0; ((int *)q)[0] = 0;
} }
......
...@@ -1667,7 +1667,13 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, ...@@ -1667,7 +1667,13 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
vp9_write_literal(&header_bc, pc->sb64_coded, 8); vp9_write_literal(&header_bc, pc->sb64_coded, 8);
pc->sb32_coded = get_binary_prob(cpi->sb32_count[0], cpi->sb32_count[1]); pc->sb32_coded = get_binary_prob(cpi->sb32_count[0], cpi->sb32_count[1]);
vp9_write_literal(&header_bc, pc->sb32_coded, 8); vp9_write_literal(&header_bc, pc->sb32_coded, 8);
#if CONFIG_LOSSLESS
vp9_write_bit(&header_bc, cpi->oxcf.lossless);
if (cpi->oxcf.lossless) {
pc->txfm_mode = ONLY_4X4;
}
else
#endif
{ {
if (pc->txfm_mode == TX_MODE_SELECT) { if (pc->txfm_mode == TX_MODE_SELECT) {
pc->prob_tx[0] = get_prob(cpi->txfm_count_32x32p[TX_4X4] + pc->prob_tx[0] = get_prob(cpi->txfm_count_32x32p[TX_4X4] +
......
...@@ -169,14 +169,14 @@ typedef struct macroblock { ...@@ -169,14 +169,14 @@ typedef struct macroblock {
PICK_MODE_CONTEXT sb32_context[4]; PICK_MODE_CONTEXT sb32_context[4];
PICK_MODE_CONTEXT sb64_context; PICK_MODE_CONTEXT sb64_context;
void (*vp9_short_fdct4x4)(int16_t *input, int16_t *output, int pitch); void (*fwd_txm4x4)(int16_t *input, int16_t *output, int pitch);
void (*vp9_short_fdct8x4)(int16_t *input, int16_t *output, int pitch); void (*fwd_txm8x4)(int16_t *input, int16_t *output, int pitch);
void (*short_walsh4x4)(int16_t *input, int16_t *output, int pitch); void (*fwd_2ndtxm4x4)(int16_t *input, int16_t *output, int pitch);
void (*fwd_txm8x8)(int16_t *input, int16_t *output, int pitch);
void (*fwd_txm16x16)(int16_t *input, int16_t *output, int pitch);
void (*fwd_2ndtxm2x2)(int16_t *input, int16_t *output, int pitch);
void (*quantize_b_4x4)(BLOCK *b, BLOCKD *d); void (*quantize_b_4x4)(BLOCK *b, BLOCKD *d);
void (*quantize_b_4x4_pair)(BLOCK *b1, BLOCK *b2, BLOCKD *d0, BLOCKD *d1); void (*quantize_b_4x4_pair)(BLOCK *b1, BLOCK *b2, BLOCKD *d0, BLOCKD *d1);
void (*vp9_short_fdct8x8)(int16_t *input, int16_t *output, int pitch);
void (*vp9_short_fdct16x16)(int16_t *input, int16_t *output, int pitch);
void (*short_fhaar2x2)(int16_t *input, int16_t *output, int pitch);
void (*quantize_b_16x16)(BLOCK *b, BLOCKD *d); void (*quantize_b_16x16)(BLOCK *b, BLOCKD *d);
void (*quantize_b_8x8)(BLOCK *b, BLOCKD *d); void (*quantize_b_8x8)(BLOCK *b, BLOCKD *d);
void (*quantize_b_2x2)(BLOCK *b, BLOCKD *d); void (*quantize_b_2x2)(BLOCK *b, BLOCKD *d);
......
...@@ -58,7 +58,7 @@ void vp9_encode_intra4x4block(MACROBLOCK *x, int ib) { ...@@ -58,7 +58,7 @@ void vp9_encode_intra4x4block(MACROBLOCK *x, int ib) {
vp9_ht_quantize_b_4x4(be, b, tx_type); vp9_ht_quantize_b_4x4(be, b, tx_type);
vp9_ihtllm(b->dqcoeff, b->diff, 32, tx_type, 4, b->eob); vp9_ihtllm(b->dqcoeff, b->diff, 32, tx_type, 4, b->eob);
} else { } else {
x->vp9_short_fdct4x4(be->src_diff, be->coeff, 32); x->fwd_txm4x4(be->src_diff, be->coeff, 32);
x->quantize_b_4x4(be, b) ; x->quantize_b_4x4(be, b) ;
vp9_inverse_transform_b_4x4(&x->e_mbd, ib, 32); vp9_inverse_transform_b_4x4(&x->e_mbd, ib, 32);
} }
...@@ -161,7 +161,7 @@ void vp9_encode_intra8x8(MACROBLOCK *x, int ib) { ...@@ -161,7 +161,7 @@ void vp9_encode_intra8x8(MACROBLOCK *x, int ib) {
tx_type, 8, xd->block[idx].eob); tx_type, 8, xd->block[idx].eob);
#endif #endif
} else { } else {
x->vp9_short_fdct8x8(be->src_diff, (x->block + idx)->coeff, 32); x->fwd_txm8x8(be->src_diff, (x->block + idx)->coeff, 32);
x->quantize_b_8x8(x->block + idx, xd->block + idx); x->quantize_b_8x8(x->block + idx, xd->block + idx);
vp9_short_idct8x8(xd->block[idx].dqcoeff, xd->block[ib].diff, 32); vp9_short_idct8x8(xd->block[idx].dqcoeff, xd->block[ib].diff, 32);
} }
...@@ -175,13 +175,13 @@ void vp9_encode_intra8x8(MACROBLOCK *x, int ib) { ...@@ -175,13 +175,13 @@ void vp9_encode_intra8x8(MACROBLOCK *x, int ib) {
vp9_ht_quantize_b_4x4(be, b, tx_type); vp9_ht_quantize_b_4x4(be, b, tx_type);
vp9_ihtllm(b->dqcoeff, b->diff, 32, tx_type, 4, b->eob); vp9_ihtllm(b->dqcoeff, b->diff, 32, tx_type, 4, b->eob);
} else if (!(i & 1) && get_tx_type_4x4(xd, b + 1) == DCT_DCT) { } else if (!(i & 1) && get_tx_type_4x4(xd, b + 1) == DCT_DCT) {
x->vp9_short_fdct8x4(be->src_diff, be->coeff, 32); x->fwd_txm8x4(be->src_diff, be->coeff, 32);
x->quantize_b_4x4_pair(be, be + 1, b, b + 1); x->quantize_b_4x4_pair(be, be + 1, b, b + 1);
vp9_inverse_transform_b_4x4(xd, ib + iblock[i], 32); vp9_inverse_transform_b_4x4(xd, ib + iblock[i], 32);
vp9_inverse_transform_b_4x4(xd, ib + iblock[i] + 1, 32); vp9_inverse_transform_b_4x4(xd, ib + iblock[i] + 1, 32);
i++; i++;
} else { } else {
x->vp9_short_fdct4x4(be->src_diff, be->coeff, 32); x->fwd_txm4x4(be->src_diff, be->coeff, 32);
x->quantize_b_4x4(be, b); x->quantize_b_4x4(be, b);
vp9_inverse_transform_b_4x4(xd, ib + iblock[i], 32); vp9_inverse_transform_b_4x4(xd, ib + iblock[i], 32);
} }
...@@ -214,7 +214,7 @@ static void encode_intra_uv4x4(MACROBLOCK *x, int ib, ...@@ -214,7 +214,7 @@ static void encode_intra_uv4x4(MACROBLOCK *x, int ib,
vp9_subtract_b(be, b, 8); vp9_subtract_b(be, b, 8);
x->vp9_short_fdct4x4(be->src_diff, be->coeff, 16); x->fwd_txm4x4(be->src_diff, be->coeff, 16);
x->quantize_b_4x4(be, b); x->quantize_b_4x4(be, b);
vp9_inverse_transform_b_4x4(&x->e_mbd, ib, 16);