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.

81 lines
3.2KB

  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "config.h"
  19. #include "libavutil/attributes.h"
  20. #include "libavutil/cpu.h"
  21. #include "libavutil/x86/asm.h"
  22. #include "libavutil/x86/cpu.h"
  23. #include "libavcodec/huffyuvdsp.h"
  24. void ff_add_bytes_mmx(uint8_t *dst, uint8_t *src, intptr_t w);
  25. void ff_add_bytes_sse2(uint8_t *dst, uint8_t *src, intptr_t w);
  26. void ff_add_hfyu_median_pred_cmov(uint8_t *dst, const uint8_t *top,
  27. const uint8_t *diff, intptr_t w,
  28. int *left, int *left_top);
  29. void ff_add_hfyu_median_pred_mmxext(uint8_t *dst, const uint8_t *top,
  30. const uint8_t *diff, intptr_t w,
  31. int *left, int *left_top);
  32. void ff_add_hfyu_median_pred_sse2(uint8_t *dst, const uint8_t *top,
  33. const uint8_t *diff, intptr_t w,
  34. int *left, int *left_top);
  35. int ff_add_hfyu_left_pred_ssse3(uint8_t *dst, const uint8_t *src,
  36. intptr_t w, int left);
  37. int ff_add_hfyu_left_pred_sse4(uint8_t *dst, const uint8_t *src,
  38. intptr_t w, int left);
  39. void ff_add_hfyu_left_pred_bgr32_mmx(uint8_t *dst, const uint8_t *src,
  40. intptr_t w, uint8_t *left);
  41. void ff_add_hfyu_left_pred_bgr32_sse2(uint8_t *dst, const uint8_t *src,
  42. intptr_t w, uint8_t *left);
  43. av_cold void ff_huffyuvdsp_init_x86(HuffYUVDSPContext *c)
  44. {
  45. int cpu_flags = av_get_cpu_flags();
  46. #if HAVE_7REGS && HAVE_INLINE_ASM
  47. if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_CMOV)
  48. c->add_hfyu_median_pred = ff_add_hfyu_median_pred_cmov;
  49. #endif
  50. if (EXTERNAL_MMX(cpu_flags)) {
  51. c->add_bytes = ff_add_bytes_mmx;
  52. c->add_hfyu_left_pred_bgr32 = ff_add_hfyu_left_pred_bgr32_mmx;
  53. }
  54. if (EXTERNAL_MMXEXT(cpu_flags)) {
  55. /* slower than cmov version on AMD */
  56. if (!(cpu_flags & AV_CPU_FLAG_3DNOW))
  57. c->add_hfyu_median_pred = ff_add_hfyu_median_pred_mmxext;
  58. }
  59. if (EXTERNAL_SSE2(cpu_flags)) {
  60. c->add_bytes = ff_add_bytes_sse2;
  61. c->add_hfyu_median_pred = ff_add_hfyu_median_pred_sse2;
  62. c->add_hfyu_left_pred_bgr32 = ff_add_hfyu_left_pred_bgr32_sse2;
  63. }
  64. if (EXTERNAL_SSSE3(cpu_flags)) {
  65. c->add_hfyu_left_pred = ff_add_hfyu_left_pred_ssse3;
  66. if (cpu_flags & AV_CPU_FLAG_SSE4) // not really SSE4, just slow on Conroe
  67. c->add_hfyu_left_pred = ff_add_hfyu_left_pred_sse4;
  68. }
  69. }