| 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 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 vpx_memset(&mi[i * stride], 0, sizeof(MODE_INFO)); | 31 vpx_memset(&mi[i * stride], 0, sizeof(MODE_INFO)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void vp9_update_mode_info_in_image(VP9_COMMON *cm, MODE_INFO *mi) { | 34 void vp9_update_mode_info_in_image(VP9_COMMON *cm, MODE_INFO *mi) { |
| 35 int i, j; | 35 int i, j; |
| 36 | 36 |
| 37 // For each in image mode_info element set the in image flag to 1 | 37 // For each in image mode_info element set the in image flag to 1 |
| 38 for (i = 0; i < cm->mi_rows; i++) { | 38 for (i = 0; i < cm->mi_rows; i++) { |
| 39 MODE_INFO *ptr = mi; | 39 MODE_INFO *ptr = mi; |
| 40 for (j = 0; j < cm->mi_cols; j++) { | 40 for (j = 0; j < cm->mi_cols; j++) { |
| 41 ptr->mbmi.mb_in_image = 1; | 41 ptr->mbmi.in_image = 1; |
| 42 ptr++; // Next element in the row | 42 ptr++; // Next element in the row |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Step over border element at start of next row | 45 // Step over border element at start of next row |
| 46 mi += cm->mode_info_stride; | 46 mi += cm->mode_info_stride; |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 void vp9_free_frame_buffers(VP9_COMMON *oci) { | 50 void vp9_free_frame_buffers(VP9_COMMON *oci) { |
| 51 int i; | 51 int i; |
| 52 | 52 |
| 53 for (i = 0; i < NUM_YV12_BUFFERS; i++) | 53 for (i = 0; i < NUM_YV12_BUFFERS; i++) |
| 54 vp9_free_frame_buffer(&oci->yv12_fb[i]); | 54 vp9_free_frame_buffer(&oci->yv12_fb[i]); |
| 55 | 55 |
| 56 vp9_free_frame_buffer(&oci->post_proc_buffer); | 56 vp9_free_frame_buffer(&oci->post_proc_buffer); |
| 57 | 57 |
| 58 vpx_free(oci->mip); | 58 vpx_free(oci->mip); |
| 59 vpx_free(oci->prev_mip); | 59 vpx_free(oci->prev_mip); |
| 60 vpx_free(oci->above_seg_context); | 60 vpx_free(oci->above_seg_context); |
| 61 vpx_free(oci->last_frame_seg_map); |
| 61 | 62 |
| 62 vpx_free(oci->above_context[0]); | 63 vpx_free(oci->above_context[0]); |
| 63 for (i = 0; i < MAX_MB_PLANE; i++) | 64 for (i = 0; i < MAX_MB_PLANE; i++) |
| 64 oci->above_context[i] = 0; | 65 oci->above_context[i] = 0; |
| 65 oci->mip = NULL; | 66 oci->mip = NULL; |
| 66 oci->prev_mip = NULL; | 67 oci->prev_mip = NULL; |
| 67 oci->above_seg_context = NULL; | 68 oci->above_seg_context = NULL; |
| 69 oci->last_frame_seg_map = NULL; |
| 68 } | 70 } |
| 69 | 71 |
| 70 static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) { | 72 static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) { |
| 71 cm->mb_cols = (aligned_width + 8) >> 4; | 73 cm->mb_cols = (aligned_width + 8) >> 4; |
| 72 cm->mb_rows = (aligned_height + 8) >> 4; | 74 cm->mb_rows = (aligned_height + 8) >> 4; |
| 73 cm->MBs = cm->mb_rows * cm->mb_cols; | 75 cm->MBs = cm->mb_rows * cm->mb_cols; |
| 74 | 76 |
| 75 cm->mi_cols = aligned_width >> LOG2_MI_SIZE; | 77 cm->mi_cols = aligned_width >> MI_SIZE_LOG2; |
| 76 cm->mi_rows = aligned_height >> LOG2_MI_SIZE; | 78 cm->mi_rows = aligned_height >> MI_SIZE_LOG2; |
| 77 cm->mode_info_stride = cm->mi_cols + MI_BLOCK_SIZE; | 79 cm->mode_info_stride = cm->mi_cols + MI_BLOCK_SIZE; |
| 78 } | 80 } |
| 79 | 81 |
| 80 static void setup_mi(VP9_COMMON *cm) { | 82 static void setup_mi(VP9_COMMON *cm) { |
| 81 cm->mi = cm->mip + cm->mode_info_stride + 1; | 83 cm->mi = cm->mip + cm->mode_info_stride + 1; |
| 82 cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; | 84 cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; |
| 83 | 85 |
| 84 vpx_memset(cm->mip, 0, | 86 vpx_memset(cm->mip, 0, |
| 85 cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); | 87 cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); |
| 86 | 88 |
| 87 vp9_update_mode_info_border(cm, cm->mip); | 89 vp9_update_mode_info_border(cm, cm->mip); |
| 88 vp9_update_mode_info_in_image(cm, cm->mi); | 90 vp9_update_mode_info_in_image(cm, cm->mi); |
| 89 | 91 |
| 90 vp9_update_mode_info_border(cm, cm->prev_mip); | 92 vp9_update_mode_info_border(cm, cm->prev_mip); |
| 91 vp9_update_mode_info_in_image(cm, cm->prev_mi); | 93 vp9_update_mode_info_in_image(cm, cm->prev_mi); |
| 92 } | 94 } |
| 93 | 95 |
| 94 int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) { | 96 int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) { |
| 95 int i, mi_cols; | 97 int i, mi_cols; |
| 96 | 98 |
| 97 const int aligned_width = ALIGN_POWER_OF_TWO(width, LOG2_MI_SIZE); | 99 const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2); |
| 98 const int aligned_height = ALIGN_POWER_OF_TWO(height, LOG2_MI_SIZE); | 100 const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2); |
| 99 const int ss_x = oci->subsampling_x; | 101 const int ss_x = oci->subsampling_x; |
| 100 const int ss_y = oci->subsampling_y; | 102 const int ss_y = oci->subsampling_y; |
| 101 int mi_size; | 103 int mi_size; |
| 102 | 104 |
| 103 vp9_free_frame_buffers(oci); | 105 vp9_free_frame_buffers(oci); |
| 104 | 106 |
| 105 for (i = 0; i < NUM_YV12_BUFFERS; i++) { | 107 for (i = 0; i < NUM_YV12_BUFFERS; i++) { |
| 106 oci->fb_idx_ref_cnt[i] = 0; | 108 oci->fb_idx_ref_cnt[i] = 0; |
| 107 if (vp9_alloc_frame_buffer(&oci->yv12_fb[i], width, height, ss_x, ss_y, | 109 if (vp9_alloc_frame_buffer(&oci->yv12_fb[i], width, height, ss_x, ss_y, |
| 108 VP9BORDERINPIXELS) < 0) | 110 VP9BORDERINPIXELS) < 0) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 138 goto fail; | 140 goto fail; |
| 139 | 141 |
| 140 setup_mi(oci); | 142 setup_mi(oci); |
| 141 | 143 |
| 142 // FIXME(jkoleszar): allocate subsampled arrays for U/V once subsampling | 144 // FIXME(jkoleszar): allocate subsampled arrays for U/V once subsampling |
| 143 // information is exposed at this level | 145 // information is exposed at this level |
| 144 mi_cols = mi_cols_aligned_to_sb(oci->mi_cols); | 146 mi_cols = mi_cols_aligned_to_sb(oci->mi_cols); |
| 145 | 147 |
| 146 // 2 contexts per 'mi unit', so that we have one context per 4x4 txfm | 148 // 2 contexts per 'mi unit', so that we have one context per 4x4 txfm |
| 147 // block where mi unit size is 8x8. | 149 // block where mi unit size is 8x8. |
| 148 # if CONFIG_ALPHA | 150 oci->above_context[0] = vpx_calloc(sizeof(ENTROPY_CONTEXT) * MAX_MB_PLANE * |
| 149 oci->above_context[0] = vpx_calloc(sizeof(ENTROPY_CONTEXT) * 8 * mi_cols, 1); | 151 (2 * mi_cols), 1); |
| 150 #else | |
| 151 oci->above_context[0] = vpx_calloc(sizeof(ENTROPY_CONTEXT) * 6 * mi_cols, 1); | |
| 152 #endif | |
| 153 if (!oci->above_context[0]) | 152 if (!oci->above_context[0]) |
| 154 goto fail; | 153 goto fail; |
| 155 | 154 |
| 156 oci->above_seg_context = vpx_calloc(sizeof(PARTITION_CONTEXT) * mi_cols, 1); | 155 oci->above_seg_context = vpx_calloc(sizeof(PARTITION_CONTEXT) * mi_cols, 1); |
| 157 if (!oci->above_seg_context) | 156 if (!oci->above_seg_context) |
| 158 goto fail; | 157 goto fail; |
| 159 | 158 |
| 159 // Create the segmentation map structure and set to 0. |
| 160 oci->last_frame_seg_map = vpx_calloc(oci->mi_rows * oci->mi_cols, 1); |
| 161 if (!oci->last_frame_seg_map) |
| 162 goto fail; |
| 163 |
| 160 return 0; | 164 return 0; |
| 161 | 165 |
| 162 fail: | 166 fail: |
| 163 vp9_free_frame_buffers(oci); | 167 vp9_free_frame_buffers(oci); |
| 164 return 1; | 168 return 1; |
| 165 } | 169 } |
| 166 | 170 |
| 167 void vp9_create_common(VP9_COMMON *oci) { | 171 void vp9_create_common(VP9_COMMON *oci) { |
| 168 vp9_machine_specific_config(oci); | 172 vp9_machine_specific_config(oci); |
| 169 | 173 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 181 } | 185 } |
| 182 | 186 |
| 183 void vp9_initialize_common() { | 187 void vp9_initialize_common() { |
| 184 vp9_coef_tree_initialize(); | 188 vp9_coef_tree_initialize(); |
| 185 vp9_entropy_mode_init(); | 189 vp9_entropy_mode_init(); |
| 186 vp9_entropy_mv_init(); | 190 vp9_entropy_mv_init(); |
| 187 } | 191 } |
| 188 | 192 |
| 189 void vp9_update_frame_size(VP9_COMMON *cm) { | 193 void vp9_update_frame_size(VP9_COMMON *cm) { |
| 190 int i, mi_cols; | 194 int i, mi_cols; |
| 191 const int aligned_width = ALIGN_POWER_OF_TWO(cm->width, LOG2_MI_SIZE); | 195 const int aligned_width = ALIGN_POWER_OF_TWO(cm->width, MI_SIZE_LOG2); |
| 192 const int aligned_height = ALIGN_POWER_OF_TWO(cm->height, LOG2_MI_SIZE); | 196 const int aligned_height = ALIGN_POWER_OF_TWO(cm->height, MI_SIZE_LOG2); |
| 193 | 197 |
| 194 set_mb_mi(cm, aligned_width, aligned_height); | 198 set_mb_mi(cm, aligned_width, aligned_height); |
| 195 setup_mi(cm); | 199 setup_mi(cm); |
| 196 | 200 |
| 197 mi_cols = mi_cols_aligned_to_sb(cm->mi_cols); | 201 mi_cols = mi_cols_aligned_to_sb(cm->mi_cols); |
| 198 for (i = 1; i < MAX_MB_PLANE; i++) | 202 for (i = 1; i < MAX_MB_PLANE; i++) |
| 199 cm->above_context[i] = | 203 cm->above_context[i] = |
| 200 cm->above_context[0] + i * sizeof(ENTROPY_CONTEXT) * 2 * mi_cols; | 204 cm->above_context[0] + i * sizeof(ENTROPY_CONTEXT) * 2 * mi_cols; |
| 205 |
| 206 // Initialize the previous frame segment map to 0. |
| 207 if (cm->last_frame_seg_map) |
| 208 vpx_memset(cm->last_frame_seg_map, 0, cm->mi_rows * cm->mi_cols); |
| 201 } | 209 } |
| OLD | NEW |