From 0f4bf347c52543057404e5c36f504ab18b901dba Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 5 Jan 2015 12:17:55 +0100 Subject: player: print used number of threads in verbose mode Also, don't use av_log() for mpv output. --- audio/decode/ad_lavc.c | 2 +- common/av_common.c | 8 +++++--- common/av_common.h | 2 +- video/decode/vd_lavc.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index 8825172123..fd09eca0b7 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -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) { diff --git a/common/av_common.c b/common/av_common.c index cced1c0694..eb357d9f05 100644 --- a/common/av_common.c +++ b/common/av_common.c @@ -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; } diff --git a/common/av_common.h b/common/av_common.h index 3168d5310d..0b0260982f 100644 --- a/common/av_common.h +++ b/common/av_common.h @@ -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); diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 2716a848e7..ff2fa71131 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -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; -- cgit v1.2.3