X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Foptions.c;h=d8e3dbfa33c0dbdba006758c7e84083c5332ea09;hb=c9ee36e60ffb2986acf7decacf6ef6e1da657d61;hp=ea2563b571fedceb212fcea9285633de667b04d4;hpb=475a686a0157a4f0243a0df4a02fadf469e5159c;p=ffmpeg diff --git a/libavcodec/options.c b/libavcodec/options.c index ea2563b571f..d8e3dbfa33c 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -89,7 +89,7 @@ static const AVClass av_codec_context_class = { .get_category = get_category, }; -int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec) +static int init_context_defaults(AVCodecContext *s, const AVCodec *codec) { int flags=0; memset(s, 0, sizeof(AVCodecContext)); @@ -146,6 +146,13 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec) return 0; } +#if FF_API_GET_CONTEXT_DEFAULTS +int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec) +{ + return init_context_defaults(s, codec); +} +#endif + AVCodecContext *avcodec_alloc_context3(const AVCodec *codec) { AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext)); @@ -153,7 +160,7 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec) if (!avctx) return NULL; - if(avcodec_get_context_defaults3(avctx, codec) < 0){ + if (init_context_defaults(avctx, codec) < 0) { av_free(avctx); return NULL; } @@ -179,6 +186,7 @@ void avcodec_free_context(AVCodecContext **pavctx) av_freep(pavctx); } +#if FF_API_COPY_CONTEXT int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) { const AVCodec *orig_codec = dest->codec; @@ -225,6 +233,7 @@ FF_ENABLE_DEPRECATION_WARNINGS dest->inter_matrix = NULL; dest->rc_override = NULL; dest->subtitle_header = NULL; + dest->hw_frames_ctx = NULL; #define alloc_and_copy_or_fail(obj, size, pad) \ if (src->obj && size > 0) { \ @@ -245,19 +254,27 @@ FF_ENABLE_DEPRECATION_WARNINGS av_assert0(dest->subtitle_header_size == src->subtitle_header_size); #undef alloc_and_copy_or_fail + if (src->hw_frames_ctx) { + dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx); + if (!dest->hw_frames_ctx) + goto fail; + } + return 0; fail: + av_freep(&dest->subtitle_header); av_freep(&dest->rc_override); av_freep(&dest->intra_matrix); av_freep(&dest->inter_matrix); av_freep(&dest->extradata); - av_freep(&dest->subtitle_header); + av_buffer_unref(&dest->hw_frames_ctx); dest->subtitle_header_size = 0; dest->extradata_size = 0; av_opt_free(dest); return AVERROR(ENOMEM); } +#endif const AVClass *avcodec_get_class(void) {