2
0

vc1dsp_init.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 "libavutil/x86/asm.h"
  30. #include "libavcodec/vc1dsp.h"
  31. #include "fpel.h"
  32. #include "vc1dsp.h"
  33. #include "config.h"
  34. #define LOOP_FILTER(EXT) \
  35. void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
  36. void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
  37. void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
  38. void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
  39. \
  40. static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
  41. { \
  42. ff_vc1_v_loop_filter8_ ## EXT(src, stride, pq); \
  43. ff_vc1_v_loop_filter8_ ## EXT(src+8, stride, pq); \
  44. } \
  45. \
  46. static void vc1_h_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
  47. { \
  48. ff_vc1_h_loop_filter8_ ## EXT(src, stride, pq); \
  49. ff_vc1_h_loop_filter8_ ## EXT(src+8*stride, stride, pq); \
  50. }
  51. #if HAVE_X86ASM
  52. LOOP_FILTER(mmxext)
  53. LOOP_FILTER(sse2)
  54. LOOP_FILTER(ssse3)
  55. void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq);
  56. static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq)
  57. {
  58. ff_vc1_h_loop_filter8_sse4(src, stride, pq);
  59. ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq);
  60. }
  61. #define DECLARE_FUNCTION(OP, DEPTH, INSN) \
  62. static void OP##vc1_mspel_mc00_##DEPTH##INSN(uint8_t *dst, \
  63. const uint8_t *src, ptrdiff_t stride, int rnd) \
  64. { \
  65. ff_ ## OP ## pixels ## DEPTH ## INSN(dst, src, stride, DEPTH); \
  66. }
  67. DECLARE_FUNCTION(put_, 8, _mmx)
  68. DECLARE_FUNCTION(put_, 16, _mmx)
  69. DECLARE_FUNCTION(avg_, 8, _mmx)
  70. DECLARE_FUNCTION(avg_, 16, _mmx)
  71. DECLARE_FUNCTION(avg_, 8, _mmxext)
  72. DECLARE_FUNCTION(avg_, 16, _mmxext)
  73. DECLARE_FUNCTION(put_, 16, _sse2)
  74. DECLARE_FUNCTION(avg_, 16, _sse2)
  75. #endif /* HAVE_X86ASM */
  76. void ff_put_vc1_chroma_mc8_nornd_mmx (uint8_t *dst, uint8_t *src,
  77. ptrdiff_t stride, int h, int x, int y);
  78. void ff_avg_vc1_chroma_mc8_nornd_mmxext(uint8_t *dst, uint8_t *src,
  79. ptrdiff_t stride, int h, int x, int y);
  80. void ff_avg_vc1_chroma_mc8_nornd_3dnow(uint8_t *dst, uint8_t *src,
  81. ptrdiff_t stride, int h, int x, int y);
  82. void ff_put_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
  83. ptrdiff_t stride, int h, int x, int y);
  84. void ff_avg_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
  85. ptrdiff_t stride, int h, int x, int y);
  86. void ff_vc1_inv_trans_4x4_dc_mmxext(uint8_t *dest, ptrdiff_t linesize,
  87. int16_t *block);
  88. void ff_vc1_inv_trans_4x8_dc_mmxext(uint8_t *dest, ptrdiff_t linesize,
  89. int16_t *block);
  90. void ff_vc1_inv_trans_8x4_dc_mmxext(uint8_t *dest, ptrdiff_t linesize,
  91. int16_t *block);
  92. void ff_vc1_inv_trans_8x8_dc_mmxext(uint8_t *dest, ptrdiff_t linesize,
  93. int16_t *block);
  94. av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp)
  95. {
  96. int cpu_flags = av_get_cpu_flags();
  97. if (HAVE_6REGS && INLINE_MMX(cpu_flags))
  98. if (EXTERNAL_MMX(cpu_flags))
  99. ff_vc1dsp_init_mmx(dsp);
  100. if (HAVE_6REGS && INLINE_MMXEXT(cpu_flags))
  101. if (EXTERNAL_MMXEXT(cpu_flags))
  102. ff_vc1dsp_init_mmxext(dsp);
  103. #define ASSIGN_LF(EXT) \
  104. dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \
  105. dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT; \
  106. dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \
  107. dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \
  108. dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \
  109. dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT
  110. #if HAVE_X86ASM
  111. if (EXTERNAL_MMX(cpu_flags)) {
  112. dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_mmx;
  113. dsp->put_vc1_mspel_pixels_tab[1][0] = put_vc1_mspel_mc00_8_mmx;
  114. dsp->put_vc1_mspel_pixels_tab[0][0] = put_vc1_mspel_mc00_16_mmx;
  115. dsp->avg_vc1_mspel_pixels_tab[1][0] = avg_vc1_mspel_mc00_8_mmx;
  116. dsp->avg_vc1_mspel_pixels_tab[0][0] = avg_vc1_mspel_mc00_16_mmx;
  117. }
  118. if (EXTERNAL_AMD3DNOW(cpu_flags)) {
  119. dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_3dnow;
  120. }
  121. if (EXTERNAL_MMXEXT(cpu_flags)) {
  122. ASSIGN_LF(mmxext);
  123. dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_mmxext;
  124. dsp->avg_vc1_mspel_pixels_tab[1][0] = avg_vc1_mspel_mc00_8_mmxext;
  125. dsp->avg_vc1_mspel_pixels_tab[0][0] = avg_vc1_mspel_mc00_16_mmxext;
  126. dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_mmxext;
  127. dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_mmxext;
  128. dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_mmxext;
  129. dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_mmxext;
  130. }
  131. if (EXTERNAL_SSE2(cpu_flags)) {
  132. dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_sse2;
  133. dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse2;
  134. dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_sse2;
  135. dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse2;
  136. dsp->put_vc1_mspel_pixels_tab[0][0] = put_vc1_mspel_mc00_16_sse2;
  137. dsp->avg_vc1_mspel_pixels_tab[0][0] = avg_vc1_mspel_mc00_16_sse2;
  138. }
  139. if (EXTERNAL_SSSE3(cpu_flags)) {
  140. ASSIGN_LF(ssse3);
  141. dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_ssse3;
  142. dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_ssse3;
  143. }
  144. if (EXTERNAL_SSE4(cpu_flags)) {
  145. dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
  146. dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4;
  147. }
  148. #endif /* HAVE_X86ASM */
  149. }