Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: source/libvpx/vp9/common/vp9_alloccommon.c

Issue 1162573005: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "./vpx_config.h" 11 #include "./vpx_config.h"
12 #include "vpx_mem/vpx_mem.h" 12 #include "vpx_mem/vpx_mem.h"
13 13
14 #include "vp9/common/vp9_alloccommon.h"
14 #include "vp9/common/vp9_blockd.h" 15 #include "vp9/common/vp9_blockd.h"
15 #include "vp9/common/vp9_entropymode.h" 16 #include "vp9/common/vp9_entropymode.h"
16 #include "vp9/common/vp9_entropymv.h" 17 #include "vp9/common/vp9_entropymv.h"
17 #include "vp9/common/vp9_onyxc_int.h" 18 #include "vp9/common/vp9_onyxc_int.h"
18 #include "vp9/common/vp9_systemdependent.h" 19 #include "vp9/common/vp9_systemdependent.h"
19 20
20 // TODO(hkuang): Don't need to lock the whole pool after implementing atomic 21 // TODO(hkuang): Don't need to lock the whole pool after implementing atomic
21 // frame reference count. 22 // frame reference count.
22 void lock_buffer_pool(BufferPool *const pool) { 23 void lock_buffer_pool(BufferPool *const pool) {
23 #if CONFIG_MULTITHREAD 24 #if CONFIG_MULTITHREAD
(...skipping 25 matching lines...) Expand all
49 } 50 }
50 51
51 static int alloc_seg_map(VP9_COMMON *cm, int seg_map_size) { 52 static int alloc_seg_map(VP9_COMMON *cm, int seg_map_size) {
52 int i; 53 int i;
53 54
54 for (i = 0; i < NUM_PING_PONG_BUFFERS; ++i) { 55 for (i = 0; i < NUM_PING_PONG_BUFFERS; ++i) {
55 cm->seg_map_array[i] = (uint8_t *)vpx_calloc(seg_map_size, 1); 56 cm->seg_map_array[i] = (uint8_t *)vpx_calloc(seg_map_size, 1);
56 if (cm->seg_map_array[i] == NULL) 57 if (cm->seg_map_array[i] == NULL)
57 return 1; 58 return 1;
58 } 59 }
60 cm->seg_map_alloc_size = seg_map_size;
59 61
60 // Init the index. 62 // Init the index.
61 cm->seg_map_idx = 0; 63 cm->seg_map_idx = 0;
62 cm->prev_seg_map_idx = 1; 64 cm->prev_seg_map_idx = 1;
63 65
64 cm->current_frame_seg_map = cm->seg_map_array[cm->seg_map_idx]; 66 cm->current_frame_seg_map = cm->seg_map_array[cm->seg_map_idx];
65 if (!cm->frame_parallel_decode) 67 if (!cm->frame_parallel_decode)
66 cm->last_frame_seg_map = cm->seg_map_array[cm->prev_seg_map_idx]; 68 cm->last_frame_seg_map = cm->seg_map_array[cm->prev_seg_map_idx];
67 69
68 return 0; 70 return 0;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void vp9_free_context_buffers(VP9_COMMON *cm) { 112 void vp9_free_context_buffers(VP9_COMMON *cm) {
111 cm->free_mi(cm); 113 cm->free_mi(cm);
112 free_seg_map(cm); 114 free_seg_map(cm);
113 vpx_free(cm->above_context); 115 vpx_free(cm->above_context);
114 cm->above_context = NULL; 116 cm->above_context = NULL;
115 vpx_free(cm->above_seg_context); 117 vpx_free(cm->above_seg_context);
116 cm->above_seg_context = NULL; 118 cm->above_seg_context = NULL;
117 } 119 }
118 120
119 int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) { 121 int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
120 vp9_free_context_buffers(cm); 122 int new_mi_size;
121 123
122 vp9_set_mb_mi(cm, width, height); 124 vp9_set_mb_mi(cm, width, height);
123 if (cm->alloc_mi(cm, cm->mi_stride * calc_mi_size(cm->mi_rows))) 125 new_mi_size = cm->mi_stride * calc_mi_size(cm->mi_rows);
124 goto fail; 126 if (cm->mi_alloc_size < new_mi_size) {
127 cm->free_mi(cm);
128 if (cm->alloc_mi(cm, new_mi_size))
129 goto fail;
130 }
125 131
126 // Create the segmentation map structure and set to 0. 132 if (cm->seg_map_alloc_size < cm->mi_rows * cm->mi_cols) {
127 free_seg_map(cm); 133 // Create the segmentation map structure and set to 0.
128 if (alloc_seg_map(cm, cm->mi_rows * cm->mi_cols)) 134 free_seg_map(cm);
129 goto fail; 135 if (alloc_seg_map(cm, cm->mi_rows * cm->mi_cols))
136 goto fail;
137 }
130 138
131 cm->above_context = (ENTROPY_CONTEXT *)vpx_calloc( 139 if (cm->above_context_alloc_cols < cm->mi_cols) {
132 2 * mi_cols_aligned_to_sb(cm->mi_cols) * MAX_MB_PLANE, 140 vpx_free(cm->above_context);
133 sizeof(*cm->above_context)); 141 cm->above_context = (ENTROPY_CONTEXT *)vpx_calloc(
134 if (!cm->above_context) goto fail; 142 2 * mi_cols_aligned_to_sb(cm->mi_cols) * MAX_MB_PLANE,
143 sizeof(*cm->above_context));
144 if (!cm->above_context) goto fail;
135 145
136 cm->above_seg_context = (PARTITION_CONTEXT *)vpx_calloc( 146 vpx_free(cm->above_seg_context);
137 mi_cols_aligned_to_sb(cm->mi_cols), sizeof(*cm->above_seg_context)); 147 cm->above_seg_context = (PARTITION_CONTEXT *)vpx_calloc(
138 if (!cm->above_seg_context) goto fail; 148 mi_cols_aligned_to_sb(cm->mi_cols), sizeof(*cm->above_seg_context));
149 if (!cm->above_seg_context) goto fail;
150 cm->above_context_alloc_cols = cm->mi_cols;
151 }
139 152
140 return 0; 153 return 0;
141 154
142 fail: 155 fail:
143 vp9_free_context_buffers(cm); 156 vp9_free_context_buffers(cm);
144 return 1; 157 return 1;
145 } 158 }
146 159
147 void vp9_remove_common(VP9_COMMON *cm) { 160 void vp9_remove_common(VP9_COMMON *cm) {
148 vp9_free_context_buffers(cm); 161 vp9_free_context_buffers(cm);
(...skipping 12 matching lines...) Expand all
161 174
162 void vp9_swap_current_and_last_seg_map(VP9_COMMON *cm) { 175 void vp9_swap_current_and_last_seg_map(VP9_COMMON *cm) {
163 // Swap indices. 176 // Swap indices.
164 const int tmp = cm->seg_map_idx; 177 const int tmp = cm->seg_map_idx;
165 cm->seg_map_idx = cm->prev_seg_map_idx; 178 cm->seg_map_idx = cm->prev_seg_map_idx;
166 cm->prev_seg_map_idx = tmp; 179 cm->prev_seg_map_idx = tmp;
167 180
168 cm->current_frame_seg_map = cm->seg_map_array[cm->seg_map_idx]; 181 cm->current_frame_seg_map = cm->seg_map_array[cm->seg_map_idx];
169 cm->last_frame_seg_map = cm->seg_map_array[cm->prev_seg_map_idx]; 182 cm->last_frame_seg_map = cm->seg_map_array[cm->prev_seg_map_idx];
170 } 183 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/mips/msa/vp9_macros_msa.h ('k') | source/libvpx/vp9/common/vp9_blockd.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698