[vlc-commits] avcodec: pass AVCodecContext to VA destroy callback

Rémi Denis-Courmont git at videolan.org
Sat Sep 13 13:26:49 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Sep 13 13:40:40 2014 +0300| [ee961d8fa4e9f2f6909b3d77269bc0de562649d9] | committer: Rémi Denis-Courmont

avcodec: pass AVCodecContext to VA destroy callback

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ee961d8fa4e9f2f6909b3d77269bc0de562649d9
---

 modules/codec/avcodec/dxva2.c |    7 ++++---
 modules/codec/avcodec/va.c    |    9 +++++----
 modules/codec/avcodec/va.h    |    2 +-
 modules/codec/avcodec/vaapi.c |    3 ++-
 modules/codec/avcodec/vda.c   |   10 +++++-----
 modules/codec/avcodec/video.c |    6 +++---
 modules/hw/vdpau/avcodec.c    |    4 ++--
 7 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 8b6dc5f..1c9824f 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -52,7 +52,7 @@
 #include "../../video_chroma/copy.h"
 
 static int Open(vlc_va_t *, AVCodecContext *, const es_format_t *);
-static void Close(vlc_va_t *);
+static void Close(vlc_va_t *, AVCodecContext *);
 
 vlc_module_begin()
     set_description(N_("DirectX Video Acceleration (DXVA) 2.0"))
@@ -463,10 +463,11 @@ static void Release(void *opaque, uint8_t *data)
     (void) data;
 }
 
-static void Close(vlc_va_t *va)
+static void Close(vlc_va_t *va, AVCodecContext *ctx)
 {
     vlc_va_sys_t *sys = va->sys;
 
+    (void) ctx;
     DxDestroyVideoConversion(sys);
     DxDestroyVideoDecoder(sys);
     DxDestroyVideoService(sys);
@@ -540,7 +541,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const es_format_t *fmt)
     return VLC_SUCCESS;
 
 error:
-    Close(va);
+    Close(va, ctx);
     return VLC_EGENERIC;
 }
 /* */
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index f2b22fb..23179c2 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -41,9 +41,10 @@ static int vlc_va_Start(void *func, va_list ap)
 static void vlc_va_Stop(void *func, va_list ap)
 {
     vlc_va_t *va = va_arg(ap, vlc_va_t *);
-    void (*close)(vlc_va_t *) = func;
+    AVCodecContext *ctx = va_arg(ap, AVCodecContext *);
+    void (*close)(vlc_va_t *, AVCodecContext *) = func;
 
-    close(va);
+    close(va, ctx);
 }
 
 vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
@@ -63,8 +64,8 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
     return va;
 }
 
-void vlc_va_Delete(vlc_va_t *va)
+void vlc_va_Delete(vlc_va_t *va, AVCodecContext *avctx)
 {
-    vlc_module_unload(va->module, vlc_va_Stop, va);
+    vlc_module_unload(va->module, vlc_va_Stop, va, avctx);
     vlc_object_release(va);
 }
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index 4a376cb..e0c6520 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -124,6 +124,6 @@ static inline int vlc_va_Extract(vlc_va_t *va, picture_t *dst, void *opaque,
  * Destroys a libavcodec hardware acceleration back-end.
  * All allocated surfaces shall have been released beforehand.
  */
-void vlc_va_Delete(vlc_va_t *);
+void vlc_va_Delete(vlc_va_t *, AVCodecContext *);
 
 #endif
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index 22b679a..f38690e 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -416,10 +416,11 @@ static int Setup( vlc_va_t *va, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma,
     return VLC_EGENERIC;
 }
 
-static void Delete( vlc_va_t *va )
+static void Delete( vlc_va_t *va, AVCodecContext *avctx )
 {
     vlc_va_sys_t *sys = va->sys;
 
+    (void) avctx;
     if( sys->i_surface_width || sys->i_surface_height )
         DestroySurfaces( sys );
 
diff --git a/modules/codec/avcodec/vda.c b/modules/codec/avcodec/vda.c
index 9da0527..80ab14d 100644
--- a/modules/codec/avcodec/vda.c
+++ b/modules/codec/avcodec/vda.c
@@ -154,7 +154,7 @@ static int Open( vlc_va_t *external, AVCodecContext *ctx,
     return VLC_SUCCESS;
 }
 
-static void Close( vlc_va_t *external )
+static void Close( vlc_va_t *external, AVCodecContext *ctx )
 {
     vlc_va_vda_t *p_va = vlc_va_vda_Get( external );
 
@@ -166,6 +166,7 @@ static void Close( vlc_va_t *external )
         CopyCleanCache( &p_va->image_cache );
 
     free( p_va );
+    (void) ctx;
 }
 
 static int Setup( vlc_va_t *external, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma,
@@ -367,11 +368,10 @@ static int Open( vlc_va_t *external, AVCodecContext *avctx,
     return VLC_SUCCESS;
 }
 
-static void Close( vlc_va_t *external )
+static void Close( vlc_va_t *external, AVCodecContext *avctx )
 {
-    vlc_va_vda_t *p_va = vlc_va_vda_Get( external );
-
-    av_vda_default_free(p_va->avctx);
+    av_vda_default_free(avctx);
+    (void) external;
 }
 
 static int Setup( vlc_va_t *external, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma,
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 2e05979..ecfaa19 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -823,7 +823,7 @@ void EndVideoDec( decoder_t *p_dec )
         avcodec_free_frame( &p_sys->p_ff_pic );
 
     if( p_sys->p_va )
-        vlc_va_Delete( p_sys->p_va );
+        vlc_va_Delete( p_sys->p_va, p_sys->p_context );
 
     vlc_sem_destroy( &p_sys->sem_mt );
 }
@@ -1323,7 +1323,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
     vlc_va_t *p_va = p_sys->p_va;
 
     if( p_va != NULL )
-        vlc_va_Delete( p_va );
+        vlc_va_Delete( p_va, p_context );
 
     /* Enumerate available formats */
     bool can_hwaccel = false;
@@ -1383,7 +1383,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
         return pi_fmt[i];
     }
 
-    vlc_va_Delete( p_va );
+    vlc_va_Delete( p_va, p_context );
 
 end:
     /* Fallback to default behaviour */
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 7a76d38..55b50d0 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -39,7 +39,7 @@
 #include "../../codec/avcodec/va.h"
 
 static int Open(vlc_va_t *, AVCodecContext *, const es_format_t *);
-static void Close(vlc_va_t *);
+static void Close(vlc_va_t *, AVCodecContext *);
 
 vlc_module_begin()
     set_description(N_("VDPAU video decoder"))
@@ -293,7 +293,7 @@ error:
     return VLC_EGENERIC;
 }
 
-static void Close(vlc_va_t *va)
+static void Close(vlc_va_t *va, AVCodecContext *avctx)
 {
     vlc_va_sys_t *sys = va->sys;
 



More information about the vlc-commits mailing list