From patchwork Sat Nov 26 08:19:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39455 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp6013289pzb; Sat, 26 Nov 2022 00:20:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf7+XzUSAZhcSrDg6tF/KK00yyvhABTHqDRfvhkKVXaUSZmyzst0wFqKJ/a8e8rT1Rxrxq+s X-Received: by 2002:a05:6402:5510:b0:461:60e8:7ac3 with SMTP id fi16-20020a056402551000b0046160e87ac3mr22876818edb.80.1669450822803; Sat, 26 Nov 2022 00:20:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669450822; cv=none; d=google.com; s=arc-20160816; b=Fq4NhfpzqK39qQq39StmqS3adcmxha3LRjMb9n3IVcZH6+sZOyj/9qbFlhGyrzFsNY smfiv2KPSvrLhiJ8w6qztKpXYv6DYs93L+lJzj9s3Jm1owMa6a03nM9AeCQbjzdxN9oZ AMpI5m+efeoO8IiVNwLwfLYrrOiQr7CFY10ESrMt0rpctCcpMExiPaPn/LsAw1r3Te1M iAWYQD9r8ylkPQdMmJg0o0R4QVrTK0/hw60jazJjDcOeZNv1xDm/aGXQTzSRCu9PV07o FFdJzxtlwH5Drrnesx1oxaXmzvAgIwhvevBMlewbq/9DiY7ZHKRObiA/VI2TxCNtkFjL RJGg== 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=8UFLo0hxLtt4kRzKQLYdiFXhik58IYkZC4q35RhN/Tg=; b=YSFr03Nt33XjQC6y16oMv58wBAck3H7PV4/8OBefSRial40Ww0VwGHKnE39Z1w+3Yf kgWd9XYzZnpgNz1WhhdoXfgrLHK/C5ubql09UEPOEwlY8fuXCepewddkZIuSogAMEB3j ZDSbQMtvf+02WFAE1LSIwfptth3vicgD3rdRW66B4AzY+57IKgTW2zmysxA3AGsXBtGF DkopfF+dva4scWwtc+KxaGszP9tA/u5PuzjbVmc3xlKxUITZBQqPlflzHUSW3rrQCo77 omyNFchVMKFdobGv9mknp8tOAYqwojToTY8jMvp7KtloHhtFXcMFNjyO3J/pU9lE1JYR LX8g== 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 s9-20020a056402164900b00461bff75d84si4684169edx.463.2022.11.26.00.20.22; Sat, 26 Nov 2022 00:20:22 -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 5A34A68B9DC; Sat, 26 Nov 2022 10:19:36 +0200 (EET) 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 EC3B868B83A for ; Sat, 26 Nov 2022 10:19:29 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7468B240591 for ; Sat, 26 Nov 2022 09:19:26 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id WH6DX0M-S2iv for ; Sat, 26 Nov 2022 09:19:25 +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 mail0.khirnov.net (Postfix) with ESMTPS id AABF42406C7 for ; Sat, 26 Nov 2022 09:19:23 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9C3D33A0102 for ; Sat, 26 Nov 2022 09:19:23 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 26 Nov 2022 09:19:06 +0100 Message-Id: <20221126081911.31275-8-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221126081911.31275-1-anton@khirnov.net> References: <20221126081911.31275-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/13] fftools/ffmpeg: stop calling adjust_frame_pts_to_encoder_tb() for audio 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: MTm+yCWwTSG8 Almost none of that function's complexity is useful for audio, it can be replaced by a simple av_rescale_q(). --- fftools/ffmpeg.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 2ee40890a9..cb65f26100 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -933,15 +933,22 @@ static int submit_encode_frame(OutputFile *of, OutputStream *ost, static void do_audio_out(OutputFile *of, OutputStream *ost, AVFrame *frame) { + AVCodecContext *enc = ost->enc_ctx; int ret; - adjust_frame_pts_to_encoder_tb(of, ost, frame); - if (!check_recording_time(ost, ost->next_pts, ost->enc_ctx->time_base)) return; if (frame->pts == AV_NOPTS_VALUE) frame->pts = ost->next_pts; + else { + int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; + frame->pts = + av_rescale_q(frame->pts, frame->time_base, enc->time_base) - + av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base); + } + frame->time_base = enc->time_base; + ost->next_pts = frame->pts + frame->nb_samples; ret = submit_encode_frame(of, ost, frame);