diff options
author | Janne Grunau <janne-libav@jannau.net> | 2013-04-26 16:43:02 +0400 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2013-05-06 20:51:47 +0400 |
commit | 74652af821d7e526a6541876a637fbf81261fa8e (patch) | |
tree | 409d869fb4c72ec18ba6b403247d803203e002c2 /libavutil/pixdesc.c | |
parent | 6e293d111fcad27d52a2ef5ad77b1009f1743396 (diff) |
pixdesc: add function to return pixel format with swapped endiannes
Diffstat (limited to 'libavutil/pixdesc.c')
-rw-r--r-- | libavutil/pixdesc.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 67f9c435d0..fdc19292a0 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -1512,3 +1512,51 @@ int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt) ret += planes[i]; return ret; } + + +enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt) +{ +#define PIX_FMT_SWAP_ENDIANNESS(fmt) \ + case AV_PIX_FMT_ ## fmt ## BE: return AV_PIX_FMT_ ## fmt ## LE; \ + case AV_PIX_FMT_ ## fmt ## LE: return AV_PIX_FMT_ ## fmt ## BE + + switch (pix_fmt) { + PIX_FMT_SWAP_ENDIANNESS(GRAY16); + PIX_FMT_SWAP_ENDIANNESS(RGB48); + PIX_FMT_SWAP_ENDIANNESS(RGB565); + PIX_FMT_SWAP_ENDIANNESS(RGB555); + PIX_FMT_SWAP_ENDIANNESS(RGB444); + PIX_FMT_SWAP_ENDIANNESS(BGR48); + PIX_FMT_SWAP_ENDIANNESS(BGR565); + PIX_FMT_SWAP_ENDIANNESS(BGR555); + PIX_FMT_SWAP_ENDIANNESS(BGR444); + + PIX_FMT_SWAP_ENDIANNESS(YUV420P9); + PIX_FMT_SWAP_ENDIANNESS(YUV422P9); + PIX_FMT_SWAP_ENDIANNESS(YUV444P9); + PIX_FMT_SWAP_ENDIANNESS(YUV420P10); + PIX_FMT_SWAP_ENDIANNESS(YUV422P10); + PIX_FMT_SWAP_ENDIANNESS(YUV444P10); + PIX_FMT_SWAP_ENDIANNESS(YUV420P16); + PIX_FMT_SWAP_ENDIANNESS(YUV422P16); + PIX_FMT_SWAP_ENDIANNESS(YUV444P16); + + PIX_FMT_SWAP_ENDIANNESS(GBRP9); + PIX_FMT_SWAP_ENDIANNESS(GBRP10); + PIX_FMT_SWAP_ENDIANNESS(GBRP16); + PIX_FMT_SWAP_ENDIANNESS(YUVA420P9); + PIX_FMT_SWAP_ENDIANNESS(YUVA422P9); + PIX_FMT_SWAP_ENDIANNESS(YUVA444P9); + PIX_FMT_SWAP_ENDIANNESS(YUVA420P10); + PIX_FMT_SWAP_ENDIANNESS(YUVA422P10); + PIX_FMT_SWAP_ENDIANNESS(YUVA444P10); + PIX_FMT_SWAP_ENDIANNESS(YUVA420P16); + PIX_FMT_SWAP_ENDIANNESS(YUVA422P16); + PIX_FMT_SWAP_ENDIANNESS(YUVA444P16); + + PIX_FMT_SWAP_ENDIANNESS(XYZ12); + default: + return AV_PIX_FMT_NONE; + } +#undef PIX_FMT_SWAP_ENDIANNESS +} |