mirror of https://github.com/mpv-player/mpv
vd_lavc: do not mutate global threads option
This mutated the variable for the thread count option (lavc_param->threads) on decoder initialization. This didn't have any practical relevance, unless formats supporting hardware video decoding and other formats were played in the same mpv instance. In this case, hardware decoding would set threads to 1, and all files played after that would use only one thread as well even with software decoding. Remove XvMC leftover (CODEC_CAP_HWACCEL).
This commit is contained in:
parent
fcd6e74e48
commit
0d1aca1289
|
@ -262,10 +262,11 @@ static int init(sh_video_t *sh)
|
||||||
avctx->codec_type = AVMEDIA_TYPE_VIDEO;
|
avctx->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
avctx->codec_id = lavc_codec->id;
|
avctx->codec_id = lavc_codec->id;
|
||||||
|
|
||||||
if (lavc_codec->capabilities & CODEC_CAP_HWACCEL // XvMC
|
avctx->thread_count = lavc_param->threads;
|
||||||
|| lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
|
|
||||||
ctx->do_dr1 = true;
|
if (lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
|
||||||
lavc_param->threads = 1;
|
ctx->do_dr1 = true;
|
||||||
|
avctx->thread_count = 1;
|
||||||
avctx->get_format = get_format;
|
avctx->get_format = get_format;
|
||||||
avctx->get_buffer = get_buffer;
|
avctx->get_buffer = get_buffer;
|
||||||
avctx->release_buffer = release_buffer;
|
avctx->release_buffer = release_buffer;
|
||||||
|
@ -277,7 +278,7 @@ static int init(sh_video_t *sh)
|
||||||
avctx->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD;
|
avctx->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lavc_param->threads == 0) {
|
if (avctx->thread_count == 0) {
|
||||||
int threads = default_thread_count();
|
int threads = default_thread_count();
|
||||||
if (threads < 1) {
|
if (threads < 1) {
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[VD_FFMPEG] Could not determine "
|
mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[VD_FFMPEG] Could not determine "
|
||||||
|
@ -285,14 +286,14 @@ static int init(sh_video_t *sh)
|
||||||
threads = 1;
|
threads = 1;
|
||||||
}
|
}
|
||||||
threads = FFMIN(threads, 16);
|
threads = FFMIN(threads, 16);
|
||||||
lavc_param->threads = threads;
|
avctx->thread_count = threads;
|
||||||
}
|
}
|
||||||
/* Our get_buffer and draw_horiz_band callbacks are not safe to call
|
/* Our get_buffer and draw_horiz_band callbacks are not safe to call
|
||||||
* from other threads. */
|
* from other threads. */
|
||||||
if (lavc_param->threads > 1) {
|
if (avctx->thread_count > 1) {
|
||||||
ctx->do_dr1 = false;
|
ctx->do_dr1 = false;
|
||||||
mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Asking decoder to use "
|
mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Asking decoder to use "
|
||||||
"%d threads if supported.\n", lavc_param->threads);
|
"%d threads if supported.\n", avctx->thread_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->do_dr1) {
|
if (ctx->do_dr1) {
|
||||||
|
@ -405,8 +406,6 @@ static int init(sh_video_t *sh)
|
||||||
if (sh->bih)
|
if (sh->bih)
|
||||||
avctx->bits_per_coded_sample = sh->bih->biBitCount;
|
avctx->bits_per_coded_sample = sh->bih->biBitCount;
|
||||||
|
|
||||||
avctx->thread_count = lavc_param->threads;
|
|
||||||
|
|
||||||
/* open it */
|
/* open it */
|
||||||
if (avcodec_open2(avctx, lavc_codec, NULL) < 0) {
|
if (avcodec_open2(avctx, lavc_codec, NULL) < 0) {
|
||||||
mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n");
|
mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n");
|
||||||
|
|
Loading…
Reference in New Issue