diff options
author | Anton Khirnov <anton@khirnov.net> | 2017-01-09 18:04:42 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-04-10 15:24:54 +0200 |
commit | 1f4cf92cfbd3accbae582ac63126ed5570ddfd37 (patch) | |
tree | 0d08c281a748689d53350a929fb0df022dc6ef2c /libavcodec/mimic.c | |
parent | 665e5b0fba41a8bae2269d9ce8929a24002e5907 (diff) |
pthread_frame: merge the functionality for normal decoder init and init_thread_copy
The current design, where
- proper init is called for the first per-thread context
- first thread's private data is copied into private data for all the
other threads
- a "fixup" function is called for all the other threads to e.g.
allocate dynamically allocated data
is very fragile and hard to follow, so it is abandoned. Instead, the
same init function is used to init each per-thread context. Where
necessary, AVCodecInternal.is_copy can be used to differentiate between
the first thread and the other ones (e.g. for decoding the extradata
just once).
Diffstat (limited to 'libavcodec/mimic.c')
-rw-r--r-- | libavcodec/mimic.c | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 8e3a77a334..2563a49d53 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -128,8 +128,7 @@ static av_cold int mimic_decode_end(AVCodecContext *avctx) av_frame_free(&ctx->frames[i].f); } - if (!avctx->internal->is_copy) - ff_free_vlc(&ctx->vlc); + ff_free_vlc(&ctx->vlc); return 0; } @@ -449,24 +448,6 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, return buf_size; } -#if HAVE_THREADS -static av_cold int mimic_init_thread_copy(AVCodecContext *avctx) -{ - MimicContext *ctx = avctx->priv_data; - int i; - - for (i = 0; i < FF_ARRAY_ELEMS(ctx->frames); i++) { - ctx->frames[i].f = av_frame_alloc(); - if (!ctx->frames[i].f) { - mimic_decode_end(avctx); - return AVERROR(ENOMEM); - } - } - - return 0; -} -#endif - AVCodec ff_mimic_decoder = { .name = "mimic", .long_name = NULL_IF_CONFIG_SMALL("Mimic"), @@ -478,6 +459,5 @@ AVCodec ff_mimic_decoder = { .decode = mimic_decode_frame, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .update_thread_context = ONLY_IF_THREADS_ENABLED(mimic_decode_update_thread_context), - .init_thread_copy = ONLY_IF_THREADS_ENABLED(mimic_init_thread_copy), .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS, }; |