From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4904D41158 for ; Mon, 14 Feb 2022 22:43:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CED8A68B1E6; Tue, 15 Feb 2022 00:42:24 +0200 (EET) Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4116368B1C1 for ; Tue, 15 Feb 2022 00:42:22 +0200 (EET) Received: by mail-oi1-f177.google.com with SMTP id 4so18970471oil.11 for ; Mon, 14 Feb 2022 14:42:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=944SdW6nEMSuoK6nMCtCLndulhEFnXqWPBSw2FySRjo=; b=CcqPfX2x41xjLD6GIbjV/zmoYMYh3LkmWzvtInkW0uQ8Krw6Fz9k64unvcOw0xM8EO MJrRWwmFvB9cbzFlO5Hf0YYgXgcbJHVj6ufbvXL0iL+GTuSdOn0Z+VMKHMPrH25aV2FQ bsRW2K7PBaMCppsMgOoYfVfdlCGftvU6DsrhwS8Lw34MGZTLiyyap1qRWxNMXJRCyrgv qUo1IV2Z/bChEX/ie8kjnnSO2MS8N95eh9bgVp7wKJZUmiWQ6XGQOssxyWVEsDDPRRy8 cE1ss4ad96mkJoRqhzNESGftg2DQ2+WfRsbuWdc4jv+XHHoBYm5/bm30X5fYN7oWNxnk WL0Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=944SdW6nEMSuoK6nMCtCLndulhEFnXqWPBSw2FySRjo=; b=2guX5K9DLijlt3MBZ1zvONYJKY9eoPjdWhSeYy9Z5fuQoDLKHoo7yNb4BBXqA2RAx+ URY7k5wzQC1NAmM9SgaYumV04PQcTvfLOHuWy76xT5xwz5tTynQtsokXBmHT7HsoCW5I oIY6AMWB4/c7i4FQ9WP2ZADW8pY3sw6fTtm/xCr8bI0U75iPWz595EBYdg/0uQ6eXly5 QaKpnCDtidFgSmDWXMkG7mFRY86ngQP5JVhcG6fYyKgh6KXQTyEmpP9cU/ctrdTIMQYv jqSDzsJd/adFRTubI4dZR2DXZ+CWLzE4FdAfBxSJb4NKyuK/z1oFiyerEy2hlXgyM4ee LY0w== X-Gm-Message-State: AOAM530va1efYxk0QwMKuQtlhgnq80PbrYh+7uI1w+0Wd9Zh2kahJP71 ok/Rng868B3C7Obqm/Q+gunoAWWdCKBvQQ== X-Google-Smtp-Source: ABdhPJyYgCH0IfX19s/JXQZYOI61fr9DxZTKSMx6hHjcCjMmAk4GTV8pY7KS0cN+vW7ucIhhlTv+ZQ== X-Received: by 2002:aca:3787:0:b0:2cb:676a:47ed with SMTP id e129-20020aca3787000000b002cb676a47edmr470251oia.76.1644878541172; Mon, 14 Feb 2022 14:42:21 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id a8sm13199885otj.47.2022.02.14.14.42.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 14:42:20 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Feb 2022 19:41:56 -0300 Message-Id: <20220214224156.39862-6-jamrial@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214224156.39862-1-jamrial@gmail.com> References: <20220214224156.39862-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/6] avcodec/setts_bsf: add constants to modify packet duration 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: James Almer --- Missing doc changes. libavcodec/setts_bsf.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c index 35266ee251..46f9a30103 100644 --- a/libavcodec/setts_bsf.c +++ b/libavcodec/setts_bsf.c @@ -35,12 +35,16 @@ static const char *const var_names[] = { "POS", ///< original position in the file of the frame "PREV_INPTS", ///< previous input PTS "PREV_INDTS", ///< previous input DTS + "PREV_INDURATION", ///< previous input duration "PREV_OUTPTS", ///< previous output PTS "PREV_OUTDTS", ///< previous output DTS + "PREV_OUTDURATION", ///< previous output duration "NEXT_PTS", ///< next input PTS "NEXT_DTS", ///< next input DTS + "NEXT_DURATION", ///< next input duration "PTS", ///< original PTS in the file of the frame "DTS", ///< original DTS in the file of the frame + "DURATION", ///< original duration in the file of the frame "STARTPTS", ///< PTS at start of movie "STARTDTS", ///< DTS at start of movie "TB", ///< timebase of the stream @@ -55,12 +59,16 @@ enum var_name { VAR_POS, VAR_PREV_INPTS, VAR_PREV_INDTS, + VAR_PREV_INDUR, VAR_PREV_OUTPTS, VAR_PREV_OUTDTS, + VAR_PREV_OUTDUR, VAR_NEXT_PTS, VAR_NEXT_DTS, + VAR_NEXT_DUR, VAR_PTS, VAR_DTS, + VAR_DURATION, VAR_STARTPTS, VAR_STARTDTS, VAR_TB, @@ -75,6 +83,7 @@ typedef struct SetTSContext { char *ts_str; char *pts_str; char *dts_str; + char *duration_str; int64_t frame_number; @@ -86,6 +95,7 @@ typedef struct SetTSContext { AVExpr *ts_expr; AVExpr *pts_expr; AVExpr *dts_expr; + AVExpr *duration_expr; AVPacket *prev_inpkt; AVPacket *prev_outpkt; @@ -109,6 +119,12 @@ static int setts_init(AVBSFContext *ctx) return ret; } + if ((ret = av_expr_parse(&s->duration_expr, s->duration_str, + var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) { + av_log(ctx, AV_LOG_ERROR, "Error while parsing duration expression '%s'\n", s->duration_str); + return ret; + } + if (s->pts_str) { if ((ret = av_expr_parse(&s->pts_expr, s->pts_str, var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) { @@ -136,7 +152,7 @@ static int setts_init(AVBSFContext *ctx) static int setts_filter(AVBSFContext *ctx, AVPacket *pkt) { SetTSContext *s = ctx->priv_data; - int64_t new_ts, new_pts, new_dts; + int64_t new_ts, new_pts, new_dts, new_duration; int ret; ret = ff_bsf_get_packet_ref(ctx, pkt); @@ -159,18 +175,23 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt) s->var_values[VAR_POS] = s->cur_pkt->pos; s->var_values[VAR_PTS] = s->cur_pkt->pts; s->var_values[VAR_DTS] = s->cur_pkt->dts; + s->var_values[VAR_DURATION] = s->cur_pkt->duration; s->var_values[VAR_PREV_INPTS] = s->prev_inpkt->pts; s->var_values[VAR_PREV_INDTS] = s->prev_inpkt->dts; + s->var_values[VAR_PREV_INDUR] = s->prev_inpkt->duration; s->var_values[VAR_PREV_OUTPTS] = s->prev_outpkt->pts; s->var_values[VAR_PREV_OUTDTS] = s->prev_outpkt->dts; + s->var_values[VAR_PREV_OUTDUR] = s->prev_outpkt->duration; 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; s->var_values[VAR_TB] = ctx->time_base_out.den ? av_q2d(ctx->time_base_out) : 0; s->var_values[VAR_SR] = ctx->par_in->sample_rate; 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)); if (s->pts_str) { s->var_values[VAR_TS] = s->cur_pkt->pts; @@ -197,6 +218,7 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt) pkt->pts = new_pts; pkt->dts = new_dts; + pkt->duration = new_duration; ret = av_packet_ref(s->prev_outpkt, pkt); if (ret < 0) @@ -228,6 +250,7 @@ static const AVOption options[] = { { "ts", "set expression for packet PTS and DTS", OFFSET(ts_str), AV_OPT_TYPE_STRING, {.str="TS"}, 0, 0, FLAGS }, { "pts", "set expression for packet PTS", OFFSET(pts_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, { "dts", "set expression for packet DTS", OFFSET(dts_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, + { "duration", "set expression for packet duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str="DURATION"}, 0, 0, FLAGS }, { NULL }, }; -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".