From: Wonchul Lee Date: Sat, 9 Nov 2019 10:37:10 +0000 (+0900) Subject: wlvideoformat: clean up video formats X-Git-Tag: 1.19.3~507^2~2542 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e79e53c6e9cc4b121ab78b177c19c00382cfb0a;p=platform%2Fupstream%2Fgstreamer.git wlvideoformat: clean up video formats It cleans up videoFormat by combining the wl_shm_formats and drm_formats into a single table that represents the same format. In addition, it adds NV61 format to the waylandsink. --- diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index 9e0d4d4..f68e24f 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -71,7 +71,7 @@ GST_DEBUG_CATEGORY (gstwayland_debug); #define WL_VIDEO_FORMATS \ "{ BGRx, BGRA, RGBx, xBGR, xRGB, RGBA, ABGR, ARGB, RGB, BGR, " \ - "RGB16, BGR16, YUY2, YVYU, UYVY, AYUV, NV12, NV21, NV16, " \ + "RGB16, BGR16, YUY2, YVYU, UYVY, AYUV, NV12, NV21, NV16, NV61, " \ "YUV9, YVU9, Y41B, I420, YV12, Y42B, v308 }" static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", diff --git a/ext/wayland/wlvideoformat.c b/ext/wayland/wlvideoformat.c index 1aac624..bc8c553 100644 --- a/ext/wayland/wlvideoformat.c +++ b/ext/wayland/wlvideoformat.c @@ -32,72 +32,40 @@ GST_DEBUG_CATEGORY_EXTERN (gstwayland_debug); typedef struct { - enum wl_shm_format wl_format; + enum wl_shm_format wl_shm_format; + guint dma_format; GstVideoFormat gst_format; -} wl_ShmVideoFormat; - -typedef struct -{ - guint wl_format; - GstVideoFormat gst_format; -} wl_DmabufVideoFormat; - -static const wl_ShmVideoFormat shm_formats[] = { - {WL_SHM_FORMAT_XRGB8888, GST_VIDEO_FORMAT_BGRx}, - {WL_SHM_FORMAT_ARGB8888, GST_VIDEO_FORMAT_BGRA}, - {WL_SHM_FORMAT_XBGR8888, GST_VIDEO_FORMAT_RGBx}, - {WL_SHM_FORMAT_RGBX8888, GST_VIDEO_FORMAT_xBGR}, - {WL_SHM_FORMAT_BGRX8888, GST_VIDEO_FORMAT_xRGB}, - {WL_SHM_FORMAT_ABGR8888, GST_VIDEO_FORMAT_RGBA}, - {WL_SHM_FORMAT_RGBA8888, GST_VIDEO_FORMAT_ABGR}, - {WL_SHM_FORMAT_BGRA8888, GST_VIDEO_FORMAT_ARGB}, - {WL_SHM_FORMAT_RGB888, GST_VIDEO_FORMAT_RGB}, - {WL_SHM_FORMAT_BGR888, GST_VIDEO_FORMAT_BGR}, - {WL_SHM_FORMAT_RGB565, GST_VIDEO_FORMAT_RGB16}, - {WL_SHM_FORMAT_BGR565, GST_VIDEO_FORMAT_BGR16}, - - {WL_SHM_FORMAT_YUYV, GST_VIDEO_FORMAT_YUY2}, - {WL_SHM_FORMAT_YVYU, GST_VIDEO_FORMAT_YVYU}, - {WL_SHM_FORMAT_UYVY, GST_VIDEO_FORMAT_UYVY}, - {WL_SHM_FORMAT_AYUV, GST_VIDEO_FORMAT_AYUV}, - {WL_SHM_FORMAT_NV12, GST_VIDEO_FORMAT_NV12}, - {WL_SHM_FORMAT_NV21, GST_VIDEO_FORMAT_NV21}, - {WL_SHM_FORMAT_NV16, GST_VIDEO_FORMAT_NV16}, - {WL_SHM_FORMAT_YUV410, GST_VIDEO_FORMAT_YUV9}, - {WL_SHM_FORMAT_YVU410, GST_VIDEO_FORMAT_YVU9}, - {WL_SHM_FORMAT_YUV411, GST_VIDEO_FORMAT_Y41B}, - {WL_SHM_FORMAT_YUV420, GST_VIDEO_FORMAT_I420}, - {WL_SHM_FORMAT_YVU420, GST_VIDEO_FORMAT_YV12}, - {WL_SHM_FORMAT_YUV422, GST_VIDEO_FORMAT_Y42B}, - {WL_SHM_FORMAT_YUV444, GST_VIDEO_FORMAT_v308}, -}; - -static const wl_DmabufVideoFormat dmabuf_formats[] = { - {DRM_FORMAT_XRGB8888, GST_VIDEO_FORMAT_BGRx}, - {DRM_FORMAT_ARGB8888, GST_VIDEO_FORMAT_BGRA}, - {DRM_FORMAT_XBGR8888, GST_VIDEO_FORMAT_RGBx}, - {DRM_FORMAT_RGBX8888, GST_VIDEO_FORMAT_xBGR}, - {DRM_FORMAT_BGRX8888, GST_VIDEO_FORMAT_xRGB}, - {DRM_FORMAT_ABGR8888, GST_VIDEO_FORMAT_RGBA}, - {DRM_FORMAT_RGBA8888, GST_VIDEO_FORMAT_ABGR}, - {DRM_FORMAT_BGRA8888, GST_VIDEO_FORMAT_ARGB}, - {DRM_FORMAT_RGB888, GST_VIDEO_FORMAT_BGR}, - {DRM_FORMAT_BGR888, GST_VIDEO_FORMAT_RGB}, - {DRM_FORMAT_RGB565, GST_VIDEO_FORMAT_RGB16}, - - {DRM_FORMAT_YUYV, GST_VIDEO_FORMAT_YUY2}, - {DRM_FORMAT_YVYU, GST_VIDEO_FORMAT_YVYU}, - {DRM_FORMAT_UYVY, GST_VIDEO_FORMAT_UYVY}, - {DRM_FORMAT_AYUV, GST_VIDEO_FORMAT_AYUV}, - {DRM_FORMAT_NV21, GST_VIDEO_FORMAT_NV21}, - {DRM_FORMAT_NV16, GST_VIDEO_FORMAT_NV16}, - {DRM_FORMAT_YUV410, GST_VIDEO_FORMAT_YUV9}, - {DRM_FORMAT_YVU410, GST_VIDEO_FORMAT_YVU9}, - {DRM_FORMAT_YUV411, GST_VIDEO_FORMAT_Y41B}, - {DRM_FORMAT_YUV420, GST_VIDEO_FORMAT_I420}, - {DRM_FORMAT_YVU420, GST_VIDEO_FORMAT_YV12}, - {DRM_FORMAT_YUV422, GST_VIDEO_FORMAT_Y42B}, - {DRM_FORMAT_YUV444, GST_VIDEO_FORMAT_v308}, +} wl_VideoFormat; + +static const wl_VideoFormat wl_formats[] = { + {WL_SHM_FORMAT_XRGB8888, DRM_FORMAT_XRGB8888, GST_VIDEO_FORMAT_BGRx}, + {WL_SHM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888, GST_VIDEO_FORMAT_BGRA}, + {WL_SHM_FORMAT_XBGR8888, DRM_FORMAT_XBGR8888, GST_VIDEO_FORMAT_RGBx}, + {WL_SHM_FORMAT_RGBX8888, DRM_FORMAT_RGBX8888, GST_VIDEO_FORMAT_xBGR}, + {WL_SHM_FORMAT_BGRX8888, DRM_FORMAT_BGRX8888, GST_VIDEO_FORMAT_xRGB}, + {WL_SHM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, GST_VIDEO_FORMAT_RGBA}, + {WL_SHM_FORMAT_RGBA8888, DRM_FORMAT_RGBA8888, GST_VIDEO_FORMAT_ABGR}, + {WL_SHM_FORMAT_BGRA8888, DRM_FORMAT_BGRA8888, GST_VIDEO_FORMAT_ARGB}, + {WL_SHM_FORMAT_RGB888, DRM_FORMAT_RGB888, GST_VIDEO_FORMAT_RGB}, + {WL_SHM_FORMAT_BGR888, DRM_FORMAT_BGR888, GST_VIDEO_FORMAT_BGR}, + {WL_SHM_FORMAT_RGB565, DRM_FORMAT_RGB565, GST_VIDEO_FORMAT_RGB16}, + {WL_SHM_FORMAT_BGR565, DRM_FORMAT_BGR565, GST_VIDEO_FORMAT_BGR16}, + + {WL_SHM_FORMAT_YUYV, DRM_FORMAT_YUYV, GST_VIDEO_FORMAT_YUY2}, + {WL_SHM_FORMAT_YVYU, DRM_FORMAT_YVYU, GST_VIDEO_FORMAT_YVYU}, + {WL_SHM_FORMAT_UYVY, DRM_FORMAT_UYVY, GST_VIDEO_FORMAT_UYVY}, + {WL_SHM_FORMAT_AYUV, DRM_FORMAT_AYUV, GST_VIDEO_FORMAT_AYUV}, + {WL_SHM_FORMAT_NV12, DRM_FORMAT_NV12, GST_VIDEO_FORMAT_NV12}, + {WL_SHM_FORMAT_NV21, DRM_FORMAT_NV21, GST_VIDEO_FORMAT_NV21}, + {WL_SHM_FORMAT_NV16, DRM_FORMAT_NV16, GST_VIDEO_FORMAT_NV16}, + {WL_SHM_FORMAT_NV61, DRM_FORMAT_NV61, GST_VIDEO_FORMAT_NV61}, + {WL_SHM_FORMAT_YUV410, DRM_FORMAT_YUV410, GST_VIDEO_FORMAT_YUV9}, + {WL_SHM_FORMAT_YVU410, DRM_FORMAT_YVU410, GST_VIDEO_FORMAT_YVU9}, + {WL_SHM_FORMAT_YUV411, DRM_FORMAT_YUV411, GST_VIDEO_FORMAT_Y41B}, + {WL_SHM_FORMAT_YUV420, DRM_FORMAT_YUV420, GST_VIDEO_FORMAT_I420}, + {WL_SHM_FORMAT_YVU420, DRM_FORMAT_YVU420, GST_VIDEO_FORMAT_YV12}, + {WL_SHM_FORMAT_YUV422, DRM_FORMAT_YUV422, GST_VIDEO_FORMAT_Y42B}, + {WL_SHM_FORMAT_YUV444, DRM_FORMAT_YUV444, GST_VIDEO_FORMAT_v308}, }; enum wl_shm_format @@ -105,9 +73,9 @@ gst_video_format_to_wl_shm_format (GstVideoFormat format) { guint i; - for (i = 0; i < G_N_ELEMENTS (shm_formats); i++) - if (shm_formats[i].gst_format == format) - return shm_formats[i].wl_format; + for (i = 0; i < G_N_ELEMENTS (wl_formats); i++) + if (wl_formats[i].gst_format == format) + return wl_formats[i].wl_shm_format; GST_WARNING ("wayland shm video format not found"); return -1; @@ -118,9 +86,9 @@ gst_video_format_to_wl_dmabuf_format (GstVideoFormat format) { guint i; - for (i = 0; i < G_N_ELEMENTS (dmabuf_formats); i++) - if (dmabuf_formats[i].gst_format == format) - return dmabuf_formats[i].wl_format; + for (i = 0; i < G_N_ELEMENTS (wl_formats); i++) + if (wl_formats[i].gst_format == format) + return wl_formats[i].dma_format; GST_WARNING ("wayland dmabuf video format not found"); return -1; @@ -131,9 +99,9 @@ gst_wl_shm_format_to_video_format (enum wl_shm_format wl_format) { guint i; - for (i = 0; i < G_N_ELEMENTS (shm_formats); i++) - if (shm_formats[i].wl_format == wl_format) - return shm_formats[i].gst_format; + for (i = 0; i < G_N_ELEMENTS (wl_formats); i++) + if (wl_formats[i].wl_shm_format == wl_format) + return wl_formats[i].gst_format; return GST_VIDEO_FORMAT_UNKNOWN; } @@ -143,9 +111,9 @@ gst_wl_dmabuf_format_to_video_format (guint wl_format) { guint i; - for (i = 0; i < G_N_ELEMENTS (dmabuf_formats); i++) - if (dmabuf_formats[i].wl_format == wl_format) - return dmabuf_formats[i].gst_format; + for (i = 0; i < G_N_ELEMENTS (wl_formats); i++) + if (wl_formats[i].wl_shm_format == wl_format) + return wl_formats[i].gst_format; return GST_VIDEO_FORMAT_UNKNOWN; }