swscale_lsx.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Loongson LSX optimized swscale
  3. *
  4. * Copyright (c) 2023 Loongson Technology Corporation Limited
  5. * Contributed by Lu Wang <wanglu@loongson.cn>
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #include "swscale_loongarch.h"
  24. void ff_hscale_16_to_15_lsx(SwsContext *c, int16_t *_dst, int dstW,
  25. const uint8_t *_src, const int16_t *filter,
  26. const int32_t *filterPos, int filterSize)
  27. {
  28. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
  29. int sh = desc->comp[0].depth - 1;
  30. if (sh < 15) {
  31. sh = isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 :
  32. (desc->comp[0].depth - 1);
  33. } else if (desc->flags && AV_PIX_FMT_FLAG_FLOAT) {
  34. sh = 15;
  35. }
  36. ff_hscale_16_to_15_sub_lsx(c, _dst, dstW, _src, filter, filterPos, filterSize, sh);
  37. }
  38. void ff_hscale_16_to_19_lsx(SwsContext *c, int16_t *_dst, int dstW,
  39. const uint8_t *_src, const int16_t *filter,
  40. const int32_t *filterPos, int filterSize)
  41. {
  42. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
  43. int bits = desc->comp[0].depth - 1;
  44. int sh = bits - 4;
  45. if ((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) && desc->comp[0].depth<16) {
  46. sh = 9;
  47. } else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are process like uint 16bpc */
  48. sh = 16 - 1 - 4;
  49. }
  50. ff_hscale_16_to_19_sub_lsx(c, _dst, dstW, _src, filter, filterPos, filterSize, sh);
  51. }