| 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 15 matching lines...) Expand all Loading... |
| 26 vpx_memset(mi, 0, sizeof(MODE_INFO) * stride); | 26 vpx_memset(mi, 0, sizeof(MODE_INFO) * stride); |
| 27 | 27 |
| 28 // Clear left border column | 28 // Clear left border column |
| 29 for (i = 1; i < cm->mi_rows + 1; i++) | 29 for (i = 1; i < cm->mi_rows + 1; i++) |
| 30 vpx_memset(&mi[i * stride], 0, sizeof(MODE_INFO)); | 30 vpx_memset(&mi[i * stride], 0, sizeof(MODE_INFO)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void vp9_free_frame_buffers(VP9_COMMON *cm) { | 33 void vp9_free_frame_buffers(VP9_COMMON *cm) { |
| 34 int i; | 34 int i; |
| 35 | 35 |
| 36 for (i = 0; i < FRAME_BUFFERS; i++) | 36 for (i = 0; i < FRAME_BUFFERS; i++) { |
| 37 vp9_free_frame_buffer(&cm->yv12_fb[i]); | 37 vp9_free_frame_buffer(&cm->frame_bufs[i].buf); |
| 38 |
| 39 if (cm->frame_bufs[i].ref_count > 0 && |
| 40 cm->frame_bufs[i].raw_frame_buffer.data != NULL) { |
| 41 cm->release_fb_cb(cm->cb_priv, &cm->frame_bufs[i].raw_frame_buffer); |
| 42 cm->frame_bufs[i].ref_count = 0; |
| 43 } |
| 44 } |
| 38 | 45 |
| 39 vp9_free_frame_buffer(&cm->post_proc_buffer); | 46 vp9_free_frame_buffer(&cm->post_proc_buffer); |
| 40 | 47 |
| 41 vpx_free(cm->mip); | 48 vpx_free(cm->mip); |
| 42 vpx_free(cm->prev_mip); | 49 vpx_free(cm->prev_mip); |
| 43 vpx_free(cm->last_frame_seg_map); | 50 vpx_free(cm->last_frame_seg_map); |
| 44 vpx_free(cm->mi_grid_base); | 51 vpx_free(cm->mi_grid_base); |
| 45 vpx_free(cm->prev_mi_grid_base); | 52 vpx_free(cm->prev_mi_grid_base); |
| 46 | 53 |
| 47 cm->mip = NULL; | 54 cm->mip = NULL; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 78 } | 85 } |
| 79 | 86 |
| 80 int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { | 87 int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { |
| 81 const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2); | 88 const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2); |
| 82 const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2); | 89 const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2); |
| 83 const int ss_x = cm->subsampling_x; | 90 const int ss_x = cm->subsampling_x; |
| 84 const int ss_y = cm->subsampling_y; | 91 const int ss_y = cm->subsampling_y; |
| 85 int mi_size; | 92 int mi_size; |
| 86 | 93 |
| 87 if (vp9_realloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y, | 94 if (vp9_realloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y, |
| 88 VP9_DEC_BORDER_IN_PIXELS) < 0) | 95 VP9_DEC_BORDER_IN_PIXELS, NULL, NULL, NULL) < 0) |
| 89 goto fail; | 96 goto fail; |
| 90 | 97 |
| 91 set_mb_mi(cm, aligned_width, aligned_height); | 98 set_mb_mi(cm, aligned_width, aligned_height); |
| 92 | 99 |
| 93 // Allocation | 100 // Allocation |
| 94 mi_size = cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE); | 101 mi_size = cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE); |
| 95 | 102 |
| 96 vpx_free(cm->mip); | 103 vpx_free(cm->mip); |
| 97 cm->mip = vpx_calloc(mi_size, sizeof(MODE_INFO)); | 104 cm->mip = vpx_calloc(mi_size, sizeof(MODE_INFO)); |
| 98 if (!cm->mip) | 105 if (!cm->mip) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 140 |
| 134 const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2); | 141 const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2); |
| 135 const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2); | 142 const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2); |
| 136 const int ss_x = cm->subsampling_x; | 143 const int ss_x = cm->subsampling_x; |
| 137 const int ss_y = cm->subsampling_y; | 144 const int ss_y = cm->subsampling_y; |
| 138 int mi_size; | 145 int mi_size; |
| 139 | 146 |
| 140 vp9_free_frame_buffers(cm); | 147 vp9_free_frame_buffers(cm); |
| 141 | 148 |
| 142 for (i = 0; i < FRAME_BUFFERS; i++) { | 149 for (i = 0; i < FRAME_BUFFERS; i++) { |
| 143 cm->fb_idx_ref_cnt[i] = 0; | 150 cm->frame_bufs[i].ref_count = 0; |
| 144 if (vp9_alloc_frame_buffer(&cm->yv12_fb[i], width, height, ss_x, ss_y, | 151 if (vp9_alloc_frame_buffer(&cm->frame_bufs[i].buf, width, height, |
| 145 VP9_ENC_BORDER_IN_PIXELS) < 0) | 152 ss_x, ss_y, VP9_ENC_BORDER_IN_PIXELS) < 0) |
| 146 goto fail; | 153 goto fail; |
| 147 } | 154 } |
| 148 | 155 |
| 149 cm->new_fb_idx = FRAME_BUFFERS - 1; | 156 cm->new_fb_idx = FRAME_BUFFERS - 1; |
| 150 cm->fb_idx_ref_cnt[cm->new_fb_idx] = 1; | 157 cm->frame_bufs[cm->new_fb_idx].ref_count = 1; |
| 151 | 158 |
| 152 for (i = 0; i < REF_FRAMES; i++) { | 159 for (i = 0; i < REF_FRAMES; i++) { |
| 153 cm->ref_frame_map[i] = i; | 160 cm->ref_frame_map[i] = i; |
| 154 cm->fb_idx_ref_cnt[i] = 1; | 161 cm->frame_bufs[i].ref_count = 1; |
| 155 } | 162 } |
| 156 | 163 |
| 157 if (vp9_alloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y, | 164 if (vp9_alloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y, |
| 158 VP9_ENC_BORDER_IN_PIXELS) < 0) | 165 VP9_ENC_BORDER_IN_PIXELS) < 0) |
| 159 goto fail; | 166 goto fail; |
| 160 | 167 |
| 161 set_mb_mi(cm, aligned_width, aligned_height); | 168 set_mb_mi(cm, aligned_width, aligned_height); |
| 162 | 169 |
| 163 // Allocation | 170 // Allocation |
| 164 mi_size = cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE); | 171 mi_size = cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 192 vp9_free_frame_buffers(cm); | 199 vp9_free_frame_buffers(cm); |
| 193 return 1; | 200 return 1; |
| 194 } | 201 } |
| 195 | 202 |
| 196 void vp9_create_common(VP9_COMMON *cm) { | 203 void vp9_create_common(VP9_COMMON *cm) { |
| 197 vp9_machine_specific_config(cm); | 204 vp9_machine_specific_config(cm); |
| 198 } | 205 } |
| 199 | 206 |
| 200 void vp9_remove_common(VP9_COMMON *cm) { | 207 void vp9_remove_common(VP9_COMMON *cm) { |
| 201 vp9_free_frame_buffers(cm); | 208 vp9_free_frame_buffers(cm); |
| 209 vp9_free_internal_frame_buffers(&cm->int_frame_buffers); |
| 202 } | 210 } |
| 203 | 211 |
| 204 void vp9_initialize_common() { | 212 void vp9_initialize_common() { |
| 205 vp9_init_neighbors(); | 213 vp9_init_neighbors(); |
| 206 } | 214 } |
| 207 | 215 |
| 208 void vp9_update_frame_size(VP9_COMMON *cm) { | 216 void vp9_update_frame_size(VP9_COMMON *cm) { |
| 209 const int aligned_width = ALIGN_POWER_OF_TWO(cm->width, MI_SIZE_LOG2); | 217 const int aligned_width = ALIGN_POWER_OF_TWO(cm->width, MI_SIZE_LOG2); |
| 210 const int aligned_height = ALIGN_POWER_OF_TWO(cm->height, MI_SIZE_LOG2); | 218 const int aligned_height = ALIGN_POWER_OF_TWO(cm->height, MI_SIZE_LOG2); |
| 211 | 219 |
| 212 set_mb_mi(cm, aligned_width, aligned_height); | 220 set_mb_mi(cm, aligned_width, aligned_height); |
| 213 setup_mi(cm); | 221 setup_mi(cm); |
| 214 | 222 |
| 215 // Initialize the previous frame segment map to 0. | 223 // Initialize the previous frame segment map to 0. |
| 216 if (cm->last_frame_seg_map) | 224 if (cm->last_frame_seg_map) |
| 217 vpx_memset(cm->last_frame_seg_map, 0, cm->mi_rows * cm->mi_cols); | 225 vpx_memset(cm->last_frame_seg_map, 0, cm->mi_rows * cm->mi_cols); |
| 218 } | 226 } |
| OLD | NEW |