From patchwork Mon Feb 26 16:09:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Rapp X-Patchwork-Id: 7744 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.181.170 with SMTP id m39csp1525969jaj; Mon, 26 Feb 2018 08:09:45 -0800 (PST) X-Google-Smtp-Source: AG47ELvIP2pwawrgos9y0Gi5pudkvEPGzM8oydR97Y2zIWgUmnsb+rW5w6RE0CLTq6xUh2AbLTxw X-Received: by 10.28.103.9 with SMTP id b9mr8637918wmc.44.1519661385237; Mon, 26 Feb 2018 08:09:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519661385; cv=none; d=google.com; s=arc-20160816; b=cfqk0mgmeQwNDg8+UBtA8tyeXuGUEPxyq2jEt0xzwORWU9nZhKiD5gblfSfGBN7Qeq UzPnfRt4mGrKeS3smFhVfFf16WCbam2TpY75LMPIpqV8MtbfW/7oKIh8ifR2pAxg9XWz OouH6XN0FvokGi6E8jVu1cio6ZZvDQq+hH6tvMR7WhsDd1MhHCisQdSuXBvU26fkDBxL HDdbcFGiIJNOK93axh1PNRW0+QPINW/nbwwyG/wuX35poENb8sK0x2Yw5cr4rvl9y6e7 tJbUOT9cUJZBtJugH03P8biO6WYRTcfAkSmXqZ69rCVlTo0DPjV3V4dEEyp60z8YQ97c jPiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=2IxyW/id5fcMzor3AmWOPL3mgu2WieI6lmlFGVEe6/E=; b=qptMe1Suh8SQFjgw9Wok5IZoRP+zUQud4Jburw+8CDevA1Xj6d6Cj0H/LGh5jtVLIK fl1j4xrt6IFmTS8sU62iSGhs5upfpptbJYcQbYBdUJeVljnWE9Zmag/brRh/NHaXZtNj ZOPq73mEvfdzJc5SwIs/kdSnqM9Q8WWCMVS0Sq2aSkhni5dqjlo6968LSU021Ohnw+2K N2siF9CGkC9LSgI26SYGf8yogbqHh1nnVV3HKyIEuXM4SumvEXSVzUiw26LzitXtj2Ej Od3y35zoe07PztR6JY+u6ARQKgGJPZuTvCtBncVug5NiE3QKveplDjZgHQJYEw+DyqIp oXXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n10si4970327wrh.425.2018.02.26.08.09.44; Mon, 26 Feb 2018 08:09:45 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 64D3C68A35E; Mon, 26 Feb 2018 18:09:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx02.mail.netstorage.at (mx02.mail.netstorage.at [89.207.146.155]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2D5EE68A2B1 for ; Mon, 26 Feb 2018 18:09:21 +0200 (EET) Received: from p1002.netstorage.at (p1002.netstorage.at [89.207.146.186]) by mx02.mail.netstorage.at (Postfix) with ESMTPS id 7D516ACC12 for ; Mon, 26 Feb 2018 17:09:06 +0100 (CET) Received: from mailix (noaport.de [46.237.252.213]) by p1002.netstorage.at (Postfix) with ESMTPA id 10ED480979 for ; Mon, 26 Feb 2018 17:09:06 +0100 (CET) Received: from frogstar-a.kuhnle.local (frogstar-a.kuhnle.local [192.168.0.26]) by mailix with ESMTPA ; Mon, 26 Feb 2018 17:09:06 +0100 From: Tobias Rapp To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Feb 2018 17:09:05 +0100 Message-Id: <1519661345-16991-2-git-send-email-t.rapp@noa-archive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519661345-16991-1-git-send-email-t.rapp@noa-archive.com> References: <20180226151155.4cffd3fc@debian> <1519661345-16991-1-git-send-email-t.rapp@noa-archive.com> X-PPP-Message-ID: <20180226160906.18862.58649@p1002.netstorage.at> X-PPP-Vhost: noa-archive.com X-NetStorage-MailScanner-Information: Please contact the ISP for more information X-NetStorage-MailScanner-ID: 7D516ACC12.A664D X-NetStorage-MailScanner: Found to be clean X-NetStorage-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (nicht zwischen gespeichert, Wertung=-0.5, benoetigt 6, autolearn=not spam, BAYES_00 -0.50) X-NetStorage-MailScanner-From: t.rapp@noa-archive.com X-Spam-Status: No Subject: [FFmpeg-devel] [PATCH v2 2/2] fftools/ffmpeg: update print_report to use AVBPrint API X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Tobias Rapp --- fftools/ffmpeg.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0097a7d..9654e07 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1658,8 +1658,7 @@ static void print_final_stats(int64_t total_size) static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time) { - char buf[1024]; - AVBPrint buf_script; + AVBPrint buf, buf_script; OutputStream *ost; AVFormatContext *oc; int64_t total_size; @@ -1696,8 +1695,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti if (total_size <= 0) // FIXME improve avio_size() so it works with non seekable output too total_size = avio_tell(oc->pb); - buf[0] = '\0'; vid = 0; + av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(&buf_script, 0, 1); for (i = 0; i < nb_output_streams; i++) { float q = -1; @@ -1707,7 +1706,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti q = ost->quality / (float) FF_QP2LAMBDA; if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q); + av_bprintf(&buf, "q=%2.1f ", q); av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n", ost->file_index, ost->index, q); } @@ -1716,21 +1715,21 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti frame_number = ost->frame_number; fps = t > 1 ? frame_number / t : 0; - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3.*f q=%3.1f ", + av_bprintf(&buf, "frame=%5d fps=%3.*f q=%3.1f ", frame_number, fps < 9.95, fps, q); av_bprintf(&buf_script, "frame=%d\n", frame_number); av_bprintf(&buf_script, "fps=%.1f\n", fps); av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n", ost->file_index, ost->index, q); if (is_last_report) - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L"); + av_bprintf(&buf, "L"); if (qp_hist) { int j; int qp = lrintf(q); if (qp >= 0 && qp < FF_ARRAY_ELEMS(qp_histogram)) qp_histogram[qp]++; for (j = 0; j < 32; j++) - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", av_log2(qp_histogram[j] + 1)); + av_bprintf(&buf, "%X", av_log2(qp_histogram[j] + 1)); } if ((enc->flags & AV_CODEC_FLAG_PSNR) && (ost->pict_type != AV_PICTURE_TYPE_NONE || is_last_report)) { @@ -1739,7 +1738,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti double scale, scale_sum = 0; double p; char type[3] = { 'Y','U','V' }; - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR="); + av_bprintf(&buf, "PSNR="); for (j = 0; j < 3; j++) { if (is_last_report) { error = enc->error[j]; @@ -1753,12 +1752,12 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti error_sum += error; scale_sum += scale; p = psnr(error / scale); - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], p); + av_bprintf(&buf, "%c:%2.2f ", type[j], p); av_bprintf(&buf_script, "stream_%d_%d_psnr_%c=%2.2f\n", ost->file_index, ost->index, type[j] | 32, p); } p = psnr(error_sum / scale_sum); - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum / scale_sum)); + av_bprintf(&buf, "*:%2.2f ", psnr(error_sum / scale_sum)); av_bprintf(&buf_script, "stream_%d_%d_psnr_all=%2.2f\n", ost->file_index, ost->index, p); } @@ -1775,18 +1774,15 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1; speed = t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1; - if (total_size < 0) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - "size=N/A "); - else snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - "size=%8.0fkB ", total_size / 1024.0); - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - "time=%s ", pts_to_hms_str(buf_pts, pts, 2)); + if (total_size < 0) av_bprintf(&buf, "size=N/A "); + else av_bprintf(&buf, "size=%8.0fkB ", total_size / 1024.0); + av_bprintf(&buf, "time=%s ", pts_to_hms_str(buf_pts, pts, 2)); if (bitrate < 0) { - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),"bitrate=N/A"); + av_bprintf(&buf, "bitrate=N/A"); av_bprintf(&buf_script, "bitrate=N/A\n"); }else{ - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),"bitrate=%6.1fkbits/s", bitrate); + av_bprintf(&buf, "bitrate=%6.1fkbits/s", bitrate); av_bprintf(&buf_script, "bitrate=%6.1fkbits/s\n", bitrate); } @@ -1800,28 +1796,28 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti av_bprintf(&buf_script, "out_time=%s\n", pts_to_hms_str(buf_pts, pts, 6)); if (nb_frames_dup || nb_frames_drop) - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d", - nb_frames_dup, nb_frames_drop); + av_bprintf(&buf, " dup=%d drop=%d", nb_frames_dup, nb_frames_drop); av_bprintf(&buf_script, "dup_frames=%d\n", nb_frames_dup); av_bprintf(&buf_script, "drop_frames=%d\n", nb_frames_drop); if (speed < 0) { - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf)," speed=N/A"); + av_bprintf(&buf, " speed=N/A"); av_bprintf(&buf_script, "speed=N/A\n"); } else { - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf)," speed=%4.3gx", speed); + av_bprintf(&buf, " speed=%4.3gx", speed); av_bprintf(&buf_script, "speed=%4.3gx\n", speed); } if (print_stats || is_last_report) { const char end = is_last_report ? '\n' : '\r'; if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) { - fprintf(stderr, "%s %c", buf, end); + fprintf(stderr, "%s %c", buf.str, end); } else - av_log(NULL, AV_LOG_INFO, "%s %c", buf, end); + av_log(NULL, AV_LOG_INFO, "%s %c", buf.str, end); fflush(stderr); } + av_bprint_finalize(&buf, NULL); if (progress_avio) { av_bprintf(&buf_script, "progress=%s\n",