| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  134       mi_cols_aligned_to_sb(cm->mi_cols), sizeof(*cm->above_seg_context)); |  134       mi_cols_aligned_to_sb(cm->mi_cols), sizeof(*cm->above_seg_context)); | 
|  135   if (!cm->above_seg_context) goto fail; |  135   if (!cm->above_seg_context) goto fail; | 
|  136  |  136  | 
|  137   return 0; |  137   return 0; | 
|  138  |  138  | 
|  139  fail: |  139  fail: | 
|  140   vp9_free_context_buffers(cm); |  140   vp9_free_context_buffers(cm); | 
|  141   return 1; |  141   return 1; | 
|  142 } |  142 } | 
|  143  |  143  | 
|  144 static void init_frame_bufs(VP9_COMMON *cm) { |  | 
|  145   BufferPool *const pool = cm->buffer_pool; |  | 
|  146   int i; |  | 
|  147  |  | 
|  148   cm->new_fb_idx = FRAME_BUFFERS - 1; |  | 
|  149   pool->frame_bufs[cm->new_fb_idx].ref_count = 1; |  | 
|  150  |  | 
|  151   for (i = 0; i < REF_FRAMES; ++i) { |  | 
|  152     cm->ref_frame_map[i] = i; |  | 
|  153     pool->frame_bufs[i].ref_count = 1; |  | 
|  154   } |  | 
|  155 } |  | 
|  156  |  | 
|  157 int vp9_alloc_ref_frame_buffers(VP9_COMMON *cm, int width, int height) { |  | 
|  158   int i; |  | 
|  159   const int ss_x = cm->subsampling_x; |  | 
|  160   const int ss_y = cm->subsampling_y; |  | 
|  161  |  | 
|  162   vp9_free_ref_frame_buffers(cm); |  | 
|  163  |  | 
|  164   for (i = 0; i < FRAME_BUFFERS; ++i) { |  | 
|  165     BufferPool *const pool = cm->buffer_pool; |  | 
|  166     pool->frame_bufs[i].ref_count = 0; |  | 
|  167     if (vp9_alloc_frame_buffer(&pool->frame_bufs[i].buf, width, height, |  | 
|  168                                ss_x, ss_y, |  | 
|  169 #if CONFIG_VP9_HIGHBITDEPTH |  | 
|  170                                cm->use_highbitdepth, |  | 
|  171 #endif |  | 
|  172                                VP9_ENC_BORDER_IN_PIXELS, |  | 
|  173                                cm->byte_alignment) < 0) |  | 
|  174       goto fail; |  | 
|  175     if (pool->frame_bufs[i].mvs == NULL) { |  | 
|  176       pool->frame_bufs[i].mvs = |  | 
|  177           (MV_REF *)vpx_calloc(cm->mi_rows * cm->mi_cols, |  | 
|  178                                sizeof(*pool->frame_bufs[i].mvs)); |  | 
|  179       if (pool->frame_bufs[i].mvs == NULL) |  | 
|  180         goto fail; |  | 
|  181  |  | 
|  182       pool->frame_bufs[i].mi_rows = cm->mi_rows; |  | 
|  183       pool->frame_bufs[i].mi_cols = cm->mi_cols; |  | 
|  184     } |  | 
|  185   } |  | 
|  186  |  | 
|  187   init_frame_bufs(cm); |  | 
|  188  |  | 
|  189 #if CONFIG_VP9_POSTPROC |  | 
|  190   if (vp9_alloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y, |  | 
|  191 #if CONFIG_VP9_HIGHBITDEPTH |  | 
|  192                              cm->use_highbitdepth, |  | 
|  193 #endif |  | 
|  194                              VP9_ENC_BORDER_IN_PIXELS, |  | 
|  195                              cm->byte_alignment) < 0) |  | 
|  196     goto fail; |  | 
|  197 #endif |  | 
|  198  |  | 
|  199   return 0; |  | 
|  200  |  | 
|  201  fail: |  | 
|  202   vp9_free_ref_frame_buffers(cm); |  | 
|  203   return 1; |  | 
|  204 } |  | 
|  205  |  | 
|  206 void vp9_remove_common(VP9_COMMON *cm) { |  144 void vp9_remove_common(VP9_COMMON *cm) { | 
|  207   vp9_free_ref_frame_buffers(cm); |  145   vp9_free_ref_frame_buffers(cm); | 
|  208   vp9_free_context_buffers(cm); |  146   vp9_free_context_buffers(cm); | 
|  209  |  147  | 
|  210   vpx_free(cm->fc); |  148   vpx_free(cm->fc); | 
|  211   cm->fc = NULL; |  149   cm->fc = NULL; | 
|  212   vpx_free(cm->frame_contexts); |  150   vpx_free(cm->frame_contexts); | 
|  213   cm->frame_contexts = NULL; |  151   cm->frame_contexts = NULL; | 
|  214 } |  152 } | 
|  215  |  153  | 
|  216 void vp9_init_context_buffers(VP9_COMMON *cm) { |  154 void vp9_init_context_buffers(VP9_COMMON *cm) { | 
|  217   cm->setup_mi(cm); |  155   cm->setup_mi(cm); | 
|  218   if (cm->last_frame_seg_map && !cm->frame_parallel_decode) |  156   if (cm->last_frame_seg_map && !cm->frame_parallel_decode) | 
|  219     vpx_memset(cm->last_frame_seg_map, 0, cm->mi_rows * cm->mi_cols); |  157     vpx_memset(cm->last_frame_seg_map, 0, cm->mi_rows * cm->mi_cols); | 
|  220 } |  158 } | 
|  221  |  159  | 
|  222 void vp9_swap_current_and_last_seg_map(VP9_COMMON *cm) { |  160 void vp9_swap_current_and_last_seg_map(VP9_COMMON *cm) { | 
|  223   // Swap indices. |  161   // Swap indices. | 
|  224   const int tmp = cm->seg_map_idx; |  162   const int tmp = cm->seg_map_idx; | 
|  225   cm->seg_map_idx = cm->prev_seg_map_idx; |  163   cm->seg_map_idx = cm->prev_seg_map_idx; | 
|  226   cm->prev_seg_map_idx = tmp; |  164   cm->prev_seg_map_idx = tmp; | 
|  227  |  165  | 
|  228   cm->current_frame_seg_map = cm->seg_map_array[cm->seg_map_idx]; |  166   cm->current_frame_seg_map = cm->seg_map_array[cm->seg_map_idx]; | 
|  229   cm->last_frame_seg_map = cm->seg_map_array[cm->prev_seg_map_idx]; |  167   cm->last_frame_seg_map = cm->seg_map_array[cm->prev_seg_map_idx]; | 
|  230 } |  168 } | 
| OLD | NEW |