| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 | |
| 12 #ifndef VP9_ENCODER_VP9_BLOCK_H_ | 11 #ifndef VP9_ENCODER_VP9_BLOCK_H_ |
| 13 #define VP9_ENCODER_VP9_BLOCK_H_ | 12 #define VP9_ENCODER_VP9_BLOCK_H_ |
| 14 | 13 |
| 15 #include "vp9/common/vp9_onyx.h" | 14 #include "vp9/common/vp9_onyx.h" |
| 16 #include "vp9/common/vp9_entropymv.h" | 15 #include "vp9/common/vp9_entropymv.h" |
| 17 #include "vp9/common/vp9_entropy.h" | 16 #include "vp9/common/vp9_entropy.h" |
| 18 #include "vpx_ports/mem.h" | 17 #include "vpx_ports/mem.h" |
| 19 #include "vp9/common/vp9_onyxc_int.h" | 18 #include "vp9/common/vp9_onyxc_int.h" |
| 20 | 19 |
| 21 // motion search site | 20 // motion search site |
| 22 typedef struct { | 21 typedef struct { |
| 23 MV mv; | 22 MV mv; |
| 24 int offset; | 23 int offset; |
| 25 } search_site; | 24 } search_site; |
| 26 | 25 |
| 27 typedef struct block { | 26 typedef struct block { |
| 28 // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries | 27 // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries |
| 29 short *src_diff; | 28 int16_t *src_diff; |
| 30 short *coeff; | 29 int16_t *coeff; |
| 31 | 30 |
| 32 // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries | 31 // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries |
| 33 short *quant; | 32 int16_t *quant; |
| 34 short *quant_fast; // fast quant deprecated for now | 33 int16_t *quant_fast; // fast quant deprecated for now |
| 35 unsigned char *quant_shift; | 34 uint8_t *quant_shift; |
| 36 short *zbin; | 35 int16_t *zbin; |
| 37 short *zbin_8x8; | 36 int16_t *zbin_8x8; |
| 38 short *zbin_16x16; | 37 int16_t *zbin_16x16; |
| 39 short *zrun_zbin_boost; | 38 int16_t *zbin_32x32; |
| 40 short *zrun_zbin_boost_8x8; | 39 int16_t *zrun_zbin_boost; |
| 41 short *zrun_zbin_boost_16x16; | 40 int16_t *zrun_zbin_boost_8x8; |
| 42 short *round; | 41 int16_t *zrun_zbin_boost_16x16; |
| 42 int16_t *zrun_zbin_boost_32x32; |
| 43 int16_t *round; |
| 43 | 44 |
| 44 // Zbin Over Quant value | 45 // Zbin Over Quant value |
| 45 short zbin_extra; | 46 short zbin_extra; |
| 46 | 47 |
| 47 unsigned char **base_src; | 48 uint8_t **base_src; |
| 48 unsigned char **base_second_src; | 49 uint8_t **base_second_src; |
| 49 int src; | 50 int src; |
| 50 int src_stride; | 51 int src_stride; |
| 51 | 52 |
| 52 int eob_max_offset; | 53 int eob_max_offset; |
| 53 int eob_max_offset_8x8; | 54 int eob_max_offset_8x8; |
| 54 int eob_max_offset_16x16; | 55 int eob_max_offset_16x16; |
| 56 int eob_max_offset_32x32; |
| 55 } BLOCK; | 57 } BLOCK; |
| 56 | 58 |
| 57 typedef struct { | 59 typedef struct { |
| 58 int count; | 60 int count; |
| 59 struct { | 61 struct { |
| 60 B_PREDICTION_MODE mode; | 62 B_PREDICTION_MODE mode; |
| 61 int_mv mv; | 63 int_mv mv; |
| 62 int_mv second_mv; | 64 int_mv second_mv; |
| 63 } bmi[16]; | 65 } bmi[16]; |
| 64 } PARTITION_INFO; | 66 } PARTITION_INFO; |
| 65 | 67 |
| 66 // Structure to hold snapshot of coding context during the mode picking process | 68 // Structure to hold snapshot of coding context during the mode picking process |
| 67 // TODO Do we need all of these? | 69 // TODO Do we need all of these? |
| 68 typedef struct { | 70 typedef struct { |
| 69 MODE_INFO mic; | 71 MODE_INFO mic; |
| 70 PARTITION_INFO partition_info; | 72 PARTITION_INFO partition_info; |
| 73 int skip; |
| 71 int_mv best_ref_mv; | 74 int_mv best_ref_mv; |
| 72 int_mv second_best_ref_mv; | 75 int_mv second_best_ref_mv; |
| 73 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REFS]; | 76 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; |
| 74 int rate; | 77 int rate; |
| 75 int distortion; | 78 int distortion; |
| 76 int64_t intra_error; | 79 int64_t intra_error; |
| 77 int best_mode_index; | 80 int best_mode_index; |
| 78 int rddiv; | 81 int rddiv; |
| 79 int rdmult; | 82 int rdmult; |
| 80 int hybrid_pred_diff; | 83 int hybrid_pred_diff; |
| 81 int comp_pred_diff; | 84 int comp_pred_diff; |
| 82 int single_pred_diff; | 85 int single_pred_diff; |
| 83 int64_t txfm_rd_diff[NB_TXFM_MODES]; | 86 int64_t txfm_rd_diff[NB_TXFM_MODES]; |
| 84 } PICK_MODE_CONTEXT; | 87 } PICK_MODE_CONTEXT; |
| 85 | 88 |
| 89 typedef struct superblock { |
| 90 DECLARE_ALIGNED(16, int16_t, src_diff[32*32+16*16*2]); |
| 91 DECLARE_ALIGNED(16, int16_t, coeff[32*32+16*16*2]); |
| 92 } SUPERBLOCK; |
| 93 |
| 86 typedef struct macroblock { | 94 typedef struct macroblock { |
| 87 DECLARE_ALIGNED(16, short, src_diff[400]); // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y | 95 DECLARE_ALIGNED(16, int16_t, src_diff[400]); // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y |
| 88 DECLARE_ALIGNED(16, short, coeff[400]); // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y | 96 DECLARE_ALIGNED(16, int16_t, coeff[400]); // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y |
| 89 #if !CONFIG_SUPERBLOCKS | |
| 90 DECLARE_ALIGNED(16, unsigned char, thismb[256]); // 16x16 Y | |
| 91 | |
| 92 unsigned char *thismb_ptr; | |
| 93 #endif | |
| 94 // 16 Y blocks, 4 U blocks, 4 V blocks, | 97 // 16 Y blocks, 4 U blocks, 4 V blocks, |
| 95 // 1 DC 2nd order block each with 16 entries | 98 // 1 DC 2nd order block each with 16 entries |
| 96 BLOCK block[25]; | 99 BLOCK block[25]; |
| 97 | 100 |
| 101 SUPERBLOCK sb_coeff_data; |
| 102 |
| 98 YV12_BUFFER_CONFIG src; | 103 YV12_BUFFER_CONFIG src; |
| 99 | 104 |
| 100 MACROBLOCKD e_mbd; | 105 MACROBLOCKD e_mbd; |
| 101 PARTITION_INFO *partition_info; /* work pointer */ | 106 PARTITION_INFO *partition_info; /* work pointer */ |
| 102 PARTITION_INFO *pi; /* Corresponds to upper left visible macroblock */ | 107 PARTITION_INFO *pi; /* Corresponds to upper left visible macroblock */ |
| 103 PARTITION_INFO *pip; /* Base of allocated array */ | 108 PARTITION_INFO *pip; /* Base of allocated array */ |
| 104 | 109 |
| 105 search_site *ss; | 110 search_site *ss; |
| 106 int ss_count; | 111 int ss_count; |
| 107 int searches_per_step; | 112 int searches_per_step; |
| 108 | 113 |
| 109 int errorperbit; | 114 int errorperbit; |
| 110 int sadperbit16; | 115 int sadperbit16; |
| 111 int sadperbit4; | 116 int sadperbit4; |
| 112 int rddiv; | 117 int rddiv; |
| 113 int rdmult; | 118 int rdmult; |
| 114 unsigned int *mb_activity_ptr; | 119 unsigned int *mb_activity_ptr; |
| 115 int *mb_norm_activity_ptr; | 120 int *mb_norm_activity_ptr; |
| 116 signed int act_zbin_adj; | 121 signed int act_zbin_adj; |
| 117 | 122 |
| 123 int mv_best_ref_index[MAX_REF_FRAMES]; |
| 124 |
| 118 int nmvjointcost[MV_JOINTS]; | 125 int nmvjointcost[MV_JOINTS]; |
| 119 int nmvcosts[2][MV_VALS]; | 126 int nmvcosts[2][MV_VALS]; |
| 120 int *nmvcost[2]; | 127 int *nmvcost[2]; |
| 121 int nmvcosts_hp[2][MV_VALS]; | 128 int nmvcosts_hp[2][MV_VALS]; |
| 122 int *nmvcost_hp[2]; | 129 int *nmvcost_hp[2]; |
| 123 int **mvcost; | 130 int **mvcost; |
| 124 | 131 |
| 125 int nmvjointsadcost[MV_JOINTS]; | 132 int nmvjointsadcost[MV_JOINTS]; |
| 126 int nmvsadcosts[2][MV_VALS]; | 133 int nmvsadcosts[2][MV_VALS]; |
| 127 int *nmvsadcost[2]; | 134 int *nmvsadcost[2]; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 146 | 153 |
| 147 int skip; | 154 int skip; |
| 148 | 155 |
| 149 int encode_breakout; | 156 int encode_breakout; |
| 150 | 157 |
| 151 // char * gf_active_ptr; | 158 // char * gf_active_ptr; |
| 152 signed char *gf_active_ptr; | 159 signed char *gf_active_ptr; |
| 153 | 160 |
| 154 unsigned char *active_ptr; | 161 unsigned char *active_ptr; |
| 155 | 162 |
| 156 unsigned int token_costs[TX_SIZE_MAX][BLOCK_TYPES][COEF_BANDS] | 163 vp9_coeff_count token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES_4X4]; |
| 157 [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; | 164 vp9_coeff_count hybrid_token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES_4X4]; |
| 158 unsigned int hybrid_token_costs[TX_SIZE_MAX][BLOCK_TYPES][COEF_BANDS] | |
| 159 [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; | |
| 160 | 165 |
| 161 int optimize; | 166 int optimize; |
| 162 | 167 |
| 163 // Structure to hold context for each of the 4 MBs within a SB: | 168 // Structure to hold context for each of the 4 MBs within a SB: |
| 164 // when encoded as 4 independent MBs: | 169 // when encoded as 4 independent MBs: |
| 165 PICK_MODE_CONTEXT mb_context[4]; | 170 PICK_MODE_CONTEXT mb_context[4][4]; |
| 166 #if CONFIG_SUPERBLOCKS | |
| 167 // when 4 MBs share coding parameters: | 171 // when 4 MBs share coding parameters: |
| 168 PICK_MODE_CONTEXT sb_context[4]; | 172 PICK_MODE_CONTEXT sb32_context[4]; |
| 169 #endif | 173 PICK_MODE_CONTEXT sb64_context; |
| 170 | 174 |
| 171 void (*vp9_short_fdct4x4)(short *input, short *output, int pitch); | 175 void (*vp9_short_fdct4x4)(int16_t *input, int16_t *output, int pitch); |
| 172 void (*vp9_short_fdct8x4)(short *input, short *output, int pitch); | 176 void (*vp9_short_fdct8x4)(int16_t *input, int16_t *output, int pitch); |
| 173 void (*short_walsh4x4)(short *input, short *output, int pitch); | 177 void (*short_walsh4x4)(int16_t *input, int16_t *output, int pitch); |
| 174 void (*quantize_b_4x4)(BLOCK *b, BLOCKD *d); | 178 void (*quantize_b_4x4)(BLOCK *b, BLOCKD *d); |
| 175 void (*quantize_b_4x4_pair)(BLOCK *b1, BLOCK *b2, BLOCKD *d0, BLOCKD *d1); | 179 void (*quantize_b_4x4_pair)(BLOCK *b1, BLOCK *b2, BLOCKD *d0, BLOCKD *d1); |
| 176 void (*vp9_short_fdct8x8)(short *input, short *output, int pitch); | 180 void (*vp9_short_fdct8x8)(int16_t *input, int16_t *output, int pitch); |
| 177 void (*vp9_short_fdct16x16)(short *input, short *output, int pitch); | 181 void (*vp9_short_fdct16x16)(int16_t *input, int16_t *output, int pitch); |
| 178 void (*short_fhaar2x2)(short *input, short *output, int pitch); | 182 void (*short_fhaar2x2)(int16_t *input, int16_t *output, int pitch); |
| 179 void (*quantize_b_16x16)(BLOCK *b, BLOCKD *d); | 183 void (*quantize_b_16x16)(BLOCK *b, BLOCKD *d); |
| 180 void (*quantize_b_8x8)(BLOCK *b, BLOCKD *d); | 184 void (*quantize_b_8x8)(BLOCK *b, BLOCKD *d); |
| 181 void (*quantize_b_2x2)(BLOCK *b, BLOCKD *d); | 185 void (*quantize_b_2x2)(BLOCK *b, BLOCKD *d); |
| 182 | |
| 183 } MACROBLOCK; | 186 } MACROBLOCK; |
| 184 | 187 |
| 185 | 188 #endif // VP9_ENCODER_VP9_BLOCK_H_ |
| 186 #endif | |
| OLD | NEW |