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.

107 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 "libavutil/x86/cpu.h"
  24. #include "libavcodec/avcodec.h"
  25. #include "libavcodec/dsputil.h"
  26. #include "libavcodec/mpegvideo.h"
  27. #include "dsputil_mmx.h"
  28. extern uint16_t ff_inv_zigzag_direct16[64];
  29. #if HAVE_MMX_INLINE
  30. #define COMPILE_TEMPLATE_MMXEXT 0
  31. #define COMPILE_TEMPLATE_SSE2 0
  32. #define COMPILE_TEMPLATE_SSSE3 0
  33. #define RENAME(a) a ## _MMX
  34. #define RENAMEl(a) a ## _mmx
  35. #include "mpegvideoenc_template.c"
  36. #endif /* HAVE_MMX_INLINE */
  37. #if HAVE_MMXEXT_INLINE
  38. #undef COMPILE_TEMPLATE_SSSE3
  39. #undef COMPILE_TEMPLATE_SSE2
  40. #undef COMPILE_TEMPLATE_MMXEXT
  41. #define COMPILE_TEMPLATE_MMXEXT 1
  42. #define COMPILE_TEMPLATE_SSE2 0
  43. #define COMPILE_TEMPLATE_SSSE3 0
  44. #undef RENAME
  45. #undef RENAMEl
  46. #define RENAME(a) a ## _MMXEXT
  47. #define RENAMEl(a) a ## _mmxext
  48. #include "mpegvideoenc_template.c"
  49. #endif /* HAVE_MMXEXT_INLINE */
  50. #if HAVE_SSE2_INLINE
  51. #undef COMPILE_TEMPLATE_MMXEXT
  52. #undef COMPILE_TEMPLATE_SSE2
  53. #undef COMPILE_TEMPLATE_SSSE3
  54. #define COMPILE_TEMPLATE_MMXEXT 0
  55. #define COMPILE_TEMPLATE_SSE2 1
  56. #define COMPILE_TEMPLATE_SSSE3 0
  57. #undef RENAME
  58. #undef RENAMEl
  59. #define RENAME(a) a ## _SSE2
  60. #define RENAMEl(a) a ## _sse2
  61. #include "mpegvideoenc_template.c"
  62. #endif /* HAVE_SSE2_INLINE */
  63. #if HAVE_SSSE3_INLINE
  64. #undef COMPILE_TEMPLATE_MMXEXT
  65. #undef COMPILE_TEMPLATE_SSE2
  66. #undef COMPILE_TEMPLATE_SSSE3
  67. #define COMPILE_TEMPLATE_MMXEXT 0
  68. #define COMPILE_TEMPLATE_SSE2 1
  69. #define COMPILE_TEMPLATE_SSSE3 1
  70. #undef RENAME
  71. #undef RENAMEl
  72. #define RENAME(a) a ## _SSSE3
  73. #define RENAMEl(a) a ## _sse2
  74. #include "mpegvideoenc_template.c"
  75. #endif /* HAVE_SSSE3_INLINE */
  76. void ff_dct_encode_init_x86(MpegEncContext *s)
  77. {
  78. int mm_flags = av_get_cpu_flags();
  79. const int dct_algo = s->avctx->dct_algo;
  80. if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
  81. #if HAVE_MMX_INLINE
  82. if (INLINE_MMX(mm_flags))
  83. s->dct_quantize = dct_quantize_MMX;
  84. #endif
  85. #if HAVE_MMXEXT_INLINE
  86. if (INLINE_MMXEXT(mm_flags))
  87. s->dct_quantize = dct_quantize_MMXEXT;
  88. #endif
  89. #if HAVE_SSE2_INLINE
  90. if (INLINE_SSE2(mm_flags))
  91. s->dct_quantize = dct_quantize_SSE2;
  92. #endif
  93. #if HAVE_SSSE3_INLINE
  94. if (INLINE_SSSE3(mm_flags))
  95. s->dct_quantize = dct_quantize_SSSE3;
  96. #endif
  97. }
  98. }