Commit 270299fc authored by Austin Yuan's avatar Austin Yuan

Update on vatrace/test and va.h

vatrace:print H263 decode paramters
test/putsurfac: create drawable with a geometry from commandline
va.h: add BGRA fourcc
Signed-off-by: default avatarAustin Yuan <shengquan.yuan@gmail.com>
parent 12f5b095
...@@ -10,22 +10,23 @@ namespace android { ...@@ -10,22 +10,23 @@ namespace android {
}; };
#define min(a,b) (a<b?a:b) #define min(a,b) (a<b?a:b)
#define SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, win_width, win_height) \ #define SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, x, y, win_width, win_height) \
do { \ do { \
client = new SurfaceComposerClient(); \ client = new SurfaceComposerClient(); \
android::DisplayInfo info; \ android::DisplayInfo info; \
int w, h; \ int w, h; \
\ \
client->getDisplayInfo(android::DisplayID(0), &info); \ client->getDisplayInfo(android::DisplayID(0), &info); \
w = min(win_width, info.w); \ /*w = min(win_width, info.w);*/ \
h = min(win_height, info.h); \ /*h = min(win_height, info.h);*/ \
w = win_width, h = win_height; \
\ \
surface_ctrl = client->createSurface(getpid(), 0, w, h, PIXEL_FORMAT_RGB_565, ISurfaceComposer::ePushBuffers); \ surface_ctrl = client->createSurface(getpid(), 0, w, h, PIXEL_FORMAT_RGB_565, ISurfaceComposer::ePushBuffers); \
android_surface = surface_ctrl->getSurface(); \ android_surface = surface_ctrl->getSurface(); \
android_isurface = Test::getISurface(android_surface); \ android_isurface = Test::getISurface(android_surface); \
\ \
client->openTransaction(); \ client->openTransaction(); \
surface_ctrl->setPosition(0, 0); \ surface_ctrl->setPosition(x, y); \
client->closeTransaction(); \ client->closeTransaction(); \
\ \
client->openTransaction(); \ client->openTransaction(); \
......
...@@ -290,7 +290,7 @@ int main(int argc,char **argv) ...@@ -290,7 +290,7 @@ int main(int argc,char **argv)
ProcessState::self()->startThreadPool(); ProcessState::self()->startThreadPool();
printf("Create window0 for thread0\n"); printf("Create window0 for thread0\n");
SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, WIN_WIDTH, WIN_HEIGHT); SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, 0, 0, WIN_WIDTH, WIN_HEIGHT);
va_status = vaPutSurface(va_dpy, surface_id, android_isurface, va_status = vaPutSurface(va_dpy, surface_id, android_isurface,
0,0,CLIP_WIDTH,CLIP_HEIGHT, 0,0,CLIP_WIDTH,CLIP_HEIGHT,
......
...@@ -58,7 +58,7 @@ static int display_surface(int frame_id, int *exit_encode) ...@@ -58,7 +58,7 @@ static int display_surface(int frame_id, int *exit_encode)
ProcessState::self()->startThreadPool(); ProcessState::self()->startThreadPool();
printf("Create window0 for thread0\n"); printf("Create window0 for thread0\n");
SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, win_width, win_height); SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, 0, 0, win_width, win_height);
va_status = vaPutSurface(va_dpy, surface_id[frame_id], android_isurface, va_status = vaPutSurface(va_dpy, surface_id[frame_id], android_isurface,
0,0, frame_width, frame_height, 0,0, frame_width, frame_height,
0,0, win_width, win_height, 0,0, win_width, win_height,
......
...@@ -53,7 +53,7 @@ sp<SurfaceControl> surface_ctrl1; ...@@ -53,7 +53,7 @@ sp<SurfaceControl> surface_ctrl1;
static void *open_display(void); static void *open_display(void);
static void close_display(void *win_display); static void close_display(void *win_display);
static int create_window(void *win_display, int width, int height); static int create_window(void *win_display, int x, int y, int width, int height);
static int check_window_event(void *x11_display, void *win, int *width, int *height, int *quit); static int check_window_event(void *x11_display, void *win, int *width, int *height, int *quit);
#define CAST_DRAWABLE(a) static_cast<ISurface*>((void *)(*(unsigned int *)a)) #define CAST_DRAWABLE(a) static_cast<ISurface*>((void *)(*(unsigned int *)a))
...@@ -69,13 +69,13 @@ static void close_display(void *win_display) ...@@ -69,13 +69,13 @@ static void close_display(void *win_display)
return; return;
} }
static int create_window(void *win_display, int width, int height) static int create_window(void *win_display, int x, int y, int width, int height)
{ {
sp<ProcessState> proc(ProcessState::self()); sp<ProcessState> proc(ProcessState::self());
ProcessState::self()->startThreadPool(); ProcessState::self()->startThreadPool();
printf("Create window0 for thread0\n"); printf("Create window0 for thread0\n");
SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, width, height); SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, x, y, width, height);
drawable_thread0 = static_cast<void*>(&android_isurface); drawable_thread0 = static_cast<void*>(&android_isurface);
if (multi_thread == 0) if (multi_thread == 0)
...@@ -83,7 +83,7 @@ static int create_window(void *win_display, int width, int height) ...@@ -83,7 +83,7 @@ static int create_window(void *win_display, int width, int height)
printf("Create window1 for thread1\n"); printf("Create window1 for thread1\n");
/* need to modify here jgl*/ /* need to modify here jgl*/
SURFACE_CREATE(client1,surface_ctrl1,android_surface1, android_isurface1, width, height); SURFACE_CREATE(client1,surface_ctrl1,android_surface1, android_isurface1, x, y, width, height);
drawable_thread1 = static_cast<void *>(&android_isurface); drawable_thread1 = static_cast<void *>(&android_isurface);
return 0; return 0;
......
...@@ -64,7 +64,9 @@ static pthread_mutex_t surface_mutex[SURFACE_NUM]; ...@@ -64,7 +64,9 @@ static pthread_mutex_t surface_mutex[SURFACE_NUM];
static void *drawable_thread0, *drawable_thread1; static void *drawable_thread0, *drawable_thread1;
static int surface_width = 352, surface_height = 288; static int surface_width = 352, surface_height = 288;
static int win_width=352, win_height=288; static int win_x = 0, win_y = 0;
static int win_width = 352, win_height = 288;
static int frame_rate = 0;
static unsigned long long frame_num_total = ~0; static unsigned long long frame_num_total = ~0;
static int check_event = 1; static int check_event = 1;
static int put_pixmap = 0; static int put_pixmap = 0;
...@@ -143,6 +145,27 @@ static unsigned long get_tick_count(void) ...@@ -143,6 +145,27 @@ static unsigned long get_tick_count(void)
return tv.tv_usec/1000+tv.tv_sec*1000; return tv.tv_usec/1000+tv.tv_sec*1000;
} }
static void update_clipbox(VARectangle *cliprects, int width, int height)
{
if (test_clip == 0)
return;
srand((unsigned)time(NULL));
cliprects[0].x = (rand() % width);
cliprects[0].y = (rand() % height);
cliprects[0].width = (rand() % (width - cliprects[0].x));
cliprects[0].height = (rand() % (height - cliprects[0].y));
cliprects[1].x = (rand() % width);
cliprects[1].y = (rand() % height);
cliprects[1].width = (rand() % (width - cliprects[1].x));
cliprects[1].height = (rand() % (height - cliprects[1].y));
printf("\nTest clip (%d,%d, %d x %d) and (%d,%d, %d x %d) \n",
cliprects[0].x, cliprects[0].y, cliprects[0].width, cliprects[0].height,
cliprects[1].x, cliprects[1].y, cliprects[1].width, cliprects[1].height);
}
static void* putsurface_thread(void *data) static void* putsurface_thread(void *data)
{ {
int width=win_width, height=win_height; int width=win_width, height=win_height;
...@@ -153,6 +176,7 @@ static void* putsurface_thread(void *data) ...@@ -153,6 +176,7 @@ static void* putsurface_thread(void *data)
int index = 0; int index = 0;
unsigned int frame_num=0, start_time, putsurface_time; unsigned int frame_num=0, start_time, putsurface_time;
VARectangle cliprects[2]; /* client supplied clip list */ VARectangle cliprects[2]; /* client supplied clip list */
int continue_display = 0;
if (drawable == drawable_thread0) if (drawable == drawable_thread0)
printf("Enter into thread0\n\n"); printf("Enter into thread0\n\n");
...@@ -171,53 +195,49 @@ static void* putsurface_thread(void *data) ...@@ -171,53 +195,49 @@ static void* putsurface_thread(void *data)
if (multi_thread) if (multi_thread)
upload_surface(va_dpy, surface_id, box_width, row_shift, display_field); upload_surface(va_dpy, surface_id, box_width, row_shift, display_field);
start_time = get_tick_count();
if (check_event) if (check_event)
pthread_mutex_lock(&gmutex); pthread_mutex_lock(&gmutex);
start_time = get_tick_count();
if ((continue_display == 0) && getenv("FRAME_STOP")) {
char c;
printf("Press any key to display frame %d...(c/C to continue)\n", frame_num);
c = getchar();
if (c == 'c' || c == 'C')
continue_display = 1;
}
vaStatus = vaPutSurface(va_dpy, surface_id, CAST_DRAWABLE(drawable), vaStatus = vaPutSurface(va_dpy, surface_id, CAST_DRAWABLE(drawable),
0,0,surface_width,surface_height, 0,0,surface_width,surface_height,
0,0,width,height, 0,0,width,height,
(test_clip==0)?NULL:&cliprects[0], (test_clip==0)?NULL:&cliprects[0],
(test_clip==0)?0:2, (test_clip==0)?0:2,
display_field); display_field);
CHECK_VASTATUS(vaStatus,"vaPutSurface");
putsurface_time += (get_tick_count() - start_time);
if (check_event) if (check_event)
pthread_mutex_unlock(&gmutex); pthread_mutex_unlock(&gmutex);
pthread_mutex_unlock(&surface_mutex[index]); /* locked in get_next_free_surface */ pthread_mutex_unlock(&surface_mutex[index]); /* locked in get_next_free_surface */
CHECK_VASTATUS(vaStatus,"vaPutSurface");
putsurface_time += (get_tick_count() - start_time);
if ((frame_num % 0xff) == 0) { if ((frame_num % 0xff) == 0) {
fprintf(stderr, "%.2f FPS \r", 256000.0 / (float)putsurface_time); fprintf(stderr, "%.2f FPS \r", 256000.0 / (float)putsurface_time);
putsurface_time = 0; putsurface_time = 0;
update_clipbox(cliprects, width, height);
if (test_clip) {
srand((unsigned)time(NULL));
cliprects[0].x = (rand() % width);
cliprects[0].y = (rand() % height);
cliprects[0].width = (rand() % (width - cliprects[0].x));
cliprects[0].height = (rand() % (height - cliprects[0].y));
cliprects[1].x = (rand() % width);
cliprects[1].y = (rand() % height);
cliprects[1].width = (rand() % (width - cliprects[1].x));
cliprects[1].height = (rand() % (height - cliprects[1].y));
printf("\nTest clip (%d,%d, %d x %d) and (%d,%d, %d x %d) \n",
cliprects[0].x, cliprects[0].y, cliprects[0].width, cliprects[0].height,
cliprects[1].x, cliprects[1].y, cliprects[1].width, cliprects[1].height);
}
} }
if (check_event) if (check_event)
check_window_event(win_display, drawable, &width, &height, &quit); check_window_event(win_display, drawable, &width, &height, &quit);
row_shift++; if (multi_thread) { /* reload surface content */
if (row_shift==(2*box_width)) row_shift= 0; row_shift++;
if (row_shift==(2*box_width)) row_shift= 0;
}
if (frame_rate != 0) /* rough framerate control */
usleep(1000/frame_rate*1000);
frame_num++; frame_num++;
if (frame_num >= frame_num_total) if (frame_num >= frame_num_total)
quit = 1; quit = 1;
} }
...@@ -238,11 +258,13 @@ int main(int argc,char **argv) ...@@ -238,11 +258,13 @@ int main(int argc,char **argv)
char c; char c;
int i; int i;
while ((c =getopt(argc,argv,"w:h:d:f:tcep?nv") ) != EOF) { while ((c =getopt(argc,argv,"w:h:g:r:d:f:tcep?n:v") ) != EOF) {
switch (c) { switch (c) {
case '?': case '?':
printf("putsurface <options>\n"); printf("putsurface <options>\n");
printf(" -w/-h the window width/height\n"); printf(" -g <widthxheight+x_location+y_location> window geometry\n");
printf(" -w/-h resolution of surface\n");
printf(" -r <framerate>\n");
printf(" -d the dimension of black/write square box, default is 32\n"); printf(" -d the dimension of black/write square box, default is 32\n");
printf(" -t multi-threads\n"); printf(" -t multi-threads\n");
printf(" -c test clipbox\n"); printf(" -c test clipbox\n");
...@@ -250,11 +272,23 @@ int main(int argc,char **argv) ...@@ -250,11 +272,23 @@ int main(int argc,char **argv)
printf(" -v verbose output\n"); printf(" -v verbose output\n");
exit(0); exit(0);
break; break;
case 'g':
ret = sscanf(optarg, "%dx%d+%d+%d", &win_width, &win_height, &win_x, &win_y);
if (ret != 4) {
printf("invalid window geometry, must be widthxheight+x_location+y_location\n");
exit(0);
} else
printf("Create window at (%d, %d), width = %d, height = %d\n",
win_x, win_y, win_width, win_height);
break;
case 'r':
frame_rate = atoi(optarg);
break;
case 'w': case 'w':
win_width = atoi(optarg); surface_width = atoi(optarg);
break; break;
case 'h': case 'h':
win_height = atoi(optarg); surface_height = atoi(optarg);
break; break;
case 'n': case 'n':
frame_num_total = atoi(optarg); frame_num_total = atoi(optarg);
...@@ -297,14 +331,12 @@ int main(int argc,char **argv) ...@@ -297,14 +331,12 @@ int main(int argc,char **argv)
fprintf(stderr, "Can't open the connection of display!\n"); fprintf(stderr, "Can't open the connection of display!\n");
exit(-1); exit(-1);
} }
create_window(win_display, win_width, win_height); create_window(win_display, win_x, win_y, win_width, win_height);
va_dpy = vaGetDisplay(win_display); va_dpy = vaGetDisplay(win_display);
va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
CHECK_VASTATUS(va_status, "vaInitialize"); CHECK_VASTATUS(va_status, "vaInitialize");
surface_width = win_width;
surface_height = win_height;
va_status = vaCreateSurfaces(va_dpy,surface_width, surface_height, va_status = vaCreateSurfaces(va_dpy,surface_width, surface_height,
VA_RT_FORMAT_YUV420, SURFACE_NUM, &surface_id[0]); VA_RT_FORMAT_YUV420, SURFACE_NUM, &surface_id[0]);
CHECK_VASTATUS(va_status, "vaCreateSurfaces"); CHECK_VASTATUS(va_status, "vaCreateSurfaces");
......
...@@ -32,7 +32,7 @@ static pthread_mutex_t gmutex; ...@@ -32,7 +32,7 @@ static pthread_mutex_t gmutex;
static void *open_display(void); static void *open_display(void);
static void close_display(void *win_display); static void close_display(void *win_display);
static int create_window(void *win_display, int width, int height); static int create_window(void *win_display, int x, int y, int width, int height);
static int check_window_event(void *x11_display, void *drawable, int *width, int *height, int *quit); static int check_window_event(void *x11_display, void *drawable, int *width, int *height, int *quit);
#define CAST_DRAWABLE(a) (Drawable)(a) #define CAST_DRAWABLE(a) (Drawable)(a)
...@@ -68,7 +68,7 @@ static Pixmap create_pixmap(void *win_display, int width, int height) ...@@ -68,7 +68,7 @@ static Pixmap create_pixmap(void *win_display, int width, int height)
return pixmap; return pixmap;
} }
static int create_window(void *win_display, int width, int height) static int create_window(void *win_display, int x, int y, int width, int height)
{ {
Display *x11_display = (Display *)win_display; Display *x11_display = (Display *)win_display;
int screen = DefaultScreen(x11_display); int screen = DefaultScreen(x11_display);
...@@ -77,7 +77,7 @@ static int create_window(void *win_display, int width, int height) ...@@ -77,7 +77,7 @@ static int create_window(void *win_display, int width, int height)
root = RootWindow(x11_display, screen); root = RootWindow(x11_display, screen);
printf("Create window0 for thread0\n"); printf("Create window0 for thread0\n");
drawable_thread0 = (void *)XCreateSimpleWindow(x11_display, root, 0, 0, width, height, drawable_thread0 = (void *)XCreateSimpleWindow(x11_display, root, x, y, width, height,
0, 0, WhitePixel(x11_display, 0)); 0, 0, WhitePixel(x11_display, 0));
win = (Window)drawable_thread0; win = (Window)drawable_thread0;
......
...@@ -1497,6 +1497,7 @@ VAStatus vaQuerySurfaceError( ...@@ -1497,6 +1497,7 @@ VAStatus vaQuerySurfaceError(
#define VA_FOURCC_NV12 0x3231564E #define VA_FOURCC_NV12 0x3231564E
#define VA_FOURCC_AI44 0x34344149 #define VA_FOURCC_AI44 0x34344149
#define VA_FOURCC_RGBA 0x41424752 #define VA_FOURCC_RGBA 0x41424752
#define VA_FOURCC_BGRA 0x41524742
#define VA_FOURCC_UYVY 0x59565955 #define VA_FOURCC_UYVY 0x59565955
#define VA_FOURCC_YUY2 0x32595559 #define VA_FOURCC_YUY2 0x32595559
#define VA_FOURCC_AYUV 0x56555941 #define VA_FOURCC_AYUV 0x56555941
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <errno.h>
/* /*
...@@ -169,6 +170,7 @@ void va_TraceInit(VADisplay dpy) ...@@ -169,6 +170,7 @@ void va_TraceInit(VADisplay dpy)
trace_context[trace_index].trace_fp_log = tmp; trace_context[trace_index].trace_fp_log = tmp;
strcpy(trace_context[trace_index].trace_log_fn, env_value); strcpy(trace_context[trace_index].trace_log_fn, env_value);
} else { } else {
va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
trace_context[trace_index].trace_fp_log = stderr; trace_context[trace_index].trace_fp_log = stderr;
strcpy(trace_context[trace_index].trace_codedbuf_fn, "/dev/stderr"); strcpy(trace_context[trace_index].trace_codedbuf_fn, "/dev/stderr");
} }
...@@ -204,6 +206,7 @@ void va_TraceInit(VADisplay dpy) ...@@ -204,6 +206,7 @@ void va_TraceInit(VADisplay dpy)
trace_context[trace_index].trace_fp_codedbuf = tmp; trace_context[trace_index].trace_fp_codedbuf = tmp;
strcpy(trace_context[trace_index].trace_codedbuf_fn, env_value); strcpy(trace_context[trace_index].trace_codedbuf_fn, env_value);
} else { } else {
va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
trace_context[trace_index].trace_fp_codedbuf = stderr; trace_context[trace_index].trace_fp_codedbuf = stderr;
strcpy(trace_context[trace_index].trace_codedbuf_fn, "/dev/stderr"); strcpy(trace_context[trace_index].trace_codedbuf_fn, "/dev/stderr");
} }
...@@ -220,6 +223,7 @@ void va_TraceInit(VADisplay dpy) ...@@ -220,6 +223,7 @@ void va_TraceInit(VADisplay dpy)
trace_context[trace_index].trace_fp_surface = tmp; trace_context[trace_index].trace_fp_surface = tmp;
strcpy(trace_context[trace_index].trace_surface_fn, env_value); strcpy(trace_context[trace_index].trace_surface_fn, env_value);
} else { } else {
va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
trace_context[trace_index].trace_fp_surface = stderr; trace_context[trace_index].trace_fp_surface = stderr;
strcpy(trace_context[trace_index].trace_surface_fn, "/dev/stderr"); strcpy(trace_context[trace_index].trace_surface_fn, "/dev/stderr");
} }
...@@ -1537,16 +1541,34 @@ static void va_TraceH263Buf( ...@@ -1537,16 +1541,34 @@ static void va_TraceH263Buf(
) )
{ {
switch (type) { switch (type) {
case VAPictureParameterBufferType: case VAPictureParameterBufferType:/* print MPEG4 buffer */
case VAIQMatrixBufferType: va_TraceVAPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
case VABitPlaneBufferType: break;
case VAIQMatrixBufferType:/* print MPEG4 buffer */
va_TraceVAIQMatrixBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
break;
case VABitPlaneBufferType:/* print MPEG4 buffer */
va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
break;
case VASliceGroupMapBufferType: case VASliceGroupMapBufferType:
case VASliceParameterBufferType: break;
case VASliceParameterBufferType:/* print MPEG4 buffer */
va_TraceVASliceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
break;
case VASliceDataBufferType: case VASliceDataBufferType:
va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
break;
case VAMacroblockParameterBufferType: case VAMacroblockParameterBufferType:
va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
break;
case VAResidualDataBufferType: case VAResidualDataBufferType:
va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
break;
case VADeblockingParameterBufferType: case VADeblockingParameterBufferType:
va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
break;
case VAImageBufferType: case VAImageBufferType:
break;
case VAProtectedSliceDataBufferType: case VAProtectedSliceDataBufferType:
va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
break; break;
...@@ -1836,7 +1858,7 @@ void va_TraceRenderPicture( ...@@ -1836,7 +1858,7 @@ void va_TraceRenderPicture(
va_TraceMsg(idx, "\t---------------------------\n", j); va_TraceMsg(idx, "\t---------------------------\n", j);
va_TraceMsg(idx, "\telement[%d] = ", j); va_TraceMsg(idx, "\telement[%d] = ", j);
va_TraceMPEG4Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j); va_TraceH263Buf(dpy, context, buffers[i], type, size, num_elements, pbuf + size*j);
} }
break; break;
default: default:
......
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