Somebody alive?

-------- Original Message --------
Subject: Simple test program produces assert with branch vaapi-ext
Date: Sat, 04 Feb 2012 20:42:57 +0100
From: Lutz Sammer <[email protected]>
To: [email protected]

Hello,

I'm trying to write a test program to report a bug.
But it self produces this:

libva: VA-API version 0.32.0
libva: va_getDriverName() returns 0
libva: Trying to open /usr/lib64/va/drivers/i965_drv_video.so
libva: va_openDriver() returns 0
video/vaapi: libva 0.32 (Intel i965 driver - 1.0.16.pre1) initialized
a.out: i965_render.c:2122: gen6_render_put_subpicture: Assertion
`obj_subpic' failed.
Aborted

libva: git from today branch vaapi-ext
libva-intel-driver: git from today vaapi-ext
x11-drivers/xf86-video-intel: 2.17.0-r3
x11-base/xorg-server: 1.11.4

I appended the test application.
To compile gcc -g vaapi.c -lva -lva-x11 -lX11
To run ./a.out or DISPLAY=:0.0 ./a.out

cu,
Johns

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>			// clock_gettime

#include <va/va_x11.h>

static Display *XlibDisplay;		///< Xlib X11 display
static VADisplay *VaDisplay;		///< VA-API display

/**
**	Get ticks in ms.
**
**	@returns ticks in ms,
*/
static inline uint32_t GetMsTicks(void)
{
#ifdef CLOCK_MONOTONIC
    struct timespec tspec;

    clock_gettime(CLOCK_MONOTONIC, &tspec);
    return (tspec.tv_sec * 1000) + (tspec.tv_nsec / (1000 * 1000));
#else
    struct timeval tval;

    if (gettimeofday(&tval, NULL) < 0) {
	return 0;
    }
    return (tval.tv_sec * 1000) + (tval.tv_usec / 1000);
#endif
}

///
///	Find VA-API profile.
///
///	Check if the requested profile is supported by VA-API.
///
///	@param profiles a table of all supported profiles
///	@param n	number of supported profiles
///	@param profile	requested profile
///
///	@returns the profile if supported, -1 if unsupported.
///
static VAProfile VaapiFindProfile(const VAProfile * profiles, unsigned n,
    VAProfile profile)
{
    unsigned u;

    for (u = 0; u < n; ++u) {
	if (profiles[u] == profile) {
	    return profile;
	}
    }
    return -1;
}

///
///	Find VA-API entry point.
///
///	Check if the requested entry point is supported by VA-API.
///
///	@param entrypoints	a table of all supported entrypoints
///	@param n		number of supported entrypoints
///	@param entrypoint	requested entrypoint
///
///	@returns the entry point if supported, -1 if unsupported.
///
static VAEntrypoint VaapiFindEntrypoint(const VAEntrypoint * entrypoints,
    unsigned n, VAEntrypoint entrypoint)
{
    unsigned u;

    for (u = 0; u < n; ++u) {
	if (entrypoints[u] == entrypoint) {
	    return entrypoint;
	}
    }
    return -1;
}

///
///	1080i
///
static void Vaapi1080i(void)
{
    VAProfile profiles[vaMaxNumProfiles(VaDisplay)];
    int profile_n;
    VAEntrypoint entrypoints[vaMaxNumEntrypoints(VaDisplay)];
    int entrypoint_n;
    int p;
    int e;
    VAConfigAttrib attrib;
    VAConfigID config_id;
    VAContextID context_id;
    VASurfaceID surfaces[32];
    VAImage image[1];
    int n;
    uint32_t start_tick;
    uint32_t tick;

    p = -1;
    e = -1;

    //	prepare va-api profiles
    if (vaQueryConfigProfiles(VaDisplay, profiles, &profile_n)) {
	printf("codec: vaQueryConfigProfiles failed");
	return;
    }
    // check profile
    p = VaapiFindProfile(profiles, profile_n, VAProfileH264High);
    if (p == -1) {
	printf("\tno profile found\n");
	return;
    }
    // prepare va-api entry points
    if (vaQueryConfigEntrypoints(VaDisplay, p, entrypoints, &entrypoint_n)) {
	printf("codec: vaQueryConfigEntrypoints failed");
	return;
    }
    e = VaapiFindEntrypoint(entrypoints, entrypoint_n, VAEntrypointVLD);
    if (e == -1) {
	printf("codec: unsupported: slow path\n");
	return;
    }
    memset(&attrib, 0, sizeof(attrib));
    attrib.type = VAConfigAttribRTFormat;
    attrib.value = VA_RT_FORMAT_YUV420;
    // create a configuration for the decode pipeline
    if (vaCreateConfig(VaDisplay, p, e, &attrib, 1, &config_id)) {
	printf("codec: can't create config");
	return;
    }
    if (vaCreateSurfaces(VaDisplay, 1920, 1080, VA_RT_FORMAT_YUV420, 32,
	    surfaces) != VA_STATUS_SUCCESS) {
	printf("video/vaapi: can't create surfaces\n");
	return;
    }
    // bind surfaces to context
    if (vaCreateContext(VaDisplay, config_id, 1920, 1080, VA_PROGRESSIVE,
	    surfaces, 32, &context_id)) {
	printf("codec: can't create context");
	return;
    }

    // without this vaPutSurface will display nothing
    image->image_id = VA_INVALID_ID;
    if( vaDeriveImage(VaDisplay, surfaces[0], image)
    	!= VA_STATUS_SUCCESS) {
	printf("video/vaapi: vaDeriveImage failed\n");
    }
    if ( image->image_id != VA_INVALID_ID ) {
	if (vaDestroyImage(VaDisplay, image->image_id) != VA_STATUS_SUCCESS) {
	    printf("video/vaapi: can't destroy image!\n");
	}
    }

    start_tick = GetMsTicks();
    for (n = 1; n < 2; ++n) {
	if (vaPutSurface(VaDisplay, surfaces[0], DefaultRootWindow(XlibDisplay),
		// decoder src
		0, 0, 1920, 1080,
		// video dst
		0, 0, 1920, 1080, NULL, 0, VA_TOP_FIELD | VA_CLEAR_DRAWABLE)
	    != VA_STATUS_SUCCESS) {
	    printf("video/vaapi: vaPutSurface failed\n");
	}
	if (vaPutSurface(VaDisplay, surfaces[0], DefaultRootWindow(XlibDisplay),
		// decoder src
		0, 0, 1920, 1080,
		// video dst
		0, 0, 1920, 1080, NULL, 0, VA_BOTTOM_FIELD | VA_CLEAR_DRAWABLE)
	    != VA_STATUS_SUCCESS) {
	    printf("video/vaapi: vaPutSurface failed\n");
	}
	tick = GetMsTicks();
	if (!(n % 10)) {
	    fprintf(stderr, "%d ms / frame\n", (tick - start_tick) / n);
	}
    }
    tick = GetMsTicks();
    fprintf(stderr, "%d ms / frame\n", (tick - start_tick) / n);

    // destory the stuff.
    if (vaDestroyContext(VaDisplay, context_id) != VA_STATUS_SUCCESS) {
	printf("video/vaapi: can't destroy context!\n");
    }
    if (vaDestroySurfaces(VaDisplay, surfaces, 32) != VA_STATUS_SUCCESS) {
	printf("video/vaapi: can't destroy surfaces\n");
    }
    if (vaDestroyConfig(VaDisplay, config_id) != VA_STATUS_SUCCESS) {
	printf("video/vaapi: can't destroy config!\n");
    }
    fprintf(stderr, "done\n");
}

void VaapiKiller(void)
{
    int major;
    int minor;
    const char *s;

    if (!(XlibDisplay = XOpenDisplay(NULL))) {
	printf("video: Can't connect to X11 server\n");
	exit(-1);
    }
    VaDisplay = vaGetDisplay(XlibDisplay);
    if (!VaDisplay) {
	printf("video/vaapi: Can't connect VA-API to X11 server\n");
	exit(-1);
    }

    if (vaInitialize(VaDisplay, &major, &minor) != VA_STATUS_SUCCESS) {
	printf("video/vaapi: Can't inititialize VA-API");
	vaTerminate(VaDisplay);
	VaDisplay = NULL;
	return;
    }
    s = vaQueryVendorString(VaDisplay);
    printf("video/vaapi: libva %d.%d (%s) initialized\n", major, minor, s);

    Vaapi1080i();
}

int main(int argc, char *const argv[])
{
    VaapiKiller();
}

_______________________________________________
Libva mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libva

Reply via email to