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.

113 lines
3.3KB

  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_x86.h"
  29. /* not permutated inverse zigzag_direct + 1 for MMX quantizer */
  30. DECLARE_ALIGNED(16, static uint16_t, inv_zigzag_direct16)[64];
  31. #if HAVE_MMX_INLINE
  32. #define COMPILE_TEMPLATE_MMXEXT 0
  33. #define COMPILE_TEMPLATE_SSE2 0
  34. #define COMPILE_TEMPLATE_SSSE3 0
  35. #define RENAME(a) a ## _MMX
  36. #define RENAMEl(a) a ## _mmx
  37. #include "mpegvideoenc_template.c"
  38. #endif /* HAVE_MMX_INLINE */
  39. #if HAVE_MMXEXT_INLINE
  40. #undef COMPILE_TEMPLATE_SSSE3
  41. #undef COMPILE_TEMPLATE_SSE2
  42. #undef COMPILE_TEMPLATE_MMXEXT
  43. #define COMPILE_TEMPLATE_MMXEXT 1
  44. #define COMPILE_TEMPLATE_SSE2 0
  45. #define COMPILE_TEMPLATE_SSSE3 0
  46. #undef RENAME
  47. #undef RENAMEl
  48. #define RENAME(a) a ## _MMXEXT
  49. #define RENAMEl(a) a ## _mmxext
  50. #include "mpegvideoenc_template.c"
  51. #endif /* HAVE_MMXEXT_INLINE */
  52. #if HAVE_SSE2_INLINE
  53. #undef COMPILE_TEMPLATE_MMXEXT
  54. #undef COMPILE_TEMPLATE_SSE2
  55. #undef COMPILE_TEMPLATE_SSSE3
  56. #define COMPILE_TEMPLATE_MMXEXT 0
  57. #define COMPILE_TEMPLATE_SSE2 1
  58. #define COMPILE_TEMPLATE_SSSE3 0
  59. #undef RENAME
  60. #undef RENAMEl
  61. #define RENAME(a) a ## _SSE2
  62. #define RENAMEl(a) a ## _sse2
  63. #include "mpegvideoenc_template.c"
  64. #endif /* HAVE_SSE2_INLINE */
  65. #if HAVE_SSSE3_INLINE
  66. #undef COMPILE_TEMPLATE_MMXEXT
  67. #undef COMPILE_TEMPLATE_SSE2
  68. #undef COMPILE_TEMPLATE_SSSE3
  69. #define COMPILE_TEMPLATE_MMXEXT 0
  70. #define COMPILE_TEMPLATE_SSE2 1
  71. #define COMPILE_TEMPLATE_SSSE3 1
  72. #undef RENAME
  73. #undef RENAMEl
  74. #define RENAME(a) a ## _SSSE3
  75. #define RENAMEl(a) a ## _sse2
  76. #include "mpegvideoenc_template.c"
  77. #endif /* HAVE_SSSE3_INLINE */
  78. av_cold void ff_MPV_encode_init_x86(MpegEncContext *s)
  79. {
  80. const int dct_algo = s->avctx->dct_algo;
  81. int i;
  82. for (i = 0; i < 64; i++)
  83. inv_zigzag_direct16[ff_zigzag_direct[i]] = i + 1;
  84. if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
  85. #if HAVE_MMX_INLINE
  86. int cpu_flags = av_get_cpu_flags();
  87. if (INLINE_MMX(cpu_flags))
  88. s->dct_quantize = dct_quantize_MMX;
  89. #endif
  90. #if HAVE_MMXEXT_INLINE
  91. if (INLINE_MMXEXT(cpu_flags))
  92. s->dct_quantize = dct_quantize_MMXEXT;
  93. #endif
  94. #if HAVE_SSE2_INLINE
  95. if (INLINE_SSE2(cpu_flags))
  96. s->dct_quantize = dct_quantize_SSE2;
  97. #endif
  98. #if HAVE_SSSE3_INLINE
  99. if (INLINE_SSSE3(cpu_flags))
  100. s->dct_quantize = dct_quantize_SSSE3;
  101. #endif
  102. }
  103. }