summaryrefslogtreecommitdiff
path: root/libavcodec/options.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-04-05 07:38:16 +0200
committerAnton Khirnov <anton@khirnov.net>2014-05-15 07:51:16 +0200
commitefc7df6c1f11b20a48e60c3f743ce2331b661973 (patch)
tree0d0ec4f903633236cd542cf43e7d1578ced115ae /libavcodec/options.c
parentc9281a01b78cc3f09e36300a0ca3f5824d1c74cf (diff)
lavc: preserve the original private data in avcodec_copy_context()
If a non-NULL codec was passed to avcodec_alloc_context3(), private data will be already allocated in dest.
Diffstat (limited to 'libavcodec/options.c')
-rw-r--r--libavcodec/options.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 2e41ce4704..c28cbeb8e2 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -137,6 +137,9 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
{
+ const AVCodec *orig_codec = dest->codec;
+ uint8_t *orig_priv_data = dest->priv_data;
+
if (avcodec_is_open(dest)) { // check that the dest context is uninitialized
av_log(dest, AV_LOG_ERROR,
"Tried to copy AVCodecContext %p into already-initialized %p\n",
@@ -145,9 +148,10 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
}
memcpy(dest, src, sizeof(*dest));
+ dest->priv_data = orig_priv_data;
+ dest->codec = orig_codec;
+
/* set values specific to opened codecs back to their default state */
- dest->priv_data = NULL;
- dest->codec = NULL;
dest->slice_offset = NULL;
dest->hwaccel = NULL;
dest->internal = NULL;