| 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 | 11 |
| 12 #ifndef VP9_COMMON_VP9_BLOCKD_H_ | 12 #ifndef VP9_COMMON_VP9_BLOCKD_H_ |
| 13 #define VP9_COMMON_VP9_BLOCKD_H_ | 13 #define VP9_COMMON_VP9_BLOCKD_H_ |
| 14 | 14 |
| 15 #include "./vpx_config.h" | 15 #include "./vpx_config.h" |
| 16 | 16 |
| 17 #include "vpx_ports/mem.h" | 17 #include "vpx_ports/mem.h" |
| 18 #include "vpx_scale/yv12config.h" | 18 #include "vpx_scale/yv12config.h" |
| 19 | 19 |
| 20 #include "vp9/common/vp9_common.h" | 20 #include "vp9/common/vp9_common.h" |
| 21 #include "vp9/common/vp9_common_data.h" | 21 #include "vp9/common/vp9_common_data.h" |
| 22 #include "vp9/common/vp9_enums.h" | 22 #include "vp9/common/vp9_enums.h" |
| 23 #include "vp9/common/vp9_filter.h" |
| 23 #include "vp9/common/vp9_mv.h" | 24 #include "vp9/common/vp9_mv.h" |
| 24 #include "vp9/common/vp9_scale.h" | 25 #include "vp9/common/vp9_scale.h" |
| 25 #include "vp9/common/vp9_seg_common.h" | 26 #include "vp9/common/vp9_seg_common.h" |
| 26 #include "vp9/common/vp9_treecoder.h" | 27 #include "vp9/common/vp9_treecoder.h" |
| 27 | 28 |
| 28 #define BLOCK_SIZE_GROUPS 4 | 29 #define BLOCK_SIZE_GROUPS 4 |
| 29 #define MBSKIP_CONTEXTS 3 | 30 #define MBSKIP_CONTEXTS 3 |
| 30 | 31 |
| 31 /* Segment Feature Masks */ | 32 /* Segment Feature Masks */ |
| 32 #define MAX_MV_REF_CANDIDATES 2 | 33 #define MAX_MV_REF_CANDIDATES 2 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 45 typedef char PARTITION_CONTEXT; | 46 typedef char PARTITION_CONTEXT; |
| 46 | 47 |
| 47 static INLINE int combine_entropy_contexts(ENTROPY_CONTEXT a, | 48 static INLINE int combine_entropy_contexts(ENTROPY_CONTEXT a, |
| 48 ENTROPY_CONTEXT b) { | 49 ENTROPY_CONTEXT b) { |
| 49 return (a != 0) + (b != 0); | 50 return (a != 0) + (b != 0); |
| 50 } | 51 } |
| 51 | 52 |
| 52 typedef enum { | 53 typedef enum { |
| 53 KEY_FRAME = 0, | 54 KEY_FRAME = 0, |
| 54 INTER_FRAME = 1, | 55 INTER_FRAME = 1, |
| 55 NUM_FRAME_TYPES, | 56 FRAME_TYPES, |
| 56 } FRAME_TYPE; | 57 } FRAME_TYPE; |
| 57 | 58 |
| 58 typedef enum { | 59 typedef enum { |
| 59 EIGHTTAP = 0, | |
| 60 EIGHTTAP_SMOOTH = 1, | |
| 61 EIGHTTAP_SHARP = 2, | |
| 62 BILINEAR = 3, | |
| 63 SWITCHABLE = 4 /* should be the last one */ | |
| 64 } INTERPOLATIONFILTERTYPE; | |
| 65 | |
| 66 typedef enum { | |
| 67 DC_PRED, // Average of above and left pixels | 60 DC_PRED, // Average of above and left pixels |
| 68 V_PRED, // Vertical | 61 V_PRED, // Vertical |
| 69 H_PRED, // Horizontal | 62 H_PRED, // Horizontal |
| 70 D45_PRED, // Directional 45 deg = round(arctan(1/1) * 180/pi) | 63 D45_PRED, // Directional 45 deg = round(arctan(1/1) * 180/pi) |
| 71 D135_PRED, // Directional 135 deg = 180 - 45 | 64 D135_PRED, // Directional 135 deg = 180 - 45 |
| 72 D117_PRED, // Directional 117 deg = 180 - 63 | 65 D117_PRED, // Directional 117 deg = 180 - 63 |
| 73 D153_PRED, // Directional 153 deg = 180 - 27 | 66 D153_PRED, // Directional 153 deg = 180 - 27 |
| 74 D207_PRED, // Directional 207 deg = 180 + 27 | 67 D207_PRED, // Directional 207 deg = 180 + 27 |
| 75 D63_PRED, // Directional 63 deg = round(arctan(2/1) * 180/pi) | 68 D63_PRED, // Directional 63 deg = round(arctan(2/1) * 180/pi) |
| 76 TM_PRED, // True-motion | 69 TM_PRED, // True-motion |
| (...skipping 17 matching lines...) Expand all Loading... |
| 94 #define INTER_MODES (1 + NEWMV - NEARESTMV) | 87 #define INTER_MODES (1 + NEWMV - NEARESTMV) |
| 95 | 88 |
| 96 static INLINE int inter_mode_offset(MB_PREDICTION_MODE mode) { | 89 static INLINE int inter_mode_offset(MB_PREDICTION_MODE mode) { |
| 97 return (mode - NEARESTMV); | 90 return (mode - NEARESTMV); |
| 98 } | 91 } |
| 99 | 92 |
| 100 /* For keyframes, intra block modes are predicted by the (already decoded) | 93 /* For keyframes, intra block modes are predicted by the (already decoded) |
| 101 modes for the Y blocks to the left and above us; for interframes, there | 94 modes for the Y blocks to the left and above us; for interframes, there |
| 102 is a single probability table. */ | 95 is a single probability table. */ |
| 103 | 96 |
| 104 union b_mode_info { | 97 typedef struct { |
| 105 MB_PREDICTION_MODE as_mode; | 98 MB_PREDICTION_MODE as_mode; |
| 106 int_mv as_mv[2]; // first, second inter predictor motion vectors | 99 int_mv as_mv[2]; // first, second inter predictor motion vectors |
| 107 }; | 100 } b_mode_info; |
| 108 | 101 |
| 109 typedef enum { | 102 typedef enum { |
| 110 NONE = -1, | 103 NONE = -1, |
| 111 INTRA_FRAME = 0, | 104 INTRA_FRAME = 0, |
| 112 LAST_FRAME = 1, | 105 LAST_FRAME = 1, |
| 113 GOLDEN_FRAME = 2, | 106 GOLDEN_FRAME = 2, |
| 114 ALTREF_FRAME = 3, | 107 ALTREF_FRAME = 3, |
| 115 MAX_REF_FRAMES = 4 | 108 MAX_REF_FRAMES = 4 |
| 116 } MV_REFERENCE_FRAME; | 109 } MV_REFERENCE_FRAME; |
| 117 | 110 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 130 return mi_height_log2_lookup[sb_type]; | 123 return mi_height_log2_lookup[sb_type]; |
| 131 } | 124 } |
| 132 | 125 |
| 133 // This structure now relates to 8x8 block regions. | 126 // This structure now relates to 8x8 block regions. |
| 134 typedef struct { | 127 typedef struct { |
| 135 MB_PREDICTION_MODE mode, uv_mode; | 128 MB_PREDICTION_MODE mode, uv_mode; |
| 136 MV_REFERENCE_FRAME ref_frame[2]; | 129 MV_REFERENCE_FRAME ref_frame[2]; |
| 137 TX_SIZE tx_size; | 130 TX_SIZE tx_size; |
| 138 int_mv mv[2]; // for each reference frame used | 131 int_mv mv[2]; // for each reference frame used |
| 139 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; | 132 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; |
| 140 int_mv best_mv, best_second_mv; | 133 int_mv best_mv[2]; |
| 141 | 134 |
| 142 uint8_t mode_context[MAX_REF_FRAMES]; | 135 uint8_t mode_context[MAX_REF_FRAMES]; |
| 143 | 136 |
| 144 unsigned char skip_coeff; // 0=need to decode coeffs, 1=no coefficients | 137 unsigned char skip_coeff; // 0=need to decode coeffs, 1=no coefficients |
| 145 unsigned char segment_id; // Segment id for this block. | 138 unsigned char segment_id; // Segment id for this block. |
| 146 | 139 |
| 147 // Flags used for prediction status of various bit-stream signals | 140 // Flags used for prediction status of various bit-stream signals |
| 148 unsigned char seg_id_predicted; | 141 unsigned char seg_id_predicted; |
| 149 | 142 |
| 150 INTERPOLATIONFILTERTYPE interp_filter; | 143 INTERPOLATION_TYPE interp_filter; |
| 151 | 144 |
| 152 BLOCK_SIZE sb_type; | 145 BLOCK_SIZE sb_type; |
| 153 } MB_MODE_INFO; | 146 } MB_MODE_INFO; |
| 154 | 147 |
| 155 typedef struct { | 148 typedef struct { |
| 156 MB_MODE_INFO mbmi; | 149 MB_MODE_INFO mbmi; |
| 157 union b_mode_info bmi[4]; | 150 b_mode_info bmi[4]; |
| 158 } MODE_INFO; | 151 } MODE_INFO; |
| 159 | 152 |
| 160 static INLINE int is_inter_block(const MB_MODE_INFO *mbmi) { | 153 static INLINE int is_inter_block(const MB_MODE_INFO *mbmi) { |
| 161 return mbmi->ref_frame[0] > INTRA_FRAME; | 154 return mbmi->ref_frame[0] > INTRA_FRAME; |
| 162 } | 155 } |
| 163 | 156 |
| 164 static INLINE int has_second_ref(const MB_MODE_INFO *mbmi) { | 157 static INLINE int has_second_ref(const MB_MODE_INFO *mbmi) { |
| 165 return mbmi->ref_frame[1] > INTRA_FRAME; | 158 return mbmi->ref_frame[1] > INTRA_FRAME; |
| 166 } | 159 } |
| 167 | 160 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 196 }; | 189 }; |
| 197 | 190 |
| 198 #define BLOCK_OFFSET(x, i) ((x) + (i) * 16) | 191 #define BLOCK_OFFSET(x, i) ((x) + (i) * 16) |
| 199 | 192 |
| 200 typedef struct macroblockd { | 193 typedef struct macroblockd { |
| 201 struct macroblockd_plane plane[MAX_MB_PLANE]; | 194 struct macroblockd_plane plane[MAX_MB_PLANE]; |
| 202 | 195 |
| 203 struct scale_factors scale_factor[2]; | 196 struct scale_factors scale_factor[2]; |
| 204 | 197 |
| 205 MODE_INFO *last_mi; | 198 MODE_INFO *last_mi; |
| 206 MODE_INFO *this_mi; | |
| 207 int mode_info_stride; | 199 int mode_info_stride; |
| 208 | 200 |
| 209 MODE_INFO *mic_stream_ptr; | |
| 210 | |
| 211 // A NULL indicates that the 8x8 is not part of the image | 201 // A NULL indicates that the 8x8 is not part of the image |
| 212 MODE_INFO **mi_8x8; | 202 MODE_INFO **mi_8x8; |
| 213 MODE_INFO **prev_mi_8x8; | 203 MODE_INFO **prev_mi_8x8; |
| 204 MODE_INFO *mi_stream; |
| 214 | 205 |
| 215 int up_available; | 206 int up_available; |
| 216 int left_available; | 207 int left_available; |
| 217 int right_available; | |
| 218 | |
| 219 // partition contexts | |
| 220 PARTITION_CONTEXT *above_seg_context; | |
| 221 PARTITION_CONTEXT *left_seg_context; | |
| 222 | 208 |
| 223 /* Distance of MB away from frame edges */ | 209 /* Distance of MB away from frame edges */ |
| 224 int mb_to_left_edge; | 210 int mb_to_left_edge; |
| 225 int mb_to_right_edge; | 211 int mb_to_right_edge; |
| 226 int mb_to_top_edge; | 212 int mb_to_top_edge; |
| 227 int mb_to_bottom_edge; | 213 int mb_to_bottom_edge; |
| 228 | 214 |
| 229 int lossless; | 215 int lossless; |
| 230 /* Inverse transform function pointers. */ | 216 /* Inverse transform function pointers. */ |
| 231 void (*inv_txm4x4_1_add)(int16_t *input, uint8_t *dest, int stride); | 217 void (*itxm_add)(const int16_t *input, uint8_t *dest, int stride, int eob); |
| 232 void (*inv_txm4x4_add)(int16_t *input, uint8_t *dest, int stride); | |
| 233 void (*itxm_add)(int16_t *input, uint8_t *dest, int stride, int eob); | |
| 234 | 218 |
| 235 struct subpix_fn_table subpix; | 219 struct subpix_fn_table subpix; |
| 236 | 220 |
| 237 int allow_high_precision_mv; | |
| 238 | |
| 239 int corrupted; | 221 int corrupted; |
| 240 | 222 |
| 241 unsigned char sb_index; // index of 32x32 block inside the 64x64 block | 223 unsigned char sb_index; // index of 32x32 block inside the 64x64 block |
| 242 unsigned char mb_index; // index of 16x16 block inside the 32x32 block | 224 unsigned char mb_index; // index of 16x16 block inside the 32x32 block |
| 243 unsigned char b_index; // index of 8x8 block inside the 16x16 block | 225 unsigned char b_index; // index of 8x8 block inside the 16x16 block |
| 244 unsigned char ab_index; // index of 4x4 block inside the 8x8 block | 226 unsigned char ab_index; // index of 4x4 block inside the 8x8 block |
| 245 | 227 |
| 246 int q_index; | 228 int q_index; |
| 247 | 229 |
| 230 /* Y,U,V,(A) */ |
| 231 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; |
| 232 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; |
| 233 |
| 234 PARTITION_CONTEXT *above_seg_context; |
| 235 PARTITION_CONTEXT left_seg_context[8]; |
| 248 } MACROBLOCKD; | 236 } MACROBLOCKD; |
| 249 | 237 |
| 250 static INLINE unsigned char *get_sb_index(MACROBLOCKD *xd, BLOCK_SIZE subsize) { | |
| 251 switch (subsize) { | |
| 252 case BLOCK_64X64: | |
| 253 case BLOCK_64X32: | |
| 254 case BLOCK_32X64: | |
| 255 case BLOCK_32X32: | |
| 256 return &xd->sb_index; | |
| 257 case BLOCK_32X16: | |
| 258 case BLOCK_16X32: | |
| 259 case BLOCK_16X16: | |
| 260 return &xd->mb_index; | |
| 261 case BLOCK_16X8: | |
| 262 case BLOCK_8X16: | |
| 263 case BLOCK_8X8: | |
| 264 return &xd->b_index; | |
| 265 case BLOCK_8X4: | |
| 266 case BLOCK_4X8: | |
| 267 case BLOCK_4X4: | |
| 268 return &xd->ab_index; | |
| 269 default: | |
| 270 assert(0); | |
| 271 return NULL; | |
| 272 } | |
| 273 } | |
| 274 | 238 |
| 275 static INLINE void update_partition_context(MACROBLOCKD *xd, BLOCK_SIZE sb_type, | |
| 276 BLOCK_SIZE sb_size) { | |
| 277 const int bsl = b_width_log2(sb_size), bs = (1 << bsl) / 2; | |
| 278 const int bwl = b_width_log2(sb_type); | |
| 279 const int bhl = b_height_log2(sb_type); | |
| 280 const int boffset = b_width_log2(BLOCK_64X64) - bsl; | |
| 281 const char pcval0 = ~(0xe << boffset); | |
| 282 const char pcval1 = ~(0xf << boffset); | |
| 283 const char pcvalue[2] = {pcval0, pcval1}; | |
| 284 | |
| 285 assert(MAX(bwl, bhl) <= bsl); | |
| 286 | |
| 287 // update the partition context at the end notes. set partition bits | |
| 288 // of block sizes larger than the current one to be one, and partition | |
| 289 // bits of smaller block sizes to be zero. | |
| 290 vpx_memset(xd->above_seg_context, pcvalue[bwl == bsl], bs); | |
| 291 vpx_memset(xd->left_seg_context, pcvalue[bhl == bsl], bs); | |
| 292 } | |
| 293 | |
| 294 static INLINE int partition_plane_context(MACROBLOCKD *xd, BLOCK_SIZE sb_type) { | |
| 295 int bsl = mi_width_log2(sb_type), bs = 1 << bsl; | |
| 296 int above = 0, left = 0, i; | |
| 297 int boffset = mi_width_log2(BLOCK_64X64) - bsl; | |
| 298 | |
| 299 assert(mi_width_log2(sb_type) == mi_height_log2(sb_type)); | |
| 300 assert(bsl >= 0); | |
| 301 assert(boffset >= 0); | |
| 302 | |
| 303 for (i = 0; i < bs; i++) | |
| 304 above |= (xd->above_seg_context[i] & (1 << boffset)); | |
| 305 for (i = 0; i < bs; i++) | |
| 306 left |= (xd->left_seg_context[i] & (1 << boffset)); | |
| 307 | |
| 308 above = (above > 0); | |
| 309 left = (left > 0); | |
| 310 | |
| 311 return (left * 2 + above) + bsl * PARTITION_PLOFFSET; | |
| 312 } | |
| 313 | 239 |
| 314 static BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, PARTITION_TYPE partition) { | 240 static BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, PARTITION_TYPE partition) { |
| 315 const BLOCK_SIZE subsize = subsize_lookup[partition][bsize]; | 241 const BLOCK_SIZE subsize = subsize_lookup[partition][bsize]; |
| 316 assert(subsize < BLOCK_SIZES); | 242 assert(subsize < BLOCK_SIZES); |
| 317 return subsize; | 243 return subsize; |
| 318 } | 244 } |
| 319 | 245 |
| 320 extern const TX_TYPE mode2txfm_map[MB_MODE_COUNT]; | 246 extern const TX_TYPE mode2txfm_map[MB_MODE_COUNT]; |
| 321 | 247 |
| 322 static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, | 248 static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, |
| 323 const MACROBLOCKD *xd, int ib) { | 249 const MACROBLOCKD *xd, int ib) { |
| 324 const MODE_INFO *const mi = xd->this_mi; | 250 const MODE_INFO *const mi = xd->mi_8x8[0]; |
| 325 const MB_MODE_INFO *const mbmi = &mi->mbmi; | 251 const MB_MODE_INFO *const mbmi = &mi->mbmi; |
| 326 | 252 |
| 327 if (plane_type != PLANE_TYPE_Y_WITH_DC || | 253 if (plane_type != PLANE_TYPE_Y_WITH_DC || |
| 328 xd->lossless || | 254 xd->lossless || |
| 329 is_inter_block(mbmi)) | 255 is_inter_block(mbmi)) |
| 330 return DCT_DCT; | 256 return DCT_DCT; |
| 331 | 257 |
| 332 return mode2txfm_map[mbmi->sb_type < BLOCK_8X8 ? | 258 return mode2txfm_map[mbmi->sb_type < BLOCK_8X8 ? |
| 333 mi->bmi[ib].as_mode : mbmi->mode]; | 259 mi->bmi[ib].as_mode : mbmi->mode]; |
| 334 } | 260 } |
| 335 | 261 |
| 336 static INLINE TX_TYPE get_tx_type_8x8(PLANE_TYPE plane_type, | 262 static INLINE TX_TYPE get_tx_type_8x8(PLANE_TYPE plane_type, |
| 337 const MACROBLOCKD *xd) { | 263 const MACROBLOCKD *xd) { |
| 338 return plane_type == PLANE_TYPE_Y_WITH_DC ? | 264 return plane_type == PLANE_TYPE_Y_WITH_DC ? |
| 339 mode2txfm_map[xd->this_mi->mbmi.mode] : DCT_DCT; | 265 mode2txfm_map[xd->mi_8x8[0]->mbmi.mode] : DCT_DCT; |
| 340 } | 266 } |
| 341 | 267 |
| 342 static INLINE TX_TYPE get_tx_type_16x16(PLANE_TYPE plane_type, | 268 static INLINE TX_TYPE get_tx_type_16x16(PLANE_TYPE plane_type, |
| 343 const MACROBLOCKD *xd) { | 269 const MACROBLOCKD *xd) { |
| 344 return plane_type == PLANE_TYPE_Y_WITH_DC ? | 270 return plane_type == PLANE_TYPE_Y_WITH_DC ? |
| 345 mode2txfm_map[xd->this_mi->mbmi.mode] : DCT_DCT; | 271 mode2txfm_map[xd->mi_8x8[0]->mbmi.mode] : DCT_DCT; |
| 346 } | 272 } |
| 347 | 273 |
| 348 static void setup_block_dptrs(MACROBLOCKD *xd, int ss_x, int ss_y) { | 274 static void setup_block_dptrs(MACROBLOCKD *xd, int ss_x, int ss_y) { |
| 349 int i; | 275 int i; |
| 350 | 276 |
| 351 for (i = 0; i < MAX_MB_PLANE; i++) { | 277 for (i = 0; i < MAX_MB_PLANE; i++) { |
| 352 xd->plane[i].plane_type = i ? PLANE_TYPE_UV : PLANE_TYPE_Y_WITH_DC; | 278 xd->plane[i].plane_type = i ? PLANE_TYPE_UV : PLANE_TYPE_Y_WITH_DC; |
| 353 xd->plane[i].subsampling_x = i ? ss_x : 0; | 279 xd->plane[i].subsampling_x = i ? ss_x : 0; |
| 354 xd->plane[i].subsampling_y = i ? ss_y : 0; | 280 xd->plane[i].subsampling_y = i ? ss_y : 0; |
| 355 } | 281 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 384 | 310 |
| 385 typedef void (*foreach_transformed_block_visitor)(int plane, int block, | 311 typedef void (*foreach_transformed_block_visitor)(int plane, int block, |
| 386 BLOCK_SIZE plane_bsize, | 312 BLOCK_SIZE plane_bsize, |
| 387 TX_SIZE tx_size, | 313 TX_SIZE tx_size, |
| 388 void *arg); | 314 void *arg); |
| 389 | 315 |
| 390 static INLINE void foreach_transformed_block_in_plane( | 316 static INLINE void foreach_transformed_block_in_plane( |
| 391 const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane, | 317 const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane, |
| 392 foreach_transformed_block_visitor visit, void *arg) { | 318 foreach_transformed_block_visitor visit, void *arg) { |
| 393 const struct macroblockd_plane *const pd = &xd->plane[plane]; | 319 const struct macroblockd_plane *const pd = &xd->plane[plane]; |
| 394 const MB_MODE_INFO* mbmi = &xd->this_mi->mbmi; | 320 const MB_MODE_INFO* mbmi = &xd->mi_8x8[0]->mbmi; |
| 395 // block and transform sizes, in number of 4x4 blocks log 2 ("*_b") | 321 // block and transform sizes, in number of 4x4 blocks log 2 ("*_b") |
| 396 // 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8 | 322 // 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8 |
| 397 // transform size varies per plane, look it up in a common way. | 323 // transform size varies per plane, look it up in a common way. |
| 398 const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi) | 324 const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi) |
| 399 : mbmi->tx_size; | 325 : mbmi->tx_size; |
| 400 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); | 326 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); |
| 401 const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize]; | 327 const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize]; |
| 402 const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize]; | 328 const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize]; |
| 403 const int step = 1 << (tx_size << 1); | 329 const int step = 1 << (tx_size << 1); |
| 404 int i; | 330 int i; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 const int bw = 4 << b_width_log2(plane_bsize); | 439 const int bw = 4 << b_width_log2(plane_bsize); |
| 514 const int umv_border_start = bw + (xd->mb_to_right_edge >> | 440 const int umv_border_start = bw + (xd->mb_to_right_edge >> |
| 515 (3 + pd->subsampling_x)); | 441 (3 + pd->subsampling_x)); |
| 516 | 442 |
| 517 if (x + bw > umv_border_start) | 443 if (x + bw > umv_border_start) |
| 518 vpx_memset(&buf[y * stride + umv_border_start], | 444 vpx_memset(&buf[y * stride + umv_border_start], |
| 519 buf[y * stride + umv_border_start - 1], bw); | 445 buf[y * stride + umv_border_start - 1], bw); |
| 520 } | 446 } |
| 521 | 447 |
| 522 if (xd->mb_to_bottom_edge < 0) { | 448 if (xd->mb_to_bottom_edge < 0) { |
| 523 const int bh = 4 << b_height_log2(plane_bsize); | 449 if (xd->left_available || x >= 0) { |
| 524 const int umv_border_start = bh + (xd->mb_to_bottom_edge >> | 450 const int bh = 4 << b_height_log2(plane_bsize); |
| 525 (3 + pd->subsampling_y)); | 451 const int umv_border_start = |
| 526 int i; | 452 bh + (xd->mb_to_bottom_edge >> (3 + pd->subsampling_y)); |
| 527 const uint8_t c = buf[(umv_border_start - 1) * stride + x]; | |
| 528 uint8_t *d = &buf[umv_border_start * stride + x]; | |
| 529 | 453 |
| 530 if (y + bh > umv_border_start) | 454 if (y + bh > umv_border_start) { |
| 531 for (i = 0; i < bh; ++i, d += stride) | 455 const uint8_t c = buf[(umv_border_start - 1) * stride + x]; |
| 532 *d = c; | 456 uint8_t *d = &buf[umv_border_start * stride + x]; |
| 457 int i; |
| 458 for (i = 0; i < bh; ++i, d += stride) |
| 459 *d = c; |
| 460 } |
| 461 } |
| 533 } | 462 } |
| 534 } | 463 } |
| 535 static void set_contexts_on_border(MACROBLOCKD *xd, | 464 static void set_contexts_on_border(MACROBLOCKD *xd, |
| 536 struct macroblockd_plane *pd, | 465 struct macroblockd_plane *pd, |
| 537 BLOCK_SIZE plane_bsize, | 466 BLOCK_SIZE plane_bsize, |
| 538 int tx_size_in_blocks, int has_eob, | 467 int tx_size_in_blocks, int has_eob, |
| 539 int aoff, int loff, | 468 int aoff, int loff, |
| 540 ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L) { | 469 ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L) { |
| 541 int mi_blocks_wide = num_4x4_blocks_wide_lookup[plane_bsize]; | 470 int mi_blocks_wide = num_4x4_blocks_wide_lookup[plane_bsize]; |
| 542 int mi_blocks_high = num_4x4_blocks_high_lookup[plane_bsize]; | 471 int mi_blocks_high = num_4x4_blocks_high_lookup[plane_bsize]; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 | 508 |
| 580 if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) { | 509 if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) { |
| 581 set_contexts_on_border(xd, pd, plane_bsize, tx_size_in_blocks, has_eob, | 510 set_contexts_on_border(xd, pd, plane_bsize, tx_size_in_blocks, has_eob, |
| 582 aoff, loff, A, L); | 511 aoff, loff, A, L); |
| 583 } else { | 512 } else { |
| 584 vpx_memset(A, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks); | 513 vpx_memset(A, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks); |
| 585 vpx_memset(L, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks); | 514 vpx_memset(L, has_eob, sizeof(ENTROPY_CONTEXT) * tx_size_in_blocks); |
| 586 } | 515 } |
| 587 } | 516 } |
| 588 | 517 |
| 589 static int get_tx_eob(struct segmentation *seg, int segment_id, | 518 static int get_tx_eob(const struct segmentation *seg, int segment_id, |
| 590 TX_SIZE tx_size) { | 519 TX_SIZE tx_size) { |
| 591 const int eob_max = 16 << (tx_size << 1); | 520 const int eob_max = 16 << (tx_size << 1); |
| 592 return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max; | 521 return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max; |
| 593 } | 522 } |
| 594 | 523 |
| 595 #endif // VP9_COMMON_VP9_BLOCKD_H_ | 524 #endif // VP9_COMMON_VP9_BLOCKD_H_ |
| OLD | NEW |