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 VP8_ENCODER_BLOCK_H_ 12 #define 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 int *mvsadcost[2]; 96 int (*mbmode_cost)[MB_MODE_COUNT]; 97 int (*intra_uv_mode_cost)[MB_MODE_COUNT]; 98 int (*bmode_costs)[10][10]; 99 int *inter_bmode_costs; 100 int (*token_costs)[COEF_BANDS][PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; 101 102 /* These define limits to motion vector components to prevent 103 * them from extending outside the UMV borders. 104 */ 105 int mv_col_min; 106 int mv_col_max; 107 int mv_row_min; 108 int mv_row_max; 109 110 int skip; 111 112 unsigned int encode_breakout; 113 114 signed char *gf_active_ptr; 115 116 unsigned char *active_ptr; 117 MV_CONTEXT *mvc; 118 119 int optimize; 120 int q_index; 121 int is_skin; 122 int denoise_zeromv; 123 124 #if CONFIG_TEMPORAL_DENOISING 125 int increase_denoising; 126 MB_PREDICTION_MODE best_sse_inter_mode; 127 int_mv best_sse_mv; 128 MV_REFERENCE_FRAME best_reference_frame; 129 MV_REFERENCE_FRAME best_zeromv_reference_frame; 130 unsigned char need_to_clamp_best_mvs; 131 #endif 132 133 int skip_true_count; 134 unsigned int coef_counts[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] 135 [MAX_ENTROPY_TOKENS]; 136 unsigned int MVcount[2][MVvals]; /* (row,col) MV cts this frame */ 137 int ymode_count[VP8_YMODES]; /* intra MB type cts this frame */ 138 int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */ 139 int64_t prediction_error; 140 int64_t intra_error; 141 int count_mb_ref_frame_usage[MAX_REF_FRAMES]; 142 143 int rd_thresh_mult[MAX_MODES]; 144 int rd_threshes[MAX_MODES]; 145 unsigned int mbs_tested_so_far; 146 unsigned int mode_test_hit_counts[MAX_MODES]; 147 int zbin_mode_boost_enabled; 148 int zbin_mode_boost; 149 int last_zbin_mode_boost; 150 151 int last_zbin_over_quant; 152 int zbin_over_quant; 153 int error_bins[MAX_ERROR_BINS]; 154 155 void (*short_fdct4x4)(short *input, short *output, int pitch); 156 void (*short_fdct8x4)(short *input, short *output, int pitch); 157 void (*short_walsh4x4)(short *input, short *output, int pitch); 158 void (*quantize_b)(BLOCK *b, BLOCKD *d); 159 160 unsigned int mbs_zero_last_dot_suppress; 161 int zero_last_dot_suppress; 162 } MACROBLOCK; 163 164 #ifdef __cplusplus 165 } // extern "C" 166 #endif 167 168 #endif // VP8_ENCODER_BLOCK_H_ 169