Using threaded decoding by default breaks backward compatibility if AVHWAccel is used or if an appliction sets threadunsafe callbacks. Avconv and avplay still use -threads auto if not specified.tags/n0.10
| @@ -2210,6 +2210,8 @@ static int init_input_stream(int ist_index, OutputStream *output_streams, int nb | |||||
| ist->st->codec->opaque = ist; | ist->st->codec->opaque = ist; | ||||
| } | } | ||||
| if (!av_dict_get(ist->opts, "threads", NULL, 0)) | |||||
| av_dict_set(&ist->opts, "threads", "auto", 0); | |||||
| if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) { | if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) { | ||||
| snprintf(error, error_len, "Error while opening decoder for input stream #%d:%d", | snprintf(error, error_len, "Error while opening decoder for input stream #%d:%d", | ||||
| ist->file_index, ist->st->index); | ist->file_index, ist->st->index); | ||||
| @@ -2512,6 +2514,8 @@ static int transcode_init(OutputFile *output_files, | |||||
| memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); | memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); | ||||
| ost->st->codec->subtitle_header_size = dec->subtitle_header_size; | ost->st->codec->subtitle_header_size = dec->subtitle_header_size; | ||||
| } | } | ||||
| if (!av_dict_get(ost->opts, "threads", NULL, 0)) | |||||
| av_dict_set(&ost->opts, "threads", "auto", 0); | |||||
| if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { | if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { | ||||
| snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height", | snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height", | ||||
| ost->file_index, ost->index); | ost->file_index, ost->index); | ||||
| @@ -2194,6 +2194,8 @@ static int stream_component_open(VideoState *is, int stream_index) | |||||
| if (lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE; | if (lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE; | ||||
| if (fast) avctx->flags2 |= CODEC_FLAG2_FAST; | if (fast) avctx->flags2 |= CODEC_FLAG2_FAST; | ||||
| if (!av_dict_get(opts, "threads", NULL, 0)) | |||||
| av_dict_set(&opts, "threads", "auto", 0); | |||||
| if (!codec || | if (!codec || | ||||
| avcodec_open2(avctx, codec, &opts) < 0) | avcodec_open2(avctx, codec, &opts) < 0) | ||||
| return -1; | return -1; | ||||
| @@ -372,7 +372,7 @@ static const AVOption options[]={ | |||||
| {"float", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, INT_MAX, V|D, "aa"}, | {"float", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, INT_MAX, V|D, "aa"}, | ||||
| #endif | #endif | ||||
| {"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, | {"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, | ||||
| {"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|E|D, "threads"}, | |||||
| {"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 1 }, 0, INT_MAX, V|E|D, "threads"}, | |||||
| {"auto", "detect a good number of threads", 0, AV_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"}, | {"auto", "detect a good number of threads", 0, AV_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"}, | ||||
| {"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, | {"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, | ||||
| {"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, | {"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, | ||||