| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 vp9_get_worker_interface()->init(&pbi->lf_worker); | 79 vp9_get_worker_interface()->init(&pbi->lf_worker); |
| 80 | 80 |
| 81 return pbi; | 81 return pbi; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void vp9_decoder_remove(VP9Decoder *pbi) { | 84 void vp9_decoder_remove(VP9Decoder *pbi) { |
| 85 VP9_COMMON *const cm = &pbi->common; | 85 VP9_COMMON *const cm = &pbi->common; |
| 86 int i; | 86 int i; |
| 87 | 87 |
| 88 vp9_remove_common(cm); | |
| 89 vp9_get_worker_interface()->end(&pbi->lf_worker); | 88 vp9_get_worker_interface()->end(&pbi->lf_worker); |
| 90 vpx_free(pbi->lf_worker.data1); | 89 vpx_free(pbi->lf_worker.data1); |
| 91 vpx_free(pbi->tile_data); | 90 vpx_free(pbi->tile_data); |
| 92 for (i = 0; i < pbi->num_tile_workers; ++i) { | 91 for (i = 0; i < pbi->num_tile_workers; ++i) { |
| 93 VP9Worker *const worker = &pbi->tile_workers[i]; | 92 VP9Worker *const worker = &pbi->tile_workers[i]; |
| 94 vp9_get_worker_interface()->end(worker); | 93 vp9_get_worker_interface()->end(worker); |
| 95 vpx_free(worker->data1); | 94 vpx_free(worker->data1); |
| 96 vpx_free(worker->data2); | 95 vpx_free(worker->data2); |
| 97 } | 96 } |
| 98 vpx_free(pbi->tile_workers); | 97 vpx_free(pbi->tile_workers); |
| 99 | 98 |
| 100 if (pbi->num_tile_workers) { | 99 if (pbi->num_tile_workers) { |
| 101 const int sb_rows = | 100 const int sb_rows = |
| 102 mi_cols_aligned_to_sb(cm->mi_rows) >> MI_BLOCK_SIZE_LOG2; | 101 mi_cols_aligned_to_sb(cm->mi_rows) >> MI_BLOCK_SIZE_LOG2; |
| 103 vp9_loop_filter_dealloc(&pbi->lf_row_sync, sb_rows); | 102 vp9_loop_filter_dealloc(&pbi->lf_row_sync, sb_rows); |
| 104 } | 103 } |
| 105 | 104 |
| 105 vp9_remove_common(cm); |
| 106 vpx_free(pbi); | 106 vpx_free(pbi); |
| 107 } | 107 } |
| 108 | 108 |
| 109 static int equal_dimensions(const YV12_BUFFER_CONFIG *a, | 109 static int equal_dimensions(const YV12_BUFFER_CONFIG *a, |
| 110 const YV12_BUFFER_CONFIG *b) { | 110 const YV12_BUFFER_CONFIG *b) { |
| 111 return a->y_height == b->y_height && a->y_width == b->y_width && | 111 return a->y_height == b->y_height && a->y_width == b->y_width && |
| 112 a->uv_height == b->uv_height && a->uv_width == b->uv_width; | 112 a->uv_height == b->uv_height && a->uv_width == b->uv_width; |
| 113 } | 113 } |
| 114 | 114 |
| 115 vpx_codec_err_t vp9_copy_reference_dec(VP9Decoder *pbi, | 115 vpx_codec_err_t vp9_copy_reference_dec(VP9Decoder *pbi, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 239 } |
| 240 | 240 |
| 241 // Check if the previous frame was a frame without any references to it. | 241 // Check if the previous frame was a frame without any references to it. |
| 242 if (cm->new_fb_idx >= 0 && cm->frame_bufs[cm->new_fb_idx].ref_count == 0) | 242 if (cm->new_fb_idx >= 0 && cm->frame_bufs[cm->new_fb_idx].ref_count == 0) |
| 243 cm->release_fb_cb(cm->cb_priv, | 243 cm->release_fb_cb(cm->cb_priv, |
| 244 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer); | 244 &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer); |
| 245 cm->new_fb_idx = get_free_fb(cm); | 245 cm->new_fb_idx = get_free_fb(cm); |
| 246 | 246 |
| 247 if (setjmp(cm->error.jmp)) { | 247 if (setjmp(cm->error.jmp)) { |
| 248 cm->error.setjmp = 0; | 248 cm->error.setjmp = 0; |
| 249 vp9_clear_system_state(); |
| 249 | 250 |
| 250 // We do not know if the missing frame(s) was supposed to update | 251 // We do not know if the missing frame(s) was supposed to update |
| 251 // any of the reference buffers, but we act conservative and | 252 // any of the reference buffers, but we act conservative and |
| 252 // mark only the last buffer as corrupted. | 253 // mark only the last buffer as corrupted. |
| 253 // | 254 // |
| 254 // TODO(jkoleszar): Error concealment is undefined and non-normative | 255 // TODO(jkoleszar): Error concealment is undefined and non-normative |
| 255 // at this point, but if it becomes so, [0] may not always be the correct | 256 // at this point, but if it becomes so, [0] may not always be the correct |
| 256 // thing to do here. | 257 // thing to do here. |
| 257 if (cm->frame_refs[0].idx != INT_MAX && cm->frame_refs[0].buf != NULL) | 258 if (cm->frame_refs[0].idx != INT_MAX && cm->frame_refs[0].buf != NULL) |
| 258 cm->frame_refs[0].buf->corrupted = 1; | 259 cm->frame_refs[0].buf->corrupted = 1; |
| 259 | 260 |
| 260 if (cm->new_fb_idx > 0 && cm->frame_bufs[cm->new_fb_idx].ref_count > 0) | 261 if (cm->new_fb_idx > 0 && cm->frame_bufs[cm->new_fb_idx].ref_count > 0) |
| 261 cm->frame_bufs[cm->new_fb_idx].ref_count--; | 262 cm->frame_bufs[cm->new_fb_idx].ref_count--; |
| 262 | 263 |
| 263 return -1; | 264 return -1; |
| 264 } | 265 } |
| 265 | 266 |
| 266 cm->error.setjmp = 1; | 267 cm->error.setjmp = 1; |
| 267 | 268 |
| 268 vp9_decode_frame(pbi, source, source + size, psource); | 269 vp9_decode_frame(pbi, source, source + size, psource); |
| 269 | 270 |
| 270 swap_frame_buffers(pbi); | 271 if (!cm->show_existing_frame) |
| 272 swap_frame_buffers(pbi); |
| 273 else |
| 274 cm->frame_to_show = get_frame_new_buffer(cm); |
| 271 | 275 |
| 272 vp9_clear_system_state(); | 276 vp9_clear_system_state(); |
| 273 | 277 |
| 274 cm->last_width = cm->width; | 278 cm->last_width = cm->width; |
| 275 cm->last_height = cm->height; | 279 cm->last_height = cm->height; |
| 276 | 280 |
| 277 if (!cm->show_existing_frame) | 281 if (!cm->show_existing_frame) |
| 278 cm->last_show_frame = cm->show_frame; | 282 cm->last_show_frame = cm->show_frame; |
| 279 if (cm->show_frame) { | 283 if (cm->show_frame) { |
| 280 if (!cm->show_existing_frame) | 284 if (!cm->show_existing_frame) |
| 281 vp9_swap_mi_and_prev_mi(cm); | 285 vp9_swap_mi_and_prev_mi(cm); |
| 282 | 286 |
| 283 cm->current_video_frame++; | 287 cm->current_video_frame++; |
| 284 } | 288 } |
| 285 | 289 |
| 286 pbi->ready_for_new_data = 0; | 290 pbi->ready_for_new_data = 0; |
| 287 | 291 |
| 288 cm->error.setjmp = 0; | 292 cm->error.setjmp = 0; |
| 289 return retcode; | 293 return retcode; |
| 290 } | 294 } |
| 291 | 295 |
| 292 int vp9_get_raw_frame(VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd, | 296 int vp9_get_raw_frame(VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd, |
| 293 vp9_ppflags_t *flags) { | 297 vp9_ppflags_t *flags) { |
| 298 VP9_COMMON *const cm = &pbi->common; |
| 294 int ret = -1; | 299 int ret = -1; |
| 295 #if !CONFIG_VP9_POSTPROC | 300 #if !CONFIG_VP9_POSTPROC |
| 296 (void)*flags; | 301 (void)*flags; |
| 297 #endif | 302 #endif |
| 298 | 303 |
| 299 if (pbi->ready_for_new_data == 1) | 304 if (pbi->ready_for_new_data == 1) |
| 300 return ret; | 305 return ret; |
| 301 | 306 |
| 302 /* no raw frame to show!!! */ | 307 /* no raw frame to show!!! */ |
| 303 if (pbi->common.show_frame == 0) | 308 if (!cm->show_frame) |
| 304 return ret; | 309 return ret; |
| 305 | 310 |
| 306 pbi->ready_for_new_data = 1; | 311 pbi->ready_for_new_data = 1; |
| 307 | 312 |
| 308 #if CONFIG_VP9_POSTPROC | 313 #if CONFIG_VP9_POSTPROC |
| 309 ret = vp9_post_proc_frame(&pbi->common, sd, flags); | 314 if (!cm->show_existing_frame) { |
| 315 ret = vp9_post_proc_frame(cm, sd, flags); |
| 316 } else { |
| 317 *sd = *cm->frame_to_show; |
| 318 ret = 0; |
| 319 } |
| 310 #else | 320 #else |
| 311 *sd = *pbi->common.frame_to_show; | 321 *sd = *cm->frame_to_show; |
| 312 ret = 0; | 322 ret = 0; |
| 313 #endif /*!CONFIG_POSTPROC*/ | 323 #endif /*!CONFIG_POSTPROC*/ |
| 314 vp9_clear_system_state(); | 324 vp9_clear_system_state(); |
| 315 return ret; | 325 return ret; |
| 316 } | 326 } |
| OLD | NEW |