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.

133 lines
5.2KB

  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/attributes.h"
  27. #include "libavutil/cpu.h"
  28. #include "libavutil/x86/cpu.h"
  29. #include "libavcodec/vc1dsp.h"
  30. #include "fpel.h"
  31. #include "vc1dsp.h"
  32. #include "config.h"
  33. #define LOOP_FILTER(EXT) \
  34. void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
  35. void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
  36. void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
  37. void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
  38. \
  39. static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
  40. { \
  41. ff_vc1_v_loop_filter8_ ## EXT(src, stride, pq); \
  42. ff_vc1_v_loop_filter8_ ## EXT(src+8, stride, pq); \
  43. } \
  44. \
  45. static void vc1_h_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
  46. { \
  47. ff_vc1_h_loop_filter8_ ## EXT(src, stride, pq); \
  48. ff_vc1_h_loop_filter8_ ## EXT(src+8*stride, stride, pq); \
  49. }
  50. #if HAVE_X86ASM
  51. LOOP_FILTER(mmxext)
  52. LOOP_FILTER(sse2)
  53. LOOP_FILTER(ssse3)
  54. void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq);
  55. static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq)
  56. {
  57. ff_vc1_h_loop_filter8_sse4(src, stride, pq);
  58. ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq);
  59. }
  60. static void avg_vc1_mspel_mc00_mmxext(uint8_t *dst, const uint8_t *src,
  61. ptrdiff_t stride, int rnd)
  62. {
  63. ff_avg_pixels8_mmxext(dst, src, stride, 8);
  64. }
  65. #endif /* HAVE_X86ASM */
  66. void ff_put_vc1_chroma_mc8_nornd_mmx (uint8_t *dst, uint8_t *src,
  67. ptrdiff_t stride, int h, int x, int y);
  68. void ff_avg_vc1_chroma_mc8_nornd_mmxext(uint8_t *dst, uint8_t *src,
  69. ptrdiff_t stride, int h, int x, int y);
  70. void ff_avg_vc1_chroma_mc8_nornd_3dnow(uint8_t *dst, uint8_t *src,
  71. ptrdiff_t stride, int h, int x, int y);
  72. void ff_put_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
  73. ptrdiff_t stride, int h, int x, int y);
  74. void ff_avg_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
  75. ptrdiff_t stride, int h, int x, int y);
  76. av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp)
  77. {
  78. int cpu_flags = av_get_cpu_flags();
  79. if (INLINE_MMX(cpu_flags))
  80. ff_vc1dsp_init_mmx(dsp);
  81. if (INLINE_MMXEXT(cpu_flags))
  82. ff_vc1dsp_init_mmxext(dsp);
  83. #define ASSIGN_LF(EXT) \
  84. dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \
  85. dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT; \
  86. dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \
  87. dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \
  88. dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \
  89. dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT
  90. #if HAVE_X86ASM
  91. if (EXTERNAL_MMX(cpu_flags)) {
  92. dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_mmx;
  93. }
  94. if (EXTERNAL_AMD3DNOW(cpu_flags)) {
  95. dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_3dnow;
  96. }
  97. if (EXTERNAL_MMXEXT(cpu_flags)) {
  98. ASSIGN_LF(mmxext);
  99. dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_mmxext;
  100. dsp->avg_vc1_mspel_pixels_tab[0] = avg_vc1_mspel_mc00_mmxext;
  101. }
  102. if (EXTERNAL_SSE2(cpu_flags)) {
  103. dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_sse2;
  104. dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse2;
  105. dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_sse2;
  106. dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse2;
  107. }
  108. if (EXTERNAL_SSSE3(cpu_flags)) {
  109. ASSIGN_LF(ssse3);
  110. dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_ssse3;
  111. dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_ssse3;
  112. }
  113. if (EXTERNAL_SSE4(cpu_flags)) {
  114. dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
  115. dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4;
  116. }
  117. #endif /* HAVE_X86ASM */
  118. }