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

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

Issue 11555023: libvpx: Add VP9 decoder. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 8 years 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11
12 #include "vpx_ports/config.h"
13 #include "vp9/common/vp9_blockd.h"
14 #include "vpx_mem/vpx_mem.h"
15 #include "vp9/common/vp9_onyxc_int.h"
16 #include "vp9/common/vp9_findnearmv.h"
17 #include "vp9/common/vp9_entropymode.h"
18 #include "vp9/common/vp9_entropymv.h"
19 #include "vp9/common/vp9_systemdependent.h"
20
21
22 void vp9_update_mode_info_border(VP9_COMMON *cpi, MODE_INFO *mi_base) {
23 int stride = cpi->mode_info_stride;
24 int i;
25
26 // Clear down top border row
27 vpx_memset(mi_base, 0, sizeof(MODE_INFO) * cpi->mode_info_stride);
28
29 // Clear left border column
30 for (i = 1; i < cpi->mb_rows + 1; i++) {
31 vpx_memset(&mi_base[i * stride], 0, sizeof(MODE_INFO));
32 }
33 }
34
35 void vp9_update_mode_info_in_image(VP9_COMMON *cpi, MODE_INFO *mi) {
36 int i, j;
37
38 // For each in image mode_info element set the in image flag to 1
39 for (i = 0; i < cpi->mb_rows; i++) {
40 for (j = 0; j < cpi->mb_cols; j++) {
41 mi->mbmi.mb_in_image = 1;
42 mi++; // Next element in the row
43 }
44
45 mi++; // Step over border element at start of next row
46 }
47 }
48
49 void vp9_de_alloc_frame_buffers(VP9_COMMON *oci) {
50 int i;
51
52 for (i = 0; i < NUM_YV12_BUFFERS; i++)
53 vp8_yv12_de_alloc_frame_buffer(&oci->yv12_fb[i]);
54
55 vp8_yv12_de_alloc_frame_buffer(&oci->temp_scale_frame);
56 vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer);
57
58 vpx_free(oci->above_context);
59 vpx_free(oci->mip);
60 vpx_free(oci->prev_mip);
61
62 oci->above_context = 0;
63 oci->mip = 0;
64 oci->prev_mip = 0;
65
66 }
67
68 int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
69 int i;
70
71 vp9_de_alloc_frame_buffers(oci);
72
73 /* our internal buffers are always multiples of 16 */
74 if ((width & 0xf) != 0)
75 width += 16 - (width & 0xf);
76
77 if ((height & 0xf) != 0)
78 height += 16 - (height & 0xf);
79
80
81 for (i = 0; i < NUM_YV12_BUFFERS; i++) {
82 oci->fb_idx_ref_cnt[i] = 0;
83 oci->yv12_fb[i].flags = 0;
84 if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i], width, height,
85 VP9BORDERINPIXELS) < 0) {
86 vp9_de_alloc_frame_buffers(oci);
87 return 1;
88 }
89 }
90
91 oci->new_fb_idx = 0;
92 oci->lst_fb_idx = 1;
93 oci->gld_fb_idx = 2;
94 oci->alt_fb_idx = 3;
95
96 oci->fb_idx_ref_cnt[0] = 1;
97 oci->fb_idx_ref_cnt[1] = 1;
98 oci->fb_idx_ref_cnt[2] = 1;
99 oci->fb_idx_ref_cnt[3] = 1;
100
101 if (vp8_yv12_alloc_frame_buffer(&oci->temp_scale_frame, width, 16,
102 VP9BORDERINPIXELS) < 0) {
103 vp9_de_alloc_frame_buffers(oci);
104 return 1;
105 }
106
107 if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height,
108 VP9BORDERINPIXELS) < 0) {
109 vp9_de_alloc_frame_buffers(oci);
110 return 1;
111 }
112
113 oci->mb_rows = height >> 4;
114 oci->mb_cols = width >> 4;
115 oci->MBs = oci->mb_rows * oci->mb_cols;
116 oci->mode_info_stride = oci->mb_cols + 1;
117 oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INF O));
118
119 if (!oci->mip) {
120 vp9_de_alloc_frame_buffers(oci);
121 return 1;
122 }
123
124 oci->mi = oci->mip + oci->mode_info_stride + 1;
125
126 /* allocate memory for last frame MODE_INFO array */
127
128 oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MOD E_INFO));
129
130 if (!oci->prev_mip) {
131 vp9_de_alloc_frame_buffers(oci);
132 return 1;
133 }
134
135 oci->prev_mi = oci->prev_mip + oci->mode_info_stride + 1;
136
137 oci->above_context = vpx_calloc(sizeof(ENTROPY_CONTEXT_PLANES) * oci->mb_cols, 1);
138
139 if (!oci->above_context) {
140 vp9_de_alloc_frame_buffers(oci);
141 return 1;
142 }
143
144 vp9_update_mode_info_border(oci, oci->mip);
145 vp9_update_mode_info_in_image(oci, oci->mi);
146
147 return 0;
148 }
149 void vp9_setup_version(VP9_COMMON *cm) {
150 if (cm->version & 0x4) {
151 if (!CONFIG_EXPERIMENTAL)
152 vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM,
153 "Bitstream was created by an experimental "
154 "encoder");
155 cm->experimental = 1;
156 }
157
158 switch (cm->version & 0x3) {
159 case 0:
160 cm->no_lpf = 0;
161 cm->filter_type = NORMAL_LOOPFILTER;
162 cm->use_bilinear_mc_filter = 0;
163 cm->full_pixel = 0;
164 break;
165 case 1:
166 cm->no_lpf = 0;
167 cm->filter_type = SIMPLE_LOOPFILTER;
168 cm->use_bilinear_mc_filter = 1;
169 cm->full_pixel = 0;
170 break;
171 case 2:
172 case 3:
173 cm->no_lpf = 1;
174 cm->filter_type = NORMAL_LOOPFILTER;
175 cm->use_bilinear_mc_filter = 1;
176 cm->full_pixel = 0;
177 break;
178 // Full pel only code deprecated in experimental code base
179 // case 3:
180 // cm->no_lpf = 1;
181 // cm->filter_type = SIMPLE_LOOPFILTER;
182 // cm->use_bilinear_mc_filter = 1;
183 // cm->full_pixel = 1;
184 // break;
185 }
186 }
187 void vp9_create_common(VP9_COMMON *oci) {
188 vp9_machine_specific_config(oci);
189
190 vp9_init_mbmode_probs(oci);
191
192 vp9_default_bmode_probs(oci->fc.bmode_prob);
193
194 oci->txfm_mode = ONLY_4X4;
195 oci->mb_no_coeff_skip = 1;
196 oci->comp_pred_mode = HYBRID_PREDICTION;
197 oci->no_lpf = 0;
198 oci->filter_type = NORMAL_LOOPFILTER;
199 oci->use_bilinear_mc_filter = 0;
200 oci->full_pixel = 0;
201 oci->clr_type = REG_YUV;
202 oci->clamp_type = RECON_CLAMP_REQUIRED;
203
204 /* Initialise reference frame sign bias structure to defaults */
205 vpx_memset(oci->ref_frame_sign_bias, 0, sizeof(oci->ref_frame_sign_bias));
206
207 /* Default disable buffer to buffer copying */
208 oci->copy_buffer_to_gf = 0;
209 oci->copy_buffer_to_arf = 0;
210 oci->kf_ymode_probs_update = 0;
211 }
212
213 void vp9_remove_common(VP9_COMMON *oci) {
214 vp9_de_alloc_frame_buffers(oci);
215 }
216
217 void vp9_initialize_common() {
218 vp9_coef_tree_initialize();
219
220 vp9_entropy_mode_init();
221
222 vp9_entropy_mv_init();
223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698