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.

124 lines
4.8KB

  1. /*
  2. * VC-1 and WMV3 - DSP functions MMX-optimized
  3. * Copyright (c) 2007 Christophe GISQUET <christophe.gisquet@free.fr>
  4. *
  5. * Permission is hereby granted, free of charge, to any person
  6. * obtaining a copy of this software and associated documentation
  7. * files (the "Software"), to deal in the Software without
  8. * restriction, including without limitation the rights to use,
  9. * copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following
  12. * conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  19. * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  21. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  22. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  23. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. * OTHER DEALINGS IN THE SOFTWARE.
  25. */
  26. #include "libavutil/cpu.h"
  27. #include "libavutil/x86/cpu.h"
  28. #include "libavcodec/vc1dsp.h"
  29. #include "vc1dsp.h"
  30. #include "config.h"
  31. #define LOOP_FILTER(EXT) \
  32. void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
  33. void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
  34. void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
  35. void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
  36. \
  37. static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
  38. { \
  39. ff_vc1_v_loop_filter8_ ## EXT(src, stride, pq); \
  40. ff_vc1_v_loop_filter8_ ## EXT(src+8, stride, pq); \
  41. } \
  42. \
  43. static void vc1_h_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
  44. { \
  45. ff_vc1_h_loop_filter8_ ## EXT(src, stride, pq); \
  46. ff_vc1_h_loop_filter8_ ## EXT(src+8*stride, stride, pq); \
  47. }
  48. #if HAVE_YASM
  49. LOOP_FILTER(mmxext)
  50. LOOP_FILTER(sse2)
  51. LOOP_FILTER(ssse3)
  52. void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq);
  53. static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq)
  54. {
  55. ff_vc1_h_loop_filter8_sse4(src, stride, pq);
  56. ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq);
  57. }
  58. #endif /* HAVE_YASM */
  59. void ff_put_vc1_chroma_mc8_nornd_mmx (uint8_t *dst, uint8_t *src,
  60. int stride, int h, int x, int y);
  61. void ff_avg_vc1_chroma_mc8_nornd_mmxext(uint8_t *dst, uint8_t *src,
  62. int stride, int h, int x, int y);
  63. void ff_avg_vc1_chroma_mc8_nornd_3dnow(uint8_t *dst, uint8_t *src,
  64. int stride, int h, int x, int y);
  65. void ff_put_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
  66. int stride, int h, int x, int y);
  67. void ff_avg_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
  68. int stride, int h, int x, int y);
  69. av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp)
  70. {
  71. int mm_flags = av_get_cpu_flags();
  72. if (INLINE_MMX(mm_flags))
  73. ff_vc1dsp_init_mmx(dsp);
  74. if (INLINE_MMXEXT(mm_flags))
  75. ff_vc1dsp_init_mmxext(dsp);
  76. #define ASSIGN_LF(EXT) \
  77. dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \
  78. dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT; \
  79. dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \
  80. dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \
  81. dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \
  82. dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT
  83. #if HAVE_YASM
  84. if (mm_flags & AV_CPU_FLAG_MMX) {
  85. dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_mmx;
  86. }
  87. if (mm_flags & AV_CPU_FLAG_MMXEXT) {
  88. ASSIGN_LF(mmxext);
  89. dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_mmxext;
  90. } else if (mm_flags & AV_CPU_FLAG_3DNOW) {
  91. dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_3dnow;
  92. }
  93. if (mm_flags & AV_CPU_FLAG_SSE2) {
  94. dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_sse2;
  95. dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse2;
  96. dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_sse2;
  97. dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse2;
  98. }
  99. if (mm_flags & AV_CPU_FLAG_SSSE3) {
  100. ASSIGN_LF(ssse3);
  101. dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_ssse3;
  102. dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_ssse3;
  103. }
  104. if (mm_flags & AV_CPU_FLAG_SSE4) {
  105. dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
  106. dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4;
  107. }
  108. #endif /* HAVE_YASM */
  109. }