From patchwork Thu Mar 17 03:00:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 34802 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp540462nkb; Wed, 16 Mar 2022 20:01:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlILOTuPS3DMsThZN3TR0KN4HtbGF6AO9fBpty1cs8YJgADfkEAsfXSred9z+2aVwKcfE7 X-Received: by 2002:a17:907:6e06:b0:6da:889b:321c with SMTP id sd6-20020a1709076e0600b006da889b321cmr2395627ejc.510.1647486098331; Wed, 16 Mar 2022 20:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647486098; cv=none; d=google.com; s=arc-20160816; b=jLVacrCI4AA25ZR+20vsaR9aQYE1QBTKOJ4mccDodvyV5lfgFEiK4bq1t3Vl99Va/L aJuj/i4Ot8bTrya2O+E+VKJ2qxIkvo6ZBbWJoPgZofUtWdwLclT4MsnkLBbe1ckLOEUw Un1XDmK/ak//3mf9pbJ94EPq8vY8iVmXbDle8sO/lXoRrrenxW+B617tB00EdLzQlnrX VFicZPFD9ATjAXwnVFjSlhi7eDso4fROt9CzhK0HPVhXsJNEVRjDQ5vLiqeEM+mIX0kH 0Dhb5hsxXVk+EgwxUdrB0xC4eR9rSp98KI/7C6LY/8zi4FMU/Osmxw8/pGMy4oUHrzbV f4nw== 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 :dkim-signature:delivered-to; bh=xvMQ2pgfC8it6q7wCaziP4OFTzjC0bML5/0WPRMu04g=; b=zXM5CZ1G4qq6E7OLWt6jbGr4TyJVYrJrooq/yHv1tRu4Llzg7GcR0Ye4laHFP3jRPJ PtH+qs46+wlOBeoXkFu88q8rg6Ll6VeeA+xpnhVIQnrUs1KNb6vBQYZZ/s+Z7WDZOHW1 7UPeJKRlFRPxSNljwCEcbNsGSFDXx5z6I6znYTeuu2/eNv0Azh+qXLdj7EWbGQ3+6/w5 7P4yE7uL2FzB1hkQt/zuWsYWSu11uMAT00NHQg/t89M/Ke+eu5a0Zr9Hg32NOoMB4s32 E8FpZ6C7F2eQj632iWOsJzB2p9beaN9Sgawqtfoj5J5sOo57oSrSXdd5V4YJB5saVvDT RBrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Eo3iPq1z; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i1-20020a170906090100b006d00a8e76f8si2151804ejd.511.2022.03.16.20.01.37; Wed, 16 Mar 2022 20:01:38 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Eo3iPq1z; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5F83468AE56; Thu, 17 Mar 2022 05:01:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2D85368AF71 for ; Thu, 17 Mar 2022 05:01:27 +0200 (EET) Received: by mail-oo1-f51.google.com with SMTP id h16-20020a4a6f10000000b00320507b9ccfso5000070ooc.7 for ; Wed, 16 Mar 2022 20:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=PmffMDZ1D5cCpyLkyiW0OCIbKjzpqfdnVteaDtUcG2I=; b=Eo3iPq1zeYE9MuGLYBbfQRKvPOIcFd4JWR7Am9DSq8WDueZ68JfsbKqCn7wlqyT9mw fngUl+9ykR/YYTRRR3C4S+pCyOLW42eGtFAtEcPlDzlzk+3Dkq7m7bqBuQ49LfiDN+wZ Qyt9wo+w2GgFyuVrcyrm/pwBM36nfQ/fTmBWCphCDnG2hiO2Dm1HKUOJqsVX6RMt6Oa2 5Qogqyw3TGPyvMGrFVD8dgw/Tz5FzNwsXz+ksHSchRuPJw3wGPp8l4AYgMKuFHTGa869 Rg3CP5OBbbB3EToI/eUeuJzItY70SgLJ89qyx8OHQJCOmS3FtXParmehL7dg142mIuG8 Vrig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=PmffMDZ1D5cCpyLkyiW0OCIbKjzpqfdnVteaDtUcG2I=; b=51NPacVwbkjeW3ze9xygDa0AIuVrb8EyVKVmcIvJU2ITl10vjn1WLrfNbb7LQ1rG+w 3UNsgSaZQYcWyCSqzFCgdtLRuEWmx0N23VjNsnC2OtBXy1zRsvH0Mg4CHcV64mWpRYgZ ABXAeNBemxIVEuLp361ZfE+a9IjSOuh8/c640sPGtBfyPrCOWt1/cHMzvT2fS9i8JH8G cMgBzIiwPl+SD33TRKyAow0g50o+zYMyWFCMUe2dNQdQ1xuvZVDUURn0/4uBrusF+wMn piJ/JGMFUAZpU5N1nGcBDZT4AqlhSazDWsMXTtO23OHDwACEpNFtvAChIc6gUbPWJs0S poUQ== X-Gm-Message-State: AOAM533CSovZ2VVmt/pESncDsghcKnnyp9bmHNieCfi3AyuK6IgFscG0 KgRWjblpukiCly5sXtvXzcOFQHg096bgeA== X-Received: by 2002:a05:6870:42c5:b0:db:ec20:9879 with SMTP id z5-20020a05687042c500b000dbec209879mr3860993oah.136.1647486084940; Wed, 16 Mar 2022 20:01:24 -0700 (PDT) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id 14-20020a056870134e00b000ddaf3927b1sm1150543oac.32.2022.03.16.20.01.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 20:01:24 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Mar 2022 00:00:37 -0300 Message-Id: <20220317030037.10486-1-jamrial@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/setts_bsf: don't repeatedly set start pts and dts 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: 4FhEL+rJ5HJt Signed-off-by: James Almer --- libavcodec/setts_bsf.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c index b7732214ee..3c666b5061 100644 --- a/libavcodec/setts_bsf.c +++ b/libavcodec/setts_bsf.c @@ -91,9 +91,6 @@ typedef struct SetTSContext { int64_t frame_number; - int64_t start_pts; - int64_t start_dts; - double var_values[VAR_VARS_NB]; AVExpr *ts_expr; @@ -149,8 +146,8 @@ static int setts_init(AVBSFContext *ctx) ctx->time_base_out = s->time_base; s->frame_number= 0; - s->start_pts = AV_NOPTS_VALUE; - s->start_dts = AV_NOPTS_VALUE; + s->var_values[VAR_STARTPTS] = AV_NOPTS_VALUE; + s->var_values[VAR_STARTDTS] = AV_NOPTS_VALUE; s->var_values[VAR_NOPTS] = AV_NOPTS_VALUE; s->var_values[VAR_TB] = ctx->time_base_in.den ? av_q2d(ctx->time_base_in) : 0; s->var_values[VAR_TB_OUT]= ctx->time_base_out.den ? av_q2d(ctx->time_base_out) : 0; @@ -174,11 +171,11 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt) return AVERROR(EAGAIN); } - if (s->start_pts == AV_NOPTS_VALUE) - s->start_pts = s->cur_pkt->pts; + if (s->var_values[VAR_STARTPTS] == AV_NOPTS_VALUE) + s->var_values[VAR_STARTPTS] = s->cur_pkt->pts; - if (s->start_dts == AV_NOPTS_VALUE) - s->start_dts = s->cur_pkt->dts; + if (s->var_values[VAR_STARTDTS] == AV_NOPTS_VALUE) + s->var_values[VAR_STARTDTS] = s->cur_pkt->dts; s->var_values[VAR_N] = s->frame_number++; s->var_values[VAR_TS] = s->cur_pkt->dts; @@ -195,8 +192,6 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt) s->var_values[VAR_NEXT_PTS] = pkt->pts; s->var_values[VAR_NEXT_DTS] = pkt->dts; s->var_values[VAR_NEXT_DUR] = pkt->duration; - s->var_values[VAR_STARTPTS] = s->start_pts; - s->var_values[VAR_STARTDTS] = s->start_dts; new_ts = llrint(av_expr_eval(s->ts_expr, s->var_values, NULL)); new_duration = llrint(av_expr_eval(s->duration_expr, s->var_values, NULL));