From patchwork Wed May 31 14:54:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41910 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp3327425pzb; Wed, 31 May 2023 07:55:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58PKA2CTmF81T++BQMVuc1sO1IcQOwIkm5AiFrd/XAUq0TPoWU2HkV5AjoXg6nzrtY72Ee X-Received: by 2002:a05:6512:98b:b0:4f1:2f5d:8679 with SMTP id w11-20020a056512098b00b004f12f5d8679mr2386984lft.22.1685544948109; Wed, 31 May 2023 07:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685544948; cv=none; d=google.com; s=arc-20160816; b=Bjwa5CTndU2Xb1hozjIJr3saic9+H8hV/OZsVQnAvWNZ8sT0nmhreNOSkXEHGJhqtp UuIof3y9kmgqR0wW4dhryoJpLa4phhEkMQ4yCJM6SqsPAjouMNL01q/OsK9Sg5JpO5z0 sAvwCzO8KGw60Km+RGXAyIE9eOSaB4BYln0Gn3fSU6P6tYMEJ8TGF0KO5ZY73k8MnZMh Ndf8/6g3iNodY4JnPQnkyo1sgC//itKQbwvT3hmwwgO4vgamHrxnVhWXwMjXdNJ7C42r K47TfQJQ9g+K5l99ujXby+h5IUNNIJWq/N8real8sIOWsZMAp+kS+1Gp8zrfWhBn1s/+ pqbA== 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:message-id:date:to:from :delivered-to; bh=ZmhToMlpXPShv74qCdYF0DgaH6BeBUB44tn4nelommM=; b=vyZNTsCTyOlWZINF7oNL4oxaSiHok3YaFAjE3myn4wNsk+4YhHrV4/Grp6RP8iCJYn r+Xv+SDc1UG6J0OjaQcFEsdM14vRVn2AgmRnqA0nHisjxj5j+oUI1/sqm8IL+h8cu8W/ 7aw+OABKCj1ukG/0X9CWfmpHfI9Fsu5l9zwPfor98BbAPnp+YUNWwJrIApxqelOG/4No Wj4S3W0QAbFD3Oc9nndkQZNAjTrm2sUZbGge1HeT8BAw19BPD4Dk2vmtSB3IdQF9hhnq 9nYkNXuP7hrClTv6sjOZBeUfhiVXVTcVb3GoEd7R0IAmP3Z5pDXtrVaPnM5WA6nA04Sp hAhQ== 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 c8-20020aa7d608000000b0050c5241edc6si8155295edr.630.2023.05.31.07.55.47; Wed, 31 May 2023 07:55:48 -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 3E21B68C296; Wed, 31 May 2023 17:55:17 +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 C780668C1CE for ; Wed, 31 May 2023 17:55:07 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9B5CE2404F5 for ; Wed, 31 May 2023 16:55:07 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 9ckN26hOGBMR for ; Wed, 31 May 2023 16:55:05 +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 52A26240177 for ; Wed, 31 May 2023 16:55:05 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C92943A0139 for ; Wed, 31 May 2023 16:54:59 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 31 May 2023 16:54:31 +0200 Message-Id: <20230531145453.20994-1-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/23] fftools/ffmpeg_enc: move nb_frames{dup, drop} globals into OutputStream 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: /QSuHpIAocfD --- The patchset is also available from branch 'ffmpeg_enc_tb' in git://git.khirnov.net/libav --- fftools/ffmpeg.c | 6 ++++-- fftools/ffmpeg.h | 6 +++--- fftools/ffmpeg_enc.c | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 36b4becaf2..bcda7570e9 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -119,8 +119,6 @@ typedef struct BenchmarkTimeStamps { static BenchmarkTimeStamps get_benchmark_time_stamps(void); static int64_t getmaxrss(void); -int64_t nb_frames_dup = 0; -int64_t nb_frames_drop = 0; unsigned nb_output_dumped = 0; static BenchmarkTimeStamps current_time; @@ -491,6 +489,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti int64_t pts = INT64_MIN + 1; static int64_t last_time = -1; static int first_report = 1; + uint64_t nb_frames_dup = 0, nb_frames_drop = 0; int hours, mins, secs, us; const char *hours_sign; int ret; @@ -536,6 +535,9 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti if (is_last_report) av_bprintf(&buf, "L"); + nb_frames_dup = ost->nb_frames_dup; + nb_frames_drop = ost->nb_frames_drop; + vid = 1; } /* compute min output value */ diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 966397270d..cef4b5d000 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -553,6 +553,9 @@ typedef struct OutputStream { Encoder *enc; AVCodecContext *enc_ctx; AVPacket *pkt; + + uint64_t nb_frames_dup; + uint64_t nb_frames_drop; int64_t last_dropped; /* video only */ @@ -707,9 +710,6 @@ extern int recast_media; extern FILE *vstats_file; -extern int64_t nb_frames_dup; -extern int64_t nb_frames_drop; - #if FFMPEG_OPT_PSNR extern int do_psnr; #endif diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 6c9cce252f..f3e291a9e4 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -1078,7 +1078,7 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) &nb_frames, &nb_frames_prev); if (nb_frames_prev == 0 && ost->last_dropped) { - nb_frames_drop++; + ost->nb_frames_drop++; av_log(ost, AV_LOG_VERBOSE, "*** dropping frame %"PRId64" at ts %"PRId64"\n", e->vsync_frame_number, e->last_frame->pts); @@ -1086,12 +1086,12 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) if (nb_frames > (nb_frames_prev && ost->last_dropped) + (nb_frames > nb_frames_prev)) { if (nb_frames > dts_error_threshold * 30) { av_log(ost, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", nb_frames - 1); - nb_frames_drop++; + ost->nb_frames_drop++; return; } - nb_frames_dup += nb_frames - (nb_frames_prev && ost->last_dropped) - (nb_frames > nb_frames_prev); + ost->nb_frames_dup += nb_frames - (nb_frames_prev && ost->last_dropped) - (nb_frames > nb_frames_prev); av_log(ost, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", nb_frames - 1); - if (nb_frames_dup > dup_warning) { + if (ost->nb_frames_dup > dup_warning) { av_log(ost, AV_LOG_WARNING, "More than %"PRIu64" frames duplicated\n", dup_warning); dup_warning *= 10; }