OSDN Git Service

Update on vatrace/test and va.h
authorAustin Yuan <shengquan.yuan@gmail.com>
Thu, 14 Jul 2011 03:18:44 +0000 (11:18 +0800)
committerAustin Yuan <shengquan.yuan@gmail.com>
Thu, 14 Jul 2011 03:18:44 +0000 (11:18 +0800)
vatrace:print H263 decode paramters
test/putsurfac: create drawable with a geometry from commandline
va.h: add BGRA fourcc

Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com>
test/android_winsys.cpp
test/decode/mpeg2vldemo.cpp
test/encode/h264encode_android.cpp
test/putsurface/putsurface_android.cpp
test/putsurface/putsurface_common.c
test/putsurface/putsurface_x11.c
va/va.h
va/va_trace.c

index e72f7d2..ba75bdf 100644 (file)
@@ -10,22 +10,23 @@ namespace android {
 };
 
 #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 {                                                                    \
     client = new SurfaceComposerClient();                               \
     android::DisplayInfo info;                                          \
     int w, h;                                                           \
                                                                         \
     client->getDisplayInfo(android::DisplayID(0), &info);               \
-    w = min(win_width, info.w);                                         \
-    h = min(win_height, info.h);                                        \
+    /*w = min(win_width, info.w);*/                                     \
+    /*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); \
     android_surface = surface_ctrl->getSurface();                       \
     android_isurface = Test::getISurface(android_surface);              \
                                                                         \
     client->openTransaction();                                          \
-    surface_ctrl->setPosition(0, 0);                                    \
+    surface_ctrl->setPosition(x, y);                                    \
     client->closeTransaction();                                         \
                                                                         \
     client->openTransaction();                                          \
index 4799a5c..efdf260 100644 (file)
@@ -290,7 +290,7 @@ int main(int argc,char **argv)
         ProcessState::self()->startThreadPool();
 
         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,
                 0,0,CLIP_WIDTH,CLIP_HEIGHT,
index 9960c48..84b315b 100644 (file)
@@ -58,7 +58,7 @@ static int display_surface(int frame_id, int *exit_encode)
     ProcessState::self()->startThreadPool();
 
     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,
             0,0, frame_width, frame_height,
             0,0, win_width, win_height,
index 8d388ee..8b70480 100644 (file)
@@ -53,7 +53,7 @@ sp<SurfaceControl> surface_ctrl1;
 
 static void *open_display(void);
 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);
 
 #define CAST_DRAWABLE(a)  static_cast<ISurface*>((void *)(*(unsigned int *)a))
@@ -69,13 +69,13 @@ static void close_display(void *win_display)
     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());
     ProcessState::self()->startThreadPool();
 
     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);
     if (multi_thread == 0)
@@ -83,7 +83,7 @@ static int create_window(void *win_display, int width, int height)
 
     printf("Create window1 for thread1\n");
     /* 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);
     
     return 0;
index 1a28d21..06f394f 100644 (file)
@@ -64,7 +64,9 @@ static  pthread_mutex_t surface_mutex[SURFACE_NUM];
 
 static  void *drawable_thread0, *drawable_thread1;
 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  int check_event = 1;
 static  int put_pixmap = 0;
@@ -143,6 +145,27 @@ static unsigned long get_tick_count(void)
     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)
 {
     int width=win_width, height=win_height;
@@ -153,6 +176,7 @@ static void* putsurface_thread(void *data)
     int index = 0;
     unsigned int frame_num=0, start_time, putsurface_time;
     VARectangle cliprects[2]; /* client supplied clip list */
+    int continue_display = 0;
     
     if (drawable == drawable_thread0)
         printf("Enter into thread0\n\n");
@@ -171,53 +195,49 @@ static void* putsurface_thread(void *data)
         if (multi_thread)
             upload_surface(va_dpy, surface_id, box_width, row_shift, display_field);
 
-        start_time = get_tick_count();
-        
         if (check_event)
             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),
                                 0,0,surface_width,surface_height,
                                 0,0,width,height,
                                 (test_clip==0)?NULL:&cliprects[0],
                                 (test_clip==0)?0:2,
                                 display_field);
+        CHECK_VASTATUS(vaStatus,"vaPutSurface");
+        putsurface_time += (get_tick_count() - start_time);
+        
         if (check_event)
             pthread_mutex_unlock(&gmutex);
         
         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) {
             fprintf(stderr, "%.2f FPS             \r", 256000.0 / (float)putsurface_time);
             putsurface_time = 0;
-
-            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);
-            }
+            update_clipbox(cliprects, width, height);
         }
+        
         if (check_event)
             check_window_event(win_display, drawable, &width, &height, &quit);
 
-        row_shift++;
-        if (row_shift==(2*box_width)) row_shift= 0;
+        if (multi_thread) { /* reload surface content */
+            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++;
-
         if (frame_num >= frame_num_total)
             quit = 1;
     }
@@ -238,11 +258,13 @@ int main(int argc,char **argv)
     char c;
     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) {
             case '?':
                 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("           -t multi-threads\n");
                 printf("           -c test clipbox\n");
@@ -250,11 +272,23 @@ int main(int argc,char **argv)
                 printf("           -v verbose output\n");
                 exit(0);
                 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':
-                win_width = atoi(optarg);
+                surface_width = atoi(optarg);
                 break;
             case 'h':
-                win_height = atoi(optarg);
+                surface_height = atoi(optarg);
                 break;
             case 'n':
                 frame_num_total = atoi(optarg);
@@ -297,14 +331,12 @@ int main(int argc,char **argv)
         fprintf(stderr, "Can't open the connection of display!\n");
         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_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
     CHECK_VASTATUS(va_status, "vaInitialize");
 
-    surface_width = win_width;
-    surface_height = win_height;
     va_status = vaCreateSurfaces(va_dpy,surface_width, surface_height,
                                 VA_RT_FORMAT_YUV420, SURFACE_NUM, &surface_id[0]);
     CHECK_VASTATUS(va_status, "vaCreateSurfaces");
index 0c659f7..a89d914 100644 (file)
@@ -32,7 +32,7 @@ static  pthread_mutex_t gmutex;
 
 static void *open_display(void);
 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);
 
 #define CAST_DRAWABLE(a)  (Drawable)(a)
@@ -68,7 +68,7 @@ static Pixmap create_pixmap(void *win_display, int width, int height)
     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;
     int screen = DefaultScreen(x11_display);
@@ -77,7 +77,7 @@ static int create_window(void *win_display, int width, int height)
     root = RootWindow(x11_display, screen);
 
     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));
 
     win = (Window)drawable_thread0;
diff --git a/va/va.h b/va/va.h
index facae17..604efb5 100644 (file)
--- a/va/va.h
+++ b/va/va.h
@@ -1497,6 +1497,7 @@ VAStatus vaQuerySurfaceError(
 #define VA_FOURCC_NV12         0x3231564E
 #define VA_FOURCC_AI44         0x34344149
 #define VA_FOURCC_RGBA         0x41424752
+#define VA_FOURCC_BGRA         0x41524742
 #define VA_FOURCC_UYVY          0x59565955
 #define VA_FOURCC_YUY2          0x32595559
 #define VA_FOURCC_AYUV          0x56555941
index 9b4881a..d85a48a 100644 (file)
@@ -38,6 +38,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <time.h>
+#include <errno.h>
 
 
 /*
@@ -169,6 +170,7 @@ void va_TraceInit(VADisplay dpy)
             trace_context[trace_index].trace_fp_log = tmp;
             strcpy(trace_context[trace_index].trace_log_fn, env_value);
         } else {
+            va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
             trace_context[trace_index].trace_fp_log = stderr;
             strcpy(trace_context[trace_index].trace_codedbuf_fn, "/dev/stderr");
         }
@@ -204,6 +206,7 @@ void va_TraceInit(VADisplay dpy)
             trace_context[trace_index].trace_fp_codedbuf = tmp;
             strcpy(trace_context[trace_index].trace_codedbuf_fn, env_value);
         } else {
+            va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
             trace_context[trace_index].trace_fp_codedbuf = stderr;
             strcpy(trace_context[trace_index].trace_codedbuf_fn, "/dev/stderr");
         }
@@ -220,6 +223,7 @@ void va_TraceInit(VADisplay dpy)
             trace_context[trace_index].trace_fp_surface = tmp;
             strcpy(trace_context[trace_index].trace_surface_fn, env_value);
         } else {
+            va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
             trace_context[trace_index].trace_fp_surface = stderr;
             strcpy(trace_context[trace_index].trace_surface_fn, "/dev/stderr");
         }
@@ -1537,16 +1541,34 @@ static void va_TraceH263Buf(
 )
 {
     switch (type) {
-    case VAPictureParameterBufferType:
-    case VAIQMatrixBufferType:
-    case VABitPlaneBufferType:
+    case VAPictureParameterBufferType:/* print MPEG4 buffer */
+        va_TraceVAPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
+        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 VASliceParameterBufferType:
+        break;
+    case VASliceParameterBufferType:/* print MPEG4 buffer */
+        va_TraceVASliceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf);
+        break;
     case VASliceDataBufferType:
+        va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
+        break;
     case VAMacroblockParameterBufferType:
+        va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
+        break;
     case VAResidualDataBufferType:
+        va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
+        break;
     case VADeblockingParameterBufferType:
+        va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
+        break;
     case VAImageBufferType:
+        break;
     case VAProtectedSliceDataBufferType:
         va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf);
         break;
@@ -1836,7 +1858,7 @@ void va_TraceRenderPicture(
                 va_TraceMsg(idx, "\t---------------------------\n", 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;
         default: