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.

89 lines
2.7KB

  1. /*
  2. * yuv2rgb_mlib.c, Software YUV to RGB coverter using mediaLib
  3. *
  4. * Copyright (C) 2000, HÃ¥kan Hjort <d95hjort@dtek.chalmers.se>
  5. * All Rights Reserved.
  6. *
  7. * This file is part of mpeg2dec, a free MPEG-2 video decoder
  8. *
  9. * mpeg2dec is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2, or (at your option)
  12. * any later version.
  13. *
  14. * mpeg2dec 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
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with GNU Make; see the file COPYING. If not, write to
  21. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22. *
  23. */
  24. #include <mlib_types.h>
  25. #include <mlib_status.h>
  26. #include <mlib_sys.h>
  27. #include <mlib_video.h>
  28. #include <inttypes.h>
  29. #include <stdlib.h>
  30. #include <assert.h>
  31. #include "../libvo/img_format.h" //FIXME try to reduce dependency of such stuff
  32. #include "swscale.h"
  33. static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
  34. int srcSliceH, uint8_t* dst[], int dstStride[]){
  35. if(c->srcFormat == IMGFMT_422P){
  36. srcStride[1] *= 2;
  37. srcStride[2] *= 2;
  38. }
  39. assert(srcStride[1] == srcStride[2]);
  40. mlib_VideoColorYUV2ARGB420(dst[0], src[0], src[1], src[2], c->dstW,
  41. c->dstH, dstStride[0], srcStride[0], srcStride[1]);
  42. return srcSliceH;
  43. }
  44. static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
  45. int srcSliceH, uint8_t* dst[], int dstStride[]){
  46. if(c->srcFormat == IMGFMT_422P){
  47. srcStride[1] *= 2;
  48. srcStride[2] *= 2;
  49. }
  50. assert(srcStride[1] == srcStride[2]);
  51. mlib_VideoColorYUV2ABGR420(dst[0], src[0], src[1], src[2], c->dstW,
  52. c->dstH, dstStride[0], srcStride[0], srcStride[1]);
  53. return srcSliceH;
  54. }
  55. static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
  56. int srcSliceH, uint8_t* dst[], int dstStride[]){
  57. if(c->srcFormat == IMGFMT_422P){
  58. srcStride[1] *= 2;
  59. srcStride[2] *= 2;
  60. }
  61. assert(srcStride[1] == srcStride[2]);
  62. mlib_VideoColorYUV2RGB420(dst[0], src[0], src[1], src[2], c->dstW,
  63. c->dstH, dstStride[0], srcStride[0], srcStride[1]);
  64. return srcSliceH;
  65. }
  66. SwsFunc yuv2rgb_init_mlib(SwsContext *c)
  67. {
  68. switch(c->dstFormat){
  69. case IMGFMT_RGB24: return mlib_YUV2RGB420_24;
  70. case IMGFMT_RGB32: return mlib_YUV2ARGB420_32;
  71. case IMGFMT_BGR32: return mlib_YUV2ARGB420_32;
  72. default: return NULL;
  73. }
  74. }