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 | |
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')
-rw-r--r-- | libavcodec/Makefile | 1 | ||||
-rw-r--r-- | libavcodec/mpeg4videodec.c | 11 | ||||
-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 | ||||
-rw-r--r-- | libavcodec/xvididct.c | 36 | ||||
-rw-r--r-- | libavcodec/xvididct.h | 29 |
8 files changed, 142 insertions, 45 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 9ce37a89df..a088a68fd4 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -272,6 +272,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o +OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o OBJS-$(CONFIG_MSMPEG4V2_ENCODER) += msmpeg4enc.o msmpeg4.o msmpeg4data.o diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 199e3b341b..cb88f7716f 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -28,6 +28,7 @@ #include "mpeg4video.h" #include "h263.h" #include "thread.h" +#include "xvididct.h" /* The defines below define the number of bits that are read at once for * reading vlc values. Changing these may improve speed and data cache needs @@ -2066,14 +2067,8 @@ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb) ctx->divx_build = -1; } -#if HAVE_MMX - if (ctx->xvid_build >= 0 && - s->avctx->idct_algo == FF_IDCT_AUTO && - (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) { - s->avctx->idct_algo = FF_IDCT_XVIDMMX; - ff_dct_common_init(s); - } -#endif + if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0) + ff_xvididct_init(&s->idsp, s->avctx); return 0; } 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); + } +} diff --git a/libavcodec/xvididct.c b/libavcodec/xvididct.c new file mode 100644 index 0000000000..1453e51700 --- /dev/null +++ b/libavcodec/xvididct.c @@ -0,0 +1,36 @@ +/* + * 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 "avcodec.h" +#include "idctdsp.h" +#include "xvididct.h" + +av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) +{ + const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; + + if (high_bit_depth || + !(avctx->idct_algo == FF_IDCT_AUTO || + avctx->idct_algo == FF_IDCT_XVIDMMX)) + return; + + if (ARCH_X86) + ff_xvididct_init_x86(c); +} diff --git a/libavcodec/xvididct.h b/libavcodec/xvididct.h new file mode 100644 index 0000000000..a688bc8c0e --- /dev/null +++ b/libavcodec/xvididct.h @@ -0,0 +1,29 @@ +/* + * 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 + */ + +#ifndef AVCODEC_XVIDIDCT_H +#define AVCODEC_XVIDIDCT_H + +#include "avcodec.h" +#include "idctdsp.h" + +void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx); + +void ff_xvididct_init_x86(IDCTDSPContext *c); + +#endif /* AVCODEC_XVIDIDCT_H */ |