| 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_filter.h" |
| 24 #include "vp9/common/vp9_idct.h" |
| 24 #include "vp9/common/vp9_mv.h" | 25 #include "vp9/common/vp9_mv.h" |
| 25 #include "vp9/common/vp9_scale.h" | 26 #include "vp9/common/vp9_scale.h" |
| 26 #include "vp9/common/vp9_seg_common.h" | 27 #include "vp9/common/vp9_seg_common.h" |
| 27 | 28 |
| 28 #ifdef __cplusplus | 29 #ifdef __cplusplus |
| 29 extern "C" { | 30 extern "C" { |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 #define BLOCK_SIZE_GROUPS 4 | 33 #define BLOCK_SIZE_GROUPS 4 |
| 33 #define SKIP_CONTEXTS 3 | 34 #define SKIP_CONTEXTS 3 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 /* For keyframes, intra block modes are predicted by the (already decoded) | 93 /* For keyframes, intra block modes are predicted by the (already decoded) |
| 93 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 |
| 94 is a single probability table. */ | 95 is a single probability table. */ |
| 95 | 96 |
| 96 typedef struct { | 97 typedef struct { |
| 97 PREDICTION_MODE as_mode; | 98 PREDICTION_MODE as_mode; |
| 98 int_mv as_mv[2]; // first, second inter predictor motion vectors | 99 int_mv as_mv[2]; // first, second inter predictor motion vectors |
| 99 } b_mode_info; | 100 } b_mode_info; |
| 100 | 101 |
| 102 // Note that the rate-distortion optimization loop, bit-stream writer, and |
| 103 // decoder implementation modules critically rely on the enum entry values |
| 104 // specified herein. They should be refactored concurrently. |
| 101 typedef enum { | 105 typedef enum { |
| 102 NONE = -1, | 106 NONE = -1, |
| 103 INTRA_FRAME = 0, | 107 INTRA_FRAME = 0, |
| 104 LAST_FRAME = 1, | 108 LAST_FRAME = 1, |
| 105 GOLDEN_FRAME = 2, | 109 GOLDEN_FRAME = 2, |
| 106 ALTREF_FRAME = 3, | 110 ALTREF_FRAME = 3, |
| 107 MAX_REF_FRAMES = 4 | 111 MAX_REF_FRAMES = 4 |
| 108 } MV_REFERENCE_FRAME; | 112 } MV_REFERENCE_FRAME; |
| 109 | 113 |
| 110 static INLINE int b_width_log2(BLOCK_SIZE sb_type) { | 114 static INLINE int b_width_log2(BLOCK_SIZE sb_type) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 132 PREDICTION_MODE uv_mode; | 136 PREDICTION_MODE uv_mode; |
| 133 | 137 |
| 134 // Only for INTER blocks | 138 // Only for INTER blocks |
| 135 MV_REFERENCE_FRAME ref_frame[2]; | 139 MV_REFERENCE_FRAME ref_frame[2]; |
| 136 int_mv mv[2]; | 140 int_mv mv[2]; |
| 137 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; | 141 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; |
| 138 uint8_t mode_context[MAX_REF_FRAMES]; | 142 uint8_t mode_context[MAX_REF_FRAMES]; |
| 139 INTERP_FILTER interp_filter; | 143 INTERP_FILTER interp_filter; |
| 140 } MB_MODE_INFO; | 144 } MB_MODE_INFO; |
| 141 | 145 |
| 142 typedef struct { | 146 typedef struct MODE_INFO { |
| 147 struct MODE_INFO *src_mi; |
| 143 MB_MODE_INFO mbmi; | 148 MB_MODE_INFO mbmi; |
| 144 b_mode_info bmi[4]; | 149 b_mode_info bmi[4]; |
| 145 } MODE_INFO; | 150 } MODE_INFO; |
| 146 | 151 |
| 147 static INLINE PREDICTION_MODE get_y_mode(const MODE_INFO *mi, int block) { | 152 static INLINE PREDICTION_MODE get_y_mode(const MODE_INFO *mi, int block) { |
| 148 return mi->mbmi.sb_type < BLOCK_8X8 ? mi->bmi[block].as_mode | 153 return mi->mbmi.sb_type < BLOCK_8X8 ? mi->bmi[block].as_mode |
| 149 : mi->mbmi.mode; | 154 : mi->mbmi.mode; |
| 150 } | 155 } |
| 151 | 156 |
| 152 static INLINE int is_inter_block(const MB_MODE_INFO *mbmi) { | 157 static INLINE int is_inter_block(const MB_MODE_INFO *mbmi) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 169 }; | 174 }; |
| 170 | 175 |
| 171 enum { MAX_MB_PLANE = 3 }; | 176 enum { MAX_MB_PLANE = 3 }; |
| 172 | 177 |
| 173 struct buf_2d { | 178 struct buf_2d { |
| 174 uint8_t *buf; | 179 uint8_t *buf; |
| 175 int stride; | 180 int stride; |
| 176 }; | 181 }; |
| 177 | 182 |
| 178 struct macroblockd_plane { | 183 struct macroblockd_plane { |
| 179 int16_t *dqcoeff; | 184 tran_low_t *dqcoeff; |
| 180 PLANE_TYPE plane_type; | 185 PLANE_TYPE plane_type; |
| 181 int subsampling_x; | 186 int subsampling_x; |
| 182 int subsampling_y; | 187 int subsampling_y; |
| 183 struct buf_2d dst; | 188 struct buf_2d dst; |
| 184 struct buf_2d pre[2]; | 189 struct buf_2d pre[2]; |
| 185 const int16_t *dequant; | 190 const int16_t *dequant; |
| 186 ENTROPY_CONTEXT *above_context; | 191 ENTROPY_CONTEXT *above_context; |
| 187 ENTROPY_CONTEXT *left_context; | 192 ENTROPY_CONTEXT *left_context; |
| 188 }; | 193 }; |
| 189 | 194 |
| 190 #define BLOCK_OFFSET(x, i) ((x) + (i) * 16) | 195 #define BLOCK_OFFSET(x, i) ((x) + (i) * 16) |
| 191 | 196 |
| 192 typedef struct RefBuffer { | 197 typedef struct RefBuffer { |
| 193 // TODO(dkovalev): idx is not really required and should be removed, now it | 198 // TODO(dkovalev): idx is not really required and should be removed, now it |
| 194 // is used in vp9_onyxd_if.c | 199 // is used in vp9_onyxd_if.c |
| 195 int idx; | 200 int idx; |
| 196 YV12_BUFFER_CONFIG *buf; | 201 YV12_BUFFER_CONFIG *buf; |
| 197 struct scale_factors sf; | 202 struct scale_factors sf; |
| 198 } RefBuffer; | 203 } RefBuffer; |
| 199 | 204 |
| 200 typedef struct macroblockd { | 205 typedef struct macroblockd { |
| 201 struct macroblockd_plane plane[MAX_MB_PLANE]; | 206 struct macroblockd_plane plane[MAX_MB_PLANE]; |
| 202 | 207 |
| 203 int mi_stride; | 208 int mi_stride; |
| 204 | 209 |
| 205 // A NULL indicates that the 8x8 is not part of the image | 210 MODE_INFO *mi; |
| 206 MODE_INFO **mi; | |
| 207 | 211 |
| 208 int up_available; | 212 int up_available; |
| 209 int left_available; | 213 int left_available; |
| 210 | 214 |
| 211 /* Distance of MB away from frame edges */ | 215 /* Distance of MB away from frame edges */ |
| 212 int mb_to_left_edge; | 216 int mb_to_left_edge; |
| 213 int mb_to_right_edge; | 217 int mb_to_right_edge; |
| 214 int mb_to_top_edge; | 218 int mb_to_top_edge; |
| 215 int mb_to_bottom_edge; | 219 int mb_to_bottom_edge; |
| 216 | 220 |
| 217 /* pointers to reference frames */ | 221 /* pointers to reference frames */ |
| 218 RefBuffer *block_refs[2]; | 222 RefBuffer *block_refs[2]; |
| 219 | 223 |
| 220 /* pointer to current frame */ | 224 /* pointer to current frame */ |
| 221 const YV12_BUFFER_CONFIG *cur_buf; | 225 const YV12_BUFFER_CONFIG *cur_buf; |
| 222 | 226 |
| 223 /* mc buffer */ | 227 /* mc buffer */ |
| 224 DECLARE_ALIGNED(16, uint8_t, mc_buf[80 * 2 * 80 * 2]); | 228 DECLARE_ALIGNED(16, uint8_t, mc_buf[80 * 2 * 80 * 2]); |
| 225 | 229 |
| 230 #if CONFIG_VP9_HIGHBITDEPTH |
| 231 /* Bit depth: 8, 10, 12 */ |
| 232 int bd; |
| 233 DECLARE_ALIGNED(16, uint16_t, mc_buf_high[80 * 2 * 80 * 2]); |
| 234 #endif |
| 235 |
| 226 int lossless; | 236 int lossless; |
| 227 | 237 |
| 228 int corrupted; | 238 int corrupted; |
| 229 | 239 |
| 230 DECLARE_ALIGNED(16, int16_t, dqcoeff[MAX_MB_PLANE][64 * 64]); | 240 DECLARE_ALIGNED(16, tran_low_t, dqcoeff[MAX_MB_PLANE][64 * 64]); |
| 231 | 241 |
| 232 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; | 242 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; |
| 233 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; | 243 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; |
| 234 | 244 |
| 235 PARTITION_CONTEXT *above_seg_context; | 245 PARTITION_CONTEXT *above_seg_context; |
| 236 PARTITION_CONTEXT left_seg_context[8]; | 246 PARTITION_CONTEXT left_seg_context[8]; |
| 237 } MACROBLOCKD; | 247 } MACROBLOCKD; |
| 238 | 248 |
| 239 static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, | 249 static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, |
| 240 PARTITION_TYPE partition) { | 250 PARTITION_TYPE partition) { |
| 241 return subsize_lookup[partition][bsize]; | 251 return subsize_lookup[partition][bsize]; |
| 242 } | 252 } |
| 243 | 253 |
| 244 extern const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES]; | 254 extern const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES]; |
| 245 | 255 |
| 246 static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, | 256 static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, |
| 247 const MACROBLOCKD *xd) { | 257 const MACROBLOCKD *xd) { |
| 248 const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 258 const MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; |
| 249 | 259 |
| 250 if (plane_type != PLANE_TYPE_Y || is_inter_block(mbmi)) | 260 if (plane_type != PLANE_TYPE_Y || is_inter_block(mbmi)) |
| 251 return DCT_DCT; | 261 return DCT_DCT; |
| 252 return intra_mode_to_tx_type_lookup[mbmi->mode]; | 262 return intra_mode_to_tx_type_lookup[mbmi->mode]; |
| 253 } | 263 } |
| 254 | 264 |
| 255 static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, | 265 static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, |
| 256 const MACROBLOCKD *xd, int ib) { | 266 const MACROBLOCKD *xd, int ib) { |
| 257 const MODE_INFO *const mi = xd->mi[0]; | 267 const MODE_INFO *const mi = xd->mi[0].src_mi; |
| 258 | 268 |
| 259 if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(&mi->mbmi)) | 269 if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(&mi->mbmi)) |
| 260 return DCT_DCT; | 270 return DCT_DCT; |
| 261 | 271 |
| 262 return intra_mode_to_tx_type_lookup[get_y_mode(mi, ib)]; | 272 return intra_mode_to_tx_type_lookup[get_y_mode(mi, ib)]; |
| 263 } | 273 } |
| 264 | 274 |
| 265 void vp9_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y); | 275 void vp9_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y); |
| 266 | 276 |
| 267 static INLINE TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize, | 277 static INLINE TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 322 |
| 313 void vp9_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, | 323 void vp9_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, |
| 314 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob, | 324 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob, |
| 315 int aoff, int loff); | 325 int aoff, int loff); |
| 316 | 326 |
| 317 #ifdef __cplusplus | 327 #ifdef __cplusplus |
| 318 } // extern "C" | 328 } // extern "C" |
| 319 #endif | 329 #endif |
| 320 | 330 |
| 321 #endif // VP9_COMMON_VP9_BLOCKD_H_ | 331 #endif // VP9_COMMON_VP9_BLOCKD_H_ |
| OLD | NEW |