From patchwork Thu Dec 14 19:31:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45138 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp5185707pzf; Thu, 14 Dec 2023 11:33:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0Ppwsh/ISs4Rw4qYX5A7ZmqJ/iEvawGFlBmSnP3DSxaZf3DDxmUryOekTleHj3NbE8r55 X-Received: by 2002:a50:c90d:0:b0:552:1317:20cf with SMTP id o13-20020a50c90d000000b00552131720cfmr1546693edh.60.1702582389926; Thu, 14 Dec 2023 11:33:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702582389; cv=none; d=google.com; s=arc-20160816; b=hIyg5yd1PSXfg3vPD2m/uDwFKJMi2WFl+hfDL5WAl4dXgpl09mtxqbPOU/EzgiWGSs wOc3exOmhvS0ccNUcKoTZPH9w4PdoUUz3moGbNJfuQbIhEiDFDZf2zHBLl40EQjyOJLv nD0gzse5cfFOWOF4CZ0jHWbntBtksIBJ4936pJyX40aKDdzx9AaRlY5P130FTpADFXgw 0awxDcXtqVyUwMYHOExN1klaHxM3OxrTu6yIA+nB9aeuSTgmm7ep30oTv8vaW0602Gx7 5f09UC452xFLfFzg4xlzWrBZ4aIBSkACrfsHaZiqqvXblKtlisySst3GGYz2OwmGWGMT q8FA== 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=a0lLcQpaXX++qgpwaVEp6zkGCJ0y3NZLVOyv40OlrTI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=jDDIDXdxGpJqI5UhUZwZdAdNGjQwubEXhsB/2UPrKe6/Ysx/3qSzCnfivGGIwnL1w5 ljnvu4NPPtylac3CNSthnmtvtQd42Yj78IrFvyHu22yyJuqATsMxPxn71MRPqpYuE5Uv E4BbH6iSwAXgBz95XyWWixo+LczoZkEj9W8GIPQcS/9U6nfJfKQTavKsGmup91oOtMaZ z2jayiUafpClNbhlpFD6jZxE9RSZTtyrEITVJ1zheJsHIepfHdG88eMf0tCcW6tsg/24 cmLOv4fNHzAxDg7RMWgRf8f0kLYJpjMhZgHwGjcnC/mHt4APgMNvGKzfH5ONdMEGdPCX FB7g== 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 c10-20020a50f60a000000b005525b851e2esi1165760edn.75.2023.12.14.11.33.08; Thu, 14 Dec 2023 11:33:09 -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 6468668D293; Thu, 14 Dec 2023 21:32:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2587C68D25E for ; Thu, 14 Dec 2023 21:32:40 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id CB0DF1BA2 for ; Thu, 14 Dec 2023 20:32:39 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id xMo1mVIuKLbu for ; Thu, 14 Dec 2023 20:32:39 +0100 (CET) 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 mail1.khirnov.net (Postfix) with ESMTPS id 5E2C71783 for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 466D53A0336 for ; Thu, 14 Dec 2023 20:32:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Dec 2023 20:31:30 +0100 Message-ID: <20231214193138.2503-1-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg_mux: stop logging to AVFormatContext 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: vnmIDLQj6xPA Only the muxer itself is supposed to do that. Log to OutputStream instead. Drop now-redundant information from the logged string. --- fftools/ffmpeg_mux.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 8e523dd49d..74df6dcb64 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -176,9 +176,8 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) if (pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->dts > pkt->pts) { - av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n", - pkt->dts, pkt->pts, - mux->of.index, ost->st->index); + av_log(ost, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64", replacing by guess\n", + pkt->dts, pkt->pts); pkt->pts = pkt->dts = pkt->pts + pkt->dts + ms->last_mux_dts + 1 - FFMIN3(pkt->pts, pkt->dts, ms->last_mux_dts + 1) @@ -192,15 +191,15 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) int loglevel = max - pkt->dts > 2 || ost->type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG; if (exit_on_error) loglevel = AV_LOG_ERROR; - av_log(s, loglevel, "Non-monotonic DTS in output stream " - "%d:%d; previous: %"PRId64", current: %"PRId64"; ", - mux->of.index, ost->st->index, ms->last_mux_dts, pkt->dts); + av_log(ost, loglevel, "Non-monotonic DTS; " + "previous: %"PRId64", current: %"PRId64"; ", + ms->last_mux_dts, pkt->dts); if (exit_on_error) { ret = AVERROR(EINVAL); goto fail; } - av_log(s, loglevel, "changing to %"PRId64". This may result " + av_log(ost, loglevel, "changing to %"PRId64". This may result " "in incorrect timestamps in the output file.\n", max); if (pkt->pts >= pkt->dts) From patchwork Thu Dec 14 19:31: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: 45136 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp5185510pzf; Thu, 14 Dec 2023 11:32:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDh+3ZX731BC+ExYxSf+2+CYncn5E46MTdfxvKil8ZRoPk1t4e3aY9iZNA3dM6aA8YSwlH X-Received: by 2002:a1c:7213:0:b0:40c:25c8:12e1 with SMTP id n19-20020a1c7213000000b0040c25c812e1mr4841338wmc.12.1702582372161; Thu, 14 Dec 2023 11:32:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702582372; cv=none; d=google.com; s=arc-20160816; b=Ys1fuH1o2Rs7GnK6KL5AmvCnkJfAik/B68SHy4gDVPJ/RmAQtLZIaRslejf6BL8wuT 5prt5y3gUV94Gzq5R0EvafCnlVYMWvGJLxez07oKPhHamTeGjdjx8MtgmCRT7dVtsciE IWSJP9g41V590sMu20X9SoeDoPDkgb19Fx8YkF+goXruVuXYJEWAWgPCmpq//MEOnNZJ XnwWz/dkWA/PfJT8GAXMvK4gCpVnwWJ4me0icjlAN+4HixmPmHJa+0r3O76IHFI73tUF GItFGrqLnyTpZNhphbuXCgfCUW4UffgZja6BLiagTps8sBwwf68HiZJ7Q45tP5lAkZ1J uYiA== 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=5cqcHz/cu4mxJrjFyHPvqU0AuXWMZ3N5IgrkObXSi+4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=j2BNswmirSq1/wSIvOpwFnICbTKWoQ/D5B+o1ehXmhCfq7ZjXTRSLXVpirfABhgO0S gf3dNzSiLf52KzSQomhCFIXmcW7OXbXcfhsO7yXkYhCzXP8sz7rexJE1ZaxAzfA57XtJ sS+0jRlMGz8JZ7TaUL7shlGrDalZcN8xRpoKlwMF1KMLOckmlpZRqSI9j6KLHQTiZx12 CSVF7u5KrL9Ohyp/RpSwzTLi6u+kyOlYKfRa2BJydotWepNtbOwoCGCCSwHhtGpIU8kN LI704PXXzzsTPpbW11nbPWvC15glNvd5SP/RIc8T6JvILu3+t9VNNDBesWJR0InzYGBc 6R9A== 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 oq14-20020a170906cc8e00b00a1d53983286si6387320ejb.246.2023.12.14.11.32.50; Thu, 14 Dec 2023 11:32:52 -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 44BAD68D289; Thu, 14 Dec 2023 21:32:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 00E6068D23D for ; Thu, 14 Dec 2023 21:32:39 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 2099A1CCB for ; Thu, 14 Dec 2023 20:32:39 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id h8p21kLkpX_I for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) 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 mail1.khirnov.net (Postfix) with ESMTPS id 5C31113BB for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 539773A0585 for ; Thu, 14 Dec 2023 20:32:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Dec 2023 20:31:31 +0100 Message-ID: <20231214193138.2503-2-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214193138.2503-1-anton@khirnov.net> References: <20231214193138.2503-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg: deprecate -fps_mode/vsync drop 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: QAVu32mxQfvu It depends on the ability of muxers to generate timestamps, which is itself deprecated. --- doc/ffmpeg.texi | 3 --- fftools/ffmpeg.h | 3 +++ fftools/ffmpeg_filter.c | 9 +++++++-- fftools/ffmpeg_mux.c | 2 ++ fftools/ffmpeg_opt.c | 7 ++++++- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index c503963941..f157c06e12 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1742,9 +1742,6 @@ constant frame rate. @item vfr (2) Frames are passed through with their timestamp or dropped so as to prevent 2 frames from having the same timestamp. -@item drop -As passthrough but destroys all timestamps, making the muxer generate -fresh timestamps based on frame-rate. @item auto (-1) Chooses between cfr and vfr depending on muxer capabilities. This is the default method. diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index affa80856a..96f4e757e1 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -60,6 +60,7 @@ #define FFMPEG_OPT_ENC_TIME_BASE_NUM 1 #define FFMPEG_OPT_TOP 1 #define FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP 1 +#define FFMPEG_OPT_VSYNC_DROP 1 #define FFMPEG_ERROR_RATE_EXCEEDED FFERRTAG('E', 'R', 'E', 'D') @@ -69,7 +70,9 @@ enum VideoSyncMethod { VSYNC_CFR, VSYNC_VFR, VSYNC_VSCFR, +#if FFMPEG_OPT_VSYNC_DROP VSYNC_DROP, +#endif }; enum EncTimeBase { diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index bb755d7bb4..9fc877b437 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -2104,8 +2104,11 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, if (delta0 < 0 && delta > 0 && - ost->vsync_method != VSYNC_PASSTHROUGH && - ost->vsync_method != VSYNC_DROP) { + ost->vsync_method != VSYNC_PASSTHROUGH +#if FFMPEG_OPT_VSYNC_DROP + && ost->vsync_method != VSYNC_DROP +#endif + ) { if (delta0 < -0.6) { av_log(ost, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0); } else @@ -2143,7 +2146,9 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, ofp->next_pts = llrint(sync_ipts); frame->duration = llrint(duration); break; +#if FFMPEG_OPT_VSYNC_DROP case VSYNC_DROP: +#endif case VSYNC_PASSTHROUGH: ofp->next_pts = llrint(sync_ipts); frame->duration = llrint(duration); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 74df6dcb64..3ce4ef131e 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -150,8 +150,10 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) goto fail; } +#if FFMPEG_OPT_VSYNC_DROP if (ost->type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) pkt->pts = pkt->dts = AV_NOPTS_VALUE; +#endif // rescale timestamps to the stream timebase if (ost->type == AVMEDIA_TYPE_AUDIO && !ost->enc) { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 6177a96a4e..96d3c56fd7 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -188,7 +188,12 @@ int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_id if (!av_strcasecmp(arg, "cfr")) *vsync_var = VSYNC_CFR; else if (!av_strcasecmp(arg, "vfr")) *vsync_var = VSYNC_VFR; else if (!av_strcasecmp(arg, "passthrough")) *vsync_var = VSYNC_PASSTHROUGH; - else if (!av_strcasecmp(arg, "drop")) *vsync_var = VSYNC_DROP; +#if FFMPEG_OPT_VSYNC_DROP + else if (!av_strcasecmp(arg, "drop")) { + av_log(NULL, AV_LOG_WARNING, "-vsync/fps_mode drop is deprecated\n"); + *vsync_var = VSYNC_DROP; + } +#endif else if (!is_global && !av_strcasecmp(arg, "auto")) *vsync_var = VSYNC_AUTO; else if (!is_global) { av_log(NULL, AV_LOG_FATAL, "Invalid value %s specified for fps_mode of #%d:%d.\n", arg, file_idx, st_idx); From patchwork Thu Dec 14 19:31:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45144 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp5186201pzf; Thu, 14 Dec 2023 11:34:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFF1y44HFWGwt0DnjC8bx/O7oYbZvPDzspEWBk0jWTaAPMyadqmuBPIKac5202r4vHPftkb X-Received: by 2002:a17:907:a70f:b0:a00:211c:9a9a with SMTP id vw15-20020a170907a70f00b00a00211c9a9amr11460327ejc.5.1702582443251; Thu, 14 Dec 2023 11:34:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702582443; cv=none; d=google.com; s=arc-20160816; b=i5TY1tdNUb4p9aKc9FMbTEkuVppgJwpn/LfPB6PO3tnamymZcsGvF5MEjF/enFpG/9 WZlZlSYmzljJk1FFrrv+TCeEVTjDb0q0JCC2lzwU11LvciaftAsBL/0njBGnsFX62xJg rdlnzmrT2AdnCTTMjKJc0KnEwX9IA4NbOAEO2WIByixnUWwVMk7rjU03lvrdJlikw5Ot /OcmcjgtaEFfvTtIKJwogZ/T6naEhpUQ7ZQft5bg8oO4b0N+WP8RGGHcNTPCGHcdwtp7 kLW7rtC7aap0DHv4DH8sTRVDKv78fGSsMqZybYqrIV7Y2Oqpzxcphj6C37owQc+4kdOX teEQ== 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=TlFkn3TH9AtwGvU4GE8sUWFtEy8RjQ9TTSOlHQ60KDQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Nia8riciXpGwd4ZDBAFHb9mO7HFCsj+dSj2xffx8sxspq2q3MeP6OEvErYYtohAlIC HDLhhTr0oRJIQE1eYKrCrpsMhgoDgI/EJkaLpCiLn6wpY322vMtjWescKutrC0rWQbhY Xanxl+JHolp7BpeZua1lLMmGzQ8/uYOQqLe7hPfT5BkB/pEjgyTmMIMLQIq3Qx8z7sYK 2Cb89ej4UPZvhSSuMPYOCTe5W0qRsv1vfKU/AcnGLZXAdAM096e20ZvU6mnhemRbLJFI 8vGgAzbnmHEGPbOcEWDCvZLMjQD71GsfIy+pUmkCTq8f/HYfcMNkbwQuopmEtnlhd0bP 3LVQ== 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 s10-20020a170906284a00b00a1b31f8f717si6562548ejc.737.2023.12.14.11.34.01; Thu, 14 Dec 2023 11:34:03 -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 68C6A68D2B9; Thu, 14 Dec 2023 21:32:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5F5A768D29D for ; Thu, 14 Dec 2023 21:32:45 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 07F4B1783 for ; Thu, 14 Dec 2023 20:32:45 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id erc6jFvYs0oV for ; Thu, 14 Dec 2023 20:32:39 +0100 (CET) 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 mail1.khirnov.net (Postfix) with ESMTPS id 5F9621B9A for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5F36E3A05D0 for ; Thu, 14 Dec 2023 20:32:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Dec 2023 20:31:32 +0100 Message-ID: <20231214193138.2503-3-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214193138.2503-1-anton@khirnov.net> References: <20231214193138.2503-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/9] fftools/ffmpeg_mux: factor timestamps processing out of write_packet() 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: 0J8epvHeSLau --- fftools/ffmpeg_mux.c | 50 ++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 3ce4ef131e..88ce3cd60c 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -135,20 +135,9 @@ static void mux_log_debug_ts(OutputStream *ost, const AVPacket *pkt) pkt->size, *latency ? latency : "N/A"); } -static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) +static int mux_fixup_ts(Muxer *mux, MuxStream *ms, AVPacket *pkt) { - MuxStream *ms = ms_from_ost(ost); - AVFormatContext *s = mux->fc; - int64_t fs; - uint64_t frame_num; - int ret; - - fs = filesize(s->pb); - atomic_store(&mux->last_filesize, fs); - if (fs >= mux->limit_filesize) { - ret = AVERROR_EOF; - goto fail; - } + OutputStream *ost = &ms->ost; #if FFMPEG_OPT_VSYNC_DROP if (ost->type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) @@ -174,7 +163,7 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) av_packet_rescale_ts(pkt, pkt->time_base, ost->st->time_base); pkt->time_base = ost->st->time_base; - if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { + if (!(mux->fc->oformat->flags & AVFMT_NOTIMESTAMPS)) { if (pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->dts > pkt->pts) { @@ -188,7 +177,7 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) if ((ost->type == AVMEDIA_TYPE_AUDIO || ost->type == AVMEDIA_TYPE_VIDEO || ost->type == AVMEDIA_TYPE_SUBTITLE) && pkt->dts != AV_NOPTS_VALUE && ms->last_mux_dts != AV_NOPTS_VALUE) { - int64_t max = ms->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT); + int64_t max = ms->last_mux_dts + !(mux->fc->oformat->flags & AVFMT_TS_NONSTRICT); if (pkt->dts < max) { int loglevel = max - pkt->dts > 2 || ost->type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG; if (exit_on_error) @@ -197,8 +186,7 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) "previous: %"PRId64", current: %"PRId64"; ", ms->last_mux_dts, pkt->dts); if (exit_on_error) { - ret = AVERROR(EINVAL); - goto fail; + return AVERROR(EINVAL); } av_log(ost, loglevel, "changing to %"PRId64". This may result " @@ -212,14 +200,36 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) } ms->last_mux_dts = pkt->dts; + if (debug_ts) + mux_log_debug_ts(ost, pkt); + + return 0; +} + +static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) +{ + MuxStream *ms = ms_from_ost(ost); + AVFormatContext *s = mux->fc; + int64_t fs; + uint64_t frame_num; + int ret; + + fs = filesize(s->pb); + atomic_store(&mux->last_filesize, fs); + if (fs >= mux->limit_filesize) { + ret = AVERROR_EOF; + goto fail; + } + + ret = mux_fixup_ts(mux, ms, pkt); + if (ret < 0) + goto fail; + ms->data_size_mux += pkt->size; frame_num = atomic_fetch_add(&ost->packets_written, 1); pkt->stream_index = ost->index; - if (debug_ts) - mux_log_debug_ts(ost, pkt); - if (ms->stats.io) enc_stats_write(ost, &ms->stats, NULL, pkt, frame_num); From patchwork Thu Dec 14 19:31:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45139 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp5185775pzf; Thu, 14 Dec 2023 11:33:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/9lrOSSBp900nSLSA3+kEIw+uJwJF3ljPmwxfu1ZHbo5niBNlpoIANiIQUdTJhAfDGRut X-Received: by 2002:a17:906:aac8:b0:a1c:d0f7:3f7a with SMTP id kt8-20020a170906aac800b00a1cd0f73f7amr4770931ejb.43.1702582397373; Thu, 14 Dec 2023 11:33:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702582397; cv=none; d=google.com; s=arc-20160816; b=xgTAV8xJjWEQy+zIz+0iE4WiHHH7hPPqmsUJ3J2JhNaIuCEOubqu6Xmz230qnerIZK zOVj6aCOxaxoVfNhIxPhdodkVI2H1NMNROC9d/qzBjXEk39iUCffbQQwxJzOBvIBkmAR HmBmmwvvOoMUyXvntFANLRp/mzHUg9iqMR9kyg/XoaOsU0EhjQD1sZlzJk/KBK54bU4b 0FSNOl7AOyFeQy6taT4FuJz6OkJu6m0VPEyEC328ziTqDX6BghF2VV333GnTXfW6vI10 YMfdM0eegmNrRODKxS2PFEYgjUFlnLMLe45/x9cBX4YN6g1XlwND+GWNnAZN5WBO3RZR pFcQ== 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=c6ys6A7U7DocUTD7R+d7zP2FTwDS+BZ3qTfzzAzdwV8=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=lxOWCQW1r7fGsZPjpzy8rzTJRXvXLla71omYpXmUhx4Gd38SAbk8zjxUIuzcFOHp7B jJ0YvImaDy+RXi+BnPEo31KMi+l26sNkMF2VYIKkRfGMoo1jiKtinmVZtF+alaVzEX+v l+P8l56pt87cJ5KPR6N+Tsfx1zChvyEoRbKE97XkwXKgCLZbsQshz9pC5JuN1AZrZcsk 6c1ZO1xd6z57wfxHzX3CvMDGz/7ArSzfL973BcJeCXyo3SUhfU/BcNgFN402BvclOuXd Tp/Ro90SnD3hiITVHCt1LYCrtg0re9Em8W296xPLSaE14GnOQP5J1/Pd8KYq1J9Qr8X7 dQXA== 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 q26-20020a1709064c9a00b00a1f78a5b5c1si6129168eju.613.2023.12.14.11.33.16; Thu, 14 Dec 2023 11:33:17 -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 7A09868D294; Thu, 14 Dec 2023 21:32:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1995668D28F for ; Thu, 14 Dec 2023 21:32:44 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id B1C671CBD for ; Thu, 14 Dec 2023 20:32:43 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id X29mnpYJQL-Z for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) 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 mail1.khirnov.net (Postfix) with ESMTPS id 619ED1BA1 for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 6AEC43A0613 for ; Thu, 14 Dec 2023 20:32:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Dec 2023 20:31:33 +0100 Message-ID: <20231214193138.2503-4-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214193138.2503-1-anton@khirnov.net> References: <20231214193138.2503-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/9] fftools/cmdutils: change option flags to (1 << N) style 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: DD93PXa/0huv It is easier to read. --- fftools/cmdutils.h | 47 ++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 8b67d827cc..85479f90e4 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -106,28 +106,31 @@ typedef struct SpecifierOpt { typedef struct OptionDef { const char *name; int flags; -#define HAS_ARG 0x0001 -#define OPT_BOOL 0x0002 -#define OPT_EXPERT 0x0004 -#define OPT_STRING 0x0008 -#define OPT_VIDEO 0x0010 -#define OPT_AUDIO 0x0020 -#define OPT_INT 0x0080 -#define OPT_FLOAT 0x0100 -#define OPT_SUBTITLE 0x0200 -#define OPT_INT64 0x0400 -#define OPT_EXIT 0x0800 -#define OPT_DATA 0x1000 -#define OPT_PERFILE 0x2000 /* the option is per-file (currently ffmpeg-only). - implied by OPT_OFFSET or OPT_SPEC */ -#define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */ -#define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt. - Implies OPT_OFFSET. Next element after the offset is - an int containing element count in the array. */ -#define OPT_TIME 0x10000 -#define OPT_DOUBLE 0x20000 -#define OPT_INPUT 0x40000 -#define OPT_OUTPUT 0x80000 +#define HAS_ARG (1 << 0) +#define OPT_BOOL (1 << 1) +#define OPT_EXPERT (1 << 2) +#define OPT_STRING (1 << 3) +#define OPT_VIDEO (1 << 4) +#define OPT_AUDIO (1 << 5) +#define OPT_INT (1 << 6) +#define OPT_FLOAT (1 << 7) +#define OPT_SUBTITLE (1 << 8) +#define OPT_INT64 (1 << 9) +#define OPT_EXIT (1 << 10) +#define OPT_DATA (1 << 11) +/* The option is per-file (currently ffmpeg-only). + implied by OPT_OFFSET or OPT_SPEC */ +#define OPT_PERFILE (1 << 12) +/* Option is specified as an offset in a passed optctx */ +#define OPT_OFFSET (1 << 13) +/* Option is to be stored in an array of SpecifierOpt. Implies OPT_OFFSET. + Next element after the offset is an int containing element count in the + array. */ +#define OPT_SPEC (1 << 14) +#define OPT_TIME (1 << 15) +#define OPT_DOUBLE (1 << 16) +#define OPT_INPUT (1 << 17) +#define OPT_OUTPUT (1 << 18) union { void *dst_ptr; int (*func_arg)(void *, const char *, const char *); From patchwork Thu Dec 14 19:31:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45137 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp5185612pzf; Thu, 14 Dec 2023 11:33:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3PNhkMoQmgLH/9GYLjFYYn7dPxwtXYvGZ1PUzevdh27w16YJHSkEMWBpIC63V8vz8iOFo X-Received: by 2002:a17:906:ba86:b0:9f2:3e76:5d39 with SMTP id cu6-20020a170906ba8600b009f23e765d39mr12115844ejd.0.1702582380975; Thu, 14 Dec 2023 11:33:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702582380; cv=none; d=google.com; s=arc-20160816; b=AH/7aF2ExMH6KwB01uAkTxOcChc1k2khPKOl5mH62O8qkiX/wbvlGAMw9NR+JsIpVQ mhhuoGP7D3MKDUBS7Tzue5DpJREw9N9DknkoxWWNQxs5Q5JoTWOI8rW3m1bM8bCGEhhs CUPTWazLoBLn0jFAWAeiNlSs7RN6OMAUTOkBQiqbSLXkzrGeGyEM2r1pGM9wjpjrXPWG +tpxucYiV7MlUUoFU5j2jiu+Egg5mSG64YvLaGrniz0/NThMQzMgRgzEgNR/5ugQTGR5 1Tc+s8hkW4z8Ti4/oHa+gUnY+DGgRzJGz754/utaqXJUWTs+i6N3Gwun0LoegmpKQFK8 SkPQ== 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=odWEmfwizhZ8lBPOhRiU3UhMiRs1yZsfD6C6jUzS1Xk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=BYXY7G0OKPvScg019FDVa+Laq2SkCyXQTUIeBCkDLooack4imC6In0rjkefsNTTmqo nVVj6QRpDtN7bv1YzNYimJ6+sW6Qt91tTpQTnoYuSfYDw/nTUIrOAGYOCf+TEhb0oQfm zJMSxjfqB/nMMJ3LrvynPQ1zXpOe6EeKDlwER0w34qWItPIVj/3mEi0Tg8Gpe5R4yP1w Th9Tvi+bSTZtDByAfLut6vMMmpOJeAqE4X2wUu5qBXJByEhQ1Tgio0IEnWOv41EqqdIM 0zTAGUXBtcaiWFy9BDK7d8fsFoRMYgZDlWI3uMN1Ryf4G7bfcEnhoSeW6rkctrxGh056 tRSQ== 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 u10-20020a17090657ca00b00a1d2851c02dsi6385794ejr.301.2023.12.14.11.32.59; Thu, 14 Dec 2023 11:33:00 -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 6D45F68D28C; Thu, 14 Dec 2023 21:32:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 03FA268D241 for ; Thu, 14 Dec 2023 21:32:39 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 6E31713BB for ; Thu, 14 Dec 2023 20:32:39 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 6hnlv4_r_ZqR for ; Thu, 14 Dec 2023 20:32:39 +0100 (CET) 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 mail1.khirnov.net (Postfix) with ESMTPS id 643ED1BA2 for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 76AC73A067E for ; Thu, 14 Dec 2023 20:32:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Dec 2023 20:31:34 +0100 Message-ID: <20231214193138.2503-5-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214193138.2503-1-anton@khirnov.net> References: <20231214193138.2503-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/9] fftools/ffmpeg_mux_init: change 1-bit bitfields from int to unsigned 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: Ik1+F2v11tsy They cannot store 1 as signed, only 0 and -1. Avoids warnings such as: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] --- fftools/ffmpeg_mux_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index f527a083db..f870d48136 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -288,9 +288,9 @@ static int enc_stats_init(OutputStream *ost, EncStats *es, int pre, static const struct { enum EncStatsType type; const char *str; - int pre_only:1; - int post_only:1; - int need_input_data:1; + unsigned pre_only:1; + unsigned post_only:1; + unsigned need_input_data:1; } fmt_specs[] = { { ENC_STATS_FILE_IDX, "fidx" }, { ENC_STATS_STREAM_IDX, "sidx" }, From patchwork Thu Dec 14 19:31:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45140 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp5185855pzf; Thu, 14 Dec 2023 11:33:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFP9VfENa/wUsg36m29CNsDtgRCDVNDc4aeKjxMyxfO1WfxxIOFneFSLM94JSja2KDM59RH X-Received: by 2002:a17:907:d404:b0:a01:b8e5:d4b7 with SMTP id vi4-20020a170907d40400b00a01b8e5d4b7mr10144045ejc.1.1702582407398; Thu, 14 Dec 2023 11:33:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702582407; cv=none; d=google.com; s=arc-20160816; b=aWWRfxY3KlWY3aQVIrlRJLZLzo+q1MQt4ucWP50dNzRcX17BsCZ0p6s5LBQrHhbbE8 btplSL88cnn8Kx4MyFIWtKWJkld0rWaUb8U8BT6tP6vDfbUvIFHnBwRGWGe7Y7Ozy51S DLWilgi8EX6kcIjpkqCNtOw/Imggw5oqn3rlG4PsaDrSTXNfOSACrI//e61vt4X9SaMJ 6dN2Q6vAwOlAJf2WEO6q99NsTBmrjq4Zseuvi6oZztVITM2XdIvd87yxOx0IpvLur1GD 5nVsZVybX7omWNdJS+srOxf0LgAgdwxCcMVsxOzcOvVbmI2Z1b2faoi1aBITQuJM1mJA wGXg== 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=MtkRr0fEYa2KGpflyFVK6rBZDodzQkiuzXW+behzqqE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=WQus+VE058+sQxuWPgG+i8bXMmMBcBeVKCuU8igD0zyY7+nbtooeh/JJUb/dLQAyeg VrqJm8VDr/1zJNmYQAZMFF8U4HQylPySQtdaLyvRCf5dHuoJDvK5WQFe3eh5A53uNUe7 rZBJ0v8VWBi7JDeOhR/WN8dkrdFJ8/jN241tX900zE2/ybBEXe1k44KddLg1LplxbsHe i/tc0V9QEogQ1JuWp4xhCNcyGrkf7gtS25GxjkDxkojH485iGdRgWBNC5lcl6+U1W6GS Hw+uLi41JvbJTQtEjz5vAQuvsN7mX6FcTjiSJCqYxWBNVILCk+IU+lcpxQ5l1aBnQ14g MPbQ== 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 q6-20020a170906a08600b00a1fa722b858si3557255ejy.981.2023.12.14.11.33.25; Thu, 14 Dec 2023 11:33:27 -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 8A8EC68D2A9; Thu, 14 Dec 2023 21:32:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6261568D292 for ; Thu, 14 Dec 2023 21:32:44 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 1423D1BA1 for ; Thu, 14 Dec 2023 20:32:44 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 7bz2A8TlNtgn for ; Thu, 14 Dec 2023 20:32:43 +0100 (CET) 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 mail1.khirnov.net (Postfix) with ESMTPS id 842581BA3 for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 826813A0688 for ; Thu, 14 Dec 2023 20:32:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Dec 2023 20:31:35 +0100 Message-ID: <20231214193138.2503-6-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214193138.2503-1-anton@khirnov.net> References: <20231214193138.2503-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: print keyframe information with -stats_* 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: 6IX3Ldq6VazR --- doc/ffmpeg.texi | 3 +++ fftools/ffmpeg.h | 1 + fftools/ffmpeg_enc.c | 2 ++ fftools/ffmpeg_mux_init.c | 1 + 4 files changed, 7 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index f157c06e12..059102b75a 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -2207,6 +2207,9 @@ Current bitrate in bits per second. Post-encoding only. @item abr (@emph{packet}) Average bitrate for the whole stream so far, in bits per second, -1 if it cannot be determined at this point. Post-encoding only. + +@item key (@emph{packet}) +Character 'K' if the packet contains a keyframe, character 'N' otherwise. @end table Directives tagged with @emph{packet} may only be used with diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 96f4e757e1..03dbb528c0 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -465,6 +465,7 @@ enum EncStatsType { ENC_STATS_PKT_SIZE, ENC_STATS_BITRATE, ENC_STATS_AVG_BITRATE, + ENC_STATS_KEYFRAME, }; typedef struct EncStatsComponent { diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 9141dab6a4..d774a7e008 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -520,6 +520,8 @@ void enc_stats_write(OutputStream *ost, EncStats *es, case ENC_STATS_DTS: avio_printf(io, "%"PRId64, pkt->dts); continue; case ENC_STATS_DTS_TIME: avio_printf(io, "%g", pkt->dts * av_q2d(tb)); continue; case ENC_STATS_PKT_SIZE: avio_printf(io, "%d", pkt->size); continue; + case ENC_STATS_KEYFRAME: avio_write(io, (pkt->flags & AV_PKT_FLAG_KEY) ? + "K" : "N", 1); continue; case ENC_STATS_BITRATE: { double duration = FFMAX(pkt->duration, 1) * av_q2d(tb); avio_printf(io, "%g", 8.0 * pkt->size / duration); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index f870d48136..0203701d78 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -309,6 +309,7 @@ static int enc_stats_init(OutputStream *ost, EncStats *es, int pre, { ENC_STATS_PKT_SIZE, "size", 0, 1 }, { ENC_STATS_BITRATE, "br", 0, 1 }, { ENC_STATS_AVG_BITRATE, "abr", 0, 1 }, + { ENC_STATS_KEYFRAME, "key", 0, 1 }, }; const char *next = fmt_spec; From patchwork Thu Dec 14 19:31:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45141 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp5185931pzf; Thu, 14 Dec 2023 11:33:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6QosU3JqciKCodEOexI0W9Ooje/Q1DuEnoKdDaRqiO3i0+OOXPMOPWzyXkhMqRPL5DzCI X-Received: by 2002:a17:907:b5a2:b0:a1f:6ead:c119 with SMTP id qx34-20020a170907b5a200b00a1f6eadc119mr10655267ejc.21.1702582415268; Thu, 14 Dec 2023 11:33:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702582415; cv=none; d=google.com; s=arc-20160816; b=lViQzyLfs7EyZ2hN7ZV6vHG+3aYLDAeGm6M/E4eKWqGpYj3dTkUR5eGBeBrBVXLA+q eGv+sPUtAI/Ob0w4OB0NRSFeU5vNtCi/zbUC6xXL2wBsMrWG8+Br6MoUDpQLRR7u8iFr jygzFvCvAVOPUvpveJMSPtNMWvAhs7SKETnf/eP4YnrRE2R1hsuIu+IXMHOph9qvPevQ 6zkOloVAjV+6wVvoXDsFevmK1umFhzUybmFEvHlNxXqmulRYIMBKnRjBJpZfuuXYmeG3 gTTqb+XDN8naJylZ7mYptu8xHlGTOYLIRO7Oy7g8BQk9d09UDYL7C4L9cxqSfZiqCs8Z JDTg== 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=ZXPIdUaSOnAX3n3QnwYZQrgySzXxRQhtWEzWjs9ssy0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=T1rTExSBsVkQW4QcrcBc2AME+IgTXyp73+tO/NLqucX+vc8FeMxQj3LqMIBbt24yuI IKhMJgeLl9AtoKUY/mDpJI3aa66qtKwzTdqNGy+oAlOwIjzSs+h0VMQ/KDDfPYHHQM8v 5Ta3U7fEof9b4qAqoUA9Xzt8mTejDY9H3OfDBHRPO8oss1123bzFIXnU+7OHKS8ElVJb 3zwIeGYvuHF9qFvWF8w1X3RX8YCLawjO0nsTlr3uI4KiRwOSPNcRb0LfRw1RfrmOhypo zlG/vJWq++vqkOyrbBI5jq/MOYXnCnflhBi66DrXDsDOGz/MRdcYDP4rgqjoKPoTELTr 6M2w== 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 o5-20020a1709062e8500b00a1ce99ee462si6338621eji.267.2023.12.14.11.33.34; Thu, 14 Dec 2023 11:33:35 -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 9306668D2A7; Thu, 14 Dec 2023 21:32:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 49D9A68D23D for ; Thu, 14 Dec 2023 21:32:45 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 5852A1BA3 for ; Thu, 14 Dec 2023 20:32:44 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 4aCVQbV1zL7k for ; Thu, 14 Dec 2023 20:32:44 +0100 (CET) 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 mail1.khirnov.net (Postfix) with ESMTPS id 8D0801BA4 for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8E5BC3A06A6 for ; Thu, 14 Dec 2023 20:32:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Dec 2023 20:31:36 +0100 Message-ID: <20231214193138.2503-7-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214193138.2503-1-anton@khirnov.net> References: <20231214193138.2503-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/9] doc/ffmpeg: drop misleading claims from -stats_*_fmt 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: ZnMpRqd82UXh The {br}/{abr} directives are not limited to post-encoding, they can also be used pre-muxing. The already-present {packet} tag describes this more accurately, so just drop the assertions. --- doc/ffmpeg.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 059102b75a..6ecd5f3cfe 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -2202,11 +2202,11 @@ Number of audio samples in the frame. Size of the encoded packet in bytes. @item br (@emph{packet}) -Current bitrate in bits per second. Post-encoding only. +Current bitrate in bits per second. @item abr (@emph{packet}) Average bitrate for the whole stream so far, in bits per second, -1 if it cannot -be determined at this point. Post-encoding only. +be determined at this point. @item key (@emph{packet}) Character 'K' if the packet contains a keyframe, character 'N' otherwise. From patchwork Thu Dec 14 19:31:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45143 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp5186103pzf; Thu, 14 Dec 2023 11:33:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0MYM6mVCIJjur4ePVpuCETkyXEa4rxEJBiM0W5C9Mlp6pKkSbtDdzt083YTusQqBlcJcq X-Received: by 2002:a17:907:7246:b0:a1e:91ab:ba2d with SMTP id ds6-20020a170907724600b00a1e91abba2dmr6490392ejc.110.1702582433729; Thu, 14 Dec 2023 11:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702582433; cv=none; d=google.com; s=arc-20160816; b=oKagBnNOYTh9Tq/s5eGc1KixiUdullUdY8q+T+PuKtXUwGbbegEIX27LpkX231gsAG PPkGHhpfsT1XrMXjrgpY2IxDQb2gmJZhX4YxbluW7N3+ei9LLJCQ/AAnOCLHOCXoq+6L lqYCj69FojyP8+eQQ96oMfH4DXW1wIarA6r9UMsBz7ZQyYwTeUHKXXm724Yp9HzpFmCn kvJepu8pJ5wgUNKQpquog0fhuhPAMKpO7jGvn47ONXJLK0UNxPI2/P/2Bq53BPlCSAGE uFpIdezdMyyfzP5PwnthgGHuVC7rxfog3i63nZFSIt+Mf+XGywHk9GoCiTwh6XSjZO4y 9YPw== 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=g2aQXv/RXoUtvUFJtnsaMdEyGJVAoXFAGXv4AC+dehk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=FulGtys8qVS6sQJWfbixqUarHol99Ye2hmilhEwOHK225Vo4Y1Wv7GXr8UIBp5Cv5f py+9cgnd5A2FlP8vc8fty0hk4ZsupcUZFdaywgmpco9Y6WZezB7Da5oVvNMGl8psI6I6 01/8Mky1cjQ82/0ila/O/68Z5uhe6G7N9DyLEDgVbdiy5m0KCG8699GbZGj1gXbgYbGi dQNUR8t54SrvNspf/AOPbmMR8cLlNkQ5e4YMydvsr1LvU2Nb2VdjDBqaKTwRN4SNqpDk eGFAdx4220OJdjcGhdIk3ecUN942jeFX3zXL+mifWdhBodZKp7y9tvdzKU1xDVOBL1mz cwfg== 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 p23-20020a170906229700b00a1d1f6bb285si6364943eja.443.2023.12.14.11.33.53; Thu, 14 Dec 2023 11:33:53 -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 707CA68D2B2; Thu, 14 Dec 2023 21:32:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5E0A468D29C for ; Thu, 14 Dec 2023 21:32:45 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id F24D51CAF for ; Thu, 14 Dec 2023 20:32:44 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Jf6PBk6WcJvT for ; Thu, 14 Dec 2023 20:32:44 +0100 (CET) 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 mail1.khirnov.net (Postfix) with ESMTPS id 945C41C9B for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 99C993A0706 for ; Thu, 14 Dec 2023 20:32:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Dec 2023 20:31:37 +0100 Message-ID: <20231214193138.2503-8-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214193138.2503-1-anton@khirnov.net> References: <20231214193138.2503-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg_mux: deduplicate uniniting EncStats 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: CRIRFqPTE8rq --- fftools/ffmpeg_mux.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 88ce3cd60c..357f34172f 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -773,6 +773,13 @@ int of_write_trailer(OutputFile *of) return mux_result; } +static void enc_stats_uninit(EncStats *es) +{ + for (int i = 0; i < es->nb_components; i++) + av_freep(&es->components[i].str); + av_freep(&es->components); +} + static void ost_free(OutputStream **post) { OutputStream *ost = *post; @@ -818,17 +825,9 @@ static void ost_free(OutputStream **post) av_freep(&ost->enc_ctx->stats_in); avcodec_free_context(&ost->enc_ctx); - for (int i = 0; i < ost->enc_stats_pre.nb_components; i++) - av_freep(&ost->enc_stats_pre.components[i].str); - av_freep(&ost->enc_stats_pre.components); - - for (int i = 0; i < ost->enc_stats_post.nb_components; i++) - av_freep(&ost->enc_stats_post.components[i].str); - av_freep(&ost->enc_stats_post.components); - - for (int i = 0; i < ms->stats.nb_components; i++) - av_freep(&ms->stats.components[i].str); - av_freep(&ms->stats.components); + enc_stats_uninit(&ost->enc_stats_pre); + enc_stats_uninit(&ost->enc_stats_post); + enc_stats_uninit(&ms->stats); av_freep(post); } From patchwork Thu Dec 14 19:31:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45142 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp5186049pzf; Thu, 14 Dec 2023 11:33:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBy5jJVOwlsGvIWpLLvqPB/JITIH6yJnQzHGD5oU7rzAct2TO0utev//TKHAEs44KvmAJl X-Received: by 2002:a17:906:c258:b0:a19:a19b:c701 with SMTP id bl24-20020a170906c25800b00a19a19bc701mr4977933ejb.81.1702582428869; Thu, 14 Dec 2023 11:33:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702582428; cv=none; d=google.com; s=arc-20160816; b=JE2kq2onVZO0aIYUM5YPvzgy8UVoVltn7lk44bmCEEoght7oZ2cbO07Re9sH4vMuVn kYqXxh6JDnyjn3rc19eiuh/JiNZE7uI0nI5Pcck1MwC0KrJVOiYDZw6UFLu0Ekm6gtb5 M6k2K0IT+ec+jWnpxJM6r1Jn4+znnnTOl2xWn9sPOtAqqa7Aaoby/FOozaoQM7olneGX UlUe/0SlCzh8owPgb6tV6pwujgOVwq/23yp0KtwR97f2y6sfBxsZ8XHgoNu7tZK2RPqy qd/jaTil7oEFu8cScB62G5hT4NDNmhqkS6LNnbY7u8lorXdJgclk3qVNwEIpNuka3c1U hfzg== 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=lOiQ9UanJWPphkDa15C9CAjPxB0hkhu8QimNIdFDrJI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=BOuhYr3pOY2NOEGlzhzsBbkBYvJVRV6vmXAebcQMPa6FJKvxqS6KdrAv37OmTe0sdf HX0HDnep8jv/mIm+O9ZMOsR3+gJlfIFTSJSEzrEYL+FOa7ybDj0smoFXAyWHba/3laem 6E1H0diardJJv5xMVhWxTtMDD1kYIx06uz0CVBTmmL5zUq44t0TLtVlXrlCKXdGNc1ge KkwDcx8eIcuylhJuSSFXQkw+0k3vOzQyv0Sj9zQwksVaVyP6Juw5cmQ66iXxFP4vI7Z/ 1vgXZVigJbr6UwCPLinBE880FYXgZttmm0sIvOlMMRmiMNvcGhPX/8zUc9S8TnScZTrF fc/Q== 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 s11-20020a170906bc4b00b00a1dda250ee2si6876846ejv.0.2023.12.14.11.33.43; Thu, 14 Dec 2023 11:33:48 -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 8A87E68D2B0; Thu, 14 Dec 2023 21:32:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4FACD68D28B for ; Thu, 14 Dec 2023 21:32:45 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id AF8C71BA4 for ; Thu, 14 Dec 2023 20:32:44 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id YtTayiXFWUNG for ; Thu, 14 Dec 2023 20:32:44 +0100 (CET) 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 mail1.khirnov.net (Postfix) with ESMTPS id 947221CAF for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A58BD3A073A for ; Thu, 14 Dec 2023 20:32:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Dec 2023 20:31:38 +0100 Message-ID: <20231214193138.2503-9-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214193138.2503-1-anton@khirnov.net> References: <20231214193138.2503-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 9/9] fftools/ffmpeg: use a mutex for enc_stats_write() 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: nAccYDy4NeRB It may be called concurrently from different threads to write into the same file. --- fftools/ffmpeg.h | 3 +++ fftools/ffmpeg_enc.c | 4 ++++ fftools/ffmpeg_mux.c | 4 ++++ fftools/ffmpeg_mux_init.c | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 03dbb528c0..33a29b316f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -480,6 +480,9 @@ typedef struct EncStats { int nb_components; AVIOContext *io; + + pthread_mutex_t lock; + int lock_initialized; } EncStats; extern const char *const forced_keyframes_const_names[]; diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index d774a7e008..57590a43a3 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -491,6 +491,8 @@ void enc_stats_write(OutputStream *ost, EncStats *es, ptsi = fd->dec.pts; } + pthread_mutex_lock(&es->lock); + for (size_t i = 0; i < es->nb_components; i++) { const EncStatsComponent *c = &es->components[i]; @@ -538,6 +540,8 @@ void enc_stats_write(OutputStream *ost, EncStats *es, } avio_w8(io, '\n'); avio_flush(io); + + pthread_mutex_unlock(&es->lock); } static inline double psnr(double d) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 357f34172f..ab86abee14 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -778,6 +778,10 @@ static void enc_stats_uninit(EncStats *es) for (int i = 0; i < es->nb_components; i++) av_freep(&es->components[i].str); av_freep(&es->components); + + if (es->lock_initialized) + pthread_mutex_destroy(&es->lock); + es->lock_initialized = 0; } static void ost_free(OutputStream **post) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 0203701d78..52eca9f9d5 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -402,6 +402,11 @@ fail: return ret; } + ret = pthread_mutex_init(&es->lock, NULL); + if (ret) + return AVERROR(ret); + es->lock_initialized = 1; + ret = enc_stats_get_file(&es->io, path); if (ret < 0) return ret;