Lines Matching refs:cm
38 void vp9_set_mb_mi(VP9_COMMON *cm, int width, int height) {
42 cm->mi_cols = aligned_width >> MI_SIZE_LOG2;
43 cm->mi_rows = aligned_height >> MI_SIZE_LOG2;
44 cm->mi_stride = calc_mi_size(cm->mi_cols);
46 cm->mb_cols = (cm->mi_cols + 1) >> 1;
47 cm->mb_rows = (cm->mi_rows + 1) >> 1;
48 cm->MBs = cm->mb_rows * cm->mb_cols;
51 static int alloc_seg_map(VP9_COMMON *cm, int seg_map_size) {
55 cm->seg_map_array[i] = (uint8_t *)vpx_calloc(seg_map_size, 1);
56 if (cm->seg_map_array[i] == NULL) return 1;
58 cm->seg_map_alloc_size = seg_map_size;
61 cm->seg_map_idx = 0;
62 cm->prev_seg_map_idx = 1;
64 cm->current_frame_seg_map = cm->seg_map_array[cm->seg_map_idx];
65 if (!cm->frame_parallel_decode)
66 cm->last_frame_seg_map = cm->seg_map_array[cm->prev_seg_map_idx];
71 static void free_seg_map(VP9_COMMON *cm) {
75 vpx_free(cm->seg_map_array[i]);
76 cm->seg_map_array[i] = NULL;
79 cm->current_frame_seg_map = NULL;
81 if (!cm->frame_parallel_decode) {
82 cm->last_frame_seg_map = NULL;
101 void vp9_free_postproc_buffers(VP9_COMMON *cm) {
103 vpx_free_frame_buffer(&cm->post_proc_buffer);
104 vpx_free_frame_buffer(&cm->post_proc_buffer_int);
105 vpx_free(cm->postproc_state.limits);
106 cm->postproc_state.limits = NULL;
107 vpx_free(cm->postproc_state.generated_noise);
108 cm->postproc_state.generated_noise = NULL;
110 (void)cm;
114 void vp9_free_context_buffers(VP9_COMMON *cm) {
115 cm->free_mi(cm);
116 free_seg_map(cm);
117 vpx_free(cm->above_context);
118 cm->above_context = NULL;
119 vpx_free(cm->above_seg_context);
120 cm->above_seg_context = NULL;
121 vpx_free(cm->lf.lfm);
122 cm->lf.lfm = NULL;
125 int vp9_alloc_loop_filter(VP9_COMMON *cm) {
126 vpx_free(cm->lf.lfm);
129 cm->lf.lfm_stride = (cm->mi_cols + (MI_BLOCK_SIZE - 1)) >> 3;
130 cm->lf.lfm = (LOOP_FILTER_MASK *)vpx_calloc(
131 ((cm->mi_rows + (MI_BLOCK_SIZE - 1)) >> 3) * cm->lf.lfm_stride,
132 sizeof(*cm->lf.lfm));
133 if (!cm->lf.lfm) return 1;
137 int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
140 vp9_set_mb_mi(cm, width, height);
141 new_mi_size = cm->mi_stride * calc_mi_size(cm->mi_rows);
142 if (cm->mi_alloc_size < new_mi_size) {
143 cm->free_mi(cm);
144 if (cm->alloc_mi(cm, new_mi_size)) goto fail;
147 if (cm->seg_map_alloc_size < cm->mi_rows * cm->mi_cols) {
149 free_seg_map(cm);
150 if (alloc_seg_map(cm, cm->mi_rows * cm->mi_cols)) goto fail;
153 if (cm->above_context_alloc_cols < cm->mi_cols) {
154 vpx_free(cm->above_context);
155 cm->above_context = (ENTROPY_CONTEXT *)vpx_calloc(
156 2 * mi_cols_aligned_to_sb(cm->mi_cols) * MAX_MB_PLANE,
157 sizeof(*cm->above_context));
158 if (!cm->above_context) goto fail;
160 vpx_free(cm->above_seg_context);
161 cm->above_seg_context = (PARTITION_CONTEXT *)vpx_calloc(
162 mi_cols_aligned_to_sb(cm->mi_cols), sizeof(*cm->above_seg_context));
163 if (!cm->above_seg_context) goto fail;
164 cm->above_context_alloc_cols = cm->mi_cols;
167 if (vp9_alloc_loop_filter(cm)) goto fail;
173 vp9_set_mb_mi(cm, 0, 0);
174 vp9_free_context_buffers(cm);
178 void vp9_remove_common(VP9_COMMON *cm) {
179 vp9_free_context_buffers(cm);
181 vpx_free(cm->fc);
182 cm->fc = NULL;
183 vpx_free(cm->frame_contexts);
184 cm->frame_contexts = NULL;
187 void vp9_init_context_buffers(VP9_COMMON *cm) {
188 cm->setup_mi(cm);
189 if (cm->last_frame_seg_map && !cm->frame_parallel_decode)
190 memset(cm->last_frame_seg_map, 0, cm->mi_rows * cm->mi_cols);
193 void vp9_swap_current_and_last_seg_map(VP9_COMMON *cm) {
195 const int tmp = cm->seg_map_idx;
196 cm->seg_map_idx = cm->prev_seg_map_idx;
197 cm->prev_seg_map_idx = tmp;
199 cm->current_frame_seg_map = cm->seg_map_array[cm->seg_map_idx];
200 cm->last_frame_seg_map = cm->seg_map_array[cm->prev_seg_map_idx];