You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.8KB

  1. /*
  2. * yuv2rgb_mlib.c, Software YUV to RGB converter using mediaLib
  3. * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <mlib_types.h>
  22. #include <mlib_status.h>
  23. #include <mlib_sys.h>
  24. #include <mlib_video.h>
  25. #include <inttypes.h>
  26. #include <stdlib.h>
  27. #include <assert.h>
  28. #include "swscale.h"
  29. static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
  30. int srcSliceH, uint8_t* dst[], int dstStride[]){
  31. if(c->srcFormat == PIX_FMT_YUV422P){
  32. srcStride[1] *= 2;
  33. srcStride[2] *= 2;
  34. }
  35. assert(srcStride[1] == srcStride[2]);
  36. mlib_VideoColorYUV2ARGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
  37. srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
  38. return srcSliceH;
  39. }
  40. static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
  41. int srcSliceH, uint8_t* dst[], int dstStride[]){
  42. if(c->srcFormat == PIX_FMT_YUV422P){
  43. srcStride[1] *= 2;
  44. srcStride[2] *= 2;
  45. }
  46. assert(srcStride[1] == srcStride[2]);
  47. mlib_VideoColorYUV2ABGR420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
  48. srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
  49. return srcSliceH;
  50. }
  51. static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
  52. int srcSliceH, uint8_t* dst[], int dstStride[]){
  53. if(c->srcFormat == PIX_FMT_YUV422P){
  54. srcStride[1] *= 2;
  55. srcStride[2] *= 2;
  56. }
  57. assert(srcStride[1] == srcStride[2]);
  58. mlib_VideoColorYUV2RGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
  59. srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
  60. return srcSliceH;
  61. }
  62. SwsFunc yuv2rgb_init_mlib(SwsContext *c)
  63. {
  64. switch(c->dstFormat){
  65. case PIX_FMT_RGB24: return mlib_YUV2RGB420_24;
  66. case PIX_FMT_BGR32: return mlib_YUV2ARGB420_32;
  67. case PIX_FMT_RGB32: return mlib_YUV2ABGR420_32;
  68. default: return NULL;
  69. }
  70. }