[vlc-commits] avcodec: expand context deletion code

Rémi Denis-Courmont git at videolan.org
Mon Jun 19 19:58:52 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jun 19 19:36:40 2017 +0300| [f97ee88000df38f308430767a09c29ba5f8dcacc] | committer: Rémi Denis-Courmont

avcodec: expand context deletion code

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

 modules/codec/avcodec/audio.c    | 5 +++++
 modules/codec/avcodec/avcodec.c  | 5 -----
 modules/codec/avcodec/subtitle.c | 5 +++++
 modules/codec/avcodec/video.c    | 2 ++
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 74598a9a90..66131969c4 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -197,7 +197,12 @@ static block_t *vlc_av_frame_Wrap(AVFrame *frame)
  *****************************************************************************/
 void EndAudioDec( decoder_t *p_dec )
 {
+    decoder_sys_t *sys = p_dec->p_sys;
+    AVCodecContext *ctx = sys->p_context;
+
     ffmpeg_CloseCodec( p_dec );
+    avcodec_free_context( &ctx );
+    free( sys );
 }
 
 /*****************************************************************************
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 0da4690ffd..bb3baf02bd 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -349,11 +349,6 @@ static void CloseDecoder( vlc_object_t *p_this )
         default:
             vlc_assert_unreachable();
     }
-
-    decoder_sys_t *p_sys = p_dec->p_sys;
-
-    avcodec_free_context( &p_sys->p_context );
-    free( p_sys );
 }
 
 /*****************************************************************************
diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c
index 61adb97fe1..02c4ed955b 100644
--- a/modules/codec/avcodec/subtitle.c
+++ b/modules/codec/avcodec/subtitle.c
@@ -120,7 +120,12 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
 
 void EndSubtitleDec(decoder_t *dec)
 {
+    decoder_sys_t *sys = dec->p_sys;
+    AVCodecContext *ctx = sys->p_context;
+
     ffmpeg_CloseCodec(dec);
+    avcodec_free_context(&ctx);
+    free(sys);
 }
 
 /**
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 11588b7d9c..523c13c743 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1225,6 +1225,8 @@ void EndVideoDec( decoder_t *p_dec )
         vlc_va_Delete( p_sys->p_va, ctx->hwaccel_context );
 
     vlc_sem_destroy( &p_sys->sem_mt );
+    avcodec_free_context( &ctx );
+    free( p_sys );
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list