diracdsp_mmx.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (C) 2010 David Conrad
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "dsputil_x86.h"
  21. #include "diracdsp_mmx.h"
  22. void ff_put_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
  23. void ff_put_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
  24. void ff_put_signed_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
  25. void ff_put_signed_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
  26. #define HPEL_FILTER(MMSIZE, EXT) \
  27. void ff_dirac_hpel_filter_v_ ## EXT(uint8_t *, const uint8_t *, int, int); \
  28. void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *, const uint8_t *, int); \
  29. \
  30. static void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \
  31. const uint8_t *src, int stride, int width, int height) \
  32. { \
  33. while( height-- ) \
  34. { \
  35. ff_dirac_hpel_filter_v_ ## EXT(dstv-MMSIZE, src-MMSIZE, stride, width+MMSIZE+5); \
  36. ff_dirac_hpel_filter_h_ ## EXT(dsth, src, width); \
  37. ff_dirac_hpel_filter_h_ ## EXT(dstc, dstv, width); \
  38. \
  39. dsth += stride; \
  40. dstv += stride; \
  41. dstc += stride; \
  42. src += stride; \
  43. } \
  44. }
  45. #if !ARCH_X86_64
  46. HPEL_FILTER(8, mmx)
  47. #endif
  48. HPEL_FILTER(16, sse2)
  49. #define PIXFUNC(PFX, IDX, EXT) \
  50. /*MMXDISABLEDc->PFX ## _dirac_pixels_tab[0][IDX] = ff_ ## PFX ## _dirac_pixels8_ ## EXT;*/ \
  51. c->PFX ## _dirac_pixels_tab[1][IDX] = ff_ ## PFX ## _dirac_pixels16_ ## EXT; \
  52. c->PFX ## _dirac_pixels_tab[2][IDX] = ff_ ## PFX ## _dirac_pixels32_ ## EXT
  53. void ff_diracdsp_init_mmx(DiracDSPContext* c)
  54. {
  55. int mm_flags = av_get_cpu_flags();
  56. if (!(mm_flags & AV_CPU_FLAG_MMX))
  57. return;
  58. #if HAVE_YASM
  59. c->add_dirac_obmc[0] = ff_add_dirac_obmc8_mmx;
  60. #if !ARCH_X86_64
  61. c->add_dirac_obmc[1] = ff_add_dirac_obmc16_mmx;
  62. c->add_dirac_obmc[2] = ff_add_dirac_obmc32_mmx;
  63. c->dirac_hpel_filter = dirac_hpel_filter_mmx;
  64. c->add_rect_clamped = ff_add_rect_clamped_mmx;
  65. c->put_signed_rect_clamped = ff_put_signed_rect_clamped_mmx;
  66. #endif
  67. #endif
  68. #if HAVE_MMX_INLINE
  69. PIXFUNC(put, 0, mmx);
  70. PIXFUNC(avg, 0, mmx);
  71. #endif
  72. #if HAVE_MMXEXT_INLINE
  73. if (mm_flags & AV_CPU_FLAG_MMX2) {
  74. PIXFUNC(avg, 0, mmxext);
  75. }
  76. #endif
  77. if (mm_flags & AV_CPU_FLAG_SSE2) {
  78. #if HAVE_YASM
  79. c->dirac_hpel_filter = dirac_hpel_filter_sse2;
  80. c->add_rect_clamped = ff_add_rect_clamped_sse2;
  81. c->put_signed_rect_clamped = ff_put_signed_rect_clamped_sse2;
  82. c->add_dirac_obmc[1] = ff_add_dirac_obmc16_sse2;
  83. c->add_dirac_obmc[2] = ff_add_dirac_obmc32_sse2;
  84. #endif
  85. #if HAVE_SSE2_INLINE
  86. c->put_dirac_pixels_tab[1][0] = ff_put_dirac_pixels16_sse2;
  87. c->avg_dirac_pixels_tab[1][0] = ff_avg_dirac_pixels16_sse2;
  88. c->put_dirac_pixels_tab[2][0] = ff_put_dirac_pixels32_sse2;
  89. c->avg_dirac_pixels_tab[2][0] = ff_avg_dirac_pixels32_sse2;
  90. #endif
  91. }
  92. }