diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 882700f357..6f61ae246d 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -303,7 +303,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if (CONFIG_FRAME_THREAD_ENCODER && av_codec_is_encoder(avctx->codec)) { unlock_avcodec(codec); //we will instantiate a few encoders thus kick the counter to prevent false detection of a problem - ret = ff_frame_thread_encoder_init(avctx, options ? *options : NULL); + ret = ff_frame_thread_encoder_init(avctx); lock_avcodec(codec); if (ret < 0) goto free_and_end; diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c index 778317d60b..5d14442c01 100644 --- a/libavcodec/frame_thread_encoder.c +++ b/libavcodec/frame_thread_encoder.c @@ -121,7 +121,8 @@ end: return NULL; } -int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options){ +int ff_frame_thread_encoder_init(AVCodecContext *avctx) +{ int i=0; ThreadContext *c; @@ -148,18 +149,14 @@ int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options){ if (avctx->codec_id == AV_CODEC_ID_HUFFYUV || avctx->codec_id == AV_CODEC_ID_FFVHUFF) { int warn = 0; - int context_model = 0; - AVDictionaryEntry *con = av_dict_get(options, "context", NULL, AV_DICT_MATCH_CASE); - - if (con && con->value) - context_model = atoi(con->value); + int64_t tmp; if (avctx->flags & AV_CODEC_FLAG_PASS1) warn = 1; - else if(context_model > 0) { - AVDictionaryEntry *t = av_dict_get(options, "non_deterministic", - NULL, AV_DICT_MATCH_CASE); - warn = !t || !t->value || !atoi(t->value) ? 1 : 0; + else if (av_opt_get_int(avctx->priv_data, "context", 0, &tmp) >= 0 && + tmp > 0) { + warn = av_opt_get_int(avctx->priv_data, "non_deterministic", 0, &tmp) < 0 + || !tmp; } // huffyuv does not support these with multiple frame threads currently if (warn) { @@ -202,7 +199,6 @@ int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options){ } for(i=0; ithread_count ; i++){ - AVDictionary *tmp = NULL; int ret; void *tmpv; AVCodecContext *thread_avctx = avcodec_alloc_context3(avctx->codec); @@ -225,13 +221,8 @@ int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options){ thread_avctx->thread_count = 1; thread_avctx->active_thread_type &= ~FF_THREAD_FRAME; - av_dict_copy(&tmp, options, 0); - av_dict_set(&tmp, "threads", "1", 0); - if(avcodec_open2(thread_avctx, avctx->codec, &tmp) < 0) { - av_dict_free(&tmp); + if (avcodec_open2(thread_avctx, avctx->codec, NULL) < 0) goto fail; - } - av_dict_free(&tmp); av_assert0(!thread_avctx->internal->frame_thread_encoder); thread_avctx->internal->frame_thread_encoder = c; if(pthread_create(&c->worker[i], NULL, worker, thread_avctx)) { diff --git a/libavcodec/frame_thread_encoder.h b/libavcodec/frame_thread_encoder.h index c400d6b32c..2cdc40a830 100644 --- a/libavcodec/frame_thread_encoder.h +++ b/libavcodec/frame_thread_encoder.h @@ -23,7 +23,7 @@ #include "avcodec.h" -int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options); +int ff_frame_thread_encoder_init(AVCodecContext *avctx); void ff_frame_thread_encoder_free(AVCodecContext *avctx); int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, AVFrame *frame, int *got_packet_ptr); diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index b35f5c3342..266984c026 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -1016,7 +1016,7 @@ static av_cold int encode_end(AVCodecContext *avctx) #define COMMON_OPTIONS \ { "non_deterministic", "Allow multithreading for e.g. context=1 at the expense of determinism", \ - OFFSET(non_determ), AV_OPT_TYPE_BOOL, { .i64 = 1 }, \ + OFFSET(non_determ), AV_OPT_TYPE_BOOL, { .i64 = 0 }, \ 0, 1, VE }, \ { "pred", "Prediction method", OFFSET(predictor), AV_OPT_TYPE_INT, { .i64 = LEFT }, LEFT, MEDIAN, VE, "pred" }, \ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LEFT }, INT_MIN, INT_MAX, VE, "pred" }, \