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.

97 lines
2.5KB

  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. #if HAVE_INLINE_ASM
  28. extern uint16_t ff_inv_zigzag_direct16[64];
  29. #if HAVE_SSSE3
  30. #define HAVE_SSSE3_BAK
  31. #endif
  32. #undef HAVE_SSSE3
  33. #define HAVE_SSSE3 0
  34. #undef HAVE_SSE2
  35. #undef HAVE_MMXEXT
  36. #define HAVE_SSE2 0
  37. #define HAVE_MMXEXT 0
  38. #define RENAME(a) a ## _MMX
  39. #define RENAMEl(a) a ## _mmx
  40. #include "mpegvideoenc_template.c"
  41. #undef HAVE_MMXEXT
  42. #define HAVE_MMXEXT 1
  43. #undef RENAME
  44. #undef RENAMEl
  45. #define RENAME(a) a ## _MMX2
  46. #define RENAMEl(a) a ## _mmx2
  47. #include "mpegvideoenc_template.c"
  48. #undef HAVE_SSE2
  49. #define HAVE_SSE2 1
  50. #undef RENAME
  51. #undef RENAMEl
  52. #define RENAME(a) a ## _SSE2
  53. #define RENAMEl(a) a ## _sse2
  54. #include "mpegvideoenc_template.c"
  55. #ifdef HAVE_SSSE3_BAK
  56. #undef HAVE_SSSE3
  57. #define HAVE_SSSE3 1
  58. #undef RENAME
  59. #undef RENAMEl
  60. #define RENAME(a) a ## _SSSE3
  61. #define RENAMEl(a) a ## _sse2
  62. #include "mpegvideoenc_template.c"
  63. #endif
  64. #endif /* HAVE_INLINE_ASM */
  65. void ff_MPV_encode_init_x86(MpegEncContext *s)
  66. {
  67. #if HAVE_INLINE_ASM
  68. int mm_flags = av_get_cpu_flags();
  69. const int dct_algo = s->avctx->dct_algo;
  70. if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
  71. #if HAVE_SSSE3
  72. if (mm_flags & AV_CPU_FLAG_SSSE3) {
  73. s->dct_quantize = dct_quantize_SSSE3;
  74. } else
  75. #endif
  76. if (mm_flags & AV_CPU_FLAG_SSE2) {
  77. s->dct_quantize = dct_quantize_SSE2;
  78. } else if (mm_flags & AV_CPU_FLAG_MMXEXT) {
  79. s->dct_quantize = dct_quantize_MMX2;
  80. } else {
  81. s->dct_quantize = dct_quantize_MMX;
  82. }
  83. }
  84. #endif /* HAVE_INLINE_ASM */
  85. }