2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-09 17:29:20 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-09 17:29:20 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
New RTCD implementation
This is a proof of concept RTCD implementation to replace the current
system of nested includes, prototypes, INVOKE macros, etc. Currently
only the decoder specific functions are implemented in the new system.
Additional functions will be added in subsequent commits.
Overview:
RTCD "functions" are implemented as either a global function pointer
or a macro (when only one eligible specialization available).
Functions which have RTCD specializations are listed using a simple
DSL identifying the function's base name, its prototype, and the
architecture extensions that specializations are available for.
Advantages over the old system:
- No INVOKE macros. A call to an RTCD function looks like an ordinary
function call.
- No need to pass vtables around.
- If there is only one eligible function to call, the function is
called directly, rather than indirecting through a function pointer.
- Supports the notion of "required" extensions, so in combination with
the above, on x86_64 if the best function available is sse2 or lower
it will be called directly, since all x86_64 platforms implement
sse2.
- Elides all references to functions which will never be called, which
could reduce binary size. For example if sse2 is required and there
are both mmx and sse2 implementations of a certain function, the
code will have no link time references to the mmx code.
- Significantly easier to add a new function, just one file to edit.
Disadvantages:
- Requires global writable data (though this is not a new requirement)
- 1 new generated source file.
Change-Id: Iae6edab65315f79c168485c96872641c5aa09d55
2011-08-19 20:06:00 +02:00
|
|
|
#include "vpx_config.h"
|
|
|
|
#include "vpx_rtcd.h"
|
2011-01-24 10:21:40 +01:00
|
|
|
#if !defined(WIN32) && CONFIG_OS_SUPPORT == 1
|
2010-05-18 17:58:33 +02:00
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include "onyxd_int.h"
|
|
|
|
#include "vpx_mem/vpx_mem.h"
|
2011-02-10 20:41:38 +01:00
|
|
|
#include "vp8/common/threading.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-02-10 20:41:38 +01:00
|
|
|
#include "vp8/common/loopfilter.h"
|
|
|
|
#include "vp8/common/extend.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_ports/vpx_timer.h"
|
2010-09-16 20:08:52 +02:00
|
|
|
#include "detokenize.h"
|
2012-02-28 20:12:30 +01:00
|
|
|
#include "vp8/common/reconintra4x4.h"
|
2011-02-10 20:41:38 +01:00
|
|
|
#include "vp8/common/reconinter.h"
|
2011-06-16 11:44:50 +02:00
|
|
|
#if CONFIG_ERROR_CONCEALMENT
|
|
|
|
#include "error_concealment.h"
|
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
extern void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-03-17 22:07:59 +01:00
|
|
|
static void setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd, MB_ROW_DEC *mbrd, int count)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
VP8_COMMON *const pc = & pbi->common;
|
2012-01-04 17:56:50 +01:00
|
|
|
int i;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
MACROBLOCKD *mbd = &mbrd[i].mbd;
|
|
|
|
mbd->subpixel_predict = xd->subpixel_predict;
|
|
|
|
mbd->subpixel_predict8x4 = xd->subpixel_predict8x4;
|
|
|
|
mbd->subpixel_predict8x8 = xd->subpixel_predict8x8;
|
|
|
|
mbd->subpixel_predict16x16 = xd->subpixel_predict16x16;
|
|
|
|
|
|
|
|
mbd->mode_info_context = pc->mi + pc->mode_info_stride * (i + 1);
|
|
|
|
mbd->mode_info_stride = pc->mode_info_stride;
|
|
|
|
|
|
|
|
mbd->frame_type = pc->frame_type;
|
2010-07-22 14:07:32 +02:00
|
|
|
mbd->pre = pc->yv12_fb[pc->lst_fb_idx];
|
|
|
|
mbd->dst = pc->yv12_fb[pc->new_fb_idx];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
mbd->segmentation_enabled = xd->segmentation_enabled;
|
|
|
|
mbd->mb_segement_abs_delta = xd->mb_segement_abs_delta;
|
|
|
|
vpx_memcpy(mbd->segment_feature_data, xd->segment_feature_data, sizeof(xd->segment_feature_data));
|
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/*signed char ref_lf_deltas[MAX_REF_LF_DELTAS];*/
|
2010-09-16 20:08:52 +02:00
|
|
|
vpx_memcpy(mbd->ref_lf_deltas, xd->ref_lf_deltas, sizeof(xd->ref_lf_deltas));
|
2010-10-28 01:04:02 +02:00
|
|
|
/*signed char mode_lf_deltas[MAX_MODE_LF_DELTAS];*/
|
2010-09-16 20:08:52 +02:00
|
|
|
vpx_memcpy(mbd->mode_lf_deltas, xd->mode_lf_deltas, sizeof(xd->mode_lf_deltas));
|
2010-10-28 01:04:02 +02:00
|
|
|
/*unsigned char mode_ref_lf_delta_enabled;
|
|
|
|
unsigned char mode_ref_lf_delta_update;*/
|
2010-09-16 20:08:52 +02:00
|
|
|
mbd->mode_ref_lf_delta_enabled = xd->mode_ref_lf_delta_enabled;
|
|
|
|
mbd->mode_ref_lf_delta_update = xd->mode_ref_lf_delta_update;
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
mbd->current_bc = &pbi->bc2;
|
|
|
|
|
2012-01-04 17:56:50 +01:00
|
|
|
vpx_memcpy(mbd->dequant_y1_dc, xd->dequant_y1_dc, sizeof(xd->dequant_y1_dc));
|
|
|
|
vpx_memcpy(mbd->dequant_y1, xd->dequant_y1, sizeof(xd->dequant_y1));
|
|
|
|
vpx_memcpy(mbd->dequant_y2, xd->dequant_y2, sizeof(xd->dequant_y2));
|
|
|
|
vpx_memcpy(mbd->dequant_uv, xd->dequant_uv, sizeof(xd->dequant_uv));
|
2011-08-24 20:42:26 +02:00
|
|
|
|
|
|
|
mbd->fullpixel_mask = 0xffffffff;
|
2012-04-20 13:14:24 +02:00
|
|
|
|
|
|
|
if (pc->full_pixel)
|
2011-08-24 20:42:26 +02:00
|
|
|
mbd->fullpixel_mask = 0xfffffff8;
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-04-20 13:14:24 +02:00
|
|
|
for (i = 0; i < pc->mb_rows; i++)
|
|
|
|
pbi->mt_current_mb_col[i] = -1;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-04-20 13:14:24 +02:00
|
|
|
static void mt_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
|
|
|
|
unsigned int mb_idx)
|
2010-07-29 22:24:26 +02:00
|
|
|
{
|
2012-03-08 21:27:41 +01:00
|
|
|
MB_PREDICTION_MODE mode;
|
2011-09-16 17:03:53 +02:00
|
|
|
int i;
|
2012-03-08 21:27:41 +01:00
|
|
|
#if CONFIG_ERROR_CONCEALMENT
|
|
|
|
int corruption_detected = 0;
|
|
|
|
#endif
|
2010-07-29 22:24:26 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
if (xd->mode_info_context->mbmi.mb_skip_coeff)
|
2010-07-29 22:24:26 +02:00
|
|
|
{
|
2010-09-16 20:08:52 +02:00
|
|
|
vp8_reset_mb_tokens_context(xd);
|
|
|
|
}
|
2011-09-06 14:34:36 +02:00
|
|
|
else if (!vp8dx_bool_error(xd->current_bc))
|
2010-09-16 20:08:52 +02:00
|
|
|
{
|
2012-02-21 20:59:05 +01:00
|
|
|
int eobtotal;
|
2010-09-16 20:08:52 +02:00
|
|
|
eobtotal = vp8_decode_mb_tokens(pbi, xd);
|
2011-04-26 15:37:19 +02:00
|
|
|
|
2012-02-21 20:59:05 +01:00
|
|
|
/* Special case: Force the loopfilter to skip when eobtotal is zero */
|
|
|
|
xd->mode_info_context->mbmi.mb_skip_coeff = (eobtotal==0);
|
2010-09-16 20:08:52 +02:00
|
|
|
}
|
2010-07-29 22:24:26 +02:00
|
|
|
|
2012-03-08 21:27:41 +01:00
|
|
|
mode = xd->mode_info_context->mbmi.mode;
|
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
if (xd->segmentation_enabled)
|
|
|
|
mb_init_dequantizer(pbi, xd);
|
2010-07-29 22:24:26 +02:00
|
|
|
|
2012-03-08 21:27:41 +01:00
|
|
|
|
|
|
|
#if CONFIG_ERROR_CONCEALMENT
|
|
|
|
|
|
|
|
if(pbi->ec_active)
|
2010-09-16 20:08:52 +02:00
|
|
|
{
|
2012-03-08 21:27:41 +01:00
|
|
|
int throw_residual;
|
|
|
|
/* When we have independent partitions we can apply residual even
|
|
|
|
* though other partitions within the frame are corrupt.
|
|
|
|
*/
|
|
|
|
throw_residual = (!pbi->independent_partitions &&
|
|
|
|
pbi->frame_corrupt_residual);
|
|
|
|
throw_residual = (throw_residual || vp8dx_bool_error(xd->current_bc));
|
|
|
|
|
|
|
|
if ((mb_idx >= pbi->mvs_corrupt_from_mb || throw_residual))
|
2012-02-21 20:59:05 +01:00
|
|
|
{
|
2012-03-08 21:27:41 +01:00
|
|
|
/* MB with corrupt residuals or corrupt mode/motion vectors.
|
|
|
|
* Better to use the predictor as reconstruction.
|
|
|
|
*/
|
|
|
|
pbi->frame_corrupt_residual = 1;
|
|
|
|
vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff));
|
|
|
|
vp8_conceal_corrupt_mb(xd);
|
2010-09-16 20:08:52 +02:00
|
|
|
|
2012-02-28 20:12:30 +01:00
|
|
|
|
2012-03-08 21:27:41 +01:00
|
|
|
corruption_detected = 1;
|
|
|
|
|
|
|
|
/* force idct to be skipped for B_PRED and use the
|
|
|
|
* prediction only for reconstruction
|
|
|
|
* */
|
|
|
|
vpx_memset(xd->eobs, 0, 25);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* do prediction */
|
|
|
|
if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME)
|
|
|
|
{
|
|
|
|
vp8_build_intra_predictors_mbuv_s(xd,
|
|
|
|
xd->recon_above[1],
|
|
|
|
xd->recon_above[2],
|
|
|
|
xd->recon_left[1],
|
|
|
|
xd->recon_left[2],
|
|
|
|
xd->recon_left_stride[1],
|
2012-03-20 20:11:42 +01:00
|
|
|
xd->dst.u_buffer, xd->dst.v_buffer,
|
|
|
|
xd->dst.uv_stride);
|
2012-03-08 21:27:41 +01:00
|
|
|
|
|
|
|
if (mode != B_PRED)
|
|
|
|
{
|
|
|
|
vp8_build_intra_predictors_mby_s(xd,
|
|
|
|
xd->recon_above[0],
|
|
|
|
xd->recon_left[0],
|
|
|
|
xd->recon_left_stride[0],
|
2012-03-20 20:11:42 +01:00
|
|
|
xd->dst.y_buffer,
|
|
|
|
xd->dst.y_stride);
|
2012-02-21 20:59:05 +01:00
|
|
|
}
|
|
|
|
else
|
2010-09-16 20:08:52 +02:00
|
|
|
{
|
2012-03-08 21:27:41 +01:00
|
|
|
short *DQC = xd->dequant_y1;
|
|
|
|
int dst_stride = xd->dst.y_stride;
|
|
|
|
unsigned char *base_dst = xd->dst.y_buffer;
|
|
|
|
|
|
|
|
/* clear out residual eob info */
|
|
|
|
if(xd->mode_info_context->mbmi.mb_skip_coeff)
|
|
|
|
vpx_memset(xd->eobs, 0, 25);
|
|
|
|
|
|
|
|
intra_prediction_down_copy(xd, xd->recon_above[0] + 16);
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++)
|
2012-02-28 20:12:30 +01:00
|
|
|
{
|
2012-03-08 21:27:41 +01:00
|
|
|
BLOCKD *b = &xd->block[i];
|
|
|
|
int b_mode = xd->mode_info_context->bmi[i].as_mode;
|
|
|
|
unsigned char *yabove;
|
|
|
|
unsigned char *yleft;
|
|
|
|
int left_stride;
|
|
|
|
unsigned char top_left;
|
|
|
|
|
|
|
|
/*Caution: For some b_mode, it needs 8 pixels (4 above + 4 above-right).*/
|
|
|
|
if (i < 4 && pbi->common.filter_level)
|
|
|
|
yabove = xd->recon_above[0] + b->offset; //i*4;
|
|
|
|
else
|
|
|
|
yabove = (base_dst - dst_stride) + b->offset;
|
|
|
|
|
|
|
|
if (i%4==0 && pbi->common.filter_level)
|
|
|
|
{
|
|
|
|
yleft = xd->recon_left[0] + i;
|
|
|
|
left_stride = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yleft = (base_dst - 1) + b->offset;
|
|
|
|
left_stride = dst_stride;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((i==4 || i==8 || i==12) && pbi->common.filter_level)
|
|
|
|
top_left = *(xd->recon_left[0] + i - 1);
|
|
|
|
else
|
|
|
|
top_left = yabove[-1];
|
|
|
|
|
|
|
|
vp8_intra4x4_predict_d_c(yabove, yleft, left_stride,
|
|
|
|
b_mode,
|
|
|
|
base_dst + b->offset, dst_stride,
|
|
|
|
top_left);
|
|
|
|
|
|
|
|
if (xd->eobs[i] )
|
|
|
|
{
|
|
|
|
if (xd->eobs[i] > 1)
|
|
|
|
{
|
|
|
|
vp8_dequant_idct_add
|
|
|
|
(b->qcoeff, DQC,
|
|
|
|
base_dst + b->offset, dst_stride);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vp8_dc_only_idct_add
|
|
|
|
(b->qcoeff[0] * DQC[0],
|
|
|
|
base_dst + b->offset, dst_stride,
|
|
|
|
base_dst + b->offset, dst_stride);
|
|
|
|
((int *)b->qcoeff)[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
2012-02-28 20:12:30 +01:00
|
|
|
}
|
2010-09-16 20:08:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vp8_build_inter_predictors_mb(xd);
|
|
|
|
}
|
2010-07-29 22:24:26 +02:00
|
|
|
|
2011-08-08 10:56:20 +02:00
|
|
|
|
2011-06-16 11:44:50 +02:00
|
|
|
#if CONFIG_ERROR_CONCEALMENT
|
2012-03-08 21:27:41 +01:00
|
|
|
if (corruption_detected)
|
2011-06-16 11:44:50 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-08 21:27:41 +01:00
|
|
|
if(!xd->mode_info_context->mbmi.mb_skip_coeff)
|
2010-09-16 20:08:52 +02:00
|
|
|
{
|
2012-03-08 21:27:41 +01:00
|
|
|
/* dequantization and idct */
|
|
|
|
if (mode != B_PRED)
|
2010-09-16 20:08:52 +02:00
|
|
|
{
|
2012-03-08 21:27:41 +01:00
|
|
|
short *DQC = xd->dequant_y1;
|
2011-06-02 19:46:41 +02:00
|
|
|
|
2012-03-08 21:27:41 +01:00
|
|
|
if (mode != SPLITMV)
|
2011-11-17 18:54:42 +01:00
|
|
|
{
|
2012-03-08 21:27:41 +01:00
|
|
|
BLOCKD *b = &xd->block[24];
|
|
|
|
|
|
|
|
/* do 2nd order transform on the dc block */
|
|
|
|
if (xd->eobs[24] > 1)
|
2011-11-17 18:54:42 +01:00
|
|
|
{
|
2012-03-08 21:27:41 +01:00
|
|
|
vp8_dequantize_b(b, xd->dequant_y2);
|
|
|
|
|
|
|
|
vp8_short_inv_walsh4x4(&b->dqcoeff[0],
|
|
|
|
xd->qcoeff);
|
|
|
|
((int *)b->qcoeff)[0] = 0;
|
|
|
|
((int *)b->qcoeff)[1] = 0;
|
|
|
|
((int *)b->qcoeff)[2] = 0;
|
|
|
|
((int *)b->qcoeff)[3] = 0;
|
|
|
|
((int *)b->qcoeff)[4] = 0;
|
|
|
|
((int *)b->qcoeff)[5] = 0;
|
|
|
|
((int *)b->qcoeff)[6] = 0;
|
|
|
|
((int *)b->qcoeff)[7] = 0;
|
2011-11-17 18:54:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-08 21:27:41 +01:00
|
|
|
b->dqcoeff[0] = b->qcoeff[0] * xd->dequant_y2[0];
|
|
|
|
vp8_short_inv_walsh4x4_1(&b->dqcoeff[0],
|
|
|
|
xd->qcoeff);
|
2011-11-17 18:54:42 +01:00
|
|
|
((int *)b->qcoeff)[0] = 0;
|
|
|
|
}
|
|
|
|
|
2012-03-08 21:27:41 +01:00
|
|
|
/* override the dc dequant constant in order to preserve the
|
|
|
|
* dc components
|
|
|
|
*/
|
|
|
|
DQC = xd->dequant_y1_dc;
|
2010-09-16 20:08:52 +02:00
|
|
|
}
|
2011-11-17 18:54:42 +01:00
|
|
|
|
2012-03-08 21:27:41 +01:00
|
|
|
vp8_dequant_idct_add_y_block
|
|
|
|
(xd->qcoeff, DQC,
|
|
|
|
xd->dst.y_buffer,
|
|
|
|
xd->dst.y_stride, xd->eobs);
|
2010-09-16 20:08:52 +02:00
|
|
|
}
|
2011-11-17 18:54:42 +01:00
|
|
|
|
2012-03-08 21:27:41 +01:00
|
|
|
vp8_dequant_idct_add_uv_block
|
|
|
|
(xd->qcoeff+16*16, xd->dequant_uv,
|
|
|
|
xd->dst.u_buffer, xd->dst.v_buffer,
|
|
|
|
xd->dst.uv_stride, xd->eobs+16);
|
2010-09-16 20:08:52 +02:00
|
|
|
}
|
2010-07-29 22:24:26 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-04-20 13:14:24 +02:00
|
|
|
static void mt_decode_mb_rows(VP8D_COMP *pbi, MACROBLOCKD *xd, int start_mb_row)
|
2012-02-28 20:00:32 +01:00
|
|
|
{
|
2012-04-20 13:14:24 +02:00
|
|
|
volatile const int *last_row_current_mb_col;
|
|
|
|
volatile int *current_mb_col;
|
2012-02-28 20:00:32 +01:00
|
|
|
int mb_row;
|
|
|
|
VP8_COMMON *pc = &pbi->common;
|
2012-04-20 13:14:24 +02:00
|
|
|
const int nsync = pbi->sync_range;
|
|
|
|
const int first_row_no_sync_above = pc->mb_cols + nsync;
|
2012-02-28 20:00:32 +01:00
|
|
|
int num_part = 1 << pbi->common.multi_token_partition;
|
2012-04-20 13:14:24 +02:00
|
|
|
int last_mb_row = start_mb_row;
|
2012-02-28 20:00:32 +01:00
|
|
|
|
2012-02-29 16:38:14 +01:00
|
|
|
int dst_fb_idx = pc->new_fb_idx;
|
|
|
|
unsigned char *ref_buffer[MAX_REF_FRAMES][3];
|
|
|
|
unsigned char *dst_buffer[3];
|
|
|
|
int i;
|
|
|
|
int ref_fb_index[MAX_REF_FRAMES];
|
|
|
|
int ref_fb_corrupted[MAX_REF_FRAMES];
|
|
|
|
|
|
|
|
ref_fb_corrupted[INTRA_FRAME] = 0;
|
|
|
|
|
|
|
|
ref_fb_index[LAST_FRAME] = pc->lst_fb_idx;
|
|
|
|
ref_fb_index[GOLDEN_FRAME] = pc->gld_fb_idx;
|
|
|
|
ref_fb_index[ALTREF_FRAME] = pc->alt_fb_idx;
|
|
|
|
|
|
|
|
for(i = 1; i < MAX_REF_FRAMES; i++)
|
|
|
|
{
|
|
|
|
ref_buffer[i][0] = pc->yv12_fb[ref_fb_index[i]].y_buffer;
|
|
|
|
ref_buffer[i][1] = pc->yv12_fb[ref_fb_index[i]].u_buffer;
|
|
|
|
ref_buffer[i][2] = pc->yv12_fb[ref_fb_index[i]].v_buffer;
|
|
|
|
|
|
|
|
ref_fb_corrupted[i] = pc->yv12_fb[ref_fb_index[i]].corrupted;
|
|
|
|
}
|
|
|
|
|
|
|
|
dst_buffer[0] = pc->yv12_fb[dst_fb_idx].y_buffer;
|
|
|
|
dst_buffer[1] = pc->yv12_fb[dst_fb_idx].u_buffer;
|
|
|
|
dst_buffer[2] = pc->yv12_fb[dst_fb_idx].v_buffer;
|
|
|
|
|
|
|
|
xd->up_available = (start_mb_row != 0);
|
2012-02-28 20:00:32 +01:00
|
|
|
|
|
|
|
for (mb_row = start_mb_row; mb_row < pc->mb_rows; mb_row += (pbi->decoding_thread_count + 1))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int recon_yoffset, recon_uvoffset;
|
|
|
|
int mb_col;
|
|
|
|
int ref_fb_idx = pc->lst_fb_idx;
|
|
|
|
int dst_fb_idx = pc->new_fb_idx;
|
|
|
|
int recon_y_stride = pc->yv12_fb[ref_fb_idx].y_stride;
|
|
|
|
int recon_uv_stride = pc->yv12_fb[ref_fb_idx].uv_stride;
|
|
|
|
|
|
|
|
int filter_level;
|
|
|
|
loop_filter_info_n *lfi_n = &pc->lf_info;
|
|
|
|
|
2012-04-20 13:14:24 +02:00
|
|
|
/* save last row processed by this thread */
|
|
|
|
last_mb_row = mb_row;
|
|
|
|
/* select bool coder for current partition */
|
|
|
|
xd->current_bc = &pbi->mbc[mb_row%num_part];
|
2012-02-28 20:00:32 +01:00
|
|
|
|
|
|
|
if (mb_row > 0)
|
|
|
|
last_row_current_mb_col = &pbi->mt_current_mb_col[mb_row -1];
|
2012-04-20 13:14:24 +02:00
|
|
|
else
|
|
|
|
last_row_current_mb_col = &first_row_no_sync_above;
|
|
|
|
|
|
|
|
current_mb_col = &pbi->mt_current_mb_col[mb_row];
|
2012-02-28 20:00:32 +01:00
|
|
|
|
|
|
|
recon_yoffset = mb_row * recon_y_stride * 16;
|
|
|
|
recon_uvoffset = mb_row * recon_uv_stride * 8;
|
|
|
|
|
2012-02-29 16:38:14 +01:00
|
|
|
/* reset contexts */
|
2012-02-28 20:00:32 +01:00
|
|
|
xd->above_context = pc->above_context;
|
|
|
|
vpx_memset(xd->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
|
2012-02-29 16:38:14 +01:00
|
|
|
|
|
|
|
xd->left_available = 0;
|
2012-02-28 20:00:32 +01:00
|
|
|
|
|
|
|
xd->mb_to_top_edge = -((mb_row * 16)) << 3;
|
|
|
|
xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3;
|
|
|
|
|
2012-03-08 21:27:41 +01:00
|
|
|
if (pbi->common.filter_level)
|
|
|
|
{
|
|
|
|
xd->recon_above[0] = pbi->mt_yabove_row[mb_row] + 0*16 +32;
|
|
|
|
xd->recon_above[1] = pbi->mt_uabove_row[mb_row] + 0*8 +16;
|
|
|
|
xd->recon_above[2] = pbi->mt_vabove_row[mb_row] + 0*8 +16;
|
|
|
|
|
|
|
|
xd->recon_left[0] = pbi->mt_yleft_col[mb_row];
|
|
|
|
xd->recon_left[1] = pbi->mt_uleft_col[mb_row];
|
|
|
|
xd->recon_left[2] = pbi->mt_vleft_col[mb_row];
|
|
|
|
|
|
|
|
//TODO: move to outside row loop
|
|
|
|
xd->recon_left_stride[0] = 1;
|
|
|
|
xd->recon_left_stride[1] = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xd->recon_above[0] = dst_buffer[0] + recon_yoffset;
|
|
|
|
xd->recon_above[1] = dst_buffer[1] + recon_uvoffset;
|
|
|
|
xd->recon_above[2] = dst_buffer[2] + recon_uvoffset;
|
|
|
|
|
|
|
|
xd->recon_left[0] = xd->recon_above[0] - 1;
|
|
|
|
xd->recon_left[1] = xd->recon_above[1] - 1;
|
|
|
|
xd->recon_left[2] = xd->recon_above[2] - 1;
|
|
|
|
|
|
|
|
xd->recon_above[0] -= xd->dst.y_stride;
|
|
|
|
xd->recon_above[1] -= xd->dst.uv_stride;
|
|
|
|
xd->recon_above[2] -= xd->dst.uv_stride;
|
|
|
|
|
|
|
|
//TODO: move to outside row loop
|
|
|
|
xd->recon_left_stride[0] = xd->dst.y_stride;
|
|
|
|
xd->recon_left_stride[1] = xd->dst.uv_stride;
|
|
|
|
}
|
|
|
|
|
2012-02-28 20:00:32 +01:00
|
|
|
for (mb_col = 0; mb_col < pc->mb_cols; mb_col++)
|
|
|
|
{
|
2012-04-20 13:14:24 +02:00
|
|
|
*current_mb_col = mb_col - 1;
|
|
|
|
|
|
|
|
if ((mb_col & (nsync - 1)) == 0)
|
2012-02-28 20:00:32 +01:00
|
|
|
{
|
2012-04-20 13:14:24 +02:00
|
|
|
while (mb_col > (*last_row_current_mb_col - nsync))
|
2012-02-28 20:00:32 +01:00
|
|
|
{
|
|
|
|
x86_pause_hint();
|
|
|
|
thread_sleep(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Distance of MB to the various image edges.
|
|
|
|
* These are specified to 8th pel as they are always
|
|
|
|
* compared to values that are in 1/8th pel units.
|
|
|
|
*/
|
|
|
|
xd->mb_to_left_edge = -((mb_col * 16) << 3);
|
|
|
|
xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
|
|
|
|
|
|
|
|
#if CONFIG_ERROR_CONCEALMENT
|
|
|
|
{
|
|
|
|
int corrupt_residual =
|
|
|
|
(!pbi->independent_partitions &&
|
|
|
|
pbi->frame_corrupt_residual) ||
|
|
|
|
vp8dx_bool_error(xd->current_bc);
|
|
|
|
if (pbi->ec_active &&
|
|
|
|
(xd->mode_info_context->mbmi.ref_frame ==
|
|
|
|
INTRA_FRAME) &&
|
|
|
|
corrupt_residual)
|
|
|
|
{
|
|
|
|
/* We have an intra block with corrupt
|
|
|
|
* coefficients, better to conceal with an inter
|
|
|
|
* block.
|
|
|
|
* Interpolate MVs from neighboring MBs
|
|
|
|
*
|
|
|
|
* Note that for the first mb with corrupt
|
|
|
|
* residual in a frame, we might not discover
|
|
|
|
* that before decoding the residual. That
|
|
|
|
* happens after this check, and therefore no
|
|
|
|
* inter concealment will be done.
|
|
|
|
*/
|
|
|
|
vp8_interpolate_motion(xd,
|
|
|
|
mb_row, mb_col,
|
|
|
|
pc->mb_rows, pc->mb_cols,
|
|
|
|
pc->mode_info_stride);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2012-02-29 16:38:14 +01:00
|
|
|
xd->dst.y_buffer = dst_buffer[0] + recon_yoffset;
|
|
|
|
xd->dst.u_buffer = dst_buffer[1] + recon_uvoffset;
|
|
|
|
xd->dst.v_buffer = dst_buffer[2] + recon_uvoffset;
|
2012-02-28 20:00:32 +01:00
|
|
|
|
2012-02-29 16:38:14 +01:00
|
|
|
xd->pre.y_buffer = ref_buffer[xd->mode_info_context->mbmi.ref_frame][0] + recon_yoffset;
|
|
|
|
xd->pre.u_buffer = ref_buffer[xd->mode_info_context->mbmi.ref_frame][1] + recon_uvoffset;
|
|
|
|
xd->pre.v_buffer = ref_buffer[xd->mode_info_context->mbmi.ref_frame][2] + recon_uvoffset;
|
2012-02-28 20:00:32 +01:00
|
|
|
|
2012-02-29 16:38:14 +01:00
|
|
|
/* propagate errors from reference frames */
|
|
|
|
xd->corrupted |= ref_fb_corrupted[xd->mode_info_context->mbmi.ref_frame];
|
2012-02-28 20:00:32 +01:00
|
|
|
|
2012-04-20 13:14:24 +02:00
|
|
|
mt_decode_macroblock(pbi, xd, 0);
|
2012-02-28 20:00:32 +01:00
|
|
|
|
2012-02-29 16:38:14 +01:00
|
|
|
xd->left_available = 1;
|
|
|
|
|
2012-02-28 20:00:32 +01:00
|
|
|
/* check if the boolean decoder has suffered an error */
|
|
|
|
xd->corrupted |= vp8dx_bool_error(xd->current_bc);
|
|
|
|
|
2012-03-08 21:27:41 +01:00
|
|
|
xd->recon_above[0] += 16;
|
|
|
|
xd->recon_above[1] += 8;
|
|
|
|
xd->recon_above[2] += 8;
|
|
|
|
|
|
|
|
if (!pbi->common.filter_level)
|
|
|
|
{
|
|
|
|
xd->recon_left[0] += 16;
|
|
|
|
xd->recon_left[1] += 8;
|
|
|
|
xd->recon_left[2] += 8;
|
|
|
|
}
|
|
|
|
|
2012-02-28 20:00:32 +01:00
|
|
|
if (pbi->common.filter_level)
|
|
|
|
{
|
|
|
|
int skip_lf = (xd->mode_info_context->mbmi.mode != B_PRED &&
|
|
|
|
xd->mode_info_context->mbmi.mode != SPLITMV &&
|
|
|
|
xd->mode_info_context->mbmi.mb_skip_coeff);
|
|
|
|
|
|
|
|
const int mode_index = lfi_n->mode_lf_lut[xd->mode_info_context->mbmi.mode];
|
|
|
|
const int seg = xd->mode_info_context->mbmi.segment_id;
|
|
|
|
const int ref_frame = xd->mode_info_context->mbmi.ref_frame;
|
|
|
|
|
|
|
|
filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
|
|
|
|
|
|
|
|
if( mb_row != pc->mb_rows-1 )
|
|
|
|
{
|
|
|
|
/* Save decoded MB last row data for next-row decoding */
|
|
|
|
vpx_memcpy((pbi->mt_yabove_row[mb_row + 1] + 32 + mb_col*16), (xd->dst.y_buffer + 15 * recon_y_stride), 16);
|
|
|
|
vpx_memcpy((pbi->mt_uabove_row[mb_row + 1] + 16 + mb_col*8), (xd->dst.u_buffer + 7 * recon_uv_stride), 8);
|
|
|
|
vpx_memcpy((pbi->mt_vabove_row[mb_row + 1] + 16 + mb_col*8), (xd->dst.v_buffer + 7 * recon_uv_stride), 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* save left_col for next MB decoding */
|
|
|
|
if(mb_col != pc->mb_cols-1)
|
|
|
|
{
|
|
|
|
MODE_INFO *next = xd->mode_info_context +1;
|
|
|
|
|
|
|
|
if (next->mbmi.ref_frame == INTRA_FRAME)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
pbi->mt_yleft_col[mb_row][i] = xd->dst.y_buffer [i* recon_y_stride + 15];
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
pbi->mt_uleft_col[mb_row][i] = xd->dst.u_buffer [i* recon_uv_stride + 7];
|
|
|
|
pbi->mt_vleft_col[mb_row][i] = xd->dst.v_buffer [i* recon_uv_stride + 7];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* loopfilter on this macroblock. */
|
|
|
|
if (filter_level)
|
|
|
|
{
|
|
|
|
if(pc->filter_type == NORMAL_LOOPFILTER)
|
|
|
|
{
|
|
|
|
loop_filter_info lfi;
|
|
|
|
FRAME_TYPE frame_type = pc->frame_type;
|
|
|
|
const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
|
|
|
|
lfi.mblim = lfi_n->mblim[filter_level];
|
|
|
|
lfi.blim = lfi_n->blim[filter_level];
|
|
|
|
lfi.lim = lfi_n->lim[filter_level];
|
|
|
|
lfi.hev_thr = lfi_n->hev_thr[hev_index];
|
|
|
|
|
|
|
|
if (mb_col > 0)
|
|
|
|
vp8_loop_filter_mbv
|
|
|
|
(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
|
|
|
vp8_loop_filter_bv
|
|
|
|
(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi);
|
|
|
|
|
|
|
|
/* don't apply across umv border */
|
|
|
|
if (mb_row > 0)
|
|
|
|
vp8_loop_filter_mbh
|
|
|
|
(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
|
|
|
vp8_loop_filter_bh
|
|
|
|
(xd->dst.y_buffer, xd->dst.u_buffer, xd->dst.v_buffer, recon_y_stride, recon_uv_stride, &lfi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (mb_col > 0)
|
|
|
|
vp8_loop_filter_simple_mbv
|
|
|
|
(xd->dst.y_buffer, recon_y_stride, lfi_n->mblim[filter_level]);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
|
|
|
vp8_loop_filter_simple_bv
|
|
|
|
(xd->dst.y_buffer, recon_y_stride, lfi_n->blim[filter_level]);
|
|
|
|
|
|
|
|
/* don't apply across umv border */
|
|
|
|
if (mb_row > 0)
|
|
|
|
vp8_loop_filter_simple_mbh
|
|
|
|
(xd->dst.y_buffer, recon_y_stride, lfi_n->mblim[filter_level]);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
|
|
|
vp8_loop_filter_simple_bh
|
|
|
|
(xd->dst.y_buffer, recon_y_stride, lfi_n->blim[filter_level]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
recon_yoffset += 16;
|
|
|
|
recon_uvoffset += 8;
|
|
|
|
|
|
|
|
++xd->mode_info_context; /* next mb */
|
|
|
|
|
|
|
|
xd->above_context++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust to the next row of mbs */
|
|
|
|
if (pbi->common.filter_level)
|
|
|
|
{
|
|
|
|
if(mb_row != pc->mb_rows-1)
|
|
|
|
{
|
|
|
|
int lasty = pc->yv12_fb[ref_fb_idx].y_width + VP8BORDERINPIXELS;
|
|
|
|
int lastuv = (pc->yv12_fb[ref_fb_idx].y_width>>1) + (VP8BORDERINPIXELS>>1);
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
pbi->mt_yabove_row[mb_row +1][lasty + i] = pbi->mt_yabove_row[mb_row +1][lasty -1];
|
|
|
|
pbi->mt_uabove_row[mb_row +1][lastuv + i] = pbi->mt_uabove_row[mb_row +1][lastuv -1];
|
|
|
|
pbi->mt_vabove_row[mb_row +1][lastuv + i] = pbi->mt_vabove_row[mb_row +1][lastuv -1];
|
|
|
|
}
|
|
|
|
}
|
2012-04-20 13:14:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
vp8_extend_mb_row(&pc->yv12_fb[dst_fb_idx], xd->dst.y_buffer + 16,
|
|
|
|
xd->dst.u_buffer + 8, xd->dst.v_buffer + 8);
|
|
|
|
|
|
|
|
/* last MB of row is ready just after extension is done */
|
|
|
|
*current_mb_col = mb_col + nsync;
|
2012-02-28 20:00:32 +01:00
|
|
|
|
|
|
|
++xd->mode_info_context; /* skip prediction column */
|
2012-02-29 16:38:14 +01:00
|
|
|
xd->up_available = 1;
|
2012-02-28 20:00:32 +01:00
|
|
|
|
|
|
|
/* since we have multithread */
|
|
|
|
xd->mode_info_context += xd->mode_info_stride * pbi->decoding_thread_count;
|
|
|
|
}
|
2012-04-20 13:14:24 +02:00
|
|
|
|
|
|
|
/* signal end of frame decoding if this thread processed the last mb_row */
|
|
|
|
if (last_mb_row == (pc->mb_rows - 1))
|
|
|
|
sem_post(&pbi->h_event_end_decoding);
|
|
|
|
|
2012-02-28 20:00:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-17 22:07:59 +01:00
|
|
|
static THREAD_FUNCTION thread_decoding_proc(void *p_data)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
int ithread = ((DECODETHREAD_DATA *)p_data)->ithread;
|
|
|
|
VP8D_COMP *pbi = (VP8D_COMP *)(((DECODETHREAD_DATA *)p_data)->ptr1);
|
|
|
|
MB_ROW_DEC *mbrd = (MB_ROW_DEC *)(((DECODETHREAD_DATA *)p_data)->ptr2);
|
2010-08-31 16:49:57 +02:00
|
|
|
ENTROPY_CONTEXT_PLANES mb_row_left_context;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (pbi->b_multithreaded_rd == 0)
|
|
|
|
break;
|
|
|
|
|
2010-07-29 22:24:26 +02:00
|
|
|
if (sem_wait(&pbi->h_event_start_decoding[ithread]) == 0)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
if (pbi->b_multithreaded_rd == 0)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MACROBLOCKD *xd = &mbrd->mbd;
|
2012-02-28 20:00:32 +01:00
|
|
|
xd->left_context = &mb_row_left_context;
|
2011-06-16 11:44:50 +02:00
|
|
|
|
2012-04-20 13:14:24 +02:00
|
|
|
mt_decode_mb_rows(pbi, xd, ithread+1);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
2010-07-29 22:24:26 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
return 0 ;
|
|
|
|
}
|
|
|
|
|
2010-07-29 22:24:26 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
void vp8_decoder_create_threads(VP8D_COMP *pbi)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2010-09-16 20:08:52 +02:00
|
|
|
int core_count = 0;
|
|
|
|
int ithread;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
pbi->b_multithreaded_rd = 0;
|
|
|
|
pbi->allocated_decoding_thread_count = 0;
|
2011-03-25 11:53:03 +01:00
|
|
|
|
|
|
|
/* limit decoding threads to the max number of token partitions */
|
|
|
|
core_count = (pbi->max_threads > 8) ? 8 : pbi->max_threads;
|
|
|
|
|
|
|
|
/* limit decoding threads to the available cores */
|
|
|
|
if (core_count > pbi->common.processor_core_count)
|
|
|
|
core_count = pbi->common.processor_core_count;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
if (core_count > 1)
|
|
|
|
{
|
|
|
|
pbi->b_multithreaded_rd = 1;
|
2011-03-25 11:53:03 +01:00
|
|
|
pbi->decoding_thread_count = core_count - 1;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
CHECK_MEM_ERROR(pbi->h_decoding_thread, vpx_malloc(sizeof(pthread_t) * pbi->decoding_thread_count));
|
|
|
|
CHECK_MEM_ERROR(pbi->h_event_start_decoding, vpx_malloc(sizeof(sem_t) * pbi->decoding_thread_count));
|
|
|
|
CHECK_MEM_ERROR(pbi->mb_row_di, vpx_memalign(32, sizeof(MB_ROW_DEC) * pbi->decoding_thread_count));
|
|
|
|
vpx_memset(pbi->mb_row_di, 0, sizeof(MB_ROW_DEC) * pbi->decoding_thread_count);
|
|
|
|
CHECK_MEM_ERROR(pbi->de_thread_data, vpx_malloc(sizeof(DECODETHREAD_DATA) * pbi->decoding_thread_count));
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
for (ithread = 0; ithread < pbi->decoding_thread_count; ithread++)
|
|
|
|
{
|
|
|
|
sem_init(&pbi->h_event_start_decoding[ithread], 0, 0);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-04-23 14:20:07 +02:00
|
|
|
vp8_setup_block_dptrs(&pbi->mb_row_di[ithread].mbd);
|
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
pbi->de_thread_data[ithread].ithread = ithread;
|
|
|
|
pbi->de_thread_data[ithread].ptr1 = (void *)pbi;
|
|
|
|
pbi->de_thread_data[ithread].ptr2 = (void *) &pbi->mb_row_di[ithread];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-03-17 22:07:59 +01:00
|
|
|
pthread_create(&pbi->h_decoding_thread[ithread], 0, thread_decoding_proc, (&pbi->de_thread_data[ithread]));
|
2010-09-16 20:08:52 +02:00
|
|
|
}
|
2010-07-29 22:24:26 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
sem_init(&pbi->h_event_end_decoding, 0, 0);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
pbi->allocated_decoding_thread_count = pbi->decoding_thread_count;
|
|
|
|
}
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows)
|
|
|
|
{
|
|
|
|
int i;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
if (pbi->b_multithreaded_rd)
|
|
|
|
{
|
|
|
|
vpx_free(pbi->mt_current_mb_col);
|
|
|
|
pbi->mt_current_mb_col = NULL ;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Free above_row buffers. */
|
2010-09-16 20:08:52 +02:00
|
|
|
if (pbi->mt_yabove_row)
|
|
|
|
{
|
|
|
|
for (i=0; i< mb_rows; i++)
|
|
|
|
{
|
|
|
|
vpx_free(pbi->mt_yabove_row[i]);
|
|
|
|
pbi->mt_yabove_row[i] = NULL ;
|
|
|
|
}
|
|
|
|
vpx_free(pbi->mt_yabove_row);
|
|
|
|
pbi->mt_yabove_row = NULL ;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
if (pbi->mt_uabove_row)
|
|
|
|
{
|
|
|
|
for (i=0; i< mb_rows; i++)
|
|
|
|
{
|
|
|
|
vpx_free(pbi->mt_uabove_row[i]);
|
|
|
|
pbi->mt_uabove_row[i] = NULL ;
|
|
|
|
}
|
|
|
|
vpx_free(pbi->mt_uabove_row);
|
|
|
|
pbi->mt_uabove_row = NULL ;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
if (pbi->mt_vabove_row)
|
|
|
|
{
|
|
|
|
for (i=0; i< mb_rows; i++)
|
|
|
|
{
|
|
|
|
vpx_free(pbi->mt_vabove_row[i]);
|
|
|
|
pbi->mt_vabove_row[i] = NULL ;
|
|
|
|
}
|
|
|
|
vpx_free(pbi->mt_vabove_row);
|
|
|
|
pbi->mt_vabove_row = NULL ;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Free left_col buffers. */
|
2010-09-16 20:08:52 +02:00
|
|
|
if (pbi->mt_yleft_col)
|
|
|
|
{
|
|
|
|
for (i=0; i< mb_rows; i++)
|
|
|
|
{
|
|
|
|
vpx_free(pbi->mt_yleft_col[i]);
|
|
|
|
pbi->mt_yleft_col[i] = NULL ;
|
|
|
|
}
|
|
|
|
vpx_free(pbi->mt_yleft_col);
|
|
|
|
pbi->mt_yleft_col = NULL ;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
if (pbi->mt_uleft_col)
|
|
|
|
{
|
|
|
|
for (i=0; i< mb_rows; i++)
|
|
|
|
{
|
|
|
|
vpx_free(pbi->mt_uleft_col[i]);
|
|
|
|
pbi->mt_uleft_col[i] = NULL ;
|
2010-07-29 22:24:26 +02:00
|
|
|
}
|
2010-09-16 20:08:52 +02:00
|
|
|
vpx_free(pbi->mt_uleft_col);
|
|
|
|
pbi->mt_uleft_col = NULL ;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
if (pbi->mt_vleft_col)
|
2010-07-29 22:24:26 +02:00
|
|
|
{
|
2010-09-16 20:08:52 +02:00
|
|
|
for (i=0; i< mb_rows; i++)
|
|
|
|
{
|
|
|
|
vpx_free(pbi->mt_vleft_col[i]);
|
|
|
|
pbi->mt_vleft_col[i] = NULL ;
|
|
|
|
}
|
|
|
|
vpx_free(pbi->mt_vleft_col);
|
|
|
|
pbi->mt_vleft_col = NULL ;
|
2010-07-29 22:24:26 +02:00
|
|
|
}
|
2010-09-16 20:08:52 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
|
2010-11-17 15:13:54 +01:00
|
|
|
void vp8mt_alloc_temp_buffers(VP8D_COMP *pbi, int width, int prev_mb_rows)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2010-09-16 20:08:52 +02:00
|
|
|
VP8_COMMON *const pc = & pbi->common;
|
|
|
|
int i;
|
|
|
|
int uv_width;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
if (pbi->b_multithreaded_rd)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2010-09-16 20:08:52 +02:00
|
|
|
vp8mt_de_alloc_temp_buffers(pbi, prev_mb_rows);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* our internal buffers are always multiples of 16 */
|
2010-09-16 20:08:52 +02:00
|
|
|
if ((width & 0xf) != 0)
|
|
|
|
width += 16 - (width & 0xf);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-23 19:53:09 +02:00
|
|
|
if (width < 640) pbi->sync_range = 1;
|
|
|
|
else if (width <= 1280) pbi->sync_range = 8;
|
|
|
|
else if (width <= 2560) pbi->sync_range =16;
|
|
|
|
else pbi->sync_range = 32;
|
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
uv_width = width >>1;
|
2010-07-29 22:24:26 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Allocate an int for each mb row. */
|
2010-09-16 20:08:52 +02:00
|
|
|
CHECK_MEM_ERROR(pbi->mt_current_mb_col, vpx_malloc(sizeof(int) * pc->mb_rows));
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Allocate memory for above_row buffers. */
|
2010-09-16 20:08:52 +02:00
|
|
|
CHECK_MEM_ERROR(pbi->mt_yabove_row, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
|
|
|
|
for (i=0; i< pc->mb_rows; i++)
|
2012-03-29 20:24:53 +02:00
|
|
|
CHECK_MEM_ERROR(pbi->mt_yabove_row[i], vpx_memalign(16,sizeof(unsigned char) * (width + (VP8BORDERINPIXELS<<1))));
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
CHECK_MEM_ERROR(pbi->mt_uabove_row, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
|
|
|
|
for (i=0; i< pc->mb_rows; i++)
|
2012-03-29 20:24:53 +02:00
|
|
|
CHECK_MEM_ERROR(pbi->mt_uabove_row[i], vpx_memalign(16,sizeof(unsigned char) * (uv_width + VP8BORDERINPIXELS)));
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
CHECK_MEM_ERROR(pbi->mt_vabove_row, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
|
|
|
|
for (i=0; i< pc->mb_rows; i++)
|
2012-03-29 20:24:53 +02:00
|
|
|
CHECK_MEM_ERROR(pbi->mt_vabove_row[i], vpx_memalign(16,sizeof(unsigned char) * (uv_width + VP8BORDERINPIXELS)));
|
2010-07-29 22:24:26 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Allocate memory for left_col buffers. */
|
2010-09-16 20:08:52 +02:00
|
|
|
CHECK_MEM_ERROR(pbi->mt_yleft_col, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
|
|
|
|
for (i=0; i< pc->mb_rows; i++)
|
|
|
|
CHECK_MEM_ERROR(pbi->mt_yleft_col[i], vpx_calloc(sizeof(unsigned char) * 16, 1));
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
CHECK_MEM_ERROR(pbi->mt_uleft_col, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
|
|
|
|
for (i=0; i< pc->mb_rows; i++)
|
|
|
|
CHECK_MEM_ERROR(pbi->mt_uleft_col[i], vpx_calloc(sizeof(unsigned char) * 8, 1));
|
|
|
|
|
|
|
|
CHECK_MEM_ERROR(pbi->mt_vleft_col, vpx_malloc(sizeof(unsigned char *) * pc->mb_rows));
|
|
|
|
for (i=0; i< pc->mb_rows; i++)
|
|
|
|
CHECK_MEM_ERROR(pbi->mt_vleft_col[i], vpx_calloc(sizeof(unsigned char) * 8, 1));
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
void vp8_decoder_remove_threads(VP8D_COMP *pbi)
|
|
|
|
{
|
2010-10-28 01:04:02 +02:00
|
|
|
/* shutdown MB Decoding thread; */
|
2010-05-18 17:58:33 +02:00
|
|
|
if (pbi->b_multithreaded_rd)
|
|
|
|
{
|
2010-07-29 22:24:26 +02:00
|
|
|
int i;
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
pbi->b_multithreaded_rd = 0;
|
2010-07-29 22:24:26 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* allow all threads to exit */
|
2010-07-29 22:24:26 +02:00
|
|
|
for (i = 0; i < pbi->allocated_decoding_thread_count; i++)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2010-07-29 22:24:26 +02:00
|
|
|
sem_post(&pbi->h_event_start_decoding[i]);
|
|
|
|
pthread_join(pbi->h_decoding_thread[i], NULL);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2010-07-29 22:24:26 +02:00
|
|
|
for (i = 0; i < pbi->allocated_decoding_thread_count; i++)
|
|
|
|
{
|
|
|
|
sem_destroy(&pbi->h_event_start_decoding[i]);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2010-07-29 22:24:26 +02:00
|
|
|
sem_destroy(&pbi->h_event_end_decoding);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
vpx_free(pbi->h_decoding_thread);
|
|
|
|
pbi->h_decoding_thread = NULL;
|
|
|
|
|
2010-07-29 22:24:26 +02:00
|
|
|
vpx_free(pbi->h_event_start_decoding);
|
|
|
|
pbi->h_event_start_decoding = NULL;
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
vpx_free(pbi->mb_row_di);
|
|
|
|
pbi->mb_row_di = NULL ;
|
|
|
|
|
|
|
|
vpx_free(pbi->de_thread_data);
|
|
|
|
pbi->de_thread_data = NULL;
|
2010-07-29 22:24:26 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2010-09-16 20:08:52 +02:00
|
|
|
void vp8mt_decode_mb_rows( VP8D_COMP *pbi, MACROBLOCKD *xd)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
VP8_COMMON *pc = &pbi->common;
|
2011-01-11 13:01:24 +01:00
|
|
|
int i;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
int filter_level = pc->filter_level;
|
2010-09-16 20:08:52 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
if (filter_level)
|
2010-09-16 20:08:52 +02:00
|
|
|
{
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Set above_row buffer to 127 for decoding first MB row */
|
2010-09-16 20:08:52 +02:00
|
|
|
vpx_memset(pbi->mt_yabove_row[0] + VP8BORDERINPIXELS-1, 127, pc->yv12_fb[pc->lst_fb_idx].y_width + 5);
|
|
|
|
vpx_memset(pbi->mt_uabove_row[0] + (VP8BORDERINPIXELS>>1)-1, 127, (pc->yv12_fb[pc->lst_fb_idx].y_width>>1) +5);
|
|
|
|
vpx_memset(pbi->mt_vabove_row[0] + (VP8BORDERINPIXELS>>1)-1, 127, (pc->yv12_fb[pc->lst_fb_idx].y_width>>1) +5);
|
|
|
|
|
|
|
|
for (i=1; i<pc->mb_rows; i++)
|
|
|
|
{
|
|
|
|
vpx_memset(pbi->mt_yabove_row[i] + VP8BORDERINPIXELS-1, (unsigned char)129, 1);
|
|
|
|
vpx_memset(pbi->mt_uabove_row[i] + (VP8BORDERINPIXELS>>1)-1, (unsigned char)129, 1);
|
|
|
|
vpx_memset(pbi->mt_vabove_row[i] + (VP8BORDERINPIXELS>>1)-1, (unsigned char)129, 1);
|
|
|
|
}
|
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Set left_col to 129 initially */
|
2010-09-16 20:08:52 +02:00
|
|
|
for (i=0; i<pc->mb_rows; i++)
|
|
|
|
{
|
|
|
|
vpx_memset(pbi->mt_yleft_col[i], (unsigned char)129, 16);
|
|
|
|
vpx_memset(pbi->mt_uleft_col[i], (unsigned char)129, 8);
|
|
|
|
vpx_memset(pbi->mt_vleft_col[i], (unsigned char)129, 8);
|
|
|
|
}
|
2011-06-10 13:10:21 +02:00
|
|
|
|
|
|
|
/* Initialize the loop filter for this frame. */
|
2011-07-20 21:53:42 +02:00
|
|
|
vp8_loop_filter_frame_init(pc, &pbi->mb, filter_level);
|
2010-09-16 20:08:52 +02:00
|
|
|
}
|
|
|
|
|
2011-03-17 22:07:59 +01:00
|
|
|
setup_decoding_thread_data(pbi, xd, pbi->mb_row_di, pbi->decoding_thread_count);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-07-29 22:24:26 +02:00
|
|
|
for (i = 0; i < pbi->decoding_thread_count; i++)
|
|
|
|
sem_post(&pbi->h_event_start_decoding[i]);
|
|
|
|
|
2012-04-20 13:14:24 +02:00
|
|
|
mt_decode_mb_rows(pbi, xd, 0);
|
2010-07-29 22:24:26 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
sem_wait(&pbi->h_event_end_decoding); /* add back for each frame */
|
2010-07-29 22:24:26 +02:00
|
|
|
}
|