An error occurred while loading the file. Please try again.
-
James Zern authored
Change-Id: I5164df72aff84eca0ace56032c5373f04053c6a5
25cfd8e8
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "vp9/decoder/vp9_onyxd_int.h"
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_header.h"
#include "vp9/common/vp9_reconintra.h"
#include "vp9/common/vp9_reconinter.h"
#include "vp9/common/vp9_entropy.h"
#include "vp9/decoder/vp9_decodframe.h"
#include "vp9/decoder/vp9_detokenize.h"
#include "vp9/common/vp9_invtrans.h"
#include "vp9/common/vp9_alloccommon.h"
#include "vp9/common/vp9_entropymode.h"
#include "vp9/common/vp9_quant_common.h"
#include "vpx_scale/vpx_scale.h"
#include "vp9/common/vp9_setupintrarecon.h"
#include "vp9/decoder/vp9_decodemv.h"
#include "vp9/common/vp9_extend.h"
#include "vp9/common/vp9_modecont.h"
#include "vpx_mem/vpx_mem.h"
#include "vp9/decoder/vp9_dboolhuff.h"
#include "vp9/common/vp9_seg_common.h"
#include "vp9_rtcd.h"
#include <assert.h>
#include <stdio.h>
#define COEFCOUNT_TESTING
//#define DEC_DEBUG
#ifdef DEC_DEBUG
int dec_debug = 0;
#endif
static int merge_index(int v, int n, int modulus) {
int max1 = (n - 1 - modulus / 2) / modulus + 1;
if (v < max1) v = v * modulus + modulus / 2;
else {
int w;
v -= max1;
w = v;
v += (v + modulus - modulus / 2) / modulus;
while (v % modulus == modulus / 2 ||
w != v - (v + modulus - modulus / 2) / modulus) v++;
}
return v;
}
static int inv_remap_prob(int v, int m) {
const int n = 256;
const int modulus = MODULUS_PARAM;
int i;
v = merge_index(v, n - 1, modulus);
if ((m << 1) <= n) {
i = vp9_inv_recenter_nonneg(v + 1, m);
} else {
i = n - 1 - vp9_inv_recenter_nonneg(v + 1, n - 1 - m);
}
return i;
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
}
static vp9_prob read_prob_diff_update(vp9_reader *const bc, int oldp) {
int delp = vp9_decode_term_subexp(bc, SUBEXP_PARAM, 255);
return (vp9_prob)inv_remap_prob(delp, oldp);
}
void vp9_init_de_quantizer(VP9D_COMP *pbi) {
int i;
int Q;
VP9_COMMON *const pc = &pbi->common;
for (Q = 0; Q < QINDEX_RANGE; Q++) {
pc->Y1dequant[Q][0] = (int16_t)vp9_dc_quant(Q, pc->y1dc_delta_q);
pc->Y2dequant[Q][0] = (int16_t)vp9_dc2quant(Q, pc->y2dc_delta_q);
pc->UVdequant[Q][0] = (int16_t)vp9_dc_uv_quant(Q, pc->uvdc_delta_q);
/* all the ac values =; */
for (i = 1; i < 16; i++) {
int rc = vp9_default_zig_zag1d_4x4[i];
pc->Y1dequant[Q][rc] = (int16_t)vp9_ac_yquant(Q);
pc->Y2dequant[Q][rc] = (int16_t)vp9_ac2quant(Q, pc->y2ac_delta_q);
pc->UVdequant[Q][rc] = (int16_t)vp9_ac_uv_quant(Q, pc->uvac_delta_q);
}
}
}
static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *xd) {
int i;
int QIndex;
VP9_COMMON *const pc = &pbi->common;
int segment_id = xd->mode_info_context->mbmi.segment_id;
// Set the Q baseline allowing for any segment level adjustment
if (vp9_segfeature_active(xd, segment_id, SEG_LVL_ALT_Q)) {
/* Abs Value */
if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA)
QIndex = vp9_get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
/* Delta Value */
else {
QIndex = pc->base_qindex +
vp9_get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0; /* Clamp to valid range */
}
} else
QIndex = pc->base_qindex;
xd->q_index = QIndex;
/* Set up the block level dequant pointers */
for (i = 0; i < 16; i++) {
xd->block[i].dequant = pc->Y1dequant[QIndex];
}
#if CONFIG_LOSSLESS
if (!QIndex) {
pbi->mb.inv_xform4x4_1_x8 = vp9_short_inv_walsh4x4_1_x8;
pbi->mb.inv_xform4x4_x8 = vp9_short_inv_walsh4x4_x8;
pbi->mb.inv_walsh4x4_1 = vp9_short_inv_walsh4x4_1_lossless;
pbi->mb.inv_walsh4x4_lossless = vp9_short_inv_walsh4x4_lossless;
pbi->idct_add = vp9_dequant_idct_add_lossless_c;
pbi->dc_idct_add = vp9_dequant_dc_idct_add_lossless_c;
pbi->dc_idct_add_y_block = vp9_dequant_dc_idct_add_y_block_lossless_c;
pbi->idct_add_y_block = vp9_dequant_idct_add_y_block_lossless_c;
pbi->idct_add_uv_block = vp9_dequant_idct_add_uv_block_lossless_c;
} else {
pbi->mb.inv_xform4x4_1_x8 = vp9_short_idct4x4llm_1;
pbi->mb.inv_xform4x4_x8 = vp9_short_idct4x4llm;
pbi->mb.inv_walsh4x4_1 = vp9_short_inv_walsh4x4_1;