summaryrefslogtreecommitdiff
path: root/kmscube.c
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2017-03-15 09:54:04 -0400
committerRob Clark <robdclark@gmail.com>2017-03-27 11:19:16 -0400
commit961c85f6eb42e4445513044c9944c83a0d9cb324 (patch)
tree910f4ac4d44599c6e335e7e6625ddff8ca305a34 /kmscube.c
parent4f4801b2b1f1aa00914f0c79fd3ab5ae8db2d284 (diff)
downloadkmscube-961c85f6eb42e4445513044c9944c83a0d9cb324.tar.gz
add video cube
Uses gstreamer for a simple decoder. If decoder can give us dma-buf's directly, we'll directly use that as a texture (zero copy), otherwise memcpy into a buffer from gbm. This should work with both hw and sw decoders. Probably room for improvement. And the interface between gl and the decoder is pretty simple so I suppose other decoders would be possible. (But hopefully they could already be supported via gstreamer.) Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'kmscube.c')
-rw-r--r--kmscube.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/kmscube.c b/kmscube.c
index fcfd902..3140574 100644
--- a/kmscube.c
+++ b/kmscube.c
@@ -31,6 +31,9 @@
#include "common.h"
#include "drm-common.h"
+#ifdef HAVE_GST
+# include <gst/gst.h>
+#endif
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -38,12 +41,13 @@ static const struct egl *egl;
static const struct gbm *gbm;
static const struct drm *drm;
-static const char *shortopts = "AD:M:";
+static const char *shortopts = "AD:M:V:";
static const struct option longopts[] = {
{"atomic", no_argument, 0, 'M'},
{"device", required_argument, 0, 'D'},
{"mode", required_argument, 0, 'M'},
+ {"video", required_argument, 0, 'V'},
{0, 0, 0, 0}
};
@@ -58,17 +62,23 @@ static void usage(const char *name)
" smooth - smooth shaded cube (default)\n"
" rgba - rgba textured cube\n"
" nv12-2img - yuv textured (color conversion in shader)\n"
- " nv12-1img - yuv textured (single nv12 texture)\n",
+ " nv12-1img - yuv textured (single nv12 texture)\n"
+ " -V, --video=FILE video textured cube\n",
name);
}
int main(int argc, char *argv[])
{
const char *device = "/dev/dri/card0";
+ const char *video = NULL;
enum mode mode = SMOOTH;
int atomic = 0;
int opt;
+#ifdef HAVE_GST
+ gst_init(&argc, &argv);
+#endif
+
while ((opt = getopt_long_only(argc, argv, shortopts, longopts, NULL)) != -1) {
switch (opt) {
case 'A':
@@ -92,6 +102,10 @@ int main(int argc, char *argv[])
return -1;
}
break;
+ case 'V':
+ mode = VIDEO;
+ video = optarg;
+ break;
default:
usage(argv[0]);
return -1;
@@ -115,6 +129,8 @@ int main(int argc, char *argv[])
if (mode == SMOOTH)
egl = init_cube_smooth(gbm);
+ else if (mode == VIDEO)
+ egl = init_cube_video(gbm, video);
else
egl = init_cube_tex(gbm, mode);