diff options
author | Emeric Grange <emeric.grange@gmail.com> | 2012-01-19 20:13:44 +0100 |
---|---|---|
committer | Emeric Grange <emeric.grange@gmail.com> | 2012-06-24 16:57:33 +0200 |
commit | f8b01453b9ba62c99de7b7f37f7c93cdc3b28a14 (patch) | |
tree | ada16ba4d39143a1c86fe14748d46048e3e3fbaf | |
parent | 879d00937efad11e887f3e5050e3dec4972a28d1 (diff) |
g3dvl: A collection of small cleanups
Signed-off-by: Emeric Grange <emeric.grange@gmail.com>
19 files changed, 210 insertions, 280 deletions
diff --git a/src/gallium/auxiliary/vl/vp8/decodeframe.c b/src/gallium/auxiliary/vl/vp8/decodeframe.c index 8c6b1ef91f..b46aff9789 100644 --- a/src/gallium/auxiliary/vl/vp8/decodeframe.c +++ b/src/gallium/auxiliary/vl/vp8/decodeframe.c @@ -9,29 +9,24 @@ */ -#include "reconintra.h" -#include "reconintra4x4.h" #include "recon.h" -#include "reconinter.h" -#include "dequantize_dispatch.h" #include "idct_dispatch.h" #include "detokenize.h" #include "invtrans.h" #include "alloccommon.h" #include "entropymode.h" #include "dequantize_common.h" -#include "yv12utils.h" +#include "dequantize_dispatch.h" #include "decodemv.h" #include "treereader.h" +#include "yv12utils.h" -#include "vp8_decoder.h".h" +#include "vp8_decoder.h" #include "vp8_mem.h" #include <assert.h> #include <stdio.h> -#define RTCD_VTABLE(x) NULL - void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd) { int i; @@ -432,7 +427,13 @@ static void token_decoder_setup(VP8D_COMP *pbi, if (num_part > 1) { - CHECK_MEM_ERROR(pbi->mbd, vpx_malloc(num_part * sizeof(BOOL_DECODER))); + pbi->mbd = vpx_memalign(32, num_part * sizeof(BOOL_DECODER)); + if (!pbi->mbd) + { + // Memory allocation failed + assert(0); + } + bool_decoder = pbi->mbd; partition += 3 * (num_part - 1); } diff --git a/src/gallium/auxiliary/vl/vp8/dequantize.c b/src/gallium/auxiliary/vl/vp8/dequantize.c index 90a1cd2411..77b5266185 100644 --- a/src/gallium/auxiliary/vl/vp8/dequantize.c +++ b/src/gallium/auxiliary/vl/vp8/dequantize.c @@ -55,7 +55,7 @@ void vp8_dequant_idct_add_c(short *input, short *dq, unsigned char *pred, if (a > 255) a = 255; - dest[c] = (unsigned char) a; + dest[c] = (unsigned char)a; } dest += stride; @@ -97,7 +97,7 @@ void vp8_dequant_dc_idct_add_c(short *input, short *dq, unsigned char *pred, if (a > 255) a = 255; - dest[c] = (unsigned char) a; + dest[c] = (unsigned char)a; } dest += stride; diff --git a/src/gallium/auxiliary/vl/vp8/dequantize_common.c b/src/gallium/auxiliary/vl/vp8/dequantize_common.c index 9a63c7210f..f2fc687766 100644 --- a/src/gallium/auxiliary/vl/vp8/dequantize_common.c +++ b/src/gallium/auxiliary/vl/vp8/dequantize_common.c @@ -20,7 +20,7 @@ static const int dc_qlookup[QINDEX_RANGE] = 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 93, 95, 96, 98, 100, 101, 102, 104, 106, 108, 110, 112, 114, 116, 118, - 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 143, 145, 148, 151, 154, 157, + 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 143, 145, 148, 151, 154, 157, }; static const int ac_qlookup[QINDEX_RANGE] = @@ -30,23 +30,23 @@ static const int ac_qlookup[QINDEX_RANGE] = 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, - 110, 112, 114, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152, - 155, 158, 161, 164, 167, 170, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, - 213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284, + 110, 112, 114, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152, + 155, 158, 161, 164, 167, 170, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, + 213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284, }; static int vp8_dc_quant(int QIndex, int Delta) { int retval; - QIndex = QIndex + Delta; + QIndex += Delta; if (QIndex > 127) QIndex = 127; else if (QIndex < 0) QIndex = 0; - retval = dc_qlookup[ QIndex ]; + retval = dc_qlookup[QIndex]; return retval; } @@ -55,14 +55,14 @@ static int vp8_dc2quant(int QIndex, int Delta) { int retval; - QIndex = QIndex + Delta; + QIndex += Delta; if (QIndex > 127) QIndex = 127; else if (QIndex < 0) QIndex = 0; - retval = dc_qlookup[ QIndex ] * 2; + retval = dc_qlookup[QIndex] * 2; return retval; } @@ -71,14 +71,14 @@ static int vp8_dc_uv_quant(int QIndex, int Delta) { int retval; - QIndex = QIndex + Delta; + QIndex += Delta; if (QIndex > 127) QIndex = 127; else if (QIndex < 0) QIndex = 0; - retval = dc_qlookup[ QIndex ]; + retval = dc_qlookup[QIndex]; if (retval > 132) retval = 132; @@ -95,7 +95,7 @@ static int vp8_ac_yquant(int QIndex) else if (QIndex < 0) QIndex = 0; - retval = ac_qlookup[ QIndex ]; + retval = ac_qlookup[QIndex]; return retval; } @@ -104,14 +104,14 @@ static int vp8_ac2quant(int QIndex, int Delta) { int retval; - QIndex = QIndex + Delta; + QIndex += Delta; if (QIndex > 127) QIndex = 127; else if (QIndex < 0) QIndex = 0; - retval = (ac_qlookup[ QIndex ] * 155) / 100; + retval = (ac_qlookup[QIndex] * 155) / 100; if (retval < 8) retval = 8; @@ -123,14 +123,14 @@ static int vp8_ac_uv_quant(int QIndex, int Delta) { int retval; - QIndex = QIndex + Delta; + QIndex += Delta; if (QIndex > 127) QIndex = 127; else if (QIndex < 0) QIndex = 0; - retval = ac_qlookup[ QIndex ]; + retval = ac_qlookup[QIndex]; return retval; } diff --git a/src/gallium/auxiliary/vl/vp8/detokenize.c b/src/gallium/auxiliary/vl/vp8/detokenize.c index 1ce65e0364..5788569058 100644 --- a/src/gallium/auxiliary/vl/vp8/detokenize.c +++ b/src/gallium/auxiliary/vl/vp8/detokenize.c @@ -39,7 +39,7 @@ DECLARE_ALIGNED(16, static const unsigned char, coef_bands_x[16]) = 6 * OCB_X, 6 * OCB_X, 6 * OCB_X, 7 * OCB_X }; -DECLARE_ALIGNED(16, static const TOKENEXTRABITS, vp8d_token_extra_bits2[MAX_ENTROPY_TOKENS]) = +DECLARE_ALIGNED(16, static const TOKEN_EXTRABITS, vp8d_token_extra_bits2[MAX_ENTROPY_TOKENS]) = { { 0, -1, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* ZERO_TOKEN */ { 1, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, /* ONE_TOKEN */ @@ -68,22 +68,23 @@ const unsigned char vp8_block2above[25] = void vp8_reset_mb_tokens_context(MACROBLOCKD *x) { /* Clear entropy contexts for Y2 blocks */ - if (x->mode_info_context->mbmi.mode != B_PRED && x->mode_info_context->mbmi.mode != SPLITMV) + if (x->mode_info_context->mbmi.mode != B_PRED && + x->mode_info_context->mbmi.mode != SPLITMV) { memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES)); memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES)); } else { - memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES)-1); - memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES)-1); + memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) - 1); + memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) - 1); } } DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); #define FILL \ - if(count < 0) \ + if (count < 0) \ VP8DX_BOOL_DECODER_FILL(count, value, bufptr, bufend); #define NORMALIZE \ @@ -96,87 +97,88 @@ DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]); } #define DECODE_AND_APPLYSIGN(value_to_sign) \ - split = (range + 1) >> 1; \ - bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8); \ - FILL \ - if ( value < bigsplit ) \ { \ - range = split; \ - v= value_to_sign; \ - } \ - else \ - { \ - range = range-split; \ - value = value-bigsplit; \ - v = -value_to_sign; \ - } \ - range +=range; \ - value +=value; \ - count--; + split = (range + 1) >> 1; \ + bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8); \ + FILL \ + if (value < bigsplit) { \ + range = split; \ + v = value_to_sign; \ + } \ + else { \ + range = range - split; \ + value = value - bigsplit; \ + v = -value_to_sign; \ + } \ + range += range; \ + value += value; \ + count--; \ + } #define DECODE_AND_BRANCH_IF_ZERO(probability,branch) \ { \ - split = 1 + (((probability*(range-1))) >> 8); \ + split = 1 + (((probability*(range - 1))) >> 8); \ bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8); \ FILL \ - if (value < bigsplit) \ - { \ + if (value < bigsplit) { \ range = split; \ NORMALIZE \ goto branch; \ } \ value -= bigsplit; \ - range = range - split; \ + range -= split; \ NORMALIZE \ } #define DECODE_AND_LOOP_IF_ZERO(probability,branch) \ { \ - split = 1 + (((probability*(range-1))) >> 8); \ + split = 1 + (((probability*(range - 1))) >> 8); \ bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8); \ FILL \ - if ( value < bigsplit ) \ - { \ + if (value < bigsplit ) { \ range = split; \ NORMALIZE \ Prob = coef_probs; \ if (c < 15) { \ - ++c; \ - Prob += coef_bands_x[c]; \ - goto branch; \ + ++c; \ + Prob += coef_bands_x[c]; \ + goto branch; \ } goto BLOCK_FINISHED; /*for malformed input */ \ } \ value -= bigsplit; \ - range = range - split; \ + range -= split; \ NORMALIZE \ } #define DECODE_SIGN_WRITE_COEFF_AND_CHECK_EXIT(val) \ - DECODE_AND_APPLYSIGN(val) \ - Prob = coef_probs + (ENTROPY_NODES*2); \ - if (c < 15) { \ - qcoeff_ptr [ scan[c] ] = (int16_t) v; \ - ++c; \ - goto DO_WHILE; } \ - qcoeff_ptr [ scan[15] ] = (int16_t) v; \ - goto BLOCK_FINISHED; + { \ + DECODE_AND_APPLYSIGN(val) \ + Prob = coef_probs + (ENTROPY_NODES*2); \ + if (c < 15) { \ + qcoeff_ptr[scan[c]] = (int16_t)v; \ + ++c; \ + goto DO_WHILE; \ + } \ + qcoeff_ptr[scan[15]] = (int16_t)v; \ + goto BLOCK_FINISHED; \ + } #define DECODE_EXTRABIT_AND_ADJUST_VAL(t, bits_count) \ - 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) \ - { \ - range = range-split; \ - value = value-bigsplit; \ - val += ((uint16_t)1 << bits_count); \ - } \ - else \ { \ - range = split; \ - } \ - NORMALIZE + 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) { \ + range = range-split; \ + value = value-bigsplit; \ + val += ((uint16_t)1 << bits_count); \ + } \ + else { \ + range = split; \ + } \ + NORMALIZE \ + } #define VP8_COMBINEENTROPYCONTEXTS(Dest, A, B) \ Dest = ((A) != 0) + ((B) != 0); @@ -194,8 +196,8 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *x) ENTROPY_CONTEXT *a; ENTROPY_CONTEXT *l; - int i; + int i = 0; int eobtotal = 0; register int count; @@ -210,22 +212,19 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *x) VP8_BD_VALUE bigsplit; int16_t *qcoeff_ptr; - const vp8_prob *coef_probs; - int type; - int stop; + int type = 3; + int stop = 16; int16_t val, bits_count; int16_t c; int16_t v; const vp8_prob *Prob; - - type = 3; - i = 0; - stop = 16; + const vp8_prob *coef_probs; scan = vp8_default_zig_zag1d; qcoeff_ptr = &x->qcoeff[0]; - if (x->mode_info_context->mbmi.mode != B_PRED && x->mode_info_context->mbmi.mode != SPLITMV) + if (x->mode_info_context->mbmi.mode != B_PRED && + x->mode_info_context->mbmi.mode != SPLITMV) { i = 24; stop = 24; @@ -240,7 +239,7 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *x) count = bd->count; range = bd->range; - coef_probs = fc->coef_probs [type] [0] [0]; + coef_probs = fc->coef_probs[type][0][0]; BLOCK_LOOP: a = A + vp8_block2above[i]; @@ -270,7 +269,7 @@ CHECK_0_: do { DECODE_EXTRABIT_AND_ADJUST_VAL(DCT_VAL_CATEGORY6, bits_count); - bits_count -- ; + bits_count --; } while (bits_count >= 0); @@ -331,12 +330,12 @@ ONE_CONTEXT_NODE_0_: if (c < 15) { - qcoeff_ptr [ scan[c] ] = (int16_t)v; + qcoeff_ptr[scan[c]] = (int16_t)v; ++c; goto DO_WHILE; } - qcoeff_ptr [ scan[15] ] = (int16_t)v; + qcoeff_ptr[scan[15]] = (int16_t)v; BLOCK_FINISHED: *a = *l = ((eobs[i] = c) != !type); /* any nonzero data ? */ @@ -353,7 +352,7 @@ BLOCK_FINISHED: type = 0; i = 0; stop = 16; - coef_probs = fc->coef_probs [type] [0] [0]; + coef_probs = fc->coef_probs[type][0][0]; qcoeff_ptr -= (24*16 + 16); goto BLOCK_LOOP; } @@ -361,7 +360,7 @@ BLOCK_FINISHED: if (i == 16) { type = 2; - coef_probs = fc->coef_probs [type] [0] [0]; + coef_probs = fc->coef_probs[type][0][0]; stop = 24; goto BLOCK_LOOP; } diff --git a/src/gallium/auxiliary/vl/vp8/idct.c b/src/gallium/auxiliary/vl/vp8/idct.c index 5dc4427263..ce981cb99c 100644 --- a/src/gallium/auxiliary/vl/vp8/idct.c +++ b/src/gallium/auxiliary/vl/vp8/idct.c @@ -92,10 +92,9 @@ void vp8_short_idct4x4llm_c(short *input, short *output, int pitch) void vp8_short_idct4x4llm_1_c(short *input, short *output, int pitch) { int i; - int a1; + int a1 = ((input[0] + 4) >> 3); short *op = output; int shortpitch = pitch >> 1; - a1 = ((input[0] + 4) >> 3); for (i = 0; i < 4; i++) { @@ -117,7 +116,7 @@ void vp8_dc_only_idct_add_c(short input_dc, unsigned char *pred_ptr, { for (c = 0; c < 4; c++) { - int a = a1 + pred_ptr[c] ; + int a = a1 + pred_ptr[c]; if (a < 0) a = 0; @@ -125,7 +124,7 @@ void vp8_dc_only_idct_add_c(short input_dc, unsigned char *pred_ptr, if (a > 255) a = 255; - dst_ptr[c] = (unsigned char) a ; + dst_ptr[c] = (unsigned char)a; } dst_ptr += stride; @@ -184,11 +183,9 @@ void vp8_short_inv_walsh4x4_c(short *input, short *output) void vp8_short_inv_walsh4x4_1_c(short *input, short *output) { int i; - int a1; + int a1 = ((input[0] + 3) >> 3); short *op = output; - a1 = ((input[0] + 3) >> 3); - for (i = 0; i < 4; i++) { op[0] = a1; diff --git a/src/gallium/auxiliary/vl/vp8/idct_dispatch.h b/src/gallium/auxiliary/vl/vp8/idct_dispatch.h index 28a5c92060..0cec664b7a 100644 --- a/src/gallium/auxiliary/vl/vp8/idct_dispatch.h +++ b/src/gallium/auxiliary/vl/vp8/idct_dispatch.h @@ -19,9 +19,8 @@ void sym(short *input, short *output, int pitch) #define prototype_idct_scalar_add(sym) \ - void sym(short input, \ - unsigned char *pred, unsigned char *output, \ - int pitch, int stride) + void sym(short input, unsigned char *pred, \ + unsigned char *output, int pitch, int stride) #ifndef vp8_idct_idct1 #define vp8_idct_idct1 vp8_short_idct4x4llm_1_c diff --git a/src/gallium/auxiliary/vl/vp8/recon.c b/src/gallium/auxiliary/vl/vp8/recon.c index ac87c9c461..14785d105a 100644 --- a/src/gallium/auxiliary/vl/vp8/recon.c +++ b/src/gallium/auxiliary/vl/vp8/recon.c @@ -22,7 +22,7 @@ void vp8_recon_b_c(unsigned char *pred_ptr, { for (c = 0; c < 4; c++) { - int a = diff_ptr[c] + pred_ptr[c] ; + int a = diff_ptr[c] + pred_ptr[c]; if (a < 0) a = 0; @@ -30,7 +30,7 @@ void vp8_recon_b_c(unsigned char *pred_ptr, if (a > 255) a = 255; - dst_ptr[c] = (unsigned char) a ; + dst_ptr[c] = (unsigned char)a; } dst_ptr += stride; @@ -50,7 +50,7 @@ void vp8_recon4b_c(unsigned char *pred_ptr, { for (c = 0; c < 16; c++) { - int a = diff_ptr[c] + pred_ptr[c] ; + int a = diff_ptr[c] + pred_ptr[c]; if (a < 0) a = 0; @@ -58,7 +58,7 @@ void vp8_recon4b_c(unsigned char *pred_ptr, if (a > 255) a = 255; - dst_ptr[c] = (unsigned char) a ; + dst_ptr[c] = (unsigned char)a; } dst_ptr += stride; @@ -78,7 +78,7 @@ void vp8_recon2b_c(unsigned char *pred_ptr, { for (c = 0; c < 8; c++) { - int a = diff_ptr[c] + pred_ptr[c] ; + int a = diff_ptr[c] + pred_ptr[c]; if (a < 0) a = 0; @@ -86,7 +86,7 @@ void vp8_recon2b_c(unsigned char *pred_ptr, if (a > 255) a = 255; - dst_ptr[c] = (unsigned char) a ; + dst_ptr[c] = (unsigned char)a; } dst_ptr += stride; @@ -95,8 +95,7 @@ void vp8_recon2b_c(unsigned char *pred_ptr, } } -void vp8_recon_mby_c(const vp8_recon_rtcd_vtable_t *rtcd, - MACROBLOCKD *x) +void vp8_recon_mby_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x) { int i; @@ -108,8 +107,7 @@ void vp8_recon_mby_c(const vp8_recon_rtcd_vtable_t *rtcd, } } -void vp8_recon_mb_c(const vp8_recon_rtcd_vtable_t *rtcd, - MACROBLOCKD *x) +void vp8_recon_mb_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x) { int i; diff --git a/src/gallium/auxiliary/vl/vp8/recon.h b/src/gallium/auxiliary/vl/vp8/recon.h index 26201e7362..60c7831982 100644 --- a/src/gallium/auxiliary/vl/vp8/recon.h +++ b/src/gallium/auxiliary/vl/vp8/recon.h @@ -13,6 +13,9 @@ #define RECON_H #include "blockd.h" +#include "reconinter.h" +#include "reconintra.h" +#include "reconintra4x4.h" #include "recon_dispatch.h" void vp8_recon_b_c(unsigned char *pred_ptr, @@ -30,10 +33,8 @@ void vp8_recon2b_c(unsigned char *pred_ptr, unsigned char *dst_ptr, int stride); -void vp8_recon_mby_c(const vp8_recon_rtcd_vtable_t *rtcd, - MACROBLOCKD *x); +void vp8_recon_mby_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x); -void vp8_recon_mb_c(const vp8_recon_rtcd_vtable_t *rtcd, - MACROBLOCKD *x); +void vp8_recon_mb_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x); #endif /* RECON_H */ diff --git a/src/gallium/auxiliary/vl/vp8/recon_dispatch.h b/src/gallium/auxiliary/vl/vp8/recon_dispatch.h index aee90a284d..d3182812b6 100644 --- a/src/gallium/auxiliary/vl/vp8/recon_dispatch.h +++ b/src/gallium/auxiliary/vl/vp8/recon_dispatch.h @@ -14,8 +14,11 @@ #include "blockd.h" +struct vp8_recon_rtcd_vtable; + #define prototype_copy_block(sym) \ - void sym(unsigned char *src, int src_pitch, unsigned char *dst, int dst_pitch) + void sym(unsigned char *src, int src_pitch, \ + unsigned char *dst, int dst_pitch) #define prototype_recon_block(sym) \ void sym(unsigned char *pred, short *diff, unsigned char *dst, int pitch) @@ -23,13 +26,12 @@ #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) -struct vp8_recon_rtcd_vtable; - #ifndef vp8_recon_copy16x16 #define vp8_recon_copy16x16 vp8_copy_mem16x16_c #endif diff --git a/src/gallium/auxiliary/vl/vp8/reconinter.c b/src/gallium/auxiliary/vl/vp8/reconinter.c index 850a4a74a9..b40fe64f38 100644 --- a/src/gallium/auxiliary/vl/vp8/reconinter.c +++ b/src/gallium/auxiliary/vl/vp8/reconinter.c @@ -13,11 +13,7 @@ #include "filter_dispatch.h" #include "blockd.h" #include "reconinter.h" - -/* Use this define on systems where unaligned int reads and writes are - * not allowed, i.e. ARM architectures. - */ -/*#define MUST_BE_ALIGNED*/ +#include "vp8_mem.h" static const int bbb[4] = {0, 2, 8, 10}; @@ -46,10 +42,10 @@ void vp8_copy_mem16x16_c(unsigned char *src, int src_stride, dst[14] = src[14]; dst[15] = src[15]; #else - ((int *)dst)[0] = ((int *)src)[0] ; - ((int *)dst)[1] = ((int *)src)[1] ; - ((int *)dst)[2] = ((int *)src)[2] ; - ((int *)dst)[3] = ((int *)src)[3] ; + ((int *)dst)[0] = ((int *)src)[0]; + ((int *)dst)[1] = ((int *)src)[1]; + ((int *)dst)[2] = ((int *)src)[2]; + ((int *)dst)[3] = ((int *)src)[3]; #endif /* MUST_BE_ALIGNED */ src += src_stride; dst += dst_stride; @@ -73,8 +69,8 @@ void vp8_copy_mem8x8_c(unsigned char *src, int src_stride, dst[6] = src[6]; dst[7] = src[7]; #else - ((int *)dst)[0] = ((int *)src)[0] ; - ((int *)dst)[1] = ((int *)src)[1] ; + ((int *)dst)[0] = ((int *)src)[0]; + ((int *)dst)[1] = ((int *)src)[1]; #endif /* MUST_BE_ALIGNED */ src += src_stride; dst += dst_stride; @@ -98,8 +94,8 @@ void vp8_copy_mem8x4_c(unsigned char *src, int src_stride, dst[6] = src[6]; dst[7] = src[7]; #else - ((int *)dst)[0] = ((int *)src)[0] ; - ((int *)dst)[1] = ((int *)src)[1] ; + ((int *)dst)[0] = ((int *)src)[0]; + ((int *)dst)[1] = ((int *)src)[1]; #endif /* MUST_BE_ALIGNED */ src += src_stride; dst += dst_stride; @@ -109,12 +105,10 @@ void vp8_copy_mem8x4_c(unsigned char *src, int src_stride, void vp8_build_inter_predictors_b(BLOCKD *d, int pitch, vp8_filter_fn_t sppf) { int r; - unsigned char *ptr_base; + unsigned char *ptr_base = *(d->base_pre); unsigned char *ptr; unsigned char *pred_ptr = d->predictor; - ptr_base = *(d->base_pre); - if (d->bmi.mv.as_mv.row & 7 || d->bmi.mv.as_mv.col & 7) { ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3); @@ -133,23 +127,20 @@ void vp8_build_inter_predictors_b(BLOCKD *d, int pitch, vp8_filter_fn_t sppf) pred_ptr[2] = ptr[2]; pred_ptr[3] = ptr[3]; #else - *(int *)pred_ptr = *(int *)ptr ; + *(int *)pred_ptr = *(int *)ptr; #endif /* MUST_BE_ALIGNED */ - pred_ptr += pitch; - ptr += d->pre_stride; + pred_ptr += pitch; + ptr += d->pre_stride; } } } static void build_inter_predictors4b(MACROBLOCKD *x, BLOCKD *d, int pitch) { - unsigned char *ptr_base; - unsigned char *ptr; + unsigned char *ptr_base = *(d->base_pre); + unsigned char *ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3); unsigned char *pred_ptr = d->predictor; - ptr_base = *(d->base_pre); - ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3); - if (d->bmi.mv.as_mv.row & 7 || d->bmi.mv.as_mv.col & 7) { x->filter_predict8x8(ptr, d->pre_stride, d->bmi.mv.as_mv.col & 7, d->bmi.mv.as_mv.row & 7, pred_ptr, pitch); @@ -162,13 +153,10 @@ static void build_inter_predictors4b(MACROBLOCKD *x, BLOCKD *d, int pitch) static void build_inter_predictors2b(MACROBLOCKD *x, BLOCKD *d, int pitch) { - unsigned char *ptr_base; - unsigned char *ptr; + unsigned char *ptr_base = *(d->base_pre); + unsigned char *ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3); unsigned char *pred_ptr = d->predictor; - ptr_base = *(d->base_pre); - ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3); - if (d->bmi.mv.as_mv.row & 7 || d->bmi.mv.as_mv.col & 7) { x->filter_predict8x4(ptr, d->pre_stride, d->bmi.mv.as_mv.col & 7, d->bmi.mv.as_mv.row & 7, pred_ptr, pitch); @@ -187,8 +175,6 @@ void vp8_build_inter16x16_predictors_mb(MACROBLOCKD *x, int dst_uvstride) { int offset; - unsigned char *ptr; - unsigned char *uptr, *vptr; int mv_row = x->mode_info_context->mbmi.mv.as_mv.row; int mv_col = x->mode_info_context->mbmi.mv.as_mv.col; @@ -196,7 +182,8 @@ void vp8_build_inter16x16_predictors_mb(MACROBLOCKD *x, unsigned char *ptr_base = x->pre.y_buffer; int pre_stride = x->block[0].pre_stride; - ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3); + unsigned char *ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3); + unsigned char *uptr, *vptr; if ((mv_row | mv_col) & 7) { @@ -297,15 +284,15 @@ void vp8_build_uvmvs(MACROBLOCKD *x, int fullpixel) int uoffset = 16 + i * 2 + j; int voffset = 20 + i * 2 + j; - int temp; - - temp = x->block[yoffset ].bmi.mv.as_mv.row - + x->block[yoffset+1].bmi.mv.as_mv.row - + x->block[yoffset+4].bmi.mv.as_mv.row - + x->block[yoffset+5].bmi.mv.as_mv.row; + int temp = x->block[yoffset].bmi.mv.as_mv.row + + x->block[yoffset+1].bmi.mv.as_mv.row + + x->block[yoffset+4].bmi.mv.as_mv.row + + x->block[yoffset+5].bmi.mv.as_mv.row; - if (temp < 0) temp -= 4; - else temp += 4; + if (temp < 0) + temp -= 4; + else + temp += 4; x->block[uoffset].bmi.mv.as_mv.row = temp / 8; @@ -317,16 +304,18 @@ void vp8_build_uvmvs(MACROBLOCKD *x, int fullpixel) + x->block[yoffset+4].bmi.mv.as_mv.col + x->block[yoffset+5].bmi.mv.as_mv.col; - if (temp < 0) temp -= 4; - else temp += 4; + if (temp < 0) + temp -= 4; + else + temp += 4; x->block[uoffset].bmi.mv.as_mv.col = temp / 8; if (fullpixel) x->block[uoffset].bmi.mv.as_mv.col = (temp / 8) & 0xfffffff8; - x->block[voffset].bmi.mv.as_mv.row = x->block[uoffset].bmi.mv.as_mv.row ; - x->block[voffset].bmi.mv.as_mv.col = x->block[uoffset].bmi.mv.as_mv.col ; + x->block[voffset].bmi.mv.as_mv.row = x->block[uoffset].bmi.mv.as_mv.row; + x->block[voffset].bmi.mv.as_mv.col = x->block[uoffset].bmi.mv.as_mv.col; } } } @@ -350,13 +339,13 @@ void vp8_build_uvmvs(MACROBLOCKD *x, int fullpixel) for (i = 0; i < 8; i++) { - x->block[ 16 + i].bmi.mv.as_mv.row = mvrow; - x->block[ 16 + i].bmi.mv.as_mv.col = mvcol; + x->block[16 + i].bmi.mv.as_mv.row = mvrow; + x->block[16 + i].bmi.mv.as_mv.col = mvcol; if (fullpixel) { - x->block[ 16 + i].bmi.mv.as_mv.row = mvrow & 0xfffffff8; - x->block[ 16 + i].bmi.mv.as_mv.col = mvcol & 0xfffffff8; + x->block[16 + i].bmi.mv.as_mv.row = mvrow & 0xfffffff8; + x->block[16 + i].bmi.mv.as_mv.col = mvcol & 0xfffffff8; } } } diff --git a/src/gallium/auxiliary/vl/vp8/reconintra.c b/src/gallium/auxiliary/vl/vp8/reconintra.c index 2a7f9652df..8565c9922b 100644 --- a/src/gallium/auxiliary/vl/vp8/reconintra.c +++ b/src/gallium/auxiliary/vl/vp8/reconintra.c @@ -86,7 +86,6 @@ void vp8_build_intra_predictors_mby(MACROBLOCKD *x) { average += yleft_col[i]; } - } shift = 3 + x->up_available + x->left_available; @@ -105,7 +104,6 @@ void vp8_build_intra_predictors_mby(MACROBLOCKD *x) { for (r = 0; r < 16; r++) { - ((int *)ypred_ptr)[0] = ((int *)yabove_row)[0]; ((int *)ypred_ptr)[1] = ((int *)yabove_row)[1]; ((int *)ypred_ptr)[2] = ((int *)yabove_row)[2]; @@ -119,7 +117,6 @@ void vp8_build_intra_predictors_mby(MACROBLOCKD *x) { for (r = 0; r < 16; r++) { - memset(ypred_ptr, yleft_col[r], 16); ypred_ptr += 16; } @@ -132,7 +129,7 @@ void vp8_build_intra_predictors_mby(MACROBLOCKD *x) { for (c = 0; c < 16; c++) { - int pred = yleft_col[r] + yabove_row[ c] - ytop_left; + int pred = yleft_col[r] + yabove_row[c] - ytop_left; if (pred < 0) pred = 0; @@ -250,7 +247,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x) { for (c = 0; c < 16; c++) { - int pred = yleft_col[r] + yabove_row[ c] - ytop_left; + int pred = yleft_col[r] + yabove_row[c] - ytop_left; if (pred < 0) pred = 0; diff --git a/src/gallium/auxiliary/vl/vp8/reconintra.h b/src/gallium/auxiliary/vl/vp8/reconintra.h index 9beb194943..8de8d8d85c 100644 --- a/src/gallium/auxiliary/vl/vp8/reconintra.h +++ b/src/gallium/auxiliary/vl/vp8/reconintra.h @@ -11,13 +11,19 @@ #ifndef RECONINTRA_H #define RECONINTRA_H -#include "yv12utils.h" #include "blockd.h" +#include "yv12utils.h" #include "recon_dispatch.h" extern void vp8_setup_intra_recon(YV12_BUFFER_CONFIG *ybf); -void vp8_recon_intra_mbuv(const vp8_recon_rtcd_vtable_t *rtcd, - MACROBLOCKD *x); +extern void vp8_recon_intra_mbuv(const vp8_recon_rtcd_vtable_t *rtcd, + MACROBLOCKD *x); + +extern void vp8_build_intra_predictors_mby(MACROBLOCKD *x); +extern void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x); + +extern void vp8_build_intra_predictors_mbuv(MACROBLOCKD *x); +extern void vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x); #endif /* RECONINTRA_H */ diff --git a/src/gallium/auxiliary/vl/vp8/reconintra4x4.h b/src/gallium/auxiliary/vl/vp8/reconintra4x4.h index ca240e3f94..96c6e4d88c 100644 --- a/src/gallium/auxiliary/vl/vp8/reconintra4x4.h +++ b/src/gallium/auxiliary/vl/vp8/reconintra4x4.h @@ -14,6 +14,7 @@ #include "blockd.h" +extern void vp8_intra4x4_predict(BLOCKD *x, int b_mode, unsigned char *predictor); extern void vp8_intra_prediction_down_copy(MACROBLOCKD *x); #endif /* RECONINTRA4x4_H */ diff --git a/src/gallium/auxiliary/vl/vp8/treereader_common.c b/src/gallium/auxiliary/vl/vp8/treereader_common.c index defdd12b05..21bc59ee77 100644 --- a/src/gallium/auxiliary/vl/vp8/treereader_common.c +++ b/src/gallium/auxiliary/vl/vp8/treereader_common.c @@ -50,10 +50,10 @@ void vp8_tokens_from_tree_offset(struct vp8_token_struct *p, vp8_tree t, int off } static void branch_counts(int n, /* n = size of alphabet */ - vp8_token tok[ /* n */ ], + vp8_token tok[/* n */], vp8_tree tree, - unsigned int branch_ct[ /* n-1 */ ] [2], - const unsigned int num_events[ /* n */ ]) + unsigned int branch_ct[/* n-1 */][2], + const unsigned int num_events[/* n */]) { const int tree_len = n - 1; int t = 0; @@ -85,8 +85,8 @@ static void branch_counts(int n, /* n = size of alphabet */ #if ENABLE_DEBUG assert(j < tree_len && 0 <= L); #endif - branch_ct [j] [b] += ct; - i = tree[ i + b]; + branch_ct[j][b] += ct; + i = tree[i + b]; } while (i > 0); @@ -104,11 +104,11 @@ static void branch_counts(int n, /* n = size of alphabet */ * probability updates. */ void vp8_tree_probs_from_distribution(int n, /* n = size of alphabet */ - vp8_token tok[ /* n */ ], + vp8_token tok[/* n */], vp8_tree tree, - vp8_prob probs[ /* n-1 */ ], - unsigned int branch_ct[ /* n-1 */ ] [2], - const unsigned int num_events[ /* n */ ], + vp8_prob probs[/* n-1 */], + unsigned int branch_ct[/* n-1 */][2], + const unsigned int num_events[/* n */], unsigned int Pfac, int rd) { diff --git a/src/gallium/auxiliary/vl/vp8/vp8_debug.c b/src/gallium/auxiliary/vl/vp8/vp8_debug.c index 08469c1ace..d58a334d9f 100644 --- a/src/gallium/auxiliary/vl/vp8/vp8_debug.c +++ b/src/gallium/auxiliary/vl/vp8/vp8_debug.c @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ + #include <stdio.h> #include <stdarg.h> diff --git a/src/gallium/auxiliary/vl/vp8/vp8_debug.h b/src/gallium/auxiliary/vl/vp8/vp8_debug.h index 5d5d99c649..837dee2d11 100644 --- a/src/gallium/auxiliary/vl/vp8/vp8_debug.h +++ b/src/gallium/auxiliary/vl/vp8/vp8_debug.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef VPX_CODEC_H -#define VPX_CODEC_H +#ifndef VP8_DEBUG_H +#define VP8_DEBUG_H #ifdef __cplusplus extern "C" { @@ -62,4 +62,4 @@ void vpx_internal_error(struct vpx_internal_error_info *info, } #endif -#endif /* VPX_CODEC_H */ +#endif /* VP8_DEBUG_H */ diff --git a/src/gallium/auxiliary/vl/vp8/vp8_decoder.h b/src/gallium/auxiliary/vl/vp8/vp8_decoder.h index a04f332762..3b2235f7cd 100644 --- a/src/gallium/auxiliary/vl/vp8/vp8_decoder.h +++ b/src/gallium/auxiliary/vl/vp8/vp8_decoder.h @@ -36,6 +36,8 @@ extern "C" #define NUM_YV12_BUFFERS 4 +#define RTCD_VTABLE(x) NULL + typedef struct { vp8_prob bmode_prob [VP8_BINTRAMODES-1]; @@ -43,9 +45,16 @@ typedef struct vp8_prob uv_mode_prob [VP8_UV_MODES-1]; vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1]; vp8_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; - MV_CONTEXT mvc [2]; + MV_CONTEXT mvc[2]; } FRAME_CONTEXT; +typedef struct +{ + int16_t min_val; + int16_t Length; + uint8_t Probs[12]; +} TOKEN_EXTRABITS; + typedef enum { ONE_PARTITION = 0, @@ -158,7 +167,7 @@ typedef struct VP8Common vp8_prob kf_uv_mode_prob [VP8_UV_MODES-1]; FRAME_CONTEXT lfc; /**< last frame entropy */ - FRAME_CONTEXT fc; /**< this frame entropy */ + FRAME_CONTEXT fc; /**< current frame entropy */ unsigned int current_video_frame; @@ -166,26 +175,10 @@ typedef struct VP8Common } VP8_COMMON; - typedef void* VP8D_PTR; typedef struct { - MACROBLOCKD mbd; - int mb_row; - int current_mb_col; - short *coef_ptr; -} MB_ROW_DEC; - -typedef struct -{ - int16_t min_val; - int16_t Length; - uint8_t Probs[12]; -} TOKENEXTRABITS; - -typedef struct -{ DECLARE_ALIGNED(16, MACROBLOCKD, mb); DECLARE_ALIGNED(16, VP8_COMMON, common); diff --git a/src/gallium/auxiliary/vl/vp8/vp8_mem.c b/src/gallium/auxiliary/vl/vp8/vp8_mem.c index 845c30163b..55030b7cb1 100644 --- a/src/gallium/auxiliary/vl/vp8/vp8_mem.c +++ b/src/gallium/auxiliary/vl/vp8/vp8_mem.c @@ -8,8 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ + #include "vp8_mem.h" +#define ADDRESS_STORAGE_SIZE sizeof(size_t) +#define DEFAULT_ALIGNMENT 32 // must be >= 1 ! + +/* returns an addr aligned to the byte boundary specified by align */ +#define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align)) + void *vpx_memalign(size_t align, size_t size) { void *addr = malloc(size + align - 1 + ADDRESS_STORAGE_SIZE); @@ -25,11 +32,6 @@ void *vpx_memalign(size_t align, size_t size) return x; } -void *vpx_malloc(size_t size) -{ - return vpx_memalign(DEFAULT_ALIGNMENT, size); -} - void *vpx_calloc(size_t num, size_t size) { void *x = vpx_memalign(DEFAULT_ALIGNMENT, num * size); @@ -40,43 +42,6 @@ void *vpx_calloc(size_t num, size_t size) return x; } -/** - * \note The realloc() function changes the size of the object pointed to by - * ptr to the size specified by size, and returns a pointer to the - * possibly moved block. The contents are unchanged up to the lesser - * of the new and old sizes. If ptr is null, realloc() behaves like - * malloc() for the specified size. If size is zero (0) and ptr is - * not a null pointer, the object pointed to is freed. - */ -void *vpx_realloc(void *memblk, size_t size) -{ - void *addr, *new_addr = NULL; - int align = DEFAULT_ALIGNMENT; - - if (!memblk) - new_addr = vpx_malloc(size); - else if (!size) - vpx_free(memblk); - else - { - addr = (void *)(((size_t *)memblk)[-1]); - memblk = NULL; - - new_addr = realloc(addr, size + align + ADDRESS_STORAGE_SIZE); - - if (new_addr) - { - addr = new_addr; - new_addr = (void *)(((size_t)((unsigned char *)new_addr + ADDRESS_STORAGE_SIZE) + (align - 1)) & (size_t) - align); - - // save the actual malloc address - ((size_t *)new_addr)[-1] = (size_t)addr; - } - } - - return new_addr; -} - void vpx_free(void *memblk) { if (memblk) diff --git a/src/gallium/auxiliary/vl/vp8/vp8_mem.h b/src/gallium/auxiliary/vl/vp8/vp8_mem.h index 2c7118f9f8..1adde1e74b 100644 --- a/src/gallium/auxiliary/vl/vp8/vp8_mem.h +++ b/src/gallium/auxiliary/vl/vp8/vp8_mem.h @@ -9,8 +9,8 @@ */ -#ifndef __VPX_MEM_H__ -#define __VPX_MEM_H__ +#ifndef VP8_MEM_H +#define VP8_MEM_H #include <string.h> #include <stdlib.h> @@ -22,44 +22,25 @@ extern "C" { #endif -/* returns an addr aligned to the byte boundary specified by align */ -#define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align)) - -#define ADDRESS_STORAGE_SIZE sizeof(size_t) -#define DEFAULT_ALIGNMENT 32 // must be >= 1 ! +/** + * Use this define on systems where unaligned int reads and writes are + * not allowed, i.e. ARM architectures. + */ +//#define MUST_BE_ALIGNED #if defined(__GNUC__) && __GNUC__ -#define DECLARE_ALIGNED(n,typ,val) typ val __attribute__ ((aligned (n))) + #define DECLARE_ALIGNED(n,typ,val) typ val __attribute__ ((aligned (n))) #else -#warning No alignment directives known for this compiler. -#define DECLARE_ALIGNED(n,typ,val) typ val + #warning No alignment directives known for this compiler. + #define DECLARE_ALIGNED(n,typ,val) typ val #endif -#if ENABLE_DEBUG -#define CHECK_MEM_ERROR(lval,expr) do { \ - lval = (expr); \ - if (!lval) \ - vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR, \ - "Failed to allocate "#lval" at %s:%d", \ - __FILE__,__LINE__); \ - } while(0) -#else -#define CHECK_MEM_ERROR(lval,expr) do { \ - lval = (expr); \ - if (!lval) \ - vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR, \ - "Failed to allocate "#lval); \ - } while(0) -#endif /* ENABLE_DEBUG */ - 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 -#endif /* __VPX_MEM_H__ */ +#endif /* VP8_MEM_H */ |