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

Side by Side Diff: source/libvpx/vp9/decoder/vp9_onyxd_if.c

Issue 181493009: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_onyxd.h ('k') | source/libvpx/vp9/decoder/vp9_read_bit_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 static void init_macroblockd(VP9D_COMP *const pbi) { 111 static void init_macroblockd(VP9D_COMP *const pbi) {
112 MACROBLOCKD *xd = &pbi->mb; 112 MACROBLOCKD *xd = &pbi->mb;
113 struct macroblockd_plane *const pd = xd->plane; 113 struct macroblockd_plane *const pd = xd->plane;
114 int i; 114 int i;
115 115
116 for (i = 0; i < MAX_MB_PLANE; ++i) 116 for (i = 0; i < MAX_MB_PLANE; ++i)
117 pd[i].dqcoeff = pbi->dqcoeff[i]; 117 pd[i].dqcoeff = pbi->dqcoeff[i];
118 } 118 }
119 119
120 VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf) { 120 VP9D_COMP *vp9_create_decompressor(VP9D_CONFIG *oxcf) {
121 VP9D_COMP *const pbi = vpx_memalign(32, sizeof(VP9D_COMP)); 121 VP9D_COMP *const pbi = vpx_memalign(32, sizeof(VP9D_COMP));
122 VP9_COMMON *const cm = pbi ? &pbi->common : NULL; 122 VP9_COMMON *const cm = pbi ? &pbi->common : NULL;
123 123
124 if (!cm) 124 if (!cm)
125 return NULL; 125 return NULL;
126 126
127 vp9_zero(*pbi); 127 vp9_zero(*pbi);
128 128
129 // Initialize the references to not point to any frame buffers. 129 // Initialize the references to not point to any frame buffers.
130 memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map)); 130 memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
131 131
132 if (setjmp(cm->error.jmp)) { 132 if (setjmp(cm->error.jmp)) {
133 cm->error.setjmp = 0; 133 cm->error.setjmp = 0;
134 vp9_remove_decompressor(pbi); 134 vp9_remove_decompressor(pbi);
135 return NULL; 135 return NULL;
136 } 136 }
137 137
138 cm->error.setjmp = 1; 138 cm->error.setjmp = 1;
139 vp9_initialize_dec(); 139 vp9_initialize_dec();
140 140
141 vp9_create_common(cm); 141 vp9_rtcd();
142 142
143 pbi->oxcf = *oxcf; 143 pbi->oxcf = *oxcf;
144 pbi->ready_for_new_data = 1; 144 pbi->ready_for_new_data = 1;
145 cm->current_video_frame = 0; 145 cm->current_video_frame = 0;
146 146
147 // vp9_init_dequantizer() is first called here. Add check in 147 // vp9_init_dequantizer() is first called here. Add check in
148 // frame_init_dequantizer() to avoid unnecessary calling of 148 // frame_init_dequantizer() to avoid unnecessary calling of
149 // vp9_init_dequantizer() for every frame. 149 // vp9_init_dequantizer() for every frame.
150 vp9_init_dequantizer(cm); 150 vp9_init_dequantizer(cm);
151 151
152 vp9_loop_filter_init(cm); 152 vp9_loop_filter_init(cm);
153 153
154 cm->error.setjmp = 0; 154 cm->error.setjmp = 0;
155 pbi->decoded_key_frame = 0; 155 pbi->decoded_key_frame = 0;
156 156
157 init_macroblockd(pbi); 157 init_macroblockd(pbi);
158 158
159 vp9_worker_init(&pbi->lf_worker); 159 vp9_worker_init(&pbi->lf_worker);
160 160
161 return pbi; 161 return pbi;
162 } 162 }
163 163
164 void vp9_remove_decompressor(VP9D_PTR ptr) { 164 void vp9_remove_decompressor(VP9D_COMP *pbi) {
165 int i; 165 int i;
166 VP9D_COMP *const pbi = (VP9D_COMP *)ptr;
167 166
168 if (!pbi) 167 if (!pbi)
169 return; 168 return;
170 169
171 vp9_remove_common(&pbi->common); 170 vp9_remove_common(&pbi->common);
172 vp9_worker_end(&pbi->lf_worker); 171 vp9_worker_end(&pbi->lf_worker);
173 vpx_free(pbi->lf_worker.data1); 172 vpx_free(pbi->lf_worker.data1);
174 for (i = 0; i < pbi->num_tile_workers; ++i) { 173 for (i = 0; i < pbi->num_tile_workers; ++i) {
175 VP9Worker *const worker = &pbi->tile_workers[i]; 174 VP9Worker *const worker = &pbi->tile_workers[i];
176 vp9_worker_end(worker); 175 vp9_worker_end(worker);
(...skipping 16 matching lines...) Expand all
193 vpx_free(pbi->above_seg_context); 192 vpx_free(pbi->above_seg_context);
194 vpx_free(pbi); 193 vpx_free(pbi);
195 } 194 }
196 195
197 static int equal_dimensions(const YV12_BUFFER_CONFIG *a, 196 static int equal_dimensions(const YV12_BUFFER_CONFIG *a,
198 const YV12_BUFFER_CONFIG *b) { 197 const YV12_BUFFER_CONFIG *b) {
199 return a->y_height == b->y_height && a->y_width == b->y_width && 198 return a->y_height == b->y_height && a->y_width == b->y_width &&
200 a->uv_height == b->uv_height && a->uv_width == b->uv_width; 199 a->uv_height == b->uv_height && a->uv_width == b->uv_width;
201 } 200 }
202 201
203 vpx_codec_err_t vp9_copy_reference_dec(VP9D_PTR ptr, 202 vpx_codec_err_t vp9_copy_reference_dec(VP9D_COMP *pbi,
204 VP9_REFFRAME ref_frame_flag, 203 VP9_REFFRAME ref_frame_flag,
205 YV12_BUFFER_CONFIG *sd) { 204 YV12_BUFFER_CONFIG *sd) {
206 VP9D_COMP *pbi = (VP9D_COMP *) ptr;
207 VP9_COMMON *cm = &pbi->common; 205 VP9_COMMON *cm = &pbi->common;
208 206
209 /* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the 207 /* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the
210 * encoder is using the frame buffers for. This is just a stub to keep the 208 * encoder is using the frame buffers for. This is just a stub to keep the
211 * vpxenc --test-decode functionality working, and will be replaced in a 209 * vpxenc --test-decode functionality working, and will be replaced in a
212 * later commit that adds VP9-specific controls for this functionality. 210 * later commit that adds VP9-specific controls for this functionality.
213 */ 211 */
214 if (ref_frame_flag == VP9_LAST_FLAG) { 212 if (ref_frame_flag == VP9_LAST_FLAG) {
215 const YV12_BUFFER_CONFIG *const cfg = 213 const YV12_BUFFER_CONFIG *const cfg =
216 &cm->frame_bufs[cm->ref_frame_map[0]].buf; 214 &cm->frame_bufs[cm->ref_frame_map[0]].buf;
217 if (!equal_dimensions(cfg, sd)) 215 if (!equal_dimensions(cfg, sd))
218 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, 216 vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
219 "Incorrect buffer dimensions"); 217 "Incorrect buffer dimensions");
220 else 218 else
221 vp8_yv12_copy_frame(cfg, sd); 219 vp8_yv12_copy_frame(cfg, sd);
222 } else { 220 } else {
223 vpx_internal_error(&cm->error, VPX_CODEC_ERROR, 221 vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
224 "Invalid reference frame"); 222 "Invalid reference frame");
225 } 223 }
226 224
227 return cm->error.error_code; 225 return cm->error.error_code;
228 } 226 }
229 227
230 228
231 vpx_codec_err_t vp9_set_reference_dec(VP9D_PTR ptr, VP9_REFFRAME ref_frame_flag, 229 vpx_codec_err_t vp9_set_reference_dec(VP9D_COMP *pbi,
230 VP9_REFFRAME ref_frame_flag,
232 YV12_BUFFER_CONFIG *sd) { 231 YV12_BUFFER_CONFIG *sd) {
233 VP9D_COMP *pbi = (VP9D_COMP *) ptr;
234 VP9_COMMON *cm = &pbi->common; 232 VP9_COMMON *cm = &pbi->common;
235 RefBuffer *ref_buf = NULL; 233 RefBuffer *ref_buf = NULL;
236 234
237 /* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the 235 /* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the
238 * encoder is using the frame buffers for. This is just a stub to keep the 236 * encoder is using the frame buffers for. This is just a stub to keep the
239 * vpxenc --test-decode functionality working, and will be replaced in a 237 * vpxenc --test-decode functionality working, and will be replaced in a
240 * later commit that adds VP9-specific controls for this functionality. 238 * later commit that adds VP9-specific controls for this functionality.
241 */ 239 */
242 if (ref_frame_flag == VP9_LAST_FLAG) { 240 if (ref_frame_flag == VP9_LAST_FLAG) {
243 ref_buf = &cm->frame_refs[0]; 241 ref_buf = &cm->frame_refs[0];
(...skipping 22 matching lines...) Expand all
266 // Manage the reference counters and copy image. 264 // Manage the reference counters and copy image.
267 ref_cnt_fb(cm->frame_bufs, ref_fb_ptr, free_fb); 265 ref_cnt_fb(cm->frame_bufs, ref_fb_ptr, free_fb);
268 ref_buf->buf = &cm->frame_bufs[*ref_fb_ptr].buf; 266 ref_buf->buf = &cm->frame_bufs[*ref_fb_ptr].buf;
269 vp8_yv12_copy_frame(sd, ref_buf->buf); 267 vp8_yv12_copy_frame(sd, ref_buf->buf);
270 } 268 }
271 269
272 return pbi->common.error.error_code; 270 return pbi->common.error.error_code;
273 } 271 }
274 272
275 273
276 int vp9_get_reference_dec(VP9D_PTR ptr, int index, YV12_BUFFER_CONFIG **fb) { 274 int vp9_get_reference_dec(VP9D_COMP *pbi, int index, YV12_BUFFER_CONFIG **fb) {
277 VP9D_COMP *pbi = (VP9D_COMP *) ptr;
278 VP9_COMMON *cm = &pbi->common; 275 VP9_COMMON *cm = &pbi->common;
279 276
280 if (index < 0 || index >= REF_FRAMES) 277 if (index < 0 || index >= REF_FRAMES)
281 return -1; 278 return -1;
282 279
283 *fb = &cm->frame_bufs[cm->ref_frame_map[index]].buf; 280 *fb = &cm->frame_bufs[cm->ref_frame_map[index]].buf;
284 return 0; 281 return 0;
285 } 282 }
286 283
287 /* If any buffer updating is signaled it should be done here. */ 284 /* If any buffer updating is signaled it should be done here. */
(...skipping 14 matching lines...) Expand all
302 } 299 }
303 300
304 cm->frame_to_show = get_frame_new_buffer(cm); 301 cm->frame_to_show = get_frame_new_buffer(cm);
305 cm->frame_bufs[cm->new_fb_idx].ref_count--; 302 cm->frame_bufs[cm->new_fb_idx].ref_count--;
306 303
307 // Invalidate these references until the next frame starts. 304 // Invalidate these references until the next frame starts.
308 for (ref_index = 0; ref_index < 3; ref_index++) 305 for (ref_index = 0; ref_index < 3; ref_index++)
309 cm->frame_refs[ref_index].idx = INT_MAX; 306 cm->frame_refs[ref_index].idx = INT_MAX;
310 } 307 }
311 308
312 int vp9_receive_compressed_data(VP9D_PTR ptr, 309 int vp9_receive_compressed_data(VP9D_COMP *pbi,
313 size_t size, const uint8_t **psource, 310 size_t size, const uint8_t **psource,
314 int64_t time_stamp) { 311 int64_t time_stamp) {
315 VP9D_COMP *pbi = (VP9D_COMP *) ptr; 312 VP9_COMMON *cm = NULL;
316 VP9_COMMON *cm = &pbi->common;
317 const uint8_t *source = *psource; 313 const uint8_t *source = *psource;
318 int retcode = 0; 314 int retcode = 0;
319 315
320 /*if(pbi->ready_for_new_data == 0) 316 /*if(pbi->ready_for_new_data == 0)
321 return -1;*/ 317 return -1;*/
322 318
323 if (ptr == 0) 319 if (!pbi)
324 return -1; 320 return -1;
325 321
322 cm = &pbi->common;
326 cm->error.error_code = VPX_CODEC_OK; 323 cm->error.error_code = VPX_CODEC_OK;
327 324
328 pbi->source = source; 325 pbi->source = source;
329 pbi->source_sz = size; 326 pbi->source_sz = size;
330 327
331 if (pbi->source_sz == 0) { 328 if (pbi->source_sz == 0) {
332 /* This is used to signal that we are missing frames. 329 /* This is used to signal that we are missing frames.
333 * We do not know if the missing frame(s) was supposed to update 330 * We do not know if the missing frame(s) was supposed to update
334 * any of the reference buffers, but we act conservative and 331 * any of the reference buffers, but we act conservative and
335 * mark only the last buffer as corrupted. 332 * mark only the last buffer as corrupted.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } 444 }
448 445
449 pbi->ready_for_new_data = 0; 446 pbi->ready_for_new_data = 0;
450 pbi->last_time_stamp = time_stamp; 447 pbi->last_time_stamp = time_stamp;
451 pbi->source_sz = 0; 448 pbi->source_sz = 0;
452 449
453 cm->error.setjmp = 0; 450 cm->error.setjmp = 0;
454 return retcode; 451 return retcode;
455 } 452 }
456 453
457 int vp9_get_raw_frame(VP9D_PTR ptr, YV12_BUFFER_CONFIG *sd, 454 int vp9_get_raw_frame(VP9D_COMP *pbi, YV12_BUFFER_CONFIG *sd,
458 int64_t *time_stamp, int64_t *time_end_stamp, 455 int64_t *time_stamp, int64_t *time_end_stamp,
459 vp9_ppflags_t *flags) { 456 vp9_ppflags_t *flags) {
460 int ret = -1; 457 int ret = -1;
461 VP9D_COMP *pbi = (VP9D_COMP *) ptr;
462 458
463 if (pbi->ready_for_new_data == 1) 459 if (pbi->ready_for_new_data == 1)
464 return ret; 460 return ret;
465 461
466 /* ie no raw frame to show!!! */ 462 /* ie no raw frame to show!!! */
467 if (pbi->common.show_frame == 0) 463 if (pbi->common.show_frame == 0)
468 return ret; 464 return ret;
469 465
470 pbi->ready_for_new_data = 1; 466 pbi->ready_for_new_data = 1;
471 *time_stamp = pbi->last_time_stamp; 467 *time_stamp = pbi->last_time_stamp;
(...skipping 12 matching lines...) Expand all
484 480
485 ret = 0; 481 ret = 0;
486 } else { 482 } else {
487 ret = -1; 483 ret = -1;
488 } 484 }
489 485
490 #endif /*!CONFIG_POSTPROC*/ 486 #endif /*!CONFIG_POSTPROC*/
491 vp9_clear_system_state(); 487 vp9_clear_system_state();
492 return ret; 488 return ret;
493 } 489 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_onyxd.h ('k') | source/libvpx/vp9/decoder/vp9_read_bit_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698