diff options
author | Diego Biurrun <diego@biurrun.de> | 2014-07-21 13:13:21 -0700 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2014-08-01 01:25:18 -0700 |
commit | a786c8259dafeca9744252230b5d78f67810770c (patch) | |
tree | aade39c2a8bc84ea95306d7a8117d4e05c908139 /libavcodec/x86 | |
parent | 03c9f357a4c2307a7913cea2cbf0ba817e80beb6 (diff) | |
download | ffmpeg-a786c8259dafeca9744252230b5d78f67810770c.tar.gz |
idct: Split off Xvid IDCT
The Xvid IDCT is only required to decode some Xvid-encoded MPEG-4 files,
so there is no point in having it as an unconditional part of idctdsp.
Diffstat (limited to 'libavcodec/x86')
-rw-r--r-- | libavcodec/x86/Makefile | 5 | ||||
-rw-r--r-- | libavcodec/x86/dct-test.c | 4 | ||||
-rw-r--r-- | libavcodec/x86/idctdsp_init.c | 38 | ||||
-rw-r--r-- | libavcodec/x86/xvididct_init.c | 63 |
4 files changed, 73 insertions, 37 deletions
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 1969007abc..f4e2c1d9f3 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -37,6 +37,7 @@ OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc_init.o OBJS-$(CONFIG_HEVC_DECODER) += x86/hevcdsp_init.o OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp.o +OBJS-$(CONFIG_MPEG4_DECODER) += x86/xvididct_init.o OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp_init.o OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp_init.o OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp_init.o @@ -56,11 +57,11 @@ MMX-OBJS-$(CONFIG_HPELDSP) += x86/fpel_mmx.o \ x86/hpeldsp_mmx.o MMX-OBJS-$(CONFIG_FDCTDSP) += x86/fdct.o MMX-OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp_mmx.o \ - x86/idct_mmx_xvid.o \ - x86/idct_sse2_xvid.o \ x86/simple_idct.o MMX-OBJS-$(CONFIG_QPELDSP) += x86/fpel_mmx.o +MMX-OBJS-$(CONFIG_MPEG4_DECODER) += x86/idct_mmx_xvid.o \ + x86/idct_sse2_xvid.o MMX-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_mmx.o YASM-OBJS += x86/deinterlace.o \ diff --git a/libavcodec/x86/dct-test.c b/libavcodec/x86/dct-test.c index 2df9170879..d97c53c7d1 100644 --- a/libavcodec/x86/dct-test.c +++ b/libavcodec/x86/dct-test.c @@ -38,6 +38,9 @@ static const struct algo fdct_tab_arch[] = { static const struct algo idct_tab_arch[] = { #if HAVE_MMX_INLINE { "SIMPLE-MMX", ff_simple_idct_mmx, FF_IDCT_PERM_SIMPLE, AV_CPU_FLAG_MMX }, +#endif +#if CONFIG_MPEG4_DECODER +#if HAVE_MMX_INLINE { "XVID-MMX", ff_idct_xvid_mmx, FF_IDCT_PERM_NONE, AV_CPU_FLAG_MMX, 1 }, #endif #if HAVE_MMXEXT_INLINE @@ -46,6 +49,7 @@ static const struct algo idct_tab_arch[] = { #if HAVE_SSE2_INLINE { "XVID-SSE2", ff_idct_xvid_sse2, FF_IDCT_PERM_SSE2, AV_CPU_FLAG_SSE2, 1 }, #endif +#endif /* CONFIG_MPEG4_DECODER */ { 0 } }; diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c index f0511f5115..a0d681afb5 100644 --- a/libavcodec/x86/idctdsp_init.c +++ b/libavcodec/x86/idctdsp_init.c @@ -22,7 +22,6 @@ #include "libavutil/x86/cpu.h" #include "libavcodec/avcodec.h" #include "libavcodec/idctdsp.h" -#include "idct_xvid.h" #include "idctdsp.h" #include "simple_idct.h" @@ -38,8 +37,6 @@ static const uint8_t simple_mmx_permutation[64] = { 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F, }; -static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 }; - av_cold int ff_init_scantable_permutation_x86(uint8_t *idct_permutation, enum idct_permutation_type perm_type) { @@ -50,10 +47,6 @@ av_cold int ff_init_scantable_permutation_x86(uint8_t *idct_permutation, for (i = 0; i < 64; i++) idct_permutation[i] = simple_mmx_permutation[i]; return 1; - case FF_IDCT_PERM_SSE2: - for (i = 0; i < 64; i++) - idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7]; - return 1; } return 0; @@ -69,38 +62,13 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx; c->add_pixels_clamped = ff_add_pixels_clamped_mmx; - if (!high_bit_depth) { - switch (avctx->idct_algo) { - case FF_IDCT_AUTO: - case FF_IDCT_SIMPLEMMX: + if (!high_bit_depth && + (avctx->idct_algo == FF_IDCT_AUTO || + avctx->idct_algo == FF_IDCT_SIMPLEMMX)) { c->idct_put = ff_simple_idct_put_mmx; c->idct_add = ff_simple_idct_add_mmx; c->idct = ff_simple_idct_mmx; c->perm_type = FF_IDCT_PERM_SIMPLE; - break; - case FF_IDCT_XVIDMMX: - c->idct_put = ff_idct_xvid_mmx_put; - c->idct_add = ff_idct_xvid_mmx_add; - c->idct = ff_idct_xvid_mmx; - break; - } - } - } - - if (INLINE_MMXEXT(cpu_flags)) { - if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) { - c->idct_put = ff_idct_xvid_mmxext_put; - c->idct_add = ff_idct_xvid_mmxext_add; - c->idct = ff_idct_xvid_mmxext; - } - } - - if (INLINE_SSE2(cpu_flags)) { - if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) { - c->idct_put = ff_idct_xvid_sse2_put; - c->idct_add = ff_idct_xvid_sse2_add; - c->idct = ff_idct_xvid_sse2; - c->perm_type = FF_IDCT_PERM_SSE2; } } } diff --git a/libavcodec/x86/xvididct_init.c b/libavcodec/x86/xvididct_init.c new file mode 100644 index 0000000000..3112fb5e92 --- /dev/null +++ b/libavcodec/x86/xvididct_init.c @@ -0,0 +1,63 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/x86/cpu.h" +#include "libavcodec/idctdsp.h" +#include "libavcodec/xvididct.h" +#include "idct_xvid.h" +#include "idctdsp.h" + +static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 }; + +static av_cold void init_scantable_permutation_sse2(uint8_t *idct_permutation, + enum idct_permutation_type perm_type) +{ + int i; + + for (i = 0; i < 64; i++) + idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7]; +} + +av_cold void ff_xvididct_init_x86(IDCTDSPContext *c) +{ + int cpu_flags = av_get_cpu_flags(); + + if (INLINE_MMX(cpu_flags)) { + c->idct_put = ff_idct_xvid_mmx_put; + c->idct_add = ff_idct_xvid_mmx_add; + c->idct = ff_idct_xvid_mmx; + } + + if (INLINE_MMXEXT(cpu_flags)) { + c->idct_put = ff_idct_xvid_mmxext_put; + c->idct_add = ff_idct_xvid_mmxext_add; + c->idct = ff_idct_xvid_mmxext; + } + + if (INLINE_SSE2(cpu_flags)) { + c->idct_put = ff_idct_xvid_sse2_put; + c->idct_add = ff_idct_xvid_sse2_add; + c->idct = ff_idct_xvid_sse2; + c->perm_type = FF_IDCT_PERM_SSE2; + + init_scantable_permutation_sse2(c->idct_permutation, c->perm_type); + } +} |