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.

82 lines
2.5KB

  1. /*
  2. * Copyright (c) 2013 Guillaume Martres <smarter@ubuntu.com>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * Libav is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <aom/aom_image.h>
  21. #include "libaom.h"
  22. #define HIGH_DEPTH(fmt) \
  23. case AOM_IMG_FMT_I ## fmt ## 16: \
  24. switch (depth) { \
  25. case 8: \
  26. return AV_PIX_FMT_YUV ## fmt ## P; \
  27. case 10: \
  28. return AV_PIX_FMT_YUV ## fmt ## P10; \
  29. case 12: \
  30. return AV_PIX_FMT_YUV ## fmt ## P12; \
  31. default: \
  32. return AV_PIX_FMT_NONE; \
  33. }
  34. enum AVPixelFormat ff_aom_imgfmt_to_pixfmt(aom_img_fmt_t img, int depth)
  35. {
  36. switch (img) {
  37. case AOM_IMG_FMT_I420:
  38. return AV_PIX_FMT_YUV420P;
  39. case AOM_IMG_FMT_I422:
  40. return AV_PIX_FMT_YUV422P;
  41. case AOM_IMG_FMT_I444:
  42. return AV_PIX_FMT_YUV444P;
  43. HIGH_DEPTH(420)
  44. HIGH_DEPTH(422)
  45. HIGH_DEPTH(444)
  46. default:
  47. return AV_PIX_FMT_NONE;
  48. }
  49. }
  50. #undef HIGH_DEPTH
  51. aom_img_fmt_t ff_aom_pixfmt_to_imgfmt(enum AVPixelFormat pix)
  52. {
  53. switch (pix) {
  54. case AV_PIX_FMT_YUV420P:
  55. return AOM_IMG_FMT_I420;
  56. case AV_PIX_FMT_YUV422P:
  57. return AOM_IMG_FMT_I422;
  58. case AV_PIX_FMT_YUV444P:
  59. return AOM_IMG_FMT_I444;
  60. case AV_PIX_FMT_YUV420P10:
  61. return AOM_IMG_FMT_I42016;
  62. case AV_PIX_FMT_YUV422P10:
  63. return AOM_IMG_FMT_I42216;
  64. case AV_PIX_FMT_YUV444P10:
  65. return AOM_IMG_FMT_I44416;
  66. case AV_PIX_FMT_YUV420P12:
  67. return AOM_IMG_FMT_I42016;
  68. case AV_PIX_FMT_YUV422P12:
  69. return AOM_IMG_FMT_I42216;
  70. case AV_PIX_FMT_YUV444P12:
  71. return AOM_IMG_FMT_I44416;
  72. default:
  73. return AOM_IMG_FMT_NONE;
  74. }
  75. }