Commit b15ab87c authored by Austin Yuan's avatar Austin Yuan

Merge branch 'sync-fdo-master'

parents 59575183 d76376f1
...@@ -126,6 +126,10 @@ AC_OUTPUT([ ...@@ -126,6 +126,10 @@ AC_OUTPUT([
i965_drv_video/shaders/mpeg2/vld/Makefile i965_drv_video/shaders/mpeg2/vld/Makefile
i965_drv_video/shaders/render/Makefile i965_drv_video/shaders/render/Makefile
test/Makefile test/Makefile
test/basic/Makefile
test/decode/Makefile
test/putsurface/Makefile
test/encode/Makefile
libva.pc libva.pc
libva-x11.pc libva-x11.pc
]) ])
......
...@@ -58,7 +58,7 @@ static int va_debug_trace = 0; ...@@ -58,7 +58,7 @@ static int va_debug_trace = 0;
static int vaDisplayIsValid(VADisplay dpy) static int vaDisplayIsValid(VADisplay dpy)
{ {
VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
return pDisplayContext && (pDisplayContext->vadpy_magic == 0x789abcde) && pDisplayContext->vaIsValid(pDisplayContext); return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);
} }
static void va_errorMessage(const char *msg, ...) static void va_errorMessage(const char *msg, ...)
......
...@@ -396,6 +396,7 @@ struct VADriverContext ...@@ -396,6 +396,7 @@ struct VADriverContext
void *dri_state; void *dri_state;
}; };
#define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
struct VADisplayContext struct VADisplayContext
{ {
int vadpy_magic; int vadpy_magic;
......
...@@ -189,7 +189,7 @@ VADisplay vaGetDisplay ( ...@@ -189,7 +189,7 @@ VADisplay vaGetDisplay (
dri_state = calloc(1, sizeof(*dri_state)); dri_state = calloc(1, sizeof(*dri_state));
if (pDisplayContext && pDriverContext && dri_state) if (pDisplayContext && pDriverContext && dri_state)
{ {
pDisplayContext->vadpy_magic = 0x789abcde; pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
pDriverContext->x11_dpy = native_dpy; pDriverContext->x11_dpy = native_dpy;
pDisplayContext->pNext = pDisplayContexts; pDisplayContext->pNext = pDisplayContexts;
......
...@@ -20,62 +20,17 @@ ...@@ -20,62 +20,17 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
check_PROGRAMS = test_01 test_02 test_03 test_04 test_05 test_06 \
test_07 test_08 test_09 test_10 test_11 test_12
bin_PROGRAMS = vainfo bin_PROGRAMS = vainfo
testdir = $(bindir) AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11 -DIN_LIBVA
AM_CFLAGS = -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA
TESTS = $(check_PROGRAMS)
TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib)
vainfo_LDADD = $(top_srcdir)/src/$(libvabackendlib) vainfo_LDADD = $(top_srcdir)/src/$(libvabackendlib)
vainfo_DEPENDENCIES = $(top_srcdir)/src/$(libvabackendlib) vainfo_DEPENDENCIES = $(top_srcdir)/src/$(libvabackendlib)
vainfo_SOURCES = vainfo.c vainfo_SOURCES = vainfo.c
test_01_LDADD = $(TEST_LIBS) SUBDIRS = basic decode encode putsurface
test_01_SOURCES = test_01.c
test_02_LDADD = $(TEST_LIBS)
test_02_SOURCES = test_02.c
test_03_LDADD = $(TEST_LIBS)
test_03_SOURCES = test_03.c
test_04_LDADD = $(TEST_LIBS)
test_04_SOURCES = test_04.c
test_05_LDADD = $(TEST_LIBS)
test_05_SOURCES = test_05.c
test_06_LDADD = $(TEST_LIBS)
test_06_SOURCES = test_06.c
test_07_LDADD = $(TEST_LIBS)
test_07_SOURCES = test_07.c
test_08_LDADD = $(TEST_LIBS)
test_08_SOURCES = test_08.c
test_09_LDADD = $(TEST_LIBS)
test_09_SOURCES = test_09.c
test_10_LDADD = $(TEST_LIBS)
test_10_SOURCES = test_10.c
test_11_LDADD = $(TEST_LIBS)
test_11_SOURCES = test_11.c
test_12_LDADD = $(TEST_LIBS)
test_12_SOURCES = test_12.c
EXTRA_DIST = test_common.c mpeg2-I.jpg mpeg2-I.mpg
valgrind: $(check_PROGRAMS) valgrind: vainfo
for a in $(check_PROGRAMS); do \ valgrind --leak-check=full --show-reachable=yes .libs/vainfo;
valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
done
# Copyright (c) 2007 Intel Corporation. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sub license, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice (including the
# next paragraph) shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bin_PROGRAMS = test_01 test_02 test_03 test_04 test_05 test_06 \
test_07 test_08 test_09 test_10 test_11
TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib)
test_01_LDADD = $(TEST_LIBS)
test_01_SOURCES = test_01.c
test_02_LDADD = $(TEST_LIBS)
test_02_SOURCES = test_02.c
test_03_LDADD = $(TEST_LIBS)
test_03_SOURCES = test_03.c
test_04_LDADD = $(TEST_LIBS)
test_04_SOURCES = test_04.c
test_05_LDADD = $(TEST_LIBS)
test_05_SOURCES = test_05.c
test_06_LDADD = $(TEST_LIBS)
test_06_SOURCES = test_06.c
test_07_LDADD = $(TEST_LIBS)
test_07_SOURCES = test_07.c
test_08_LDADD = $(TEST_LIBS)
test_08_SOURCES = test_08.c
test_09_LDADD = $(TEST_LIBS)
test_09_SOURCES = test_09.c
test_10_LDADD = $(TEST_LIBS)
test_10_SOURCES = test_10.c
test_11_LDADD = $(TEST_LIBS)
test_11_SOURCES = test_11.c
EXTRA_DIST = test_common.c
valgrind: $(bin_PROGRAMS)
for a in $(bin_PROGRAMS); do \
valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
done
# Copyright (c) 2007 Intel Corporation. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sub license, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice (including the
# next paragraph) shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bin_PROGRAMS = mpeg2vldemo
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA
TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib)
mpeg2vldemo_LDADD = $(TEST_LIBS)
mpeg2vldemo_SOURCES = mpeg2vldemo.c
valgrind: $(bin_PROGRAMS)
for a in $(bin_PROGRAMS); do \
valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
done
/* /*
* Copyright (c) 2007 Intel Corporation. All Rights Reserved. * Copyright (c) 2007-2008 Intel Corporation. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -22,23 +22,38 @@ ...@@ -22,23 +22,38 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#define TEST_DESCRIPTION "Sample MPEG2 VLD Decoding" /*
* it is a real program to show how VAAPI decode work,
#ifdef IN_LIBVA * It does VLD decode for a simple MPEG2 clip "mpeg2-I.m2v"
#include <va_x11.h> * "mpeg2-I.m2v" and VA parameters are hardcoded into mpeg2vldemo.c,
#else * See mpeg2-I.jif to know how those VA parameters come from
#include <va/va_x11.h> *
#endif * gcc -o mpeg2vldemo mpeg2vldemo.c -lva -lva-x11
* ./mpeg2vldemo : only do decode
* ./mpeg2vldemo <any parameter >: decode+display
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include <X11/Xlib.h>
#include "test_common.c" #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
void pre() #include <assert.h>
{
test_init(); #include <va/va.h>
#include <va/va_x11.h>
#define CHECK_VASTATUS(va_status,func) \
if (va_status != VA_STATUS_SUCCESS) { \
fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \
exit(1); \
} }
/* Data dump of a 16x16 MPEG2 video clip,it has one I frame /* Data dump of a 16x16 MPEG2 video clip,it has one I frame
...@@ -120,23 +135,43 @@ static VASliceParameterBufferMPEG2 slice_param={ ...@@ -120,23 +135,43 @@ static VASliceParameterBufferMPEG2 slice_param={
#define CLIP_WIDTH 16 #define CLIP_WIDTH 16
#define CLIP_HEIGHT 16 #define CLIP_HEIGHT 16
int surf_width=CLIP_WIDTH,surf_height=CLIP_HEIGHT; #define WIN_WIDTH (CLIP_WIDTH<<1)
int win_width=CLIP_WIDTH<<1,win_height=CLIP_HEIGHT<<1; #define WIN_HEIGHT (CLIP_HEIGHT<<1)
void test() int main(int argc,char **argv)
{ {
VAEntrypoint entrypoints[5]; VAEntrypoint entrypoints[5];
int num_entrypoints,vld_entrypoint; int num_entrypoints,vld_entrypoint;
VAConfigAttrib attrib; VAConfigAttrib attrib;
VAConfigID config_id; VAConfigID config_id;
VASurfaceID vaSurface; VASurfaceID surface_id;
VAContextID vaContext; VAContextID context_id;
VABufferID vaPicParamBuf,vaIQMatrixBuf,vaSliceParamBuf,vaSliceDataBuf; VABufferID pic_param_buf,iqmatrix_buf,slice_param_buf,slice_data_buf;
Window win = 0; int major_ver, minor_ver;
Display *x11_display;
VADisplay va_dpy;
VAStatus va_status;
int putsurface=0;
if (argc > 1)
putsurface=1;
x11_display = XOpenDisplay(":0.0");
if (x11_display == NULL) {
fprintf(stderr, "Can't connect X server!\n");
exit(-1);
}
assert(x11_display);
va_dpy = vaGetDisplay(x11_display);
va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
assert(va_status == VA_STATUS_SUCCESS);
va_status = vaQueryConfigEntrypoints(va_dpy, VAProfileMPEG2Main, entrypoints, va_status = vaQueryConfigEntrypoints(va_dpy, VAProfileMPEG2Main, entrypoints,
&num_entrypoints); &num_entrypoints);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints");
for (vld_entrypoint = 0; vld_entrypoint < num_entrypoints; vld_entrypoint++) { for (vld_entrypoint = 0; vld_entrypoint < num_entrypoints; vld_entrypoint++) {
if (entrypoints[vld_entrypoint] == VAEntrypointVLD) if (entrypoints[vld_entrypoint] == VAEntrypointVLD)
...@@ -144,107 +179,108 @@ void test() ...@@ -144,107 +179,108 @@ void test()
} }
if (vld_entrypoint == num_entrypoints) { if (vld_entrypoint == num_entrypoints) {
/* not find VLD entry point */ /* not find VLD entry point */
ASSERT(0); assert(0);
} }
/* Assuming finding VLD, find out the format for the render target */ /* Assuming finding VLD, find out the format for the render target */
attrib.type = VAConfigAttribRTFormat; attrib.type = VAConfigAttribRTFormat;
va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD,
&attrib, 1); &attrib, 1);
ASSERT( VA_STATUS_SUCCESS == va_status );
if ((attrib.value & VA_RT_FORMAT_YUV420) == 0) { if ((attrib.value & VA_RT_FORMAT_YUV420) == 0) {
/* not find desired YUV420 RT format */ /* not find desired YUV420 RT format */
ASSERT(0); assert(0);
} }
va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD,
&attrib, 1,&config_id); &attrib, 1,&config_id);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints");
va_status = vaCreateSurfaces(va_dpy,surf_width,surf_height, va_status = vaCreateSurfaces(va_dpy,CLIP_WIDTH,CLIP_HEIGHT,
VA_RT_FORMAT_YUV420, 1, &vaSurface); VA_RT_FORMAT_YUV420, 1, &surface_id);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaCreateSurfaces");
/* Create a context for this decode pipe */ /* Create a context for this decode pipe */
va_status = vaCreateContext(va_dpy, config_id, va_status = vaCreateContext(va_dpy, config_id,
CLIP_WIDTH, CLIP_WIDTH,
((CLIP_HEIGHT+15)/16)*16, ((CLIP_HEIGHT+15)/16)*16,
VA_PROGRESSIVE, VA_PROGRESSIVE,
&vaSurface, &surface_id,
1, 1,
&vaContext); &context_id);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaCreateContext");
va_status = vaCreateBuffer(va_dpy, vaContext, va_status = vaCreateBuffer(va_dpy, context_id,
VAPictureParameterBufferType, VAPictureParameterBufferType,
sizeof(VAPictureParameterBufferMPEG2), sizeof(VAPictureParameterBufferMPEG2),
1, &pic_param, 1, &pic_param,
&vaPicParamBuf); &pic_param_buf);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaCreateBuffer");
va_status = vaCreateBuffer(va_dpy, vaContext, va_status = vaCreateBuffer(va_dpy, context_id,
VAIQMatrixBufferType, VAIQMatrixBufferType,
sizeof(VAIQMatrixBufferMPEG2), sizeof(VAIQMatrixBufferMPEG2),
1, &iq_matrix, 1, &iq_matrix,
&vaIQMatrixBuf ); &iqmatrix_buf );
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaCreateBuffer");
va_status = vaCreateBuffer(va_dpy, vaContext, va_status = vaCreateBuffer(va_dpy, context_id,
VASliceParameterBufferType, VASliceParameterBufferType,
sizeof(VASliceParameterBufferMPEG2), sizeof(VASliceParameterBufferMPEG2),
1, 1,
&slice_param, &vaSliceParamBuf); &slice_param, &slice_param_buf);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaCreateBuffer");
va_status = vaCreateBuffer(va_dpy, vaContext, va_status = vaCreateBuffer(va_dpy, context_id,
VASliceDataBufferType, VASliceDataBufferType,
0xc4-0x2f+1, 0xc4-0x2f+1,
1, 1,
mpeg2_clip+0x2f, mpeg2_clip+0x2f,
&vaSliceDataBuf); &slice_data_buf);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaCreateBuffer");
va_status = vaBeginPicture(va_dpy, vaContext, vaSurface);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaRenderPicture(va_dpy,vaContext, &vaPicParamBuf, 1);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaRenderPicture(va_dpy,vaContext, &vaIQMatrixBuf, 1);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaRenderPicture(va_dpy,vaContext, &vaSliceParamBuf, 1); va_status = vaBeginPicture(va_dpy, context_id, surface_id);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaBeginPicture");
va_status = vaRenderPicture(va_dpy,vaContext, &vaSliceDataBuf, 1); va_status = vaRenderPicture(va_dpy,context_id, &pic_param_buf, 1);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaRenderPicture");
va_status = vaEndPicture(va_dpy,vaContext); va_status = vaRenderPicture(va_dpy,context_id, &iqmatrix_buf, 1);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaRenderPicture");
va_status = vaSyncSurface(va_dpy, vaSurface); va_status = vaRenderPicture(va_dpy,context_id, &slice_param_buf, 1);
ASSERT( VA_STATUS_SUCCESS == va_status ); CHECK_VASTATUS(va_status, "vaRenderPicture");
win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0, va_status = vaRenderPicture(va_dpy,context_id, &slice_data_buf, 1);
win_width,win_height, 0, 0, WhitePixel(dpy, 0)); CHECK_VASTATUS(va_status, "vaRenderPicture");
XMapWindow(dpy, win);
XSync(dpy, False); va_status = vaEndPicture(va_dpy,context_id);
CHECK_VASTATUS(va_status, "vaEndPicture");
va_status = vaPutSurface(va_dpy, vaSurface, win, va_status = vaSyncSurface(va_dpy, surface_id);
0,0,surf_width,surf_height, CHECK_VASTATUS(va_status, "vaSyncSurface");
0,0,win_width,win_height,
NULL,0,0); if (putsurface) {
ASSERT( VA_STATUS_SUCCESS == va_status ); Window win;
win = XCreateSimpleWindow(x11_display, RootWindow(x11_display, 0), 0, 0,
WIN_WIDTH,WIN_HEIGHT, 0, 0, WhitePixel(x11_display, 0));
XMapWindow(x11_display, win);
XSync(x11_display, False);
va_status = vaPutSurface(va_dpy, surface_id, win,
0,0,CLIP_WIDTH,CLIP_HEIGHT,
0,0,WIN_WIDTH,WIN_HEIGHT,
NULL,0,0);
CHECK_VASTATUS(va_status, "vaPutSurface");
}
printf("press any key to exit\n"); printf("press any key to exit\n");
getchar(); getchar();
vaDestroySurfaces(va_dpy,&vaSurface,1); vaDestroySurfaces(va_dpy,&surface_id,1);
vaDestroyConfig(va_dpy,config_id); vaDestroyConfig(va_dpy,config_id);
vaDestroyContext(va_dpy,vaContext); vaDestroyContext(va_dpy,context_id);
}
void post() vaTerminate(va_dpy);
{ XCloseDisplay(x11_display);
test_terminate();
return 0;
} }
# Copyright (c) 2007 Intel Corporation. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sub license, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice (including the
# next paragraph) shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bin_PROGRAMS = h264encode
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA
TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib)
h264encode_LDADD = $(TEST_LIBS)
h264encode_SOURCES = h264encode.c
valgrind: $(bin_PROGRAMS)
for a in $(bin_PROGRAMS); do \
valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
done
This diff is collapsed.
../putsurface/loadsurface.h
\ No newline at end of file
# Copyright (c) 2007 Intel Corporation. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sub license, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice (including the
# next paragraph) shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bin_PROGRAMS = putsurface
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA
TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib)
putsurface_LDADD = $(TEST_LIBS)
putsurface_SOURCES = putsurface.c
valgrind: $(bin_PROGRAMS)
for a in $(bin_PROGRAMS); do \
valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
done
/*
* Copyright (c) 2008-2009 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
static int yuvgen_planar(int width, int height,
unsigned char *Y_start, int Y_pitch,
unsigned char *U_start, int U_pitch,
unsigned char *V_start, int V_pitch,
int UV_interleave, int box_width, int row_shift,
int field)
{
int row;
/* copy Y plane */
for (row=0;row<height;row++) {
unsigned char *Y_row = Y_start + row * Y_pitch;
int jj, xpos, ypos;
ypos = (row / box_width) & 0x1;
/* fill garbage data into the other field */
if (((field == VA_TOP_FIELD) && (row &1))
|| ((field == VA_BOTTOM_FIELD) && ((row &1)==0))) {
memset(Y_row, 0xff, width);
continue;
}
for (jj=0; jj<width; jj++) {
xpos = ((row_shift + jj) / box_width) & 0x1;
if ((xpos == 0) && (ypos == 0))
Y_row[jj] = 0xeb;
if ((xpos == 1) && (ypos == 1))
Y_row[jj] = 0xeb;
if ((xpos == 1) && (ypos == 0))
Y_row[jj] = 0x10;
if ((xpos == 0) && (ypos == 1))
Y_row[jj] = 0x10;
}
}
/* copy UV data */
for( row =0; row < height/2; row++) {
unsigned short value = 0x80;
/* fill garbage data into the other field */
if (((field == VA_TOP_FIELD) && (row &1))
|| ((field == VA_BOTTOM_FIELD) && ((row &1)==0))) {
value = 0xff;
}
if (UV_interleave) {
unsigned short *UV_row = (unsigned short *)(U_start + row * U_pitch);
memset(UV_row, value, width);
} else {
unsigned char *U_row = U_start + row * U_pitch;
unsigned char *V_row = V_start + row * V_pitch;
memset (U_row,value,width/2);
memset (V_row,value,width/2);
}
}
return 0;
}
static int upload_surface(VADisplay va_dpy, VASurfaceID surface_id,
int box_width, int row_shift,
int field)
{
VAImage surface_image;
void *surface_p=NULL, *U_start,*V_start;
VAStatus va_status;
va_status = vaDeriveImage(va_dpy,surface_id,&surface_image);
CHECK_VASTATUS(va_status,"vaDeriveImage");
vaMapBuffer(va_dpy,surface_image.buf,&surface_p);
assert(VA_STATUS_SUCCESS == va_status);
U_start = surface_p + surface_image.offsets[1];
V_start = surface_p + surface_image.offsets[2];
/* assume surface is planar format */
yuvgen_planar(surface_image.width, surface_image.height,
surface_p, surface_image.pitches[0],
U_start, surface_image.pitches[1],
V_start, surface_image.pitches[2],
(surface_image.format.fourcc==VA_FOURCC_NV12),
box_width, row_shift, field);
vaUnmapBuffer(va_dpy,surface_image.buf);
vaDestroyImage(va_dpy,surface_image.image_id);
return 0;
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment