video-fourcc.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /******************************************************************************
  2. Copyright (C) 2014 by Ruwen Hahn <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include "../util/c99defs.h"
  15. #include "video-io.h"
  16. #define MAKE_FOURCC(a, b, c, d) \
  17. ((uint32_t)(((d) << 24) | ((c) << 16) | ((b) << 8) | (a)))
  18. enum video_format video_format_from_fourcc(uint32_t fourcc)
  19. {
  20. switch (fourcc) {
  21. case MAKE_FOURCC('U','Y','V','Y'):
  22. case MAKE_FOURCC('H','D','Y','C'):
  23. case MAKE_FOURCC('U','Y','N','V'):
  24. case MAKE_FOURCC('U','Y','N','Y'):
  25. case MAKE_FOURCC('u','y','v','1'):
  26. case MAKE_FOURCC('2','v','u','y'):
  27. case MAKE_FOURCC('2','V','u','y'):
  28. return VIDEO_FORMAT_UYVY;
  29. case MAKE_FOURCC('Y','U','Y','2'):
  30. case MAKE_FOURCC('Y','4','2','2'):
  31. case MAKE_FOURCC('V','4','2','2'):
  32. case MAKE_FOURCC('V','Y','U','Y'):
  33. case MAKE_FOURCC('Y','U','N','V'):
  34. case MAKE_FOURCC('y','u','v','2'):
  35. case MAKE_FOURCC('y','u','v','s'):
  36. return VIDEO_FORMAT_YUY2;
  37. case MAKE_FOURCC('Y','V','Y','U'):
  38. return VIDEO_FORMAT_YVYU;
  39. case MAKE_FOURCC('Y','8','0','0'):
  40. return VIDEO_FORMAT_Y800;
  41. }
  42. return VIDEO_FORMAT_NONE;
  43. }