From 87807298a307d4e38195dc04f66c26404e7cb791 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 5 Feb 2020 10:20:06 +0100 Subject: [PATCH] format: add format_to_chroma_format MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Acked-by: Leo Liu Part-of: --- src/gallium/include/pipe/p_format.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 46bb8c97a00..a51843caa20 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -560,6 +560,26 @@ enum pipe_video_chroma_format PIPE_VIDEO_CHROMA_FORMAT_NONE }; +static inline enum pipe_video_chroma_format +pipe_format_to_chroma_format(enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_NV12: + case PIPE_FORMAT_NV21: + case PIPE_FORMAT_YV12: + case PIPE_FORMAT_IYUV: + case PIPE_FORMAT_P010: + case PIPE_FORMAT_P016: + return PIPE_VIDEO_CHROMA_FORMAT_420; + case PIPE_FORMAT_UYVY: + case PIPE_FORMAT_YUYV: + case PIPE_FORMAT_YV16: + return PIPE_VIDEO_CHROMA_FORMAT_422; + default: + return PIPE_VIDEO_CHROMA_FORMAT_NONE; + } +} + #ifdef __cplusplus } #endif -- 2.30.2