aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/pixdesc.c
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2013-04-26 14:43:02 +0200
committerJanne Grunau <janne-libav@jannau.net>2013-05-06 18:51:47 +0200
commit74652af821d7e526a6541876a637fbf81261fa8e (patch)
tree409d869fb4c72ec18ba6b403247d803203e002c2 /libavutil/pixdesc.c
parent6e293d111fcad27d52a2ef5ad77b1009f1743396 (diff)
downloadffmpeg-74652af821d7e526a6541876a637fbf81261fa8e.tar.gz
pixdesc: add function to return pixel format with swapped endiannes
Diffstat (limited to 'libavutil/pixdesc.c')
-rw-r--r--libavutil/pixdesc.c48
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
+}