summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2018-01-12 01:53:01 +0100
committerSven Gothel <[email protected]>2018-01-12 02:46:19 +0100
commitc82905d5ad6e28eadab3beefc9ac186ea55ad3cc (patch)
treefda372be0a110f31c81c4eb1b9afed2a7f9c206d
parent7b3fde81b625431000da82fe2d524989448835c5 (diff)
FFMPEG: Use avcodec_free_context(..) instead of deprecated leaking avcodec_close(..)
Hence rename hb_avcodec_close -> hb_avcodec_free_context and pass the required ptr-ptr. avcodec_free_context(..) ensures releasing of all resources attached to the context.
-rw-r--r--libhb/decavcodec.c13
-rw-r--r--libhb/decpgssub.c2
-rw-r--r--libhb/encavcodec.c9
-rw-r--r--libhb/encavcodecaudio.c6
-rw-r--r--libhb/hb.c6
-rw-r--r--libhb/hbffmpeg.h2
6 files changed, 16 insertions, 22 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 8b5d367cc..836c7f1be 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -390,13 +390,12 @@ static void closePrivData( hb_work_private_t ** ppv )
//if (!(pv->qsv.decode && pv->job != NULL && (pv->job->vcodec & HB_VCODEC_QSV_MASK)))
#endif
{
- hb_avcodec_close(pv->context);
+ hb_avcodec_free_context(&pv->context);
}
}
if ( pv->context )
{
- av_freep( &pv->context->extradata );
- av_freep( &pv->context );
+ hb_avcodec_free_context(&pv->context);
}
hb_audio_resample_free(pv->resample);
@@ -821,9 +820,7 @@ static int decavcodecaBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
if ( parser != NULL )
av_parser_close( parser );
- hb_avcodec_close( context );
- av_freep( &context->extradata );
- av_freep( &context );
+ hb_avcodec_free_context(&context);
return result;
}
@@ -2105,9 +2102,7 @@ static void decavcodecvFlush( hb_work_object_t *w )
if ( pv->title->opaque_priv == NULL )
{
pv->video_codec_opened = 0;
- hb_avcodec_close( pv->context );
- av_freep( &pv->context->extradata );
- av_freep( &pv->context );
+ hb_avcodec_free_context(&pv->context);
if ( pv->parser )
{
av_parser_close(pv->parser);
diff --git a/libhb/decpgssub.c b/libhb/decpgssub.c
index c3621428b..463c3b9e4 100644
--- a/libhb/decpgssub.c
+++ b/libhb/decpgssub.c
@@ -502,7 +502,7 @@ static void decsubClose( hb_work_object_t * w )
{
hb_work_private_t * pv = w->private_data;
avcodec_flush_buffers( pv->context );
- avcodec_close( pv->context );
+ avcodec_free_context( &pv->context );
}
hb_work_object_t hb_decpgssub =
diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c
index 9960a21b4..d9ea805ea 100644
--- a/libhb/encavcodec.c
+++ b/libhb/encavcodec.c
@@ -399,12 +399,13 @@ void encavcodecClose( hb_work_object_t * w )
return;
}
hb_chapter_queue_close(&pv->chapter_queue);
- if( pv->context && pv->context->codec )
+ if( pv->context )
{
hb_deep_log( 2, "encavcodec: closing libavcodec" );
- avcodec_flush_buffers( pv->context );
- hb_avcodec_close( pv->context );
- av_free( pv->context );
+ if( pv->context->codec ) {
+ avcodec_flush_buffers( pv->context );
+ }
+ hb_avcodec_free_context(&pv->context);
}
if( pv->file )
{
diff --git a/libhb/encavcodecaudio.c b/libhb/encavcodecaudio.c
index 480d1e684..544cd3304 100644
--- a/libhb/encavcodecaudio.c
+++ b/libhb/encavcodecaudio.c
@@ -308,10 +308,10 @@ static void encavcodecaClose(hb_work_object_t * w)
{
Finalize(w);
hb_deep_log(2, "encavcodecaudio: closing libavcodec");
- if (pv->context->codec != NULL)
+ if (pv->context->codec != NULL) {
avcodec_flush_buffers(pv->context);
- hb_avcodec_close(pv->context);
- av_free( pv->context );
+ }
+ hb_avcodec_free_context(&pv->context);
}
if (pv->output_buf != NULL)
diff --git a/libhb/hb.c b/libhb/hb.c
index f35090e38..112b5f5c6 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -140,11 +140,9 @@ int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec,
return ret;
}
-int hb_avcodec_close(AVCodecContext *avctx)
+void hb_avcodec_free_context(AVCodecContext **avctx)
{
- int ret;
- ret = avcodec_close(avctx);
- return ret;
+ avcodec_free_context(avctx);
}
diff --git a/libhb/hbffmpeg.h b/libhb/hbffmpeg.h
index 76ffbe830..a148a6901 100644
--- a/libhb/hbffmpeg.h
+++ b/libhb/hbffmpeg.h
@@ -24,7 +24,7 @@
void hb_avcodec_init(void);
int hb_avcodec_open(AVCodecContext *, AVCodec *, AVDictionary **, int);
-int hb_avcodec_close(AVCodecContext *);
+void hb_avcodec_free_context(AVCodecContext **avctx);
const char* const* hb_av_preset_get_names(int encoder);
uint64_t hb_ff_mixdown_xlat(int hb_mixdown, int *downmix_mode);