[vlc-commits] avcodec: close acceleration back-end after the context

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


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

avcodec: close acceleration back-end after the context

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

 modules/codec/avcodec/avcodec.c |   32 ++++++++++++++++++--------------
 modules/codec/avcodec/avcodec.h |    1 +
 modules/codec/avcodec/video.c   |    2 ++
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index fb83b5e..88c21da 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -333,22 +333,13 @@ static int OpenDecoder( vlc_object_t *p_this )
 static void CloseDecoder( vlc_object_t *p_this )
 {
     decoder_t *p_dec = (decoder_t *)p_this;
-    decoder_sys_t *p_sys = p_dec->p_sys;
 
-    switch( p_dec->fmt_out.i_cat )
-    {
-    case VIDEO_ES:
-         EndVideoDec ( p_dec );
-        break;
-    }
+    if( p_dec->fmt_out.i_cat == VIDEO_ES )
+        EndVideoDec( p_dec );
+    else
+        ffmpeg_CloseCodec( p_dec );
 
-    if( !p_sys->b_delayed_open )
-    {
-        vlc_avcodec_lock();
-        avcodec_close( p_sys->p_context );
-        vlc_avcodec_unlock();
-        msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->p_codec->name );
-    }
+    decoder_sys_t *p_sys = p_dec->p_sys;
 
     av_freep( &p_sys->p_context->extradata );
     avcodec_free_context( &p_sys->p_context );
@@ -389,3 +380,16 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
     p_sys->b_delayed_open = false;
     return VLC_SUCCESS;
 }
+
+void ffmpeg_CloseCodec( decoder_t *p_dec )
+{
+    decoder_sys_t *p_sys = p_dec->p_sys;
+
+    if( p_sys->b_delayed_open )
+        return;
+
+    vlc_avcodec_lock();
+    avcodec_close( p_sys->p_context );
+    vlc_avcodec_unlock();
+    msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->p_codec->name );
+}
diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
index 43e2637..b187169 100644
--- a/modules/codec/avcodec/avcodec.h
+++ b/modules/codec/avcodec/avcodec.h
@@ -55,6 +55,7 @@ int InitSubtitleDec( decoder_t *, AVCodecContext *, const AVCodec * );
 
 /* Initialize decoder */
 int ffmpeg_OpenCodec( decoder_t *p_dec );
+void ffmpeg_CloseCodec( decoder_t *p_dec );
 
 /*****************************************************************************
  * Module descriptor help strings
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 806c2df..a542732 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -819,6 +819,8 @@ void EndVideoDec( decoder_t *p_dec )
 
     wait_mt( p_sys );
 
+    ffmpeg_CloseCodec( p_dec );
+
     if( p_sys->p_ff_pic )
         avcodec_free_frame( &p_sys->p_ff_pic );
 



More information about the vlc-commits mailing list