| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifdef HAVE_CONFIG_H |
| 25 |
#include <config.h> |
| 26 |
#endif |
| 27 |
|
| 28 |
#include "gstwlvideoformat.h" |
| 29 |
|
| 30 |
#include <drm_fourcc.h> |
| 31 |
|
| 32 |
#define GST_CAT_DEFAULT gst_wl_videoformat_debug |
| 33 |
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); |
| 34 |
|
| 35 |
void |
| 36 |
gst_wl_videoformat_init_once (void) |
| 37 |
{ |
| 38 |
static gsize _init = 0; |
| 39 |
|
| 40 |
if (g_once_init_enter (&_init)) { |
| 41 |
GST_DEBUG_CATEGORY_INIT (gst_wl_videoformat_debug, "wl_videoformat", 0, |
| 42 |
"wl_videoformat library"); |
| 43 |
|
| 44 |
g_once_init_leave (&_init, 1); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
enum wl_shm_format |
| 49 |
gst_video_format_to_wl_shm_format (GstVideoFormat format) |
| 50 |
{ |
| 51 |
guint32 drm_format; |
| 52 |
guint64 modifier; |
| 53 |
|
| 54 |
drm_format = gst_video_dma_drm_format_from_gst_format (format, &modifier); |
| 55 |
|
| 56 |
if (drm_format == DRM_FORMAT_INVALID || modifier != DRM_FORMAT_MOD_LINEAR) { |
| 57 |
GST_WARNING ("wayland shm video format not found"); |
| 58 |
return -1; |
| 59 |
} |
| 60 |
|
| 61 |
if (drm_format == DRM_FORMAT_XRGB8888) |
| 62 |
drm_format = WL_SHM_FORMAT_XRGB8888; |
| 63 |
else if (drm_format == DRM_FORMAT_ARGB8888) |
| 64 |
drm_format = WL_SHM_FORMAT_ARGB8888; |
| 65 |
|
| 66 |
return drm_format; |
| 67 |
} |
| 68 |
|
| 69 |
guint32 |
| 70 |
gst_video_format_to_wl_dmabuf_format (GstVideoFormat format) |
| 71 |
{ |
| 72 |
guint32 drm_format; |
| 73 |
guint64 modifier; |
| 74 |
|
| 75 |
drm_format = gst_video_dma_drm_format_from_gst_format (format, &modifier); |
| 76 |
|
| 77 |
if (drm_format == DRM_FORMAT_INVALID || modifier != DRM_FORMAT_MOD_LINEAR) { |
| 78 |
GST_WARNING ("wayland dmabuf video format not found"); |
| 79 |
return DRM_FORMAT_INVALID; |
| 80 |
} |
| 81 |
|
| 82 |
return drm_format; |
| 83 |
} |
| 84 |
|
| 85 |
GstVideoFormat |
| 86 |
gst_wl_shm_format_to_video_format (enum wl_shm_format wl_format) |
| 87 |
{ |
| 88 |
if (wl_format == WL_SHM_FORMAT_XRGB8888) |
| 89 |
wl_format = DRM_FORMAT_XRGB8888; |
| 90 |
else if (wl_format == WL_SHM_FORMAT_ARGB8888) |
| 91 |
wl_format = DRM_FORMAT_ARGB8888; |
| 92 |
|
| 93 |
return gst_wl_dmabuf_format_to_video_format (wl_format); |
| 94 |
} |
| 95 |
|
| 96 |
GstVideoFormat |
| 97 |
gst_wl_dmabuf_format_to_video_format (guint wl_format) |
| 98 |
{ |
| 99 |
return gst_video_dma_drm_format_to_gst_format (wl_format, |
| 100 |
DRM_FORMAT_MOD_LINEAR); |
| 101 |
} |
| 102 |
|
| 103 |
const gchar * |
| 104 |
gst_wl_shm_format_to_string (enum wl_shm_format wl_format) |
| 105 |
{ |
| 106 |
return gst_video_format_to_string |
| 107 |
(gst_wl_shm_format_to_video_format (wl_format)); |
| 108 |
} |