diff options
author | Dmitry Kovalev <dkovalev@google.com> | 2013-08-07 15:33:17 -0700 |
---|---|---|
committer | Dmitry Kovalev <dkovalev@google.com> | 2013-08-07 15:33:17 -0700 |
commit | 8db2675b97f2a9c5600f533093a5df3dcc409d86 (patch) | |
tree | e9ce95631e629ae6fde5ee5ff425c0b96baa671b /vp9/encoder/vp9_rdopt.c | |
parent | 78182538d64d2e919c2729fd7f10dd77ded27bec (diff) | |
download | libvpx-8db2675b97f2a9c5600f533093a5df3dcc409d86.tar libvpx-8db2675b97f2a9c5600f533093a5df3dcc409d86.tar.gz libvpx-8db2675b97f2a9c5600f533093a5df3dcc409d86.tar.bz2 libvpx-8db2675b97f2a9c5600f533093a5df3dcc409d86.zip |
Adding ss_size_lookup table.
Removing the old one bsize_from_dim_lookup. Now we have a way to determine
block size for plane using its subsampling values (ss_size_lookup). And
then we can find the number of pixels in the block (num_pels_log2_lookup).
Change-Id: I6fc981da2ae093de81741d3d78eaefed11015db9
Diffstat (limited to 'vp9/encoder/vp9_rdopt.c')
-rw-r--r-- | vp9/encoder/vp9_rdopt.c | 98 |
1 files changed, 43 insertions, 55 deletions
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 90d35f86a..3cc526d03 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -277,16 +277,6 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int qindex) { } } -static INLINE BLOCK_SIZE_TYPE get_block_size(int bwl, int bhl) { - return bsize_from_dim_lookup[bwl][bhl]; -} - -static BLOCK_SIZE_TYPE get_plane_block_size(BLOCK_SIZE_TYPE bsize, - struct macroblockd_plane *pd) { - return get_block_size(plane_block_width_log2by4(bsize, pd), - plane_block_height_log2by4(bsize, pd)); -} - static INLINE void linear_interpolate2(double x, int ntab, int inv_step, const double *tab1, const double *tab2, double *v1, double *v2) { @@ -399,18 +389,14 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE_TYPE bsize, for (i = 0; i < MAX_MB_PLANE; ++i) { struct macroblock_plane *const p = &x->plane[i]; struct macroblockd_plane *const pd = &xd->plane[i]; - - // TODO(dkovalev) the same code in get_plane_block_size - const int bwl = plane_block_width_log2by4(bsize, pd); - const int bhl = plane_block_height_log2by4(bsize, pd); - const BLOCK_SIZE_TYPE bs = get_block_size(bwl, bhl); + const BLOCK_SIZE_TYPE bs = get_plane_block_size(bsize, pd); unsigned int sse; int rate; int64_t dist; (void) cpi->fn_ptr[bs].vf(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, &sse); // sse works better than var, since there is no dc prediction used - model_rd_from_var_lapndz(sse, 16 << (bwl + bhl), + model_rd_from_var_lapndz(sse, 1 << num_pels_log2_lookup[bs], pd->dequant[1] >> 3, &rate, &dist); rate_sum += rate; @@ -630,44 +616,46 @@ static void rate_block(int plane, int block, BLOCK_SIZE_TYPE bsize, // with that of luma component. this function should be deprecated afterwards. static int rdcost_plane(VP9_COMMON * const cm, MACROBLOCK *x, int plane, BLOCK_SIZE_TYPE bsize, TX_SIZE tx_size) { - MACROBLOCKD * const xd = &x->e_mbd; - const int bwl = plane_block_width_log2by4(bsize, &xd->plane[plane]); - const int bhl = plane_block_height_log2by4(bsize, &xd->plane[plane]); - const int bw = 1 << bwl, bh = 1 << bhl; + MACROBLOCKD *const xd = &x->e_mbd; + struct macroblockd_plane *pd = &xd->plane[plane]; + const BLOCK_SIZE_TYPE bs = get_plane_block_size(bsize, pd); + const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bs]; + const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bs]; int i; - struct rdcost_block_args args = { cm, x, { 0 }, { 0 }, tx_size, bw, bh, - 0, 0, 0, INT64_MAX, 0 }; + struct rdcost_block_args args = { cm, x, { 0 }, { 0 }, tx_size, + num_4x4_blocks_wide, num_4x4_blocks_high, + 0, 0, 0, INT64_MAX, 0 }; switch (tx_size) { case TX_4X4: - vpx_memcpy(&args.t_above, xd->plane[plane].above_context, - sizeof(ENTROPY_CONTEXT) * bw); - vpx_memcpy(&args.t_left, xd->plane[plane].left_context, - sizeof(ENTROPY_CONTEXT) * bh); + vpx_memcpy(&args.t_above, pd->above_context, + sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide); + vpx_memcpy(&args.t_left, pd->left_context, + sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high); args.scan = vp9_default_scan_4x4; args.nb = vp9_default_scan_4x4_neighbors; break; case TX_8X8: - for (i = 0; i < bw; i += 2) - args.t_above[i] = !!*(uint16_t *)&xd->plane[plane].above_context[i]; - for (i = 0; i < bh; i += 2) - args.t_left[i] = !!*(uint16_t *)&xd->plane[plane].left_context[i]; + for (i = 0; i < num_4x4_blocks_wide; i += 2) + args.t_above[i] = !!*(uint16_t *)&pd->above_context[i]; + for (i = 0; i < num_4x4_blocks_high; i += 2) + args.t_left[i] = !!*(uint16_t *)&pd->left_context[i]; args.scan = vp9_default_scan_8x8; args.nb = vp9_default_scan_8x8_neighbors; break; case TX_16X16: - for (i = 0; i < bw; i += 4) - args.t_above[i] = !!*(uint32_t *)&xd->plane[plane].above_context[i]; - for (i = 0; i < bh; i += 4) - args.t_left[i] = !!*(uint32_t *)&xd->plane[plane].left_context[i]; + for (i = 0; i < num_4x4_blocks_wide; i += 4) + args.t_above[i] = !!*(uint32_t *)&pd->above_context[i]; + for (i = 0; i < num_4x4_blocks_high; i += 4) + args.t_left[i] = !!*(uint32_t *)&pd->left_context[i]; args.scan = vp9_default_scan_16x16; args.nb = vp9_default_scan_16x16_neighbors; break; case TX_32X32: - for (i = 0; i < bw; i += 8) - args.t_above[i] = !!*(uint64_t *)&xd->plane[plane].above_context[i]; - for (i = 0; i < bh; i += 8) - args.t_left[i] = !!*(uint64_t *)&xd->plane[plane].left_context[i]; + for (i = 0; i < num_4x4_blocks_wide; i += 8) + args.t_above[i] = !!*(uint64_t *)&pd->above_context[i]; + for (i = 0; i < num_4x4_blocks_high; i += 8) + args.t_left[i] = !!*(uint64_t *)&pd->left_context[i]; args.scan = vp9_default_scan_32x32; args.nb = vp9_default_scan_32x32_neighbors; break; @@ -696,11 +684,10 @@ static int64_t block_error_sbuv(MACROBLOCK *x, BLOCK_SIZE_TYPE bsize, *sse = 0; for (plane = 1; plane < MAX_MB_PLANE; plane++) { - struct macroblockd_plane *p = &x->e_mbd.plane[plane]; - const int bwl = plane_block_width_log2by4(bsize, p); - const int bhl = plane_block_height_log2by4(bsize, p); - sum += vp9_block_error(x->plane[plane].coeff, x->e_mbd.plane[plane].dqcoeff, - 16 << (bwl + bhl), &this_sse); + struct macroblockd_plane *pd = &x->e_mbd.plane[plane]; + const BLOCK_SIZE_TYPE bs = get_plane_block_size(bsize, pd); + sum += vp9_block_error(x->plane[plane].coeff, pd->dqcoeff, + 1 << num_pels_log2_lookup[bs], &this_sse); *sse += this_sse; } *sse >>= shift; @@ -744,42 +731,43 @@ static void super_block_yrd_for_txfm(VP9_COMMON *const cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize, TX_SIZE tx_size) { MACROBLOCKD *const xd = &x->e_mbd; struct macroblockd_plane *const pd = &xd->plane[0]; - const int bwl = plane_block_width_log2by4(bsize, pd); - const int bhl = plane_block_height_log2by4(bsize, pd); - const int bw = 1 << bwl, bh = 1 << bhl; + const BLOCK_SIZE_TYPE bs = get_plane_block_size(bsize, pd); + const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bs]; + const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bs]; int i; - struct rdcost_block_args args = { cm, x, { 0 }, { 0 }, tx_size, bw, bh, + struct rdcost_block_args args = { cm, x, { 0 }, { 0 }, tx_size, + num_4x4_blocks_wide, num_4x4_blocks_high, 0, 0, 0, ref_best_rd, 0 }; xd->mode_info_context->mbmi.txfm_size = tx_size; switch (tx_size) { case TX_4X4: vpx_memcpy(&args.t_above, pd->above_context, - sizeof(ENTROPY_CONTEXT) * bw); + sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide); vpx_memcpy(&args.t_left, pd->left_context, - sizeof(ENTROPY_CONTEXT) * bh); + sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high); get_scan_nb_4x4(get_tx_type_4x4(PLANE_TYPE_Y_WITH_DC, xd, 0), &args.scan, &args.nb); break; case TX_8X8: - for (i = 0; i < bw; i += 2) + for (i = 0; i < num_4x4_blocks_wide; i += 2) args.t_above[i] = !!*(uint16_t *)&pd->above_context[i]; - for (i = 0; i < bh; i += 2) + for (i = 0; i < num_4x4_blocks_high; i += 2) args.t_left[i] = !!*(uint16_t *)&pd->left_context[i]; get_scan_nb_8x8(get_tx_type_8x8(PLANE_TYPE_Y_WITH_DC, xd), &args.scan, &args.nb); break; case TX_16X16: - for (i = 0; i < bw; i += 4) + for (i = 0; i < num_4x4_blocks_wide; i += 4) args.t_above[i] = !!*(uint32_t *)&pd->above_context[i]; - for (i = 0; i < bh; i += 4) + for (i = 0; i < num_4x4_blocks_high; i += 4) args.t_left[i] = !!*(uint32_t *)&pd->left_context[i]; get_scan_nb_16x16(get_tx_type_16x16(PLANE_TYPE_Y_WITH_DC, xd), &args.scan, &args.nb); break; case TX_32X32: - for (i = 0; i < bw; i += 8) + for (i = 0; i < num_4x4_blocks_wide; i += 8) args.t_above[i] = !!*(uint64_t *)&pd->above_context[i]; - for (i = 0; i < bh; i += 8) + for (i = 0; i < num_4x4_blocks_high; i += 8) args.t_left[i] = !!*(uint64_t *)&pd->left_context[i]; args.scan = vp9_default_scan_32x32; args.nb = vp9_default_scan_32x32_neighbors; |