mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
Add VA/GLX display tests.
This commit is contained in:
parent
ec3a04d74d
commit
1b62b8a642
3 changed files with 94 additions and 83 deletions
|
@ -4,38 +4,50 @@ noinst_PROGRAMS = \
|
||||||
test-windows \
|
test-windows \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
if USE_GLX
|
||||||
noinst_PROGRAMS += \
|
noinst_PROGRAMS += \
|
||||||
test-textures \
|
test-textures \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
endif
|
||||||
|
|
||||||
TEST_CFLAGS = \
|
TEST_CFLAGS = -I$(top_srcdir)/gst-libs $(GST_CFLAGS)
|
||||||
$(GST_CFLAGS) \
|
TEST_X11_CFLAGS = -DUSE_X11 $(X11_CFLAGS)
|
||||||
-I$(top_srcdir)/gst-libs \
|
TEST_GLX_CFLAGS = -DUSE_GLX $(GLX_CFLAGS)
|
||||||
$(X11_CFLAGS)
|
TEST_MIX_CFLAGS = $(TEST_X11_CFLAGS)
|
||||||
|
if USE_GLX
|
||||||
|
TEST_MIX_CFLAGS += $(TEST_GLX_CFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
TEST_LIBS = \
|
TEST_LIBS = \
|
||||||
$(X11_LIBS)
|
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-@GST_MAJORMINOR@.la
|
||||||
|
|
||||||
TEST_GLX_LIBS = \
|
|
||||||
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-glx-@GST_MAJORMINOR@.la
|
|
||||||
|
|
||||||
TEST_X11_LIBS = \
|
TEST_X11_LIBS = \
|
||||||
|
$(X11_LIBS) \
|
||||||
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-x11-@GST_MAJORMINOR@.la
|
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-x11-@GST_MAJORMINOR@.la
|
||||||
|
|
||||||
|
TEST_GLX_LIBS = \
|
||||||
|
$(GLX_LIBS) \
|
||||||
|
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-glx-@GST_MAJORMINOR@.la
|
||||||
|
|
||||||
|
TEST_MIX_LIBS = $(TEST_X11_LIBS)
|
||||||
|
if USE_GLX
|
||||||
|
TEST_MIX_LIBS += $(TEST_GLX_LIBS)
|
||||||
|
endif
|
||||||
|
|
||||||
test_display_SOURCES = test-display.c
|
test_display_SOURCES = test-display.c
|
||||||
test_display_CFLAGS = $(TEST_CFLAGS)
|
test_display_CFLAGS = $(TEST_CFLAGS) $(TEST_MIX_CFLAGS)
|
||||||
test_display_LDADD = $(TEST_LIBS) $(TEST_X11_LIBS)
|
test_display_LDADD = $(TEST_LIBS) $(TEST_MIX_LIBS)
|
||||||
|
|
||||||
test_surfaces_SOURCES = test-surfaces.c
|
test_surfaces_SOURCES = test-surfaces.c
|
||||||
test_surfaces_CFLAGS = $(TEST_CFLAGS)
|
test_surfaces_CFLAGS = $(TEST_CFLAGS) $(TEST_X11_CFLAGS)
|
||||||
test_surfaces_LDADD = $(TEST_LIBS) $(TEST_X11_LIBS)
|
test_surfaces_LDADD = $(TEST_LIBS) $(TEST_X11_LIBS)
|
||||||
|
|
||||||
test_windows_SOURCES = test-windows.c
|
test_windows_SOURCES = test-windows.c
|
||||||
test_windows_CFLAGS = $(TEST_CFLAGS)
|
test_windows_CFLAGS = $(TEST_CFLAGS) $(TEST_X11_CFLAGS)
|
||||||
test_windows_LDADD = $(TEST_LIBS) $(TEST_X11_LIBS)
|
test_windows_LDADD = $(TEST_LIBS) $(TEST_X11_LIBS)
|
||||||
|
|
||||||
test_textures_SOURCES = test-textures.c
|
test_textures_SOURCES = test-textures.c
|
||||||
test_textures_CFLAGS = $(TEST_CFLAGS)
|
test_textures_CFLAGS = $(TEST_CFLAGS) $(TEST_GLX_CFLAGS)
|
||||||
test_textures_LDADD = $(TEST_LIBS) $(TEST_GLX_LIBS)
|
test_textures_LDADD = $(TEST_LIBS) $(TEST_GLX_LIBS)
|
||||||
|
|
||||||
# Extra clean files so that maintainer-clean removes *everything*
|
# Extra clean files so that maintainer-clean removes *everything*
|
||||||
|
|
|
@ -19,7 +19,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gst/video/video.h>
|
#include <gst/video/video.h>
|
||||||
|
#ifdef USE_X11
|
||||||
#include <gst/vaapi/gstvaapidisplay_x11.h>
|
#include <gst/vaapi/gstvaapidisplay_x11.h>
|
||||||
|
#endif
|
||||||
|
#ifdef USE_GLX
|
||||||
|
#include <gst/vaapi/gstvaapidisplay_glx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_caps(GstCaps *caps, const gchar *name)
|
print_caps(GstCaps *caps, const gchar *name)
|
||||||
|
@ -98,6 +103,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
gst_init(&argc, &argv);
|
gst_init(&argc, &argv);
|
||||||
|
|
||||||
|
#ifdef USE_X11
|
||||||
g_print("#\n");
|
g_print("#\n");
|
||||||
g_print("# Create display with gst_vaapi_display_x11_new()\n");
|
g_print("# Create display with gst_vaapi_display_x11_new()\n");
|
||||||
g_print("#\n");
|
g_print("#\n");
|
||||||
|
@ -136,7 +142,7 @@ main(int argc, char *argv[])
|
||||||
g_print("\n");
|
g_print("\n");
|
||||||
|
|
||||||
g_print("#\n");
|
g_print("#\n");
|
||||||
g_print("# Create display with gst_vaapi_display_new_with_display()\n");
|
g_print("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplay()]\n");
|
||||||
g_print("#\n");
|
g_print("#\n");
|
||||||
{
|
{
|
||||||
x11_display = XOpenDisplay(NULL);
|
x11_display = XOpenDisplay(NULL);
|
||||||
|
@ -156,6 +162,68 @@ main(int argc, char *argv[])
|
||||||
XCloseDisplay(x11_display);
|
XCloseDisplay(x11_display);
|
||||||
}
|
}
|
||||||
g_print("\n");
|
g_print("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_GLX
|
||||||
|
g_print("#\n");
|
||||||
|
g_print("# Create display with gst_vaapi_display_glx_new()\n");
|
||||||
|
g_print("#\n");
|
||||||
|
{
|
||||||
|
display = gst_vaapi_display_glx_new(NULL);
|
||||||
|
if (!display)
|
||||||
|
g_error("could not create Gst/VA display");
|
||||||
|
|
||||||
|
gst_vaapi_display_get_size(display, &width, &height);
|
||||||
|
g_print("Display size: %ux%u\n", width, height);
|
||||||
|
|
||||||
|
gst_vaapi_display_get_pixel_aspect_ratio(display, &par_n, &par_d);
|
||||||
|
g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d);
|
||||||
|
|
||||||
|
dump_caps(display);
|
||||||
|
g_object_unref(display);
|
||||||
|
}
|
||||||
|
g_print("\n");
|
||||||
|
|
||||||
|
g_print("#\n");
|
||||||
|
g_print("# Create display with gst_vaapi_display_glx_new_with_display()\n");
|
||||||
|
g_print("#\n");
|
||||||
|
{
|
||||||
|
x11_display = XOpenDisplay(NULL);
|
||||||
|
if (!x11_display)
|
||||||
|
g_error("could not create X11 display");
|
||||||
|
|
||||||
|
display = gst_vaapi_display_glx_new_with_display(x11_display);
|
||||||
|
if (!display)
|
||||||
|
g_error("could not create Gst/VA display");
|
||||||
|
|
||||||
|
dump_caps(display);
|
||||||
|
g_object_unref(display);
|
||||||
|
XCloseDisplay(x11_display);
|
||||||
|
}
|
||||||
|
g_print("\n");
|
||||||
|
|
||||||
|
g_print("#\n");
|
||||||
|
g_print("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplayGLX()]\n");
|
||||||
|
g_print("#\n");
|
||||||
|
{
|
||||||
|
x11_display = XOpenDisplay(NULL);
|
||||||
|
if (!x11_display)
|
||||||
|
g_error("could not create X11 display");
|
||||||
|
|
||||||
|
va_display = vaGetDisplayGLX(x11_display);
|
||||||
|
if (!va_display)
|
||||||
|
g_error("could not create VA display");
|
||||||
|
|
||||||
|
display = gst_vaapi_display_new_with_display(va_display);
|
||||||
|
if (!display)
|
||||||
|
g_error("could not create Gst/VA display");
|
||||||
|
|
||||||
|
dump_caps(display);
|
||||||
|
g_object_unref(display);
|
||||||
|
XCloseDisplay(x11_display);
|
||||||
|
}
|
||||||
|
g_print("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
gst_deinit();
|
gst_deinit();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -27,73 +27,6 @@ static inline void pause(void)
|
||||||
getchar();
|
getchar();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
print_caps(GstCaps *caps, const gchar *name)
|
|
||||||
{
|
|
||||||
guint i, n_caps = gst_caps_get_size(caps);
|
|
||||||
|
|
||||||
g_print("%u %s caps\n", n_caps, name);
|
|
||||||
|
|
||||||
for (i = 0; i < gst_caps_get_size(caps); i++) {
|
|
||||||
GstStructure * const structure = gst_caps_get_structure(caps, i);
|
|
||||||
if (!structure)
|
|
||||||
g_error("could not get caps structure %d", i);
|
|
||||||
|
|
||||||
g_print(" %s:", gst_structure_get_name(structure));
|
|
||||||
|
|
||||||
if (gst_structure_has_name(structure, "video/x-raw-yuv")) {
|
|
||||||
guint32 fourcc;
|
|
||||||
|
|
||||||
gst_structure_get_fourcc(structure, "format", &fourcc);
|
|
||||||
|
|
||||||
g_print(" fourcc '%c%c%c%c'",
|
|
||||||
fourcc & 0xff,
|
|
||||||
(fourcc >> 8) & 0xff,
|
|
||||||
(fourcc >> 16) & 0xff,
|
|
||||||
(fourcc >> 24) & 0xff);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gint bpp, endian, rmask, gmask, bmask, amask;
|
|
||||||
gboolean has_alpha;
|
|
||||||
|
|
||||||
gst_structure_get_int(structure, "bpp", &bpp);
|
|
||||||
gst_structure_get_int(structure, "endianness", &endian);
|
|
||||||
gst_structure_get_int(structure, "red_mask", &rmask);
|
|
||||||
gst_structure_get_int(structure, "blue_mask", &bmask);
|
|
||||||
gst_structure_get_int(structure, "green_mask", &gmask);
|
|
||||||
has_alpha = gst_structure_get_int(structure, "alpha_mask", &amask);
|
|
||||||
|
|
||||||
g_print(" %d bits per pixel, %s endian,",
|
|
||||||
bpp, endian == G_BIG_ENDIAN ? "big" : "little");
|
|
||||||
g_print(" %s masks", has_alpha ? "rgba" : "rgb");
|
|
||||||
g_print(" 0x%08x 0x%08x 0x%08x", rmask, gmask, bmask);
|
|
||||||
if (has_alpha)
|
|
||||||
g_print(" 0x%08x", amask);
|
|
||||||
}
|
|
||||||
g_print("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
dump_caps(GstVaapiDisplay *display)
|
|
||||||
{
|
|
||||||
GstCaps *caps;
|
|
||||||
|
|
||||||
caps = gst_vaapi_display_get_image_caps(display);
|
|
||||||
if (!caps)
|
|
||||||
g_error("could not get VA image caps");
|
|
||||||
|
|
||||||
print_caps(caps, "image");
|
|
||||||
gst_caps_unref(caps);
|
|
||||||
|
|
||||||
caps = gst_vaapi_display_get_subpicture_caps(display);
|
|
||||||
if (!caps)
|
|
||||||
g_error("could not get VA subpicture caps");
|
|
||||||
|
|
||||||
print_caps(caps, "subpicture");
|
|
||||||
gst_caps_unref(caps);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -116,8 +49,6 @@ main(int argc, char *argv[])
|
||||||
if (!display)
|
if (!display)
|
||||||
g_error("could not create Gst/VA display");
|
g_error("could not create Gst/VA display");
|
||||||
|
|
||||||
dump_caps(display);
|
|
||||||
|
|
||||||
window = gst_vaapi_window_glx_new(display, win_width, win_height);
|
window = gst_vaapi_window_glx_new(display, win_width, win_height);
|
||||||
if (!window)
|
if (!window)
|
||||||
g_error("could not create window");
|
g_error("could not create window");
|
||||||
|
|
Loading…
Reference in a new issue