X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Foptions.c;h=e3ded738bb64e378c26e96f94174e1351b7f2475;hb=e0bfe34ea8ccf333ec5b17961fd58eb575e74f8b;hp=c28cbeb8e2c3988ce73e783638aa44ffca4986a2;hpb=efc7df6c1f11b20a48e60c3f743ce2331b661973;p=ffmpeg diff --git a/libavcodec/options.c b/libavcodec/options.c index c28cbeb8e2c..e3ded738bb6 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -135,6 +135,21 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec) return avctx; } +void avcodec_free_context(AVCodecContext **pavctx) +{ + AVCodecContext *avctx = *pavctx; + + if (!avctx) + return; + + avcodec_close(avctx); + + av_freep(&avctx->extradata); + av_freep(&avctx->subtitle_header); + + av_freep(pavctx); +} + int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) { const AVCodec *orig_codec = dest->codec; @@ -162,6 +177,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) dest->intra_matrix = NULL; dest->inter_matrix = NULL; dest->rc_override = NULL; + dest->subtitle_header = NULL; if (src->rc_eq) { dest->rc_eq = av_strdup(src->rc_eq); if (!dest->rc_eq) @@ -182,6 +198,8 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0); alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0); alloc_and_copy_or_fail(rc_override, src->rc_override_count * sizeof(*src->rc_override), 0); + alloc_and_copy_or_fail(subtitle_header, src->subtitle_header_size, 0); + dest->subtitle_header_size = src->subtitle_header_size; #undef alloc_and_copy_or_fail return 0;