swscale_bfin.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <inttypes.h>
  26. #include <assert.h>
  27. #include "config.h"
  28. #include <unistd.h>
  29. #include "libswscale/rgb2rgb.h"
  30. #include "libswscale/swscale.h"
  31. #include "libswscale/swscale_internal.h"
  32. #if defined (__FDPIC__) && CONFIG_SRAM
  33. #define L1CODE __attribute__ ((l1_text))
  34. #else
  35. #define L1CODE
  36. #endif
  37. int ff_bfin_uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
  38. long width, long height,
  39. long lumStride, long chromStride, long srcStride) L1CODE;
  40. int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
  41. long width, long height,
  42. long lumStride, long chromStride, long srcStride) L1CODE;
  43. static int uyvytoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
  44. int srcSliceH, uint8_t* dst[], int dstStride[])
  45. {
  46. uint8_t *dsty = dst[0] + dstStride[0]*srcSliceY;
  47. uint8_t *dstu = dst[1] + dstStride[1]*srcSliceY/2;
  48. uint8_t *dstv = dst[2] + dstStride[2]*srcSliceY/2;
  49. uint8_t *ip = src[0] + srcStride[0]*srcSliceY;
  50. int w = dstStride[0];
  51. ff_bfin_uyvytoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
  52. dstStride[0], dstStride[1], srcStride[0]);
  53. return srcSliceH;
  54. }
  55. static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
  56. int srcSliceH, uint8_t* dst[], int dstStride[])
  57. {
  58. uint8_t *dsty = dst[0] + dstStride[0]*srcSliceY;
  59. uint8_t *dstu = dst[1] + dstStride[1]*srcSliceY/2;
  60. uint8_t *dstv = dst[2] + dstStride[2]*srcSliceY/2;
  61. uint8_t *ip = src[0] + srcStride[0]*srcSliceY;
  62. int w = dstStride[0];
  63. ff_bfin_yuyvtoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
  64. dstStride[0], dstStride[1], srcStride[0]);
  65. return srcSliceH;
  66. }
  67. void ff_bfin_get_unscaled_swscale(SwsContext *c)
  68. {
  69. SwsFunc swScale = c->swScale;
  70. if (c->flags & SWS_CPU_CAPS_BFIN)
  71. if (c->dstFormat == PIX_FMT_YUV420P)
  72. if (c->srcFormat == PIX_FMT_UYVY422) {
  73. av_log (NULL, AV_LOG_VERBOSE, "selecting Blackfin optimized uyvytoyv12_unscaled\n");
  74. c->swScale = uyvytoyv12_unscaled;
  75. }
  76. if (c->dstFormat == PIX_FMT_YUV420P)
  77. if (c->srcFormat == PIX_FMT_YUYV422) {
  78. av_log (NULL, AV_LOG_VERBOSE, "selecting Blackfin optimized yuyvtoyv12_unscaled\n");
  79. c->swScale = yuyvtoyv12_unscaled;
  80. }
  81. }