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.

90 lines
4.1KB

  1. /*
  2. * RV40 decoder motion compensation functions x86-optimised
  3. * Copyright (c) 2008 Konstantin Shishkov
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * RV40 decoder motion compensation functions x86-optimised
  24. */
  25. #include "libavcodec/rv34dsp.h"
  26. void ff_put_rv40_chroma_mc8_mmx (uint8_t *dst, uint8_t *src,
  27. int stride, int h, int x, int y);
  28. void ff_avg_rv40_chroma_mc8_mmx2 (uint8_t *dst, uint8_t *src,
  29. int stride, int h, int x, int y);
  30. void ff_avg_rv40_chroma_mc8_3dnow(uint8_t *dst, uint8_t *src,
  31. int stride, int h, int x, int y);
  32. void ff_put_rv40_chroma_mc4_mmx (uint8_t *dst, uint8_t *src,
  33. int stride, int h, int x, int y);
  34. void ff_avg_rv40_chroma_mc4_mmx2 (uint8_t *dst, uint8_t *src,
  35. int stride, int h, int x, int y);
  36. void ff_avg_rv40_chroma_mc4_3dnow(uint8_t *dst, uint8_t *src,
  37. int stride, int h, int x, int y);
  38. #define DECLARE_WEIGHT(opt) \
  39. void ff_rv40_weight_func_rnd_16_##opt(uint8_t *dst, uint8_t *src1, uint8_t *src2, \
  40. int w1, int w2, ptrdiff_t stride); \
  41. void ff_rv40_weight_func_rnd_8_##opt (uint8_t *dst, uint8_t *src1, uint8_t *src2, \
  42. int w1, int w2, ptrdiff_t stride); \
  43. void ff_rv40_weight_func_nornd_16_##opt(uint8_t *dst, uint8_t *src1, uint8_t *src2, \
  44. int w1, int w2, ptrdiff_t stride); \
  45. void ff_rv40_weight_func_nornd_8_##opt (uint8_t *dst, uint8_t *src1, uint8_t *src2, \
  46. int w1, int w2, ptrdiff_t stride);
  47. DECLARE_WEIGHT(mmx)
  48. DECLARE_WEIGHT(sse2)
  49. DECLARE_WEIGHT(ssse3)
  50. void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp)
  51. {
  52. #if HAVE_YASM
  53. int mm_flags = av_get_cpu_flags();
  54. if (mm_flags & AV_CPU_FLAG_MMX) {
  55. c->put_chroma_pixels_tab[0] = ff_put_rv40_chroma_mc8_mmx;
  56. c->put_chroma_pixels_tab[1] = ff_put_rv40_chroma_mc4_mmx;
  57. c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_mmx;
  58. c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_mmx;
  59. c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_mmx;
  60. c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_mmx;
  61. }
  62. if (mm_flags & AV_CPU_FLAG_MMX2) {
  63. c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_mmx2;
  64. c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_mmx2;
  65. } else if (mm_flags & AV_CPU_FLAG_3DNOW) {
  66. c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_3dnow;
  67. c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_3dnow;
  68. }
  69. if (mm_flags & AV_CPU_FLAG_SSE2) {
  70. c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_sse2;
  71. c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_sse2;
  72. c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_sse2;
  73. c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_sse2;
  74. }
  75. if (mm_flags & AV_CPU_FLAG_SSSE3) {
  76. c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_ssse3;
  77. c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_ssse3;
  78. c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_ssse3;
  79. c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_ssse3;
  80. }
  81. #endif
  82. }