aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/options.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2016-06-26 15:14:17 -0300
committerJames Almer <jamrial@gmail.com>2016-06-26 15:14:17 -0300
commit104c357b6a3ee181e1d657df68e38c17ba2bda77 (patch)
tree8de7acbcf90609e153169a3d0c65eba46b93b15c /libavcodec/options.c
parentb2a74dd629c1ab3318ba0123f8814797a4fea3a4 (diff)
parente9394ca63dab3434bc8e869de019ecd86cb604ac (diff)
downloadffmpeg-104c357b6a3ee181e1d657df68e38c17ba2bda77.tar.gz
Merge branch 'master' into release/3.1
Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/options.c')
-rw-r--r--libavcodec/options.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/libavcodec/options.c b/libavcodec/options.c
index ea2563b571..d8e3dbfa33 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)
{