kmsgrab: Fix DRM format definitions
[ffmpeg.git] / libavdevice / kmsgrab.c
index d0b9cf50019fcdf9714d3aa8ee70c2511516b4c3..bcb6865f60a5cd9c2ff4c81d0c399d6d8d3173e9 100644 (file)
@@ -190,10 +190,10 @@ static int kmsgrab_read_packet(AVFormatContext *avctx, AVPacket *pkt)
     if (!pkt->buf)
         return AVERROR(ENOMEM);
 
-    pkt->data  = (uint8_t*)frame;
-    pkt->size  = sizeof(*frame);
-    pkt->pts   = now;
-    pkt->flags = AV_PKT_FLAG_TRUSTED;
+    pkt->data   = (uint8_t*)frame;
+    pkt->size   = sizeof(*frame);
+    pkt->pts    = now;
+    pkt->flags |= AV_PKT_FLAG_TRUSTED;
 
     return 0;
 }
@@ -202,18 +202,22 @@ static const struct {
     enum AVPixelFormat pixfmt;
     uint32_t drm_format;
 } kmsgrab_formats[] = {
+#ifdef DRM_FORMAT_R8
     { AV_PIX_FMT_GRAY8,    DRM_FORMAT_R8       },
+#endif
+#ifdef DRM_FORMAT_R16
     { AV_PIX_FMT_GRAY16LE, DRM_FORMAT_R16      },
+#endif
     { AV_PIX_FMT_RGB24,    DRM_FORMAT_RGB888   },
     { AV_PIX_FMT_BGR24,    DRM_FORMAT_BGR888   },
-    { AV_PIX_FMT_0RGB,     DRM_FORMAT_XRGB8888 },
-    { AV_PIX_FMT_0BGR,     DRM_FORMAT_XBGR8888 },
-    { AV_PIX_FMT_RGB0,     DRM_FORMAT_RGBX8888 },
-    { AV_PIX_FMT_BGR0,     DRM_FORMAT_BGRX8888 },
-    { AV_PIX_FMT_ARGB,     DRM_FORMAT_ARGB8888 },
-    { AV_PIX_FMT_ABGR,     DRM_FORMAT_ABGR8888 },
-    { AV_PIX_FMT_RGBA,     DRM_FORMAT_RGBA8888 },
-    { AV_PIX_FMT_BGRA,     DRM_FORMAT_BGRA8888 },
+    { AV_PIX_FMT_0RGB,     DRM_FORMAT_BGRX8888 },
+    { AV_PIX_FMT_0BGR,     DRM_FORMAT_RGBX8888 },
+    { AV_PIX_FMT_RGB0,     DRM_FORMAT_XBGR8888 },
+    { AV_PIX_FMT_BGR0,     DRM_FORMAT_XRGB8888 },
+    { AV_PIX_FMT_ARGB,     DRM_FORMAT_BGRA8888 },
+    { AV_PIX_FMT_ABGR,     DRM_FORMAT_RGBA8888 },
+    { AV_PIX_FMT_RGBA,     DRM_FORMAT_ABGR8888 },
+    { AV_PIX_FMT_BGRA,     DRM_FORMAT_ARGB8888 },
     { AV_PIX_FMT_YUYV422,  DRM_FORMAT_YUYV     },
     { AV_PIX_FMT_YVYU422,  DRM_FORMAT_YVYU     },
     { AV_PIX_FMT_UYVY422,  DRM_FORMAT_UYVY     },