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 24 matching lines...) Expand all Loading... |
35 void vp9_initialize_dec() { | 35 void vp9_initialize_dec() { |
36 static int init_done = 0; | 36 static int init_done = 0; |
37 | 37 |
38 if (!init_done) { | 38 if (!init_done) { |
39 vp9_init_neighbors(); | 39 vp9_init_neighbors(); |
40 vp9_init_quant_tables(); | 40 vp9_init_quant_tables(); |
41 init_done = 1; | 41 init_done = 1; |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 VP9Decoder *vp9_decoder_create(const VP9DecoderConfig *oxcf) { | 45 VP9Decoder *vp9_decoder_create() { |
46 VP9Decoder *const pbi = vpx_memalign(32, sizeof(*pbi)); | 46 VP9Decoder *const pbi = vpx_memalign(32, sizeof(*pbi)); |
47 VP9_COMMON *const cm = pbi ? &pbi->common : NULL; | 47 VP9_COMMON *const cm = pbi ? &pbi->common : NULL; |
48 | 48 |
49 if (!cm) | 49 if (!cm) |
50 return NULL; | 50 return NULL; |
51 | 51 |
52 vp9_zero(*pbi); | 52 vp9_zero(*pbi); |
53 | 53 |
54 if (setjmp(cm->error.jmp)) { | 54 if (setjmp(cm->error.jmp)) { |
55 cm->error.setjmp = 0; | 55 cm->error.setjmp = 0; |
56 vp9_decoder_remove(pbi); | 56 vp9_decoder_remove(pbi); |
57 return NULL; | 57 return NULL; |
58 } | 58 } |
59 | 59 |
60 cm->error.setjmp = 1; | 60 cm->error.setjmp = 1; |
61 vp9_initialize_dec(); | 61 vp9_initialize_dec(); |
62 | 62 |
63 vp9_rtcd(); | 63 vp9_rtcd(); |
64 | 64 |
65 // Initialize the references to not point to any frame buffers. | 65 // Initialize the references to not point to any frame buffers. |
66 vpx_memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map)); | 66 vpx_memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map)); |
67 | 67 |
68 cm->current_video_frame = 0; | 68 cm->current_video_frame = 0; |
69 pbi->oxcf = *oxcf; | |
70 pbi->ready_for_new_data = 1; | 69 pbi->ready_for_new_data = 1; |
71 pbi->decoded_key_frame = 0; | 70 pbi->decoded_key_frame = 0; |
72 | 71 |
73 // vp9_init_dequantizer() is first called here. Add check in | 72 // vp9_init_dequantizer() is first called here. Add check in |
74 // frame_init_dequantizer() to avoid unnecessary calling of | 73 // frame_init_dequantizer() to avoid unnecessary calling of |
75 // vp9_init_dequantizer() for every frame. | 74 // vp9_init_dequantizer() for every frame. |
76 vp9_init_dequantizer(cm); | 75 vp9_init_dequantizer(cm); |
77 | 76 |
78 vp9_loop_filter_init(cm); | 77 vp9_loop_filter_init(cm); |
79 | 78 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 if (retcode < 0) { | 272 if (retcode < 0) { |
274 cm->error.error_code = VPX_CODEC_ERROR; | 273 cm->error.error_code = VPX_CODEC_ERROR; |
275 cm->error.setjmp = 0; | 274 cm->error.setjmp = 0; |
276 if (cm->frame_bufs[cm->new_fb_idx].ref_count > 0) | 275 if (cm->frame_bufs[cm->new_fb_idx].ref_count > 0) |
277 cm->frame_bufs[cm->new_fb_idx].ref_count--; | 276 cm->frame_bufs[cm->new_fb_idx].ref_count--; |
278 return retcode; | 277 return retcode; |
279 } | 278 } |
280 | 279 |
281 swap_frame_buffers(pbi); | 280 swap_frame_buffers(pbi); |
282 | 281 |
283 if (!pbi->do_loopfilter_inline) { | |
284 // If multiple threads are used to decode tiles, then we use those threads | |
285 // to do parallel loopfiltering. | |
286 if (pbi->num_tile_workers) { | |
287 vp9_loop_filter_frame_mt(pbi, cm, cm->lf.filter_level, 0, 0); | |
288 } else { | |
289 vp9_loop_filter_frame(cm, &pbi->mb, cm->lf.filter_level, 0, 0); | |
290 } | |
291 } | |
292 | |
293 vp9_clear_system_state(); | 282 vp9_clear_system_state(); |
294 | 283 |
295 cm->last_width = cm->width; | 284 cm->last_width = cm->width; |
296 cm->last_height = cm->height; | 285 cm->last_height = cm->height; |
297 | 286 |
298 if (!cm->show_existing_frame) | 287 if (!cm->show_existing_frame) |
299 cm->last_show_frame = cm->show_frame; | 288 cm->last_show_frame = cm->show_frame; |
300 if (cm->show_frame) { | 289 if (cm->show_frame) { |
301 if (!cm->show_existing_frame) | 290 if (!cm->show_existing_frame) |
302 vp9_swap_mi_and_prev_mi(cm); | 291 vp9_swap_mi_and_prev_mi(cm); |
303 | 292 |
304 cm->current_video_frame++; | 293 cm->current_video_frame++; |
305 } | 294 } |
306 | 295 |
307 pbi->ready_for_new_data = 0; | 296 pbi->ready_for_new_data = 0; |
308 pbi->last_time_stamp = time_stamp; | 297 pbi->last_time_stamp = time_stamp; |
309 | 298 |
310 cm->error.setjmp = 0; | 299 cm->error.setjmp = 0; |
311 return retcode; | 300 return retcode; |
312 } | 301 } |
313 | 302 |
314 int vp9_get_raw_frame(VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd, | 303 int vp9_get_raw_frame(VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd, |
315 int64_t *time_stamp, int64_t *time_end_stamp, | 304 int64_t *time_stamp, int64_t *time_end_stamp, |
316 vp9_ppflags_t *flags) { | 305 vp9_ppflags_t *flags) { |
317 int ret = -1; | 306 int ret = -1; |
| 307 #if !CONFIG_VP9_POSTPROC |
| 308 (void)*flags; |
| 309 #endif |
318 | 310 |
319 if (pbi->ready_for_new_data == 1) | 311 if (pbi->ready_for_new_data == 1) |
320 return ret; | 312 return ret; |
321 | 313 |
322 /* ie no raw frame to show!!! */ | 314 /* no raw frame to show!!! */ |
323 if (pbi->common.show_frame == 0) | 315 if (pbi->common.show_frame == 0) |
324 return ret; | 316 return ret; |
325 | 317 |
326 pbi->ready_for_new_data = 1; | 318 pbi->ready_for_new_data = 1; |
327 *time_stamp = pbi->last_time_stamp; | 319 *time_stamp = pbi->last_time_stamp; |
328 *time_end_stamp = 0; | 320 *time_end_stamp = 0; |
329 | 321 |
330 #if CONFIG_VP9_POSTPROC | 322 #if CONFIG_VP9_POSTPROC |
331 ret = vp9_post_proc_frame(&pbi->common, sd, flags); | 323 ret = vp9_post_proc_frame(&pbi->common, sd, flags); |
332 #else | 324 #else |
333 *sd = *pbi->common.frame_to_show; | 325 *sd = *pbi->common.frame_to_show; |
334 ret = 0; | 326 ret = 0; |
335 #endif /*!CONFIG_POSTPROC*/ | 327 #endif /*!CONFIG_POSTPROC*/ |
336 vp9_clear_system_state(); | 328 vp9_clear_system_state(); |
337 return ret; | 329 return ret; |
338 } | 330 } |
OLD | NEW |