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.
//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);
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;
}
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);
{
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 =
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 )
{
{
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)
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);
}
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);