swscale_bfin.c 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
  3. *
  4. * Blackfin software video scaler operations
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include <stdint.h>
  23. #include "config.h"
  24. #include "libswscale/swscale_internal.h"
  25. #if defined (__FDPIC__) && CONFIG_SRAM
  26. #define L1CODE __attribute__((l1_text))
  27. #else
  28. #define L1CODE
  29. #endif
  30. int ff_bfin_uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
  31. uint8_t *vdst, int width, int height,
  32. int lumStride, int chromStride, int srcStride) L1CODE;
  33. int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
  34. uint8_t *vdst, int width, int height,
  35. int lumStride, int chromStride, int srcStride) L1CODE;
  36. static int uyvytoyv12_unscaled(SwsContext *c, const uint8_t *src[],
  37. int srcStride[], int srcSliceY, int srcSliceH,
  38. uint8_t *dst[], int dstStride[])
  39. {
  40. uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
  41. uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
  42. uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
  43. const uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
  44. int w = dstStride[0];
  45. ff_bfin_uyvytoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
  46. dstStride[0], dstStride[1], srcStride[0]);
  47. return srcSliceH;
  48. }
  49. static int yuyvtoyv12_unscaled(SwsContext *c, const uint8_t *src[],
  50. int srcStride[], int srcSliceY, int srcSliceH,
  51. uint8_t *dst[], int dstStride[])
  52. {
  53. uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
  54. uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
  55. uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
  56. const uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
  57. int w = dstStride[0];
  58. ff_bfin_yuyvtoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
  59. dstStride[0], dstStride[1], srcStride[0]);
  60. return srcSliceH;
  61. }
  62. void ff_bfin_get_unscaled_swscale(SwsContext *c)
  63. {
  64. if (c->dstFormat == AV_PIX_FMT_YUV420P && c->srcFormat == AV_PIX_FMT_UYVY422) {
  65. av_log(NULL, AV_LOG_VERBOSE,
  66. "selecting Blackfin optimized uyvytoyv12_unscaled\n");
  67. c->swScale = uyvytoyv12_unscaled;
  68. }
  69. if (c->dstFormat == AV_PIX_FMT_YUV420P && c->srcFormat == AV_PIX_FMT_YUYV422) {
  70. av_log(NULL, AV_LOG_VERBOSE,
  71. "selecting Blackfin optimized yuyvtoyv12_unscaled\n");
  72. c->swScale = yuyvtoyv12_unscaled;
  73. }
  74. }