video-fourcc.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /******************************************************************************
  2. Copyright (C) 2014 by Ruwen Hahn <palana@stunned.de>
  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) ((uint32_t)(((d) << 24) | ((c) << 16) | ((b) << 8) | (a)))
  17. enum video_format video_format_from_fourcc(uint32_t fourcc)
  18. {
  19. switch (fourcc) {
  20. case MAKE_FOURCC('U', 'Y', 'V', 'Y'):
  21. case MAKE_FOURCC('H', 'D', 'Y', 'C'):
  22. case MAKE_FOURCC('U', 'Y', 'N', 'V'):
  23. case MAKE_FOURCC('U', 'Y', 'N', 'Y'):
  24. case MAKE_FOURCC('u', 'y', 'v', '1'):
  25. case MAKE_FOURCC('2', 'v', 'u', 'y'):
  26. case MAKE_FOURCC('2', 'V', 'u', 'y'):
  27. return VIDEO_FORMAT_UYVY;
  28. case MAKE_FOURCC('Y', 'U', 'Y', '2'):
  29. case MAKE_FOURCC('Y', '4', '2', '2'):
  30. case MAKE_FOURCC('V', '4', '2', '2'):
  31. case MAKE_FOURCC('V', 'Y', 'U', 'Y'):
  32. case MAKE_FOURCC('Y', 'U', 'N', 'V'):
  33. case MAKE_FOURCC('y', 'u', 'v', '2'):
  34. case MAKE_FOURCC('y', 'u', 'v', 's'):
  35. return VIDEO_FORMAT_YUY2;
  36. case MAKE_FOURCC('Y', 'V', 'Y', 'U'):
  37. return VIDEO_FORMAT_YVYU;
  38. case MAKE_FOURCC('Y', '8', '0', '0'):
  39. return VIDEO_FORMAT_Y800;
  40. }
  41. return VIDEO_FORMAT_NONE;
  42. }