From 383f432a6a48c33be4a09958a786deebe018cd45 Mon Sep 17 00:00:00 2001 From: Emeric Grange Date: Mon, 31 Oct 2011 17:42:23 +0100 Subject: g3dvl: Mostly cosmetic cleanups, and some var & func renaming Signed-off-by: Emeric Grange --- src/gallium/auxiliary/vl/vp8/common/mbpitch.c | 6 +- src/gallium/auxiliary/vl/vp8/common/onyxc_int.h | 8 +- src/gallium/auxiliary/vl/vp8/common/onyxd.h | 9 +- src/gallium/auxiliary/vl/vp8/common/quant_common.c | 23 +++ src/gallium/auxiliary/vl/vp8/common/quant_common.h | 3 + src/gallium/auxiliary/vl/vp8/common/recon.h | 22 +-- src/gallium/auxiliary/vl/vp8/common/reconintra.c | 6 +- .../auxiliary/vl/vp8/common/reconintra4x4.c | 9 +- src/gallium/auxiliary/vl/vp8/common/treecoder.c | 4 +- src/gallium/auxiliary/vl/vp8/common/yv12utils.c | 6 +- src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.c | 16 +- src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.h | 14 +- src/gallium/auxiliary/vl/vp8/decoder/decodeframe.c | 163 +++++++++------------ src/gallium/auxiliary/vl/vp8/decoder/onyxd_if.c | 55 ++++--- src/gallium/auxiliary/vl/vp8/decoder/onyxd_int.h | 6 +- src/gallium/auxiliary/vl/vp8/decoder/treereader.h | 7 +- src/gallium/auxiliary/vl/vp8/vp8_mem.h | 6 - 17 files changed, 173 insertions(+), 190 deletions(-) diff --git a/src/gallium/auxiliary/vl/vp8/common/mbpitch.c b/src/gallium/auxiliary/vl/vp8/common/mbpitch.c index fefbf0fb6d..fc405fc527 100644 --- a/src/gallium/auxiliary/vl/vp8/common/mbpitch.c +++ b/src/gallium/auxiliary/vl/vp8/common/mbpitch.c @@ -60,16 +60,16 @@ static void setup_macroblock(MACROBLOCKD *x, BLOCKSET bs) for (block = 0; block < 16; block++) /* y blocks */ { setup_block(&x->block[block], x->dst.y_stride, y, x->dst.y_stride, - (block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4, bs); + (block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4, bs); } for (block = 16; block < 20; block++) /* U and V blocks */ { setup_block(&x->block[block], x->dst.uv_stride, u, x->dst.uv_stride, - ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs); + ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs); setup_block(&x->block[block+4], x->dst.uv_stride, v, x->dst.uv_stride, - ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs); + ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs); } } diff --git a/src/gallium/auxiliary/vl/vp8/common/onyxc_int.h b/src/gallium/auxiliary/vl/vp8/common/onyxc_int.h index 241d888cc2..e905126d69 100644 --- a/src/gallium/auxiliary/vl/vp8/common/onyxc_int.h +++ b/src/gallium/auxiliary/vl/vp8/common/onyxc_int.h @@ -136,14 +136,13 @@ typedef struct VP8Common int ref_frame_sign_bias [MAX_REF_FRAMES]; /**< Two state 0, 1 */ - /* Y,U,V,Y2 */ - ENTROPY_CONTEXT_PLANES *above_context; /**< row of context for each plane */ - ENTROPY_CONTEXT_PLANES left_context; /**< (up to) 4 contexts "" */ + ENTROPY_CONTEXT_PLANES *above_context; /**< Row of context for each plane */ + ENTROPY_CONTEXT_PLANES left_context; /**< (up to) 4 contexts */ /* keyframe block modes are predicted by their above, left neighbors */ vp8_prob kf_bmode_prob [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1]; - vp8_prob kf_ymode_prob [VP8_YMODES-1]; /**< keyframe "" */ + vp8_prob kf_ymode_prob [VP8_YMODES-1]; /**< keyframe */ vp8_prob kf_uv_mode_prob [VP8_UV_MODES-1]; FRAME_CONTEXT lfc; /**< last frame entropy */ @@ -152,6 +151,7 @@ typedef struct VP8Common unsigned int current_video_frame; TOKEN_PARTITION multi_token_partition; + } VP8_COMMON; #endif /* VP8C_INT_H */ diff --git a/src/gallium/auxiliary/vl/vp8/common/onyxd.h b/src/gallium/auxiliary/vl/vp8/common/onyxd.h index e395b0fb02..f1da5d3039 100644 --- a/src/gallium/auxiliary/vl/vp8/common/onyxd.h +++ b/src/gallium/auxiliary/vl/vp8/common/onyxd.h @@ -25,10 +25,15 @@ extern "C" typedef void *VP8D_PTR; VP8D_PTR vp8dx_create_decompressor(); + void vp8dx_remove_decompressor(VP8D_PTR comp); -int vp8dx_receive_compressed_data(VP8D_PTR comp, const unsigned char *data, unsigned data_size, int64_t time_stamp); -int vp8dx_get_raw_frame(VP8D_PTR comp, YV12_BUFFER_CONFIG *sd, int64_t *time_stamp, int64_t *time_end_stamp); +int vp8dx_receive_compressed_data(VP8D_PTR comp, + const unsigned char *data, unsigned data_size, + int64_t timestamp_deadline); + +int vp8dx_get_raw_frame(VP8D_PTR comp, YV12_BUFFER_CONFIG *sd, + int64_t *timestamp, int64_t *timestamp_end); #ifdef __cplusplus } diff --git a/src/gallium/auxiliary/vl/vp8/common/quant_common.c b/src/gallium/auxiliary/vl/vp8/common/quant_common.c index 2f9c05598e..36036d57a3 100644 --- a/src/gallium/auxiliary/vl/vp8/common/quant_common.c +++ b/src/gallium/auxiliary/vl/vp8/common/quant_common.c @@ -134,3 +134,26 @@ int vp8_ac_uv_quant(int QIndex, int Delta) return retval; } + +void vp8_initialize_dequantizer(VP8_COMMON *pc) +{ + int i; + int Q; + + for (Q = 0; Q < QINDEX_RANGE; Q++) + { + pc->Y1dequant[Q][0] = (short)vp8_dc_quant(Q, pc->y1dc_delta_q); + pc->Y2dequant[Q][0] = (short)vp8_dc2quant(Q, pc->y2dc_delta_q); + pc->UVdequant[Q][0] = (short)vp8_dc_uv_quant(Q, pc->uvdc_delta_q); + + /* All the ac values = ; */ + for (i = 1; i < 16; i++) + { + int rc = vp8_default_zig_zag1d[i]; + + pc->Y1dequant[Q][rc] = (short)vp8_ac_yquant(Q); + pc->Y2dequant[Q][rc] = (short)vp8_ac2quant(Q, pc->y2ac_delta_q); + pc->UVdequant[Q][rc] = (short)vp8_ac_uv_quant(Q, pc->uvac_delta_q); + } + } +} diff --git a/src/gallium/auxiliary/vl/vp8/common/quant_common.h b/src/gallium/auxiliary/vl/vp8/common/quant_common.h index 6a940900d1..4686904d5f 100644 --- a/src/gallium/auxiliary/vl/vp8/common/quant_common.h +++ b/src/gallium/auxiliary/vl/vp8/common/quant_common.h @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ + #ifndef QUANT_COMMON_H #define QUANT_COMMON_H @@ -21,4 +22,6 @@ extern int vp8_ac2quant(int QIndex, int Delta); extern int vp8_dc_uv_quant(int QIndex, int Delta); extern int vp8_ac_uv_quant(int QIndex, int Delta); +extern void vp8_initialize_dequantizer(VP8_COMMON *pc); + #endif /* QUANT_COMMON_H */ diff --git a/src/gallium/auxiliary/vl/vp8/common/recon.h b/src/gallium/auxiliary/vl/vp8/common/recon.h index 1c97c0df36..482a2edbab 100644 --- a/src/gallium/auxiliary/vl/vp8/common/recon.h +++ b/src/gallium/auxiliary/vl/vp8/common/recon.h @@ -23,8 +23,7 @@ #define prototype_recon_macroblock(sym) \ void sym(const struct vp8_recon_rtcd_vtable *rtcd, MACROBLOCKD *x) -#define prototype_build_intra_predictors(sym) \ - void sym(MACROBLOCKD *x) +#define prototype_build_intra_predictors(sym) void sym(MACROBLOCKD *x) #define prototype_intra4x4_predict(sym) \ void sym(BLOCKD *x, int b_mode, unsigned char *predictor) @@ -74,33 +73,27 @@ extern prototype_recon_macroblock(vp8_recon_recon_mby); #ifndef vp8_recon_build_intra_predictors_mby #define vp8_recon_build_intra_predictors_mby vp8_build_intra_predictors_mby #endif -extern prototype_build_intra_predictors\ - (vp8_recon_build_intra_predictors_mby); +extern prototype_build_intra_predictors(vp8_recon_build_intra_predictors_mby); #ifndef vp8_recon_build_intra_predictors_mby_s #define vp8_recon_build_intra_predictors_mby_s vp8_build_intra_predictors_mby_s #endif -extern prototype_build_intra_predictors\ - (vp8_recon_build_intra_predictors_mby_s); +extern prototype_build_intra_predictors(vp8_recon_build_intra_predictors_mby_s); #ifndef vp8_recon_build_intra_predictors_mbuv #define vp8_recon_build_intra_predictors_mbuv vp8_build_intra_predictors_mbuv #endif -extern prototype_build_intra_predictors\ - (vp8_recon_build_intra_predictors_mbuv); +extern prototype_build_intra_predictor(vp8_recon_build_intra_predictors_mbuv); #ifndef vp8_recon_build_intra_predictors_mbuv_s #define vp8_recon_build_intra_predictors_mbuv_s vp8_build_intra_predictors_mbuv_s #endif -extern prototype_build_intra_predictors\ - (vp8_recon_build_intra_predictors_mbuv_s); +extern prototype_build_intra_predictors(vp8_recon_build_intra_predictors_mbuv_s); #ifndef vp8_recon_intra4x4_predict #define vp8_recon_intra4x4_predict vp8_intra4x4_predict #endif -extern prototype_intra4x4_predict\ - (vp8_recon_intra4x4_predict); - +extern prototype_intra4x4_predict(vp8_recon_intra4x4_predict); typedef prototype_copy_block((*vp8_copy_block_fn_t)); typedef prototype_recon_block((*vp8_recon_fn_t)); @@ -127,4 +120,5 @@ typedef struct vp8_recon_rtcd_vtable #define RECON_INVOKE(ctx,fn) vp8_recon_##fn void vp8_recon_intra_mbuv(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x); -#endif + +#endif /* RECON_H */ diff --git a/src/gallium/auxiliary/vl/vp8/common/reconintra.c b/src/gallium/auxiliary/vl/vp8/common/reconintra.c index 58854545ba..9c9d839d8f 100644 --- a/src/gallium/auxiliary/vl/vp8/common/reconintra.c +++ b/src/gallium/auxiliary/vl/vp8/common/reconintra.c @@ -13,8 +13,9 @@ #include "reconintra.h" #include "../vp8_mem.h" -/* For skip_recon_mb(), add vp8_build_intra_predictors_mby_s(MACROBLOCKD *x) and - * vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x). +/** + * For skip_recon_mb(), add vp8_build_intra_predictors_mby_s(MACROBLOCKD *x) + * and vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x). */ void vp8_recon_intra_mbuv(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x) { @@ -141,7 +142,6 @@ void vp8_build_intra_predictors_mby(MACROBLOCKD *x) void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x) { - unsigned char *yabove_row = x->dst.y_buffer - x->dst.y_stride; unsigned char yleft_col[16]; unsigned char ytop_left = yabove_row[-1]; diff --git a/src/gallium/auxiliary/vl/vp8/common/reconintra4x4.c b/src/gallium/auxiliary/vl/vp8/common/reconintra4x4.c index efa8ca07f4..2416ff5e6d 100644 --- a/src/gallium/auxiliary/vl/vp8/common/reconintra4x4.c +++ b/src/gallium/auxiliary/vl/vp8/common/reconintra4x4.c @@ -9,8 +9,8 @@ */ -#include "recon.h" #include "../vp8_mem.h" +#include "recon.h" #include "reconintra.h" void vp8_intra4x4_predict(BLOCKD *x, int b_mode, unsigned char *predictor) @@ -77,7 +77,6 @@ void vp8_intra4x4_predict(BLOCKD *x, int b_mode, unsigned char *predictor) case B_VE_PRED: { - unsigned int ap[4]; ap[0] = (top_left + 2 * Above[0] + Above[1] + 2) >> 2; ap[1] = (Above[0] + 2 * Above[1] + Above[2] + 2) >> 2; @@ -100,7 +99,6 @@ void vp8_intra4x4_predict(BLOCKD *x, int b_mode, unsigned char *predictor) case B_HE_PRED: { - unsigned int lp[4]; lp[0] = (top_left + 2 * Left[0] + Left[1] + 2) >> 2; lp[1] = (Left[0] + 2 * Left[1] + Left[2] + 2) >> 2; @@ -289,8 +287,9 @@ void vp8_intra4x4_predict(BLOCKD *x, int b_mode, unsigned char *predictor) } } -/* copy 4 bytes from the above right down so that the 4x4 prediction modes using pixels above and - * to the right prediction have filled in pixels to use. +/** + * Copy 4 bytes from the above right down so that the 4x4 prediction modes using + * pixels above and to the right prediction have filled in pixels to use. */ void vp8_intra_prediction_down_copy(MACROBLOCKD *x) { diff --git a/src/gallium/auxiliary/vl/vp8/common/treecoder.c b/src/gallium/auxiliary/vl/vp8/common/treecoder.c index 00d965e2a7..c026bef16f 100644 --- a/src/gallium/auxiliary/vl/vp8/common/treecoder.c +++ b/src/gallium/auxiliary/vl/vp8/common/treecoder.c @@ -82,7 +82,6 @@ static void branch_counts(int n, /* n = size of alphabet */ #if CONFIG_DEBUG assert(j < tree_len && 0 <= L); #endif - branch_ct [j] [b] += ct; i = tree[ i + b]; } @@ -96,7 +95,6 @@ static void branch_counts(int n, /* n = size of alphabet */ } - void vp8_tree_probs_from_distribution(int n, /* n = size of alphabet */ vp8_token tok[ /* n */ ], vp8_tree tree, @@ -117,7 +115,7 @@ void vp8_tree_probs_from_distribution(int n, /* n = size of alphabet */ const unsigned int tot = c[0] + c[1]; #if CONFIG_DEBUG - assert(tot < (1 << 24)); /* no overflow below */ + assert(tot < (1 << 24)); /* no overflow below */ #endif if (tot) diff --git a/src/gallium/auxiliary/vl/vp8/common/yv12utils.c b/src/gallium/auxiliary/vl/vp8/common/yv12utils.c index 3ba77e981e..345189169a 100644 --- a/src/gallium/auxiliary/vl/vp8/common/yv12utils.c +++ b/src/gallium/auxiliary/vl/vp8/common/yv12utils.c @@ -107,7 +107,7 @@ vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf) plane_height = ybf->y_height; plane_width = ybf->y_width; - /* copy the left and right most columns out */ + /* Copy the left and right most columns out */ src_ptr1 = ybf->y_buffer; src_ptr2 = src_ptr1 + plane_width - 1; dest_ptr1 = src_ptr1 - Border; @@ -146,7 +146,7 @@ vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf) plane_width = ybf->uv_width; Border /= 2; - /* copy the left and right most columns out */ + /* Copy the left and right most columns out */ src_ptr1 = ybf->u_buffer; src_ptr2 = src_ptr1 + plane_width - 1; dest_ptr1 = src_ptr1 - Border; @@ -180,7 +180,7 @@ vp8_yv12_extend_frame_borders(YV12_BUFFER_CONFIG *ybf) /* V Plane */ /***********/ - /* copy the left and right most columns out */ + /* Copy the left and right most columns out */ src_ptr1 = ybf->v_buffer; src_ptr2 = src_ptr1 + plane_width - 1; dest_ptr1 = src_ptr1 - Border; diff --git a/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.c b/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.c index 6fb8b38ac5..19d30b1f91 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.c +++ b/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.c @@ -12,16 +12,16 @@ #include "dboolhuff.h" int vp8dx_start_decode(BOOL_DECODER *br, - const unsigned char *source, - unsigned int source_sz) + const unsigned char *data, + unsigned int data_size) { - br->user_buffer_end = source+source_sz; - br->user_buffer = source; - br->value = 0; - br->count = -8; - br->range = 255; + br->user_buffer_end = data + data_size; + br->user_buffer = data; + br->value = 0; + br->count = -8; + br->range = 255; - if (source_sz && !source) + if (data_size && !data) return 1; /* Populate the buffer */ diff --git a/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.h b/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.h index e854d7ddf3..fd54eb3f66 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.h +++ b/src/gallium/auxiliary/vl/vp8/decoder/dboolhuff.h @@ -40,8 +40,8 @@ typedef struct DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); int vp8dx_start_decode(BOOL_DECODER *br, - const unsigned char *source, - unsigned int source_sz); + const unsigned char *data, + unsigned int data_size); void vp8dx_bool_decoder_fill(BOOL_DECODER *br); @@ -62,13 +62,13 @@ void vp8dx_bool_decoder_fill(BOOL_DECODER *br); \ x = shift + CHAR_BIT - bits_left; \ loop_end = 0; \ - if(x >= 0) \ + if (x >= 0) \ { \ (_count) += VP8_LOTS_OF_BITS; \ loop_end = x; \ - if(!bits_left) break; \ + if (!bits_left) break; \ } \ - while(shift >= loop_end) \ + while (shift >= loop_end) \ { \ (_count) += CHAR_BIT; \ (_value) |= (VP8_BD_VALUE)*(_bufptr)++ << shift; \ @@ -148,13 +148,11 @@ static int vp8dx_bool_error(BOOL_DECODER *br) */ if ((br->count > VP8_BD_VALUE_SIZE) && (br->count < VP8_LOTS_OF_BITS)) { - /* We have tried to decode bits after the end of - * stream was encountered. + /* We have tried to decode bits after the end of stream was encountered. */ return 1; } - /* No error. */ return 0; } diff --git a/src/gallium/auxiliary/vl/vp8/decoder/decodeframe.c b/src/gallium/auxiliary/vl/vp8/decoder/decodeframe.c index 375cc53b03..f400c4f486 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/decodeframe.c +++ b/src/gallium/auxiliary/vl/vp8/decoder/decodeframe.c @@ -32,54 +32,32 @@ #include #include -void vp8cx_init_de_quantizer(VP8D_COMP *pbi) -{ - int i; - int Q; - VP8_COMMON *const pc = & pbi->common; - - for (Q = 0; Q < QINDEX_RANGE; Q++) - { - pc->Y1dequant[Q][0] = (short)vp8_dc_quant(Q, pc->y1dc_delta_q); - pc->Y2dequant[Q][0] = (short)vp8_dc2quant(Q, pc->y2dc_delta_q); - pc->UVdequant[Q][0] = (short)vp8_dc_uv_quant(Q, pc->uvdc_delta_q); - - /* all the ac values = ; */ - for (i = 1; i < 16; i++) - { - int rc = vp8_default_zig_zag1d[i]; - - pc->Y1dequant[Q][rc] = (short)vp8_ac_yquant(Q); - pc->Y2dequant[Q][rc] = (short)vp8_ac2quant(Q, pc->y2ac_delta_q); - pc->UVdequant[Q][rc] = (short)vp8_ac_uv_quant(Q, pc->uvac_delta_q); - } - } -} - void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd) { int i; int QIndex; MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; - VP8_COMMON *const pc = & pbi->common; + VP8_COMMON *const pc = &pbi->common; /* Decide whether to use the default or alternate baseline Q value. */ if (xd->segmentation_enabled) { - /* Abs Value */ if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA) { + /* Abs Value */ QIndex = xd->segment_feature_data[MB_LVL_ALT_Q][mbmi->segment_id]; } - /* Delta Value */ else { + /* Delta Value */ QIndex = pc->base_qindex + xd->segment_feature_data[MB_LVL_ALT_Q][mbmi->segment_id]; - QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0; /* Clamp to valid range */ + QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0; /* Clamp to valid range */ } } else + { QIndex = pc->base_qindex; + } /* Set up the block level dequant pointers */ for (i = 0; i < 16; i++) @@ -152,9 +130,9 @@ void clamp_mvs(MACROBLOCKD *xd) { int i; - for (i=0; i<16; i++) + for (i = 0; i < 16; i++) clamp_mv_to_umv_border(&xd->block[i].bmi.mv.as_mv, xd); - for (i=16; i<24; i++) + for (i = 16; i < 24; i++) clamp_uvmv_to_umv_border(&xd->block[i].bmi.mv.as_mv, xd); } else @@ -164,6 +142,25 @@ void clamp_mvs(MACROBLOCKD *xd) } } +static int get_delta_q(vp8_reader *bc, int prev, int *q_update) +{ + int ret_val = 0; + + if (vp8_read_bit(bc)) + { + ret_val = vp8_read_literal(bc, 4); + + if (vp8_read_bit(bc)) + ret_val = -ret_val; + } + + /* Trigger a quantizer update if the delta-q value has changed */ + if (ret_val != prev) + *q_update = 1; + + return ret_val; +} + static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_idx) { int eobtotal = 0; @@ -190,8 +187,7 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i if (eobtotal == 0 && mode != B_PRED && mode != SPLITMV) { /* Special case: Force the loopfilter to skip when eobtotal and - * mb_skip_coeff are zero. - * */ + * mb_skip_coeff are zero. */ xd->mode_info_context->mbmi.mb_skip_coeff = 1; skip_recon_mb(pbi, xd); @@ -289,27 +285,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i xd->dst.uv_stride, xd->eobs+16); } -static int get_delta_q(vp8_reader *bc, int prev, int *q_update) -{ - int ret_val = 0; - - if (vp8_read_bit(bc)) - { - ret_val = vp8_read_literal(bc, 4); - - if (vp8_read_bit(bc)) - ret_val = -ret_val; - } - - /* Trigger a quantizer update if the delta-q value has changed */ - if (ret_val != prev) - *q_update = 1; - - return ret_val; -} - static void -decode_mb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mb_row, MACROBLOCKD *xd) +decode_macroblock_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mb_row, MACROBLOCKD *xd) { int recon_yoffset, recon_uvoffset; int mb_col; @@ -321,8 +298,8 @@ decode_mb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mb_row, MACROBLOCKD *xd) memset(&pc->left_context, 0, sizeof(pc->left_context)); recon_yoffset = mb_row * recon_y_stride * 16; recon_uvoffset = mb_row * recon_uv_stride * 8; - /* reset above block coeffs */ + /* Reset above block coeffs */ xd->above_context = pc->above_context; xd->up_available = (mb_row != 0); @@ -333,8 +310,7 @@ decode_mb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mb_row, MACROBLOCKD *xd) { /* Distance of Mb to the various image edges. * These are specified to 8th pel as they are always compared to values - * that are in 1/8th pel units - */ + * that are in 1/8th pel units. */ xd->mb_to_left_edge = -((mb_col * 16) << 3); xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3; @@ -360,7 +336,7 @@ decode_mb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mb_row, MACROBLOCKD *xd) if (xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME) { - /* propagate errors from reference frames */ + /* Propagate errors from reference frames */ xd->corrupted |= pc->yv12_fb[ref_fb_idx].corrupted; } @@ -374,7 +350,7 @@ decode_mb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mb_row, MACROBLOCKD *xd) */ decode_macroblock(pbi, xd, mb_row * pc->mb_cols + mb_col); - /* 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); recon_yoffset += 16; @@ -385,31 +361,33 @@ decode_mb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mb_row, MACROBLOCKD *xd) xd->above_context++; } - /* adjust to the next row of mbs */ + /* Adjust to the next row of mbs */ vp8_extend_mb_row(&pc->yv12_fb[dst_fb_idx], xd->dst.y_buffer + 16, xd->dst.u_buffer + 8, xd->dst.v_buffer + 8); - /* skip prediction column */ + /* Skip prediction column */ ++xd->mode_info_context; } -static unsigned int read_partition_size(const unsigned char *cx_size) +static unsigned int token_decoder_readpartitionsize(const unsigned char *cx_size) { const unsigned int size = cx_size[0] + (cx_size[1] << 8) + (cx_size[2] << 16); return size; } -static void setup_token_decoder(VP8D_COMP *pbi, +static void token_decoder_setup(VP8D_COMP *pbi, const unsigned char *cx_data) { int num_part; int i; VP8_COMMON *pc = &pbi->common; - const unsigned char *user_data_end = pbi->Source + pbi->source_sz; - vp8_reader *bool_decoder; - const unsigned char *partition; + const unsigned char *user_data_end = pbi->data + pbi->data_size; + + /* Set up pointers to the first partition */ + vp8_reader *bool_decoder = &pbi->bc2; + const unsigned char *partition = cx_data; /* Parse number of token partitions to use */ const TOKEN_PARTITION multi_token_partition = (TOKEN_PARTITION)vp8_read_literal(&pbi->bc, 2); @@ -420,10 +398,6 @@ static void setup_token_decoder(VP8D_COMP *pbi, num_part = 1 << pc->multi_token_partition; - /* Set up pointers to the first partition */ - partition = cx_data; - bool_decoder = &pbi->bc2; - if (num_part > 1) { CHECK_MEM_ERROR(pbi->mbc, vpx_malloc(num_part * sizeof(vp8_reader))); @@ -440,7 +414,7 @@ static void setup_token_decoder(VP8D_COMP *pbi, * size is implicit. */ if (i < num_part - 1) { - partition_size = read_partition_size(partition_size_ptr); + partition_size = token_decoder_readpartitionsize(partition_size_ptr); } else { @@ -467,7 +441,7 @@ static void setup_token_decoder(VP8D_COMP *pbi, } } -static void stop_token_decoder(VP8D_COMP *pbi) +static void token_decoder_stop(VP8D_COMP *pbi) { VP8_COMMON *pc = &pbi->common; @@ -478,10 +452,10 @@ static void stop_token_decoder(VP8D_COMP *pbi) } } -static void init_frame(VP8D_COMP *pbi) +static void vp8_frame_init(VP8D_COMP *pbi) { - VP8_COMMON *const pc = & pbi->common; - MACROBLOCKD *const xd = & pbi->mb; + VP8_COMMON *const pc = &pbi->common; + MACROBLOCKD *const xd = &pbi->mb; if (pc->frame_type == KEY_FRAME) { @@ -516,7 +490,7 @@ static void init_frame(VP8D_COMP *pbi) { if (pc->use_bilinear_mc_filter) { - pc->mcomp_filter_type = BILINEAR; + pc->mcomp_filter_type = BILINEAR; xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear4x4); xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear8x4); xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), bilinear8x8); @@ -524,7 +498,7 @@ static void init_frame(VP8D_COMP *pbi) } else { - pc->mcomp_filter_type = SIXTAP; + pc->mcomp_filter_type = SIXTAP; xd->subpixel_predict = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap4x4); xd->subpixel_predict8x4 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap8x4); xd->subpixel_predict8x8 = SUBPIX_INVOKE(RTCD_VTABLE(subpix), sixtap8x8); @@ -540,20 +514,19 @@ static void init_frame(VP8D_COMP *pbi) xd->corrupted = 0; /* init without corruption */ } -int vp8_decode_frame(VP8D_COMP *pbi) +int vp8_frame_decode(VP8D_COMP *pbi) { vp8_reader *const bc = &pbi->bc; VP8_COMMON *const pc = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; - const unsigned char *data = (const unsigned char *)pbi->Source; - const unsigned char *data_end = data + pbi->source_sz; + const unsigned char *data = (const unsigned char *)pbi->data; + const unsigned char *data_end = data + pbi->data_size; ptrdiff_t first_partition_length_in_bytes = 0; int mb_row; int i, j, k, l; - const int *const mb_feature_data_bits = vp8_mb_feature_data_bits; - /* start with no corruption of current frame */ + /* Start with no corruption of current frame */ xd->corrupted = 0; pc->yv12_fb[pc->new_fb_idx].corrupted = 0; @@ -636,7 +609,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) return -1; } - init_frame(pbi); + vp8_frame_init(pbi); if (vp8dx_start_decode(bc, data, data_end - data)) { @@ -673,7 +646,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) /* Frame level data */ if (vp8_read_bit(bc)) { - xd->segment_feature_data[i][j] = (signed char)vp8_read_literal(bc, mb_feature_data_bits[i]); + xd->segment_feature_data[i][j] = (signed char)vp8_read_literal(bc, vp8_mb_feature_data_bits[i]); if (vp8_read_bit(bc)) xd->segment_feature_data[i][j] = -xd->segment_feature_data[i][j]; @@ -743,7 +716,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) } } - setup_token_decoder(pbi, data + first_partition_length_in_bytes); + token_decoder_setup(pbi, data + first_partition_length_in_bytes); xd->current_bc = &pbi->bc2; /* Read the default quantizers. */ @@ -760,7 +733,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) pc->uvac_delta_q = get_delta_q(bc, pc->uvac_delta_q, &q_update); if (q_update) - vp8cx_init_de_quantizer(pbi); + vp8_initialize_dequantizer(&pbi->common); /* MB level dequantizer setup */ mb_init_dequantizer(pbi, &pbi->mb); @@ -768,11 +741,10 @@ int vp8_decode_frame(VP8D_COMP *pbi) /* Determine if the golden frame or ARF buffer should be updated and how. * For all non key frames the GF and ARF refresh flags and sign bias - * flags must be set explicitly. - */ + * flags must be set explicitly. */ 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_alt_ref_frame = vp8_read_bit(bc); @@ -800,15 +772,15 @@ int vp8_decode_frame(VP8D_COMP *pbi) pc->refresh_last_frame = (pc->frame_type == KEY_FRAME || vp8_read_bit(bc)); - /* read coef probability tree */ + /* Read coef probability tree */ for (i = 0; i < BLOCK_TYPES; i++) for (j = 0; j < COEF_BANDS; j++) for (k = 0; k < PREV_COEF_CONTEXTS; k++) for (l = 0; l < ENTROPY_NODES; l++) { - vp8_prob *const p = pc->fc.coef_probs [i][j][k] + l; + vp8_prob *const p = pc->fc.coef_probs[i][j][k] + l; - if (vp8_read(bc, vp8_coef_update_probs [i][j][k][l])) + if (vp8_read(bc, vp8_coef_update_probs[i][j][k][l])) { *p = (vp8_prob)vp8_read_literal(bc, 8); } @@ -843,18 +815,18 @@ int vp8_decode_frame(VP8D_COMP *pbi) { if (num_part > 1) { - xd->current_bc = & pbi->mbc[ibc]; + xd->current_bc = &pbi->mbc[ibc]; ibc++; if (ibc == num_part) ibc = 0; } - decode_mb_row(pbi, pc, mb_row, xd); + decode_macroblock_row(pbi, pc, mb_row, xd); } } - stop_token_decoder(pbi); + token_decoder_stop(pbi); /* Collect information about decoder corruption. */ /* 1. Check first boolean decoder for errors. */ @@ -866,8 +838,9 @@ int vp8_decode_frame(VP8D_COMP *pbi) /* printf("Decoder: Frame Decoded, Size Roughly:%d bytes \n", bc->pos+pbi->bc2.pos); */ /* If this was a kf or Gf note the Q used */ - if ((pc->frame_type == KEY_FRAME) || - pc->refresh_golden_frame || pc->refresh_alt_ref_frame) + if (pc->frame_type == KEY_FRAME + || pc->refresh_golden_frame + || pc->refresh_alt_ref_frame) { pc->last_kf_gf_q = pc->base_qindex; } diff --git a/src/gallium/auxiliary/vl/vp8/decoder/onyxd_if.c b/src/gallium/auxiliary/vl/vp8/decoder/onyxd_if.c index 51ad20b389..1526d06ff9 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/onyxd_if.c +++ b/src/gallium/auxiliary/vl/vp8/decoder/onyxd_if.c @@ -9,20 +9,20 @@ */ +#include +#include + +#include "../vp8_mem.h" + #include "../common/onyxc_int.h" #include "onyxd_int.h" -#include "../vp8_mem.h" #include "../common/onyxd.h" #include "../common/alloccommon.h" #include "../common/yv12utils.h" -#include -#include - #include "../common/quant_common.h" #include "detokenize.h" -extern void vp8cx_init_de_quantizer(VP8D_COMP *pbi); static int get_free_fb(VP8_COMMON *cm); static void ref_cnt_fb(int *buf, int *idx, int new_idx); @@ -50,10 +50,7 @@ VP8D_PTR vp8dx_create_decompressor() pbi->common.current_video_frame = 0; pbi->ready_for_new_data = 1; - /* vp8cx_init_de_quantizer() is first called here. Add check in - * frame_init_dequantizer() to avoid unnecessary calling of - * vp8cx_init_de_quantizer() for every frame. */ - vp8cx_init_de_quantizer(pbi); + vp8_initialize_dequantizer(&pbi->common); // vp8_loop_filter_init(&pbi->common); @@ -96,7 +93,9 @@ static void ref_cnt_fb(int *buf, int *idx, int new_idx) buf[new_idx]++; } -/* If any buffer copy / swapping is signalled it should be done here. */ +/** + * If any buffer copy / swapping is signalled it should be done here. + */ static int swap_frame_buffers(VP8_COMMON *cm) { int err = 0; @@ -104,8 +103,7 @@ static int swap_frame_buffers(VP8_COMMON *cm) /* The alternate reference frame or golden frame can be updated * using the new, last, or golden/alt ref frame. If it * is updated using the newly decoded frame it is a refresh. - * An update using the last or golden/alt ref frame is a copy. - */ + * An update using the last or golden/alt ref frame is a copy. */ if (cm->copy_buffer_to_arf) { int new_fb = 0; @@ -154,7 +152,9 @@ static int swap_frame_buffers(VP8_COMMON *cm) return err; } -int vp8dx_receive_compressed_data(VP8D_PTR ptr, const unsigned char *data, unsigned data_size, int64_t time_stamp) +int vp8dx_receive_compressed_data(VP8D_PTR ptr, + const unsigned char *data, unsigned data_size, + int64_t timestamp_deadline) { VP8D_COMP *pbi = (VP8D_COMP *)ptr; VP8_COMMON *cm = &pbi->common; @@ -171,21 +171,19 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, const unsigned char *data, unsig pbi->common.error.error_code = VPX_CODEC_OK; { - pbi->Source = data; - pbi->source_sz = data_size; + pbi->data = data; + pbi->data_size = data_size; - if (pbi->source_sz == 0) + if (pbi->data_size == 0) { /* This is used to signal that we are missing frames. * We do not know if the missing frame(s) was supposed to update * any of the reference buffers, but we act conservative and - * mark only the last buffer as corrupted. - */ + * mark only the last buffer as corrupted. */ cm->yv12_fb[cm->lst_fb_idx].corrupted = 1; /* If error concealment is disabled we won't signal missing frames to - * the decoder. - */ + * the decoder. */ { /* Signal that we have no frame to show. */ cm->show_frame = 0; @@ -201,8 +199,7 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, const unsigned char *data, unsig /* We do not know if the missing frame(s) was supposed to update * any of the reference buffers, but we act conservative and - * mark only the last buffer as corrupted. - */ + * mark only the last buffer as corrupted. */ cm->yv12_fb[cm->lst_fb_idx].corrupted = 1; if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0) @@ -214,7 +211,7 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, const unsigned char *data, unsig pbi->common.error.setjmp = 1; } - retcode = vp8_decode_frame(pbi); + retcode = vp8_frame_decode(pbi); if (retcode < 0) { @@ -250,8 +247,8 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, const unsigned char *data, unsig cm->current_video_frame++; pbi->ready_for_new_data = 0; - pbi->last_time_stamp = time_stamp; - pbi->source_sz = 0; + pbi->last_time_stamp = timestamp_deadline; + pbi->data_size = 0; pbi->common.error.setjmp = 0; return retcode; @@ -259,8 +256,8 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, const unsigned char *data, unsig int vp8dx_get_raw_frame(VP8D_PTR ptr, YV12_BUFFER_CONFIG *sd, - int64_t *time_stamp, - int64_t *time_end_stamp) + int64_t *timestamp, + int64_t *timestamp_end) { int ret = -1; VP8D_COMP *pbi = (VP8D_COMP *)ptr; @@ -273,8 +270,8 @@ int vp8dx_get_raw_frame(VP8D_PTR ptr, return ret; pbi->ready_for_new_data = 1; - *time_stamp = pbi->last_time_stamp; - *time_end_stamp = 0; + *timestamp = pbi->last_time_stamp; + *timestamp_end = 0; sd->clrtype = pbi->common.clr_type; diff --git a/src/gallium/auxiliary/vl/vp8/decoder/onyxd_int.h b/src/gallium/auxiliary/vl/vp8/decoder/onyxd_int.h index 7ec316c224..721682b43b 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/onyxd_int.h +++ b/src/gallium/auxiliary/vl/vp8/decoder/onyxd_int.h @@ -39,8 +39,8 @@ typedef struct vp8_reader bc, bc2; - const unsigned char *Source; - unsigned int source_sz; + const unsigned char *data; + unsigned int data_size; vp8_reader *mbc; int64_t last_time_stamp; @@ -53,7 +53,7 @@ typedef struct } VP8D_COMP; -int vp8_decode_frame(VP8D_COMP *cpi); +int vp8_frame_decode(VP8D_COMP *cpi); #if CONFIG_DEBUG #define CHECK_MEM_ERROR(lval,expr) do { \ diff --git a/src/gallium/auxiliary/vl/vp8/decoder/treereader.h b/src/gallium/auxiliary/vl/vp8/decoder/treereader.h index c216ec27f1..67836d4359 100644 --- a/src/gallium/auxiliary/vl/vp8/decoder/treereader.h +++ b/src/gallium/auxiliary/vl/vp8/decoder/treereader.h @@ -23,13 +23,12 @@ typedef BOOL_DECODER vp8_reader; /* Intent of tree data structure is to make decoding trivial. */ -static int vp8_treed_read(vp8_reader *const r, /* !!! must return a 0 or 1 !!! */ - vp8_tree t, - const vp8_prob *const p) +/** must return a 0 or 1 !!! */ +static int vp8_treed_read(vp8_reader *const r, vp8_tree t, const vp8_prob *const p) { register vp8_tree_index i = 0; - while ((i = t[ i + vp8_read(r, p[i>>1])]) > 0) ; + while ((i = t[i + vp8_read(r, p[i >> 1])]) > 0); return -i; } diff --git a/src/gallium/auxiliary/vl/vp8/vp8_mem.h b/src/gallium/auxiliary/vl/vp8/vp8_mem.h index 2b3b4d3f84..d7361ca57c 100644 --- a/src/gallium/auxiliary/vl/vp8/vp8_mem.h +++ b/src/gallium/auxiliary/vl/vp8/vp8_mem.h @@ -22,8 +22,6 @@ extern "C" { #endif -/* ************************************************************************** */ - #define ADDRESS_STORAGE_SIZE sizeof(size_t) #define DEFAULT_ALIGNMENT 32 // must be >= 1 ! @@ -37,16 +35,12 @@ extern "C" { #define DECLARE_ALIGNED(n,typ,val) typ val #endif -/* ************************************************************************** */ - void *vpx_memalign(size_t align, size_t size); void *vpx_malloc(size_t size); void *vpx_calloc(size_t num, size_t size); void *vpx_realloc(void *memblk, size_t size); void vpx_free(void *memblk); -/* ************************************************************************** */ - #if defined(__cplusplus) } #endif -- cgit v1.2.3