0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

player: print used number of threads in verbose mode

Also, don't use av_log() for mpv output.
This commit is contained in:
wm4 2015-01-05 12:17:55 +01:00
parent 862a1b6e7e
commit 0f4bf347c5
4 changed files with 8 additions and 6 deletions

View File

@ -136,7 +136,7 @@ static int init(struct dec_audio *da, const char *decoder)
if (sh->lav_headers)
mp_copy_lav_codec_headers(lavc_context, sh->lav_headers);
mp_set_avcodec_threads(lavc_context, opts->threads);
mp_set_avcodec_threads(da->log, lavc_context, opts->threads);
/* open it */
if (avcodec_open2(lavc_context, lavc_codec, NULL) < 0) {

View File

@ -126,19 +126,21 @@ void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb)
dst->dts = mp_pts_to_av(mpkt ? mpkt->dts : MP_NOPTS_VALUE, tb);
}
void mp_set_avcodec_threads(AVCodecContext *avctx, int threads)
void mp_set_avcodec_threads(struct mp_log *l, AVCodecContext *avctx, int threads)
{
if (threads == 0) {
threads = default_thread_count();
if (threads < 1) {
av_log(avctx, AV_LOG_WARNING, "Could not determine "
"thread count to use, defaulting to 1.\n");
mp_warn(l, "Could not determine thread count to use, defaulting to 1.\n");
threads = 1;
} else {
mp_verbose(l, "Detected %d logical cores.\n", threads);
}
// Apparently some libavcodec versions have or had trouble with more
// than 16 threads, and/or print a warning when using > 16.
threads = MPMIN(threads, 16);
}
mp_verbose(l, "Requesting %d threads for decoding.\n", threads);
avctx->thread_count = threads;
}

View File

@ -34,7 +34,7 @@ void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st);
void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb);
int64_t mp_pts_to_av(double mp_pts, AVRational *tb);
double mp_pts_from_av(int64_t av_pts, AVRational *tb);
void mp_set_avcodec_threads(AVCodecContext *avctx, int threads);
void mp_set_avcodec_threads(struct mp_log *l, AVCodecContext *avctx, int threads);
void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type);
int mp_codec_to_av_codec_id(const char *codec);
const char *mp_codec_from_av_codec_id(int codec_id);

View File

@ -372,7 +372,7 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
if (ctx->hwdec->init(ctx) < 0)
goto error;
} else {
mp_set_avcodec_threads(avctx, lavc_param->threads);
mp_set_avcodec_threads(vd->log, avctx, lavc_param->threads);
}
avctx->flags |= lavc_param->bitexact ? CODEC_FLAG_BITEXACT : 0;