diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-03-03 14:54:00 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-03-03 14:54:00 +0000 |
commit | b0368839ac6de47dee3e971c709676d9635865e9 (patch) | |
tree | d2f5240d3726509118642a98d11adfdd21d73d07 /libavcodec/i386 | |
parent | a5dbb247af9f02cff4899f16d3a87f49fe16727a (diff) | |
download | ffmpeg-b0368839ac6de47dee3e971c709676d9635865e9.tar.gz |
MpegEncContext.(i)dct_* -> DspContext.(i)dct_*
bitexact cleanup
Originally committed as revision 1617 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/i386')
-rw-r--r-- | libavcodec/i386/dsputil_mmx.c | 101 | ||||
-rw-r--r-- | libavcodec/i386/motion_est_mmx.c | 29 | ||||
-rw-r--r-- | libavcodec/i386/mpegvideo_mmx.c | 46 | ||||
-rw-r--r-- | libavcodec/i386/mpegvideo_mmx_template.c | 4 |
4 files changed, 82 insertions, 98 deletions
diff --git a/libavcodec/i386/dsputil_mmx.c b/libavcodec/i386/dsputil_mmx.c index 8804c1cd21..906a5effa1 100644 --- a/libavcodec/i386/dsputil_mmx.c +++ b/libavcodec/i386/dsputil_mmx.c @@ -20,6 +20,7 @@ */ #include "../dsputil.h" +#include "../simple_idct.h" int mm_flags; /* multimedia extension flags */ @@ -1408,8 +1409,35 @@ static void just_return() { return; } c->put_ ## postfix1 = put_ ## postfix2;\ c->put_no_rnd_ ## postfix1 = put_no_rnd_ ## postfix2;\ c->avg_ ## postfix1 = avg_ ## postfix2; + +/* external functions, from idct_mmx.c */ +void ff_mmx_idct(DCTELEM *block); +void ff_mmxext_idct(DCTELEM *block); + +/* XXX: those functions should be suppressed ASAP when all IDCTs are + converted */ +static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size, DCTELEM *block) +{ + ff_mmx_idct (block); + put_pixels_clamped_mmx(block, dest, line_size); +} +static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size, DCTELEM *block) +{ + ff_mmx_idct (block); + add_pixels_clamped_mmx(block, dest, line_size); +} +static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size, DCTELEM *block) +{ + ff_mmxext_idct (block); + put_pixels_clamped_mmx(block, dest, line_size); +} +static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size, DCTELEM *block) +{ + ff_mmxext_idct (block); + add_pixels_clamped_mmx(block, dest, line_size); +} -void dsputil_init_mmx(DSPContext* c, unsigned mask) +void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) { mm_flags = mm_support(); #if 0 @@ -1428,6 +1456,27 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask) #endif if (mm_flags & MM_MMX) { + const int dct_algo = avctx->dct_algo; + const int idct_algo= avctx->idct_algo; + + if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX) + c->fdct = ff_fdct_mmx; + + if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){ + c->idct_put= ff_simple_idct_put_mmx; + c->idct_add= ff_simple_idct_add_mmx; + c->idct_permutation_type= FF_SIMPLE_IDCT_PERM; + }else if(idct_algo==FF_IDCT_LIBMPEG2MMX){ + if(mm_flags & MM_MMXEXT){ + c->idct_put= ff_libmpeg2mmx2_idct_put; + c->idct_add= ff_libmpeg2mmx2_idct_add; + }else{ + c->idct_put= ff_libmpeg2mmx_idct_put; + c->idct_add= ff_libmpeg2mmx_idct_add; + } + c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; + } + c->get_pixels = get_pixels_mmx; c->diff_pixels = diff_pixels_mmx; c->put_pixels_clamped = put_pixels_clamped_mmx; @@ -1487,23 +1536,26 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask) if (mm_flags & MM_MMXEXT) { c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2; c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2; - c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2; - c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2; c->avg_pixels_tab[0][0] = avg_pixels16_mmx2; c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2; c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2; - c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2; c->put_pixels_tab[1][1] = put_pixels8_x2_mmx2; c->put_pixels_tab[1][2] = put_pixels8_y2_mmx2; - c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2; - c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2; c->avg_pixels_tab[1][0] = avg_pixels8_mmx2; c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2; c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2; - c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2; + + if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ + c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2; + c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2; + c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2; + c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2; + c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2; + c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2; + } #if 1 SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_mmx2) @@ -1542,23 +1594,26 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask) } else if (mm_flags & MM_3DNOW) { c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow; c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow; - c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow; - c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow; c->avg_pixels_tab[0][0] = avg_pixels16_3dnow; c->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow; c->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow; - c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow; c->put_pixels_tab[1][1] = put_pixels8_x2_3dnow; c->put_pixels_tab[1][2] = put_pixels8_y2_3dnow; - c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow; - c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow; c->avg_pixels_tab[1][0] = avg_pixels8_3dnow; c->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow; c->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow; - c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow; + + if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ + c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow; + c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow; + c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow; + c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow; + c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow; + c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow; + } SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_3dnow) SET_QPEL_FUNC(qpel_pixels_tab[0][ 1], qpel16_mc10_3dnow) @@ -1594,7 +1649,8 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask) SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_3dnow) } } - dsputil_init_pix_mmx(c, mask); + + dsputil_init_pix_mmx(c, avctx); #if 0 // for speed testing get_pixels = just_return; @@ -1630,20 +1686,3 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask) //ff_idct = just_return; #endif } - -/* remove any non bit exact operation (testing purpose). NOTE that - this function should be kept as small as possible because it is - always difficult to test automatically non bit exact cases. */ -void dsputil_set_bit_exact_mmx(DSPContext* c, unsigned mask) -{ - if (mm_flags & MM_MMX) { - /* MMX2 & 3DNOW */ - c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx; - c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx; - c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx; - c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx; - c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx; - c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx; - } - dsputil_set_bit_exact_pix_mmx(c, mask); -} diff --git a/libavcodec/i386/motion_est_mmx.c b/libavcodec/i386/motion_est_mmx.c index 1e6b9f73d2..5c4b32dcd3 100644 --- a/libavcodec/i386/motion_est_mmx.c +++ b/libavcodec/i386/motion_est_mmx.c @@ -386,7 +386,7 @@ static int pix_abs16x16_xy2_ ## suf(uint8_t *blk2, uint8_t *blk1, int stride)\ PIX_SAD(mmx) PIX_SAD(mmx2) -void dsputil_init_pix_mmx(DSPContext* c, unsigned mask) +void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx) { if (mm_flags & MM_MMX) { c->pix_abs16x16 = pix_abs16x16_mmx; @@ -403,27 +403,18 @@ void dsputil_init_pix_mmx(DSPContext* c, unsigned mask) } if (mm_flags & MM_MMXEXT) { c->pix_abs16x16 = pix_abs16x16_mmx2; - c->pix_abs16x16_x2 = pix_abs16x16_x2_mmx2; - c->pix_abs16x16_y2 = pix_abs16x16_y2_mmx2; - c->pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx2; c->pix_abs8x8 = pix_abs8x8_mmx2; - c->pix_abs8x8_x2 = pix_abs8x8_x2_mmx2; - c->pix_abs8x8_y2 = pix_abs8x8_y2_mmx2; - c->pix_abs8x8_xy2 = pix_abs8x8_xy2_mmx2; c->sad[0]= sad16x16_mmx2; c->sad[1]= sad8x8_mmx2; - } -} - -void dsputil_set_bit_exact_pix_mmx(DSPContext* c, unsigned mask) -{ - if (mm_flags & MM_MMXEXT) { - c->pix_abs16x16_x2 = pix_abs16x16_x2_mmx; - c->pix_abs16x16_y2 = pix_abs16x16_y2_mmx; - c->pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx; - c->pix_abs8x8_x2 = pix_abs8x8_x2_mmx; - c->pix_abs8x8_y2 = pix_abs8x8_y2_mmx; - c->pix_abs8x8_xy2 = pix_abs8x8_xy2_mmx; + + if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ + c->pix_abs16x16_x2 = pix_abs16x16_x2_mmx2; + c->pix_abs16x16_y2 = pix_abs16x16_y2_mmx2; + c->pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx2; + c->pix_abs8x8_x2 = pix_abs8x8_x2_mmx2; + c->pix_abs8x8_y2 = pix_abs8x8_y2_mmx2; + c->pix_abs8x8_xy2 = pix_abs8x8_xy2_mmx2; + } } } diff --git a/libavcodec/i386/mpegvideo_mmx.c b/libavcodec/i386/mpegvideo_mmx.c index 23f6831071..8e452b4991 100644 --- a/libavcodec/i386/mpegvideo_mmx.c +++ b/libavcodec/i386/mpegvideo_mmx.c @@ -23,7 +23,6 @@ #include "../dsputil.h" #include "../mpegvideo.h" #include "../avcodec.h" -#include "../simple_idct.h" extern uint8_t zigzag_direct_noperm[64]; extern uint16_t inv_zigzag_direct16[64]; @@ -499,38 +498,10 @@ static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w) #define RENAME(a) a ## _MMX2 #include "mpegvideo_mmx_template.c" -/* external functions, from idct_mmx.c */ -void ff_mmx_idct(DCTELEM *block); -void ff_mmxext_idct(DCTELEM *block); - -/* XXX: those functions should be suppressed ASAP when all IDCTs are - converted */ -static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size, DCTELEM *block) -{ - ff_mmx_idct (block); - put_pixels_clamped_mmx(block, dest, line_size); -} -static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size, DCTELEM *block) -{ - ff_mmx_idct (block); - add_pixels_clamped_mmx(block, dest, line_size); -} -static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size, DCTELEM *block) -{ - ff_mmxext_idct (block); - put_pixels_clamped_mmx(block, dest, line_size); -} -static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size, DCTELEM *block) -{ - ff_mmxext_idct (block); - add_pixels_clamped_mmx(block, dest, line_size); -} - void MPV_common_init_mmx(MpegEncContext *s) { if (mm_flags & MM_MMX) { const int dct_algo = s->avctx->dct_algo; - const int idct_algo= s->avctx->idct_algo; s->dct_unquantize_h263 = dct_unquantize_h263_mmx; s->dct_unquantize_mpeg1 = dct_unquantize_mpeg1_mmx; @@ -539,28 +510,11 @@ void MPV_common_init_mmx(MpegEncContext *s) draw_edges = draw_edges_mmx; if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){ - s->fdct = ff_fdct_mmx; - if(mm_flags & MM_MMXEXT){ s->dct_quantize= dct_quantize_MMX2; } else { s->dct_quantize= dct_quantize_MMX; } } - - if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){ - s->idct_put= ff_simple_idct_put_mmx; - s->idct_add= ff_simple_idct_add_mmx; - s->idct_permutation_type= FF_SIMPLE_IDCT_PERM; - }else if(idct_algo==FF_IDCT_LIBMPEG2MMX){ - if(mm_flags & MM_MMXEXT){ - s->idct_put= ff_libmpeg2mmx2_idct_put; - s->idct_add= ff_libmpeg2mmx2_idct_add; - }else{ - s->idct_put= ff_libmpeg2mmx_idct_put; - s->idct_add= ff_libmpeg2mmx_idct_add; - } - s->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; - } } } diff --git a/libavcodec/i386/mpegvideo_mmx_template.c b/libavcodec/i386/mpegvideo_mmx_template.c index 730b912eb8..fa1ab579d9 100644 --- a/libavcodec/i386/mpegvideo_mmx_template.c +++ b/libavcodec/i386/mpegvideo_mmx_template.c @@ -191,7 +191,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s, if(s->mb_intra) block[0]= level; else block[0]= temp_block[0]; - if(s->idct_permutation[1]==8){ + if(s->dsp.idct_permutation_type == FF_SIMPLE_IDCT_PERM){ if(last_non_zero_p1 <= 1) goto end; block[0x08] = temp_block[0x01]; block[0x10] = temp_block[0x08]; block[0x20] = temp_block[0x10]; @@ -235,7 +235,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s, block[0x3E] = temp_block[0x3D]; block[0x27] = temp_block[0x36]; block[0x3D] = temp_block[0x2F]; block[0x2F] = temp_block[0x37]; block[0x37] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F]; - }else if(s->idct_permutation[1]==4){ + }else if(s->dsp.idct_permutation_type == FF_LIBMPEG2_IDCT_PERM){ if(last_non_zero_p1 <= 1) goto end; block[0x04] = temp_block[0x01]; block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10]; |