diff options
author | Anton Khirnov <anton@khirnov.net> | 2017-01-15 14:52:04 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-04-10 15:44:15 +0200 |
commit | e40107c1ad12a53bb7d81538f35b85ed3d11c4b0 (patch) | |
tree | 8d99ba12a99b7c0939efc4b39fc82cc914694b35 /libavcodec/pthread_frame.c | |
parent | 1f4cf92cfbd3accbae582ac63126ed5570ddfd37 (diff) | |
download | ffmpeg-e40107c1ad12a53bb7d81538f35b85ed3d11c4b0.tar.gz |
pthread_frame: do not share priv_data between multiple codec contexts
Specifically, between the user-facing one and the first frame thread
one.
This is fragile and dangerous, allocate separate private data for each
per-thread context.
Diffstat (limited to 'libavcodec/pthread_frame.c')
-rw-r--r-- | libavcodec/pthread_frame.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 69671c90fb..1ad43d438a 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -702,7 +702,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) av_packet_unref(&p->avpkt); av_freep(&p->released_buffers); - if (i && p->avctx) { + if (p->avctx) { if (codec->priv_class) av_opt_free(p->avctx->priv_data); av_freep(&p->avctx->priv_data); @@ -812,7 +812,7 @@ int ff_frame_thread_init(AVCodecContext *avctx) copy->internal->thread_ctx = p; copy->internal->last_pkt_props = &p->avpkt; - if (i) { + if (codec->priv_data_size) { copy->priv_data = av_mallocz(codec->priv_data_size); if (!copy->priv_data) { err = AVERROR(ENOMEM); @@ -825,9 +825,11 @@ int ff_frame_thread_init(AVCodecContext *avctx) if (err < 0) goto error; } - copy->internal->is_copy = 1; } + if (i) + copy->internal->is_copy = 1; + if (codec->init) err = codec->init(copy); |