image_convert.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*****************************************************************************
  2. * yuv_rgb.c : ARM NEONv1 YUV to RGB32 chroma conversion for VLC
  3. *****************************************************************************
  4. * Copyright (C) 2011 Bilibili
  5. * Copyright (C) 2011 Sébastien Toque
  6. * Rémi Denis-Courmont
  7. * Copyright (C) 2013 Zhang Rui <bbcallen@gmail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation; either version 2.1 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program 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 Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  22. *****************************************************************************/
  23. #include "../ijksdl_image_convert.h"
  24. #if defined(__ANDROID__)
  25. #include "libyuv.h"
  26. #endif
  27. int ijk_image_convert(int width, int height,
  28. enum AVPixelFormat dst_format, uint8_t **dst_data, int *dst_linesize,
  29. enum AVPixelFormat src_format, const uint8_t **src_data, const int *src_linesize)
  30. {
  31. #if defined(__ANDROID__)
  32. switch (src_format) {
  33. case AV_PIX_FMT_YUV420P:
  34. case AV_PIX_FMT_YUVJ420P: // FIXME: 9 not equal to AV_PIX_FMT_YUV420P, but a workaround
  35. switch (dst_format) {
  36. case AV_PIX_FMT_RGB565:
  37. return I420ToRGB565(
  38. src_data[0], src_linesize[0],
  39. src_data[1], src_linesize[1],
  40. src_data[2], src_linesize[2],
  41. dst_data[0], dst_linesize[0],
  42. width, height);
  43. case AV_PIX_FMT_0BGR32:
  44. return I420ToABGR(
  45. src_data[0], src_linesize[0],
  46. src_data[1], src_linesize[1],
  47. src_data[2], src_linesize[2],
  48. dst_data[0], dst_linesize[0],
  49. width, height);
  50. default:
  51. break;
  52. }
  53. break;
  54. default:
  55. break;
  56. }
  57. #endif
  58. return -1;
  59. }