X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fdsputil.c;h=8ce741a308451ce263bd48293ea4c677919bd0ad;hb=5959bfaca396ecaf63a8123055f499688b79cae3;hp=bd10054234fd89fcb462169d31abf60bdaff0f57;hpb=27cfdc3e4fcf0ab490cce6bf961af9180b21ac6b;p=ffmpeg diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index bd10054234f..8ce741a3084 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -36,8 +36,6 @@ #include "mathops.h" #include "mpegvideo.h" #include "config.h" -#include "ac3dec.h" -#include "vorbis.h" uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, }; uint32_t ff_squareTbl[512] = {0, }; @@ -130,9 +128,6 @@ void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_s int j; j = src_scantable[i]; st->permutated[i] = permutation[j]; -#if ARCH_PPC - st->inverse[j] = i; -#endif } end=-1; @@ -362,65 +357,30 @@ static void diff_pixels_c(DCTELEM *restrict block, const uint8_t *s1, } -void ff_put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels, - int line_size) -{ - int i; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - - /* read the pixels */ - for(i=0;i<8;i++) { - pixels[0] = cm[block[0]]; - pixels[1] = cm[block[1]]; - pixels[2] = cm[block[2]]; - pixels[3] = cm[block[3]]; - pixels[4] = cm[block[4]]; - pixels[5] = cm[block[5]]; - pixels[6] = cm[block[6]]; - pixels[7] = cm[block[7]]; - - pixels += line_size; - block += 8; - } -} - -static void put_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels, +static void put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels, int line_size) { int i; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; /* read the pixels */ - for(i=0;i<4;i++) { - pixels[0] = cm[block[0]]; - pixels[1] = cm[block[1]]; - pixels[2] = cm[block[2]]; - pixels[3] = cm[block[3]]; - - pixels += line_size; - block += 8; - } -} - -static void put_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels, - int line_size) -{ - int i; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - - /* read the pixels */ - for(i=0;i<2;i++) { - pixels[0] = cm[block[0]]; - pixels[1] = cm[block[1]]; + for(i=0;i<8;i++) { + pixels[0] = av_clip_uint8(block[0]); + pixels[1] = av_clip_uint8(block[1]); + pixels[2] = av_clip_uint8(block[2]); + pixels[3] = av_clip_uint8(block[3]); + pixels[4] = av_clip_uint8(block[4]); + pixels[5] = av_clip_uint8(block[5]); + pixels[6] = av_clip_uint8(block[6]); + pixels[7] = av_clip_uint8(block[7]); pixels += line_size; block += 8; } } -void ff_put_signed_pixels_clamped_c(const DCTELEM *block, - uint8_t *restrict pixels, - int line_size) +static void put_signed_pixels_clamped_c(const DCTELEM *block, + uint8_t *restrict pixels, + int line_size) { int i, j; @@ -439,54 +399,21 @@ void ff_put_signed_pixels_clamped_c(const DCTELEM *block, } } -void ff_add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels, - int line_size) +static void add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels, + int line_size) { int i; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; /* read the pixels */ for(i=0;i<8;i++) { - pixels[0] = cm[pixels[0] + block[0]]; - pixels[1] = cm[pixels[1] + block[1]]; - pixels[2] = cm[pixels[2] + block[2]]; - pixels[3] = cm[pixels[3] + block[3]]; - pixels[4] = cm[pixels[4] + block[4]]; - pixels[5] = cm[pixels[5] + block[5]]; - pixels[6] = cm[pixels[6] + block[6]]; - pixels[7] = cm[pixels[7] + block[7]]; - pixels += line_size; - block += 8; - } -} - -static void add_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels, - int line_size) -{ - int i; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - - /* read the pixels */ - for(i=0;i<4;i++) { - pixels[0] = cm[pixels[0] + block[0]]; - pixels[1] = cm[pixels[1] + block[1]]; - pixels[2] = cm[pixels[2] + block[2]]; - pixels[3] = cm[pixels[3] + block[3]]; - pixels += line_size; - block += 8; - } -} - -static void add_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels, - int line_size) -{ - int i; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - - /* read the pixels */ - for(i=0;i<2;i++) { - pixels[0] = cm[pixels[0] + block[0]]; - pixels[1] = cm[pixels[1] + block[1]]; + pixels[0] = av_clip_uint8(pixels[0] + block[0]); + pixels[1] = av_clip_uint8(pixels[1] + block[1]); + pixels[2] = av_clip_uint8(pixels[2] + block[2]); + pixels[3] = av_clip_uint8(pixels[3] + block[3]); + pixels[4] = av_clip_uint8(pixels[4] + block[4]); + pixels[5] = av_clip_uint8(pixels[5] + block[5]); + pixels[6] = av_clip_uint8(pixels[6] + block[6]); + pixels[7] = av_clip_uint8(pixels[7] + block[7]); pixels += line_size; block += 8; } @@ -1856,14 +1783,6 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){ case FF_CMP_NSSE: cmp[i]= c->nsse[i]; break; -#if CONFIG_DWT - case FF_CMP_W53: - cmp[i]= c->w53[i]; - break; - case FF_CMP_W97: - cmp[i]= c->w97[i]; - break; -#endif default: av_log(NULL, AV_LOG_ERROR,"internal error in cmp function selection\n"); } @@ -2434,82 +2353,7 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) WRAPPER8_16_SQ(rd8x8_c, rd16_c) WRAPPER8_16_SQ(bit8x8_c, bit16_c) -static void vector_fmul_c(float *dst, const float *src0, const float *src1, int len){ - int i; - for(i=0; i> shift; + res += *v1++ * *v2++; return res; } @@ -2614,138 +2458,17 @@ static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min, } while (len > 0); } -#define W0 2048 -#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */ -#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */ -#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */ -#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */ -#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */ -#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */ -#define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */ - -static void wmv2_idct_row(short * b) -{ - int s1,s2; - int a0,a1,a2,a3,a4,a5,a6,a7; - /*step 1*/ - a1 = W1*b[1]+W7*b[7]; - a7 = W7*b[1]-W1*b[7]; - a5 = W5*b[5]+W3*b[3]; - a3 = W3*b[5]-W5*b[3]; - a2 = W2*b[2]+W6*b[6]; - a6 = W6*b[2]-W2*b[6]; - a0 = W0*b[0]+W0*b[4]; - a4 = W0*b[0]-W0*b[4]; - /*step 2*/ - s1 = (181*(a1-a5+a7-a3)+128)>>8;//1,3,5,7, - s2 = (181*(a1-a5-a7+a3)+128)>>8; - /*step 3*/ - b[0] = (a0+a2+a1+a5 + (1<<7))>>8; - b[1] = (a4+a6 +s1 + (1<<7))>>8; - b[2] = (a4-a6 +s2 + (1<<7))>>8; - b[3] = (a0-a2+a7+a3 + (1<<7))>>8; - b[4] = (a0-a2-a7-a3 + (1<<7))>>8; - b[5] = (a4-a6 -s2 + (1<<7))>>8; - b[6] = (a4+a6 -s1 + (1<<7))>>8; - b[7] = (a0+a2-a1-a5 + (1<<7))>>8; -} -static void wmv2_idct_col(short * b) -{ - int s1,s2; - int a0,a1,a2,a3,a4,a5,a6,a7; - /*step 1, with extended precision*/ - a1 = (W1*b[8*1]+W7*b[8*7] + 4)>>3; - a7 = (W7*b[8*1]-W1*b[8*7] + 4)>>3; - a5 = (W5*b[8*5]+W3*b[8*3] + 4)>>3; - a3 = (W3*b[8*5]-W5*b[8*3] + 4)>>3; - a2 = (W2*b[8*2]+W6*b[8*6] + 4)>>3; - a6 = (W6*b[8*2]-W2*b[8*6] + 4)>>3; - a0 = (W0*b[8*0]+W0*b[8*4] )>>3; - a4 = (W0*b[8*0]-W0*b[8*4] )>>3; - /*step 2*/ - s1 = (181*(a1-a5+a7-a3)+128)>>8; - s2 = (181*(a1-a5-a7+a3)+128)>>8; - /*step 3*/ - b[8*0] = (a0+a2+a1+a5 + (1<<13))>>14; - b[8*1] = (a4+a6 +s1 + (1<<13))>>14; - b[8*2] = (a4-a6 +s2 + (1<<13))>>14; - b[8*3] = (a0-a2+a7+a3 + (1<<13))>>14; - - b[8*4] = (a0-a2-a7-a3 + (1<<13))>>14; - b[8*5] = (a4-a6 -s2 + (1<<13))>>14; - b[8*6] = (a4+a6 -s1 + (1<<13))>>14; - b[8*7] = (a0+a2-a1-a5 + (1<<13))>>14; -} -void ff_wmv2_idct_c(short * block){ - int i; - - for(i=0;i<64;i+=8){ - wmv2_idct_row(block+i); - } - for(i=0;i<8;i++){ - wmv2_idct_col(block+i); - } -} -/* XXX: those functions should be suppressed ASAP when all IDCTs are - converted */ -static void ff_wmv2_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block) -{ - ff_wmv2_idct_c(block); - ff_put_pixels_clamped_c(block, dest, line_size); -} -static void ff_wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block) -{ - ff_wmv2_idct_c(block); - ff_add_pixels_clamped_c(block, dest, line_size); -} static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block) { ff_j_rev_dct (block); - ff_put_pixels_clamped_c(block, dest, line_size); + put_pixels_clamped_c(block, dest, line_size); } static void ff_jref_idct_add(uint8_t *dest, int line_size, DCTELEM *block) { ff_j_rev_dct (block); - ff_add_pixels_clamped_c(block, dest, line_size); -} - -static void ff_jref_idct4_put(uint8_t *dest, int line_size, DCTELEM *block) -{ - ff_j_rev_dct4 (block); - put_pixels_clamped4_c(block, dest, line_size); -} -static void ff_jref_idct4_add(uint8_t *dest, int line_size, DCTELEM *block) -{ - ff_j_rev_dct4 (block); - add_pixels_clamped4_c(block, dest, line_size); -} - -static void ff_jref_idct2_put(uint8_t *dest, int line_size, DCTELEM *block) -{ - ff_j_rev_dct2 (block); - put_pixels_clamped2_c(block, dest, line_size); -} -static void ff_jref_idct2_add(uint8_t *dest, int line_size, DCTELEM *block) -{ - ff_j_rev_dct2 (block); - add_pixels_clamped2_c(block, dest, line_size); -} - -static void ff_jref_idct1_put(uint8_t *dest, int line_size, DCTELEM *block) -{ - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - - dest[0] = cm[(block[0] + 4)>>3]; -} -static void ff_jref_idct1_add(uint8_t *dest, int line_size, DCTELEM *block) -{ - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - - dest[0] = cm[dest[0] + ((block[0] + 4)>>3)]; + add_pixels_clamped_c(block, dest, line_size); } -static void just_return(void *mem av_unused, int stride av_unused, int h av_unused) { return; } - /* init static data */ av_cold void ff_dsputil_static_init(void) { @@ -2786,8 +2509,6 @@ int ff_check_alignment(void){ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) { - int i; - ff_check_alignment(); #if CONFIG_ENCODERS @@ -2810,65 +2531,34 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) } #endif //CONFIG_ENCODERS - if(avctx->lowres==1){ - c->idct_put= ff_jref_idct4_put; - c->idct_add= ff_jref_idct4_add; - c->idct = ff_j_rev_dct4; - c->idct_permutation_type= FF_NO_IDCT_PERM; - }else if(avctx->lowres==2){ - c->idct_put= ff_jref_idct2_put; - c->idct_add= ff_jref_idct2_add; - c->idct = ff_j_rev_dct2; - c->idct_permutation_type= FF_NO_IDCT_PERM; - }else if(avctx->lowres==3){ - c->idct_put= ff_jref_idct1_put; - c->idct_add= ff_jref_idct1_add; - c->idct = ff_j_rev_dct1; - c->idct_permutation_type= FF_NO_IDCT_PERM; - }else{ - if (avctx->bits_per_raw_sample == 10) { - c->idct_put = ff_simple_idct_put_10; - c->idct_add = ff_simple_idct_add_10; - c->idct = ff_simple_idct_10; - c->idct_permutation_type = FF_NO_IDCT_PERM; - } else { + if (avctx->bits_per_raw_sample == 10) { + c->idct_put = ff_simple_idct_put_10; + c->idct_add = ff_simple_idct_add_10; + c->idct = ff_simple_idct_10; + c->idct_permutation_type = FF_NO_IDCT_PERM; + } else { if(avctx->idct_algo==FF_IDCT_INT){ c->idct_put= ff_jref_idct_put; c->idct_add= ff_jref_idct_add; c->idct = ff_j_rev_dct; c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; - }else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER ) && - avctx->idct_algo==FF_IDCT_VP3){ - c->idct_put= ff_vp3_idct_put_c; - c->idct_add= ff_vp3_idct_add_c; - c->idct = ff_vp3_idct_c; - c->idct_permutation_type= FF_NO_IDCT_PERM; - }else if(avctx->idct_algo==FF_IDCT_WMV2){ - c->idct_put= ff_wmv2_idct_put_c; - c->idct_add= ff_wmv2_idct_add_c; - c->idct = ff_wmv2_idct_c; - c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->idct_algo==FF_IDCT_FAAN){ c->idct_put= ff_faanidct_put; c->idct_add= ff_faanidct_add; c->idct = ff_faanidct; c->idct_permutation_type= FF_NO_IDCT_PERM; - }else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) { - c->idct_put= ff_ea_idct_put_c; - c->idct_permutation_type= FF_NO_IDCT_PERM; }else{ //accurate/default c->idct_put = ff_simple_idct_put_8; c->idct_add = ff_simple_idct_add_8; c->idct = ff_simple_idct_8; c->idct_permutation_type= FF_NO_IDCT_PERM; } - } } c->diff_pixels = diff_pixels_c; - c->put_pixels_clamped = ff_put_pixels_clamped_c; - c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c; - c->add_pixels_clamped = ff_add_pixels_clamped_c; + c->put_pixels_clamped = put_pixels_clamped_c; + c->put_signed_pixels_clamped = put_signed_pixels_clamped_c; + c->add_pixels_clamped = add_pixels_clamped_c; c->sum_abs_dctelem = sum_abs_dctelem_c; c->gmc1 = gmc1_c; c->gmc = ff_gmc_c; @@ -2940,13 +2630,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) #undef dspfunc -#if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER - ff_mlp_init(c, avctx); -#endif -#if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER - ff_intrax8dsp_init(c,avctx); -#endif - c->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c; c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c; c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c; @@ -2984,9 +2667,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) c->vsse[5]= vsse_intra8_c; c->nsse[0]= nsse16_c; c->nsse[1]= nsse8_c; -#if CONFIG_DWT - ff_dsputil_init_dwt(c); -#endif c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c; @@ -3004,48 +2684,23 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) c->h263_v_loop_filter= h263_v_loop_filter_c; } - if (CONFIG_VP3_DECODER) { - c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c; - c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c; - c->vp3_idct_dc_add= ff_vp3_idct_dc_add_c; - } - c->h261_loop_filter= h261_loop_filter_c; c->try_8x8basis= try_8x8basis_c; c->add_8x8basis= add_8x8basis_c; -#if CONFIG_VORBIS_DECODER - c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling; -#endif -#if CONFIG_AC3_DECODER - c->ac3_downmix = ff_ac3_downmix_c; -#endif - c->vector_fmul = vector_fmul_c; - c->vector_fmul_reverse = vector_fmul_reverse_c; - c->vector_fmul_add = vector_fmul_add_c; - c->vector_fmul_window = vector_fmul_window_c; c->vector_clipf = vector_clipf_c; c->scalarproduct_int16 = scalarproduct_int16_c; c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c; c->apply_window_int16 = apply_window_int16_c; c->vector_clip_int32 = vector_clip_int32_c; - c->scalarproduct_float = scalarproduct_float_c; - c->butterflies_float = butterflies_float_c; - c->butterflies_float_interleave = butterflies_float_interleave_c; - c->vector_fmul_scalar = vector_fmul_scalar_c; - c->vector_fmac_scalar = vector_fmac_scalar_c; + c->scalarproduct_float = ff_scalarproduct_float_c; c->shrink[0]= av_image_copy_plane; c->shrink[1]= ff_shrink22; c->shrink[2]= ff_shrink44; c->shrink[3]= ff_shrink88; - c->prefetch= just_return; - - memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab)); - memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab)); - #undef FUNC #undef FUNCC #define FUNC(f, depth) f ## _ ## depth @@ -3079,13 +2734,10 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) #define BIT_DEPTH_FUNCS(depth, dct)\ c->get_pixels = FUNCC(get_pixels ## dct , depth);\ c->draw_edges = FUNCC(draw_edges , depth);\ - c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\ c->clear_block = FUNCC(clear_block ## dct , depth);\ c->clear_blocks = FUNCC(clear_blocks ## dct , depth);\ c->add_pixels8 = FUNCC(add_pixels8 ## dct , depth);\ c->add_pixels4 = FUNCC(add_pixels4 ## dct , depth);\ - c->put_no_rnd_pixels_l2[0] = FUNCC(put_no_rnd_pixels16_l2, depth);\ - c->put_no_rnd_pixels_l2[1] = FUNCC(put_no_rnd_pixels8_l2 , depth);\ \ c->put_h264_chroma_pixels_tab[0] = FUNCC(put_h264_chroma_mc8 , depth);\ c->put_h264_chroma_pixels_tab[1] = FUNCC(put_h264_chroma_mc4 , depth);\ @@ -3141,17 +2793,9 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) if (HAVE_VIS) ff_dsputil_init_vis (c, avctx); if (ARCH_ALPHA) ff_dsputil_init_alpha (c, avctx); if (ARCH_PPC) ff_dsputil_init_ppc (c, avctx); - if (HAVE_MMI) ff_dsputil_init_mmi (c, avctx); if (ARCH_SH4) ff_dsputil_init_sh4 (c, avctx); if (ARCH_BFIN) ff_dsputil_init_bfin (c, avctx); - for(i=0; i<64; i++){ - if(!c->put_2tap_qpel_pixels_tab[0][i]) - c->put_2tap_qpel_pixels_tab[0][i]= c->put_h264_qpel_pixels_tab[0][i]; - if(!c->avg_2tap_qpel_pixels_tab[0][i]) - c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i]; - } - ff_init_scantable_permutation(c->idct_permutation, c->idct_permutation_type); }