16fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org/* 26fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 36fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * 46fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * Use of this source code is governed by a BSD-style license 56fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * that can be found in the LICENSE file in the root of the source 66fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * tree. An additional intellectual property rights grant can be found 76fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * in the file PATENTS. All contributing project authors may 86fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * be found in the AUTHORS file in the root of the source tree. 96fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org */ 106fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 116fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org#ifndef VP9_ENCODER_VP9_BLOCK_H_ 126fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org#define VP9_ENCODER_VP9_BLOCK_H_ 136fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 146fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org#include "vp9/common/vp9_entropymv.h" 156fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org#include "vp9/common/vp9_entropy.h" 166fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org#include "vpx_ports/mem.h" 176fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org#include "vp9/common/vp9_onyxc_int.h" 186fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 19dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org#ifdef __cplusplus 20dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.orgextern "C" { 21dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org#endif 22dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org 23e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.orgtypedef struct { 24e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org unsigned int sse; 25e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org int sum; 26e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org unsigned int var; 27e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org} diff; 28e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org 2910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.orgstruct macroblock_plane { 30ecee051929d6ced19cf324688774acccc9ad4a0ajohannkoenig@chromium.org DECLARE_ALIGNED(16, int16_t, src_diff[64 * 64]); 3187997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org tran_low_t *qcoeff; 3287997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org tran_low_t *coeff; 33d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org uint16_t *eobs; 3410a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org struct buf_2d src; 3510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 3610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org // Quantizer setings 3788b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org int16_t *quant_fp; 38e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org int16_t *round_fp; 3910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org int16_t *quant; 4047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org int16_t *quant_shift; 4110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org int16_t *zbin; 4210a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org int16_t *round; 4310a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 4441294d96d7dbf9bc215b09832a8336c5fb158f0bjohannkoenig@chromium.org int64_t quant_thred[2]; 4510a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org // Zbin Over Quant value 4610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org int16_t zbin_extra; 4710a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org}; 4810a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 4953a13f1fa964820f7a8f9d3932a6f3c0433f8bf5fgalligan@chromium.org/* The [2] dimension is for whether we skip the EOB node (i.e. if previous 5053a13f1fa964820f7a8f9d3932a6f3c0433f8bf5fgalligan@chromium.org * coefficient in this block was zero) or not. */ 51d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.orgtypedef unsigned int vp9_coeff_cost[PLANE_TYPES][REF_TYPES][COEF_BANDS][2] 52d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org [COEFF_CONTEXTS][ENTROPY_TOKENS]; 5353a13f1fa964820f7a8f9d3932a6f3c0433f8bf5fgalligan@chromium.org 5490c5310de3dfbd1b1624502616cbc8aaf9ad25f0johannkoenig@chromium.orgtypedef struct macroblock MACROBLOCK; 5590c5310de3dfbd1b1624502616cbc8aaf9ad25f0johannkoenig@chromium.orgstruct macroblock { 5610a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org struct macroblock_plane plane[MAX_MB_PLANE]; 576fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 586fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org MACROBLOCKD e_mbd; 5910a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org int skip_block; 6088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org int select_tx_size; 61d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org int skip_recode; 62d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org int skip_optimize; 63d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org int q_index; 646fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 656fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int errorperbit; 666fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int sadperbit16; 676fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int sadperbit4; 686fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int rddiv; 696fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int rdmult; 7041294d96d7dbf9bc215b09832a8336c5fb158f0bjohannkoenig@chromium.org int mb_energy; 716fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 72d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org int mv_best_ref_index[MAX_REF_FRAMES]; 7347265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org unsigned int max_mv_context[MAX_REF_FRAMES]; 7453a13f1fa964820f7a8f9d3932a6f3c0433f8bf5fgalligan@chromium.org unsigned int source_variance; 75dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org unsigned int pred_sse[MAX_REF_FRAMES]; 76dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org int pred_mv_sad[MAX_REF_FRAMES]; 77d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org 786fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int nmvjointcost[MV_JOINTS]; 796fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int *nmvcost[2]; 806fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int *nmvcost_hp[2]; 816fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int **mvcost; 826fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 836fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int nmvjointsadcost[MV_JOINTS]; 846fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int *nmvsadcost[2]; 856fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int *nmvsadcost_hp[2]; 866fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int **mvsadcost; 876fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 886fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org // These define limits to motion vector components to prevent them 896fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org // from extending outside the UMV borders 906fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int mv_col_min; 916fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int mv_col_max; 926fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int mv_row_min; 936fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int mv_row_max; 946fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 95ecee051929d6ced19cf324688774acccc9ad4a0ajohannkoenig@chromium.org uint8_t zcoeff_blk[TX_SIZES][256]; 966fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int skip; 976fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 986fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int encode_breakout; 996fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 10010a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org // note that token_costs is the cost when eob node is skipped 10153a13f1fa964820f7a8f9d3932a6f3c0433f8bf5fgalligan@chromium.org vp9_coeff_cost token_costs[TX_SIZES]; 1026fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 103693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com int in_static_area; 104693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com 1056fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org int optimize; 1066fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org 1076ffb5d8eaaa9cb68c354c46f375ccc5b9bc8b107jpet@google.com // indicate if it is in the rd search loop or encoding process 10853a13f1fa964820f7a8f9d3932a6f3c0433f8bf5fgalligan@chromium.org int use_lp32x32fdct; 10947265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org int skip_encode; 11047265f8fe3a36a426773454ad90d20c9aa616c24johannkoenig@chromium.org 111e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org // use fast quantization process 112e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org int quant_fp; 113e2064011d36b2008099446503f28e64d445060ecjohannkoenig@chromium.org 11488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org // skip forward transform and quantization 115d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org uint8_t skip_txfm[MAX_MB_PLANE << 2]; 11641294d96d7dbf9bc215b09832a8336c5fb158f0bjohannkoenig@chromium.org 117d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org int64_t bsse[MAX_MB_PLANE << 2]; 1186ffb5d8eaaa9cb68c354c46f375ccc5b9bc8b107jpet@google.com 11988b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org // Used to store sub partition's choices. 12088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org MV pred_mv[MAX_REF_FRAMES]; 12110a9a0d835561a7f2300c561c514efcf374554d6fgalligan@chromium.org 12287997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org void (*fwd_txm4x4)(const int16_t *input, tran_low_t *output, int stride); 12387997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org void (*itxm_add)(const tran_low_t *input, uint8_t *dest, int stride, int eob); 12487997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org#if CONFIG_VP9_HIGHBITDEPTH 12587997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org void (*high_itxm_add)(const tran_low_t *input, uint8_t *dest, int stride, 12687997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org int eob, int bd); 12787997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org#endif 128ecee051929d6ced19cf324688774acccc9ad4a0ajohannkoenig@chromium.org}; 129ecee051929d6ced19cf324688774acccc9ad4a0ajohannkoenig@chromium.org 130dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org#ifdef __cplusplus 131dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org} // extern "C" 132dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org#endif 133dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org 134d348b8d765c019ee7250075d663a83db00c65c08tomfinegan@chromium.org#endif // VP9_ENCODER_VP9_BLOCK_H_ 135