swscale_unscaled.c 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2013 Xiaolei Yu <dreifachstein@gmail.com>
  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 "config.h"
  21. #include "libswscale/swscale.h"
  22. #include "libswscale/swscale_internal.h"
  23. #include "libavutil/arm/cpu.h"
  24. extern void rgbx_to_nv12_neon_32(const uint8_t *src, uint8_t *y, uint8_t *chroma,
  25. int width, int height,
  26. int y_stride, int c_stride, int src_stride,
  27. int32_t coeff_tbl[9]);
  28. extern void rgbx_to_nv12_neon_16(const uint8_t *src, uint8_t *y, uint8_t *chroma,
  29. int width, int height,
  30. int y_stride, int c_stride, int src_stride,
  31. int32_t coeff_tbl[9]);
  32. static int rgbx_to_nv12_neon_32_wrapper(SwsContext *context, const uint8_t *src[],
  33. int srcStride[], int srcSliceY, int srcSliceH,
  34. uint8_t *dst[], int dstStride[]) {
  35. rgbx_to_nv12_neon_32(src[0] + srcSliceY * srcStride[0],
  36. dst[0] + srcSliceY * dstStride[0],
  37. dst[1] + (srcSliceY / 2) * dstStride[1],
  38. context->srcW, srcSliceH,
  39. dstStride[0], dstStride[1], srcStride[0],
  40. context->input_rgb2yuv_table);
  41. return 0;
  42. }
  43. static int rgbx_to_nv12_neon_16_wrapper(SwsContext *context, const uint8_t *src[],
  44. int srcStride[], int srcSliceY, int srcSliceH,
  45. uint8_t *dst[], int dstStride[]) {
  46. rgbx_to_nv12_neon_16(src[0] + srcSliceY * srcStride[0],
  47. dst[0] + srcSliceY * dstStride[0],
  48. dst[1] + (srcSliceY / 2) * dstStride[1],
  49. context->srcW, srcSliceH,
  50. dstStride[0], dstStride[1], srcStride[0],
  51. context->input_rgb2yuv_table);
  52. return 0;
  53. }
  54. static void get_unscaled_swscale_neon(SwsContext *c) {
  55. int accurate_rnd = c->flags & SWS_ACCURATE_RND;
  56. if (c->srcFormat == AV_PIX_FMT_RGBA
  57. && c->dstFormat == AV_PIX_FMT_NV12
  58. && (c->srcW >= 16)) {
  59. c->swscale = accurate_rnd ? rgbx_to_nv12_neon_32_wrapper
  60. : rgbx_to_nv12_neon_16_wrapper;
  61. }
  62. }
  63. void ff_get_unscaled_swscale_arm(SwsContext *c)
  64. {
  65. int cpu_flags = av_get_cpu_flags();
  66. if (have_neon(cpu_flags))
  67. get_unscaled_swscale_neon(c);
  68. }