From patchwork Wed May 11 08:16:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 35723 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp3780997pzb; Wed, 11 May 2022 01:17:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ6I1RDuGq98mUbdqBAkFNrdId+gtLukUgM1oyMW2K6JYlaoYd/yJiHGNJ9iqDfTjnxZDx X-Received: by 2002:a17:907:3e93:b0:6f4:e215:e293 with SMTP id hs19-20020a1709073e9300b006f4e215e293mr22716767ejc.629.1652257059965; Wed, 11 May 2022 01:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652257059; cv=none; d=google.com; s=arc-20160816; b=svcWjdhxKDmFlWCP0MK4+VUBMHdUi9m6nnX0u/f0Um+n6rpcL+J0ZPTomTQoJ3JGCT zlmkB0TeWZetsmtPMROmFnekEw71wovMrfO6HJ2MAhcLPrMghsnwLI1rjV+jUVyf/hEX T2YPyD+97WRt3vpaSET6fITwoqEY3/ozrKZaVI1OBjsMyjaotJDqBrBtqod1H6G8UwM+ GkYF1UXbsGo7BD2SekZQtYzlCKLilawijTo5UNy5UhRrJsGQ59/myNJmOeT64bAHV4CH sc5+sidqIL1+dbt7/3vwlgHFwtuoW1lcIkzvivyjuo4IM6BX+6OqncRwHohyIFDWKlir lrvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=SXU0/0i84gkG0P6Kn+Tt9nZSf0a4xqeCgaIJSf7St6I=; b=LX2mW7WZTRaJD8X/c7jpuIiQ0/925inAuAYFO4JcP3REtUwGmWs3vPqzbNO/LuhGR3 wZOhkVw9ZOnT2FmDEI6PxOd/fGGavE569EorMcxn0ii9zXgF4QdOJ5lXcoyUeewifenL YyefVMi0Njpzgc+ET9QG1qSwRHOAlGA25cpkAbNpj6OZ/LGO2UeamuwEonSHyvilt/ca XOMxxqDcNHpoQ3A+7VLzv7g3dAiG4GzGz59GAsN56D5AQh7VUDTtXeqdSDXfbCweQurg 8Y0HwsUZjrZd5rtGVsug2VTfWm/ol4PCVQ/RjRkX4ogwTi40Yh4XUo97Xtu59ecJ08kQ ON5Q== 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 hr40-20020a1709073fa800b006fa8f581b90si1632764ejc.771.2022.05.11.01.17.39; Wed, 11 May 2022 01:17:39 -0700 (PDT) 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 BF07F68B388; Wed, 11 May 2022 11:17:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5C91B68B236 for ; Wed, 11 May 2022 11:17:10 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id BE5632400F5 for ; Wed, 11 May 2022 10:17:09 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 1WJw3r90FPB6 for ; Wed, 11 May 2022 10:17:07 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 8F27D240179 for ; Wed, 11 May 2022 10:17:07 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id ABB0B3A0663; Wed, 11 May 2022 10:17:02 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 May 2022 10:16:49 +0200 Message-Id: <20220511081654.15127-4-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220511081654.15127-1-anton@khirnov.net> References: <20220511081654.15127-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/9] fftools/ffmpeg: drop a useless check and reduce indentation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: x3QHTw/OVnSW do_video_stats() is only ever called for video. --- fftools/ffmpeg.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 69b9c42822..2bc612f448 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1251,31 +1251,29 @@ static void do_video_stats(OutputStream *ost, int frame_size) } enc = ost->enc_ctx; - if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { - frame_number = ost->st->nb_frames; - if (vstats_version <= 1) { - fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, - ost->quality / (float)FF_QP2LAMBDA); - } else { - fprintf(vstats_file, "out= %2d st= %2d frame= %5d q= %2.1f ", ost->file_index, ost->index, frame_number, - ost->quality / (float)FF_QP2LAMBDA); - } - - if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR)) - fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width * enc->height * 255.0 * 255.0))); - - fprintf(vstats_file,"f_size= %6d ", frame_size); - /* compute pts value */ - ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base); - if (ti1 < 0.01) - ti1 = 0.01; - - bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0; - avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0; - fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", - (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate); - fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type)); - } + frame_number = ost->st->nb_frames; + if (vstats_version <= 1) { + fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, + ost->quality / (float)FF_QP2LAMBDA); + } else { + fprintf(vstats_file, "out= %2d st= %2d frame= %5d q= %2.1f ", ost->file_index, ost->index, frame_number, + ost->quality / (float)FF_QP2LAMBDA); + } + + if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR)) + fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width * enc->height * 255.0 * 255.0))); + + fprintf(vstats_file,"f_size= %6d ", frame_size); + /* compute pts value */ + ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base); + if (ti1 < 0.01) + ti1 = 0.01; + + bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0; + avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0; + fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", + (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate); + fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type)); } static void finish_output_stream(OutputStream *ost)