Remove bc, bc2 from pbi,cpi,xd
Pass the bool coder to be used explicitly. This avoids cases where two different bool coders can be addressed from the same function. Also be more consistent with bool coder variable naming, start to standardize on 'bc'. Change-Id: I1c95e2fdbe24ebe8c0f84924daa1728e3b054a31
This commit is contained in:
parent
f3208f362b
commit
e9fd1eace1
@ -364,8 +364,6 @@ typedef struct MacroBlockD {
|
|||||||
vp8_subpix_fn_t subpixel_predict_avg16x16;
|
vp8_subpix_fn_t subpixel_predict_avg16x16;
|
||||||
int allow_high_precision_mv;
|
int allow_high_precision_mv;
|
||||||
|
|
||||||
void *current_bc;
|
|
||||||
|
|
||||||
int corrupted;
|
int corrupted;
|
||||||
|
|
||||||
#if !CONFIG_SUPERBLOCKS && (ARCH_X86 || ARCH_X86_64)
|
#if !CONFIG_SUPERBLOCKS && (ARCH_X86 || ARCH_X86_64)
|
||||||
|
@ -24,7 +24,6 @@ DEFINE(detok_A, offsetof(DETOK, A));
|
|||||||
DEFINE(detok_L, offsetof(DETOK, L));
|
DEFINE(detok_L, offsetof(DETOK, L));
|
||||||
|
|
||||||
DEFINE(detok_qcoeff_start_ptr, offsetof(DETOK, qcoeff_start_ptr));
|
DEFINE(detok_qcoeff_start_ptr, offsetof(DETOK, qcoeff_start_ptr));
|
||||||
DEFINE(detok_current_bc, offsetof(DETOK, current_bc));
|
|
||||||
DEFINE(detok_coef_probs, offsetof(DETOK, coef_probs));
|
DEFINE(detok_coef_probs, offsetof(DETOK, coef_probs));
|
||||||
DEFINE(detok_eob, offsetof(DETOK, eob));
|
DEFINE(detok_eob, offsetof(DETOK, eob));
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "vp8/common/seg_common.h"
|
#include "vp8/common/seg_common.h"
|
||||||
#include "vp8/common/pred_common.h"
|
#include "vp8/common/pred_common.h"
|
||||||
#include "vp8/common/entropy.h"
|
#include "vp8/common/entropy.h"
|
||||||
|
#include "vp8/decoder/decodemv.h"
|
||||||
#if CONFIG_DEBUG
|
#if CONFIG_DEBUG
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
@ -73,12 +73,12 @@ static void vp8_read_mb_segid(vp8_reader *r, MB_MODE_INFO *mi,
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern const int vp8_i8x8_block[4];
|
extern const int vp8_i8x8_block[4];
|
||||||
static void vp8_kfread_modes(VP8D_COMP *pbi,
|
static void kfread_modes(VP8D_COMP *pbi,
|
||||||
MODE_INFO *m,
|
MODE_INFO *m,
|
||||||
int mb_row,
|
int mb_row,
|
||||||
int mb_col) {
|
int mb_col,
|
||||||
|
BOOL_DECODER* const bc) {
|
||||||
VP8_COMMON *const cm = &pbi->common;
|
VP8_COMMON *const cm = &pbi->common;
|
||||||
vp8_reader *const bc = pbi->mb.current_bc;
|
|
||||||
const int mis = pbi->common.mode_info_stride;
|
const int mis = pbi->common.mode_info_stride;
|
||||||
int map_index = mb_row * pbi->common.mb_cols + mb_col;
|
int map_index = mb_row * pbi->common.mb_cols + mb_col;
|
||||||
MB_PREDICTION_MODE y_mode;
|
MB_PREDICTION_MODE y_mode;
|
||||||
@ -597,9 +597,9 @@ static const unsigned char mbsplit_fill_offset[4][16] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if CONFIG_SWITCHABLE_INTERP
|
#if CONFIG_SWITCHABLE_INTERP
|
||||||
static void read_switchable_interp_probs(VP8D_COMP *pbi) {
|
static void read_switchable_interp_probs(VP8D_COMP* const pbi,
|
||||||
|
BOOL_DECODER* const bc) {
|
||||||
VP8_COMMON *const cm = &pbi->common;
|
VP8_COMMON *const cm = &pbi->common;
|
||||||
vp8_reader *const bc = &pbi->bc;
|
|
||||||
int i, j;
|
int i, j;
|
||||||
for (j = 0; j <= VP8_SWITCHABLE_FILTERS; ++j) {
|
for (j = 0; j <= VP8_SWITCHABLE_FILTERS; ++j) {
|
||||||
//for (j = 0; j <= 0; ++j) {
|
//for (j = 0; j <= 0; ++j) {
|
||||||
@ -634,7 +634,7 @@ static void mb_mode_mv_init(VP8D_COMP *pbi, vp8_reader *bc) {
|
|||||||
#endif
|
#endif
|
||||||
#if CONFIG_SWITCHABLE_INTERP
|
#if CONFIG_SWITCHABLE_INTERP
|
||||||
if (cm->mcomp_filter_type == SWITCHABLE)
|
if (cm->mcomp_filter_type == SWITCHABLE)
|
||||||
read_switchable_interp_probs(pbi);
|
read_switchable_interp_probs(pbi, bc);
|
||||||
#endif
|
#endif
|
||||||
// Decode the baseline probabilities for decoding reference frame
|
// Decode the baseline probabilities for decoding reference frame
|
||||||
cm->prob_intra_coded = (vp8_prob)vp8_read_literal(bc, 8);
|
cm->prob_intra_coded = (vp8_prob)vp8_read_literal(bc, 8);
|
||||||
@ -676,10 +676,10 @@ static void mb_mode_mv_init(VP8D_COMP *pbi, vp8_reader *bc) {
|
|||||||
// the bitstream or if the value is temporally predicted asserts the predicted
|
// the bitstream or if the value is temporally predicted asserts the predicted
|
||||||
// value
|
// value
|
||||||
static void read_mb_segment_id(VP8D_COMP *pbi,
|
static void read_mb_segment_id(VP8D_COMP *pbi,
|
||||||
int mb_row, int mb_col) {
|
int mb_row, int mb_col,
|
||||||
|
BOOL_DECODER* const bc) {
|
||||||
VP8_COMMON *const cm = &pbi->common;
|
VP8_COMMON *const cm = &pbi->common;
|
||||||
MACROBLOCKD *const xd = &pbi->mb;
|
MACROBLOCKD *const xd = &pbi->mb;
|
||||||
vp8_reader *const bc = xd->current_bc;
|
|
||||||
MODE_INFO *mi = xd->mode_info_context;
|
MODE_INFO *mi = xd->mode_info_context;
|
||||||
MB_MODE_INFO *mbmi = &mi->mbmi;
|
MB_MODE_INFO *mbmi = &mi->mbmi;
|
||||||
int index = mb_row * pbi->common.mb_cols + mb_col;
|
int index = mb_row * pbi->common.mb_cols + mb_col;
|
||||||
@ -748,7 +748,8 @@ static void read_mb_segment_id(VP8D_COMP *pbi,
|
|||||||
|
|
||||||
static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
||||||
MODE_INFO *prev_mi,
|
MODE_INFO *prev_mi,
|
||||||
int mb_row, int mb_col) {
|
int mb_row, int mb_col,
|
||||||
|
BOOL_DECODER* const bc) {
|
||||||
VP8_COMMON *const cm = &pbi->common;
|
VP8_COMMON *const cm = &pbi->common;
|
||||||
#if CONFIG_NEWMVENTROPY
|
#if CONFIG_NEWMVENTROPY
|
||||||
nmv_context *const nmvc = &pbi->common.fc.nmvc;
|
nmv_context *const nmvc = &pbi->common.fc.nmvc;
|
||||||
@ -758,7 +759,6 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
|||||||
#endif
|
#endif
|
||||||
const int mis = pbi->common.mode_info_stride;
|
const int mis = pbi->common.mode_info_stride;
|
||||||
MACROBLOCKD *const xd = &pbi->mb;
|
MACROBLOCKD *const xd = &pbi->mb;
|
||||||
vp8_reader *const bc = xd->current_bc;
|
|
||||||
|
|
||||||
int_mv *const mv = &mbmi->mv;
|
int_mv *const mv = &mbmi->mv;
|
||||||
int mb_to_left_edge;
|
int mb_to_left_edge;
|
||||||
@ -790,7 +790,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
|||||||
xd->prev_mode_info_context = prev_mi;
|
xd->prev_mode_info_context = prev_mi;
|
||||||
|
|
||||||
// Read the macroblock segment id.
|
// Read the macroblock segment id.
|
||||||
read_mb_segment_id(pbi, mb_row, mb_col);
|
read_mb_segment_id(pbi, mb_row, mb_col, bc);
|
||||||
|
|
||||||
if (pbi->common.mb_no_coeff_skip &&
|
if (pbi->common.mb_no_coeff_skip &&
|
||||||
(!segfeature_active(xd,
|
(!segfeature_active(xd,
|
||||||
@ -1305,27 +1305,28 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vpx_decode_mode_mvs_init(VP8D_COMP *pbi){
|
void vpx_decode_mode_mvs_init(VP8D_COMP *pbi, BOOL_DECODER* const bc) {
|
||||||
VP8_COMMON *cm = &pbi->common;
|
VP8_COMMON *cm = &pbi->common;
|
||||||
|
|
||||||
vpx_memset(cm->mbskip_pred_probs, 0, sizeof(cm->mbskip_pred_probs));
|
vpx_memset(cm->mbskip_pred_probs, 0, sizeof(cm->mbskip_pred_probs));
|
||||||
if (pbi->common.mb_no_coeff_skip) {
|
if (pbi->common.mb_no_coeff_skip) {
|
||||||
int k;
|
int k;
|
||||||
for (k = 0; k < MBSKIP_CONTEXTS; ++k)
|
for (k = 0; k < MBSKIP_CONTEXTS; ++k)
|
||||||
cm->mbskip_pred_probs[k] = (vp8_prob)vp8_read_literal(&pbi->bc, 8);
|
cm->mbskip_pred_probs[k] = (vp8_prob)vp8_read_literal(bc, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
mb_mode_mv_init(pbi, &pbi->bc);
|
mb_mode_mv_init(pbi, bc);
|
||||||
}
|
}
|
||||||
void vpx_decode_mb_mode_mv(VP8D_COMP *pbi,
|
void vpx_decode_mb_mode_mv(VP8D_COMP *pbi,
|
||||||
MACROBLOCKD *xd,
|
MACROBLOCKD *xd,
|
||||||
int mb_row,
|
int mb_row,
|
||||||
int mb_col){
|
int mb_col,
|
||||||
|
BOOL_DECODER* const bc) {
|
||||||
MODE_INFO *mi = xd->mode_info_context;
|
MODE_INFO *mi = xd->mode_info_context;
|
||||||
MODE_INFO *prev_mi = xd->prev_mode_info_context;
|
MODE_INFO *prev_mi = xd->prev_mode_info_context;
|
||||||
|
|
||||||
if (pbi->common.frame_type == KEY_FRAME)
|
if (pbi->common.frame_type == KEY_FRAME)
|
||||||
vp8_kfread_modes(pbi, mi, mb_row, mb_col);
|
kfread_modes(pbi, mi, mb_row, mb_col, bc);
|
||||||
else
|
else
|
||||||
read_mb_modes_mv(pbi, mi, &mi->mbmi, prev_mi, mb_row, mb_col);
|
read_mb_modes_mv(pbi, mi, &mi->mbmi, prev_mi, mb_row, mb_col, bc);
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,9 @@
|
|||||||
|
|
||||||
#include "onyxd_int.h"
|
#include "onyxd_int.h"
|
||||||
|
|
||||||
void vpx_decode_mb_mode_mv(VP8D_COMP *pbi,
|
void vpx_decode_mb_mode_mv(VP8D_COMP* const pbi,
|
||||||
MACROBLOCKD *xd,
|
MACROBLOCKD* const xd,
|
||||||
int mb_row,
|
int mb_row,
|
||||||
int mb_col);
|
int mb_col,
|
||||||
void vpx_decode_mode_mvs_init(VP8D_COMP *pbi);
|
BOOL_DECODER* const bc);
|
||||||
|
void vpx_decode_mode_mvs_init(VP8D_COMP* const pbi, BOOL_DECODER* const bc);
|
||||||
|
@ -202,7 +202,8 @@ static void skip_recon_mb(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
|
static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
|
||||||
unsigned int mb_col) {
|
unsigned int mb_col,
|
||||||
|
BOOL_DECODER* const bc) {
|
||||||
int eobtotal = 0;
|
int eobtotal = 0;
|
||||||
MB_PREDICTION_MODE mode;
|
MB_PREDICTION_MODE mode;
|
||||||
int i;
|
int i;
|
||||||
@ -240,17 +241,17 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
|
|||||||
xd->left_context--;
|
xd->left_context--;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (!vp8dx_bool_error(xd->current_bc)) {
|
} else if (!vp8dx_bool_error(bc)) {
|
||||||
for (i = 0; i < 25; i++) {
|
for (i = 0; i < 25; i++) {
|
||||||
xd->block[i].eob = 0;
|
xd->block[i].eob = 0;
|
||||||
xd->eobs[i] = 0;
|
xd->eobs[i] = 0;
|
||||||
}
|
}
|
||||||
if (tx_size == TX_16X16) {
|
if (tx_size == TX_16X16) {
|
||||||
eobtotal = vp8_decode_mb_tokens_16x16(pbi, xd);
|
eobtotal = vp8_decode_mb_tokens_16x16(pbi, xd, bc);
|
||||||
} else if (tx_size == TX_8X8) {
|
} else if (tx_size == TX_8X8) {
|
||||||
eobtotal = vp8_decode_mb_tokens_8x8(pbi, xd);
|
eobtotal = vp8_decode_mb_tokens_8x8(pbi, xd, bc);
|
||||||
} else {
|
} else {
|
||||||
eobtotal = vp8_decode_mb_tokens(pbi, xd);
|
eobtotal = vp8_decode_mb_tokens(pbi, xd, bc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,8 +264,7 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
|
|||||||
|
|
||||||
if (eobtotal == 0 && mode != B_PRED && mode != SPLITMV
|
if (eobtotal == 0 && mode != B_PRED && mode != SPLITMV
|
||||||
&& mode != I8X8_PRED
|
&& mode != I8X8_PRED
|
||||||
&& !vp8dx_bool_error(xd->current_bc)
|
&& !vp8dx_bool_error(bc)) {
|
||||||
) {
|
|
||||||
/* Special case: Force the loopfilter to skip when eobtotal and
|
/* Special case: Force the loopfilter to skip when eobtotal and
|
||||||
* mb_skip_coeff are zero.
|
* mb_skip_coeff are zero.
|
||||||
* */
|
* */
|
||||||
@ -451,7 +451,7 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
|
|||||||
xd->mode_info_context += (n & 1);
|
xd->mode_info_context += (n & 1);
|
||||||
xd->mode_info_context += (n >> 1) * pc->mode_info_stride;
|
xd->mode_info_context += (n >> 1) * pc->mode_info_stride;
|
||||||
if (!orig_skip_flag) {
|
if (!orig_skip_flag) {
|
||||||
eobtotal = vp8_decode_mb_tokens_8x8(pbi, xd);
|
eobtotal = vp8_decode_mb_tokens_8x8(pbi, xd, bc);
|
||||||
if (eobtotal == 0) // skip loopfilter
|
if (eobtotal == 0) // skip loopfilter
|
||||||
xd->mode_info_context->mbmi.mb_skip_coeff = 1;
|
xd->mode_info_context->mbmi.mb_skip_coeff = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -562,7 +562,8 @@ FILE *vpxlog = 0;
|
|||||||
|
|
||||||
/* Decode a row of Superblocks (2x2 region of MBs) */
|
/* Decode a row of Superblocks (2x2 region of MBs) */
|
||||||
static void
|
static void
|
||||||
decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd) {
|
decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd,
|
||||||
|
BOOL_DECODER* const bc) {
|
||||||
int i;
|
int i;
|
||||||
int sb_col;
|
int sb_col;
|
||||||
int mb_row, mb_col;
|
int mb_row, mb_col;
|
||||||
@ -585,7 +586,7 @@ decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd) {
|
|||||||
MODE_INFO *mi = xd->mode_info_context;
|
MODE_INFO *mi = xd->mode_info_context;
|
||||||
|
|
||||||
#if CONFIG_SUPERBLOCKS
|
#if CONFIG_SUPERBLOCKS
|
||||||
mi->mbmi.encoded_as_sb = vp8_read(&pbi->bc, pc->sb_coded);
|
mi->mbmi.encoded_as_sb = vp8_read(bc, pc->sb_coded);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Process the 4 MBs within the SB in the order:
|
// Process the 4 MBs within the SB in the order:
|
||||||
@ -634,7 +635,7 @@ decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd) {
|
|||||||
if (i)
|
if (i)
|
||||||
mi->mbmi.encoded_as_sb = 0;
|
mi->mbmi.encoded_as_sb = 0;
|
||||||
#endif
|
#endif
|
||||||
vpx_decode_mb_mode_mv(pbi, xd, mb_row, mb_col);
|
vpx_decode_mb_mode_mv(pbi, xd, mb_row, mb_col, bc);
|
||||||
|
|
||||||
update_blockd_bmi(xd);
|
update_blockd_bmi(xd);
|
||||||
|
|
||||||
@ -682,7 +683,7 @@ decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd) {
|
|||||||
mi[pc->mode_info_stride + 1] = mi[0];
|
mi[pc->mode_info_stride + 1] = mi[0];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
decode_macroblock(pbi, xd, mb_col);
|
decode_macroblock(pbi, xd, mb_col, bc);
|
||||||
#if CONFIG_SUPERBLOCKS
|
#if CONFIG_SUPERBLOCKS
|
||||||
if (xd->mode_info_context->mbmi.encoded_as_sb) {
|
if (xd->mode_info_context->mbmi.encoded_as_sb) {
|
||||||
mi[1].mbmi.txfm_size = mi[0].mbmi.txfm_size;
|
mi[1].mbmi.txfm_size = mi[0].mbmi.txfm_size;
|
||||||
@ -692,7 +693,7 @@ decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check if the boolean decoder has suffered an error */
|
/* check if the boolean decoder has suffered an error */
|
||||||
xd->corrupted |= vp8dx_bool_error(xd->current_bc);
|
xd->corrupted |= vp8dx_bool_error(bc);
|
||||||
|
|
||||||
#if CONFIG_SUPERBLOCKS
|
#if CONFIG_SUPERBLOCKS
|
||||||
if (mi->mbmi.encoded_as_sb) {
|
if (mi->mbmi.encoded_as_sb) {
|
||||||
@ -731,21 +732,17 @@ static int read_is_valid(const unsigned char *start,
|
|||||||
|
|
||||||
|
|
||||||
static void setup_token_decoder(VP8D_COMP *pbi,
|
static void setup_token_decoder(VP8D_COMP *pbi,
|
||||||
const unsigned char *cx_data) {
|
const unsigned char *cx_data,
|
||||||
|
BOOL_DECODER* const bool_decoder) {
|
||||||
VP8_COMMON *pc = &pbi->common;
|
VP8_COMMON *pc = &pbi->common;
|
||||||
const unsigned char *user_data_end = pbi->Source + pbi->source_sz;
|
const unsigned char *user_data_end = pbi->Source + pbi->source_sz;
|
||||||
vp8_reader *bool_decoder;
|
|
||||||
const unsigned char *partition;
|
const unsigned char *partition;
|
||||||
|
|
||||||
ptrdiff_t partition_size;
|
ptrdiff_t partition_size;
|
||||||
ptrdiff_t bytes_left;
|
ptrdiff_t bytes_left;
|
||||||
|
|
||||||
// Dummy read for now
|
|
||||||
vp8_read_literal(&pbi->bc, 2);
|
|
||||||
|
|
||||||
// Set up pointers to token partition
|
// Set up pointers to token partition
|
||||||
partition = cx_data;
|
partition = cx_data;
|
||||||
bool_decoder = &pbi->bc2;
|
|
||||||
bytes_left = user_data_end - partition;
|
bytes_left = user_data_end - partition;
|
||||||
partition_size = bytes_left;
|
partition_size = bytes_left;
|
||||||
|
|
||||||
@ -884,9 +881,8 @@ static void read_coef_probs2(VP8D_COMP *pbi) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void read_coef_probs(VP8D_COMP *pbi) {
|
static void read_coef_probs(VP8D_COMP *pbi, BOOL_DECODER* const bc) {
|
||||||
int i, j, k, l;
|
int i, j, k, l;
|
||||||
vp8_reader *const bc = &pbi->bc;
|
|
||||||
VP8_COMMON *const pc = &pbi->common;
|
VP8_COMMON *const pc = &pbi->common;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1011,7 +1007,7 @@ static void read_coef_probs(VP8D_COMP *pbi) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int vp8_decode_frame(VP8D_COMP *pbi) {
|
int vp8_decode_frame(VP8D_COMP *pbi) {
|
||||||
vp8_reader *const bc = &pbi->bc;
|
BOOL_DECODER header_bc, residual_bc;
|
||||||
VP8_COMMON *const pc = &pbi->common;
|
VP8_COMMON *const pc = &pbi->common;
|
||||||
MACROBLOCKD *const xd = &pbi->mb;
|
MACROBLOCKD *const xd = &pbi->mb;
|
||||||
const unsigned char *data = (const unsigned char *)pbi->Source;
|
const unsigned char *data = (const unsigned char *)pbi->Source;
|
||||||
@ -1099,21 +1095,21 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
|
|
||||||
init_frame(pbi);
|
init_frame(pbi);
|
||||||
|
|
||||||
if (vp8dx_start_decode(bc, data, first_partition_length_in_bytes))
|
if (vp8dx_start_decode(&header_bc, data, first_partition_length_in_bytes))
|
||||||
vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
|
vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
|
||||||
"Failed to allocate bool decoder 0");
|
"Failed to allocate bool decoder 0");
|
||||||
if (pc->frame_type == KEY_FRAME) {
|
if (pc->frame_type == KEY_FRAME) {
|
||||||
pc->clr_type = (YUV_TYPE)vp8_read_bit(bc);
|
pc->clr_type = (YUV_TYPE)vp8_read_bit(&header_bc);
|
||||||
pc->clamp_type = (CLAMP_TYPE)vp8_read_bit(bc);
|
pc->clamp_type = (CLAMP_TYPE)vp8_read_bit(&header_bc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is segmentation enabled */
|
/* Is segmentation enabled */
|
||||||
xd->segmentation_enabled = (unsigned char)vp8_read_bit(bc);
|
xd->segmentation_enabled = (unsigned char)vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
if (xd->segmentation_enabled) {
|
if (xd->segmentation_enabled) {
|
||||||
// Read whether or not the segmentation map is being explicitly
|
// Read whether or not the segmentation map is being explicitly
|
||||||
// updated this frame.
|
// updated this frame.
|
||||||
xd->update_mb_segmentation_map = (unsigned char)vp8_read_bit(bc);
|
xd->update_mb_segmentation_map = (unsigned char)vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
// If so what method will be used.
|
// If so what method will be used.
|
||||||
if (xd->update_mb_segmentation_map) {
|
if (xd->update_mb_segmentation_map) {
|
||||||
@ -1122,28 +1118,28 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
// Read the probs used to decode the segment id for each macro
|
// Read the probs used to decode the segment id for each macro
|
||||||
// block.
|
// block.
|
||||||
for (i = 0; i < MB_FEATURE_TREE_PROBS; i++) {
|
for (i = 0; i < MB_FEATURE_TREE_PROBS; i++) {
|
||||||
xd->mb_segment_tree_probs[i] = vp8_read_bit(bc) ?
|
xd->mb_segment_tree_probs[i] = vp8_read_bit(&header_bc) ?
|
||||||
(vp8_prob)vp8_read_literal(bc, 8) : 255;
|
(vp8_prob)vp8_read_literal(&header_bc, 8) : 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the prediction probs needed to decode the segment id
|
// Read the prediction probs needed to decode the segment id
|
||||||
pc->temporal_update = (unsigned char)vp8_read_bit(bc);
|
pc->temporal_update = (unsigned char)vp8_read_bit(&header_bc);
|
||||||
for (i = 0; i < PREDICTION_PROBS; i++) {
|
for (i = 0; i < PREDICTION_PROBS; i++) {
|
||||||
if (pc->temporal_update) {
|
if (pc->temporal_update) {
|
||||||
pc->segment_pred_probs[i] = vp8_read_bit(bc) ?
|
pc->segment_pred_probs[i] = vp8_read_bit(&header_bc) ?
|
||||||
(vp8_prob)vp8_read_literal(bc, 8) : 255;
|
(vp8_prob)vp8_read_literal(&header_bc, 8) : 255;
|
||||||
} else {
|
} else {
|
||||||
pc->segment_pred_probs[i] = 255;
|
pc->segment_pred_probs[i] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Is the segment data being updated
|
// Is the segment data being updated
|
||||||
xd->update_mb_segmentation_data = (unsigned char)vp8_read_bit(bc);
|
xd->update_mb_segmentation_data = (unsigned char)vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
if (xd->update_mb_segmentation_data) {
|
if (xd->update_mb_segmentation_data) {
|
||||||
int data;
|
int data;
|
||||||
|
|
||||||
xd->mb_segment_abs_delta = (unsigned char)vp8_read_bit(bc);
|
xd->mb_segment_abs_delta = (unsigned char)vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
clearall_segfeatures(xd);
|
clearall_segfeatures(xd);
|
||||||
|
|
||||||
@ -1154,11 +1150,11 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
|
|
||||||
#if CONFIG_FEATUREUPDATES
|
#if CONFIG_FEATUREUPDATES
|
||||||
// feature updated?
|
// feature updated?
|
||||||
if (vp8_read_bit(bc)) {
|
if (vp8_read_bit(&header_bc)) {
|
||||||
int active = 1;
|
int active = 1;
|
||||||
|
|
||||||
if (segfeature_active(xd, i, j))
|
if (segfeature_active(xd, i, j))
|
||||||
active = vp8_read_bit(bc);
|
active = vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
// Is the feature enabled
|
// Is the feature enabled
|
||||||
if (active) {
|
if (active) {
|
||||||
@ -1166,11 +1162,11 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
enable_segfeature(xd, i, j);
|
enable_segfeature(xd, i, j);
|
||||||
|
|
||||||
data = (signed char)vp8_read_literal(
|
data = (signed char)vp8_read_literal(
|
||||||
bc, seg_feature_data_bits(j));
|
&header_bc, seg_feature_data_bits(j));
|
||||||
|
|
||||||
// Is the segment data signed..
|
// Is the segment data signed..
|
||||||
if (is_segfeature_signed(j)) {
|
if (is_segfeature_signed(j)) {
|
||||||
if (vp8_read_bit(bc))
|
if (vp8_read_bit(&header_bc))
|
||||||
data = - data;
|
data = - data;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -1181,16 +1177,16 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
// Is the feature enabled
|
// Is the feature enabled
|
||||||
if (vp8_read_bit(bc)) {
|
if (vp8_read_bit(&header_bc)) {
|
||||||
// Update the feature data and mask
|
// Update the feature data and mask
|
||||||
enable_segfeature(xd, i, j);
|
enable_segfeature(xd, i, j);
|
||||||
|
|
||||||
data = (signed char)vp8_read_literal(
|
data = (signed char)vp8_read_literal(
|
||||||
bc, seg_feature_data_bits(j));
|
&header_bc, seg_feature_data_bits(j));
|
||||||
|
|
||||||
// Is the segment data signed..
|
// Is the segment data signed..
|
||||||
if (is_segfeature_signed(j)) {
|
if (is_segfeature_signed(j)) {
|
||||||
if (vp8_read_bit(bc))
|
if (vp8_read_bit(&header_bc))
|
||||||
data = - data;
|
data = - data;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -1212,81 +1208,84 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
pc->ref_pred_probs[2] = 40;
|
pc->ref_pred_probs[2] = 40;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < PREDICTION_PROBS; i++) {
|
for (i = 0; i < PREDICTION_PROBS; i++) {
|
||||||
if (vp8_read_bit(bc))
|
if (vp8_read_bit(&header_bc))
|
||||||
pc->ref_pred_probs[i] = (vp8_prob)vp8_read_literal(bc, 8);
|
pc->ref_pred_probs[i] = (vp8_prob)vp8_read_literal(&header_bc, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_SUPERBLOCKS
|
#if CONFIG_SUPERBLOCKS
|
||||||
pc->sb_coded = vp8_read_literal(bc, 8);
|
pc->sb_coded = vp8_read_literal(&header_bc, 8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Read the loop filter level and type */
|
/* Read the loop filter level and type */
|
||||||
#if CONFIG_TX_SELECT
|
#if CONFIG_TX_SELECT
|
||||||
pc->txfm_mode = vp8_read_literal(bc, 2);
|
pc->txfm_mode = vp8_read_literal(&header_bc, 2);
|
||||||
if (pc->txfm_mode == TX_MODE_SELECT) {
|
if (pc->txfm_mode == TX_MODE_SELECT) {
|
||||||
pc->prob_tx[0] = vp8_read_literal(bc, 8);
|
pc->prob_tx[0] = vp8_read_literal(&header_bc, 8);
|
||||||
pc->prob_tx[1] = vp8_read_literal(bc, 8);
|
pc->prob_tx[1] = vp8_read_literal(&header_bc, 8);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
pc->txfm_mode = (TXFM_MODE) vp8_read_bit(bc);
|
pc->txfm_mode = (TXFM_MODE) vp8_read_bit(&header_bc);
|
||||||
if (pc->txfm_mode == ALLOW_8X8)
|
if (pc->txfm_mode == ALLOW_8X8)
|
||||||
pc->txfm_mode = ALLOW_16X16;
|
pc->txfm_mode = ALLOW_16X16;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pc->filter_type = (LOOPFILTERTYPE) vp8_read_bit(bc);
|
pc->filter_type = (LOOPFILTERTYPE) vp8_read_bit(&header_bc);
|
||||||
pc->filter_level = vp8_read_literal(bc, 6);
|
pc->filter_level = vp8_read_literal(&header_bc, 6);
|
||||||
pc->sharpness_level = vp8_read_literal(bc, 3);
|
pc->sharpness_level = vp8_read_literal(&header_bc, 3);
|
||||||
|
|
||||||
/* Read in loop filter deltas applied at the MB level based on mode or ref frame. */
|
/* Read in loop filter deltas applied at the MB level based on mode or ref frame. */
|
||||||
xd->mode_ref_lf_delta_update = 0;
|
xd->mode_ref_lf_delta_update = 0;
|
||||||
xd->mode_ref_lf_delta_enabled = (unsigned char)vp8_read_bit(bc);
|
xd->mode_ref_lf_delta_enabled = (unsigned char)vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
if (xd->mode_ref_lf_delta_enabled) {
|
if (xd->mode_ref_lf_delta_enabled) {
|
||||||
/* Do the deltas need to be updated */
|
/* Do the deltas need to be updated */
|
||||||
xd->mode_ref_lf_delta_update = (unsigned char)vp8_read_bit(bc);
|
xd->mode_ref_lf_delta_update = (unsigned char)vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
if (xd->mode_ref_lf_delta_update) {
|
if (xd->mode_ref_lf_delta_update) {
|
||||||
/* Send update */
|
/* Send update */
|
||||||
for (i = 0; i < MAX_REF_LF_DELTAS; i++) {
|
for (i = 0; i < MAX_REF_LF_DELTAS; i++) {
|
||||||
if (vp8_read_bit(bc)) {
|
if (vp8_read_bit(&header_bc)) {
|
||||||
/*sign = vp8_read_bit( bc );*/
|
/*sign = vp8_read_bit( &header_bc );*/
|
||||||
xd->ref_lf_deltas[i] = (signed char)vp8_read_literal(bc, 6);
|
xd->ref_lf_deltas[i] = (signed char)vp8_read_literal(&header_bc, 6);
|
||||||
|
|
||||||
if (vp8_read_bit(bc)) /* Apply sign */
|
if (vp8_read_bit(&header_bc)) /* Apply sign */
|
||||||
xd->ref_lf_deltas[i] = xd->ref_lf_deltas[i] * -1;
|
xd->ref_lf_deltas[i] = xd->ref_lf_deltas[i] * -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send update */
|
/* Send update */
|
||||||
for (i = 0; i < MAX_MODE_LF_DELTAS; i++) {
|
for (i = 0; i < MAX_MODE_LF_DELTAS; i++) {
|
||||||
if (vp8_read_bit(bc)) {
|
if (vp8_read_bit(&header_bc)) {
|
||||||
/*sign = vp8_read_bit( bc );*/
|
/*sign = vp8_read_bit( &header_bc );*/
|
||||||
xd->mode_lf_deltas[i] = (signed char)vp8_read_literal(bc, 6);
|
xd->mode_lf_deltas[i] = (signed char)vp8_read_literal(&header_bc, 6);
|
||||||
|
|
||||||
if (vp8_read_bit(bc)) /* Apply sign */
|
if (vp8_read_bit(&header_bc)) /* Apply sign */
|
||||||
xd->mode_lf_deltas[i] = xd->mode_lf_deltas[i] * -1;
|
xd->mode_lf_deltas[i] = xd->mode_lf_deltas[i] * -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_token_decoder(pbi, data + first_partition_length_in_bytes);
|
// Dummy read for now
|
||||||
|
vp8_read_literal(&header_bc, 2);
|
||||||
|
|
||||||
xd->current_bc = &pbi->bc2;
|
setup_token_decoder(pbi, data + first_partition_length_in_bytes,
|
||||||
|
&residual_bc);
|
||||||
|
|
||||||
/* Read the default quantizers. */
|
/* Read the default quantizers. */
|
||||||
{
|
{
|
||||||
int Q, q_update;
|
int Q, q_update;
|
||||||
|
|
||||||
Q = vp8_read_literal(bc, QINDEX_BITS); /* AC 1st order Q = default */
|
Q = vp8_read_literal(&header_bc, QINDEX_BITS);
|
||||||
pc->base_qindex = Q;
|
pc->base_qindex = Q;
|
||||||
q_update = 0;
|
q_update = 0;
|
||||||
pc->y1dc_delta_q = get_delta_q(bc, pc->y1dc_delta_q, &q_update);
|
/* AC 1st order Q = default */
|
||||||
pc->y2dc_delta_q = get_delta_q(bc, pc->y2dc_delta_q, &q_update);
|
pc->y1dc_delta_q = get_delta_q(&header_bc, pc->y1dc_delta_q, &q_update);
|
||||||
pc->y2ac_delta_q = get_delta_q(bc, pc->y2ac_delta_q, &q_update);
|
pc->y2dc_delta_q = get_delta_q(&header_bc, pc->y2dc_delta_q, &q_update);
|
||||||
pc->uvdc_delta_q = get_delta_q(bc, pc->uvdc_delta_q, &q_update);
|
pc->y2ac_delta_q = get_delta_q(&header_bc, pc->y2ac_delta_q, &q_update);
|
||||||
pc->uvac_delta_q = get_delta_q(bc, pc->uvac_delta_q, &q_update);
|
pc->uvdc_delta_q = get_delta_q(&header_bc, pc->uvdc_delta_q, &q_update);
|
||||||
|
pc->uvac_delta_q = get_delta_q(&header_bc, pc->uvac_delta_q, &q_update);
|
||||||
|
|
||||||
if (q_update)
|
if (q_update)
|
||||||
vp8cx_init_de_quantizer(pbi);
|
vp8cx_init_de_quantizer(pbi);
|
||||||
@ -1301,8 +1300,8 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
*/
|
*/
|
||||||
if (pc->frame_type != KEY_FRAME) {
|
if (pc->frame_type != KEY_FRAME) {
|
||||||
/* Should the GF or ARF be updated from the current frame */
|
/* Should the GF or ARF be updated from the current frame */
|
||||||
pc->refresh_golden_frame = vp8_read_bit(bc);
|
pc->refresh_golden_frame = vp8_read_bit(&header_bc);
|
||||||
pc->refresh_alt_ref_frame = vp8_read_bit(bc);
|
pc->refresh_alt_ref_frame = vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
if (pc->refresh_alt_ref_frame) {
|
if (pc->refresh_alt_ref_frame) {
|
||||||
vpx_memcpy(&pc->fc, &pc->lfc_a, sizeof(pc->fc));
|
vpx_memcpy(&pc->fc, &pc->lfc_a, sizeof(pc->fc));
|
||||||
@ -1320,37 +1319,38 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
pc->copy_buffer_to_gf = 0;
|
pc->copy_buffer_to_gf = 0;
|
||||||
|
|
||||||
if (!pc->refresh_golden_frame)
|
if (!pc->refresh_golden_frame)
|
||||||
pc->copy_buffer_to_gf = vp8_read_literal(bc, 2);
|
pc->copy_buffer_to_gf = vp8_read_literal(&header_bc, 2);
|
||||||
|
|
||||||
pc->copy_buffer_to_arf = 0;
|
pc->copy_buffer_to_arf = 0;
|
||||||
|
|
||||||
if (!pc->refresh_alt_ref_frame)
|
if (!pc->refresh_alt_ref_frame)
|
||||||
pc->copy_buffer_to_arf = vp8_read_literal(bc, 2);
|
pc->copy_buffer_to_arf = vp8_read_literal(&header_bc, 2);
|
||||||
|
|
||||||
pc->ref_frame_sign_bias[GOLDEN_FRAME] = vp8_read_bit(bc);
|
pc->ref_frame_sign_bias[GOLDEN_FRAME] = vp8_read_bit(&header_bc);
|
||||||
pc->ref_frame_sign_bias[ALTREF_FRAME] = vp8_read_bit(bc);
|
pc->ref_frame_sign_bias[ALTREF_FRAME] = vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
/* Is high precision mv allowed */
|
/* Is high precision mv allowed */
|
||||||
xd->allow_high_precision_mv = (unsigned char)vp8_read_bit(bc);
|
xd->allow_high_precision_mv = (unsigned char)vp8_read_bit(&header_bc);
|
||||||
// Read the type of subpel filter to use
|
// Read the type of subpel filter to use
|
||||||
#if CONFIG_SWITCHABLE_INTERP
|
#if CONFIG_SWITCHABLE_INTERP
|
||||||
if (vp8_read_bit(bc)) {
|
if (vp8_read_bit(&header_bc)) {
|
||||||
pc->mcomp_filter_type = SWITCHABLE;
|
pc->mcomp_filter_type = SWITCHABLE;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
pc->mcomp_filter_type = vp8_read_literal(bc, 2);
|
pc->mcomp_filter_type = vp8_read_literal(&header_bc, 2);
|
||||||
}
|
}
|
||||||
/* To enable choice of different interploation filters */
|
/* To enable choice of different interploation filters */
|
||||||
vp8_setup_interp_filters(xd, pc->mcomp_filter_type, pc);
|
vp8_setup_interp_filters(xd, pc->mcomp_filter_type, pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
pc->refresh_entropy_probs = vp8_read_bit(bc);
|
pc->refresh_entropy_probs = vp8_read_bit(&header_bc);
|
||||||
if (pc->refresh_entropy_probs == 0) {
|
if (pc->refresh_entropy_probs == 0) {
|
||||||
vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
|
vpx_memcpy(&pc->lfc, &pc->fc, sizeof(pc->fc));
|
||||||
}
|
}
|
||||||
|
|
||||||
pc->refresh_last_frame = pc->frame_type == KEY_FRAME || vp8_read_bit(bc);
|
pc->refresh_last_frame = (pc->frame_type == KEY_FRAME)
|
||||||
|
|| vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
FILE *z = fopen("decodestats.stt", "a");
|
FILE *z = fopen("decodestats.stt", "a");
|
||||||
@ -1421,7 +1421,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
vp8_zero(pbi->common.fc.mv_ref_ct);
|
vp8_zero(pbi->common.fc.mv_ref_ct);
|
||||||
vp8_zero(pbi->common.fc.mv_ref_ct_a);
|
vp8_zero(pbi->common.fc.mv_ref_ct_a);
|
||||||
|
|
||||||
read_coef_probs(pbi);
|
read_coef_probs(pbi, &header_bc);
|
||||||
|
|
||||||
vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->lst_fb_idx], sizeof(YV12_BUFFER_CONFIG));
|
vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->lst_fb_idx], sizeof(YV12_BUFFER_CONFIG));
|
||||||
vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], sizeof(YV12_BUFFER_CONFIG));
|
vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], sizeof(YV12_BUFFER_CONFIG));
|
||||||
@ -1442,9 +1442,9 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff));
|
vpx_memset(xd->qcoeff, 0, sizeof(xd->qcoeff));
|
||||||
|
|
||||||
/* Read the mb_no_coeff_skip flag */
|
/* Read the mb_no_coeff_skip flag */
|
||||||
pc->mb_no_coeff_skip = (int)vp8_read_bit(bc);
|
pc->mb_no_coeff_skip = (int)vp8_read_bit(&header_bc);
|
||||||
|
|
||||||
vpx_decode_mode_mvs_init(pbi);
|
vpx_decode_mode_mvs_init(pbi, &header_bc);
|
||||||
|
|
||||||
vpx_memset(pc->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * pc->mb_cols);
|
vpx_memset(pc->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * pc->mb_cols);
|
||||||
|
|
||||||
@ -1454,13 +1454,13 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
|
|
||||||
/* Decode a row of superblocks */
|
/* Decode a row of superblocks */
|
||||||
for (mb_row = 0; mb_row < pc->mb_rows; mb_row += 2) {
|
for (mb_row = 0; mb_row < pc->mb_rows; mb_row += 2) {
|
||||||
decode_sb_row(pbi, pc, mb_row, xd);
|
decode_sb_row(pbi, pc, mb_row, xd, &residual_bc);
|
||||||
}
|
}
|
||||||
corrupt_tokens |= xd->corrupted;
|
corrupt_tokens |= xd->corrupted;
|
||||||
|
|
||||||
/* Collect information about decoder corruption. */
|
/* Collect information about decoder corruption. */
|
||||||
/* 1. Check first boolean decoder for errors. */
|
/* 1. Check first boolean decoder for errors. */
|
||||||
pc->yv12_fb[pc->new_fb_idx].corrupted = vp8dx_bool_error(bc);
|
pc->yv12_fb[pc->new_fb_idx].corrupted = vp8dx_bool_error(&header_bc);
|
||||||
/* 2. Check the macroblock information */
|
/* 2. Check the macroblock information */
|
||||||
pc->yv12_fb[pc->new_fb_idx].corrupted |= corrupt_tokens;
|
pc->yv12_fb[pc->new_fb_idx].corrupted |= corrupt_tokens;
|
||||||
|
|
||||||
@ -1473,7 +1473,6 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
"A stream must start with a complete key frame");
|
"A stream must start with a complete key frame");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vpx_log("Decoder: Frame Decoded, Size Roughly:%d bytes \n",bc->pos+pbi->bc2.pos); */
|
|
||||||
vp8_adapt_coef_probs(pc);
|
vp8_adapt_coef_probs(pc);
|
||||||
if (pc->frame_type != KEY_FRAME) {
|
if (pc->frame_type != KEY_FRAME) {
|
||||||
vp8_adapt_mode_probs(pc);
|
vp8_adapt_mode_probs(pc);
|
||||||
@ -1500,7 +1499,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
|
|||||||
#ifdef PACKET_TESTING
|
#ifdef PACKET_TESTING
|
||||||
{
|
{
|
||||||
FILE *f = fopen("decompressor.VP8", "ab");
|
FILE *f = fopen("decompressor.VP8", "ab");
|
||||||
unsigned int size = pbi->bc2.pos + pbi->bc.pos + 8;
|
unsigned int size = residual_bc.pos + header_bc.pos + 8;
|
||||||
fwrite((void *) &size, 4, 1, f);
|
fwrite((void *) &size, 4, 1, f);
|
||||||
fwrite((void *) pbi->Source, size, 1, f);
|
fwrite((void *) pbi->Source, size, 1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -302,17 +302,17 @@ static int vp8_get_signed(BOOL_DECODER *br, int value_to_sign) {
|
|||||||
val += (UINT16)(1 << bits_count);\
|
val += (UINT16)(1 << bits_count);\
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
static int vp8_decode_coefs(VP8D_COMP *dx, const MACROBLOCKD *xd,
|
static int decode_coefs(VP8D_COMP *dx, const MACROBLOCKD *xd,
|
||||||
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
|
BOOL_DECODER* const br,
|
||||||
PLANE_TYPE type,
|
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
|
||||||
|
PLANE_TYPE type,
|
||||||
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
||||||
TX_TYPE tx_type,
|
TX_TYPE tx_type,
|
||||||
#endif
|
#endif
|
||||||
int seg_eob, INT16 *qcoeff_ptr, int i,
|
int seg_eob, INT16 *qcoeff_ptr, int i,
|
||||||
const int *const scan, int block_type,
|
const int *const scan, int block_type,
|
||||||
const int *coef_bands) {
|
const int *coef_bands) {
|
||||||
FRAME_CONTEXT *const fc = &dx->common.fc;
|
FRAME_CONTEXT *const fc = &dx->common.fc;
|
||||||
BOOL_DECODER *br = xd->current_bc;
|
|
||||||
int tmp, c = (type == PLANE_TYPE_Y_NO_DC);
|
int tmp, c = (type == PLANE_TYPE_Y_NO_DC);
|
||||||
const vp8_prob *prob, *coef_probs;
|
const vp8_prob *prob, *coef_probs;
|
||||||
|
|
||||||
@ -446,7 +446,8 @@ SKIP_START:
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vp8_decode_mb_tokens_16x16(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
int vp8_decode_mb_tokens_16x16(VP8D_COMP *pbi, MACROBLOCKD *xd,
|
||||||
|
BOOL_DECODER* const bc) {
|
||||||
ENTROPY_CONTEXT* const A = (ENTROPY_CONTEXT *)xd->above_context;
|
ENTROPY_CONTEXT* const A = (ENTROPY_CONTEXT *)xd->above_context;
|
||||||
ENTROPY_CONTEXT* const L = (ENTROPY_CONTEXT *)xd->left_context;
|
ENTROPY_CONTEXT* const L = (ENTROPY_CONTEXT *)xd->left_context;
|
||||||
|
|
||||||
@ -473,12 +474,12 @@ int vp8_decode_mb_tokens_16x16(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
|||||||
// Luma block
|
// Luma block
|
||||||
{
|
{
|
||||||
const int* const scan = vp8_default_zig_zag1d_16x16;
|
const int* const scan = vp8_default_zig_zag1d_16x16;
|
||||||
c = vp8_decode_coefs(pbi, xd, A, L, type,
|
c = decode_coefs(pbi, xd, bc, A, L, type,
|
||||||
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
||||||
tx_type,
|
tx_type,
|
||||||
#endif
|
#endif
|
||||||
seg_eob, qcoeff_ptr,
|
seg_eob, qcoeff_ptr,
|
||||||
0, scan, TX_16X16, coef_bands_x_16x16);
|
0, scan, TX_16X16, coef_bands_x_16x16);
|
||||||
eobs[0] = c;
|
eobs[0] = c;
|
||||||
*A = *L = (c != !type);
|
*A = *L = (c != !type);
|
||||||
for (i = 1; i < 16; i++) {
|
for (i = 1; i < 16; i++) {
|
||||||
@ -503,12 +504,12 @@ int vp8_decode_mb_tokens_16x16(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
|||||||
ENTROPY_CONTEXT* const l = L + vp8_block2left_8x8[i];
|
ENTROPY_CONTEXT* const l = L + vp8_block2left_8x8[i];
|
||||||
const int* const scan = vp8_default_zig_zag1d_8x8;
|
const int* const scan = vp8_default_zig_zag1d_8x8;
|
||||||
|
|
||||||
c = vp8_decode_coefs(pbi, xd, a, l, type,
|
c = decode_coefs(pbi, xd, bc, a, l, type,
|
||||||
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
||||||
tx_type,
|
tx_type,
|
||||||
#endif
|
#endif
|
||||||
seg_eob, qcoeff_ptr,
|
seg_eob, qcoeff_ptr,
|
||||||
i, scan, TX_8X8, coef_bands_x_8x8);
|
i, scan, TX_8X8, coef_bands_x_8x8);
|
||||||
a[0] = l[0] = ((eobs[i] = c) != !type);
|
a[0] = l[0] = ((eobs[i] = c) != !type);
|
||||||
a[1] = a[0];
|
a[1] = a[0];
|
||||||
l[1] = l[0];
|
l[1] = l[0];
|
||||||
@ -521,7 +522,8 @@ int vp8_decode_mb_tokens_16x16(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
|||||||
return eobtotal;
|
return eobtotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd,
|
||||||
|
BOOL_DECODER* const bc) {
|
||||||
ENTROPY_CONTEXT *const A = (ENTROPY_CONTEXT *)xd->above_context;
|
ENTROPY_CONTEXT *const A = (ENTROPY_CONTEXT *)xd->above_context;
|
||||||
ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
|
ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
|
||||||
|
|
||||||
@ -548,12 +550,12 @@ int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
|||||||
seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
|
seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
|
||||||
else
|
else
|
||||||
seg_eob = 4;
|
seg_eob = 4;
|
||||||
c = vp8_decode_coefs(pbi, xd, a, l, type,
|
c = decode_coefs(pbi, xd, bc, a, l, type,
|
||||||
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
||||||
tx_type,
|
tx_type,
|
||||||
#endif
|
#endif
|
||||||
seg_eob, qcoeff_ptr + 24 * 16,
|
seg_eob, qcoeff_ptr + 24 * 16,
|
||||||
24, scan, TX_8X8, coef_bands_x);
|
24, scan, TX_8X8, coef_bands_x);
|
||||||
a[0] = l[0] = ((eobs[24] = c) != !type);
|
a[0] = l[0] = ((eobs[24] = c) != !type);
|
||||||
|
|
||||||
eobtotal += c - 4;
|
eobtotal += c - 4;
|
||||||
@ -583,12 +585,12 @@ int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
c = vp8_decode_coefs(pbi, xd, a, l, type,
|
c = decode_coefs(pbi, xd, bc, a, l, type,
|
||||||
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
||||||
tx_type,
|
tx_type,
|
||||||
#endif
|
#endif
|
||||||
seg_eob, qcoeff_ptr,
|
seg_eob, qcoeff_ptr,
|
||||||
i, scan, TX_8X8, coef_bands_x_8x8);
|
i, scan, TX_8X8, coef_bands_x_8x8);
|
||||||
a[0] = l[0] = ((eobs[i] = c) != !type);
|
a[0] = l[0] = ((eobs[i] = c) != !type);
|
||||||
a[1] = a[0];
|
a[1] = a[0];
|
||||||
l[1] = l[0];
|
l[1] = l[0];
|
||||||
@ -610,12 +612,12 @@ int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
|||||||
ENTROPY_CONTEXT *const l = L + vp8_block2left[i];
|
ENTROPY_CONTEXT *const l = L + vp8_block2left[i];
|
||||||
const int *scan = vp8_default_zig_zag1d;
|
const int *scan = vp8_default_zig_zag1d;
|
||||||
|
|
||||||
c = vp8_decode_coefs(pbi, xd, a, l, type,
|
c = decode_coefs(pbi, xd, bc, a, l, type,
|
||||||
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
||||||
tx_type,
|
tx_type,
|
||||||
#endif
|
#endif
|
||||||
seg_eob, qcoeff_ptr,
|
seg_eob, qcoeff_ptr,
|
||||||
i, scan, TX_4X4, coef_bands_x);
|
i, scan, TX_4X4, coef_bands_x);
|
||||||
a[0] = l[0] = ((eobs[i] = c) != !type);
|
a[0] = l[0] = ((eobs[i] = c) != !type);
|
||||||
|
|
||||||
eobtotal += c;
|
eobtotal += c;
|
||||||
@ -627,7 +629,8 @@ int vp8_decode_mb_tokens_8x8(VP8D_COMP *pbi, MACROBLOCKD *xd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd) {
|
int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd,
|
||||||
|
BOOL_DECODER* const bc) {
|
||||||
ENTROPY_CONTEXT *const A = (ENTROPY_CONTEXT *)xd->above_context;
|
ENTROPY_CONTEXT *const A = (ENTROPY_CONTEXT *)xd->above_context;
|
||||||
ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
|
ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
|
||||||
|
|
||||||
@ -648,12 +651,12 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd) {
|
|||||||
ENTROPY_CONTEXT *const l = L + vp8_block2left[24];
|
ENTROPY_CONTEXT *const l = L + vp8_block2left[24];
|
||||||
type = PLANE_TYPE_Y2;
|
type = PLANE_TYPE_Y2;
|
||||||
|
|
||||||
c = vp8_decode_coefs(dx, xd, a, l, type,
|
c = decode_coefs(dx, xd, bc, a, l, type,
|
||||||
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
||||||
DCT_DCT,
|
DCT_DCT,
|
||||||
#endif
|
#endif
|
||||||
seg_eob, qcoeff_ptr + 24 * 16, 24,
|
seg_eob, qcoeff_ptr + 24 * 16, 24,
|
||||||
scan, TX_4X4, coef_bands_x);
|
scan, TX_4X4, coef_bands_x);
|
||||||
a[0] = l[0] = ((eobs[24] = c) != !type);
|
a[0] = l[0] = ((eobs[24] = c) != !type);
|
||||||
eobtotal += c - 16;
|
eobtotal += c - 16;
|
||||||
|
|
||||||
@ -688,12 +691,12 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
c = vp8_decode_coefs(dx, xd, a, l, type,
|
c = decode_coefs(dx, xd, bc, a, l, type,
|
||||||
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
|
||||||
tx_type,
|
tx_type,
|
||||||
#endif
|
#endif
|
||||||
seg_eob, qcoeff_ptr,
|
seg_eob, qcoeff_ptr,
|
||||||
i, scan, TX_4X4, coef_bands_x);
|
i, scan, TX_4X4, coef_bands_x);
|
||||||
a[0] = l[0] = ((eobs[i] = c) != !type);
|
a[0] = l[0] = ((eobs[i] = c) != !type);
|
||||||
|
|
||||||
eobtotal += c;
|
eobtotal += c;
|
||||||
|
@ -14,9 +14,12 @@
|
|||||||
|
|
||||||
#include "onyxd_int.h"
|
#include "onyxd_int.h"
|
||||||
|
|
||||||
void vp8_reset_mb_tokens_context(MACROBLOCKD *xd);
|
void vp8_reset_mb_tokens_context(MACROBLOCKD* const);
|
||||||
int vp8_decode_mb_tokens(VP8D_COMP *, MACROBLOCKD *);
|
int vp8_decode_mb_tokens(VP8D_COMP* const, MACROBLOCKD* const,
|
||||||
int vp8_decode_mb_tokens_8x8(VP8D_COMP *, MACROBLOCKD *);
|
BOOL_DECODER* const);
|
||||||
int vp8_decode_mb_tokens_16x16(VP8D_COMP *, MACROBLOCKD *);
|
int vp8_decode_mb_tokens_8x8(VP8D_COMP* const, MACROBLOCKD* const,
|
||||||
|
BOOL_DECODER* const);
|
||||||
|
int vp8_decode_mb_tokens_16x16(VP8D_COMP* const, MACROBLOCKD* const,
|
||||||
|
BOOL_DECODER* const);
|
||||||
|
|
||||||
#endif /* DETOKENIZE_H */
|
#endif /* DETOKENIZE_H */
|
||||||
|
@ -45,7 +45,6 @@ typedef struct {
|
|||||||
ENTROPY_CONTEXT_PLANES *L;
|
ENTROPY_CONTEXT_PLANES *L;
|
||||||
|
|
||||||
INT16 *qcoeff_start_ptr;
|
INT16 *qcoeff_start_ptr;
|
||||||
BOOL_DECODER *current_bc;
|
|
||||||
|
|
||||||
vp8_prob const *coef_probs[BLOCK_TYPES];
|
vp8_prob const *coef_probs[BLOCK_TYPES];
|
||||||
vp8_prob const *coef_probs_8x8[BLOCK_TYPES_8X8];
|
vp8_prob const *coef_probs_8x8[BLOCK_TYPES_8X8];
|
||||||
@ -60,8 +59,6 @@ typedef struct VP8Decompressor {
|
|||||||
|
|
||||||
DECLARE_ALIGNED(16, VP8_COMMON, common);
|
DECLARE_ALIGNED(16, VP8_COMMON, common);
|
||||||
|
|
||||||
vp8_reader bc, bc2;
|
|
||||||
|
|
||||||
VP8D_CONFIG oxcf;
|
VP8D_CONFIG oxcf;
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,6 @@ DEFINE(vp8_extra_bit_struct_base_val, offsetof(vp8_extra_bit_struct, b
|
|||||||
|
|
||||||
DEFINE(vp8_comp_tplist, offsetof(VP8_COMP, tplist));
|
DEFINE(vp8_comp_tplist, offsetof(VP8_COMP, tplist));
|
||||||
DEFINE(vp8_comp_common, offsetof(VP8_COMP, common));
|
DEFINE(vp8_comp_common, offsetof(VP8_COMP, common));
|
||||||
DEFINE(vp8_comp_bc2, offsetof(VP8_COMP, bc2));
|
|
||||||
|
|
||||||
DEFINE(tokenlist_start, offsetof(TOKENLIST, start));
|
DEFINE(tokenlist_start, offsetof(TOKENLIST, start));
|
||||||
DEFINE(tokenlist_stop, offsetof(TOKENLIST, stop));
|
DEFINE(tokenlist_stop, offsetof(TOKENLIST, stop));
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -28,38 +28,38 @@ extern unsigned int active_section;
|
|||||||
nmv_context_counts tnmvcounts;
|
nmv_context_counts tnmvcounts;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void encode_nmv_component(vp8_writer *w,
|
static void encode_nmv_component(vp8_writer* const bc,
|
||||||
int v,
|
int v,
|
||||||
int r,
|
int r,
|
||||||
const nmv_component *mvcomp) {
|
const nmv_component* const mvcomp) {
|
||||||
int s, z, c, o, d;
|
int s, z, c, o, d;
|
||||||
assert (v != 0); /* should not be zero */
|
assert (v != 0); /* should not be zero */
|
||||||
s = v < 0;
|
s = v < 0;
|
||||||
vp8_write(w, s, mvcomp->sign);
|
vp8_write(bc, s, mvcomp->sign);
|
||||||
z = (s ? -v : v) - 1; /* magnitude - 1 */
|
z = (s ? -v : v) - 1; /* magnitude - 1 */
|
||||||
|
|
||||||
c = vp8_get_mv_class(z, &o);
|
c = vp8_get_mv_class(z, &o);
|
||||||
|
|
||||||
vp8_write_token(w, vp8_mv_class_tree, mvcomp->classes,
|
vp8_write_token(bc, vp8_mv_class_tree, mvcomp->classes,
|
||||||
vp8_mv_class_encodings + c);
|
vp8_mv_class_encodings + c);
|
||||||
|
|
||||||
d = (o >> 3); /* int mv data */
|
d = (o >> 3); /* int mv data */
|
||||||
|
|
||||||
if (c == MV_CLASS_0) {
|
if (c == MV_CLASS_0) {
|
||||||
vp8_write_token(w, vp8_mv_class0_tree, mvcomp->class0,
|
vp8_write_token(bc, vp8_mv_class0_tree, mvcomp->class0,
|
||||||
vp8_mv_class0_encodings + d);
|
vp8_mv_class0_encodings + d);
|
||||||
} else {
|
} else {
|
||||||
int i, b;
|
int i, b;
|
||||||
b = c + CLASS0_BITS - 1; /* number of bits */
|
b = c + CLASS0_BITS - 1; /* number of bits */
|
||||||
for (i = 0; i < b; ++i)
|
for (i = 0; i < b; ++i)
|
||||||
vp8_write(w, ((d >> i) & 1), mvcomp->bits[i]);
|
vp8_write(bc, ((d >> i) & 1), mvcomp->bits[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void encode_nmv_component_fp(vp8_writer *w,
|
static void encode_nmv_component_fp(vp8_writer *bc,
|
||||||
int v,
|
int v,
|
||||||
int r,
|
int r,
|
||||||
const nmv_component *mvcomp,
|
const nmv_component* const mvcomp,
|
||||||
int usehp) {
|
int usehp) {
|
||||||
int s, z, c, o, d, f, e;
|
int s, z, c, o, d, f, e;
|
||||||
assert (v != 0); /* should not be zero */
|
assert (v != 0); /* should not be zero */
|
||||||
@ -74,24 +74,24 @@ static void encode_nmv_component_fp(vp8_writer *w,
|
|||||||
|
|
||||||
/* Code the fractional pel bits */
|
/* Code the fractional pel bits */
|
||||||
if (c == MV_CLASS_0) {
|
if (c == MV_CLASS_0) {
|
||||||
vp8_write_token(w, vp8_mv_fp_tree, mvcomp->class0_fp[d],
|
vp8_write_token(bc, vp8_mv_fp_tree, mvcomp->class0_fp[d],
|
||||||
vp8_mv_fp_encodings + f);
|
vp8_mv_fp_encodings + f);
|
||||||
} else {
|
} else {
|
||||||
vp8_write_token(w, vp8_mv_fp_tree, mvcomp->fp,
|
vp8_write_token(bc, vp8_mv_fp_tree, mvcomp->fp,
|
||||||
vp8_mv_fp_encodings + f);
|
vp8_mv_fp_encodings + f);
|
||||||
}
|
}
|
||||||
/* Code the high precision bit */
|
/* Code the high precision bit */
|
||||||
if (usehp) {
|
if (usehp) {
|
||||||
if (c == MV_CLASS_0) {
|
if (c == MV_CLASS_0) {
|
||||||
vp8_write(w, e, mvcomp->class0_hp);
|
vp8_write(bc, e, mvcomp->class0_hp);
|
||||||
} else {
|
} else {
|
||||||
vp8_write(w, e, mvcomp->hp);
|
vp8_write(bc, e, mvcomp->hp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void build_nmv_component_cost_table(int *mvcost,
|
static void build_nmv_component_cost_table(int *mvcost,
|
||||||
const nmv_component *mvcomp,
|
const nmv_component* const mvcomp,
|
||||||
int usehp) {
|
int usehp) {
|
||||||
int i, v;
|
int i, v;
|
||||||
int sign_cost[2], class_cost[MV_CLASSES], class0_cost[CLASS0_SIZE];
|
int sign_cost[2], class_cost[MV_CLASSES], class0_cost[CLASS0_SIZE];
|
||||||
@ -177,7 +177,7 @@ static int update_nmv_savings(const unsigned int ct[2],
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int update_nmv(
|
static int update_nmv(
|
||||||
vp8_writer *const w,
|
vp8_writer *const bc,
|
||||||
const unsigned int ct[2],
|
const unsigned int ct[2],
|
||||||
vp8_prob *const cur_p,
|
vp8_prob *const cur_p,
|
||||||
const vp8_prob new_p,
|
const vp8_prob new_p,
|
||||||
@ -199,15 +199,15 @@ static int update_nmv(
|
|||||||
|
|
||||||
if (cur_b - mod_b > cost) {
|
if (cur_b - mod_b > cost) {
|
||||||
*cur_p = mod_p;
|
*cur_p = mod_p;
|
||||||
vp8_write(w, 1, upd_p);
|
vp8_write(bc, 1, upd_p);
|
||||||
#ifdef LOW_PRECISION_MV_UPDATE
|
#ifdef LOW_PRECISION_MV_UPDATE
|
||||||
vp8_write_literal(w, mod_p >> 1, 7);
|
vp8_write_literal(bc, mod_p >> 1, 7);
|
||||||
#else
|
#else
|
||||||
vp8_write_literal(w, mod_p, 8);
|
vp8_write_literal(bc, mod_p, 8);
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
vp8_write(w, 0, upd_p);
|
vp8_write(bc, 0, upd_p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,7 +318,8 @@ void print_nmvstats() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_nmvcount(nmv_context_counts *dst, nmv_context_counts *src) {
|
static void add_nmvcount(nmv_context_counts* const dst,
|
||||||
|
const nmv_context_counts* const src) {
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
for (j = 0; j < MV_JOINTS; ++j) {
|
for (j = 0; j < MV_JOINTS; ++j) {
|
||||||
dst->joints[j] += src->joints[j];
|
dst->joints[j] += src->joints[j];
|
||||||
@ -357,8 +358,7 @@ static void add_nmvcount(nmv_context_counts *dst, nmv_context_counts *src) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void vp8_write_nmvprobs(VP8_COMP * cpi, int usehp) {
|
void vp8_write_nmvprobs(VP8_COMP* const cpi, int usehp, vp8_writer* const bc) {
|
||||||
vp8_writer *const w = &cpi->bc;
|
|
||||||
int i, j;
|
int i, j;
|
||||||
nmv_context prob;
|
nmv_context prob;
|
||||||
unsigned int branch_ct_joint[MV_JOINTS - 1][2];
|
unsigned int branch_ct_joint[MV_JOINTS - 1][2];
|
||||||
@ -443,37 +443,37 @@ void vp8_write_nmvprobs(VP8_COMP * cpi, int usehp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (savings <= 0) {
|
if (savings <= 0) {
|
||||||
vp8_write_bit(w, 0);
|
vp8_write_bit(bc, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vp8_write_bit(w, 1);
|
vp8_write_bit(bc, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (j = 0; j < MV_JOINTS - 1; ++j) {
|
for (j = 0; j < MV_JOINTS - 1; ++j) {
|
||||||
update_nmv(w, branch_ct_joint[j],
|
update_nmv(bc, branch_ct_joint[j],
|
||||||
&cpi->common.fc.nmvc.joints[j],
|
&cpi->common.fc.nmvc.joints[j],
|
||||||
prob.joints[j],
|
prob.joints[j],
|
||||||
VP8_NMV_UPDATE_PROB);
|
VP8_NMV_UPDATE_PROB);
|
||||||
}
|
}
|
||||||
for (i = 0; i < 2; ++i) {
|
for (i = 0; i < 2; ++i) {
|
||||||
update_nmv(w, branch_ct_sign[i],
|
update_nmv(bc, branch_ct_sign[i],
|
||||||
&cpi->common.fc.nmvc.comps[i].sign,
|
&cpi->common.fc.nmvc.comps[i].sign,
|
||||||
prob.comps[i].sign,
|
prob.comps[i].sign,
|
||||||
VP8_NMV_UPDATE_PROB);
|
VP8_NMV_UPDATE_PROB);
|
||||||
for (j = 0; j < MV_CLASSES - 1; ++j) {
|
for (j = 0; j < MV_CLASSES - 1; ++j) {
|
||||||
update_nmv(w, branch_ct_classes[i][j],
|
update_nmv(bc, branch_ct_classes[i][j],
|
||||||
&cpi->common.fc.nmvc.comps[i].classes[j],
|
&cpi->common.fc.nmvc.comps[i].classes[j],
|
||||||
prob.comps[i].classes[j],
|
prob.comps[i].classes[j],
|
||||||
VP8_NMV_UPDATE_PROB);
|
VP8_NMV_UPDATE_PROB);
|
||||||
}
|
}
|
||||||
for (j = 0; j < CLASS0_SIZE - 1; ++j) {
|
for (j = 0; j < CLASS0_SIZE - 1; ++j) {
|
||||||
update_nmv(w, branch_ct_class0[i][j],
|
update_nmv(bc, branch_ct_class0[i][j],
|
||||||
&cpi->common.fc.nmvc.comps[i].class0[j],
|
&cpi->common.fc.nmvc.comps[i].class0[j],
|
||||||
prob.comps[i].class0[j],
|
prob.comps[i].class0[j],
|
||||||
VP8_NMV_UPDATE_PROB);
|
VP8_NMV_UPDATE_PROB);
|
||||||
}
|
}
|
||||||
for (j = 0; j < MV_OFFSET_BITS; ++j) {
|
for (j = 0; j < MV_OFFSET_BITS; ++j) {
|
||||||
update_nmv(w, branch_ct_bits[i][j],
|
update_nmv(bc, branch_ct_bits[i][j],
|
||||||
&cpi->common.fc.nmvc.comps[i].bits[j],
|
&cpi->common.fc.nmvc.comps[i].bits[j],
|
||||||
prob.comps[i].bits[j],
|
prob.comps[i].bits[j],
|
||||||
VP8_NMV_UPDATE_PROB);
|
VP8_NMV_UPDATE_PROB);
|
||||||
@ -483,14 +483,14 @@ void vp8_write_nmvprobs(VP8_COMP * cpi, int usehp) {
|
|||||||
for (j = 0; j < CLASS0_SIZE; ++j) {
|
for (j = 0; j < CLASS0_SIZE; ++j) {
|
||||||
int k;
|
int k;
|
||||||
for (k = 0; k < 3; ++k) {
|
for (k = 0; k < 3; ++k) {
|
||||||
update_nmv(w, branch_ct_class0_fp[i][j][k],
|
update_nmv(bc, branch_ct_class0_fp[i][j][k],
|
||||||
&cpi->common.fc.nmvc.comps[i].class0_fp[j][k],
|
&cpi->common.fc.nmvc.comps[i].class0_fp[j][k],
|
||||||
prob.comps[i].class0_fp[j][k],
|
prob.comps[i].class0_fp[j][k],
|
||||||
VP8_NMV_UPDATE_PROB);
|
VP8_NMV_UPDATE_PROB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (j = 0; j < 3; ++j) {
|
for (j = 0; j < 3; ++j) {
|
||||||
update_nmv(w, branch_ct_fp[i][j],
|
update_nmv(bc, branch_ct_fp[i][j],
|
||||||
&cpi->common.fc.nmvc.comps[i].fp[j],
|
&cpi->common.fc.nmvc.comps[i].fp[j],
|
||||||
prob.comps[i].fp[j],
|
prob.comps[i].fp[j],
|
||||||
VP8_NMV_UPDATE_PROB);
|
VP8_NMV_UPDATE_PROB);
|
||||||
@ -498,11 +498,11 @@ void vp8_write_nmvprobs(VP8_COMP * cpi, int usehp) {
|
|||||||
}
|
}
|
||||||
if (usehp) {
|
if (usehp) {
|
||||||
for (i = 0; i < 2; ++i) {
|
for (i = 0; i < 2; ++i) {
|
||||||
update_nmv(w, branch_ct_class0_hp[i],
|
update_nmv(bc, branch_ct_class0_hp[i],
|
||||||
&cpi->common.fc.nmvc.comps[i].class0_hp,
|
&cpi->common.fc.nmvc.comps[i].class0_hp,
|
||||||
prob.comps[i].class0_hp,
|
prob.comps[i].class0_hp,
|
||||||
VP8_NMV_UPDATE_PROB);
|
VP8_NMV_UPDATE_PROB);
|
||||||
update_nmv(w, branch_ct_hp[i],
|
update_nmv(bc, branch_ct_hp[i],
|
||||||
&cpi->common.fc.nmvc.comps[i].hp,
|
&cpi->common.fc.nmvc.comps[i].hp,
|
||||||
prob.comps[i].hp,
|
prob.comps[i].hp,
|
||||||
VP8_NMV_UPDATE_PROB);
|
VP8_NMV_UPDATE_PROB);
|
||||||
@ -510,34 +510,35 @@ void vp8_write_nmvprobs(VP8_COMP * cpi, int usehp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp8_encode_nmv(vp8_writer *w, const MV *mv, const MV *ref,
|
void vp8_encode_nmv(vp8_writer* const bc, const MV* const mv,
|
||||||
const nmv_context *mvctx) {
|
const MV* const ref, const nmv_context* const mvctx) {
|
||||||
MV_JOINT_TYPE j = vp8_get_mv_joint(*mv);
|
MV_JOINT_TYPE j = vp8_get_mv_joint(*mv);
|
||||||
vp8_write_token(w, vp8_mv_joint_tree, mvctx->joints,
|
vp8_write_token(bc, vp8_mv_joint_tree, mvctx->joints,
|
||||||
vp8_mv_joint_encodings + j);
|
vp8_mv_joint_encodings + j);
|
||||||
if (j == MV_JOINT_HZVNZ || j == MV_JOINT_HNZVNZ) {
|
if (j == MV_JOINT_HZVNZ || j == MV_JOINT_HNZVNZ) {
|
||||||
encode_nmv_component(w, mv->row, ref->col, &mvctx->comps[0]);
|
encode_nmv_component(bc, mv->row, ref->col, &mvctx->comps[0]);
|
||||||
}
|
}
|
||||||
if (j == MV_JOINT_HNZVZ || j == MV_JOINT_HNZVNZ) {
|
if (j == MV_JOINT_HNZVZ || j == MV_JOINT_HNZVNZ) {
|
||||||
encode_nmv_component(w, mv->col, ref->col, &mvctx->comps[1]);
|
encode_nmv_component(bc, mv->col, ref->col, &mvctx->comps[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp8_encode_nmv_fp(vp8_writer *w, const MV *mv, const MV *ref,
|
void vp8_encode_nmv_fp(vp8_writer* const bc, const MV* const mv,
|
||||||
const nmv_context *mvctx, int usehp) {
|
const MV* const ref, const nmv_context* const mvctx,
|
||||||
|
int usehp) {
|
||||||
MV_JOINT_TYPE j = vp8_get_mv_joint(*mv);
|
MV_JOINT_TYPE j = vp8_get_mv_joint(*mv);
|
||||||
usehp = usehp && vp8_use_nmv_hp(ref);
|
usehp = usehp && vp8_use_nmv_hp(ref);
|
||||||
if (j == MV_JOINT_HZVNZ || j == MV_JOINT_HNZVNZ) {
|
if (j == MV_JOINT_HZVNZ || j == MV_JOINT_HNZVNZ) {
|
||||||
encode_nmv_component_fp(w, mv->row, ref->row, &mvctx->comps[0], usehp);
|
encode_nmv_component_fp(bc, mv->row, ref->row, &mvctx->comps[0], usehp);
|
||||||
}
|
}
|
||||||
if (j == MV_JOINT_HNZVZ || j == MV_JOINT_HNZVNZ) {
|
if (j == MV_JOINT_HNZVZ || j == MV_JOINT_HNZVNZ) {
|
||||||
encode_nmv_component_fp(w, mv->col, ref->col, &mvctx->comps[1], usehp);
|
encode_nmv_component_fp(bc, mv->col, ref->col, &mvctx->comps[1], usehp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp8_build_nmv_cost_table(int *mvjoint,
|
void vp8_build_nmv_cost_table(int *mvjoint,
|
||||||
int *mvcost[2],
|
int *mvcost[2],
|
||||||
const nmv_context *mvctx,
|
const nmv_context* const mvctx,
|
||||||
int usehp,
|
int usehp,
|
||||||
int mvc_flag_v,
|
int mvc_flag_v,
|
||||||
int mvc_flag_h) {
|
int mvc_flag_h) {
|
||||||
@ -552,7 +553,7 @@ void vp8_build_nmv_cost_table(int *mvjoint,
|
|||||||
#else /* CONFIG_NEWMVENTROPY */
|
#else /* CONFIG_NEWMVENTROPY */
|
||||||
|
|
||||||
static void encode_mvcomponent(
|
static void encode_mvcomponent(
|
||||||
vp8_writer *const w,
|
vp8_writer *const bc,
|
||||||
const int v,
|
const int v,
|
||||||
const struct mv_context *mvc
|
const struct mv_context *mvc
|
||||||
) {
|
) {
|
||||||
@ -560,41 +561,44 @@ static void encode_mvcomponent(
|
|||||||
const int x = v < 0 ? -v : v;
|
const int x = v < 0 ? -v : v;
|
||||||
|
|
||||||
if (x < mvnum_short) { // Small
|
if (x < mvnum_short) { // Small
|
||||||
vp8_write(w, 0, p [mvpis_short]);
|
vp8_write(bc, 0, p[mvpis_short]);
|
||||||
vp8_treed_write(w, vp8_small_mvtree, p + MVPshort, x, mvnum_short_bits);
|
vp8_treed_write(bc, vp8_small_mvtree, p + MVPshort, x, mvnum_short_bits);
|
||||||
if (!x)
|
if (!x)
|
||||||
return; // no sign bit
|
return; // no sign bit
|
||||||
} else { // Large
|
} else { // Large
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
vp8_write(w, 1, p [mvpis_short]);
|
vp8_write(bc, 1, p[mvpis_short]);
|
||||||
|
|
||||||
do
|
do
|
||||||
vp8_write(w, (x >> i) & 1, p [MVPbits + i]);
|
vp8_write(bc, (x >> i) & 1, p[MVPbits + i]);
|
||||||
|
|
||||||
while (++i < mvnum_short_bits);
|
while (++i < mvnum_short_bits);
|
||||||
|
|
||||||
i = mvlong_width - 1; /* Skip bit 3, which is sometimes implicit */
|
i = mvlong_width - 1; /* Skip bit 3, which is sometimes implicit */
|
||||||
|
|
||||||
do
|
do
|
||||||
vp8_write(w, (x >> i) & 1, p [MVPbits + i]);
|
vp8_write(bc, (x >> i) & 1, p[MVPbits + i]);
|
||||||
|
|
||||||
while (--i > mvnum_short_bits);
|
while (--i > mvnum_short_bits);
|
||||||
|
|
||||||
if (x & ~((2 << mvnum_short_bits) - 1))
|
if (x & ~((2 << mvnum_short_bits) - 1))
|
||||||
vp8_write(w, (x >> mvnum_short_bits) & 1, p [MVPbits + mvnum_short_bits]);
|
vp8_write(bc, (x >> mvnum_short_bits) & 1, p[MVPbits + mvnum_short_bits]);
|
||||||
}
|
}
|
||||||
|
|
||||||
vp8_write(w, v < 0, p [MVPsign]);
|
vp8_write(bc, v < 0, p[MVPsign]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp8_encode_motion_vector(vp8_writer *w, const MV *mv, const MV_CONTEXT *mvc) {
|
void vp8_encode_motion_vector(vp8_writer* const bc,
|
||||||
encode_mvcomponent(w, mv->row >> 1, &mvc[0]);
|
const MV* const mv,
|
||||||
encode_mvcomponent(w, mv->col >> 1, &mvc[1]);
|
const MV_CONTEXT* const mvc) {
|
||||||
|
encode_mvcomponent(bc, mv->row >> 1, &mvc[0]);
|
||||||
|
encode_mvcomponent(bc, mv->col >> 1, &mvc[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static unsigned int cost_mvcomponent(const int v, const struct mv_context *mvc) {
|
static unsigned int cost_mvcomponent(const int v,
|
||||||
|
const struct mv_context* const mvc) {
|
||||||
const vp8_prob *p = mvc->prob;
|
const vp8_prob *p = mvc->prob;
|
||||||
const int x = v; // v<0? -v:v;
|
const int x = v; // v<0? -v:v;
|
||||||
unsigned int cost;
|
unsigned int cost;
|
||||||
@ -628,7 +632,8 @@ static unsigned int cost_mvcomponent(const int v, const struct mv_context *mvc)
|
|||||||
return cost; // + vp8_cost_bit( p [MVPsign], v < 0);
|
return cost; // + vp8_cost_bit( p [MVPsign], v < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp8_build_component_cost_table(int *mvcost[2], const MV_CONTEXT *mvc, int mvc_flag[2]) {
|
void vp8_build_component_cost_table(int *mvcost[2], const MV_CONTEXT *mvc,
|
||||||
|
const int mvc_flag[2]) {
|
||||||
int i = 1; // -mv_max;
|
int i = 1; // -mv_max;
|
||||||
unsigned int cost0 = 0;
|
unsigned int cost0 = 0;
|
||||||
unsigned int cost1 = 0;
|
unsigned int cost1 = 0;
|
||||||
@ -682,7 +687,7 @@ __inline static void calc_prob(vp8_prob *p, const unsigned int ct[2]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void update(
|
static void update(
|
||||||
vp8_writer *const w,
|
vp8_writer *const bc,
|
||||||
const unsigned int ct[2],
|
const unsigned int ct[2],
|
||||||
vp8_prob *const cur_p,
|
vp8_prob *const cur_p,
|
||||||
const vp8_prob new_p,
|
const vp8_prob new_p,
|
||||||
@ -695,16 +700,16 @@ static void update(
|
|||||||
|
|
||||||
if (cur_b - new_b > cost) {
|
if (cur_b - new_b > cost) {
|
||||||
*cur_p = new_p;
|
*cur_p = new_p;
|
||||||
vp8_write(w, 1, update_p);
|
vp8_write(bc, 1, update_p);
|
||||||
vp8_write_literal(w, new_p >> 1, 7);
|
vp8_write_literal(bc, new_p >> 1, 7);
|
||||||
*updated = 1;
|
*updated = 1;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
vp8_write(w, 0, update_p);
|
vp8_write(bc, 0, update_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_component_probs(
|
static void write_component_probs(
|
||||||
vp8_writer *const w,
|
vp8_writer *const bc,
|
||||||
struct mv_context *cur_mvc,
|
struct mv_context *cur_mvc,
|
||||||
const struct mv_context *default_mvc_,
|
const struct mv_context *default_mvc_,
|
||||||
const struct mv_context *update_mvc,
|
const struct mv_context *update_mvc,
|
||||||
@ -800,9 +805,11 @@ static void write_component_probs(
|
|||||||
while (++j < mvlong_width);
|
while (++j < mvlong_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(w, is_short_ct, Pcur + mvpis_short, Pnew[mvpis_short], *Pupdate++, updated);
|
update(bc, is_short_ct, Pcur + mvpis_short, Pnew[mvpis_short],
|
||||||
|
*Pupdate++, updated);
|
||||||
|
|
||||||
update(w, sign_ct, Pcur + MVPsign, Pnew[MVPsign], *Pupdate++, updated);
|
update(bc, sign_ct, Pcur + MVPsign, Pnew[MVPsign],
|
||||||
|
*Pupdate++, updated);
|
||||||
|
|
||||||
{
|
{
|
||||||
const vp8_prob *const new_p = Pnew + MVPshort;
|
const vp8_prob *const new_p = Pnew + MVPshort;
|
||||||
@ -812,7 +819,7 @@ static void write_component_probs(
|
|||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
update(w, short_bct[j], cur_p + j, new_p[j], *Pupdate++, updated);
|
update(bc, short_bct[j], cur_p + j, new_p[j], *Pupdate++, updated);
|
||||||
|
|
||||||
while (++j < mvnum_short - 1);
|
while (++j < mvnum_short - 1);
|
||||||
}
|
}
|
||||||
@ -825,25 +832,25 @@ static void write_component_probs(
|
|||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
update(w, bit_ct[j], cur_p + j, new_p[j], *Pupdate++, updated);
|
update(bc, bit_ct[j], cur_p + j, new_p[j], *Pupdate++, updated);
|
||||||
|
|
||||||
while (++j < mvlong_width);
|
while (++j < mvlong_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp8_write_mvprobs(VP8_COMP *cpi) {
|
void vp8_write_mvprobs(VP8_COMP* const cpi, vp8_writer* const bc) {
|
||||||
vp8_writer *const w = &cpi->bc;
|
|
||||||
MV_CONTEXT *mvc = cpi->common.fc.mvc;
|
MV_CONTEXT *mvc = cpi->common.fc.mvc;
|
||||||
int flags[2] = {0, 0};
|
int flags[2] = {0, 0};
|
||||||
#ifdef ENTROPY_STATS
|
#ifdef ENTROPY_STATS
|
||||||
active_section = 4;
|
active_section = 4;
|
||||||
#endif
|
#endif
|
||||||
write_component_probs(
|
write_component_probs(
|
||||||
w, &mvc[0], &vp8_default_mv_context[0], &vp8_mv_update_probs[0], cpi->MVcount[0], 0, &flags[0]
|
bc, &mvc[0], &vp8_default_mv_context[0], &vp8_mv_update_probs[0],
|
||||||
);
|
cpi->MVcount[0], 0, &flags[0]);
|
||||||
|
|
||||||
write_component_probs(
|
write_component_probs(
|
||||||
w, &mvc[1], &vp8_default_mv_context[1], &vp8_mv_update_probs[1], cpi->MVcount[1], 1, &flags[1]
|
bc, &mvc[1], &vp8_default_mv_context[1], &vp8_mv_update_probs[1],
|
||||||
);
|
cpi->MVcount[1], 1, &flags[1]);
|
||||||
|
|
||||||
if (flags[0] || flags[1])
|
if (flags[0] || flags[1])
|
||||||
vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cpi->common.fc.mvc, flags);
|
vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cpi->common.fc.mvc, flags);
|
||||||
@ -855,7 +862,7 @@ void vp8_write_mvprobs(VP8_COMP *cpi) {
|
|||||||
|
|
||||||
|
|
||||||
static void encode_mvcomponent_hp(
|
static void encode_mvcomponent_hp(
|
||||||
vp8_writer *const w,
|
vp8_writer *const bc,
|
||||||
const int v,
|
const int v,
|
||||||
const struct mv_context_hp *mvc
|
const struct mv_context_hp *mvc
|
||||||
) {
|
) {
|
||||||
@ -863,41 +870,41 @@ static void encode_mvcomponent_hp(
|
|||||||
const int x = v < 0 ? -v : v;
|
const int x = v < 0 ? -v : v;
|
||||||
|
|
||||||
if (x < mvnum_short_hp) { // Small
|
if (x < mvnum_short_hp) { // Small
|
||||||
vp8_write(w, 0, p [mvpis_short_hp]);
|
vp8_write(bc, 0, p[mvpis_short_hp]);
|
||||||
vp8_treed_write(w, vp8_small_mvtree_hp, p + MVPshort_hp, x,
|
vp8_treed_write(bc, vp8_small_mvtree_hp, p + MVPshort_hp, x,
|
||||||
mvnum_short_bits_hp);
|
mvnum_short_bits_hp);
|
||||||
if (!x)
|
if (!x)
|
||||||
return; // no sign bit
|
return; // no sign bit
|
||||||
} else { // Large
|
} else { // Large
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
vp8_write(w, 1, p [mvpis_short_hp]);
|
vp8_write(bc, 1, p[mvpis_short_hp]);
|
||||||
|
|
||||||
do
|
do
|
||||||
vp8_write(w, (x >> i) & 1, p [MVPbits_hp + i]);
|
vp8_write(bc, (x >> i) & 1, p[MVPbits_hp + i]);
|
||||||
|
|
||||||
while (++i < mvnum_short_bits_hp);
|
while (++i < mvnum_short_bits_hp);
|
||||||
|
|
||||||
i = mvlong_width_hp - 1; /* Skip bit 3, which is sometimes implicit */
|
i = mvlong_width_hp - 1; /* Skip bit 3, which is sometimes implicit */
|
||||||
|
|
||||||
do
|
do
|
||||||
vp8_write(w, (x >> i) & 1, p [MVPbits_hp + i]);
|
vp8_write(bc, (x >> i) & 1, p[MVPbits_hp + i]);
|
||||||
|
|
||||||
while (--i > mvnum_short_bits_hp);
|
while (--i > mvnum_short_bits_hp);
|
||||||
|
|
||||||
if (x & ~((2 << mvnum_short_bits_hp) - 1))
|
if (x & ~((2 << mvnum_short_bits_hp) - 1))
|
||||||
vp8_write(w, (x >> mvnum_short_bits_hp) & 1,
|
vp8_write(bc, (x >> mvnum_short_bits_hp) & 1,
|
||||||
p [MVPbits_hp + mvnum_short_bits_hp]);
|
p[MVPbits_hp + mvnum_short_bits_hp]);
|
||||||
}
|
}
|
||||||
|
|
||||||
vp8_write(w, v < 0, p [MVPsign_hp]);
|
vp8_write(bc, v < 0, p[MVPsign_hp]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp8_encode_motion_vector_hp(vp8_writer *w, const MV *mv,
|
void vp8_encode_motion_vector_hp(vp8_writer *bc, const MV *mv,
|
||||||
const MV_CONTEXT_HP *mvc) {
|
const MV_CONTEXT_HP *mvc) {
|
||||||
|
|
||||||
encode_mvcomponent_hp(w, mv->row, &mvc[0]);
|
encode_mvcomponent_hp(bc, mv->row, &mvc[0]);
|
||||||
encode_mvcomponent_hp(w, mv->col, &mvc[1]);
|
encode_mvcomponent_hp(bc, mv->col, &mvc[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -940,7 +947,7 @@ static unsigned int cost_mvcomponent_hp(const int v,
|
|||||||
|
|
||||||
void vp8_build_component_cost_table_hp(int *mvcost[2],
|
void vp8_build_component_cost_table_hp(int *mvcost[2],
|
||||||
const MV_CONTEXT_HP *mvc,
|
const MV_CONTEXT_HP *mvc,
|
||||||
int mvc_flag[2]) {
|
const int mvc_flag[2]) {
|
||||||
int i = 1; // -mv_max;
|
int i = 1; // -mv_max;
|
||||||
unsigned int cost0 = 0;
|
unsigned int cost0 = 0;
|
||||||
unsigned int cost1 = 0;
|
unsigned int cost1 = 0;
|
||||||
@ -978,7 +985,7 @@ void vp8_build_component_cost_table_hp(int *mvcost[2],
|
|||||||
|
|
||||||
|
|
||||||
static void write_component_probs_hp(
|
static void write_component_probs_hp(
|
||||||
vp8_writer *const w,
|
vp8_writer *const bc,
|
||||||
struct mv_context_hp *cur_mvc,
|
struct mv_context_hp *cur_mvc,
|
||||||
const struct mv_context_hp *default_mvc_,
|
const struct mv_context_hp *default_mvc_,
|
||||||
const struct mv_context_hp *update_mvc,
|
const struct mv_context_hp *update_mvc,
|
||||||
@ -1074,10 +1081,10 @@ static void write_component_probs_hp(
|
|||||||
while (++j < mvlong_width_hp);
|
while (++j < mvlong_width_hp);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(w, is_short_ct, Pcur + mvpis_short_hp, Pnew[mvpis_short_hp],
|
update(bc, is_short_ct, Pcur + mvpis_short_hp, Pnew[mvpis_short_hp],
|
||||||
*Pupdate++, updated);
|
*Pupdate++, updated);
|
||||||
|
|
||||||
update(w, sign_ct, Pcur + MVPsign_hp, Pnew[MVPsign_hp], *Pupdate++,
|
update(bc, sign_ct, Pcur + MVPsign_hp, Pnew[MVPsign_hp], *Pupdate++,
|
||||||
updated);
|
updated);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1088,7 +1095,7 @@ static void write_component_probs_hp(
|
|||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
update(w, short_bct[j], cur_p + j, new_p[j], *Pupdate++, updated);
|
update(bc, short_bct[j], cur_p + j, new_p[j], *Pupdate++, updated);
|
||||||
|
|
||||||
while (++j < mvnum_short_hp - 1);
|
while (++j < mvnum_short_hp - 1);
|
||||||
}
|
}
|
||||||
@ -1101,25 +1108,24 @@ static void write_component_probs_hp(
|
|||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
update(w, bit_ct[j], cur_p + j, new_p[j], *Pupdate++, updated);
|
update(bc, bit_ct[j], cur_p + j, new_p[j], *Pupdate++, updated);
|
||||||
|
|
||||||
while (++j < mvlong_width_hp);
|
while (++j < mvlong_width_hp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp8_write_mvprobs_hp(VP8_COMP *cpi) {
|
void vp8_write_mvprobs_hp(VP8_COMP* const cpi, vp8_writer* const bc) {
|
||||||
vp8_writer *const w = &cpi->bc;
|
|
||||||
MV_CONTEXT_HP *mvc = cpi->common.fc.mvc_hp;
|
MV_CONTEXT_HP *mvc = cpi->common.fc.mvc_hp;
|
||||||
int flags[2] = {0, 0};
|
int flags[2] = {0, 0};
|
||||||
#ifdef ENTROPY_STATS
|
#ifdef ENTROPY_STATS
|
||||||
active_section = 4;
|
active_section = 4;
|
||||||
#endif
|
#endif
|
||||||
write_component_probs_hp(
|
write_component_probs_hp(
|
||||||
w, &mvc[0], &vp8_default_mv_context_hp[0], &vp8_mv_update_probs_hp[0],
|
bc, &mvc[0], &vp8_default_mv_context_hp[0], &vp8_mv_update_probs_hp[0],
|
||||||
cpi->MVcount_hp[0], 0, &flags[0]
|
cpi->MVcount_hp[0], 0, &flags[0]
|
||||||
);
|
);
|
||||||
write_component_probs_hp(
|
write_component_probs_hp(
|
||||||
w, &mvc[1], &vp8_default_mv_context_hp[1], &vp8_mv_update_probs_hp[1],
|
bc, &mvc[1], &vp8_default_mv_context_hp[1], &vp8_mv_update_probs_hp[1],
|
||||||
cpi->MVcount_hp[1], 1, &flags[1]
|
cpi->MVcount_hp[1], 1, &flags[1]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
#include "onyx_int.h"
|
#include "onyx_int.h"
|
||||||
|
|
||||||
#if CONFIG_NEWMVENTROPY
|
#if CONFIG_NEWMVENTROPY
|
||||||
void vp8_write_nmvprobs(VP8_COMP *, int usehp);
|
void vp8_write_nmvprobs(VP8_COMP* const, int usehp, vp8_writer* const);
|
||||||
void vp8_encode_nmv(vp8_writer *w, const MV *mv, const MV *ref,
|
void vp8_encode_nmv(vp8_writer* const w, const MV* const mv,
|
||||||
const nmv_context *mvctx);
|
const MV* const ref, const nmv_context* const mvctx);
|
||||||
void vp8_encode_nmv_fp(vp8_writer *w, const MV *mv, const MV *ref,
|
void vp8_encode_nmv_fp(vp8_writer* const w, const MV* const mv,
|
||||||
const nmv_context *mvctx, int usehp);
|
const MV* const ref, const nmv_context *mvctx,
|
||||||
|
int usehp);
|
||||||
void vp8_build_nmv_cost_table(int *mvjoint,
|
void vp8_build_nmv_cost_table(int *mvjoint,
|
||||||
int *mvcost[2],
|
int *mvcost[2],
|
||||||
const nmv_context *mvctx,
|
const nmv_context *mvctx,
|
||||||
@ -27,18 +28,18 @@ void vp8_build_nmv_cost_table(int *mvjoint,
|
|||||||
int mvc_flag_v,
|
int mvc_flag_v,
|
||||||
int mvc_flag_h);
|
int mvc_flag_h);
|
||||||
#else /* CONFIG_NEWMVENTROPY */
|
#else /* CONFIG_NEWMVENTROPY */
|
||||||
void vp8_write_mvprobs(VP8_COMP *);
|
void vp8_write_mvprobs(VP8_COMP* const, vp8_writer* const);
|
||||||
void vp8_encode_motion_vector(vp8_writer *, const MV *,
|
void vp8_encode_motion_vector(vp8_writer* const, const MV* const,
|
||||||
const MV_CONTEXT *);
|
const MV_CONTEXT* const);
|
||||||
void vp8_build_component_cost_table(int *mvcost[2],
|
void vp8_build_component_cost_table(int *mvcost[2],
|
||||||
const MV_CONTEXT *mvc,
|
const MV_CONTEXT*,
|
||||||
int mvc_flag[2]);
|
const int mvc_flag[2]);
|
||||||
void vp8_write_mvprobs_hp(VP8_COMP *);
|
void vp8_write_mvprobs_hp(VP8_COMP* const, vp8_writer* const);
|
||||||
void vp8_encode_motion_vector_hp(vp8_writer *, const MV *,
|
void vp8_encode_motion_vector_hp(vp8_writer* const, const MV* const,
|
||||||
const MV_CONTEXT_HP *);
|
const MV_CONTEXT_HP* const);
|
||||||
void vp8_build_component_cost_table_hp(int *mvcost[2],
|
void vp8_build_component_cost_table_hp(int *mvcost[2],
|
||||||
const MV_CONTEXT_HP *mvc,
|
const MV_CONTEXT_HP*,
|
||||||
int mvc_flag[2]);
|
const int mvc_flag[2]);
|
||||||
#endif /* CONFIG_NEWMVENTROPY */
|
#endif /* CONFIG_NEWMVENTROPY */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -420,9 +420,6 @@ typedef struct VP8_COMP {
|
|||||||
|
|
||||||
MACROBLOCK mb;
|
MACROBLOCK mb;
|
||||||
VP8_COMMON common;
|
VP8_COMMON common;
|
||||||
vp8_writer bc, bc2;
|
|
||||||
// bool_writer *bc2;
|
|
||||||
|
|
||||||
VP8_CONFIG oxcf;
|
VP8_CONFIG oxcf;
|
||||||
|
|
||||||
struct lookahead_ctx *lookahead;
|
struct lookahead_ctx *lookahead;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user