From 2dbaa4f4f4cb52b88244d513ca6254b3301dc8c7 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Mon, 29 Apr 2013 10:37:25 -0700 Subject: [PATCH] Change above/left_context to use an 8x8 basis. Output changes slightly because of a minor bug in (at least) the sb32x16 block2above tx16x16 tables that previously existed in vp9_blockd.c. Change-Id: I624af28ac200a8322d64454cf05c79e9502968cc --- vp9/common/vp9_alloccommon.c | 20 +- vp9/common/vp9_blockd.c | 919 ------------------------------------------ vp9/common/vp9_blockd.h | 26 +- vp9/common/vp9_entropy.h | 13 +- vp9/common/vp9_onyxc_int.h | 4 +- vp9/decoder/vp9_decodframe.c | 17 +- vp9/decoder/vp9_detokenize.c | 113 ++---- vp9/encoder/vp9_encodeframe.c | 122 ++++-- vp9/encoder/vp9_encodemb.c | 161 +++----- vp9/encoder/vp9_rdopt.c | 344 ++++++---------- vp9/encoder/vp9_tokenize.c | 126 +----- vp9/vp9_common.mk | 1 - 12 files changed, 368 insertions(+), 1498 deletions(-) delete mode 100644 vp9/common/vp9_blockd.c diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c index a7dc079..a802767 100644 --- a/vp9/common/vp9_alloccommon.c +++ b/vp9/common/vp9_alloccommon.c @@ -57,19 +57,20 @@ void vp9_free_frame_buffers(VP9_COMMON *oci) { vp8_yv12_de_alloc_frame_buffer(&oci->temp_scale_frame); vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer); - vpx_free(oci->above_context); vpx_free(oci->mip); vpx_free(oci->prev_mip); vpx_free(oci->above_seg_context); - oci->above_context = 0; + vpx_free(oci->above_context[0]); + for (i = 0; i < MAX_MB_PLANE; i++) + oci->above_context[i] = 0; oci->mip = 0; oci->prev_mip = 0; oci->above_seg_context = 0; } int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) { - int i; + int i, mb_cols; // Our internal buffers are always multiples of 16 const int aligned_width = multiple16(width); @@ -137,13 +138,18 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) { oci->prev_mi = oci->prev_mip + oci->mode_info_stride + 1; - oci->above_context = - vpx_calloc(sizeof(ENTROPY_CONTEXT_PLANES) * mb_cols_aligned_to_sb(oci), 1); - - if (!oci->above_context) { + // FIXME(jkoleszar): allocate subsampled arrays for U/V once subsampling + // information is exposed at this level + mb_cols = mb_cols_aligned_to_sb(oci); + oci->above_context[0] = vpx_calloc(sizeof(ENTROPY_CONTEXT) * 12 * mb_cols, 1); + if (!oci->above_context[0]) { vp9_free_frame_buffers(oci); return 1; } + oci->above_context[1] = + oci->above_context[0] + sizeof(ENTROPY_CONTEXT) * 4 * mb_cols; + oci->above_context[2] = + oci->above_context[1] + sizeof(ENTROPY_CONTEXT) * 4 * mb_cols; oci->above_seg_context = vpx_calloc(sizeof(PARTITION_CONTEXT) * mb_cols_aligned_to_sb(oci), 1); diff --git a/vp9/common/vp9_blockd.c b/vp9/common/vp9_blockd.c deleted file mode 100644 index d06e1b2..0000000 --- a/vp9/common/vp9_blockd.c +++ /dev/null @@ -1,919 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#include "./vpx_config.h" -#include "vp9/common/vp9_blockd.h" -#include "vpx_mem/vpx_mem.h" - -const uint8_t vp9_block2left[TX_SIZE_MAX_MB][24] = { - { 0, 0, 0, 0, - 1, 1, 1, 1, - 2, 2, 2, 2, - 3, 3, 3, 3, - 4, 4, - 5, 5, - 6, 6, - 7, 7 }, - { 0, 0, 0, 0, - 0, 0, 0, 0, - 2, 2, 2, 2, - 2, 2, 2, 2, - 4, 4, - 4, 4, - 6, 6, - 6, 6 }, - { 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 }, -}; -const uint8_t vp9_block2above[TX_SIZE_MAX_MB][24] = { - { 0, 1, 2, 3, - 0, 1, 2, 3, - 0, 1, 2, 3, - 0, 1, 2, 3, - 4, 5, - 4, 5, - 6, 7, - 6, 7 }, - { 0, 0, 0, 0, - 2, 2, 2, 2, - 0, 0, 0, 0, - 2, 2, 2, 2, - 4, 4, - 4, 4, - 6, 6, - 6, 6 }, - { 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 }, -}; - -#define S(x) x + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT) - -const uint8_t vp9_block2left_sb16x32[TX_SIZE_MAX_MB][48] = { - { 0, 0, 0, 0, - 1, 1, 1, 1, - 2, 2, 2, 2, - 3, 3, 3, 3, - S(0), S(0), S(0), S(0), - S(1), S(1), S(1), S(1), - S(2), S(2), S(2), S(2), - S(3), S(3), S(3), S(3), - 4, 4, - 5, 5, - S(4), S(4), - S(5), S(5), - 6, 6, - 7, 7, - S(6), S(6), - S(7), S(7) }, - { 0, 0, 0, 0, - 0, 0, 0, 0, - 2, 2, 2, 2, - 2, 2, 2, 2, - S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), - S(2), S(2), S(2), S(2), - S(2), S(2), S(2), S(2), - 4, 4, - 4, 4, - S(4), S(4), - S(4), S(4), - 6, 6, - 6, 6, - S(6), S(6), - S(6), S(6) }, - { 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0) }, -}; -const uint8_t vp9_block2above_sb16x32[TX_SIZE_MAX_MB][48] = { - { 0, 1, 2, 3, - 0, 1, 2, 3, - 0, 1, 2, 3, - 0, 1, 2, 3, - 0, 1, 2, 3, - 0, 1, 2, 3, - 0, 1, 2, 3, - 0, 1, 2, 3, - 4, 5, - 4, 5, - 4, 5, - 4, 5, - 6, 7, - 6, 7, - 6, 7, - 6, 7 }, - { 0, 0, 0, 0, - 2, 2, 2, 2, - 0, 0, 0, 0, - 2, 2, 2, 2, - 0, 0, 0, 0, - 2, 2, 2, 2, - 0, 0, 0, 0, - 2, 2, 2, 2, - 4, 4, - 4, 4, - 4, 4, - 4, 4, - 6, 6, - 6, 6, - 6, 6, - 6, 6 }, - { 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 }, -}; - -const uint8_t vp9_block2left_sb32x16[TX_SIZE_MAX_MB][48] = { - { 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, - 5, 5, 5, 5, - 6, 6, 6, 6, - 7, 7, 7, 7 }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 4, 4, 4, 4, - 4, 4, 4, 4, - 6, 6, 6, 6, - 6, 6, 6, 6 }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 }, -}; -const uint8_t vp9_block2above_sb32x16[TX_SIZE_MAX_MB][48] = { - { 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7) }, - { 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 4, 4, 4, 4, - S(4), S(4), S(4), S(4), - 6, 6, 6, 6, - S(6), S(6), S(6), S(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -const uint8_t vp9_block2left_sb[TX_SIZE_MAX_SB][96] = { - { 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), - 4, 4, 4, 4, - 5, 5, 5, 5, - S(4), S(4), S(4), S(4), - S(5), S(5), S(5), S(5), - 6, 6, 6, 6, - 7, 7, 7, 7, - S(6), S(6), S(6), S(6), - S(7), S(7), S(7), S(7) }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - 4, 4, 4, 4, - 4, 4, 4, 4, - S(4), S(4), S(4), S(4), - S(4), S(4), S(4), S(4), - 6, 6, 6, 6, - 6, 6, 6, 6, - S(6), S(6), S(6), S(6), - S(6), S(6), S(6), S(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6 }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 }, -}; -const uint8_t vp9_block2above_sb[TX_SIZE_MAX_SB][96] = { - { 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7) }, - { 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 4, 4, 4, 4, - S(4), S(4), S(4), S(4), - 4, 4, 4, 4, - S(4), S(4), S(4), S(4), - 6, 6, 6, 6, - S(6), S(6), S(6), S(6), - 6, 6, 6, 6, - S(6), S(6), S(6), S(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6 }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -#define T(x) x + 2 * (sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT)) -#define U(x) x + 3 * (sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT)) - -const uint8_t vp9_block2left_sb32x64[TX_SIZE_MAX_SB][192] = { - { 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), - T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), - T(3), T(3), T(3), T(3), T(3), T(3), T(3), T(3), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(1), U(1), U(1), U(1), U(1), U(1), U(1), U(1), - U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), - U(3), U(3), U(3), U(3), U(3), U(3), U(3), U(3), - 4, 4, 4, 4, - 5, 5, 5, 5, - S(4), S(4), S(4), S(4), - S(5), S(5), S(5), S(5), - T(4), T(4), T(4), T(4), - T(5), T(5), T(5), T(5), - U(4), U(4), U(4), U(4), - U(5), U(5), U(5), U(5), - 6, 6, 6, 6, - 7, 7, 7, 7, - S(6), S(6), S(6), S(6), - S(7), S(7), S(7), S(7), - T(6), T(6), T(6), T(6), - T(7), T(7), T(7), T(7) }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), - T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), - U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), - 4, 4, 4, 4, - 4, 4, 4, 4, - S(4), S(4), S(4), S(4), - S(4), S(4), S(4), S(4), - T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), - U(4), U(4), U(4), U(4), - U(4), U(4), U(4), U(4), - 6, 6, 6, 6, - 6, 6, 6, 6, - S(6), S(6), S(6), S(6), - S(6), S(6), S(6), S(6), - T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6), - U(6), U(6), U(6), U(6), - U(6), U(6), U(6), U(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6, - T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0) }, -}; -const uint8_t vp9_block2above_sb32x64[TX_SIZE_MAX_SB][192] = { - { 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 4, 5, S(4), S(5), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7), - 6, 7, S(6), S(7) }, - { 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 0, 0, 0, 0, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - 4, 4, 4, 4, - S(4), S(4), S(4), S(4), - 4, 4, 4, 4, - S(4), S(4), S(4), S(4), - 4, 4, 4, 4, - S(4), S(4), S(4), S(4), - 4, 4, 4, 4, - S(4), S(4), S(4), S(4), - 6, 6, 6, 6, - S(6), S(6), S(6), S(6), - 6, 6, 6, 6, - S(6), S(6), S(6), S(6), - 6, 6, 6, 6, - S(6), S(6), S(6), S(6), - 6, 6, 6, 6, - S(6), S(6), S(6), S(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 4, 4, 4, 4, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6, - 6, 6, 6, 6 }, - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 }, -}; - -const uint8_t vp9_block2left_sb64x32[TX_SIZE_MAX_SB][192] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), - 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 5, - S(4), S(4), S(4), S(4), S(4), S(4), S(4), S(4), - S(5), S(5), S(5), S(5), S(5), S(5), S(5), S(5), - 6, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 7, - S(6), S(6), S(6), S(6), S(6), S(6), S(6), S(6), - S(7), S(7), S(7), S(7), S(7), S(7), S(7), S(7) }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - S(4), S(4), S(4), S(4), S(4), S(4), S(4), S(4), - S(4), S(4), S(4), S(4), S(4), S(4), S(4), S(4), - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - S(6), S(6), S(6), S(6), S(6), S(6), S(6), S(6), - S(6), S(6), S(6), S(6), S(6), S(6), S(6), S(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, -}; -const uint8_t vp9_block2above_sb64x32[TX_SIZE_MAX_SB][192] = { - { 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7) }, - { 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 4, 4, 4, 4, S(4), S(4), S(4), S(4), - T(4), T(4), T(4), T(4), U(4), U(4), U(4), U(4), - 4, 4, 4, 4, S(4), S(4), S(4), S(4), - T(4), T(4), T(4), T(4), U(4), U(4), U(4), U(4), - 6, 6, 6, 6, S(6), S(6), S(6), S(6), - T(6), T(6), T(6), T(6), U(6), U(6), U(6), U(6), - 6, 6, 6, 6, S(6), S(6), S(6), S(6), - T(6), T(6), T(6), T(6), U(6), U(6), U(6), U(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0) }, -}; - -const uint8_t vp9_block2left_sb64[TX_SIZE_MAX_SB][384] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), S(1), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), S(3), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), T(1), - T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), - T(3), T(3), T(3), T(3), T(3), T(3), T(3), T(3), T(3), T(3), T(3), T(3), T(3), T(3), T(3), T(3), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(1), U(1), U(1), U(1), U(1), U(1), U(1), U(1), U(1), U(1), U(1), U(1), U(1), U(1), U(1), U(1), - U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), - U(3), U(3), U(3), U(3), U(3), U(3), U(3), U(3), U(3), U(3), U(3), U(3), U(3), U(3), U(3), U(3), - 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 5, - S(4), S(4), S(4), S(4), S(4), S(4), S(4), S(4), - S(5), S(5), S(5), S(5), S(5), S(5), S(5), S(5), - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - T(5), T(5), T(5), T(5), T(5), T(5), T(5), T(5), - U(4), U(4), U(4), U(4), U(4), U(4), U(4), U(4), - U(5), U(5), U(5), U(5), U(5), U(5), U(5), U(5), - 6, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 7, - S(6), S(6), S(6), S(6), S(6), S(6), S(6), S(6), - S(7), S(7), S(7), S(7), S(7), S(7), S(7), S(7), - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6), - T(7), T(7), T(7), T(7), T(7), T(7), T(7), T(7), - U(6), U(6), U(6), U(6), U(6), U(6), U(6), U(6), - U(7), U(7), U(7), U(7), U(7), U(7), U(7), U(7) }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), - T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), T(2), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), - U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), U(2), - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - S(4), S(4), S(4), S(4), S(4), S(4), S(4), S(4), - S(4), S(4), S(4), S(4), S(4), S(4), S(4), S(4), - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - U(4), U(4), U(4), U(4), U(4), U(4), U(4), U(4), - U(4), U(4), U(4), U(4), U(4), U(4), U(4), U(4), - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - S(6), S(6), S(6), S(6), S(6), S(6), S(6), S(6), - S(6), S(6), S(6), S(6), S(6), S(6), S(6), S(6), - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6), - U(6), U(6), U(6), U(6), U(6), U(6), U(6), U(6), - U(6), U(6), U(6), U(6), U(6), U(6), U(6), U(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6 }, -}; -const uint8_t vp9_block2above_sb64[TX_SIZE_MAX_SB][384] = { - { 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 0, 1, 2, 3, S(0), S(1), S(2), S(3), T(0), T(1), T(2), T(3), U(0), U(1), U(2), U(3), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 4, 5, S(4), S(5), T(4), T(5), U(4), U(5), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7), - 6, 7, S(6), S(7), T(6), T(7), U(6), U(7) }, - { 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 0, 0, 0, 0, 2, 2, 2, 2, S(0), S(0), S(0), S(0), S(2), S(2), S(2), S(2), - T(0), T(0), T(0), T(0), T(2), T(2), T(2), T(2), U(0), U(0), U(0), U(0), U(2), U(2), U(2), U(2), - 4, 4, 4, 4, S(4), S(4), S(4), S(4), - T(4), T(4), T(4), T(4), U(4), U(4), U(4), U(4), - 4, 4, 4, 4, S(4), S(4), S(4), S(4), - T(4), T(4), T(4), T(4), U(4), U(4), U(4), U(4), - 4, 4, 4, 4, S(4), S(4), S(4), S(4), - T(4), T(4), T(4), T(4), U(4), U(4), U(4), U(4), - 4, 4, 4, 4, S(4), S(4), S(4), S(4), - T(4), T(4), T(4), T(4), U(4), U(4), U(4), U(4), - 6, 6, 6, 6, S(6), S(6), S(6), S(6), - T(6), T(6), T(6), T(6), U(6), U(6), U(6), U(6), - 6, 6, 6, 6, S(6), S(6), S(6), S(6), - T(6), T(6), T(6), T(6), U(6), U(6), U(6), U(6), - 6, 6, 6, 6, S(6), S(6), S(6), S(6), - T(6), T(6), T(6), T(6), U(6), U(6), U(6), U(6), - 6, 6, 6, 6, S(6), S(6), S(6), S(6), - T(6), T(6), T(6), T(6), U(6), U(6), U(6), U(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), S(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), U(0), - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - T(4), T(4), T(4), T(4), T(4), T(4), T(4), T(4), - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6), - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6), - T(6), T(6), T(6), T(6), T(6), T(6), T(6), T(6) }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), T(0), - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6 }, -}; -#undef U -#undef T -#undef S diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index 246aae1..8bb5a69 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -48,11 +48,6 @@ typedef enum { } PLANE_TYPE; typedef char ENTROPY_CONTEXT; -typedef struct { - ENTROPY_CONTEXT y1[4]; - ENTROPY_CONTEXT u[2]; - ENTROPY_CONTEXT v[2]; -} ENTROPY_CONTEXT_PLANES; typedef char PARTITION_CONTEXT; @@ -329,6 +324,8 @@ struct macroblockd_plane { struct buf_2d dst; struct buf_2d pre[2]; int16_t *dequant; + ENTROPY_CONTEXT *above_context; + ENTROPY_CONTEXT *left_context; }; #define BLOCK_OFFSET(x, i, n) ((x) + (i) * (n)) @@ -354,10 +351,6 @@ typedef struct macroblockd { int left_available; int right_available; - /* Y,U,V */ - ENTROPY_CONTEXT_PLANES *above_context; - ENTROPY_CONTEXT_PLANES *left_context; - // partition contexts PARTITION_CONTEXT *above_seg_context; PARTITION_CONTEXT *left_seg_context; @@ -546,21 +539,6 @@ static TX_TYPE txfm_map(B_PREDICTION_MODE bmode) { } } -extern const uint8_t vp9_block2left[TX_SIZE_MAX_MB][24]; -extern const uint8_t vp9_block2above[TX_SIZE_MAX_MB][24]; -extern const uint8_t vp9_block2left_sb[TX_SIZE_MAX_SB][96]; -extern const uint8_t vp9_block2above_sb[TX_SIZE_MAX_SB][96]; -extern const uint8_t vp9_block2left_sb64[TX_SIZE_MAX_SB][384]; -extern const uint8_t vp9_block2above_sb64[TX_SIZE_MAX_SB][384]; -extern const uint8_t vp9_block2left_sb16x32[TX_SIZE_MAX_MB][48]; -extern const uint8_t vp9_block2above_sb16x32[TX_SIZE_MAX_MB][48]; -extern const uint8_t vp9_block2left_sb32x16[TX_SIZE_MAX_MB][48]; -extern const uint8_t vp9_block2above_sb32x16[TX_SIZE_MAX_MB][48]; -extern const uint8_t vp9_block2left_sb32x64[TX_SIZE_MAX_SB][192]; -extern const uint8_t vp9_block2above_sb32x64[TX_SIZE_MAX_SB][192]; -extern const uint8_t vp9_block2left_sb64x32[TX_SIZE_MAX_SB][192]; -extern const uint8_t vp9_block2above_sb64x32[TX_SIZE_MAX_SB][192]; - #define USE_ADST_FOR_I16X16_8X8 1 #define USE_ADST_FOR_I16X16_4X4 1 #define USE_ADST_FOR_I8X8_4X4 1 diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h index 06641dc..34cf145 100644 --- a/vp9/common/vp9_entropy.h +++ b/vp9/common/vp9_entropy.h @@ -119,10 +119,15 @@ void vp9_adapt_coef_probs(struct VP9Common *); static INLINE void vp9_reset_sb_tokens_context(MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize) { /* Clear entropy contexts */ - const int bw = 1 << (b_width_log2(bsize) - 2); - const int bh = 1 << (b_height_log2(bsize) - 2); - vpx_memset(xd->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * bw); - vpx_memset(xd->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * bh); + const int bw = 1 << b_width_log2(bsize); + const int bh = 1 << b_height_log2(bsize); + int i; + for (i = 0; i < MAX_MB_PLANE; i++) { + vpx_memset(xd->plane[i].above_context, 0, + sizeof(ENTROPY_CONTEXT) * bw >> xd->plane[i].subsampling_x); + vpx_memset(xd->plane[i].left_context, 0, + sizeof(ENTROPY_CONTEXT) * bh >> xd->plane[i].subsampling_y); + } } extern const int vp9_coef_bands8x8[64]; diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index aa59053..68fed95 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -253,8 +253,8 @@ typedef struct VP9Common { int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */ /* Y,U,V */ - ENTROPY_CONTEXT_PLANES *above_context; /* row of context for each plane */ - ENTROPY_CONTEXT_PLANES left_context[4]; /* (up to) 4 contexts "" */ + ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; + ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; // partition contexts PARTITION_CONTEXT *above_seg_context; diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index a06cb0a..c037d4b 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -742,6 +742,7 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, const int bw = 1 << mi_width_log2(bsize); VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; + int i; const int mi_idx = mi_row * cm->mode_info_stride + mi_col; const YV12_BUFFER_CONFIG *dst_fb = &cm->yv12_fb[cm->new_fb_idx]; @@ -754,8 +755,12 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, xd->mode_info_context->mbmi.sb_type = bsize; xd->prev_mode_info_context = cm->prev_mi + mi_idx; - xd->above_context = cm->above_context + (mi_col >> CONFIG_SB8X8); - xd->left_context = cm->left_context + ((mi_row >> CONFIG_SB8X8) & 3); + for (i = 0; i < MAX_MB_PLANE; i++) { + xd->plane[i].above_context = cm->above_context[i] + + (mi_col * 4 >> (xd->plane[i].subsampling_x + CONFIG_SB8X8)); + xd->plane[i].left_context = cm->left_context[i] + + (((mi_row * 4 >> CONFIG_SB8X8) & 15) >> xd->plane[i].subsampling_y); + } xd->above_seg_context = cm->above_seg_context + (mi_col >> CONFIG_SB8X8); xd->left_seg_context = cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3); @@ -1297,7 +1302,7 @@ static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) { for (mi_row = pc->cur_tile_mi_row_start; mi_row < pc->cur_tile_mi_row_end; mi_row += (4 << CONFIG_SB8X8)) { // For a SB there are 2 left contexts, each pertaining to a MB row within - vpx_memset(pc->left_context, 0, sizeof(pc->left_context)); + vpx_memset(&pc->left_context, 0, sizeof(pc->left_context)); vpx_memset(pc->left_seg_context, 0, sizeof(pc->left_seg_context)); for (mi_col = pc->cur_tile_mi_col_start; mi_col < pc->cur_tile_mi_col_end; mi_col += (4 << CONFIG_SB8X8)) { @@ -1328,8 +1333,10 @@ static void decode_tiles(VP9D_COMP *pbi, pc->tile_columns = 1 << pc->log2_tile_columns; pc->tile_rows = 1 << pc->log2_tile_rows; - vpx_memset(pc->above_context, 0, - sizeof(ENTROPY_CONTEXT_PLANES) * mb_cols_aligned_to_sb(pc)); + // Note: this memset assumes above_context[0], [1] and [2] + // are allocated as part of the same buffer. + vpx_memset(pc->above_context[0], 0, sizeof(ENTROPY_CONTEXT) * 4 * + MAX_MB_PLANE * mb_cols_aligned_to_sb(pc)); vpx_memset(pc->above_seg_context, 0, sizeof(PARTITION_CONTEXT) * mb_cols_aligned_to_sb(pc)); diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c index 0a68265..3ef1e5b 100644 --- a/vp9/decoder/vp9_detokenize.c +++ b/vp9/decoder/vp9_detokenize.c @@ -106,10 +106,8 @@ DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]); static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, vp9_reader *r, int block_idx, PLANE_TYPE type, int seg_eob, int16_t *qcoeff_ptr, - TX_SIZE txfm_size, const int16_t *dq) { - ENTROPY_CONTEXT* const A0 = (ENTROPY_CONTEXT *) xd->above_context; - ENTROPY_CONTEXT* const L0 = (ENTROPY_CONTEXT *) xd->left_context; - int aidx, lidx; + TX_SIZE txfm_size, const int16_t *dq, + ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L) { ENTROPY_CONTEXT above_ec, left_ec; FRAME_CONTEXT *const fc = &dx->common.fc; int pt, c = 0, pad, default_eob; @@ -133,37 +131,14 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, vpx_memset(token_cache, UNKNOWN_TOKEN, sizeof(token_cache)); #endif - if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB64X64) { - aidx = vp9_block2above_sb64[txfm_size][block_idx]; - lidx = vp9_block2left_sb64[txfm_size][block_idx]; - } else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB64X32) { - aidx = vp9_block2above_sb64x32[txfm_size][block_idx]; - lidx = vp9_block2left_sb64x32[txfm_size][block_idx]; - } else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB32X64) { - aidx = vp9_block2above_sb32x64[txfm_size][block_idx]; - lidx = vp9_block2left_sb32x64[txfm_size][block_idx]; - } else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB32X32) { - aidx = vp9_block2above_sb[txfm_size][block_idx]; - lidx = vp9_block2left_sb[txfm_size][block_idx]; - } else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB32X16) { - aidx = vp9_block2above_sb32x16[txfm_size][block_idx]; - lidx = vp9_block2left_sb32x16[txfm_size][block_idx]; - } else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB16X32) { - aidx = vp9_block2above_sb16x32[txfm_size][block_idx]; - lidx = vp9_block2left_sb16x32[txfm_size][block_idx]; - } else { - aidx = vp9_block2above[txfm_size][block_idx]; - lidx = vp9_block2left[txfm_size][block_idx]; - } - switch (txfm_size) { default: case TX_4X4: { tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type_4x4(xd, block_idx) : DCT_DCT; scan = get_scan_4x4(tx_type); - above_ec = A0[aidx] != 0; - left_ec = L0[lidx] != 0; + above_ec = A[0] != 0; + left_ec = L[0] != 0; coef_probs = fc->coef_probs_4x4; coef_counts = fc->coef_counts_4x4; default_eob = 16; @@ -183,8 +158,8 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, scan = get_scan_8x8(tx_type); coef_probs = fc->coef_probs_8x8; coef_counts = fc->coef_counts_8x8; - above_ec = (A0[aidx] + A0[aidx + 1]) != 0; - left_ec = (L0[lidx] + L0[lidx + 1]) != 0; + above_ec = (A[0] + A[1]) != 0; + left_ec = (L[0] + L[1]) != 0; default_eob = 64; #if CONFIG_CODE_ZEROGROUP zpc_probs = &(fc->zpc_probs_8x8); @@ -202,15 +177,8 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, scan = get_scan_16x16(tx_type); coef_probs = fc->coef_probs_16x16; coef_counts = fc->coef_counts_16x16; - if (type == PLANE_TYPE_UV) { - ENTROPY_CONTEXT *A1 = (ENTROPY_CONTEXT *) (xd->above_context + 1); - ENTROPY_CONTEXT *L1 = (ENTROPY_CONTEXT *) (xd->left_context + 1); - above_ec = (A0[aidx] + A0[aidx + 1] + A1[aidx] + A1[aidx + 1]) != 0; - left_ec = (L0[lidx] + L0[lidx + 1] + L1[lidx] + L1[lidx + 1]) != 0; - } else { - above_ec = (A0[aidx] + A0[aidx + 1] + A0[aidx + 2] + A0[aidx + 3]) != 0; - left_ec = (L0[lidx] + L0[lidx + 1] + L0[lidx + 2] + L0[lidx + 3]) != 0; - } + above_ec = (A[0] + A[1] + A[2] + A[3]) != 0; + left_ec = (L[0] + L[1] + L[2] + L[3]) != 0; default_eob = 256; #if CONFIG_CODE_ZEROGROUP zpc_probs = &(fc->zpc_probs_16x16); @@ -222,25 +190,8 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd, scan = vp9_default_zig_zag1d_32x32; coef_probs = fc->coef_probs_32x32; coef_counts = fc->coef_counts_32x32; - if (type == PLANE_TYPE_UV) { - ENTROPY_CONTEXT *A1 = (ENTROPY_CONTEXT *) (xd->above_context + 1); - ENTROPY_CONTEXT *L1 = (ENTROPY_CONTEXT *) (xd->left_context + 1); - ENTROPY_CONTEXT *A2 = (ENTROPY_CONTEXT *) (xd->above_context + 2); - ENTROPY_CONTEXT *L2 = (ENTROPY_CONTEXT *) (xd->left_context + 2); - ENTROPY_CONTEXT *A3 = (ENTROPY_CONTEXT *) (xd->above_context + 3); - ENTROPY_CONTEXT *L3 = (ENTROPY_CONTEXT *) (xd->left_context + 3); - above_ec = (A0[aidx] + A0[aidx + 1] + A1[aidx] + A1[aidx + 1] + - A2[aidx] + A2[aidx + 1] + A3[aidx] + A3[aidx + 1]) != 0; - left_ec = (L0[lidx] + L0[lidx + 1] + L1[lidx] + L1[lidx + 1] + - L2[lidx] + L2[lidx + 1] + L3[lidx] + L3[lidx + 1]) != 0; - } else { - ENTROPY_CONTEXT *A1 = (ENTROPY_CONTEXT *) (xd->above_context + 1); - ENTROPY_CONTEXT *L1 = (ENTROPY_CONTEXT *) (xd->left_context + 1); - above_ec = (A0[aidx] + A0[aidx + 1] + A0[aidx + 2] + A0[aidx + 3] + - A1[aidx] + A1[aidx + 1] + A1[aidx + 2] + A1[aidx + 3]) != 0; - left_ec = (L0[lidx] + L0[lidx + 1] + L0[lidx + 2] + L0[lidx + 3] + - L1[lidx] + L1[lidx + 1] + L1[lidx + 2] + L1[lidx + 3]) != 0; - } + above_ec = (A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7]) != 0; + left_ec = (L[0] + L[1] + L[2] + L[3] + L[4] + L[5] + L[6] + L[7]) != 0; default_eob = 1024; #if CONFIG_CODE_ZEROGROUP zpc_probs = &fc->zpc_probs_32x32; @@ -381,33 +332,10 @@ SKIP_START: coef_counts[type][ref][get_coef_band(scan, txfm_size, c)] [pt][DCT_EOB_TOKEN]++; - A0[aidx] = L0[lidx] = c > 0; - if (txfm_size >= TX_8X8) { - A0[aidx + 1] = L0[lidx + 1] = A0[aidx]; - if (txfm_size >= TX_16X16) { - if (type == PLANE_TYPE_UV) { - ENTROPY_CONTEXT *A1 = (ENTROPY_CONTEXT *) (xd->above_context + 1); - ENTROPY_CONTEXT *L1 = (ENTROPY_CONTEXT *) (xd->left_context + 1); - A1[aidx] = A1[aidx + 1] = L1[lidx] = L1[lidx + 1] = A0[aidx]; - if (txfm_size >= TX_32X32) { - ENTROPY_CONTEXT *A2 = (ENTROPY_CONTEXT *) (xd->above_context + 2); - ENTROPY_CONTEXT *L2 = (ENTROPY_CONTEXT *) (xd->left_context + 2); - ENTROPY_CONTEXT *A3 = (ENTROPY_CONTEXT *) (xd->above_context + 3); - ENTROPY_CONTEXT *L3 = (ENTROPY_CONTEXT *) (xd->left_context + 3); - A2[aidx] = A2[aidx + 1] = A3[aidx] = A3[aidx + 1] = A0[aidx]; - L2[lidx] = L2[lidx + 1] = L3[lidx] = L3[lidx + 1] = A0[aidx]; - } - } else { - A0[aidx + 2] = A0[aidx + 3] = L0[lidx + 2] = L0[lidx + 3] = A0[aidx]; - if (txfm_size >= TX_32X32) { - ENTROPY_CONTEXT *A1 = (ENTROPY_CONTEXT *) (xd->above_context + 1); - ENTROPY_CONTEXT *L1 = (ENTROPY_CONTEXT *) (xd->left_context + 1); - A1[aidx] = A1[aidx + 1] = A1[aidx + 2] = A1[aidx + 3] = A0[aidx]; - L1[lidx] = L1[lidx + 1] = L1[lidx + 2] = L1[lidx + 3] = A0[aidx]; - } - } - } + for (pt = 0; pt < (1 << txfm_size); pt++) { + A[pt] = L[pt] = c > 0; } + return c; } @@ -436,11 +364,17 @@ static void decode_block(int plane, int block, const TX_SIZE ss_tx_size = ss_txfrm_size / 2; const int seg_eob = get_eob(arg->xd, segment_id, 16 << ss_txfrm_size); int16_t* const qcoeff_base = arg->xd->plane[plane].qcoeff; + const int off = block >> ss_txfrm_size; + const int mod = bw - ss_tx_size - arg->xd->plane[plane].subsampling_x; + const int aoff = (off & ((1 << mod) - 1)) << ss_tx_size; + const int loff = (off >> mod) << ss_tx_size; const int eob = decode_coefs(arg->pbi, arg->xd, arg->r, old_block_idx, arg->xd->plane[plane].plane_type, seg_eob, BLOCK_OFFSET(qcoeff_base, block, 16), - ss_tx_size, arg->xd->plane[plane].dequant); + ss_tx_size, arg->xd->plane[plane].dequant, + arg->xd->plane[plane].above_context + aoff, + arg->xd->plane[plane].left_context + loff); arg->xd->plane[plane].eobs[block] = eob; arg->eobtotal[0] += eob; @@ -461,9 +395,14 @@ static int decode_coefs_4x4(VP9D_COMP *dx, MACROBLOCKD *xd, vp9_reader *r, PLANE_TYPE type, int i, int seg_eob) { const struct plane_block_idx pb_idx = plane_block_idx(16, i); + const int mod = 2 - xd->plane[pb_idx.plane].subsampling_x; + const int aoff = pb_idx.block & ((1 << mod) - 1); + const int loff = pb_idx.block >> mod; + ENTROPY_CONTEXT *A = xd->plane[pb_idx.plane].above_context; + ENTROPY_CONTEXT *L = xd->plane[pb_idx.plane].left_context; const int c = decode_coefs(dx, xd, r, i, type, seg_eob, BLOCK_OFFSET(xd->plane[pb_idx.plane].qcoeff, pb_idx.block, 16), TX_4X4, - xd->plane[pb_idx.plane].dequant); + xd->plane[pb_idx.plane].dequant, A + aoff, L + loff); xd->plane[pb_idx.plane].eobs[pb_idx.block] = c; return c; } diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 8e524f4..6d5583b 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -574,10 +574,15 @@ static void set_offsets(VP9_COMP *cpi, const int mb_row = mi_row >> CONFIG_SB8X8; const int mb_col = mi_col >> CONFIG_SB8X8; const int idx_map = mb_row * cm->mb_cols + mb_col; + int i; // entropy context structures - xd->above_context = cm->above_context + mb_col; - xd->left_context = cm->left_context + (mb_row & 3); + for (i = 0; i < MAX_MB_PLANE; i++) { + xd->plane[i].above_context = cm->above_context[i] + + (mi_col * 4 >> (CONFIG_SB8X8 + xd->plane[i].subsampling_x)); + xd->plane[i].left_context = cm->left_context[i] + + (((mi_row * 4 >> CONFIG_SB8X8) & 15) >> xd->plane[i].subsampling_y); + } // partition contexts xd->above_seg_context = cm->above_seg_context + mb_col; @@ -983,22 +988,27 @@ static void encode_sb_row(VP9_COMP *cpi, int mi_col, pl; // Initialize the left context for the new SB row - vpx_memset(cm->left_context, 0, sizeof(cm->left_context)); + vpx_memset(&cm->left_context, 0, sizeof(cm->left_context)); vpx_memset(cm->left_seg_context, 0, sizeof(cm->left_seg_context)); // Code each SB in the row for (mi_col = cm->cur_tile_mi_col_start; mi_col < cm->cur_tile_mi_col_end; mi_col += (4 << CONFIG_SB8X8)) { - int i; + int i, p; BLOCK_SIZE_TYPE sb_partitioning[4]; int sb64_rate = 0, sb64_dist = 0; int sb64_skip = 0; - ENTROPY_CONTEXT_PLANES l[4], a[4]; + ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE]; PARTITION_CONTEXT seg_l[4], seg_a[4]; TOKENEXTRA *tp_orig = *tp; - memcpy(&a, cm->above_context + (mi_col >> CONFIG_SB8X8), sizeof(a)); - memcpy(&l, cm->left_context, sizeof(l)); + for (p = 0; p < MAX_MB_PLANE; p++) { + memcpy(a + 16 * p, cm->above_context[p] + + (mi_col * 4 >> (CONFIG_SB8X8 + xd->plane[p].subsampling_x)), + sizeof(ENTROPY_CONTEXT) * 16 >> xd->plane[p].subsampling_x); + memcpy(l + 16 * p, cm->left_context[p], + sizeof(ENTROPY_CONTEXT) * 16 >> xd->plane[p].subsampling_y); + } memcpy(&seg_a, cm->above_seg_context + (mi_col >> CONFIG_SB8X8), sizeof(seg_a)); memcpy(&seg_l, cm->left_seg_context, sizeof(seg_l)); @@ -1009,7 +1019,7 @@ static void encode_sb_row(VP9_COMP *cpi, int splitmodes_used = 0; int sb32_skip = 0; int j; - ENTROPY_CONTEXT_PLANES l2[2], a2[2]; + ENTROPY_CONTEXT l2[8 * MAX_MB_PLANE], a2[8 * MAX_MB_PLANE]; if (mi_row + y_idx >= cm->mi_rows || mi_col + x_idx >= cm->mi_cols) continue; @@ -1017,9 +1027,18 @@ static void encode_sb_row(VP9_COMP *cpi, xd->sb_index = i; /* Function should not modify L & A contexts; save and restore on exit */ - vpx_memcpy(l2, cm->left_context + (y_idx >> CONFIG_SB8X8), sizeof(l2)); - vpx_memcpy(a2, cm->above_context + ((mi_col + x_idx) >> CONFIG_SB8X8), - sizeof(a2)); + for (p = 0; p < MAX_MB_PLANE; p++) { + vpx_memcpy(l2 + 8 * p, + cm->left_context[p] + + (y_idx * 4 >> (CONFIG_SB8X8 + + xd->plane[p].subsampling_y)), + sizeof(ENTROPY_CONTEXT) * 8 >> xd->plane[p].subsampling_y); + vpx_memcpy(a2 + 8 * p, + cm->above_context[p] + + ((mi_col + x_idx) * 4 >> (CONFIG_SB8X8 + + xd->plane[p].subsampling_x)), + sizeof(ENTROPY_CONTEXT) * 8 >> xd->plane[p].subsampling_x); + } /* Encode MBs in raster order within the SB */ sb_partitioning[i] = BLOCK_SIZE_MB16X16; @@ -1052,9 +1071,18 @@ static void encode_sb_row(VP9_COMP *cpi, } /* Restore L & A coding context to those in place on entry */ - vpx_memcpy(cm->left_context + (y_idx >> CONFIG_SB8X8), l2, sizeof(l2)); - vpx_memcpy(cm->above_context + ((mi_col + x_idx) >> CONFIG_SB8X8), a2, - sizeof(a2)); + for (p = 0; p < MAX_MB_PLANE; p++) { + vpx_memcpy(cm->left_context[p] + + (y_idx * 4 >> (CONFIG_SB8X8 + + xd->plane[p].subsampling_y)), + l2 + 8 * p, + sizeof(ENTROPY_CONTEXT) * 8 >> xd->plane[p].subsampling_y); + vpx_memcpy(cm->above_context[p] + + ((mi_col + x_idx) * 4 >> (CONFIG_SB8X8 + + xd->plane[p].subsampling_x)), + a2 + 8 * p, + sizeof(ENTROPY_CONTEXT) * 8 >> xd->plane[p].subsampling_x); + } xd->left_seg_context = cm->left_seg_context + (y_idx >> CONFIG_SB8X8); xd->above_seg_context = @@ -1105,9 +1133,18 @@ static void encode_sb_row(VP9_COMP *cpi, sb_partitioning[i] = BLOCK_SIZE_SB32X16; } - vpx_memcpy(cm->left_context + (y_idx >> CONFIG_SB8X8), l2, sizeof(l2)); - vpx_memcpy(cm->above_context + ((mi_col + x_idx) >> CONFIG_SB8X8), a2, - sizeof(a2)); + for (p = 0; p < MAX_MB_PLANE; p++) { + vpx_memcpy(cm->left_context[p] + + (y_idx * 4 >> (CONFIG_SB8X8 + + xd->plane[p].subsampling_y)), + l2 + 8 * p, + sizeof(ENTROPY_CONTEXT) * 8 >> xd->plane[p].subsampling_y); + vpx_memcpy(cm->above_context[p] + + ((mi_col + x_idx) * 4 >> (CONFIG_SB8X8 + + xd->plane[p].subsampling_x)), + a2 + 8 * p, + sizeof(ENTROPY_CONTEXT) * 8 >> xd->plane[p].subsampling_x); + } } // check 16x32 @@ -1150,9 +1187,18 @@ static void encode_sb_row(VP9_COMP *cpi, sb_partitioning[i] = BLOCK_SIZE_SB16X32; } - vpx_memcpy(cm->left_context + (y_idx >> CONFIG_SB8X8), l2, sizeof(l2)); - vpx_memcpy(cm->above_context + ((mi_col + x_idx) >> CONFIG_SB8X8), a2, - sizeof(a2)); + for (p = 0; p < MAX_MB_PLANE; p++) { + vpx_memcpy(cm->left_context[p] + + (y_idx * 4 >> (CONFIG_SB8X8 + + xd->plane[p].subsampling_y)), + l2 + 8 * p, + sizeof(ENTROPY_CONTEXT) * 8 >> xd->plane[p].subsampling_y); + vpx_memcpy(cm->above_context[p] + + ((mi_col + x_idx) * 4 >> (CONFIG_SB8X8 + + xd->plane[p].subsampling_x)), + a2 + 8 * p, + sizeof(ENTROPY_CONTEXT) * 8 >> xd->plane[p].subsampling_x); + } } if (!sb32_skip && @@ -1197,8 +1243,14 @@ static void encode_sb_row(VP9_COMP *cpi, sb_partitioning[i]); } - memcpy(cm->above_context + (mi_col >> CONFIG_SB8X8), &a, sizeof(a)); - memcpy(cm->left_context, &l, sizeof(l)); + for (p = 0; p < MAX_MB_PLANE; p++) { + memcpy(cm->above_context[p] + + (mi_col * 4 >> (CONFIG_SB8X8 + xd->plane[p].subsampling_x)), + a + 16 * p, + sizeof(ENTROPY_CONTEXT) * 16 >> xd->plane[p].subsampling_x); + memcpy(cm->left_context[p], l + 16 * p, + sizeof(ENTROPY_CONTEXT) * 16 >> xd->plane[p].subsampling_y); + } memcpy(cm->above_seg_context + (mi_col >> CONFIG_SB8X8), &seg_a, sizeof(seg_a)); memcpy(cm->left_seg_context, &seg_l, sizeof(seg_l)); @@ -1244,8 +1296,14 @@ static void encode_sb_row(VP9_COMP *cpi, sb_partitioning[0] = BLOCK_SIZE_SB64X32; } - vpx_memcpy(cm->left_context, l, sizeof(l)); - vpx_memcpy(cm->above_context + (mi_col >> CONFIG_SB8X8), a, sizeof(a)); + for (p = 0; p < MAX_MB_PLANE; p++) { + memcpy(cm->above_context[p] + + (mi_col * 4 >> (CONFIG_SB8X8 + xd->plane[p].subsampling_x)), + a + 16 * p, + sizeof(ENTROPY_CONTEXT) * 16 >> xd->plane[p].subsampling_x); + memcpy(cm->left_context[p], l + 16 * p, + sizeof(ENTROPY_CONTEXT) * 16 >> xd->plane[p].subsampling_y); + } } // check 32x64 @@ -1284,8 +1342,14 @@ static void encode_sb_row(VP9_COMP *cpi, sb_partitioning[0] = BLOCK_SIZE_SB32X64; } - vpx_memcpy(cm->left_context, l, sizeof(l)); - vpx_memcpy(cm->above_context + (mi_col >> CONFIG_SB8X8), a, sizeof(a)); + for (p = 0; p < MAX_MB_PLANE; p++) { + memcpy(cm->above_context[p] + + (mi_col * 4 >> (CONFIG_SB8X8 + xd->plane[p].subsampling_x)), + a + 16 * p, + sizeof(ENTROPY_CONTEXT) * 16 >> xd->plane[p].subsampling_x); + memcpy(cm->left_context[p], l + 16 * p, + sizeof(ENTROPY_CONTEXT) * 16 >> xd->plane[p].subsampling_y); + } } if (!sb64_skip && @@ -1368,8 +1432,10 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) { vp9_zero(cpi->interintra_select_count); #endif - vpx_memset(cm->above_context, 0, - sizeof(ENTROPY_CONTEXT_PLANES) * mb_cols_aligned_to_sb(cm)); + // Note: this memset assumes above_context[0], [1] and [2] + // are allocated as part of the same buffer. + vpx_memset(cm->above_context[0], 0, sizeof(ENTROPY_CONTEXT) * 4 * + MAX_MB_PLANE * mb_cols_aligned_to_sb(cm)); vpx_memset(cm->above_seg_context, 0, sizeof(PARTITION_CONTEXT) * mb_cols_aligned_to_sb(cm)); } diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 0823316..0cb1ae9 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -486,25 +486,18 @@ static void optimize_b(VP9_COMMON *const cm, void vp9_optimize_sby_32x32(VP9_COMMON *const cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { + MACROBLOCKD *const xd = &x->e_mbd; + ENTROPY_CONTEXT *a = xd->plane[0].above_context; + ENTROPY_CONTEXT *l = xd->plane[0].left_context; const int bwl = b_width_log2(bsize) - 3, bw = 1 << bwl; const int bh = 1 << (b_height_log2(bsize) - 3); ENTROPY_CONTEXT ta[2], tl[2]; int n; - for (n = 0; n < bw; n++) { - ENTROPY_CONTEXT *a = - (ENTROPY_CONTEXT *) (x->e_mbd.above_context + n * 2 + 0); - ENTROPY_CONTEXT *a1 = - (ENTROPY_CONTEXT *) (x->e_mbd.above_context + n * 2 + 1); - ta[n] = (a[0] + a[1] + a[2] + a[3] + a1[0] + a1[1] + a1[2] + a1[3]) != 0; - } - for (n = 0; n < bh; n++) { - ENTROPY_CONTEXT *l = - (ENTROPY_CONTEXT *) (x->e_mbd.left_context + n * 2); - ENTROPY_CONTEXT *l1 = - (ENTROPY_CONTEXT *) (x->e_mbd.left_context + n * 2 + 1); - tl[n] = (l[0] + l[1] + l[2] + l[3] + l1[0] + l1[1] + l1[2] + l1[3]) != 0; - } + for (n = 0; n < bw; n++, a += 8) + ta[n] = (a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7]) != 0; + for (n = 0; n < bh; n++, l += 8) + tl[n] = (l[0] + l[1] + l[2] + l[3] + l[4] + l[5] + l[6] + l[7]) != 0; for (n = 0; n < bw * bh; n++) { const int x_idx = n & (bw - 1), y_idx = n >> bwl; @@ -516,19 +509,19 @@ void vp9_optimize_sby_32x32(VP9_COMMON *const cm, MACROBLOCK *x, void vp9_optimize_sby_16x16(VP9_COMMON *const cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { + MACROBLOCKD *const xd = &x->e_mbd; + ENTROPY_CONTEXT *a = xd->plane[0].above_context; + ENTROPY_CONTEXT *l = xd->plane[0].left_context; const int bwl = b_width_log2(bsize) - 2, bw = 1 << bwl; const int bh = 1 << (b_height_log2(bsize) - 2); ENTROPY_CONTEXT ta[4], tl[4]; int n; - for (n = 0; n < bw; n++) { - ENTROPY_CONTEXT *a = (ENTROPY_CONTEXT *) (x->e_mbd.above_context + n); + for (n = 0; n < bw; n++, a += 4) ta[n] = (a[0] + a[1] + a[2] + a[3]) != 0; - } - for (n = 0; n < bh; n++) { - ENTROPY_CONTEXT *l = (ENTROPY_CONTEXT *) (x->e_mbd.left_context + n); + for (n = 0; n < bh; n++, l += 4) tl[n] = (l[0] + l[1] + l[2] + l[3]) != 0; - } + for (n = 0; n < bw * bh; n++) { const int x_idx = n & (bw - 1), y_idx = n >> bwl; @@ -539,23 +532,18 @@ void vp9_optimize_sby_16x16(VP9_COMMON *const cm, MACROBLOCK *x, void vp9_optimize_sby_8x8(VP9_COMMON *const cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { + MACROBLOCKD *const xd = &x->e_mbd; + ENTROPY_CONTEXT *a = xd->plane[0].above_context; + ENTROPY_CONTEXT *l = xd->plane[0].left_context; const int bwl = b_width_log2(bsize) - 1, bw = 1 << bwl; const int bh = 1 << (b_height_log2(bsize) - 1); ENTROPY_CONTEXT ta[8], tl[8]; int n; - for (n = 0; n < bw; n += 2) { - ENTROPY_CONTEXT *a = - (ENTROPY_CONTEXT *) (x->e_mbd.above_context + (n >> 1)); - ta[n + 0] = (a[0] + a[1]) != 0; - ta[n + 1] = (a[2] + a[3]) != 0; - } - for (n = 0; n < bh; n += 2) { - ENTROPY_CONTEXT *l = - (ENTROPY_CONTEXT *) (x->e_mbd.left_context + (n >> 1)); - tl[n + 0] = (l[0] + l[1]) != 0; - tl[n + 1] = (l[2] + l[3]) != 0; - } + for (n = 0; n < bw; n++, a += 2) + ta[n] = (a[0] + a[1]) != 0; + for (n = 0; n < bh; n++, l += 2) + tl[n] = (l[0] + l[1]) != 0; for (n = 0; n < bw * bh; n++) { const int x_idx = n & (bw - 1), y_idx = n >> bwl; @@ -567,17 +555,14 @@ void vp9_optimize_sby_8x8(VP9_COMMON *const cm, MACROBLOCK *x, void vp9_optimize_sby_4x4(VP9_COMMON *const cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { + MACROBLOCKD *const xd = &x->e_mbd; int bwl = b_width_log2(bsize), bw = 1 << bwl; int bh = 1 << b_height_log2(bsize); ENTROPY_CONTEXT ta[16], tl[16]; int n; - for (n = 0; n < bw; n += 4) - vpx_memcpy(&ta[n], x->e_mbd.above_context + (n >> 2), - sizeof(ENTROPY_CONTEXT) * 4); - for (n = 0; n < bh; n += 4) - vpx_memcpy(&tl[n], x->e_mbd.left_context + (n >> 2), - sizeof(ENTROPY_CONTEXT) * 4); + vpx_memcpy(ta, xd->plane[0].above_context, sizeof(ENTROPY_CONTEXT) * bw); + vpx_memcpy(tl, xd->plane[0].left_context, sizeof(ENTROPY_CONTEXT) * bh); for (n = 0; n < bw * bh; n++) { const int x_idx = n & (bw - 1), y_idx = n >> bwl; @@ -589,24 +574,18 @@ void vp9_optimize_sby_4x4(VP9_COMMON *const cm, MACROBLOCK *x, void vp9_optimize_sbuv_32x32(VP9_COMMON *const cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { - ENTROPY_CONTEXT *ta = (ENTROPY_CONTEXT *) x->e_mbd.above_context; - ENTROPY_CONTEXT *tl = (ENTROPY_CONTEXT *) x->e_mbd.left_context; - ENTROPY_CONTEXT *a, *l, *a1, *l1, *a2, *l2, *a3, *l3, a_ec, l_ec; + MACROBLOCKD *const xd = &x->e_mbd; int b; assert(bsize == BLOCK_SIZE_SB64X64); for (b = 256; b < 384; b += 64) { const int plane = 1 + (b >= 320); - a = ta + vp9_block2above_sb64[TX_32X32][b]; - l = tl + vp9_block2left_sb64[TX_32X32][b]; - a1 = a + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l1 = l + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a2 = a + 2 * sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l2 = l + 2 * sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a3 = a + 3 * sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l3 = l + 3 * sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a_ec = (a[0] + a[1] + a1[0] + a1[1] + a2[0] + a2[1] + a3[0] + a3[1]) != 0; - l_ec = (l[0] + l[1] + l1[0] + l1[1] + l2[0] + l2[1] + l3[0] + l3[1]) != 0; + ENTROPY_CONTEXT *a = xd->plane[plane].above_context; + ENTROPY_CONTEXT *l = xd->plane[plane].left_context; + ENTROPY_CONTEXT a_ec, l_ec; + + a_ec = (a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7]) != 0; + l_ec = (l[0] + l[1] + l[2] + l[3] + l[4] + l[5] + l[6] + l[7]) != 0; optimize_b(cm, x, b, PLANE_TYPE_UV, x->e_mbd.plane[plane].dequant, &a_ec, &l_ec, TX_32X32, 256); } @@ -614,32 +593,27 @@ void vp9_optimize_sbuv_32x32(VP9_COMMON *const cm, MACROBLOCK *x, void vp9_optimize_sbuv_16x16(VP9_COMMON *const cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { + MACROBLOCKD *const xd = &x->e_mbd; const int bwl = b_width_log2(bsize) - 2, bhl = b_height_log2(bsize) - 2; const int bw = 1 << (bwl - 1); const int bh = 1 << (bhl - 1); int uvoff = 16 << (bwl + bhl); - ENTROPY_CONTEXT ta[2][2], tl[2][2]; int plane, n; - for (n = 0; n < bw; n++) { - ENTROPY_CONTEXT_PLANES *a = x->e_mbd.above_context + n * 2; - ENTROPY_CONTEXT_PLANES *a1 = x->e_mbd.above_context + n * 2 + 1; - ta[0][n] = (a->u[0] + a->u[1] + a1->u[0] + a1->u[1]) != 0; - ta[1][n] = (a->v[0] + a->v[1] + a1->v[0] + a1->v[1]) != 0; - } - for (n = 0; n < bh; n++) { - ENTROPY_CONTEXT_PLANES *l = (x->e_mbd.left_context + n * 2); - ENTROPY_CONTEXT_PLANES *l1 = (x->e_mbd.left_context + n * 2 + 1); - tl[0][n] = (l->u[0] + l->u[1] + l1->u[0] + l1->u[1]) != 0; - tl[1][n] = (l->v[0] + l->v[1] + l1->v[0] + l1->v[1]) != 0; - } + for (plane = 1; plane < MAX_MB_PLANE; plane++) { + ENTROPY_CONTEXT ta[2], *a = xd->plane[plane].above_context; + ENTROPY_CONTEXT tl[2], *l = xd->plane[plane].left_context; + + for (n = 0; n < bw; n++, a += 4) + ta[n] = (a[0] + a[1] + a[2] + a[3]) != 0; + for (n = 0; n < bh; n++, l += 4) + tl[n] = (l[0] + l[1] + l[2] + l[3]) != 0; - for (plane = 0; plane < 2; plane++) { for (n = 0; n < bw * bh; n++) { const int x_idx = n & (bw - 1), y_idx = n >> (bwl - 1); optimize_b(cm, x, uvoff + n * 16, PLANE_TYPE_UV, - x->e_mbd.plane[plane + 1].dequant, - &ta[plane][x_idx], &tl[plane][y_idx], + x->e_mbd.plane[plane].dequant, + &ta[x_idx], &tl[y_idx], TX_16X16, bh * bw * 64); } uvoff = (uvoff * 5) >> 2; // switch u -> v @@ -648,30 +622,27 @@ void vp9_optimize_sbuv_16x16(VP9_COMMON *const cm, MACROBLOCK *x, void vp9_optimize_sbuv_8x8(VP9_COMMON *const cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { + MACROBLOCKD *const xd = &x->e_mbd; const int bwl = b_width_log2(bsize) - 1, bhl = b_height_log2(bsize) - 1; const int bw = 1 << (bwl - 1); const int bh = 1 << (bhl - 1); int uvoff = 4 << (bwl + bhl); - ENTROPY_CONTEXT ta[2][4], tl[2][4]; int plane, n; - for (n = 0; n < bw; n++) { - ENTROPY_CONTEXT_PLANES *a = x->e_mbd.above_context + n; - ta[0][n] = (a->u[0] + a->u[1]) != 0; - ta[1][n] = (a->v[0] + a->v[1]) != 0; - } - for (n = 0; n < bh; n++) { - ENTROPY_CONTEXT_PLANES *l = x->e_mbd.left_context + n; - tl[0][n] = (l->u[0] + l->u[1]) != 0; - tl[1][n] = (l->v[0] + l->v[1]) != 0; - } + for (plane = 1; plane < MAX_MB_PLANE; plane++) { + ENTROPY_CONTEXT ta[4], *a = xd->plane[plane].above_context; + ENTROPY_CONTEXT tl[4], *l = xd->plane[plane].left_context; + + for (n = 0; n < bw; n++, a += 2) + ta[n] = (a[0] + a[1]) != 0; + for (n = 0; n < bh; n++, l += 2) + tl[n] = (l[0] + l[1]) != 0; - for (plane = 0; plane < 2; plane++) { for (n = 0; n < bw * bh; n++) { const int x_idx = n & (bw - 1), y_idx = n >> (bwl - 1); optimize_b(cm, x, uvoff + n * 4, PLANE_TYPE_UV, - x->e_mbd.plane[plane + 1].dequant, - &ta[plane][x_idx], &tl[plane][y_idx], + x->e_mbd.plane[plane].dequant, + &ta[x_idx], &tl[y_idx], TX_8X8, bh * bw * 16); } uvoff = (uvoff * 5) >> 2; // switch u -> v @@ -680,34 +651,26 @@ void vp9_optimize_sbuv_8x8(VP9_COMMON *const cm, MACROBLOCK *x, void vp9_optimize_sbuv_4x4(VP9_COMMON *const cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { + MACROBLOCKD *const xd = &x->e_mbd; const int bwl = b_width_log2(bsize), bhl = b_height_log2(bsize); const int bw = 1 << (bwl - 1); const int bh = 1 << (bhl - 1); int uvoff = 1 << (bwl + bhl); - ENTROPY_CONTEXT ta[2][8], tl[2][8]; int plane, n; - for (n = 0; n < bw; n += 2) { - ENTROPY_CONTEXT_PLANES *a = x->e_mbd.above_context + (n >> 1); - ta[0][n + 0] = (a->u[0]) != 0; - ta[0][n + 1] = (a->u[1]) != 0; - ta[1][n + 0] = (a->v[0]) != 0; - ta[1][n + 1] = (a->v[1]) != 0; - } - for (n = 0; n < bh; n += 2) { - ENTROPY_CONTEXT_PLANES *l = x->e_mbd.left_context + (n >> 1); - tl[0][n + 0] = (l->u[0]) != 0; - tl[0][n + 1] = (l->u[1]) != 0; - tl[1][n + 0] = (l->v[0]) != 0; - tl[1][n + 1] = (l->v[1]) != 0; - } + for (plane = 1; plane < MAX_MB_PLANE; plane++) { + ENTROPY_CONTEXT ta[8], tl[8]; + + vpx_memcpy(ta, xd->plane[plane].above_context, + sizeof(ENTROPY_CONTEXT) * bw); + vpx_memcpy(tl, xd->plane[plane].left_context, + sizeof(ENTROPY_CONTEXT) * bh); - for (plane = 0; plane < 2; plane++) { for (n = 0; n < bw * bh; n++) { const int x_idx = n & (bw - 1), y_idx = n >> (bwl - 1); optimize_b(cm, x, uvoff + n, PLANE_TYPE_UV, - x->e_mbd.plane[plane + 1].dequant, - &ta[plane][x_idx], &tl[plane][y_idx], + x->e_mbd.plane[plane].dequant, + &ta[x_idx], &tl[y_idx], TX_4X4, bh * bw * 4); } uvoff = (uvoff * 5) >> 2; // switch u -> v diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 058a2da..cc142d9 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -292,8 +292,8 @@ int vp9_block_error_c(int16_t *coeff, int16_t *dqcoeff, int block_size) { static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, int ib, PLANE_TYPE type, - ENTROPY_CONTEXT *a, - ENTROPY_CONTEXT *l, + ENTROPY_CONTEXT *A, + ENTROPY_CONTEXT *L, TX_SIZE tx_size, int y_blocks) { MACROBLOCKD *const xd = &mb->e_mbd; @@ -309,11 +309,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, const int ref = mbmi->ref_frame != INTRA_FRAME; unsigned int (*token_costs)[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS] = mb->token_costs[tx_size][type][ref]; - ENTROPY_CONTEXT a_ec, l_ec; - ENTROPY_CONTEXT *const a1 = a + - sizeof(ENTROPY_CONTEXT_PLANES)/sizeof(ENTROPY_CONTEXT); - ENTROPY_CONTEXT *const l1 = l + - sizeof(ENTROPY_CONTEXT_PLANES)/sizeof(ENTROPY_CONTEXT); + ENTROPY_CONTEXT above_ec, left_ec; TX_TYPE tx_type = DCT_DCT; #if CONFIG_CODE_ZEROGROUP @@ -348,8 +344,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, case TX_4X4: { tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type_4x4(xd, ib) : DCT_DCT; - a_ec = *a; - l_ec = *l; + above_ec = A[0] != 0; + left_ec = L[0] != 0; coef_probs = cm->fc.coef_probs_4x4; seg_eob = 16; scan = get_scan_4x4(tx_type); @@ -364,8 +360,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, const int x = ib & ((1 << sz) - 1), y = ib - x; TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT; - a_ec = (a[0] + a[1]) != 0; - l_ec = (l[0] + l[1]) != 0; + above_ec = (A[0] + A[1]) != 0; + left_ec = (L[0] + L[1]) != 0; scan = get_scan_8x8(tx_type); coef_probs = cm->fc.coef_probs_8x8; seg_eob = 64; @@ -383,13 +379,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, scan = get_scan_16x16(tx_type); coef_probs = cm->fc.coef_probs_16x16; seg_eob = 256; - if (type == PLANE_TYPE_UV) { - a_ec = (a[0] + a[1] + a1[0] + a1[1]) != 0; - l_ec = (l[0] + l[1] + l1[0] + l1[1]) != 0; - } else { - a_ec = (a[0] + a[1] + a[2] + a[3]) != 0; - l_ec = (l[0] + l[1] + l[2] + l[3]) != 0; - } + above_ec = (A[0] + A[1] + A[2] + A[3]) != 0; + left_ec = (L[0] + L[1] + L[2] + L[3]) != 0; #if CONFIG_CODE_ZEROGROUP zpc_probs = &cm->fc.zpc_probs_16x16; #endif @@ -399,22 +390,9 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, scan = vp9_default_zig_zag1d_32x32; coef_probs = cm->fc.coef_probs_32x32; seg_eob = 1024; - if (type == PLANE_TYPE_UV) { - ENTROPY_CONTEXT *a2, *a3, *l2, *l3; - a2 = a1 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a3 = a2 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l2 = l1 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l3 = l2 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a_ec = (a[0] + a[1] + a1[0] + a1[1] + - a2[0] + a2[1] + a3[0] + a3[1]) != 0; - l_ec = (l[0] + l[1] + l1[0] + l1[1] + - l2[0] + l2[1] + l3[0] + l3[1]) != 0; - } else { - a_ec = (a[0] + a[1] + a[2] + a[3] + - a1[0] + a1[1] + a1[2] + a1[3]) != 0; - l_ec = (l[0] + l[1] + l[2] + l[3] + - l1[0] + l1[1] + l1[2] + l1[3]) != 0; - } + above_ec = (A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7]) != 0; + left_ec = (L[0] + L[1] + L[2] + L[3] + L[4] + L[5] + L[6] + L[7]) != 0; + #if CONFIG_CODE_ZEROGROUP zpc_probs = &cm->fc.zpc_probs_32x32; #endif @@ -425,7 +403,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, } assert(eob <= seg_eob); - pt = combine_entropy_contexts(a_ec, l_ec); + pt = combine_entropy_contexts(above_ec, left_ec); nb = vp9_get_coef_neighbors_handle(scan, &pad); default_eob = seg_eob; @@ -534,23 +512,11 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb, } } - // is eob first coefficient; - pt = (c > 0); - *a = *l = pt; - if (tx_size >= TX_8X8) { - a[1] = l[1] = pt; - if (tx_size >= TX_16X16) { - if (type == PLANE_TYPE_UV) { - a1[0] = a1[1] = l1[0] = l1[1] = pt; - } else { - a[2] = a[3] = l[2] = l[3] = pt; - if (tx_size >= TX_32X32) { - a1[0] = a1[1] = a1[2] = a1[3] = pt; - l1[0] = l1[1] = l1[2] = l1[3] = pt; - } - } - } + // is eob first coefficient; + for (pt = 0; pt < (1 << tx_size); pt++) { + A[pt] = L[pt] = c > 0; } + return cost; } @@ -670,19 +636,18 @@ static int rdcost_sby_4x4(VP9_COMMON *const cm, MACROBLOCK *x, const int bh = 1 << b_height_log2(bsize); int cost = 0, b; MACROBLOCKD *const xd = &x->e_mbd; - ENTROPY_CONTEXT_PLANES t_above[4], t_left[4]; + ENTROPY_CONTEXT t_above[16], t_left[16]; - vpx_memcpy(&t_above, xd->above_context, - (sizeof(ENTROPY_CONTEXT_PLANES) * bw) >> 2); - vpx_memcpy(&t_left, xd->left_context, - (sizeof(ENTROPY_CONTEXT_PLANES) * bh) >> 2); + vpx_memcpy(&t_above, xd->plane[0].above_context, + sizeof(ENTROPY_CONTEXT) * bw); + vpx_memcpy(&t_left, xd->plane[0].left_context, + sizeof(ENTROPY_CONTEXT) * bh); for (b = 0; b < bw * bh; b++) { const int x_idx = b & (bw - 1), y_idx = b >> bwl; cost += cost_coeffs(cm, x, b, PLANE_TYPE_Y_WITH_DC, - ((ENTROPY_CONTEXT *) &t_above[x_idx >> 2]) + (x_idx & 3), - ((ENTROPY_CONTEXT *) &t_left[y_idx >> 2]) + (y_idx & 3), - TX_4X4, bw * bh); + t_above + x_idx, t_left + y_idx, + TX_4X4, bw * bh); } return cost; @@ -709,19 +674,18 @@ static int rdcost_sby_8x8(VP9_COMMON *const cm, MACROBLOCK *x, const int bh = 1 << (b_height_log2(bsize) - 1); int cost = 0, b; MACROBLOCKD *const xd = &x->e_mbd; - ENTROPY_CONTEXT_PLANES t_above[4], t_left[4]; + ENTROPY_CONTEXT t_above[16], t_left[16]; - vpx_memcpy(&t_above, xd->above_context, - (sizeof(ENTROPY_CONTEXT_PLANES) * bw) >> 1); - vpx_memcpy(&t_left, xd->left_context, - (sizeof(ENTROPY_CONTEXT_PLANES) * bh) >> 1); + vpx_memcpy(&t_above, xd->plane[0].above_context, + sizeof(ENTROPY_CONTEXT) * 2 * bw); + vpx_memcpy(&t_left, xd->plane[0].left_context, + sizeof(ENTROPY_CONTEXT) * 2 * bh); for (b = 0; b < bw * bh; b++) { const int x_idx = b & (bw - 1), y_idx = b >> bwl; cost += cost_coeffs(cm, x, b * 4, PLANE_TYPE_Y_WITH_DC, - ((ENTROPY_CONTEXT *) &t_above[x_idx >> 1]) + ((x_idx & 1) << 1), - ((ENTROPY_CONTEXT *) &t_left[y_idx >> 1]) + ((y_idx & 1) << 1), - TX_8X8, 4 * bw * bh); + t_above + x_idx * 2, t_left + y_idx * 2, + TX_8X8, 4 * bw * bh); } return cost; @@ -748,16 +712,17 @@ static int rdcost_sby_16x16(VP9_COMMON *const cm, MACROBLOCK *x, const int bh = 1 << (b_height_log2(bsize) - 2); int cost = 0, b; MACROBLOCKD *const xd = &x->e_mbd; - ENTROPY_CONTEXT_PLANES t_above[4], t_left[4]; + ENTROPY_CONTEXT t_above[16], t_left[16]; - vpx_memcpy(&t_above, xd->above_context, sizeof(ENTROPY_CONTEXT_PLANES) * bw); - vpx_memcpy(&t_left, xd->left_context, sizeof(ENTROPY_CONTEXT_PLANES) * bh); + vpx_memcpy(&t_above, xd->plane[0].above_context, + sizeof(ENTROPY_CONTEXT) * 4 * bw); + vpx_memcpy(&t_left, xd->plane[0].left_context, + sizeof(ENTROPY_CONTEXT) * 4 * bh); for (b = 0; b < bw * bh; b++) { const int x_idx = b & (bw - 1), y_idx = b >> bwl; cost += cost_coeffs(cm, x, b * 16, PLANE_TYPE_Y_WITH_DC, - (ENTROPY_CONTEXT *) &t_above[x_idx], - (ENTROPY_CONTEXT *) &t_left[y_idx], + t_above + x_idx * 4, t_left + y_idx * 4, TX_16X16, bw * bh * 16); } @@ -785,18 +750,17 @@ static int rdcost_sby_32x32(VP9_COMMON *const cm, MACROBLOCK *x, const int bh = 1 << (b_height_log2(bsize) - 3); int cost = 0, b; MACROBLOCKD * const xd = &x->e_mbd; - ENTROPY_CONTEXT_PLANES t_above[4], t_left[4]; + ENTROPY_CONTEXT t_above[16], t_left[16]; - vpx_memcpy(&t_above, xd->above_context, - sizeof(ENTROPY_CONTEXT_PLANES) * bw * 2); - vpx_memcpy(&t_left, xd->left_context, - sizeof(ENTROPY_CONTEXT_PLANES) * bh * 2); + vpx_memcpy(&t_above, xd->plane[0].above_context, + sizeof(ENTROPY_CONTEXT) * 8 * bw); + vpx_memcpy(&t_left, xd->plane[0].left_context, + sizeof(ENTROPY_CONTEXT) * 8 * bh); for (b = 0; b < bw * bh; b++) { const int x_idx = b & (bw - 1), y_idx = b >> bwl; cost += cost_coeffs(cm, x, b * 64, PLANE_TYPE_Y_WITH_DC, - (ENTROPY_CONTEXT *) &t_above[x_idx * 2], - (ENTROPY_CONTEXT *) &t_left[y_idx * 2], + t_above + x_idx * 8, t_left + y_idx * 8, TX_32X32, bw * bh * 64); } @@ -968,22 +932,17 @@ static int64_t rd_pick_intra4x4mby_modes(VP9_COMP *cpi, MACROBLOCK *mb, int distortion = 0; int tot_rate_y = 0; int64_t total_rd = 0; - ENTROPY_CONTEXT_PLANES t_above, t_left; - ENTROPY_CONTEXT *ta, *tl; + ENTROPY_CONTEXT t_above[4], t_left[4]; int *bmode_costs; - vpx_memcpy(&t_above, xd->above_context, - sizeof(ENTROPY_CONTEXT_PLANES)); - vpx_memcpy(&t_left, xd->left_context, - sizeof(ENTROPY_CONTEXT_PLANES)); - - ta = (ENTROPY_CONTEXT *)&t_above; - tl = (ENTROPY_CONTEXT *)&t_left; + vpx_memcpy(t_above, xd->plane[0].above_context, sizeof(t_above)); + vpx_memcpy(t_left, xd->plane[0].left_context, sizeof(t_left)); xd->mode_info_context->mbmi.mode = I4X4_PRED; bmode_costs = mb->inter_bmode_costs; for (i = 0; i < 16; i++) { + const int x_idx = i & 3, y_idx = i >> 2; MODE_INFO *const mic = xd->mode_info_context; const int mis = xd->mode_info_stride; B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode); @@ -1006,10 +965,9 @@ static int64_t rd_pick_intra4x4mby_modes(VP9_COMP *cpi, MACROBLOCK *mb, xd->plane[0].dst.stride); #endif - total_rd += rd_pick_intra4x4block( - cpi, mb, i, &best_mode, - bmode_costs, ta + vp9_block2above[TX_4X4][i], - tl + vp9_block2left[TX_4X4][i], &r, &ry, &d); + total_rd += rd_pick_intra4x4block(cpi, mb, i, &best_mode, bmode_costs, + t_above + x_idx, t_left + y_idx, + &r, &ry, &d); cost += r; distortion += d; @@ -1099,9 +1057,7 @@ static int64_t rd_pick_intra8x8block(VP9_COMP *cpi, MACROBLOCK *x, int ib, MACROBLOCKD *xd = &x->e_mbd; int64_t best_rd = INT64_MAX; int distortion = 0, rate = 0; - ENTROPY_CONTEXT_PLANES ta, tl; - ENTROPY_CONTEXT *ta0, *ta1, besta0 = 0, besta1 = 0; - ENTROPY_CONTEXT *tl0, *tl1, bestl0 = 0, bestl1 = 0; + ENTROPY_CONTEXT ta[2], tl[2], ta_temp[2], tl_temp[2]; // perform transformation of dimension 8x8 // note the input and output index mapping int idx = (ib & 0x02) ? (ib + 2) : ib; @@ -1118,6 +1074,8 @@ static int64_t rd_pick_intra8x8block(VP9_COMP *cpi, MACROBLOCK *x, int ib, xd->plane[0].dst.buf, xd->plane[0].dst.stride); assert(ib < 16); + vpx_memcpy(ta, a, sizeof(ta)); + vpx_memcpy(tl, l, sizeof(tl)); for (mode = DC_PRED; mode <= TM_PRED; mode++) { int64_t this_rd; int rate_t = 0; @@ -1132,6 +1090,9 @@ static int64_t rd_pick_intra8x8block(VP9_COMP *cpi, MACROBLOCK *x, int ib, src, src_stride, dst, xd->plane[0].dst.stride); + vpx_memcpy(ta_temp, ta, sizeof(ta)); + vpx_memcpy(tl_temp, tl, sizeof(tl)); + if (xd->mode_info_context->mbmi.txfm_size == TX_8X8) { TX_TYPE tx_type = get_tx_type_8x8(xd, ib); if (tx_type != DCT_DCT) @@ -1144,28 +1105,15 @@ static int64_t rd_pick_intra8x8block(VP9_COMP *cpi, MACROBLOCK *x, int ib, distortion = vp9_block_error_c(coeff, BLOCK_OFFSET(xd->plane[0].dqcoeff, idx, 16), 64); - vpx_memcpy(&ta, a, sizeof(ENTROPY_CONTEXT_PLANES)); - vpx_memcpy(&tl, l, sizeof(ENTROPY_CONTEXT_PLANES)); - - ta0 = ((ENTROPY_CONTEXT*)&ta) + vp9_block2above[TX_8X8][idx]; - tl0 = ((ENTROPY_CONTEXT*)&tl) + vp9_block2left[TX_8X8][idx]; - ta1 = ta0 + 1; - tl1 = tl0 + 1; - rate_t = cost_coeffs(cm, x, idx, PLANE_TYPE_Y_WITH_DC, - ta0, tl0, TX_8X8, 16); + ta_temp, tl_temp, TX_8X8, 16); rate += rate_t; } else { static const int iblock[4] = {0, 1, 4, 5}; TX_TYPE tx_type; int i; - vpx_memcpy(&ta, a, sizeof(ENTROPY_CONTEXT_PLANES)); - vpx_memcpy(&tl, l, sizeof(ENTROPY_CONTEXT_PLANES)); - ta0 = ((ENTROPY_CONTEXT*)&ta) + vp9_block2above[TX_4X4][ib]; - tl0 = ((ENTROPY_CONTEXT*)&tl) + vp9_block2left[TX_4X4][ib]; - ta1 = ta0 + 1; - tl1 = tl0 + 1; + distortion = 0; rate_t = 0; for (i = 0; i < 4; ++i) { @@ -1193,12 +1141,12 @@ static int64_t rd_pick_intra8x8block(VP9_COMP *cpi, MACROBLOCK *x, int ib, BLOCK_OFFSET(xd->plane[0].dqcoeff, ib + iblock[i], 16), 16 << do_two); rate_t += cost_coeffs(cm, x, ib + iblock[i], PLANE_TYPE_Y_WITH_DC, - i&1 ? ta1 : ta0, i&2 ? tl1 : tl0, + &ta_temp[i & 1], &tl_temp[i >> 1], TX_4X4, 16); if (do_two) { i++; rate_t += cost_coeffs(cm, x, ib + iblock[i], PLANE_TYPE_Y_WITH_DC, - i&1 ? ta1 : ta0, i&2 ? tl1 : tl0, + &ta_temp[i & 1], &tl_temp[i >> 1], TX_4X4, 16); } } @@ -1211,10 +1159,8 @@ static int64_t rd_pick_intra8x8block(VP9_COMP *cpi, MACROBLOCK *x, int ib, *bestrate = rate; *bestratey = rate_t; *bestdistortion = distortion; - besta0 = *ta0; - besta1 = *ta1; - bestl0 = *tl0; - bestl1 = *tl1; + vpx_memcpy(a, ta_temp, sizeof(ta_temp)); + vpx_memcpy(l, tl_temp, sizeof(tl_temp)); best_rd = this_rd; *best_mode = mode; } @@ -1222,18 +1168,6 @@ static int64_t rd_pick_intra8x8block(VP9_COMP *cpi, MACROBLOCK *x, int ib, xd->mode_info_context->bmi[ib].as_mode.first = (*best_mode); vp9_encode_intra8x8(x, ib); - if (xd->mode_info_context->mbmi.txfm_size == TX_8X8) { - a[vp9_block2above[TX_8X8][idx]] = besta0; - a[vp9_block2above[TX_8X8][idx] + 1] = besta1; - l[vp9_block2left[TX_8X8][idx]] = bestl0; - l[vp9_block2left[TX_8X8][idx] + 1] = bestl1; - } else { - a[vp9_block2above[TX_4X4][ib]] = besta0; - a[vp9_block2above[TX_4X4][ib + 1]] = besta1; - l[vp9_block2left[TX_4X4][ib]] = bestl0; - l[vp9_block2left[TX_4X4][ib + 4]] = bestl1; - } - return best_rd; } @@ -1246,28 +1180,25 @@ static int64_t rd_pick_intra8x8mby_modes(VP9_COMP *cpi, MACROBLOCK *mb, int distortion = 0; int tot_rate_y = 0; int64_t total_rd = 0; - ENTROPY_CONTEXT_PLANES t_above, t_left; - ENTROPY_CONTEXT *ta, *tl; + ENTROPY_CONTEXT t_above[4], t_left[4]; int *i8x8mode_costs; - vpx_memcpy(&t_above, xd->above_context, sizeof(ENTROPY_CONTEXT_PLANES)); - vpx_memcpy(&t_left, xd->left_context, sizeof(ENTROPY_CONTEXT_PLANES)); - - ta = (ENTROPY_CONTEXT *)&t_above; - tl = (ENTROPY_CONTEXT *)&t_left; + vpx_memcpy(t_above, xd->plane[0].above_context, sizeof(t_above)); + vpx_memcpy(t_left, xd->plane[0].left_context, sizeof(t_left)); xd->mode_info_context->mbmi.mode = I8X8_PRED; i8x8mode_costs = mb->i8x8_mode_costs; for (i = 0; i < 4; i++) { + const int x_idx = i & 1, y_idx = i >> 1; MODE_INFO *const mic = xd->mode_info_context; B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode); int UNINITIALIZED_IS_SAFE(r), UNINITIALIZED_IS_SAFE(ry), UNINITIALIZED_IS_SAFE(d); ib = vp9_i8x8_block[i]; - total_rd += rd_pick_intra8x8block( - cpi, mb, ib, &best_mode, - i8x8mode_costs, ta, tl, &r, &ry, &d); + total_rd += rd_pick_intra8x8block(cpi, mb, ib, &best_mode, i8x8mode_costs, + t_above + x_idx * 2, t_left + y_idx * 2, + &r, &ry, &d); cost += r; distortion += d; tot_rate_y += ry; @@ -1353,7 +1284,6 @@ static int64_t rd_pick_intra8x8mby_modes_and_txsz(VP9_COMP *cpi, MACROBLOCK *x, return tmp_rd; } -#define UVCTX(c, p) ((p) ? (c).v : (c).u) static int rd_cost_sbuv_4x4(VP9_COMMON *const cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { const int bwl = b_width_log2(bsize) - 1, bw = 1 << bwl; @@ -1361,19 +1291,18 @@ static int rd_cost_sbuv_4x4(VP9_COMMON *const cm, MACROBLOCK *x, int yoff = 4 * bw * bh; int p, b, cost = 0; MACROBLOCKD *const xd = &x->e_mbd; - ENTROPY_CONTEXT_PLANES t_above[4], t_left[4]; - vpx_memcpy(&t_above, xd->above_context, - (sizeof(ENTROPY_CONTEXT_PLANES) * bw) >> 1); - vpx_memcpy(&t_left, xd->left_context, - (sizeof(ENTROPY_CONTEXT_PLANES) * bh) >> 1); + for (p = 1; p < MAX_MB_PLANE; p++) { + ENTROPY_CONTEXT t_above[8], t_left[8]; - for (p = 0; p < 2; p++) { + vpx_memcpy(t_above, xd->plane[p].above_context, + sizeof(ENTROPY_CONTEXT) * 2 * bw >> xd->plane[p].subsampling_x); + vpx_memcpy(t_left, xd->plane[p].left_context, + sizeof(ENTROPY_CONTEXT) * 2 * bh >> xd->plane[p].subsampling_y); for (b = 0; b < bw * bh; b++) { const int x_idx = b & (bw - 1), y_idx = b >> bwl; cost += cost_coeffs(cm, x, yoff + b, PLANE_TYPE_UV, - UVCTX(t_above[x_idx >> 1], p) + (x_idx & 1), - UVCTX(t_left[y_idx >> 1], p) + (y_idx & 1), + t_above + x_idx, t_left + y_idx, TX_4X4, bw * bh * 4); } yoff = (yoff * 5) >> 2; // u -> v @@ -1402,19 +1331,18 @@ static int rd_cost_sbuv_8x8(VP9_COMMON *const cm, MACROBLOCK *x, int yoff = 16 * bw * bh; int p, b, cost = 0; MACROBLOCKD *const xd = &x->e_mbd; - ENTROPY_CONTEXT_PLANES t_above[4], t_left[4]; - vpx_memcpy(&t_above, xd->above_context, - sizeof(ENTROPY_CONTEXT_PLANES) * bw); - vpx_memcpy(&t_left, xd->left_context, - sizeof(ENTROPY_CONTEXT_PLANES) * bh); + for (p = 1; p < MAX_MB_PLANE; p++) { + ENTROPY_CONTEXT t_above[8], t_left[8]; - for (p = 0; p < 2; p++) { + vpx_memcpy(t_above, xd->plane[p].above_context, + sizeof(ENTROPY_CONTEXT) * 4 * bw >> xd->plane[p].subsampling_x); + vpx_memcpy(t_left, xd->plane[p].left_context, + sizeof(ENTROPY_CONTEXT) * 4 * bh >> xd->plane[p].subsampling_y); for (b = 0; b < bw * bh; b++) { const int x_idx = b & (bw - 1), y_idx = b >> bwl; cost += cost_coeffs(cm, x, yoff + b * 4, PLANE_TYPE_UV, - UVCTX(t_above[x_idx], p), - UVCTX(t_left[y_idx], p), + t_above + x_idx * 2, t_left + y_idx * 2, TX_8X8, bw * bh * 16); } yoff = (yoff * 5) >> 2; // u -> v @@ -1443,19 +1371,18 @@ static int rd_cost_sbuv_16x16(VP9_COMMON *const cm, MACROBLOCK *x, int yoff = 64 * bw * bh; int p, b, cost = 0; MACROBLOCKD *const xd = &x->e_mbd; - ENTROPY_CONTEXT_PLANES t_above[4], t_left[4]; - vpx_memcpy(&t_above, xd->above_context, - sizeof(ENTROPY_CONTEXT_PLANES) * 2 * bw); - vpx_memcpy(&t_left, xd->left_context, - sizeof(ENTROPY_CONTEXT_PLANES) * 2 * bh); + for (p = 1; p < MAX_MB_PLANE; p++) { + ENTROPY_CONTEXT t_above[8], t_left[8]; - for (p = 0; p < 2; p++) { + vpx_memcpy(t_above, xd->plane[p].above_context, + sizeof(ENTROPY_CONTEXT) * 8 * bw >> xd->plane[p].subsampling_x); + vpx_memcpy(t_left, xd->plane[p].left_context, + sizeof(ENTROPY_CONTEXT) * 8 * bh >> xd->plane[p].subsampling_y); for (b = 0; b < bw * bh; b++) { const int x_idx = b & (bw - 1), y_idx = b >> bwl; cost += cost_coeffs(cm, x, yoff + b * 16, PLANE_TYPE_UV, - UVCTX(t_above[x_idx * 2], p), - UVCTX(t_left[y_idx * 2], p), + t_above + x_idx * 4, t_left + y_idx * 4, TX_16X16, bw * bh * 64); } yoff = (yoff * 5) >> 2; // u -> v @@ -1484,19 +1411,18 @@ static int rd_cost_sbuv_32x32(VP9_COMMON *const cm, MACROBLOCK *x, int yoff = 256 * bh * bw; int p, b, cost = 0; MACROBLOCKD *const xd = &x->e_mbd; - ENTROPY_CONTEXT_PLANES t_above[4], t_left[4]; - vpx_memcpy(&t_above, xd->above_context, - sizeof(ENTROPY_CONTEXT_PLANES) * 4 * bw); - vpx_memcpy(&t_left, xd->left_context, - sizeof(ENTROPY_CONTEXT_PLANES) * 4 * bh); + for (p = 1; p < MAX_MB_PLANE; p++) { + ENTROPY_CONTEXT t_above[8], t_left[8]; - for (p = 0; p < 2; p++) { + vpx_memcpy(t_above, xd->plane[p].above_context, + sizeof(ENTROPY_CONTEXT) * 16 * bw >> xd->plane[p].subsampling_x); + vpx_memcpy(t_left, xd->plane[p].left_context, + sizeof(ENTROPY_CONTEXT) * 16 * bh >> xd->plane[p].subsampling_y); for (b = 0; b < bw * bh; b++) { const int x_idx = b * (bw - 1), y_idx = b >> bwl; cost += cost_coeffs(cm, x, yoff + b * 64, PLANE_TYPE_UV, - UVCTX(t_above[x_idx * 4], p), - UVCTX(t_left[y_idx * 4], p), + t_above + x_idx * 8, t_left + y_idx * 8, TX_32X32, 256 * bh * bw); } yoff = (yoff * 5) >> 2; // u -> v @@ -1775,8 +1701,8 @@ static int64_t encode_inter_mb_segment(VP9_COMMON *const cm, BLOCK_OFFSET(xd->plane[0].dqcoeff, i, 16), 16); *distortion += thisdistortion; *labelyrate += cost_coeffs(cm, x, i, PLANE_TYPE_Y_WITH_DC, - ta + vp9_block2above[TX_4X4][i], - tl + vp9_block2left[TX_4X4][i], TX_4X4, 16); + ta + (i & 3), + tl + (i >> 2), TX_4X4, 16); } } *distortion >>= 2; @@ -1796,13 +1722,11 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm, MACROBLOCKD *xd = &x->e_mbd; const int iblock[4] = { 0, 1, 4, 5 }; int othercost = 0, otherdist = 0; - ENTROPY_CONTEXT_PLANES tac, tlc; - ENTROPY_CONTEXT *tacp = (ENTROPY_CONTEXT *) &tac, - *tlcp = (ENTROPY_CONTEXT *) &tlc; + ENTROPY_CONTEXT tac[4], tlc[4]; if (otherrd) { - memcpy(&tac, ta, sizeof(ENTROPY_CONTEXT_PLANES)); - memcpy(&tlc, tl, sizeof(ENTROPY_CONTEXT_PLANES)); + memcpy(&tac, ta, sizeof(tac)); + memcpy(&tlc, tl, sizeof(tlc)); } *distortion = 0; @@ -1860,8 +1784,8 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm, otherdist += thisdistortion; xd->mode_info_context->mbmi.txfm_size = TX_8X8; othercost += cost_coeffs(cm, x, idx, PLANE_TYPE_Y_WITH_DC, - tacp + vp9_block2above[TX_8X8][idx], - tlcp + vp9_block2left[TX_8X8][idx], + tac + (i & 1) * 2, + tlc + (i & 2), TX_8X8, 16); xd->mode_info_context->mbmi.txfm_size = TX_4X4; } @@ -1879,14 +1803,14 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm, *distortion += thisdistortion; *labelyrate += cost_coeffs(cm, x, ib + iblock[j], PLANE_TYPE_Y_WITH_DC, - ta + vp9_block2above[TX_4X4][ib + iblock[j]], - tl + vp9_block2left[TX_4X4][ib + iblock[j]], + ta + (i & 1) * 2, + tl + (i & 2) + ((j & 2) >> 1), TX_4X4, 16); *labelyrate += cost_coeffs(cm, x, ib + iblock[j] + 1, PLANE_TYPE_Y_WITH_DC, - ta + vp9_block2above[TX_4X4][ib + iblock[j] + 1], - tl + vp9_block2left[TX_4X4][ib + iblock[j]], + ta + (i & 1) * 2 + 1, + tl + (i & 2) + ((j & 2) >> 1), TX_4X4, 16); } } else /* 8x8 */ { @@ -1906,14 +1830,14 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm, xd->mode_info_context->mbmi.txfm_size = TX_4X4; othercost += cost_coeffs(cm, x, ib + iblock[j], PLANE_TYPE_Y_WITH_DC, - tacp + vp9_block2above[TX_4X4][ib + iblock[j]], - tlcp + vp9_block2left[TX_4X4][ib + iblock[j]], + tac + (i & 1) * 2, + tlc + (i & 2) + ((j & 2) >> 1), TX_4X4, 16); othercost += cost_coeffs(cm, x, ib + iblock[j] + 1, PLANE_TYPE_Y_WITH_DC, - tacp + vp9_block2above[TX_4X4][ib + iblock[j] + 1], - tlcp + vp9_block2left[TX_4X4][ib + iblock[j]], + tac + (i & 1) * 2 + 1, + tlc + (i & 2) + ((j & 2) >> 1), TX_4X4, 16); xd->mode_info_context->mbmi.txfm_size = TX_8X8; } @@ -1924,9 +1848,9 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm, BLOCK_OFFSET(xd->plane[0].dqcoeff, idx, 16), 64); *distortion += thisdistortion; *labelyrate += cost_coeffs(cm, x, idx, PLANE_TYPE_Y_WITH_DC, - ta + vp9_block2above[TX_8X8][idx], - tl + vp9_block2left[TX_8X8][idx], TX_8X8, - 16); + ta + (i & 1) * 2, + tl + (i & 2), + TX_8X8, 16); } } } @@ -1996,18 +1920,11 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, vp9_variance_fn_ptr_t *v_fn_ptr; - ENTROPY_CONTEXT_PLANES t_above, t_left; - ENTROPY_CONTEXT *ta, *tl; - ENTROPY_CONTEXT_PLANES t_above_b, t_left_b; - ENTROPY_CONTEXT *ta_b, *tl_b; + ENTROPY_CONTEXT t_above[4], t_left[4]; + ENTROPY_CONTEXT t_above_b[4], t_left_b[4]; - vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES)); - vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); - - ta = (ENTROPY_CONTEXT *)&t_above; - tl = (ENTROPY_CONTEXT *)&t_left; - ta_b = (ENTROPY_CONTEXT *)&t_above_b; - tl_b = (ENTROPY_CONTEXT *)&t_left_b; + vpx_memcpy(t_above, x->e_mbd.plane[0].above_context, sizeof(t_above)); + vpx_memcpy(t_left, x->e_mbd.plane[0].left_context, sizeof(t_left)); v_fn_ptr = &cpi->fn_ptr[segmentation]; labels = vp9_mbsplits[segmentation]; @@ -2040,15 +1957,10 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, int64_t this_rd, other_rd; int distortion; int labelyrate; - ENTROPY_CONTEXT_PLANES t_above_s, t_left_s; - ENTROPY_CONTEXT *ta_s; - ENTROPY_CONTEXT *tl_s; - - vpx_memcpy(&t_above_s, &t_above, sizeof(ENTROPY_CONTEXT_PLANES)); - vpx_memcpy(&t_left_s, &t_left, sizeof(ENTROPY_CONTEXT_PLANES)); + ENTROPY_CONTEXT t_above_s[4], t_left_s[4]; - ta_s = (ENTROPY_CONTEXT *)&t_above_s; - tl_s = (ENTROPY_CONTEXT *)&t_left_s; + vpx_memcpy(t_above_s, t_above, sizeof(t_above_s)); + vpx_memcpy(t_left_s, t_left, sizeof(t_left_s)); // motion search for newmv (single predictor case only) if (mbmi->second_ref_frame <= 0 && this_mode == NEW4X4) { @@ -2183,13 +2095,13 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, if (segmentation == PARTITIONING_4X4) { this_rd = encode_inter_mb_segment(&cpi->common, x, labels, i, &labelyrate, - &distortion, ta_s, tl_s); + &distortion, t_above_s, t_left_s); other_rd = this_rd; } else { this_rd = encode_inter_mb_segment_8x8(&cpi->common, x, labels, i, &labelyrate, &distortion, &other_rd, - ta_s, tl_s); + t_above_s, t_left_s); } this_rd += RDCOST(x->rdmult, x->rddiv, rate, 0); rate += labelyrate; @@ -2215,14 +2127,14 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, if (other_rd < best_other_rd) best_other_rd = other_rd; - vpx_memcpy(ta_b, ta_s, sizeof(ENTROPY_CONTEXT_PLANES)); - vpx_memcpy(tl_b, tl_s, sizeof(ENTROPY_CONTEXT_PLANES)); + vpx_memcpy(t_above_b, t_above_s, sizeof(t_above_s)); + vpx_memcpy(t_left_b, t_left_s, sizeof(t_left_s)); } } /*for each 4x4 mode*/ - vpx_memcpy(ta, ta_b, sizeof(ENTROPY_CONTEXT_PLANES)); - vpx_memcpy(tl, tl_b, sizeof(ENTROPY_CONTEXT_PLANES)); + vpx_memcpy(t_above, t_above_b, sizeof(t_above)); + vpx_memcpy(t_left, t_left_b, sizeof(t_left)); labels2mode(x, labels, i, mode_selected, &mode_mv[mode_selected], &second_mode_mv[mode_selected], seg_mvs[i], diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index 67e1390..d1e4943 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -109,17 +109,24 @@ static void tokenize_b(VP9_COMP *cpi, int c = 0, rc = 0; TOKENEXTRA *t = *tp; /* store tokens starting here */ const struct plane_block_idx pb_idx = plane_block_idx(y_blocks, ib); + const BLOCK_SIZE_TYPE sb_type = mbmi->sb_type; + const int bwl = b_width_log2(sb_type); + const int off = pb_idx.block >> (2 * tx_size); + const int mod = bwl - tx_size - xd->plane[pb_idx.plane].subsampling_x; + const int aoff = (off & ((1 << mod) - 1)) << tx_size; + const int loff = (off >> mod) << tx_size; + ENTROPY_CONTEXT *A = xd->plane[pb_idx.plane].above_context + aoff; + ENTROPY_CONTEXT *L = xd->plane[pb_idx.plane].left_context + loff; const int eob = xd->plane[pb_idx.plane].eobs[pb_idx.block]; const int16_t *qcoeff_ptr = BLOCK_OFFSET(xd->plane[pb_idx.plane].qcoeff, pb_idx.block, 16); int seg_eob, default_eob, pad; const int segment_id = mbmi->segment_id; - const BLOCK_SIZE_TYPE sb_type = mbmi->sb_type; const int *scan, *nb; vp9_coeff_count *counts; vp9_coeff_probs *coef_probs; const int ref = mbmi->ref_frame != INTRA_FRAME; - ENTROPY_CONTEXT *a, *l, *a1, *l1, *a2, *l2, *a3, *l3, a_ec, l_ec; + ENTROPY_CONTEXT above_ec, left_ec; uint8_t token_cache[1024]; TX_TYPE tx_type = DCT_DCT; #if CONFIG_CODE_ZEROGROUP @@ -137,68 +144,14 @@ static void tokenize_b(VP9_COMP *cpi, #endif assert((!type && !pb_idx.plane) || (type && pb_idx.plane)); - if (sb_type == BLOCK_SIZE_SB64X64) { - a = (ENTROPY_CONTEXT *)xd->above_context + - vp9_block2above_sb64[tx_size][ib]; - l = (ENTROPY_CONTEXT *)xd->left_context + vp9_block2left_sb64[tx_size][ib]; - a1 = a + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l1 = l + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a2 = a1 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l2 = l1 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a3 = a2 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l3 = l2 + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - } else if (sb_type == BLOCK_SIZE_SB32X64) { - a = (ENTROPY_CONTEXT *)xd->above_context + - vp9_block2above_sb32x64[tx_size][ib]; - l = (ENTROPY_CONTEXT *)xd->left_context + - vp9_block2left_sb32x64[tx_size][ib]; - a1 = a + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l1 = l + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a2 = a3 = l2 = l3 = NULL; - } else if (sb_type == BLOCK_SIZE_SB64X32) { - a = (ENTROPY_CONTEXT *)xd->above_context + - vp9_block2above_sb64x32[tx_size][ib]; - l = (ENTROPY_CONTEXT *)xd->left_context + - vp9_block2left_sb64x32[tx_size][ib]; - a1 = a + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l1 = l + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a2 = a3 = l2 = l3 = NULL; - } else if (sb_type == BLOCK_SIZE_SB32X32) { - a = (ENTROPY_CONTEXT *)xd->above_context + vp9_block2above_sb[tx_size][ib]; - l = (ENTROPY_CONTEXT *)xd->left_context + vp9_block2left_sb[tx_size][ib]; - a1 = a + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l1 = l + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a2 = a3 = l2 = l3 = NULL; - } else if (sb_type == BLOCK_SIZE_SB16X32) { - a = (ENTROPY_CONTEXT *)xd->above_context + - vp9_block2above_sb16x32[tx_size][ib]; - l = (ENTROPY_CONTEXT *)xd->left_context + - vp9_block2left_sb16x32[tx_size][ib]; - a1 = a + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l1 = l + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a1 = l1 = a2 = l2 = a3 = l3 = NULL; - } else if (sb_type == BLOCK_SIZE_SB32X16) { - a = (ENTROPY_CONTEXT *)xd->above_context + - vp9_block2above_sb32x16[tx_size][ib]; - l = (ENTROPY_CONTEXT *)xd->left_context + - vp9_block2left_sb32x16[tx_size][ib]; - a1 = a + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - l1 = l + sizeof(ENTROPY_CONTEXT_PLANES) / sizeof(ENTROPY_CONTEXT); - a1 = l1 = a2 = l2 = a3 = l3 = NULL; - } else { - assert(sb_type == BLOCK_SIZE_MB16X16); - a = (ENTROPY_CONTEXT *)xd->above_context + vp9_block2above[tx_size][ib]; - l = (ENTROPY_CONTEXT *)xd->left_context + vp9_block2left[tx_size][ib]; - a1 = l1 = a2 = l2 = a3 = l3 = NULL; - } switch (tx_size) { default: case TX_4X4: { tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type_4x4(xd, ib) : DCT_DCT; - a_ec = *a; - l_ec = *l; + above_ec = A[0] != 0; + left_ec = L[0] != 0; seg_eob = 16; scan = get_scan_4x4(tx_type); counts = cpi->coef_counts_4x4; @@ -214,8 +167,8 @@ static void tokenize_b(VP9_COMP *cpi, const int x = ib & ((1 << sz) - 1), y = ib - x; tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type_8x8(xd, y + (x >> 1)) : DCT_DCT; - a_ec = (a[0] + a[1]) != 0; - l_ec = (l[0] + l[1]) != 0; + above_ec = (A[0] + A[1]) != 0; + left_ec = (L[0] + L[1]) != 0; seg_eob = 64; scan = get_scan_8x8(tx_type); counts = cpi->coef_counts_8x8; @@ -231,13 +184,8 @@ static void tokenize_b(VP9_COMP *cpi, const int x = ib & ((1 << sz) - 1), y = ib - x; tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? get_tx_type_16x16(xd, y + (x >> 2)) : DCT_DCT; - if (type != PLANE_TYPE_UV) { - a_ec = (a[0] + a[1] + a[2] + a[3]) != 0; - l_ec = (l[0] + l[1] + l[2] + l[3]) != 0; - } else { - a_ec = (a[0] + a[1] + a1[0] + a1[1]) != 0; - l_ec = (l[0] + l[1] + l1[0] + l1[1]) != 0; - } + above_ec = (A[0] + A[1] + A[2] + A[3]) != 0; + left_ec = (L[0] + L[1] + L[2] + L[3]) != 0; seg_eob = 256; scan = get_scan_16x16(tx_type); counts = cpi->coef_counts_16x16; @@ -249,17 +197,8 @@ static void tokenize_b(VP9_COMP *cpi, break; } case TX_32X32: - if (type != PLANE_TYPE_UV) { - a_ec = (a[0] + a[1] + a[2] + a[3] + - a1[0] + a1[1] + a1[2] + a1[3]) != 0; - l_ec = (l[0] + l[1] + l[2] + l[3] + - l1[0] + l1[1] + l1[2] + l1[3]) != 0; - } else { - a_ec = (a[0] + a[1] + a1[0] + a1[1] + - a2[0] + a2[1] + a3[0] + a3[1]) != 0; - l_ec = (l[0] + l[1] + l1[0] + l1[1] + - l2[0] + l2[1] + l3[0] + l3[1]) != 0; - } + above_ec = (A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7]) != 0; + left_ec = (L[0] + L[1] + L[2] + L[3] + L[4] + L[5] + L[6] + L[7]) != 0; seg_eob = 1024; scan = vp9_default_zig_zag1d_32x32; counts = cpi->coef_counts_32x32; @@ -271,7 +210,7 @@ static void tokenize_b(VP9_COMP *cpi, break; } - pt = combine_entropy_contexts(a_ec, l_ec); + pt = combine_entropy_contexts(above_ec, left_ec); nb = vp9_get_coef_neighbors_handle(scan, &pad); default_eob = seg_eob; @@ -403,33 +342,8 @@ static void tokenize_b(VP9_COMP *cpi, } while (c < eob && ++c < seg_eob); *tp = t; - a_ec = l_ec = (c > 0); /* 0 <-> all coeff data is zero */ - a[0] = a_ec; - l[0] = l_ec; - - if (tx_size == TX_8X8) { - a[1] = a_ec; - l[1] = l_ec; - } else if (tx_size == TX_16X16) { - if (type != PLANE_TYPE_UV) { - a[1] = a[2] = a[3] = a_ec; - l[1] = l[2] = l[3] = l_ec; - } else { - a1[0] = a1[1] = a[1] = a_ec; - l1[0] = l1[1] = l[1] = l_ec; - } - } else if (tx_size == TX_32X32) { - if (type != PLANE_TYPE_UV) { - a[1] = a[2] = a[3] = a_ec; - l[1] = l[2] = l[3] = l_ec; - a1[0] = a1[1] = a1[2] = a1[3] = a_ec; - l1[0] = l1[1] = l1[2] = l1[3] = l_ec; - } else { - a[1] = a1[0] = a1[1] = a_ec; - l[1] = l1[0] = l1[1] = l_ec; - a2[0] = a2[1] = a3[0] = a3[1] = a_ec; - l2[0] = l2[1] = l3[0] = l3[1] = l_ec; - } + for (pt = 0; pt < (1 << tx_size); pt++) { + A[pt] = L[pt] = c > 0; } } diff --git a/vp9/vp9_common.mk b/vp9/vp9_common.mk index aed6cc5..1ddd4f0 100644 --- a/vp9/vp9_common.mk +++ b/vp9/vp9_common.mk @@ -15,7 +15,6 @@ VP9_COMMON_SRCS-yes += common/vp9_ppflags.h VP9_COMMON_SRCS-yes += common/vp9_onyx.h VP9_COMMON_SRCS-yes += common/vp9_alloccommon.c VP9_COMMON_SRCS-yes += common/vp9_asm_com_offsets.c -VP9_COMMON_SRCS-yes += common/vp9_blockd.c VP9_COMMON_SRCS-yes += common/vp9_coefupdateprobs.h VP9_COMMON_SRCS-yes += common/vp9_convolve.c VP9_COMMON_SRCS-yes += common/vp9_convolve.h -- 2.7.4