summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2014-02-28 10:49:11 -0800
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2014-02-28 10:49:11 -0800
commit9d0d6d1945d69af9d8376a6c3e65340a79a70052 (patch)
tree240030ec459e1dc2a87e93885155374e67937170 /vp9
parent761eef0310295b006648c1313bea2a839fe8aabe (diff)
parent40a65cd1e56b1121386e7fd5c3e169fc610ff34e (diff)
downloadlibvpx-9d0d6d1945d69af9d8376a6c3e65340a79a70052.tar
libvpx-9d0d6d1945d69af9d8376a6c3e65340a79a70052.tar.gz
libvpx-9d0d6d1945d69af9d8376a6c3e65340a79a70052.tar.bz2
libvpx-9d0d6d1945d69af9d8376a6c3e65340a79a70052.zip
Merge "Explicit lossless handling in rd_pick_intra4x4block()."
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_rdopt.c77
1 files changed, 36 insertions, 41 deletions
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index f7577e174..7cf1bdf06 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -36,6 +36,7 @@
#include "./vp9_rtcd.h"
#include "vp9/common/vp9_mvref_common.h"
#include "vp9/common/vp9_common.h"
+#include "vp9/common/vp9_idct.h"
/* Factor to weigh the rate for switchable interp filters */
#define SWITCHABLE_INTERP_RATE_FACTOR 1
@@ -1037,10 +1038,9 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib,
int64_t *bestdistortion,
BLOCK_SIZE bsize, int64_t rd_thresh) {
MB_PREDICTION_MODE mode;
- MACROBLOCKD *xd = &x->e_mbd;
+ MACROBLOCKD *const xd = &x->e_mbd;
int64_t best_rd = rd_thresh;
- int rate = 0;
- int64_t distortion;
+
struct macroblock_plane *p = &x->plane[0];
struct macroblockd_plane *pd = &xd->plane[0];
const int src_stride = p->src.stride;
@@ -1049,8 +1049,6 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib,
src_stride)];
uint8_t *dst_init = &pd->dst.buf[raster_block_offset(BLOCK_8X8, ib,
dst_stride)];
- int16_t *src_diff, *coeff;
-
ENTROPY_CONTEXT ta[2], tempa[2];
ENTROPY_CONTEXT tl[2], templ[2];
@@ -1068,6 +1066,8 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib,
for (mode = DC_PRED; mode <= TM_PRED; ++mode) {
int64_t this_rd;
int ratey = 0;
+ int64_t distortion = 0;
+ int rate = bmode_costs[mode];
if (!(cpi->sf.intra_y_mode_mask[TX_4X4] & (1 << mode)))
continue;
@@ -1079,55 +1079,50 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib,
continue;
}
- rate = bmode_costs[mode];
- distortion = 0;
-
vpx_memcpy(tempa, ta, sizeof(ta));
vpx_memcpy(templ, tl, sizeof(tl));
for (idy = 0; idy < num_4x4_blocks_high; ++idy) {
for (idx = 0; idx < num_4x4_blocks_wide; ++idx) {
- int64_t ssz;
- const scan_order *so;
- const uint8_t *src = src_init + idx * 4 + idy * 4 * src_stride;
- uint8_t *dst = dst_init + idx * 4 + idy * 4 * dst_stride;
const int block = ib + idy * 2 + idx;
- TX_TYPE tx_type;
+ const uint8_t *const src = &src_init[idx * 4 + idy * 4 * src_stride];
+ uint8_t *const dst = &dst_init[idx * 4 + idy * 4 * dst_stride];
+ int16_t *const src_diff = raster_block_offset_int16(BLOCK_8X8, block,
+ p->src_diff);
+ int16_t *const coeff = BLOCK_OFFSET(x->plane[0].coeff, block);
xd->mi_8x8[0]->bmi[block].as_mode = mode;
- src_diff = raster_block_offset_int16(BLOCK_8X8, block, p->src_diff);
- coeff = BLOCK_OFFSET(x->plane[0].coeff, block);
vp9_predict_intra_block(xd, block, 1,
TX_4X4, mode,
x->skip_encode ? src : dst,
x->skip_encode ? src_stride : dst_stride,
dst, dst_stride, idx, idy, 0);
- vp9_subtract_block(4, 4, src_diff, 8,
- src, src_stride,
- dst, dst_stride);
-
- tx_type = get_tx_type_4x4(PLANE_TYPE_Y, xd, block);
- so = &vp9_scan_orders[TX_4X4][tx_type];
-
- if (tx_type != DCT_DCT)
+ vp9_subtract_block(4, 4, src_diff, 8, src, src_stride, dst, dst_stride);
+
+ if (xd->lossless) {
+ const scan_order *so = &vp9_default_scan_orders[TX_4X4];
+ vp9_fwht4x4(src_diff, coeff, 8);
+ vp9_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
+ ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
+ so->scan, so->neighbors);
+ if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd)
+ goto next;
+ vp9_iwht4x4_add(BLOCK_OFFSET(pd->dqcoeff, block), dst, dst_stride,
+ p->eobs[block]);
+ } else {
+ int64_t unused;
+ const TX_TYPE tx_type = get_tx_type_4x4(PLANE_TYPE_Y, xd, block);
+ const scan_order *so = &vp9_scan_orders[TX_4X4][tx_type];
vp9_fht4x4(src_diff, coeff, 8, tx_type);
- else
- x->fwd_txm4x4(src_diff, coeff, 8);
-
- vp9_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
-
- ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
- so->scan, so->neighbors);
- distortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, block),
- 16, &ssz) >> 2;
- if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd)
- goto next;
-
- if (tx_type != DCT_DCT)
- vp9_iht4x4_16_add(BLOCK_OFFSET(pd->dqcoeff, block),
- dst, pd->dst.stride, tx_type);
- else
- xd->itxm_add(BLOCK_OFFSET(pd->dqcoeff, block), dst, pd->dst.stride,
- 16);
+ vp9_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
+ ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
+ so->scan, so->neighbors);
+ distortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, block),
+ 16, &unused) >> 2;
+ if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd)
+ goto next;
+ vp9_iht4x4_add(tx_type, BLOCK_OFFSET(pd->dqcoeff, block),
+ dst, dst_stride, p->eobs[block]);
+ }
}
}