From patchwork Sun Apr 9 14:08:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41062 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1591984pzb; Sun, 9 Apr 2023 07:11:56 -0700 (PDT) X-Google-Smtp-Source: AKy350YRIRaacNQWcyBGObbcJoqOO/LzWRvFopUzNXJUbuO8gjdDQC8N0sC8vK+/vgaRlawEGZz/ X-Received: by 2002:a05:6402:409:b0:501:d3a0:30d9 with SMTP id q9-20020a056402040900b00501d3a030d9mr7128417edv.7.1681049515741; Sun, 09 Apr 2023 07:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681049515; cv=none; d=google.com; s=arc-20160816; b=zxukKKrBwZnBJKVwIjB2iOKGi5lV2BV6Z0WD366Ex/oYePPDwMsT64fZl6y+66+2ut UQzi0BHr8uaO3nH/HT+X/8xMmgBFh77yJI7bYG7Pk1NEhSDEwR99PkX+dW366BC2WitS +Kywk5o34gjMREilFi19e2jqcEOI6bvqxZW8VyYnXKg+c1Co3h4jibShoqoAqvwqe4AL OJSiA21t0u32GzwPMibv7OnZB9H33CJo/edvAVO2AzH1Kw8pTU12+KW0tK9f3vBk5n9W 0lEc4gbcivoNMfvu6VBs6j2m77h05/PKhd761ZV30lI75slgywp/SwKKtgfM3Xjr7IL6 zRSA== 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=BOvJNMEhmW9+HEXa9+M5o9HDIaGYeRPcMsXbbCDsFNE=; b=ANKNtv4yeI7DQ8LsR2nz042zPdNiwN/AJ5ynZXjN1O9jX0xyHv84viOltO5qKIjUQi MPmL83cUqGXKTb72sHVHeRCUWyYjhuMvPP711BocSO0ItbjE4aSUELCrFgmTIKBwX0g4 wp1PkxSAd8ttATc8awcezQd0qBTjOIyLWEwCCscCScyxRnVuDegInv12zhoU0qN0FXaV iExzuao7H7lA6jkqTAHhsTsWVXLioxMugRNYTGWcCU9iwWZ7wMVvmOTCZ6JgXSKSvA1m CU8vnBhdAUIKxKAycjjHVwonHmMDKAGehZr9MKigeqFyOJn6bPXJMQ8OB+vRJAmAUCuB 7KAw== 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 w16-20020a056402071000b005048736290asi4185617edx.342.2023.04.09.07.11.55; Sun, 09 Apr 2023 07:11:55 -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 5621368BCFB; Sun, 9 Apr 2023 17:09:35 +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 DC46368BD38 for ; Sun, 9 Apr 2023 17:09:20 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A7E162404EC for ; Sun, 9 Apr 2023 16:09:20 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ZjPHyzDirWpa for ; Sun, 9 Apr 2023 16:09:18 +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 E6215240D1F for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D4DD23A038E for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:49 +0200 Message-Id: <20230409140853.28858-25-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 25/29] fftools/ffmpeg_demux: set the timebase on demuxed packets 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: icjQFfUp+8bQ Simplifies tracking what timebase are the timestamps in. Will be useful in following commits. --- fftools/ffmpeg_demux.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index f2da0826ad..7ff57273c9 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -194,15 +194,17 @@ static void ts_fixup(Demuxer *d, AVPacket *pkt, int *repeat_pict) const int64_t start_time = ifile->start_time_effective; int64_t duration; + pkt->time_base = ist->st->time_base; + #define SHOW_TS_DEBUG(tag_) \ if (debug_ts) { \ av_log(ist, AV_LOG_INFO, "%s -> ist_index:%d:%d type:%s " \ "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s\n", \ tag_, ifile->index, pkt->stream_index, \ av_get_media_type_string(ist->st->codecpar->codec_type), \ - av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ist->st->time_base), \ - av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ist->st->time_base), \ - av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ist->st->time_base)); \ + av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base), \ + av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base), \ + av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base)); \ } SHOW_TS_DEBUG("demuxer"); @@ -211,7 +213,7 @@ static void ts_fixup(Demuxer *d, AVPacket *pkt, int *repeat_pict) ist->st->pts_wrap_bits < 64) { int64_t stime, stime2; - stime = av_rescale_q(start_time, AV_TIME_BASE_Q, ist->st->time_base); + stime = av_rescale_q(start_time, AV_TIME_BASE_Q, pkt->time_base); stime2= stime + (1ULL<st->pts_wrap_bits); ist->wrap_correction_done = 1; @@ -226,16 +228,16 @@ static void ts_fixup(Demuxer *d, AVPacket *pkt, int *repeat_pict) } if (pkt->dts != AV_NOPTS_VALUE) - pkt->dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); + pkt->dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, pkt->time_base); if (pkt->pts != AV_NOPTS_VALUE) - pkt->pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); + pkt->pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, pkt->time_base); if (pkt->pts != AV_NOPTS_VALUE) pkt->pts *= ds->ts_scale; if (pkt->dts != AV_NOPTS_VALUE) pkt->dts *= ds->ts_scale; - duration = av_rescale_q(d->duration, d->time_base, ist->st->time_base); + duration = av_rescale_q(d->duration, d->time_base, pkt->time_base); if (pkt->pts != AV_NOPTS_VALUE) { pkt->pts += duration; ds->max_pts = FFMAX(pkt->pts, ds->max_pts);