[Libva] [PATCH 9/9] Avoid the dup of gen_free_avc_surface during compile

yakui.zhao at intel.com yakui.zhao at intel.com
Wed Oct 31 01:47:59 PDT 2012


From: Zhao Yakui <yakui.zhao at intel.com>

Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
 src/Makefile.am          |  1 +
 src/gen6_mfc_common.c    |  4 ----
 src/gen6_mfd.c           |  4 ----
 src/gen75_mfd.c          |  4 ----
 src/gen7_mfd.c           |  4 ----
 src/i965_avc_bsd.c       |  4 ----
 src/intel_media.h        | 30 +------------------------
 src/intel_media_common.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 60 insertions(+), 49 deletions(-)
 create mode 100644 src/intel_media_common.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 69d101f..354b890 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -76,6 +76,7 @@ source_c = \
 	intel_driver.c		\
 	intel_memman.c		\
 	object_heap.c		\
+	intel_media_common.c		\
 	$(NULL)
 
 source_h = \
diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
index 12ffeaa..4e23705 100644
--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -27,10 +27,6 @@
  *
  */
 
-#ifndef HAVE_GEN_AVC_SURFACE
-#define HAVE_GEN_AVC_SURFACE 1
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/gen6_mfd.c b/src/gen6_mfd.c
index 6a39ff1..1790053 100755
--- a/src/gen6_mfd.c
+++ b/src/gen6_mfd.c
@@ -26,10 +26,6 @@
  *
  */
 
-#ifndef HAVE_GEN_AVC_SURFACE
-#define HAVE_GEN_AVC_SURFACE 1
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/gen75_mfd.c b/src/gen75_mfd.c
index a0aa960..2b77f7b 100644
--- a/src/gen75_mfd.c
+++ b/src/gen75_mfd.c
@@ -27,10 +27,6 @@
  *
  */
 
-#ifndef HAVE_GEN_AVC_SURFACE
-#define HAVE_GEN_AVC_SURFACE 1
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/gen7_mfd.c b/src/gen7_mfd.c
index e4dfbb2..fe333ed 100755
--- a/src/gen7_mfd.c
+++ b/src/gen7_mfd.c
@@ -26,10 +26,6 @@
  *
  */
 
-#ifndef HAVE_GEN_AVC_SURFACE
-#define HAVE_GEN_AVC_SURFACE 1
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/i965_avc_bsd.c b/src/i965_avc_bsd.c
index 439498a..8921275 100644
--- a/src/i965_avc_bsd.c
+++ b/src/i965_avc_bsd.c
@@ -30,10 +30,6 @@
 #include <string.h>
 #include <assert.h>
 
-#ifndef HAVE_GEN_AVC_SURFACE
-#define HAVE_GEN_AVC_SURFACE 1
-#endif
-
 #include "intel_batchbuffer.h"
 #include "intel_driver.h"
 
diff --git a/src/intel_media.h b/src/intel_media.h
index 5493c60..ca1a78f 100644
--- a/src/intel_media.h
+++ b/src/intel_media.h
@@ -31,9 +31,7 @@
 #include <va/va.h>
 #include <intel_bufmgr.h>
 
-#if HAVE_GEN_AVC_SURFACE
 
-static pthread_mutex_t free_avc_surface_lock = PTHREAD_MUTEX_INITIALIZER;
 
 typedef struct gen_avc_surface GenAvcSurface;
 struct gen_avc_surface
@@ -43,32 +41,6 @@ struct gen_avc_surface
     int dmv_bottom_flag;
 };
 
-static void 
-gen_free_avc_surface(void **data)
-{
-    GenAvcSurface *avc_surface;
-
-    pthread_mutex_lock(&free_avc_surface_lock);
-
-    avc_surface = *data;
-
-    if (!avc_surface) {
-        pthread_mutex_unlock(&free_avc_surface_lock);
-        return;
-    }
-
-
-    dri_bo_unreference(avc_surface->dmv_top);
-    avc_surface->dmv_top = NULL;
-    dri_bo_unreference(avc_surface->dmv_bottom);
-    avc_surface->dmv_bottom = NULL;
-
-    free(avc_surface);
-    *data = NULL;
-
-    pthread_mutex_unlock(&free_avc_surface_lock);
-}
-
-#endif
+extern void gen_free_avc_surface(void **data);
 
 #endif /* INTEL_MEDIA_H */
diff --git a/src/intel_media_common.c b/src/intel_media_common.c
new file mode 100644
index 0000000..c90d893
--- /dev/null
+++ b/src/intel_media_common.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2006-2012 Intel Corporation
+ *
+ * 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, sublicense,
+ * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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 <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "intel_driver.h"
+#include "intel_media.h"
+
+static pthread_mutex_t free_avc_surface_lock = PTHREAD_MUTEX_INITIALIZER;
+
+void 
+gen_free_avc_surface(void **data)
+{
+    GenAvcSurface *avc_surface;
+
+    pthread_mutex_lock(&free_avc_surface_lock);
+
+    avc_surface = *data;
+
+    if (!avc_surface) {
+        pthread_mutex_unlock(&free_avc_surface_lock);
+        return;
+    }
+
+
+    dri_bo_unreference(avc_surface->dmv_top);
+    avc_surface->dmv_top = NULL;
+    dri_bo_unreference(avc_surface->dmv_bottom);
+    avc_surface->dmv_bottom = NULL;
+
+    free(avc_surface);
+    *data = NULL;
+
+    pthread_mutex_unlock(&free_avc_surface_lock);
+}
-- 
1.7.12-rc1



More information about the Libva mailing list