You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.1KB

  1. /*
  2. * The simplest mpeg encoder (well, it was the simplest!)
  3. * Copyright (c) 2000,2001 Fabrice Bellard
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "libavutil/cpu.h"
  22. #include "libavutil/x86/asm.h"
  23. #include "libavcodec/avcodec.h"
  24. #include "libavcodec/dsputil.h"
  25. #include "libavcodec/mpegvideo.h"
  26. #include "dsputil_mmx.h"
  27. extern uint16_t ff_inv_zigzag_direct16[64];
  28. #if HAVE_MMX_INLINE
  29. #define COMPILE_TEMPLATE_MMXEXT 0
  30. #define COMPILE_TEMPLATE_SSE2 0
  31. #define COMPILE_TEMPLATE_SSSE3 0
  32. #define RENAME(a) a ## _MMX
  33. #define RENAMEl(a) a ## _mmx
  34. #include "mpegvideoenc_template.c"
  35. #endif /* HAVE_MMX_INLINE */
  36. #if HAVE_MMXEXT_INLINE
  37. #undef COMPILE_TEMPLATE_SSSE3
  38. #undef COMPILE_TEMPLATE_SSE2
  39. #undef COMPILE_TEMPLATE_MMXEXT
  40. #define COMPILE_TEMPLATE_MMXEXT 1
  41. #define COMPILE_TEMPLATE_SSE2 0
  42. #define COMPILE_TEMPLATE_SSSE3 0
  43. #undef RENAME
  44. #undef RENAMEl
  45. #define RENAME(a) a ## _MMX2
  46. #define RENAMEl(a) a ## _mmx2
  47. #include "mpegvideoenc_template.c"
  48. #endif /* HAVE_MMXEXT_INLINE */
  49. #if HAVE_SSE2_INLINE
  50. #undef COMPILE_TEMPLATE_MMXEXT
  51. #undef COMPILE_TEMPLATE_SSE2
  52. #undef COMPILE_TEMPLATE_SSSE3
  53. #define COMPILE_TEMPLATE_MMXEXT 0
  54. #define COMPILE_TEMPLATE_SSE2 1
  55. #define COMPILE_TEMPLATE_SSSE3 0
  56. #undef RENAME
  57. #undef RENAMEl
  58. #define RENAME(a) a ## _SSE2
  59. #define RENAMEl(a) a ## _sse2
  60. #include "mpegvideoenc_template.c"
  61. #endif /* HAVE_SSE2_INLINE */
  62. #if HAVE_SSSE3_INLINE
  63. #undef COMPILE_TEMPLATE_MMXEXT
  64. #undef COMPILE_TEMPLATE_SSE2
  65. #undef COMPILE_TEMPLATE_SSSE3
  66. #define COMPILE_TEMPLATE_MMXEXT 0
  67. #define COMPILE_TEMPLATE_SSE2 1
  68. #define COMPILE_TEMPLATE_SSSE3 1
  69. #undef RENAME
  70. #undef RENAMEl
  71. #define RENAME(a) a ## _SSSE3
  72. #define RENAMEl(a) a ## _sse2
  73. #include "mpegvideoenc_template.c"
  74. #endif /* HAVE_SSSE3_INLINE */
  75. void ff_MPV_encode_init_x86(MpegEncContext *s)
  76. {
  77. int mm_flags = av_get_cpu_flags();
  78. const int dct_algo = s->avctx->dct_algo;
  79. if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
  80. #if HAVE_MMX_INLINE
  81. if (mm_flags & AV_CPU_FLAG_MMX && HAVE_MMX)
  82. s->dct_quantize = dct_quantize_MMX;
  83. #endif
  84. #if HAVE_MMXEXT_INLINE
  85. if (mm_flags & AV_CPU_FLAG_MMXEXT && HAVE_MMXEXT)
  86. s->dct_quantize = dct_quantize_MMX2;
  87. #endif
  88. #if HAVE_SSE2_INLINE
  89. if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE2)
  90. s->dct_quantize = dct_quantize_SSE2;
  91. #endif
  92. #if HAVE_SSSE3_INLINE
  93. if (mm_flags & AV_CPU_FLAG_SSSE3)
  94. s->dct_quantize = dct_quantize_SSSE3;
  95. #endif
  96. }
  97. }