format: add format_to_chroma_format
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Wed, 5 Feb 2020 09:20:06 +0000 (10:20 +0100)
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Thu, 27 Feb 2020 09:01:31 +0000 (10:01 +0100)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3738>

src/gallium/include/pipe/p_format.h

index 46bb8c97a00a8952b53472df2a230ab0c10dc403..a51843caa203b888f7bf37a7ff10517f9a0cda99 100644 (file)
@@ -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