Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / ffmpeg / libavcodec / options.c
index b31483b..64b27e5 100644 (file)
@@ -154,6 +154,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;
@@ -167,11 +182,14 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
     }
 
     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 */