From patchwork Tue Oct 18 12:36:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38780 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp2082747pzb; Tue, 18 Oct 2022 05:38:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6fSKX0JCMkYGyQISENZ4L/rbCms5lcwLbCawuOOt8Tqo3ngYz52MSIgc8woPt7jd+6GGL+ X-Received: by 2002:a17:906:99c3:b0:78d:9cc9:deda with SMTP id s3-20020a17090699c300b0078d9cc9dedamr2235278ejn.712.1666096724815; Tue, 18 Oct 2022 05:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666096724; cv=none; d=google.com; s=arc-20160816; b=rWmA26FLYp7Ve4fBPqV++02Ga/1EIDg+fhAVDFpkfH+YZwb1s/Epzp8qBQW+az61z+ UzjTXVzN+CjhnqVqGifHHDyytJj8XX7XjTLbx71BzOgfIM1N8swdIbYuWmeHQPimHVlJ 7qoZJHFY2v6U7ETEs8qLYMErKLgMK2Fw4oFuhNoDXlp9LUd03ATVyh3RsuOyUiZx46fj GBFD6O5SaA8+UFt4rCKSm+R/uN9qoRKOJr4WK/6nh7Ji/jftplx3nfyifhwO/G5EnEk/ 5FlCyvk2W4UARn8KK95w2If885fF6Mcb674fwF2mG000FwopRb/EWp/C3ptfVue4di9j YnMQ== 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=xEKCbx6irBej/hIyI/ty8Yk1AxzSpniEMgYyizNRaD0=; b=zZhQzOXS/XTCaI2E0hTeZVY6/kNg1rCnVteIBgcUDuZMR5EvCMfzInPvyo25R7T6tk 10VlqvcqxNEx/rcurH1U/utvcnA1oxwSegueCvYB4emzbbrw3OPJ53Tl4mUhzXFBBJt4 GGsQm/LQekLyPYQEuC9RBWHWTw5i6Qqm4Jpz5AiVjAmNbd+XK4NazENKLytqnrHkjJv2 bfm3vq4WXa2HzOsRJc3AhyHlv3I5LiAolL8cJPOhBFjj602As1VexmNhJI2OwIDSroHs jyVFvW9SjE3yypZcrduuVSh0aRX5+wZh/zljz1sQkGi4qNB7UeSPmRKf66kIbUSxK51I Uv6Q== 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 p26-20020a170906a01a00b0078db89b2566si10313393ejy.699.2022.10.18.05.38.44; Tue, 18 Oct 2022 05:38:44 -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 9843868BD4D; Tue, 18 Oct 2022 15:38:24 +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 9333368BC19 for ; Tue, 18 Oct 2022 15:38:20 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 091612405EC for ; Tue, 18 Oct 2022 14:38:18 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id WM2yYDtcov3B for ; Tue, 18 Oct 2022 14:38:17 +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 B5FAB2406CB for ; Tue, 18 Oct 2022 14:38:13 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D44853A0212 for ; Tue, 18 Oct 2022 14:38:13 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Oct 2022 14:36:57 +0200 Message-Id: <20221018123701.25002-16-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221018123701.25002-1-anton@khirnov.net> References: <20221018123701.25002-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/20] fftools/ffmpeg_mux_init: stop modifying some OptionsContext fields 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: /D/WOIWWCApn Specifically recording_time and stop_time - use local variables instead. OptionsContext should be input-only to this code. Will allow making it const in future commits. --- fftools/ffmpeg_mux_init.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 96584e960b..d25dace105 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1575,7 +1575,7 @@ static void copy_meta(Muxer *mux, OptionsContext *o) if (!metadata_global_manual && nb_input_files){ av_dict_copy(&oc->metadata, input_files[0]->ctx->metadata, AV_DICT_DONT_OVERWRITE); - if(o->recording_time != INT64_MAX) + if (of->recording_time != INT64_MAX) av_dict_set(&oc->metadata, "duration", NULL, 0); av_dict_set(&oc->metadata, "creation_time", NULL, 0); av_dict_set(&oc->metadata, "company_name", NULL, 0); @@ -1671,18 +1671,21 @@ int of_open(OptionsContext *o, const char *filename) AVDictionary *unused_opts = NULL; const AVDictionaryEntry *e = NULL; - if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) { - o->stop_time = INT64_MAX; + int64_t recording_time = o->recording_time; + int64_t stop_time = o->stop_time; + + if (stop_time != INT64_MAX && recording_time != INT64_MAX) { + stop_time = INT64_MAX; av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n"); } - if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) { + if (stop_time != INT64_MAX && recording_time == INT64_MAX) { int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time; - if (o->stop_time <= start_time) { + if (stop_time <= start_time) { av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n"); exit_program(1); } else { - o->recording_time = o->stop_time - start_time; + recording_time = stop_time - start_time; } } @@ -1690,7 +1693,7 @@ int of_open(OptionsContext *o, const char *filename) of = &mux->of; of->index = nb_output_files - 1; - of->recording_time = o->recording_time; + of->recording_time = recording_time; of->start_time = o->start_time; of->shortest = o->shortest; @@ -1712,8 +1715,8 @@ int of_open(OptionsContext *o, const char *filename) want_sdp = 0; of->format = oc->oformat; - if (o->recording_time != INT64_MAX) - oc->duration = o->recording_time; + if (recording_time != INT64_MAX) + oc->duration = recording_time; oc->interrupt_callback = int_cb;