[Libva] [libva][PATCH v3 1/6] vpp: fix memory leak in DNDI code path.

Xiang, Haihao haihao.xiang at intel.com
Thu May 7 18:04:19 PDT 2015


From: Gwenole Beauchesne <gb.devel at gmail.com>

The original current_out_surface was never released on exit. Main
reason for that is the legacy VPP framework that did not allow the
VADriverContextP handle to be passed down to the desired .finalize()
hook. Improved that to bring it on par with the VEBOX code path.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
---
 src/gen8_post_processing.c |    3 ++-
 src/i965_post_processing.c |   18 ++++++++++++++----
 src/i965_post_processing.h |    4 +++-
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/gen8_post_processing.c b/src/gen8_post_processing.c
index 320a1bf..de56b39 100644
--- a/src/gen8_post_processing.c
+++ b/src/gen8_post_processing.c
@@ -1386,7 +1386,8 @@ gen8_post_processing(
 }
 
 static void
-gen8_post_processing_context_finalize(struct i965_post_processing_context *pp_context)
+gen8_post_processing_context_finalize(VADriverContextP ctx,
+    struct i965_post_processing_context *pp_context)
 {
     dri_bo_unreference(pp_context->surface_state_binding_table.bo);
     pp_context->surface_state_binding_table.bo = NULL;
diff --git a/src/i965_post_processing.c b/src/i965_post_processing.c
index 9c296ed..fb4d0a7 100755
--- a/src/i965_post_processing.c
+++ b/src/i965_post_processing.c
@@ -5272,7 +5272,8 @@ i965_image_processing(VADriverContextP ctx,
 }       
 
 static void
-i965_post_processing_context_finalize(struct i965_post_processing_context *pp_context)
+i965_post_processing_context_finalize(VADriverContextP ctx,
+    struct i965_post_processing_context *pp_context)
 {
     int i;
 
@@ -5301,6 +5302,13 @@ i965_post_processing_context_finalize(struct i965_post_processing_context *pp_co
     dri_bo_unreference(pp_context->pp_dndi_context.stmm_bo);
     pp_context->pp_dndi_context.stmm_bo = NULL;
 
+    if (pp_context->pp_dndi_context.current_out_surface != VA_INVALID_ID) {
+        i965_DestroySurfaces(ctx,
+            &pp_context->pp_dndi_context.current_out_surface, 1);
+        pp_context->pp_dndi_context.current_out_surface = VA_INVALID_ID;
+        pp_context->pp_dndi_context.current_out_obj_surface = NULL;
+    }
+
     dri_bo_unreference(pp_context->pp_dn_context.stmm_bo);
     pp_context->pp_dn_context.stmm_bo = NULL;
 
@@ -5324,7 +5332,7 @@ i965_post_processing_terminate(VADriverContextP ctx)
     struct i965_post_processing_context *pp_context = i965->pp_context;
 
     if (pp_context) {
-        pp_context->finalize(pp_context);
+        pp_context->finalize(ctx, pp_context);
         free(pp_context);
     }
 
@@ -5938,9 +5946,10 @@ error:
 static void
 i965_proc_context_destroy(void *hw_context)
 {
-    struct i965_proc_context *proc_context = (struct i965_proc_context *)hw_context;
+    struct i965_proc_context * const proc_context = hw_context;
+    VADriverContextP const ctx = proc_context->driver_context;
 
-    i965_post_processing_context_finalize(&proc_context->pp_context);
+    i965_post_processing_context_finalize(ctx, &proc_context->pp_context);
     intel_batchbuffer_free(proc_context->base.batch);
     free(proc_context);
 }
@@ -5955,6 +5964,7 @@ i965_proc_context_init(VADriverContextP ctx, struct object_config *obj_config)
     proc_context->base.destroy = i965_proc_context_destroy;
     proc_context->base.run = i965_proc_picture;
     proc_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
+    proc_context->driver_context = ctx;
     i965->codec_info->post_processing_context_init(ctx, &proc_context->pp_context, proc_context->base.batch);
 
     return (struct hw_context *)proc_context;
diff --git a/src/i965_post_processing.h b/src/i965_post_processing.h
index d434527..e6940c0 100755
--- a/src/i965_post_processing.h
+++ b/src/i965_post_processing.h
@@ -542,12 +542,14 @@ struct i965_post_processing_context
 				const VARectangle *dst_rect,
 				int   pp_index,
 				void * filter_param);
-    void (*finalize)(struct i965_post_processing_context *pp_context);
+    void (*finalize)(VADriverContextP ctx,
+        struct i965_post_processing_context *pp_context);
 };
 
 struct i965_proc_context
 {
     struct hw_context base;
+    void *driver_context;
     struct i965_post_processing_context pp_context;
 };
 
-- 
1.7.9.5



More information about the Libva mailing list