From patchwork Tue Oct 18 12:37:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38790 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp2083352pzb; Tue, 18 Oct 2022 05:40:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XkFq2Bf3/dGNka/y2aOcdvLyk7p1DGfjWJAM23WznzUvaZu+GFK+aVb5qC6NBHoJy/Hk0 X-Received: by 2002:a17:907:74a:b0:77e:9455:b4e1 with SMTP id xc10-20020a170907074a00b0077e9455b4e1mr2300916ejb.462.1666096810719; Tue, 18 Oct 2022 05:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666096810; cv=none; d=google.com; s=arc-20160816; b=PQUEA+TDUX4WvYWkwH/YRat67MugzXDuR4xeC2Em9sXGDBQKPVuPntnqG+YUO4FVn3 qIwuhgaSSSB9jYk5eVxYQMhE3W0jHJoWcvrfzU+EM3ya4MWGDp5hNBBrJhlAe5TkzYjg EPSEMxfeZ2nyuxJmoyDWSxg/bNa1qhnKIFmWVa3dUuT1yBnopIVZIrlkG/VfyWv8Bq3C DhbNFeg2M9kytuEGGS1t+Q4AKFWU6SG2ZKkrOOS3/sU5fy8QdOrizUCUE+bN4l58Ea9M ZwXVEqz0oNBKqt1l3/k4B0aPXYpm4FBJAsDo+RBZEM6a1Nls8UjAmVUWfbv4kDdLs8CV Jngg== 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=20GfJ3bcczjOFFk7nlLPOaNolf5SrKd/FH8pboFpye0=; b=Ey1LIFfqgVimYgkA1q48lJEoaninNfr7p+kmLUfA0UjMn1939IsnI5SLL1waisNQx8 VVPldeFgi2ywugDu/PTb8O2HmePbc0E4VqARrCF5D7nZTkixHrt4IUkYpgsJ6rpQ8QUP NbyFC5yiCOujNcdvyTJ/9OX/icbVPr7JoWtt8uQBu72hmD26ZZMzY/+J485j4IhKIDDE pRe8nCAlaLiTVUrTs+OTFLqVoRn5MEfrRAs/2fXnPppWNl36XvlXtF734gBzXtuqQC1a Qxftsnh1jCHebEa/c/77ShWFr7qFXS2rqKYoOKzrVX1BUaoCAu19sB/8L10drtcW0OFT w0Vg== 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 cr2-20020a170906d54200b0078cc4a8a956si12880266ejc.881.2022.10.18.05.40.10; Tue, 18 Oct 2022 05:40:10 -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 AB7DD68BD3D; Tue, 18 Oct 2022 15:38:34 +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 21AF568BD23 for ; Tue, 18 Oct 2022 15:38:21 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 0FBB32406CF for ; Tue, 18 Oct 2022 14:38:20 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id cWmmY577YSan for ; Tue, 18 Oct 2022 14:38:19 +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 DE119240706 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 E6DE43A0922 for ; Tue, 18 Oct 2022 14:38:13 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Oct 2022 14:37:00 +0200 Message-Id: <20221018123701.25002-19-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 19/20] fftools/ffmpeg_demux: stop modifying OptionsContext 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: /a5BtZF062YL It should be input-only to this code. --- fftools/ffmpeg_demux.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 29cff4b471..4ce92862cb 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -772,18 +772,23 @@ int ifile_open(OptionsContext *o, const char *filename) char * data_codec_name = NULL; int scan_all_pmts_set = 0; - if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) { - o->stop_time = INT64_MAX; + int64_t start_time = o->start_time; + int64_t start_time_eof = o->start_time_eof; + int64_t stop_time = o->stop_time; + int64_t recording_time = o->recording_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) { - int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time; - if (o->stop_time <= start_time) { + if (stop_time != INT64_MAX && recording_time == INT64_MAX) { + int64_t start = start_time == AV_NOPTS_VALUE ? 0 : start_time; + if (stop_time <= start) { 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; } } @@ -908,32 +913,32 @@ int ifile_open(OptionsContext *o, const char *filename) } } - if (o->start_time != AV_NOPTS_VALUE && o->start_time_eof != AV_NOPTS_VALUE) { + if (start_time != AV_NOPTS_VALUE && start_time_eof != AV_NOPTS_VALUE) { av_log(NULL, AV_LOG_WARNING, "Cannot use -ss and -sseof both, using -ss for %s\n", filename); - o->start_time_eof = AV_NOPTS_VALUE; + start_time_eof = AV_NOPTS_VALUE; } - if (o->start_time_eof != AV_NOPTS_VALUE) { - if (o->start_time_eof >= 0) { + if (start_time_eof != AV_NOPTS_VALUE) { + if (start_time_eof >= 0) { av_log(NULL, AV_LOG_ERROR, "-sseof value must be negative; aborting\n"); exit_program(1); } if (ic->duration > 0) { - o->start_time = o->start_time_eof + ic->duration; - if (o->start_time < 0) { + start_time = start_time_eof + ic->duration; + if (start_time < 0) { av_log(NULL, AV_LOG_WARNING, "-sseof value seeks to before start of file %s; ignored\n", filename); - o->start_time = AV_NOPTS_VALUE; + start_time = AV_NOPTS_VALUE; } } else av_log(NULL, AV_LOG_WARNING, "Cannot use -sseof, duration of %s not known\n", filename); } - timestamp = (o->start_time == AV_NOPTS_VALUE) ? 0 : o->start_time; + timestamp = (start_time == AV_NOPTS_VALUE) ? 0 : start_time; /* add the stream start time */ if (!o->seek_timestamp && ic->start_time != AV_NOPTS_VALUE) timestamp += ic->start_time; /* if seeking requested, we execute it */ - if (o->start_time != AV_NOPTS_VALUE) { + if (start_time != AV_NOPTS_VALUE) { int64_t seek_timestamp = timestamp; if (!(ic->iformat->flags & AVFMT_SEEK_TO_PTS)) { @@ -968,8 +973,8 @@ int ifile_open(OptionsContext *o, const char *filename) f->ctx = ic; f->index = nb_input_files - 1; f->ist_index = nb_input_streams - ic->nb_streams; - f->start_time = o->start_time; - f->recording_time = o->recording_time; + f->start_time = start_time; + f->recording_time = recording_time; f->input_sync_ref = o->input_sync_ref; f->input_ts_offset = o->input_ts_offset; f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp);