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 23 matching lines...) Expand all Loading... |
34 void vp9_free_frame_buffers(VP9_COMMON *cm) { | 34 void vp9_free_frame_buffers(VP9_COMMON *cm) { |
35 int i; | 35 int i; |
36 | 36 |
37 for (i = 0; i < NUM_YV12_BUFFERS; i++) | 37 for (i = 0; i < NUM_YV12_BUFFERS; i++) |
38 vp9_free_frame_buffer(&cm->yv12_fb[i]); | 38 vp9_free_frame_buffer(&cm->yv12_fb[i]); |
39 | 39 |
40 vp9_free_frame_buffer(&cm->post_proc_buffer); | 40 vp9_free_frame_buffer(&cm->post_proc_buffer); |
41 | 41 |
42 vpx_free(cm->mip); | 42 vpx_free(cm->mip); |
43 vpx_free(cm->prev_mip); | 43 vpx_free(cm->prev_mip); |
44 vpx_free(cm->above_seg_context); | |
45 vpx_free(cm->last_frame_seg_map); | 44 vpx_free(cm->last_frame_seg_map); |
46 vpx_free(cm->mi_grid_base); | 45 vpx_free(cm->mi_grid_base); |
47 vpx_free(cm->prev_mi_grid_base); | 46 vpx_free(cm->prev_mi_grid_base); |
48 | 47 |
49 vpx_free(cm->above_context[0]); | |
50 for (i = 0; i < MAX_MB_PLANE; i++) | |
51 cm->above_context[i] = 0; | |
52 cm->mip = NULL; | 48 cm->mip = NULL; |
53 cm->prev_mip = NULL; | 49 cm->prev_mip = NULL; |
54 cm->above_seg_context = NULL; | |
55 cm->last_frame_seg_map = NULL; | 50 cm->last_frame_seg_map = NULL; |
56 cm->mi_grid_base = NULL; | 51 cm->mi_grid_base = NULL; |
57 cm->prev_mi_grid_base = NULL; | 52 cm->prev_mi_grid_base = NULL; |
58 } | 53 } |
59 | 54 |
60 static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) { | 55 static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) { |
61 cm->mb_cols = (aligned_width + 8) >> 4; | |
62 cm->mb_rows = (aligned_height + 8) >> 4; | |
63 cm->MBs = cm->mb_rows * cm->mb_cols; | |
64 | |
65 cm->mi_cols = aligned_width >> MI_SIZE_LOG2; | 56 cm->mi_cols = aligned_width >> MI_SIZE_LOG2; |
66 cm->mi_rows = aligned_height >> MI_SIZE_LOG2; | 57 cm->mi_rows = aligned_height >> MI_SIZE_LOG2; |
67 cm->mode_info_stride = cm->mi_cols + MI_BLOCK_SIZE; | 58 cm->mode_info_stride = cm->mi_cols + MI_BLOCK_SIZE; |
| 59 |
| 60 cm->mb_cols = (cm->mi_cols + 1) >> 1; |
| 61 cm->mb_rows = (cm->mi_rows + 1) >> 1; |
| 62 cm->MBs = cm->mb_rows * cm->mb_cols; |
68 } | 63 } |
69 | 64 |
70 static void setup_mi(VP9_COMMON *cm) { | 65 static void setup_mi(VP9_COMMON *cm) { |
71 cm->mi = cm->mip + cm->mode_info_stride + 1; | 66 cm->mi = cm->mip + cm->mode_info_stride + 1; |
72 cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; | 67 cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; |
73 cm->mi_grid_visible = cm->mi_grid_base + cm->mode_info_stride + 1; | 68 cm->mi_grid_visible = cm->mi_grid_base + cm->mode_info_stride + 1; |
74 cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1; | 69 cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1; |
75 | 70 |
76 vpx_memset(cm->mip, 0, | 71 vpx_memset(cm->mip, 0, |
77 cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); | 72 cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); |
78 | 73 |
79 vpx_memset(cm->mi_grid_base, 0, | 74 vpx_memset(cm->mi_grid_base, 0, |
80 cm->mode_info_stride * (cm->mi_rows + 1) * | 75 cm->mode_info_stride * (cm->mi_rows + 1) * |
81 sizeof(*cm->mi_grid_base)); | 76 sizeof(*cm->mi_grid_base)); |
82 | 77 |
83 vp9_update_mode_info_border(cm, cm->mip); | 78 vp9_update_mode_info_border(cm, cm->mip); |
84 vp9_update_mode_info_border(cm, cm->prev_mip); | 79 vp9_update_mode_info_border(cm, cm->prev_mip); |
85 } | 80 } |
86 | 81 |
87 int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) { | 82 int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) { |
88 int i, mi_cols; | 83 int i; |
89 | 84 |
90 const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2); | 85 const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2); |
91 const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2); | 86 const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2); |
92 const int ss_x = cm->subsampling_x; | 87 const int ss_x = cm->subsampling_x; |
93 const int ss_y = cm->subsampling_y; | 88 const int ss_y = cm->subsampling_y; |
94 int mi_size; | 89 int mi_size; |
95 | 90 |
96 vp9_free_frame_buffers(cm); | 91 vp9_free_frame_buffers(cm); |
97 | 92 |
98 for (i = 0; i < NUM_YV12_BUFFERS; i++) { | 93 for (i = 0; i < NUM_YV12_BUFFERS; i++) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 cm->mi_grid_base = vpx_calloc(mi_size, sizeof(*cm->mi_grid_base)); | 128 cm->mi_grid_base = vpx_calloc(mi_size, sizeof(*cm->mi_grid_base)); |
134 if (!cm->mi_grid_base) | 129 if (!cm->mi_grid_base) |
135 goto fail; | 130 goto fail; |
136 | 131 |
137 cm->prev_mi_grid_base = vpx_calloc(mi_size, sizeof(*cm->prev_mi_grid_base)); | 132 cm->prev_mi_grid_base = vpx_calloc(mi_size, sizeof(*cm->prev_mi_grid_base)); |
138 if (!cm->prev_mi_grid_base) | 133 if (!cm->prev_mi_grid_base) |
139 goto fail; | 134 goto fail; |
140 | 135 |
141 setup_mi(cm); | 136 setup_mi(cm); |
142 | 137 |
143 // FIXME(jkoleszar): allocate subsampled arrays for U/V once subsampling | |
144 // information is exposed at this level | |
145 mi_cols = mi_cols_aligned_to_sb(cm->mi_cols); | |
146 | |
147 // 2 contexts per 'mi unit', so that we have one context per 4x4 txfm | |
148 // block where mi unit size is 8x8. | |
149 cm->above_context[0] = vpx_calloc(sizeof(ENTROPY_CONTEXT) * MAX_MB_PLANE * | |
150 (2 * mi_cols), 1); | |
151 if (!cm->above_context[0]) | |
152 goto fail; | |
153 | |
154 cm->above_seg_context = vpx_calloc(sizeof(PARTITION_CONTEXT) * mi_cols, 1); | |
155 if (!cm->above_seg_context) | |
156 goto fail; | |
157 | |
158 // Create the segmentation map structure and set to 0. | 138 // Create the segmentation map structure and set to 0. |
159 cm->last_frame_seg_map = vpx_calloc(cm->mi_rows * cm->mi_cols, 1); | 139 cm->last_frame_seg_map = vpx_calloc(cm->mi_rows * cm->mi_cols, 1); |
160 if (!cm->last_frame_seg_map) | 140 if (!cm->last_frame_seg_map) |
161 goto fail; | 141 goto fail; |
162 | 142 |
163 return 0; | 143 return 0; |
164 | 144 |
165 fail: | 145 fail: |
166 vp9_free_frame_buffers(cm); | 146 vp9_free_frame_buffers(cm); |
167 return 1; | 147 return 1; |
168 } | 148 } |
169 | 149 |
170 void vp9_create_common(VP9_COMMON *cm) { | 150 void vp9_create_common(VP9_COMMON *cm) { |
171 vp9_machine_specific_config(cm); | 151 vp9_machine_specific_config(cm); |
172 | 152 |
173 vp9_init_mbmode_probs(cm); | |
174 | |
175 cm->tx_mode = ONLY_4X4; | 153 cm->tx_mode = ONLY_4X4; |
176 cm->comp_pred_mode = HYBRID_PREDICTION; | 154 cm->comp_pred_mode = HYBRID_PREDICTION; |
177 | |
178 // Initialize reference frame sign bias structure to defaults | |
179 vpx_memset(cm->ref_frame_sign_bias, 0, sizeof(cm->ref_frame_sign_bias)); | |
180 } | 155 } |
181 | 156 |
182 void vp9_remove_common(VP9_COMMON *cm) { | 157 void vp9_remove_common(VP9_COMMON *cm) { |
183 vp9_free_frame_buffers(cm); | 158 vp9_free_frame_buffers(cm); |
184 } | 159 } |
185 | 160 |
186 void vp9_initialize_common() { | 161 void vp9_initialize_common() { |
| 162 vp9_init_neighbors(); |
187 vp9_coef_tree_initialize(); | 163 vp9_coef_tree_initialize(); |
188 vp9_entropy_mode_init(); | 164 vp9_entropy_mode_init(); |
189 vp9_entropy_mv_init(); | 165 vp9_entropy_mv_init(); |
190 } | 166 } |
191 | 167 |
192 void vp9_update_frame_size(VP9_COMMON *cm) { | 168 void vp9_update_frame_size(VP9_COMMON *cm) { |
193 int i, mi_cols; | |
194 const int aligned_width = ALIGN_POWER_OF_TWO(cm->width, MI_SIZE_LOG2); | 169 const int aligned_width = ALIGN_POWER_OF_TWO(cm->width, MI_SIZE_LOG2); |
195 const int aligned_height = ALIGN_POWER_OF_TWO(cm->height, MI_SIZE_LOG2); | 170 const int aligned_height = ALIGN_POWER_OF_TWO(cm->height, MI_SIZE_LOG2); |
196 | 171 |
197 set_mb_mi(cm, aligned_width, aligned_height); | 172 set_mb_mi(cm, aligned_width, aligned_height); |
198 setup_mi(cm); | 173 setup_mi(cm); |
199 | 174 |
200 mi_cols = mi_cols_aligned_to_sb(cm->mi_cols); | |
201 for (i = 1; i < MAX_MB_PLANE; i++) | |
202 cm->above_context[i] = | |
203 cm->above_context[0] + i * sizeof(ENTROPY_CONTEXT) * 2 * mi_cols; | |
204 | |
205 // Initialize the previous frame segment map to 0. | 175 // Initialize the previous frame segment map to 0. |
206 if (cm->last_frame_seg_map) | 176 if (cm->last_frame_seg_map) |
207 vpx_memset(cm->last_frame_seg_map, 0, cm->mi_rows * cm->mi_cols); | 177 vpx_memset(cm->last_frame_seg_map, 0, cm->mi_rows * cm->mi_cols); |
208 } | 178 } |
OLD | NEW |