diff options
-rw-r--r-- | src/gallium/auxiliary/vl/vl_vp8_decoder.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/blockd.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/decodeframe.c | 29 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/detokenize.c | 16 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/detokenize.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/entropy.h | 85 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/entropymode.c | 12 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/entropymode.h | 5 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/reconintra.c | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/treereader.c | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/treereader.h | 35 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/vp8_decoder.c | 17 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vp8/vp8_decoder.h | 35 |
13 files changed, 113 insertions, 137 deletions
diff --git a/src/gallium/auxiliary/vl/vl_vp8_decoder.h b/src/gallium/auxiliary/vl/vl_vp8_decoder.h index 6ba4044103..64fd9bace0 100644 --- a/src/gallium/auxiliary/vl/vl_vp8_decoder.h +++ b/src/gallium/auxiliary/vl/vl_vp8_decoder.h @@ -79,7 +79,7 @@ struct vl_vp8_decoder struct vl_vp8_buffer *dec_buffers[4]; // VP8 decoder context - VP8D_PTR vp8_dec; + VP8D_COMP *vp8_dec; YV12_BUFFER_CONFIG img_yv12; unsigned startcode; diff --git a/src/gallium/auxiliary/vl/vp8/blockd.h b/src/gallium/auxiliary/vl/vp8/blockd.h index 5b563fd271..d443784e14 100644 --- a/src/gallium/auxiliary/vl/vp8/blockd.h +++ b/src/gallium/auxiliary/vl/vp8/blockd.h @@ -225,8 +225,6 @@ typedef struct int mb_to_top_edge; int mb_to_bottom_edge; - unsigned int frames_since_golden; - unsigned int frames_till_alt_ref_frame; vp8_filter_fn_t filter_predict4x4; vp8_filter_fn_t filter_predict8x4; vp8_filter_fn_t filter_predict8x8; diff --git a/src/gallium/auxiliary/vl/vp8/decodeframe.c b/src/gallium/auxiliary/vl/vp8/decodeframe.c index 31ac246d43..b2e2fab871 100644 --- a/src/gallium/auxiliary/vl/vp8/decodeframe.c +++ b/src/gallium/auxiliary/vl/vp8/decodeframe.c @@ -27,12 +27,13 @@ #include <assert.h> #include <stdio.h> -void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *mb) +#define RTCD_VTABLE(x) NULL + +void mb_init_dequantizer(VP8_COMMON *common, MACROBLOCKD *mb) { int i; int QIndex; MB_MODE_INFO *mbmi = &mb->mode_info_context->mbmi; - VP8_COMMON *const pc = &pbi->common; /* Decide whether to use the default or alternate baseline Q value. */ if (mb->segmentation_enabled) @@ -45,27 +46,27 @@ void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *mb) else { /* Delta Value */ - QIndex = pc->base_qindex + mb->segment_feature_data[MB_LVL_ALT_Q][mbmi->segment_id]; + QIndex = common->base_qindex + mb->segment_feature_data[MB_LVL_ALT_Q][mbmi->segment_id]; QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0; /* Clamp to valid range */ } } else { - QIndex = pc->base_qindex; + QIndex = common->base_qindex; } /* Set up the block level dequant pointers */ for (i = 0; i < 16; i++) { - mb->block[i].dequant = pc->Y1dequant[QIndex]; + mb->block[i].dequant = common->Y1dequant[QIndex]; } for (i = 16; i < 24; i++) { - mb->block[i].dequant = pc->UVdequant[QIndex]; + mb->block[i].dequant = common->UVdequant[QIndex]; } - mb->block[24].dequant = pc->Y2dequant[QIndex]; + mb->block[24].dequant = common->Y2dequant[QIndex]; } /** @@ -73,12 +74,12 @@ void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *mb) * buffer and then copying it to dst buffer, we can write the result directly * to dst buffer. This eliminates unnecessary copy. */ -static void skip_recon_mb(VP8D_COMP *pbi, MACROBLOCKD *mb) +static void skip_recon_mb(VP8_COMMON *common, MACROBLOCKD *mb) { if (mb->mode_info_context->mbmi.ref_frame == INTRA_FRAME) { - RECON_INVOKE(&pbi->common.rtcd.recon, build_intra_predictors_mbuv_s)(mb); - RECON_INVOKE(&pbi->common.rtcd.recon, build_intra_predictors_mby_s)(mb); + RECON_INVOKE(&common->rtcd.recon, build_intra_predictors_mbuv_s)(mb); + RECON_INVOKE(&common->rtcd.recon, build_intra_predictors_mby_s)(mb); } else { @@ -206,7 +207,7 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *mb, unsigned int mb_i } else { - eobtotal = vp8_decode_mb_tokens(pbi, mb); + eobtotal = vp8_decode_mb_tokens(&pbi->common, mb); } /* Perform temporary clamping of the MV to be used for prediction */ @@ -223,12 +224,12 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *mb, unsigned int mb_i * mb_skip_coeff are zero. */ mb->mode_info_context->mbmi.mb_skip_coeff = 1; - skip_recon_mb(pbi, mb); + skip_recon_mb(&pbi->common, mb); return; } if (mb->segmentation_enabled) - mb_init_dequantizer(pbi, mb); + mb_init_dequantizer(&pbi->common, mb); /* do prediction */ if (mb->mode_info_context->mbmi.ref_frame == INTRA_FRAME) @@ -713,7 +714,7 @@ int vp8_frame_decode(VP8D_COMP *pbi, struct pipe_vp8_picture_desc *frame_header) vp8_initialize_dequantizer(&pbi->common); /* MB level dequantizer setup */ - mb_init_dequantizer(pbi, &pbi->mb); + mb_init_dequantizer(&pbi->common, &pbi->mb); } /* Determine if the golden frame or ARF buffer should be updated and how. diff --git a/src/gallium/auxiliary/vl/vp8/detokenize.c b/src/gallium/auxiliary/vl/vp8/detokenize.c index c6336f985f..4187c4fae1 100644 --- a/src/gallium/auxiliary/vl/vp8/detokenize.c +++ b/src/gallium/auxiliary/vl/vp8/detokenize.c @@ -166,7 +166,7 @@ DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); #define DECODE_EXTRABIT_AND_ADJUST_VAL(t, bits_count) \ { \ - split = 1 + (((range - 1) * vp8d_token_extra_bits2[t].Probs[bits_count]) >> 8); \ + split = 1 + (((range - 1) * vp8d_token_extra_bits2[t].probs[bits_count]) >> 8); \ bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8); \ FILL \ if(value >= bigsplit) { \ @@ -184,11 +184,11 @@ DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); Dest = ((A) != 0) + ((B) != 0); -int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *mb) +int vp8_decode_mb_tokens(VP8_COMMON *common, MACROBLOCKD *mb) { ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)mb->above_context; ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)mb->left_context; - const FRAME_CONTEXT * const fc = &dx->common.fc; + const FRAME_CONTEXT * const fc = &common->fc; BOOL_DECODER *bd = mb->current_bd; @@ -206,11 +206,11 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *mb) const uint8_t *bufend; register unsigned int range; VP8_BD_VALUE value; - const int *scan; + const int *scan = vp8_default_zig_zag1d; register unsigned int shift; uint32_t split; VP8_BD_VALUE bigsplit; - int16_t *qcoeff_ptr; + int16_t *qcoeff_ptr = &mb->qcoeff[0]; int type = 3; int stop = 16; @@ -220,9 +220,6 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *mb) const vp8_prob *Prob; const vp8_prob *coef_probs; - scan = vp8_default_zig_zag1d; - qcoeff_ptr = &mb->qcoeff[0]; - if (mb->mode_info_context->mbmi.mode != B_PRED && mb->mode_info_context->mbmi.mode != SPLITMV) { @@ -264,7 +261,7 @@ CHECK_0_: DECODE_AND_BRANCH_IF_ZERO(Prob[CAT_THREEFOUR_CONTEXT_NODE], CAT_THREEFOUR_CONTEXT_NODE_0_); DECODE_AND_BRANCH_IF_ZERO(Prob[CAT_FIVE_CONTEXT_NODE], CAT_FIVE_CONTEXT_NODE_0_); val = vp8d_token_extra_bits2[DCT_VAL_CATEGORY6].min_val; - bits_count = vp8d_token_extra_bits2[DCT_VAL_CATEGORY6].Length; + bits_count = vp8d_token_extra_bits2[DCT_VAL_CATEGORY6].length; do { @@ -302,7 +299,6 @@ CAT_THREE_CONTEXT_NODE_0_: HIGH_LOW_CONTEXT_NODE_0_: DECODE_AND_BRANCH_IF_ZERO(Prob[CAT_ONE_CONTEXT_NODE], CAT_ONE_CONTEXT_NODE_0_); - val = vp8d_token_extra_bits2[DCT_VAL_CATEGORY2].min_val; DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY2, 1); DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY2, 0); diff --git a/src/gallium/auxiliary/vl/vp8/detokenize.h b/src/gallium/auxiliary/vl/vp8/detokenize.h index 388d1e3fe6..301afe7f63 100644 --- a/src/gallium/auxiliary/vl/vp8/detokenize.h +++ b/src/gallium/auxiliary/vl/vp8/detokenize.h @@ -15,6 +15,6 @@ #include "vp8_decoder.h" void vp8_reset_mb_tokens_context(MACROBLOCKD *mb); -int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *mb); +int vp8_decode_mb_tokens(VP8_COMMON *common, MACROBLOCKD *mb); #endif /* DETOKENIZE_H */ diff --git a/src/gallium/auxiliary/vl/vp8/entropy.h b/src/gallium/auxiliary/vl/vp8/entropy.h index ea5dfea15a..3ca64ed76c 100644 --- a/src/gallium/auxiliary/vl/vp8/entropy.h +++ b/src/gallium/auxiliary/vl/vp8/entropy.h @@ -17,62 +17,57 @@ /* Coefficient token alphabet */ -#define ZERO_TOKEN 0 /* 0 Extra Bits 0+0 */ -#define ONE_TOKEN 1 /* 1 Extra Bits 0+1 */ -#define TWO_TOKEN 2 /* 2 Extra Bits 0+1 */ -#define THREE_TOKEN 3 /* 3 Extra Bits 0+1 */ -#define FOUR_TOKEN 4 /* 4 Extra Bits 0+1 */ -#define DCT_VAL_CATEGORY1 5 /* 5-6 Extra Bits 1+1 */ -#define DCT_VAL_CATEGORY2 6 /* 7-10 Extra Bits 2+1 */ -#define DCT_VAL_CATEGORY3 7 /* 11-18 Extra Bits 3+1 */ -#define DCT_VAL_CATEGORY4 8 /* 19-34 Extra Bits 4+1 */ -#define DCT_VAL_CATEGORY5 9 /* 35-66 Extra Bits 5+1 */ -#define DCT_VAL_CATEGORY6 10 /* 67+ Extra Bits 11+1 */ -#define DCT_EOB_TOKEN 11 /* EOB Extra Bits 0+0 */ - -#define MAX_ENTROPY_TOKENS 12 -#define ENTROPY_NODES 11 - -extern const vp8_tree_index vp8_coef_tree[]; - -extern struct vp8_token_struct vp8_coef_encodings[MAX_ENTROPY_TOKENS]; +#define ZERO_TOKEN 0 /* 0 Extra Bits 0+0 */ +#define ONE_TOKEN 1 /* 1 Extra Bits 0+1 */ +#define TWO_TOKEN 2 /* 2 Extra Bits 0+1 */ +#define THREE_TOKEN 3 /* 3 Extra Bits 0+1 */ +#define FOUR_TOKEN 4 /* 4 Extra Bits 0+1 */ +#define DCT_VAL_CATEGORY1 5 /* 5-6 Extra Bits 1+1 */ +#define DCT_VAL_CATEGORY2 6 /* 7-10 Extra Bits 2+1 */ +#define DCT_VAL_CATEGORY3 7 /* 11-18 Extra Bits 3+1 */ +#define DCT_VAL_CATEGORY4 8 /* 19-34 Extra Bits 4+1 */ +#define DCT_VAL_CATEGORY5 9 /* 35-66 Extra Bits 5+1 */ +#define DCT_VAL_CATEGORY6 10 /* 67+ Extra Bits 11+1 */ +#define DCT_EOB_TOKEN 11 /* EOB Extra Bits 0+0 */ + +#define MAX_ENTROPY_TOKENS 12 +#define ENTROPY_NODES 11 /* Coefficients are predicted via a 3-dimensional probability table. */ -/* Outside dimension. 0 = Y no DC, 1 = Y2, 2 = UV, 3 = Y with DC */ - -#define BLOCK_TYPES 4 +#define BLOCK_TYPES 4 /**< Outside dimension. 0 = Y no DC, 1 = Y2, 2 = UV, 3 = Y with DC */ +#define COEF_BANDS 8 /**< Middle dimension is a coarsening of the coefficient's position within the 4x4 DCT. */ + +/** + * Inside dimension is 3-valued measure of nearby complexity, that is, + * the extent to which nearby coefficients are nonzero. For the first + * coefficient (DC, unless block type is 0), we look at the (already encoded) + * blocks above and to the left of the current block. The context index is + * then the number (0,1,or 2) of these blocks having nonzero coefficients. + * After decoding a coefficient, the measure is roughly the size of the + * most recently decoded coefficient (0 for 0, 1 for 1, 2 for >1). + * Note that the intuitive meaning of this measure changes as coefficients + * are decoded, e.g., prior to the first token, a zero means that my neighbors + * are empty while, after the first token, because of the use of end-of-block, + * a zero means we just decoded a zero and hence guarantees that a non-zero + * coefficient will appear later in this block. However, this shift + * in meaning is perfectly OK because our context depends also on the + * coefficient band (and since zigzag positions 0, 1, and 2 are in + * distinct bands). + */ +#define PREV_COEF_CONTEXTS 3 -/* Middle dimension is a coarsening of the coefficient's - position within the 4x4 DCT. */ +extern const vp8_tree_index vp8_coef_tree[]; -#define COEF_BANDS 8 -extern DECLARE_ALIGNED(16, const unsigned char, vp8_coef_bands[16]); +extern const vp8_prob vp8_coef_update_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]; -/* Inside dimension is 3-valued measure of nearby complexity, that is, - the extent to which nearby coefficients are nonzero. For the first - coefficient (DC, unless block type is 0), we look at the (already encoded) - blocks above and to the left of the current block. The context index is - then the number (0,1,or 2) of these blocks having nonzero coefficients. - After decoding a coefficient, the measure is roughly the size of the - most recently decoded coefficient (0 for 0, 1 for 1, 2 for >1). - Note that the intuitive meaning of this measure changes as coefficients - are decoded, e.g., prior to the first token, a zero means that my neighbors - are empty while, after the first token, because of the use of end-of-block, - a zero means we just decoded a zero and hence guarantees that a non-zero - coefficient will appear later in this block. However, this shift - in meaning is perfectly OK because our context depends also on the - coefficient band (and since zigzag positions 0, 1, and 2 are in - distinct bands). */ +extern struct vp8_token_struct vp8_coef_encodings[MAX_ENTROPY_TOKENS]; -#define PREV_COEF_CONTEXTS 3 +extern DECLARE_ALIGNED(16, const unsigned char, vp8_coef_bands[16]); extern DECLARE_ALIGNED(16, const unsigned char, vp8_prev_token_class[MAX_ENTROPY_TOKENS]); -extern const vp8_prob vp8_coef_update_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]; - struct VP8Common; -void vp8_default_coef_probs(struct VP8Common *); extern DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]); extern DECLARE_ALIGNED(16, const short, vp8_default_inv_zig_zag[16]); diff --git a/src/gallium/auxiliary/vl/vp8/entropymode.c b/src/gallium/auxiliary/vl/vp8/entropymode.c index 109f8930d1..c36b636b08 100644 --- a/src/gallium/auxiliary/vl/vp8/entropymode.c +++ b/src/gallium/auxiliary/vl/vp8/entropymode.c @@ -173,27 +173,27 @@ const vp8_tree_index vp8_small_mvtree[14] = struct vp8_token_struct vp8_small_mvencodings[8]; -void vp8_init_mbmode_probs(VP8_COMMON *x) +void vp8_init_mbmode_probs(VP8_COMMON *common) { unsigned int bct[VP8_YMODES][2]; /* num Ymodes > num UV modes */ vp8_tree_probs_from_distribution( VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree, - x->fc.ymode_prob, bct, y_mode_cts, 256, 1); + common->fc.ymode_prob, bct, y_mode_cts, 256, 1); vp8_tree_probs_from_distribution( VP8_YMODES, vp8_kf_ymode_encodings, vp8_kf_ymode_tree, - x->kf_ymode_prob, bct, kf_y_mode_cts, 256, 1); + common->kf_ymode_prob, bct, kf_y_mode_cts, 256, 1); vp8_tree_probs_from_distribution( VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree, - x->fc.uv_mode_prob, bct, uv_mode_cts, 256, 1); + common->fc.uv_mode_prob, bct, uv_mode_cts, 256, 1); vp8_tree_probs_from_distribution( VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree, - x->kf_uv_mode_prob, bct, kf_uv_mode_cts, 256, 1); + common->kf_uv_mode_prob, bct, kf_uv_mode_cts, 256, 1); - memcpy(x->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob)); + memcpy(common->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob)); } static void intra_bmode_probs_from_distribution(vp8_prob p[VP8_BINTRAMODES - 1], diff --git a/src/gallium/auxiliary/vl/vp8/entropymode.h b/src/gallium/auxiliary/vl/vp8/entropymode.h index 3b99b40a91..54b0574e88 100644 --- a/src/gallium/auxiliary/vl/vp8/entropymode.h +++ b/src/gallium/auxiliary/vl/vp8/entropymode.h @@ -22,7 +22,7 @@ typedef const int vp8_mbsplit[16]; extern vp8_mbsplit vp8_mbsplits[VP8_NUMMBSPLITS]; -extern const int vp8_mbsplit_count[VP8_NUMMBSPLITS]; /* # of subsets */ +extern const int vp8_mbsplit_count[VP8_NUMMBSPLITS]; /* # of subsets */ extern const vp8_prob vp8_mbsplit_probs[VP8_NUMMBSPLITS - 1]; @@ -57,9 +57,10 @@ extern struct vp8_token_struct vp8_small_mvencodings[8]; void vp8_entropy_mode_init(); -void vp8_init_mbmode_probs(VP8_COMMON *x); +void vp8_init_mbmode_probs(VP8_COMMON *common); void vp8_default_bmode_probs(vp8_prob dest[VP8_BINTRAMODES - 1]); + void vp8_kf_default_bmode_probs(vp8_prob dest[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES - 1]); #endif /* ENTROPYMODE_H */ diff --git a/src/gallium/auxiliary/vl/vp8/reconintra.c b/src/gallium/auxiliary/vl/vp8/reconintra.c index 82de750e8a..c06617bb11 100644 --- a/src/gallium/auxiliary/vl/vp8/reconintra.c +++ b/src/gallium/auxiliary/vl/vp8/reconintra.c @@ -21,15 +21,15 @@ void vp8_setup_intra_recon(YV12_BUFFER_CONFIG *ybf) memset(ybf->y_buffer - 1 - ybf->y_stride, 127, ybf->y_width + 5); for (i = 0; i < ybf->y_height; i++) - ybf->y_buffer[ybf->y_stride *i - 1] = (unsigned char) 129; + ybf->y_buffer[ybf->y_stride*i - 1] = (unsigned char)129; memset(ybf->u_buffer - 1 - ybf->uv_stride, 127, ybf->uv_width + 5); for (i = 0; i < ybf->uv_height; i++) - ybf->u_buffer[ybf->uv_stride *i - 1] = (unsigned char) 129; + ybf->u_buffer[ybf->uv_stride*i - 1] = (unsigned char)129; memset(ybf->v_buffer - 1 - ybf->uv_stride, 127, ybf->uv_width + 5); for (i = 0; i < ybf->uv_height; i++) - ybf->v_buffer[ybf->uv_stride *i - 1] = (unsigned char) 129; + ybf->v_buffer[ybf->uv_stride*i - 1] = (unsigned char)129; } /** diff --git a/src/gallium/auxiliary/vl/vp8/treereader.c b/src/gallium/auxiliary/vl/vp8/treereader.c index a017479126..256e1d7a20 100644 --- a/src/gallium/auxiliary/vl/vp8/treereader.c +++ b/src/gallium/auxiliary/vl/vp8/treereader.c @@ -40,8 +40,8 @@ void vp8dx_bool_decoder_fill(BOOL_DECODER *bd) { const unsigned char *bufptr; const unsigned char *bufend; - VP8_BD_VALUE value; - int count; + VP8_BD_VALUE value; + int count; bufend = bd->user_buffer_end; bufptr = bd->user_buffer; value = bd->value; diff --git a/src/gallium/auxiliary/vl/vp8/treereader.h b/src/gallium/auxiliary/vl/vp8/treereader.h index 065a406285..4594b0bd3c 100644 --- a/src/gallium/auxiliary/vl/vp8/treereader.h +++ b/src/gallium/auxiliary/vl/vp8/treereader.h @@ -15,19 +15,6 @@ #include "treereader_common.h" #include "vp8_mem.h" -#define vp8_read vp8dx_decode_bool -#define vp8_read_literal vp8_decode_value -#define vp8_read_bit( R) vp8_read( R, vp8_prob_half) - -/** - * This is meant to be a large, positive constant that can still be efficiently - * loaded as an immediate (on platforms like ARM, for example). - * Even relatively modest values like 100 would work fine. - */ -#define VP8_LOTS_OF_BITS (0x40000000) - -#define VP8_BD_VALUE_SIZE ((int)sizeof(VP8_BD_VALUE)*CHAR_BIT) - typedef size_t VP8_BD_VALUE; typedef struct @@ -39,6 +26,19 @@ typedef struct unsigned int range; } BOOL_DECODER; +/** + * This is meant to be a large, positive constant that can still be efficiently + * loaded as an immediate (on platforms like ARM, for example). + * Even relatively modest values like 100 would work fine. + */ +#define VP8_LOTS_OF_BITS (0x40000000) + +#define VP8_BD_VALUE_SIZE ((int)sizeof(VP8_BD_VALUE)*CHAR_BIT) + +#define vp8_read vp8dx_decode_bool +#define vp8_read_literal vp8_decode_value +#define vp8_read_bit( R) vp8_read( R, vp8_prob_half) + DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); int vp8dx_start_decode(BOOL_DECODER *bd, const unsigned char *data, unsigned int data_size); @@ -61,15 +61,14 @@ int vp8_treed_read(BOOL_DECODER *const bd, vp8_tree t, const vp8_prob *const p); * enough to eliminate the stores to those fields and the subsequent reloads * from them when inlining the function. */ -#define VP8DX_BOOL_DECODER_FILL(_count,_value,_bufptr,_bufend) \ +#define VP8DX_BOOL_DECODER_FILL(_count, _value, _bufptr, _bufend) \ do \ { \ - int shift = VP8_BD_VALUE_SIZE - 8 - ((_count) + 8); \ - int loop_end, x; \ size_t bits_left = ((_bufend)-(_bufptr))*CHAR_BIT; \ + int shift = VP8_BD_VALUE_SIZE - 8 - ((_count) + 8); \ + int loop_end = 0; \ + int x = shift + CHAR_BIT - bits_left; \ \ - x = shift + CHAR_BIT - bits_left; \ - loop_end = 0; \ if (x >= 0) \ { \ (_count) += VP8_LOTS_OF_BITS; \ diff --git a/src/gallium/auxiliary/vl/vp8/vp8_decoder.c b/src/gallium/auxiliary/vl/vp8/vp8_decoder.c index 0aaf8f38e3..dfefb91883 100644 --- a/src/gallium/auxiliary/vl/vp8/vp8_decoder.c +++ b/src/gallium/auxiliary/vl/vp8/vp8_decoder.c @@ -104,7 +104,7 @@ static int swap_frame_buffers(VP8_COMMON *cm) /** * Create a VP8 decoder instance. */ -VP8D_PTR vp8_decoder_create() +VP8D_COMP *vp8_decoder_create() { VP8D_COMP *pbi = vpx_memalign(32, sizeof(VP8D_COMP)); @@ -121,7 +121,6 @@ VP8D_PTR vp8_decoder_create() } pbi->common.error.setjmp = 1; - pbi->common.current_video_frame = 0; pbi->common.show_frame = 0; vp8_initialize_common(); @@ -131,16 +130,15 @@ VP8D_PTR vp8_decoder_create() pbi->common.error.setjmp = 0; - return (VP8D_PTR)pbi; + return pbi; } /** * Decode one VP8 frame. */ -int vp8_decoder_start(VP8D_PTR ptr, struct pipe_vp8_picture_desc *frame_header, +int vp8_decoder_start(VP8D_COMP *pbi, struct pipe_vp8_picture_desc *frame_header, const unsigned char *data, unsigned data_size) { - VP8D_COMP *pbi = (VP8D_COMP *)ptr; VP8_COMMON *cm = &pbi->common; int retcode = 0; @@ -200,7 +198,7 @@ int vp8_decoder_start(VP8D_PTR ptr, struct pipe_vp8_picture_desc *frame_header, vp8_yv12_extend_frame_borders(cm->frame_to_show); } - /* from libvpx : vp8_print_modes_and_motion_vectors(cm->mi, cm->mb_rows, cm->mb_cols, cm->current_video_frame); */ + /* from libvpx : vp8_print_modes_and_motion_vectors(cm->mi, cm->mb_rows, cm->mb_cols, current_video_frame); */ pbi->data_size = 0; pbi->common.error.setjmp = 0; @@ -211,11 +209,10 @@ int vp8_decoder_start(VP8D_PTR ptr, struct pipe_vp8_picture_desc *frame_header, /** * Return a decoded VP8 frame in a YV12 framebuffer. */ -int vp8_decoder_getframe(VP8D_PTR ptr, +int vp8_decoder_getframe(VP8D_COMP *pbi, YV12_BUFFER_CONFIG *sd) { int ret = -1; - VP8D_COMP *pbi = (VP8D_COMP *)ptr; /* ie no raw frame to show!!! */ if (pbi->common.show_frame == 0) @@ -238,10 +235,8 @@ int vp8_decoder_getframe(VP8D_PTR ptr, /** * Destroy a VP8 decoder instance. */ -void vp8_decoder_remove(VP8D_PTR ptr) +void vp8_decoder_remove(VP8D_COMP *pbi) { - VP8D_COMP *pbi = (VP8D_COMP *)ptr; - if (!pbi) return; diff --git a/src/gallium/auxiliary/vl/vp8/vp8_decoder.h b/src/gallium/auxiliary/vl/vp8/vp8_decoder.h index d852ba1aff..58f9b6454e 100644 --- a/src/gallium/auxiliary/vl/vp8/vp8_decoder.h +++ b/src/gallium/auxiliary/vl/vp8/vp8_decoder.h @@ -36,8 +36,6 @@ extern "C" #define NUM_YV12_BUFFERS 4 -#define RTCD_VTABLE(x) NULL - typedef struct { vp8_prob bmode_prob[VP8_BINTRAMODES - 1]; @@ -51,8 +49,8 @@ typedef struct typedef struct { int16_t min_val; - int16_t Length; - uint8_t Probs[12]; + int16_t length; + uint8_t probs[12]; } TOKEN_EXTRABITS; typedef enum @@ -85,10 +83,6 @@ typedef struct VP8Common { struct vpx_internal_error_info error; - DECLARE_ALIGNED(16, short, Y1dequant[QINDEX_RANGE][16]); - DECLARE_ALIGNED(16, short, Y2dequant[QINDEX_RANGE][16]); - DECLARE_ALIGNED(16, short, UVdequant[QINDEX_RANGE][16]); - /* Header content */ FRAME_TYPE frame_type; int version; @@ -112,6 +106,7 @@ typedef struct VP8Common int refresh_last_frame; /**< Two state 0 = NO, 1 = YES */ int refresh_golden_frame; /**< Two state 0 = NO, 1 = YES */ int refresh_alt_ref_frame; /**< Two state 0 = NO, 1 = YES */ + int refresh_entropy_probs; /**< Two state 0 = NO, 1 = YES */ /* Frame buffers */ YV12_BUFFER_CONFIG *frame_to_show; @@ -131,6 +126,11 @@ typedef struct VP8Common int use_bilinear_mc_filter; int full_pixel; + /* Quantization */ + DECLARE_ALIGNED(16, short, Y1dequant[QINDEX_RANGE][16]); + DECLARE_ALIGNED(16, short, Y2dequant[QINDEX_RANGE][16]); + DECLARE_ALIGNED(16, short, UVdequant[QINDEX_RANGE][16]); + int base_qindex; int last_kf_gf_q; /**< Q used on the last GF or KF */ @@ -140,9 +140,6 @@ typedef struct VP8Common int uvdc_delta_q; int uvac_delta_q; - unsigned int frames_since_golden; - unsigned int frames_till_alt_ref_frame; - /* We allocate a MODE_INFO struct for each macroblock, together with an extra row on top and column on the left to simplify prediction. */ @@ -152,8 +149,6 @@ typedef struct VP8Common int copy_buffer_to_gf; /**< 0 none, 1 Last to GF, 2 ARF to GF */ int copy_buffer_to_arf; /**< 0 none, 1 Last to ARF, 2 GF to ARF */ - int refresh_entropy_probs; /**< Two state 0 = NO, 1 = YES */ - int ref_frame_sign_bias[MAX_REF_FRAMES]; /**< Two state 0, 1 */ ENTROPY_CONTEXT_PLANES *above_context; /**< Row of context for each plane */ @@ -168,14 +163,10 @@ typedef struct VP8Common FRAME_CONTEXT lfc; /**< Last frame entropy */ FRAME_CONTEXT fc; /**< Current frame entropy */ - unsigned int current_video_frame; - TOKEN_PARTITION multi_token_partition; } VP8_COMMON; -typedef void* VP8D_PTR; - typedef struct { DECLARE_ALIGNED(16, MACROBLOCKD, mb); @@ -196,16 +187,16 @@ typedef struct /* ************************************************************************** */ -VP8D_PTR vp8_decoder_create(); +VP8D_COMP *vp8_decoder_create(); -int vp8_decoder_start(VP8D_PTR comp, struct pipe_vp8_picture_desc *frame_header, +int vp8_decoder_start(VP8D_COMP *pbi, struct pipe_vp8_picture_desc *frame_header, const unsigned char *data, unsigned data_size); -int vp8_decoder_getframe(VP8D_PTR comp, YV12_BUFFER_CONFIG *sd); +int vp8_decoder_getframe(VP8D_COMP *pbi, YV12_BUFFER_CONFIG *sd); -void vp8_decoder_remove(VP8D_PTR comp); +void vp8_decoder_remove(VP8D_COMP *pbi); -int vp8_frame_decode(VP8D_COMP *cpi, struct pipe_vp8_picture_desc *frame_header); +int vp8_frame_decode(VP8D_COMP *pbi, struct pipe_vp8_picture_desc *frame_header); #ifdef __cplusplus } |