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;
}
av_opt_free(dest);
- av_free(dest->priv_data);
memcpy(dest, src, sizeof(*dest));
dest->priv_data = orig_priv_data;
+
+ if (orig_priv_data)
+ av_opt_copy(orig_priv_data, src->priv_data);
+
dest->codec = orig_codec;
/* set values specific to opened codecs back to their default state */