1 /* 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef VPX_VP8_ENCODER_BLOCK_H_ 12 #define VPX_VP8_ENCODER_BLOCK_H_ 13 14 #include "vp8/common/onyx.h" 15 #include "vp8/common/blockd.h" 16 #include "vp8/common/entropymv.h" 17 #include "vp8/common/entropy.h" 18 #include "vpx_ports/mem.h" 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #define MAX_MODES 20 25 #define MAX_ERROR_BINS 1024 26 27 /* motion search site */ 28 typedef struct { 29 MV mv; 30 int offset; 31 } search_site; 32 33 typedef struct block { 34 /* 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries */ 35 short *src_diff; 36 short *coeff; 37 38 /* 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries */ 39 short *quant; 40 short *quant_fast; 41 short *quant_shift; 42 short *zbin; 43 short *zrun_zbin_boost; 44 short *round; 45 46 /* Zbin Over Quant value */ 47 short zbin_extra; 48 49 unsigned char **base_src; 50 int src; 51 int src_stride; 52 } BLOCK; 53 54 typedef struct { 55 int count; 56 struct { 57 B_PREDICTION_MODE mode; 58 int_mv mv; 59 } bmi[16]; 60 } PARTITION_INFO; 61 62 typedef struct macroblock { 63 DECLARE_ALIGNED(16, short, src_diff[400]); /* 25 blocks Y,U,V,Y2 */ 64 DECLARE_ALIGNED(16, short, coeff[400]); /* 25 blocks Y,U,V,Y2 */ 65 DECLARE_ALIGNED(16, unsigned char, thismb[256]); 66 67 unsigned char *thismb_ptr; 68 /* 16 Y, 4 U, 4 V, 1 DC 2nd order block */ 69 BLOCK block[25]; 70 71 YV12_BUFFER_CONFIG src; 72 73 MACROBLOCKD e_mbd; 74 PARTITION_INFO *partition_info; /* work pointer */ 75 PARTITION_INFO *pi; /* Corresponds to upper left visible macroblock */ 76 PARTITION_INFO *pip; /* Base of allocated array */ 77 78 int ref_frame_cost[MAX_REF_FRAMES]; 79 80 search_site *ss; 81 int ss_count; 82 int searches_per_step; 83 84 int errorperbit; 85 int sadperbit16; 86 int sadperbit4; 87 int rddiv; 88 int rdmult; 89 unsigned int *mb_activity_ptr; 90 int *mb_norm_activity_ptr; 91 signed int act_zbin_adj; 92 signed int last_act_zbin_adj; 93 94 int *mvcost[2]; 95 /* MSVC generates code that thinks this is 16-byte aligned */ 96 DECLARE_ALIGNED(16, int*, mvsadcost[2]); 97 int (*mbmode_cost)[MB_MODE_COUNT]; 98 int (*intra_uv_mode_cost)[MB_MODE_COUNT]; 99 int (*bmode_costs)[10][10]; 100 int *inter_bmode_costs; 101 int (*token_costs)[COEF_BANDS][PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; 102 103 /* These define limits to motion vector components to prevent 104 * them from extending outside the UMV borders. 105 */ 106 int mv_col_min; 107 int mv_col_max; 108 int mv_row_min; 109 int mv_row_max; 110 111 int skip; 112 113 unsigned int encode_breakout; 114 115 signed char *gf_active_ptr; 116 117 unsigned char *active_ptr; 118 MV_CONTEXT *mvc; 119 120 int optimize; 121 int q_index; 122 int is_skin; 123 int denoise_zeromv; 124 125 #if CONFIG_TEMPORAL_DENOISING 126 int increase_denoising; 127 MB_PREDICTION_MODE best_sse_inter_mode; 128 int_mv best_sse_mv; 129 MV_REFERENCE_FRAME best_reference_frame; 130 MV_REFERENCE_FRAME best_zeromv_reference_frame; 131 unsigned char need_to_clamp_best_mvs; 132 #endif 133 134 int skip_true_count; 135 unsigned int coef_counts[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] 136 [MAX_ENTROPY_TOKENS]; 137 unsigned int MVcount[2][MVvals]; /* (row,col) MV cts this frame */ 138 int ymode_count[VP8_YMODES]; /* intra MB type cts this frame */ 139 int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */ 140 int64_t prediction_error; 141 int64_t intra_error; 142 int count_mb_ref_frame_usage[MAX_REF_FRAMES]; 143 144 int rd_thresh_mult[MAX_MODES]; 145 int rd_threshes[MAX_MODES]; 146 unsigned int mbs_tested_so_far; 147 unsigned int mode_test_hit_counts[MAX_MODES]; 148 int zbin_mode_boost_enabled; 149 int zbin_mode_boost; 150 int last_zbin_mode_boost; 151 152 int last_zbin_over_quant; 153 int zbin_over_quant; 154 int error_bins[MAX_ERROR_BINS]; 155 156 void (*short_fdct4x4)(short *input, short *output, int pitch); 157 void (*short_fdct8x4)(short *input, short *output, int pitch); 158 void (*short_walsh4x4)(short *input, short *output, int pitch); 159 void (*quantize_b)(BLOCK *b, BLOCKD *d); 160 161 unsigned int mbs_zero_last_dot_suppress; 162 int zero_last_dot_suppress; 163 } MACROBLOCK; 164 165 #ifdef __cplusplus 166 } // extern "C" 167 #endif 168 169 #endif // VPX_VP8_ENCODER_BLOCK_H_ 170