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.

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