| Index: source/libvpx/vp9/decoder/vp9_onyxd_if.c
|
| ===================================================================
|
| --- source/libvpx/vp9/decoder/vp9_onyxd_if.c (revision 219822)
|
| +++ source/libvpx/vp9/decoder/vp9_onyxd_if.c (working copy)
|
| @@ -8,9 +8,9 @@
|
| * be found in the AUTHORS file in the root of the source tree.
|
| */
|
|
|
| -
|
| +#include <assert.h>
|
| +#include <limits.h>
|
| #include <stdio.h>
|
| -#include <assert.h>
|
|
|
| #include "vp9/common/vp9_onyxc_int.h"
|
| #if CONFIG_POSTPROC
|
| @@ -110,37 +110,48 @@
|
|
|
| VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf) {
|
| VP9D_COMP *const pbi = vpx_memalign(32, sizeof(VP9D_COMP));
|
| + VP9_COMMON *const cm = pbi ? &pbi->common : NULL;
|
|
|
| - if (!pbi)
|
| + if (!cm)
|
| return NULL;
|
|
|
| - vpx_memset(pbi, 0, sizeof(VP9D_COMP));
|
| + vp9_zero(*pbi);
|
|
|
| - if (setjmp(pbi->common.error.jmp)) {
|
| - pbi->common.error.setjmp = 0;
|
| + if (setjmp(cm->error.jmp)) {
|
| + cm->error.setjmp = 0;
|
| vp9_remove_decompressor(pbi);
|
| return NULL;
|
| }
|
|
|
| - pbi->common.error.setjmp = 1;
|
| + cm->error.setjmp = 1;
|
| vp9_initialize_dec();
|
|
|
| - vp9_create_common(&pbi->common);
|
| + vp9_create_common(cm);
|
|
|
| pbi->oxcf = *oxcf;
|
| - pbi->common.current_video_frame = 0;
|
| pbi->ready_for_new_data = 1;
|
| + cm->current_video_frame = 0;
|
|
|
| // vp9_init_dequantizer() is first called here. Add check in
|
| // frame_init_dequantizer() to avoid unnecessary calling of
|
| // vp9_init_dequantizer() for every frame.
|
| - vp9_init_dequantizer(&pbi->common);
|
| + vp9_init_dequantizer(cm);
|
|
|
| - vp9_loop_filter_init(&pbi->common, &pbi->mb.lf);
|
| + vp9_loop_filter_init(cm);
|
|
|
| - pbi->common.error.setjmp = 0;
|
| + cm->error.setjmp = 0;
|
| pbi->decoded_key_frame = 0;
|
|
|
| + if (pbi->oxcf.max_threads > 1) {
|
| + vp9_worker_init(&pbi->lf_worker);
|
| + pbi->lf_worker.data1 = vpx_malloc(sizeof(LFWorkerData));
|
| + pbi->lf_worker.hook = (VP9WorkerHook)vp9_loop_filter_worker;
|
| + if (pbi->lf_worker.data1 == NULL || !vp9_worker_reset(&pbi->lf_worker)) {
|
| + vp9_remove_decompressor(pbi);
|
| + return NULL;
|
| + }
|
| + }
|
| +
|
| return pbi;
|
| }
|
|
|
| @@ -150,10 +161,9 @@
|
| if (!pbi)
|
| return;
|
|
|
| - if (pbi->common.last_frame_seg_map)
|
| - vpx_free(pbi->common.last_frame_seg_map);
|
| -
|
| vp9_remove_common(&pbi->common);
|
| + vp9_worker_end(&pbi->lf_worker);
|
| + vpx_free(pbi->lf_worker.data1);
|
| vpx_free(pbi);
|
| }
|
|
|
| @@ -175,21 +185,21 @@
|
| * later commit that adds VP9-specific controls for this functionality.
|
| */
|
| if (ref_frame_flag == VP9_LAST_FLAG) {
|
| - ref_fb_idx = pbi->common.ref_frame_map[0];
|
| + ref_fb_idx = cm->ref_frame_map[0];
|
| } else {
|
| - vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
|
| + vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
| "Invalid reference frame");
|
| - return pbi->common.error.error_code;
|
| + return cm->error.error_code;
|
| }
|
|
|
| if (!equal_dimensions(&cm->yv12_fb[ref_fb_idx], sd)) {
|
| - vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
|
| + vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
| "Incorrect buffer dimensions");
|
| } else {
|
| vp8_yv12_copy_frame(&cm->yv12_fb[ref_fb_idx], sd);
|
| }
|
|
|
| - return pbi->common.error.error_code;
|
| + return cm->error.error_code;
|
| }
|
|
|
|
|
| @@ -249,22 +259,21 @@
|
| /* If any buffer updating is signaled it should be done here. */
|
| static void swap_frame_buffers(VP9D_COMP *pbi) {
|
| int ref_index = 0, mask;
|
| + VP9_COMMON *const cm = &pbi->common;
|
|
|
| for (mask = pbi->refresh_frame_flags; mask; mask >>= 1) {
|
| - if (mask & 1) {
|
| - ref_cnt_fb(pbi->common.fb_idx_ref_cnt,
|
| - &pbi->common.ref_frame_map[ref_index],
|
| - pbi->common.new_fb_idx);
|
| - }
|
| + if (mask & 1)
|
| + ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->ref_frame_map[ref_index],
|
| + cm->new_fb_idx);
|
| ++ref_index;
|
| }
|
|
|
| - pbi->common.frame_to_show = &pbi->common.yv12_fb[pbi->common.new_fb_idx];
|
| - pbi->common.fb_idx_ref_cnt[pbi->common.new_fb_idx]--;
|
| + cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
|
| + cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
|
|
|
| - /* Invalidate these references until the next frame starts. */
|
| + // Invalidate these references until the next frame starts.
|
| for (ref_index = 0; ref_index < 3; ref_index++)
|
| - pbi->common.active_ref_idx[ref_index] = INT_MAX;
|
| + cm->active_ref_idx[ref_index] = INT_MAX;
|
| }
|
|
|
| int vp9_receive_compressed_data(VP9D_PTR ptr,
|
| @@ -281,7 +290,7 @@
|
| if (ptr == 0)
|
| return -1;
|
|
|
| - pbi->common.error.error_code = VPX_CODEC_OK;
|
| + cm->error.error_code = VPX_CODEC_OK;
|
|
|
| pbi->source = source;
|
| pbi->source_sz = size;
|
| @@ -302,8 +311,8 @@
|
|
|
| cm->new_fb_idx = get_free_fb(cm);
|
|
|
| - if (setjmp(pbi->common.error.jmp)) {
|
| - pbi->common.error.setjmp = 0;
|
| + if (setjmp(cm->error.jmp)) {
|
| + cm->error.setjmp = 0;
|
|
|
| /* We do not know if the missing frame(s) was supposed to update
|
| * any of the reference buffers, but we act conservative and
|
| @@ -322,13 +331,13 @@
|
| return -1;
|
| }
|
|
|
| - pbi->common.error.setjmp = 1;
|
| + cm->error.setjmp = 1;
|
|
|
| retcode = vp9_decode_frame(pbi, psource);
|
|
|
| if (retcode < 0) {
|
| - pbi->common.error.error_code = VPX_CODEC_ERROR;
|
| - pbi->common.error.setjmp = 0;
|
| + cm->error.error_code = VPX_CODEC_ERROR;
|
| + cm->error.setjmp = 0;
|
| if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
|
| cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
|
| return retcode;
|
| @@ -348,7 +357,7 @@
|
|
|
| if (!pbi->do_loopfilter_inline) {
|
| /* Apply the loop filter if appropriate. */
|
| - vp9_loop_filter_frame(cm, &pbi->mb, pbi->mb.lf.filter_level, 0);
|
| + vp9_loop_filter_frame(cm, &pbi->mb, pbi->common.lf.filter_level, 0, 0);
|
| }
|
|
|
| #if WRITE_RECON_BUFFER == 2
|
| @@ -391,7 +400,7 @@
|
| pbi->last_time_stamp = time_stamp;
|
| pbi->source_sz = 0;
|
|
|
| - pbi->common.error.setjmp = 0;
|
| + cm->error.setjmp = 0;
|
| return retcode;
|
| }
|
|
|
| @@ -413,7 +422,7 @@
|
| *time_end_stamp = 0;
|
|
|
| #if CONFIG_POSTPROC
|
| - ret = vp9_post_proc_frame(&pbi->common, &pbi->mb.lf, sd, flags);
|
| + ret = vp9_post_proc_frame(&pbi->common, sd, flags);
|
| #else
|
|
|
| if (pbi->common.frame_to_show) {
|
|
|