yuv2rgb.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * software YUV to RGB converter
  3. *
  4. * Copyright (C) 2009 Konstantin Shishkov
  5. *
  6. * MMX/MMXEXT template stuff (needed for fast movntq support),
  7. * 1,4,8bpp support and context / deglobalize stuff
  8. * by Michael Niedermayer (michaelni@gmx.at)
  9. *
  10. * This file is part of FFmpeg.
  11. *
  12. * FFmpeg is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU Lesser General Public
  14. * License as published by the Free Software Foundation; either
  15. * version 2.1 of the License, or (at your option) any later version.
  16. *
  17. * FFmpeg is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with FFmpeg; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  25. */
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <inttypes.h>
  29. #include "config.h"
  30. #include "libswscale/rgb2rgb.h"
  31. #include "libswscale/swscale.h"
  32. #include "libswscale/swscale_internal.h"
  33. #include "libavutil/attributes.h"
  34. #include "libavutil/x86/asm.h"
  35. #include "libavutil/x86/cpu.h"
  36. #include "libavutil/cpu.h"
  37. #if HAVE_X86ASM
  38. #define DITHER1XBPP // only for MMX
  39. //SSSE3 versions
  40. #undef RENAME
  41. #define RENAME(a) a ## _ssse3
  42. #include "yuv2rgb_template.c"
  43. #endif /* HAVE_X86ASM */
  44. av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c)
  45. {
  46. #if HAVE_X86ASM
  47. int cpu_flags = av_get_cpu_flags();
  48. if (EXTERNAL_SSSE3(cpu_flags)) {
  49. switch (c->dstFormat) {
  50. case AV_PIX_FMT_RGB32:
  51. if (c->srcFormat == AV_PIX_FMT_YUVA420P) {
  52. #if CONFIG_SWSCALE_ALPHA
  53. return yuva420_rgb32_ssse3;
  54. #endif
  55. break;
  56. } else
  57. return yuv420_rgb32_ssse3;
  58. case AV_PIX_FMT_BGR32:
  59. if (c->srcFormat == AV_PIX_FMT_YUVA420P) {
  60. #if CONFIG_SWSCALE_ALPHA
  61. return yuva420_bgr32_ssse3;
  62. #endif
  63. break;
  64. } else
  65. return yuv420_bgr32_ssse3;
  66. case AV_PIX_FMT_RGB24:
  67. return yuv420_rgb24_ssse3;
  68. case AV_PIX_FMT_BGR24:
  69. return yuv420_bgr24_ssse3;
  70. case AV_PIX_FMT_RGB565:
  71. return yuv420_rgb16_ssse3;
  72. case AV_PIX_FMT_RGB555:
  73. return yuv420_rgb15_ssse3;
  74. }
  75. }
  76. #endif /* HAVE_X86ASM */
  77. return NULL;
  78. }