diff options
author | Sven Gothel <[email protected]> | 2018-01-12 02:48:11 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2018-01-12 02:48:11 +0100 |
commit | 236863bdc00677721a378bcd314d7c9d26bfb241 (patch) | |
tree | ca41a1bfc980a8d4a89d778fbe3946f246c1a78a | |
parent | 1d9e85ffa4703fb1f8973862eb9089ff696eba7c (diff) | |
parent | c82905d5ad6e28eadab3beefc9ac186ea55ad3cc (diff) |
Merge branch 'ffmpeg' into nvenc-encoder
-rw-r--r-- | libhb/decavcodec.c | 21 | ||||
-rw-r--r-- | libhb/decpgssub.c | 2 | ||||
-rw-r--r-- | libhb/encavcodec.c | 9 | ||||
-rw-r--r-- | libhb/encavcodecaudio.c | 6 | ||||
-rw-r--r-- | libhb/hb.c | 6 | ||||
-rw-r--r-- | libhb/hbffmpeg.h | 2 |
6 files changed, 22 insertions, 24 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 9838a0b51..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; } @@ -1294,8 +1291,12 @@ static void filter_video(hb_work_private_t *pv) { int result; - av_buffersrc_add_frame(pv->video_filters.input, pv->frame); - result = av_buffersink_get_frame(pv->video_filters.output, pv->frame); + result = av_buffersrc_add_frame(pv->video_filters.input, pv->frame); + if (result < 0) { + hb_error("filter_video: failed to add frame"); + } else { + result = av_buffersink_get_frame(pv->video_filters.output, pv->frame); + } while (result >= 0) { hb_buffer_t * buf = copy_frame(pv); @@ -2101,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 948454f40..5e637fb57 100644 --- a/libhb/encavcodec.c +++ b/libhb/encavcodec.c @@ -514,12 +514,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 b6ee36aee..41e8e3c34 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); } int hb_avcodec_test_encoder(AVCodec *codec) diff --git a/libhb/hbffmpeg.h b/libhb/hbffmpeg.h index 0779a9999..535e4b3f5 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); int hb_avcodec_test_encoder(AVCodec *codec); int hb_av_encoder_present(int encoder); const char* const* hb_av_preset_get_names(int encoder); |