OSDN Git Service

1) test/*: enable/refine the test/* for both X11 and Android
authorAustin Yuan <shengquan.yuan@gmail.com>
Fri, 6 May 2011 03:04:50 +0000 (20:04 -0700)
committerAustin Yuan <shengquan.yuan@gmail.com>
Fri, 6 May 2011 04:52:16 +0000 (21:52 -0700)
2) va_dri2.c: use _XSend instead of _XReply which is time-consuming
3) trace message for vaPutSurface/vaInitialize/vaTerminate

Signed-off-by: Guoliang Ji <guoliangx.ji@intel.com>
Signed-off-by: Zhaohan Ren <zhaohan.ren@intel.com>
Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com>
22 files changed:
configure.ac
test/android_winsys.cpp [new file with mode: 0644]
test/basic/Android.mk [new file with mode: 0755]
test/basic/test_android.c [new file with mode: 0644]
test/basic/test_common.c
test/basic/test_x11.c [new file with mode: 0644]
test/decode/Android.mk [new file with mode: 0755]
test/decode/Makefile.am
test/decode/mpeg2vldemo.cpp [moved from test/decode/mpeg2vldemo.c with 87% similarity]
test/encode/Android.mk [new file with mode: 0755]
test/encode/Makefile.am
test/encode/h264encode_android.cpp [new file with mode: 0644]
test/encode/h264encode_common.c [moved from test/encode/h264encode.c with 90% similarity]
test/encode/h264encode_x11.c [new file with mode: 0644]
test/putsurface/Android.mk
test/putsurface/Makefile.am
test/putsurface/putsurface.c [deleted file]
test/putsurface/putsurface_android.cpp [new file with mode: 0644]
test/putsurface/putsurface_common.c [moved from test/putsurface/putsurface-android.cpp with 79% similarity]
test/putsurface/putsurface_x11.c [new file with mode: 0644]
va/va_trace.c
va/x11/va_dri2.c

index 99693b4..2d8381e 100644 (file)
@@ -92,6 +92,7 @@ AC_SUBST(LIBVA_DRIVERS_PATH)
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 AC_PROG_CC
+AC_PROG_CXX
 
 AC_HEADER_STDC
 AC_SYS_LARGEFILE
diff --git a/test/android_winsys.cpp b/test/android_winsys.cpp
new file mode 100644 (file)
index 0000000..6f84e38
--- /dev/null
@@ -0,0 +1,32 @@
+
+namespace android {
+    class Test {
+        public:
+                static const sp<ISurface>& getISurface(const sp<Surface>& s) {
+                            return s->getISurface();
+                }
+    };
+};
+
+#define SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, win_width, win_height) \
+{\
+    client = new SurfaceComposerClient();\
+    surface_ctrl = client->createSurface(getpid(), 0, win_width, win_height, PIXEL_FORMAT_RGB_565, ISurfaceComposer::ePushBuffers);\
+    android_surface = surface_ctrl->getSurface();\
+    android_isurface = Test::getISurface(android_surface);\
+\
+    client->openTransaction();\
+    surface_ctrl->setPosition(0, 0);\
+    client->closeTransaction();\
+\
+    client->openTransaction();\
+    surface_ctrl->setSize(win_width, win_height);\
+    client->closeTransaction();\
+\
+    client->openTransaction();\
+    surface_ctrl->setLayer(0x100000);\
+    client->closeTransaction();\
+\
+}\
+
+
diff --git a/test/basic/Android.mk b/test/basic/Android.mk
new file mode 100755 (executable)
index 0000000..a4b136c
--- /dev/null
@@ -0,0 +1,234 @@
+# For test_01
+# =====================================================
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_01.c    \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_001 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
+# For test_02
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_02.c    \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_02_android 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
+# For test_03
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_03.c    \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_03_android 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
+# For test_04g
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_04.c    \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_04_android 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
+# For test_05
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_05.c    \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_05_android 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
+# For test_06
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_06.c    \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_06_android 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
+# For test_07
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_07.c    \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_07_android 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
+# For test_08
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_08.c    \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_08_android 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
+# For test_09
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_09.c    \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_09_android 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
+# For test_10
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_10.c    
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_10_android 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
+# For test_11
+# =====================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  test_11.c    
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        test_11_android 
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
diff --git a/test/basic/test_android.c b/test/basic/test_android.c
new file mode 100644 (file)
index 0000000..2bb247a
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+#define Display unsigned int
+Display *dpy;
+VADisplay va_dpy;
+VAStatus va_status;
+VAProfile *profiles ;
+int major_version, minor_version;
+
+void test_init()
+{
+    dpy = (Display*)malloc(sizeof(Display));
+    *(dpy) = 0x18c34078;
+    ASSERT( dpy );
+    status("malloc Display: dpy = %08x\n", dpy);
+
+    va_dpy = vaGetDisplay(dpy);
+    ASSERT( va_dpy );  
+    status("vaGetDisplay: va_dpy = %08x\n", va_dpy);
+
+    va_status = vaInitialize(va_dpy, &major_version, &minor_version);
+    ASSERT( VA_STATUS_SUCCESS == va_status );
+    status("vaInitialize: major = %d minor = %d\n", major_version, minor_version);
+}
+
+void test_terminate()
+{
+    va_status = vaTerminate(va_dpy);
+    ASSERT( VA_STATUS_SUCCESS == va_status );
+    status("vaTerminate\n");
+
+    free(dpy);
+    status("free Display\n");
+
+    if (profiles)
+    {
+        free(profiles);
+        profiles = NULL;
+    }
+}
+
index 8287d1e..ae730a4 100644 (file)
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <va/va.h>
+#ifdef ANDROID
+#include <va/va_android.h>
+#else
 #include <va/va_x11.h>
-
+#endif
 #include "assert.h"
 #include <stdarg.h>
 #include <stdio.h>
 
 #define ASSERT assert
 
+void status(const char *msg, ...);
+#ifdef ANDROID
+#include "test_android.c"
+#else
+#include "test_x11.c"
+#endif
+
 Display *dpy;
 VADisplay va_dpy;
 VAStatus va_status;
@@ -74,37 +85,6 @@ int main(int argc, const char* argv[])
   return 0;
 }
 
-void test_init()
-{
-  dpy = XOpenDisplay(NULL);
-  ASSERT( dpy );
-  status("XOpenDisplay: dpy = %08x\n", dpy);
-  
-  va_dpy = vaGetDisplay(dpy);
-  ASSERT( va_dpy );  
-  status("vaGetDisplay: va_dpy = %08x\n", va_dpy);
-  
-  va_status = vaInitialize(va_dpy, &major_version, &minor_version);
-  ASSERT( VA_STATUS_SUCCESS == va_status );
-  status("vaInitialize: major = %d minor = %d\n", major_version, minor_version);
-}
-
-void test_terminate()
-{
-  va_status = vaTerminate(va_dpy);
-  ASSERT( VA_STATUS_SUCCESS == va_status );
-  status("vaTerminate\n");
-
-  XCloseDisplay(dpy);
-  status("XCloseDisplay\n");
-
-  if (profiles)
-  {
-      free(profiles);
-      profiles = NULL;
-  }
-}
-
 #define PROFILE(profile)       case VAProfile##profile:        return("VAProfile" #profile);
 
 const char *profile2string(VAProfile profile)
diff --git a/test/basic/test_x11.c b/test/basic/test_x11.c
new file mode 100644 (file)
index 0000000..df8f362
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+Display *dpy;
+VADisplay va_dpy;
+VAStatus va_status;
+VAProfile *profiles ;
+int major_version, minor_version;
+
+void test_init()
+{
+  dpy = XOpenDisplay(NULL);
+  ASSERT( dpy );
+  status("XOpenDisplay: dpy = %08x\n", dpy);
+  
+  va_dpy = vaGetDisplay(dpy);
+  ASSERT( va_dpy );  
+  status("vaGetDisplay: va_dpy = %08x\n", va_dpy);
+  
+  va_status = vaInitialize(va_dpy, &major_version, &minor_version);
+  ASSERT( VA_STATUS_SUCCESS == va_status );
+  status("vaInitialize: major = %d minor = %d\n", major_version, minor_version);
+}
+
+void test_terminate()
+{
+  va_status = vaTerminate(va_dpy);
+  ASSERT( VA_STATUS_SUCCESS == va_status );
+  status("vaTerminate\n");
+
+  XCloseDisplay(dpy);
+  status("XCloseDisplay\n");
+
+  if (profiles)
+  {
+      free(profiles);
+      profiles = NULL;
+  }
+}
+
diff --git a/test/decode/Android.mk b/test/decode/Android.mk
new file mode 100755 (executable)
index 0000000..3541ee2
--- /dev/null
@@ -0,0 +1,25 @@
+# For test_01
+# =====================================================
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  mpeg2vldemo.cpp      \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/   \
+  $(TARGET_OUT_HEADERS)/X11    
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        mpeg2vldemo
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
index ea30643..9d74137 100644 (file)
@@ -27,7 +27,7 @@ AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/src/x11
 TEST_LIBS = $(top_builddir)/va/$(libvabackendlib)
 
 mpeg2vldemo_LDADD = $(TEST_LIBS)
-mpeg2vldemo_SOURCES = mpeg2vldemo.c
+mpeg2vldemo_SOURCES = mpeg2vldemo.cpp
 
 
 valgrind:      $(bin_PROGRAMS)
similarity index 87%
rename from test/decode/mpeg2vldemo.c
rename to test/decode/mpeg2vldemo.cpp
index 7057675..4799a5c 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <getopt.h>
-#include <X11/Xlib.h>
-
 #include <unistd.h>
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-
 #include <assert.h>
-
 #include <va/va.h>
+
+#ifdef ANDROID
+#include <va/va_android.h>
+#include <binder/IPCThreadState.h>
+#include <binder/ProcessState.h>
+#include <binder/IServiceManager.h>
+#include <utils/Log.h>
+#include <surfaceflinger/ISurfaceComposer.h>
+#include <surfaceflinger/Surface.h>
+#include <surfaceflinger/ISurface.h>
+#include <surfaceflinger/SurfaceComposerClient.h>
+#include <binder/MemoryHeapBase.h>
+#define Display unsigned int
+
+using namespace android;
+sp<SurfaceComposerClient> client;
+sp<Surface> android_surface;
+sp<ISurface> android_isurface;
+sp<SurfaceControl> surface_ctrl;
+#include "../android_winsys.cpp"
+#else
 #include <va/va_x11.h>
+#include <X11/Xlib.h>
+#endif
 
 #define CHECK_VASTATUS(va_status,func)                                  \
 if (va_status != VA_STATUS_SUCCESS) {                                   \
@@ -122,15 +140,18 @@ static VAIQMatrixBufferMPEG2 iq_matrix = {
   chroma_non_intra_quantiser_matrix:{0}
 };
 
+#if 1
 static VASliceParameterBufferMPEG2 slice_param={
   slice_data_size:150,
   slice_data_offset:0,
   slice_data_flag:0,
-  macroblock_offset:38,/* 4byte + 6bits=38bits */
+  macroblock_offset:38, /* 4byte + 6bits=38bits */
+  slice_horizontal_position:0,
   slice_vertical_position:0,
   quantiser_scale_code:2,
   intra_slice_flag:0
 };
+#endif
 
 #define CLIP_WIDTH  16
 #define CLIP_HEIGHT 16
@@ -155,8 +176,12 @@ int main(int argc,char **argv)
 
     if (argc > 1)
         putsurface=1;
+#ifdef ANDROID 
+    x11_display = (Display*)malloc(sizeof(Display));
+    *(x11_display ) = 0x18c34078;
+#else
     x11_display = XOpenDisplay(":0.0");
+#endif
 
     if (x11_display == NULL) {
       fprintf(stderr, "Can't connect X server!\n");
@@ -222,7 +247,7 @@ int main(int argc,char **argv)
                               1, &iq_matrix,
                               &iqmatrix_buf );
     CHECK_VASTATUS(va_status, "vaCreateBuffer");
-                
+
     va_status = vaCreateBuffer(va_dpy, context_id,
                               VASliceParameterBufferType,
                               sizeof(VASliceParameterBufferMPEG2),
@@ -258,20 +283,32 @@ int main(int argc,char **argv)
 
     va_status = vaSyncSurface(va_dpy, surface_id);
     CHECK_VASTATUS(va_status, "vaSyncSurface");
-    
+
     if (putsurface) {
+#ifdef ANDROID 
+        sp<ProcessState> proc(ProcessState::self());
+        ProcessState::self()->startThreadPool();
+
+        printf("Create window0 for thread0\n");
+        SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, WIN_WIDTH, WIN_HEIGHT);
+
+        va_status = vaPutSurface(va_dpy, surface_id, android_isurface,
+                0,0,CLIP_WIDTH,CLIP_HEIGHT,
+                0,0,WIN_WIDTH,WIN_HEIGHT,
+                NULL,0,0);
+#else
         Window  win;
         win = XCreateSimpleWindow(x11_display, RootWindow(x11_display, 0), 0, 0,
-                              WIN_WIDTH,WIN_HEIGHT, 0, 0, WhitePixel(x11_display, 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");
+#endif
+       CHECK_VASTATUS(va_status, "vaPutSurface");
     }
-
     printf("press any key to exit\n");
     getchar();
 
@@ -280,7 +317,11 @@ int main(int argc,char **argv)
     vaDestroyContext(va_dpy,context_id);
 
     vaTerminate(va_dpy);
+#ifdef ANDROID
+    free(x11_display);
+#else
     XCloseDisplay(x11_display);
+#endif
     
     return 0;
 }
diff --git a/test/encode/Android.mk b/test/encode/Android.mk
new file mode 100755 (executable)
index 0000000..8395cdd
--- /dev/null
@@ -0,0 +1,26 @@
+# For test_01
+# =====================================================
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+  h264encode_android.cpp       \
+  #h264encode_x11.c    \
+
+LOCAL_CFLAGS += \
+    -DANDROID  
+
+LOCAL_C_INCLUDES += \
+  $(TARGET_OUT_HEADERS)/libva  \
+  $(TOPDIR)/hardware/intel/libva/va/   \
+  $(TARGET_OUT_HEADERS)/X11    
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE :=        h264encode
+
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+
+include $(BUILD_EXECUTABLE)
+
index db4e67e..133b08e 100644 (file)
@@ -27,7 +27,7 @@ AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/src/x11
 TEST_LIBS = $(top_builddir)/va/$(libvabackendlib)
 
 h264encode_LDADD = $(TEST_LIBS)
-h264encode_SOURCES = h264encode.c
+h264encode_SOURCES = h264encode_x11.c
 
 avcenc_LDADD= $(TEST_LIBS)
 avcenc_SOURCES= avcenc.c
diff --git a/test/encode/h264encode_android.cpp b/test/encode/h264encode_android.cpp
new file mode 100644 (file)
index 0000000..9960c48
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007-2008 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.
+ */
+
+/*
+ * it is a real program to show how VAAPI encoding work,
+ * It does H264 element stream level encoding on auto-generated YUV data
+ *
+ * gcc -o  h264encode  h264encode -lva -lva-x11
+ * ./h264encode -w <width> -h <height> -n <frame_num>
+ *
+ */  
+#include <binder/IPCThreadState.h>
+#include <binder/ProcessState.h>
+#include <binder/IServiceManager.h>
+#include <utils/Log.h>
+#include <surfaceflinger/ISurfaceComposer.h>
+#include <surfaceflinger/Surface.h>
+#include <surfaceflinger/ISurface.h>
+#include <surfaceflinger/SurfaceComposerClient.h>
+#include <binder/MemoryHeapBase.h>
+#define Display unsigned int
+
+using namespace android;
+#include "../android_winsys.cpp"
+#include "h264encode_common.c"
+
+sp<SurfaceComposerClient> client;
+sp<Surface> android_surface;
+sp<ISurface> android_isurface;
+sp<SurfaceControl> surface_ctrl;
+
+static int display_surface(int frame_id, int *exit_encode)
+{
+    VAStatus va_status;
+
+    sp<ProcessState> proc(ProcessState::self());
+    ProcessState::self()->startThreadPool();
+
+    printf("Create window0 for thread0\n");
+    SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, 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,
+            NULL,0,0);
+
+    *exit_encode = 0;
+    return 0;
+}
+
similarity index 90%
rename from test/encode/h264encode.c
rename to test/encode/h264encode_common.c
index cfdaea6..97dd719 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <getopt.h>
-#include <X11/Xlib.h>
-
 #include <unistd.h>
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-
 #include <assert.h>
-
 #include <va/va.h>
+#ifdef ANDROID
+#include <va/va_android.h>
+#else
 #include <va/va_x11.h>
+#endif
 
 #define CHECK_VASTATUS(va_status,func)                                  \
 if (va_status != VA_STATUS_SUCCESS) {                                   \
@@ -54,25 +53,19 @@ if (va_status != VA_STATUS_SUCCESS) {                                   \
 }
 
 #include "loadsurface.h"
-
 #define SURFACE_NUM 18 /* 16 surfaces for src, 2 surface for reconstructed/reference */
-
-static  Display *x11_display;
+#define CODEDBUF_NUM 5
 static  VADisplay va_dpy;
-static  VAContextID context_id;
 static  VASurfaceID surface_id[SURFACE_NUM];
-static  Window display_win = 0;
-static  int win_width;
-static  int win_height;
-
+static  VABufferID coded_buf[CODEDBUF_NUM];
+static  VAContextID context_id;
+static  Display *x11_display;
 static  int coded_fd;
 static  char coded_file[256];
-
-#define CODEDBUF_NUM 5
-static  VABufferID coded_buf[CODEDBUF_NUM];
-
+static  int frame_width,  frame_height;
+static  int win_width;
+static  int win_height;
 static  int frame_display = 0; /* display the frame during encoding */
-static  int frame_width=352, frame_height=288;
 static  int frame_rate = 30;
 static  int frame_count = 400;
 static  int intra_count = 30;
@@ -80,6 +73,8 @@ static  int frame_bitrate = 8000000; /* 8M */
 static  int initial_qp = 15;
 static  int minimal_qp = 0;
 
+static int display_surface(int frame_id, int *exit_encode);
+
 static int upload_source_YUV_once_for_all()
 {
     VAImage surface_image;
@@ -96,7 +91,7 @@ static int upload_source_YUV_once_for_all()
         row_shift++;
         if (row_shift==(2*box_width)) row_shift= 0;
     }
-    printf("\n", i);
+    printf("\n");
 
     return 0;
 }
@@ -114,7 +109,7 @@ static int save_coded_buf(VABufferID coded_buf, int current_frame, int frame_ski
     while (buf_list != NULL) {
         printf("Write %d bytes", buf_list->size);
         coded_size += write(coded_fd, buf_list->buf, buf_list->size);
-        buf_list = buf_list->next;
+        buf_list = (VACodedBufferSegment *) buf_list->next;
     }
     vaUnmapBuffer(va_dpy,coded_buf);
 
@@ -144,53 +139,10 @@ static int save_coded_buf(VABufferID coded_buf, int current_frame, int frame_ski
         printf("(SKipped)");
     printf("                                    ");
 
-    return;
+    return 0;
 }
 
 
-static int display_surface(int frame_id, int *exit_encode)
-{
-    Window win = display_win;
-    XEvent event;
-    VAStatus va_status;
-    
-    if (win == 0) { /* display reconstructed surface */
-        win_width = frame_width;
-        win_height = frame_height;
-        
-        win = XCreateSimpleWindow(x11_display, RootWindow(x11_display, 0), 0, 0,
-                                  frame_width, frame_height, 0, 0, WhitePixel(x11_display, 0));
-        XMapWindow(x11_display, win);
-        XSync(x11_display, False);
-
-        display_win = win;
-    }
-
-    va_status = vaPutSurface(va_dpy, surface_id[frame_id], win,
-                             0,0, frame_width, frame_height,
-                             0,0, win_width, win_height,
-                             NULL,0,0);
-
-    *exit_encode = 0;
-    while(XPending(x11_display)) {
-        XNextEvent(x11_display, &event);
-            
-        /* bail on any focused key press */
-        if(event.type == KeyPress) {  
-            *exit_encode = 1;
-            break;
-        }
-            
-        /* rescale the video to fit the window */
-        if(event.type == ConfigureNotify) { 
-            win_width = event.xconfigure.width;
-            win_height = event.xconfigure.height;
-        }      
-    }  
-
-    return;
-}
-
 enum {
     SH_LEVEL_1=10,
     SH_LEVEL_1B=11,
@@ -302,7 +254,7 @@ static int do_h264_encoding(void)
         va_status = vaSyncSurface(va_dpy, surface_id[src_surface]);
         CHECK_VASTATUS(va_status,"vaSyncSurface");
 
-        surface_status = 0;
+        surface_status = (VASurfaceStatus) 0;
         va_status = vaQuerySurfaceStatus(va_dpy, surface_id[src_surface],&surface_status);
         frame_skipped = (surface_status & VASurfaceSkipped);
 
@@ -398,9 +350,14 @@ int main(int argc,char **argv)
         }
     }
     
+#ifdef ANDROID
+    x11_display = (Display*)malloc(sizeof(Display));
+    *(x11_display) = 0x18c34078;
+#else
     x11_display = XOpenDisplay(":0.0");
+#endif
     assert(x11_display);
-    
+
     va_dpy = vaGetDisplay(x11_display);
     va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
     CHECK_VASTATUS(va_status, "vaInitialize");
@@ -466,7 +423,11 @@ int main(int argc,char **argv)
     
     vaTerminate(va_dpy);
     
+#ifdef ANDROID
+    free(x11_display);
+#else
     XCloseDisplay(x11_display);
+#endif
     
     return 0;
 }
diff --git a/test/encode/h264encode_x11.c b/test/encode/h264encode_x11.c
new file mode 100644 (file)
index 0000000..a30e667
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2007-2008 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.
+ */
+
+/*
+ * it is a real program to show how VAAPI encoding work,
+ * It does H264 element stream level encoding on auto-generated YUV data
+ *
+ * gcc -o  h264encode  h264encode -lva -lva-x11
+ * ./h264encode -w <width> -h <height> -n <frame_num>
+ *
+ */  
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <va/va.h>
+#include <X11/Xlib.h>
+#include <va/va_x11.h>
+
+#define SURFACE_NUM 18 /* 16 surfaces for src, 2 surface for reconstructed/reference */
+
+static  Display *x11_display;
+static  VADisplay va_dpy;
+static  VASurfaceID surface_id[SURFACE_NUM];
+static  Window display_win = 0;
+static  int win_width;
+static  int win_height;
+static  int frame_width=352, frame_height=288;
+
+static int display_surface(int frame_id, int *exit_encode)
+{
+    Window win = display_win;
+    XEvent event;
+    VAStatus va_status;
+    
+    if (win == 0) { /* display reconstructed surface */
+        win_width = frame_width;
+        win_height = frame_height;
+        
+        win = XCreateSimpleWindow(x11_display, RootWindow(x11_display, 0), 0, 0,
+                                  frame_width, frame_height, 0, 0, WhitePixel(x11_display, 0));
+        XMapWindow(x11_display, win);
+        XSync(x11_display, False);
+
+        display_win = win;
+    }
+
+    va_status = vaPutSurface(va_dpy, surface_id[frame_id], win,
+                             0,0, frame_width, frame_height,
+                             0,0, win_width, win_height,
+                             NULL,0,0);
+
+    *exit_encode = 0;
+    while(XPending(x11_display)) {
+        XNextEvent(x11_display, &event);
+            
+        /* bail on any focused key press */
+        if(event.type == KeyPress) {  
+            *exit_encode = 1;
+            break;
+        }
+            
+        /* rescale the video to fit the window */
+        if(event.type == ConfigureNotify) { 
+            win_width = event.xconfigure.width;
+            win_height = event.xconfigure.height;
+        }      
+    }  
+
+    return;
+}
+
+#include "h264encode_common.c"
index 8bcfd0c..cce0b63 100644 (file)
@@ -6,7 +6,8 @@ LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-  putsurface-android.cpp
+  putsurface_android.cpp
+  #putsurface_x11.c
 
 LOCAL_CFLAGS += \
     -DANDROID  
index fe18388..c43bde2 100644 (file)
@@ -27,7 +27,7 @@ AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/src/x11
 TEST_LIBS = $(top_builddir)/va/$(libvabackendlib) -lpthread
 
 putsurface_LDADD = $(TEST_LIBS)
-putsurface_SOURCES = putsurface.c
+putsurface_SOURCES = putsurface_x11.c
 
 EXTRA_DIST = loadsurface.h
 
diff --git a/test/putsurface/putsurface.c b/test/putsurface/putsurface.c
deleted file mode 100644 (file)
index fcea3ad..0000000
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * 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.
- */
-
-
-/* gcc -o putsurface putsurface.c -lva -lva-x11 */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <sys/time.h>
-
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <va/va.h>
-#include <va/va_x11.h>
-
-#include <assert.h>
-
-#include <pthread.h>
-
-/*currently, if XCheckWindowEvent was called  in more than one thread, it would cause
- * XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
- *       after 87 requests (83 known processed) with 0 events remaining.
- *
- *       X Error of failed request:  BadGC (invalid GC parameter)
- *       Major opcode of failed request:  60 (X_FreeGC)
- *       Resource id in failed request:  0x600034
- *       Serial number of failed request:  398
- *       Current serial number in output stream:  399
- * The root cause is unknown. */
-
-#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);                                                            \
-}
-
-#include "loadsurface.h"
-
-
-#define SURFACE_NUM 5
-static  VASurfaceID surface_id[SURFACE_NUM];
-static  int surface_width=352, surface_height=288;
-static  int win_width=352, win_height=288;
-static  Window win_thread0, win_thread1;
-static  Pixmap pixmap_thread0, pixmap_thread1;
-static  GC context_thread0, context_thread1;
-static  Display *x11_display;
-static  VADisplay *va_dpy;
-static  int multi_thread=0;
-static  int put_pixmap = 0;
-static  int test_clip = 0;
-static  int display_field = VA_FRAME_PICTURE;
-static  int check_event = 1;
-static  int verbose=0;
-static  pthread_mutex_t surface_mutex[SURFACE_NUM];
-
-static pthread_mutex_t gmutex;
-
-static  int box_width=32;
-
-static Pixmap create_pixmap(int width, int height)
-{
-    int screen = DefaultScreen(x11_display);
-    Window root;
-    Pixmap pixmap;
-    XWindowAttributes attr;
-    
-    root = RootWindow(x11_display, screen);
-
-    XGetWindowAttributes (x11_display, root, &attr);
-    
-    printf("Create a pixmap from ROOT window %dx%d, pixmap size %dx%d\n\n", attr.width, attr.height, width, height);
-    pixmap = XCreatePixmap(x11_display, root, width, height,
-                           DefaultDepth(x11_display, DefaultScreen(x11_display)));
-
-    return pixmap;
-}
-
-static int create_window(int width, int height)
-{
-    int screen = DefaultScreen(x11_display);
-    Window root, win;
-
-    root = RootWindow(x11_display, screen);
-
-    printf("Create window0 for thread0\n");
-    win_thread0 = win = XCreateSimpleWindow(x11_display, root, 0, 0, width, height,
-                                            0, 0, WhitePixel(x11_display, 0));
-    if (win) {
-        XSizeHints sizehints;
-        sizehints.width  = width;
-        sizehints.height = height;
-        sizehints.flags = USSize;
-        XSetNormalHints(x11_display, win, &sizehints);
-        XSetStandardProperties(x11_display, win, "Thread 0", "Thread 0",
-                               None, (char **)NULL, 0, &sizehints);
-
-        XMapWindow(x11_display, win);
-    }
-    context_thread0 = XCreateGC(x11_display, win, 0, 0);
-    XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask);
-    XSync(x11_display, False);
-
-    if (put_pixmap)
-        pixmap_thread0 = create_pixmap(width, height);
-    
-    if (multi_thread == 0)
-        return 0;
-
-    printf("Create window1 for thread1\n");
-    
-    win_thread1 = win = XCreateSimpleWindow(x11_display, root, width, 0, width, height,
-                                            0, 0, WhitePixel(x11_display, 0));
-    if (win) {
-        XSizeHints sizehints;
-        sizehints.width  = width;
-        sizehints.height = height;
-        sizehints.flags = USSize;
-        XSetNormalHints(x11_display, win, &sizehints);
-        XSetStandardProperties(x11_display, win, "Thread 1", "Thread 1",
-                               None, (char **)NULL, 0, &sizehints);
-
-        XMapWindow(x11_display, win);
-    }
-    if (put_pixmap)
-        pixmap_thread1 = create_pixmap(width, height);
-
-    context_thread1 = XCreateGC(x11_display, win, 0, 0);
-    XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask);
-    XSync(x11_display, False);
-    
-    return 0;
-}
-
-static VASurfaceID get_next_free_surface(int *index)
-{
-    VASurfaceStatus surface_status;
-    int i;
-
-    assert(index);
-
-    for (i=0; i<SURFACE_NUM; i++) {
-        surface_status = 0;
-        vaQuerySurfaceStatus(va_dpy, surface_id[i], &surface_status);
-        if (surface_status == VASurfaceReady)
-        {
-            if (0 == pthread_mutex_trylock(&surface_mutex[i]))
-            {
-                *index = i;
-                break;
-            }
-        }
-    }
-
-    if (i==SURFACE_NUM)
-        return VA_INVALID_SURFACE;
-    else
-        return surface_id[i];
-}
-
-/*
- * Helper function for profiling purposes
- */
-static unsigned long get_tick_count(void)
-{
-    struct timeval tv;
-    if (gettimeofday(&tv, NULL))
-        return 0;
-    return tv.tv_usec/1000+tv.tv_sec*1000;
-}
-
-static int putsurface_thread(void *data)
-{
-    int width=win_width, height=win_height;
-    Drawable draw;
-    Window win = (Window)data;
-    Pixmap pixmap = 0;
-    GC context = NULL;
-    int quit = 0;
-    VAStatus vaStatus;
-    int row_shift = 0;
-    int index = 0;
-    Bool is_event; 
-    XEvent event;
-    unsigned int frame_num=0, start_time, putsurface_time;
-    VARectangle cliprects[2]; /* client supplied clip list */
-    
-    if (win == win_thread0) {
-        printf("Enter into thread0\n\n");
-        pixmap = pixmap_thread0;
-        context = context_thread0;
-    }
-    
-    if (win == win_thread1) {
-        printf("Enter into thread1\n\n");
-        pixmap = pixmap_thread1;
-        context = context_thread1;
-    }
-    
-    if (put_pixmap) {
-        printf("vaPutSurface into a Pixmap, then copy into the Window\n\n");
-        draw = pixmap;
-    } else {
-        printf("vaPutSurface into a Window directly\n\n");
-        draw = win;
-    }
-
-    putsurface_time = 0;
-    while (!quit) {
-        VASurfaceID surface_id = VA_INVALID_SURFACE;
-        
-        while (surface_id == VA_INVALID_SURFACE)
-            surface_id = get_next_free_surface(&index);
-
-        if (verbose) printf("Thread %x Display surface 0x%p,\n", (unsigned int)win, (void *)surface_id);
-
-        upload_surface(va_dpy, surface_id, box_width, row_shift, display_field);
-
-        start_time = get_tick_count();
-        vaStatus = vaPutSurface(va_dpy, surface_id, draw,
-                                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 ((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);
-            }
-        }
-        
-        if (put_pixmap)
-            XCopyArea(x11_display, pixmap, win,  context, 0, 0, width, height, 0, 0);
-        
-        pthread_mutex_unlock(&surface_mutex[index]);
-
-        if (check_event) {
-            pthread_mutex_lock(&gmutex);
-            is_event = XCheckWindowEvent(x11_display, win, StructureNotifyMask|KeyPressMask,&event);
-            pthread_mutex_unlock(&gmutex);
-            if (is_event) {
-                /* bail on any focused key press */
-                if(event.type == KeyPress) {  
-                    quit = 1;
-                    break;
-                }
-
-                /* rescale the video to fit the window */
-                if(event.type == ConfigureNotify) { 
-                    width = event.xconfigure.width;
-                    height = event.xconfigure.height;
-                    printf("Scale window to %dx%d\n", width, height);
-                }      
-            }
-        }
-        
-        row_shift++;
-        if (row_shift==(2*box_width)) row_shift= 0;
-
-        frame_num++;
-    }
-
-    pthread_exit(NULL);
-}
-
-
-int main(int argc,char **argv)
-{
-    int major_ver, minor_ver;
-    VAStatus va_status;
-    pthread_t thread1;
-    int ret;
-    char c;
-    int i;
-
-    while ((c =getopt(argc,argv,"w:h:d:f:tcep?nv") ) != EOF) {
-        switch (c) {
-            case '?':
-                printf("putsurface <options>\n");
-                printf("           -p output to pixmap\n");
-                printf("           -d the dimension of black/write square box, default is 32\n");
-                printf("           -t multi-threads\n");
-                printf("           -e don't check X11 event\n");
-                printf("           -c test clipbox\n");
-                printf("           -f <1/2> top field, or bottom field\n");
-                printf("           -v verbose output\n");
-                exit(0);
-                break;
-            case 'w':
-                win_width = atoi(optarg);
-                break;
-            case 'h':
-                win_height = atoi(optarg);
-                break;
-            case 'd':
-                box_width = atoi(optarg);
-                break;
-            case 't':
-                multi_thread = 1;
-                printf("Two threads to do vaPutSurface\n");
-                break;
-            case 'e':
-                check_event = 0;
-                break;
-            case 'p':
-                put_pixmap = 1;
-                break;
-            case 'c':
-                test_clip = 1;
-                break;
-            case 'f':
-                if (atoi(optarg) == 1) {
-                    printf("Display TOP field\n");
-                    display_field = VA_TOP_FIELD;
-                } else if (atoi(optarg) == 2) {
-                    printf("Display BOTTOM field\n");
-                    display_field = VA_BOTTOM_FIELD;
-                } else
-                    printf("The validate input for -f is: 1(top field)/2(bottom field)\n");
-                break;
-            case 'v':
-                verbose = 1;
-                printf("Enable verbose output\n");
-                break;
-        }
-    }
-    
-    x11_display = XOpenDisplay(":0.0");
-    if (x11_display == NULL) {
-        fprintf(stderr, "Can't connect X server!\n");
-        exit(-1);
-    }
-
-    create_window(win_width, win_height);
-
-    va_dpy = vaGetDisplay(x11_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");
-
-    if (check_event)
-        pthread_mutex_init(&gmutex, NULL);
-    
-    for(i = 0; i< SURFACE_NUM; i++)
-        pthread_mutex_init(&surface_mutex[i], NULL);
-    
-    if (multi_thread == 1) 
-        ret = pthread_create(&thread1, NULL, (void *)putsurface_thread, (void*)win_thread1);
-
-    putsurface_thread((void *)win_thread0);
-
-    if (multi_thread == 1) 
-        pthread_join(thread1, (void **)&ret);
-
-    vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM);    
-    vaTerminate(va_dpy);
-    
-    return 0;
-}
diff --git a/test/putsurface/putsurface_android.cpp b/test/putsurface/putsurface_android.cpp
new file mode 100644 (file)
index 0000000..e168727
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+#include <stdio.h>
+#include <va/va.h>
+#include <va/va_android.h>
+#include <binder/IPCThreadState.h>
+#include <binder/ProcessState.h>
+#include <binder/IServiceManager.h>
+#include <utils/Log.h>
+#include <surfaceflinger/ISurfaceComposer.h>
+#include <surfaceflinger/Surface.h>
+#include <surfaceflinger/ISurface.h>
+#include <surfaceflinger/SurfaceComposerClient.h>
+#include <binder/MemoryHeapBase.h>
+#include <assert.h>
+#include <pthread.h>
+
+#define Display unsigned int
+static  int win_thread0 = 0, win_thread1 = 0;
+static  int multi_thread = 0;
+
+using namespace android;
+#include "../android_winsys.cpp"
+
+sp<SurfaceComposerClient> client;
+sp<Surface> android_surface;
+sp<ISurface> android_isurface;
+sp<SurfaceControl> surface_ctrl;
+
+sp<SurfaceComposerClient> client1;
+sp<Surface> android_surface1;
+sp<ISurface> android_isurface1;
+sp<SurfaceControl> surface_ctrl1;
+
+
+static int create_window(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);
+
+    win_thread0 = 1;
+    if (multi_thread == 0)
+        return 0;
+
+    printf("Create window1 for thread1\n");
+    /* need to modify here jgl*/
+    SURFACE_CREATE(client1,surface_ctrl1,android_surface1, android_isurface1, width, height);
+
+    win_thread1 = 2;
+    return 0;
+}
+
+#include "putsurface_common.c"
similarity index 79%
rename from test/putsurface/putsurface-android.cpp
rename to test/putsurface/putsurface_common.c
index ec2c865..23736ca 100644 (file)
 #include <fcntl.h>
 
 #include <va/va.h>
+#ifdef ANDROID
 #include <va/va_android.h>
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <binder/IServiceManager.h>
-#include <utils/Log.h>
-#include <surfaceflinger/ISurfaceComposer.h>
-#include <surfaceflinger/Surface.h>
-#include <surfaceflinger/ISurface.h>
-#include <surfaceflinger/SurfaceComposerClient.h>
-#include <binder/MemoryHeapBase.h>
-#define Display unsigned int
-
-
+#else
+#include <va/va_x11.h>
+#endif
 #include <assert.h>
-
 #include <pthread.h>
 
 /*currently, if XCheckWindowEvent was called  in more than one thread, it would cause
@@ -71,104 +62,27 @@ if (va_status != VA_STATUS_SUCCESS) {                                   \
     fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \
     exit(1);                                                            \
 }
-
 #include "loadsurface.h"
 
-
 #define SURFACE_NUM 5
 static  VASurfaceID surface_id[SURFACE_NUM];
 static  int surface_width = 352, surface_height = 288;
 static  int win_width=352, win_height=288;
-static  int win_thread0 = 0, win_thread1 = 0;
 static  Display *x11_display;
 static  VADisplay va_dpy;
-static  int multi_thread = 0;
+static  int check_event = 1;
+static  int put_pixmap = 0;
 static  int test_clip = 0;
 static  int display_field = VA_FRAME_PICTURE;
 static  int verbose = 0;
 static  pthread_mutex_t surface_mutex[SURFACE_NUM];
-
-//static pthread_mutex_t gmutex;
-
+static pthread_mutex_t gmutex;
 static  int box_width = 32;
 
-
-using namespace android;
-
-sp<SurfaceComposerClient> client;
-sp<Surface> android_surface;
-sp<ISurface> android_isurface;
-sp<SurfaceControl> surface_ctrl;
-
-sp<SurfaceComposerClient> client1;
-sp<Surface> android_surface1;
-sp<ISurface> android_isurface1;
-sp<SurfaceControl> surface_ctrl1;
-
-namespace android {
-class Test {
-public:
-    static const sp<ISurface>& getISurface(const sp<Surface>& s) {
-        return s->getISurface();
-    }
-};
-};
-
-
-
-
-
-static int create_window(int width, int height)
-{
-    sp<ProcessState> proc(ProcessState::self());
-    ProcessState::self()->startThreadPool();
-
-    printf("Create window0 for thread0\n");
-    client = new SurfaceComposerClient();
-    surface_ctrl = client->createSurface(getpid(), 0, width, height, PIXEL_FORMAT_RGB_565, ISurfaceComposer::ePushBuffers);
-    android_surface = surface_ctrl->getSurface();
-    android_isurface = Test::getISurface(android_surface);
-
-    client->openTransaction();
-    surface_ctrl->setPosition(0, 0);
-    client->closeTransaction();
-
-    client->openTransaction();
-    surface_ctrl->setSize(width, height);
-    client->closeTransaction();
-
-    client->openTransaction();
-    surface_ctrl->setLayer(0x100000);
-    client->closeTransaction();
-
-    win_thread0 = 1;
-    if (multi_thread == 0)
-        return 0;
-
-    printf("Create window1 for thread1\n");
-    client1 = new SurfaceComposerClient();
-    surface_ctrl1 = client1->createSurface(getpid(), 0, width, height, PIXEL_FORMAT_RGB_565, ISurfaceComposer::ePushBuffers);
-    android_surface1 = surface_ctrl1->getSurface();
-    android_isurface1 = Test::getISurface(android_surface1);
-
-    client1->openTransaction();
-    surface_ctrl1->setPosition(width, 0);
-    client1->closeTransaction();
-
-    client1->openTransaction();
-    surface_ctrl1->setSize(width, height);
-    client1->closeTransaction();
-
-    client1->openTransaction();
-    surface_ctrl1->setLayer(0x100000);
-    client1->closeTransaction();
-
-    win_thread1 = 2;
-    return 0;
-
-}
-
-
+#ifndef ANDROID
+static Pixmap create_pixmap(int width, int height);
+#endif
+static int create_window(int width, int height);
 
 static VASurfaceID get_next_free_surface(int *index)
 {
@@ -210,13 +124,23 @@ static unsigned long get_tick_count(void)
 static void* putsurface_thread(void *data)
 {
     int width=win_width, height=win_height;
+#ifdef ANDROID
     int win = (int)data;
+#else 
+    Window win = (Window)data;
+    Pixmap pixmap = 0;
+    GC context = NULL;
+    Bool is_event; 
+    XEvent event;
+    Drawable draw;
+#endif
     int quit = 0;
     VAStatus vaStatus;
     int row_shift = 0;
     int index = 0;
     unsigned int frame_num=0, start_time, putsurface_time;
     VARectangle cliprects[2]; /* client supplied clip list */
+#ifdef ANDROID
     sp<ISurface> win_isurface;
     if (win == win_thread0) {
         printf("Enter into thread0\n\n");
@@ -227,6 +151,20 @@ static void* putsurface_thread(void *data)
         printf("Enter into thread1\n\n");
         win_isurface = android_isurface1;  
     }   
+#else
+    if (win == win_thread0) {
+        printf("Enter into thread0\n\n");
+        pixmap = pixmap_thread0;
+        context = context_thread0;
+    }
+    
+    if (win == win_thread1) {
+        printf("Enter into thread1\n\n");
+        pixmap = pixmap_thread1;
+        context = context_thread1;
+    }
+#endif
     printf("vaPutSurface into a Window directly\n\n");
 
     putsurface_time = 0;
@@ -242,12 +180,21 @@ static void* putsurface_thread(void *data)
 
         start_time = get_tick_count();
 
+#ifdef ANDROID
             vaStatus = vaPutSurface(va_dpy, surface_id, win_isurface,
                                     0,0,surface_width,surface_height,
                                     0,0,width,height,
                                     (test_clip==0)?NULL:&cliprects[0],
                                     (test_clip==0)?0:2,
                                     display_field);
+#else
+        vaStatus = vaPutSurface(va_dpy, surface_id, draw,
+                                0,0,surface_width,surface_height,
+                                0,0,width,height,
+                                (test_clip==0)?NULL:&cliprects[0],
+                                (test_clip==0)?0:2,
+                                display_field);
+#endif 
 
         CHECK_VASTATUS(vaStatus,"vaPutSurface");
 
@@ -274,10 +221,31 @@ static void* putsurface_thread(void *data)
                        cliprects[1].x, cliprects[1].y, cliprects[1].width, cliprects[1].height);
             }
         }
-        
-        
+
+
         pthread_mutex_unlock(&surface_mutex[index]);
-    
+#ifndef ANDROID
+        if (check_event) {
+            pthread_mutex_lock(&gmutex);
+            is_event = XCheckWindowEvent(x11_display, win, StructureNotifyMask|KeyPressMask,&event);
+            pthread_mutex_unlock(&gmutex);
+            if (is_event) {
+                /* bail on any focused key press */
+                if(event.type == KeyPress) {  
+                    quit = 1;
+                    break;
+                }
+#if 0
+                /* rescale the video to fit the window */
+                if(event.type == ConfigureNotify) { 
+                    width = event.xconfigure.width;
+                    height = event.xconfigure.height;
+                    printf("Scale window to %dx%d\n", width, height);
+                }      
+#endif
+            }
+        }
+#endif
         row_shift++;
         if (row_shift==(2*box_width)) row_shift= 0;
 
@@ -326,6 +294,14 @@ int main(int argc,char **argv)
                 multi_thread = 1;
                 printf("Two threads to do vaPutSurface\n");
                 break;
+#ifndef ANDROID
+            case 'e':
+                check_event = 0;
+                break;
+            case 'p':
+                put_pixmap = 1;
+                break;
+#endif 
             case 'c':
                 test_clip = 1;
                 break;
@@ -346,8 +322,12 @@ int main(int argc,char **argv)
         }
     }
 
+#ifdef ANDROID
     x11_display = (Display*)malloc(sizeof(Display));
     *(x11_display) = 0x18c34078;
+#else
+    x11_display = XOpenDisplay(":0.0");
+#endif
 
     if (x11_display == NULL) {
         fprintf(stderr, "Can't connect X server!\n");
@@ -365,10 +345,10 @@ int main(int argc,char **argv)
     va_status = vaCreateSurfaces(va_dpy,surface_width, surface_height,
                                 VA_RT_FORMAT_YUV420, SURFACE_NUM, &surface_id[0]);
     CHECK_VASTATUS(va_status, "vaCreateSurfaces");
-/*
+
     if (check_event)
         pthread_mutex_init(&gmutex, NULL);
-*/   
+   
     for(i = 0; i< SURFACE_NUM; i++)
         pthread_mutex_init(&surface_mutex[i], NULL);
     
diff --git a/test/putsurface/putsurface_x11.c b/test/putsurface/putsurface_x11.c
new file mode 100644 (file)
index 0000000..3968ad3
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <va/va_x11.h>
+
+static  Window win_thread0, win_thread1;
+static  int multi_thread = 0;
+static  Pixmap pixmap_thread0, pixmap_thread1;
+static  GC context_thread0, context_thread1;
+static pthread_mutex_t gmutex;
+
+#include "putsurface_common.c"
+
+static Pixmap create_pixmap(int width, int height)
+{
+    int screen = DefaultScreen(x11_display);
+    Window root;
+    Pixmap pixmap;
+    XWindowAttributes attr;
+    
+    root = RootWindow(x11_display, screen);
+
+    XGetWindowAttributes (x11_display, root, &attr);
+    
+    printf("Create a pixmap from ROOT window %dx%d, pixmap size %dx%d\n\n", attr.width, attr.height, width, height);
+    pixmap = XCreatePixmap(x11_display, root, width, height,
+                           DefaultDepth(x11_display, DefaultScreen(x11_display)));
+
+    return pixmap;
+}
+
+static int create_window(int width, int height)
+{
+    int screen = DefaultScreen(x11_display);
+    Window root, win;
+
+    root = RootWindow(x11_display, screen);
+
+    printf("Create window0 for thread0\n");
+    win_thread0 = win = XCreateSimpleWindow(x11_display, root, 0, 0, width, height,
+                                            0, 0, WhitePixel(x11_display, 0));
+    if (win) {
+        XSizeHints sizehints;
+        sizehints.width  = width;
+        sizehints.height = height;
+        sizehints.flags = USSize;
+        XSetNormalHints(x11_display, win, &sizehints);
+        XSetStandardProperties(x11_display, win, "Thread 0", "Thread 0",
+                               None, (char **)NULL, 0, &sizehints);
+
+        XMapWindow(x11_display, win);
+    }
+    context_thread0 = XCreateGC(x11_display, win, 0, 0);
+    XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask);
+    XSync(x11_display, False);
+
+    if (put_pixmap)
+        pixmap_thread0 = create_pixmap(width, height);
+    
+    if (multi_thread == 0)
+        return 0;
+
+    printf("Create window1 for thread1\n");
+    
+    win_thread1 = win = XCreateSimpleWindow(x11_display, root, width, 0, width, height,
+                                            0, 0, WhitePixel(x11_display, 0));
+    if (win) {
+        XSizeHints sizehints;
+        sizehints.width  = width;
+        sizehints.height = height;
+        sizehints.flags = USSize;
+        XSetNormalHints(x11_display, win, &sizehints);
+        XSetStandardProperties(x11_display, win, "Thread 1", "Thread 1",
+                               None, (char **)NULL, 0, &sizehints);
+
+        XMapWindow(x11_display, win);
+    }
+    if (put_pixmap)
+        pixmap_thread1 = create_pixmap(width, height);
+
+    context_thread1 = XCreateGC(x11_display, win, 0, 0);
+    XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask);
+    XSync(x11_display, False);
+    
+    return 0;
+}
index eb268db..cd15312 100644 (file)
@@ -407,25 +407,21 @@ void va_TraceSurface(VADisplay dpy)
 }
 
 
-VAStatus va_TraceInitialize (
+void va_TraceInitialize (
     VADisplay dpy,
     int *major_version,         /* out */
     int *minor_version          /* out */
 )
 {
-    int i;
-    DPY2INDEX(dpy);
-
+    DPY2INDEX(dpy);    
     TRACE_FUNCNAME(idx);
 }
 
-VAStatus va_TraceTerminate (
+void va_TraceTerminate (
     VADisplay dpy
 )
 {
-    int i;
-    DPY2INDEX(dpy);
-
+    DPY2INDEX(dpy);    
     TRACE_FUNCNAME(idx);
 }
 
@@ -1841,12 +1837,12 @@ void va_TracePutSurface (
     
     va_TraceMsg(idx, "\tsurface = 0x%08x\n", surface);
     va_TraceMsg(idx, "\tdraw = 0x%08x\n", draw);
-    va_TraceMsg(idx, "\tsrcx = %d\n", surface);
-    va_TraceMsg(idx, "\tsrcy = %d\n", surface);
-    va_TraceMsg(idx, "\tsrcw = %d\n", surface);
-    va_TraceMsg(idx, "\tsrch = %d\n", surface);
-    va_TraceMsg(idx, "\tdestx = %d\n", surface);
-    va_TraceMsg(idx, "\tdesty = %d\n", surface);
+    va_TraceMsg(idx, "\tsrcx = %d\n", srcx);
+    va_TraceMsg(idx, "\tsrcy = %d\n", srcy);
+    va_TraceMsg(idx, "\tsrcw = %d\n", srcw);
+    va_TraceMsg(idx, "\tsrch = %d\n", srch);
+    va_TraceMsg(idx, "\tdestx = %d\n", destx);
+    va_TraceMsg(idx, "\tdesty = %d\n", desty);
     va_TraceMsg(idx, "\tdestw = %d\n", destw);
     va_TraceMsg(idx, "\tdesth = %d\n", desth);
     va_TraceMsg(idx, "\tcliprects = 0x%08x\n", cliprects);
index 4915651..8e9f304 100644 (file)
@@ -340,9 +340,9 @@ void VA_DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc,
     req->drawable = drawable;
     load_swap_req(req, target_msc, divisor, remainder);
 
-    _XReply(dpy, (xReply *)&rep, 0, xFalse);
+    _XSend(dpy, NULL, 0);
 
-    *count = vals_to_card64(rep.swap_lo, rep.swap_hi);
+    *count = 0;
 
     UnlockDisplay(dpy);
     SyncHandle();