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 39BE145164 for ; Tue, 10 Jan 2023 15:42:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D1E9168BD23; Tue, 10 Jan 2023 17:42:21 +0200 (EET) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB10468B35D for ; Tue, 10 Jan 2023 17:42:13 +0200 (EET) Received: by mail-pf1-f176.google.com with SMTP id g20so9142586pfb.3 for ; Tue, 10 Jan 2023 07:42:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:from:to:cc:subject:date :message-id:reply-to; bh=iAciP99WkJqCFndKULMJDHw0y1Qqq4nHeDfqKAjwjHQ=; b=KqAG35msYm1StywZxJmQsc5BG63dfEXMcjtMMWlFTP4XyrHWlwncA7o3iHLQzNtpYj JDo1bYDgDQkjCkloddpxn+VEIH3H5Tce16NvKnGur+LCctQYGidNdxYDQS1czQHJY649 o36QgQeC+EXSEo9CSjIUBzZNHT279wUv4MWOcgFBlziLQ7qeVtWIzfWjR1PFHPgsx2xi ddISwGHb/bXayIr1E7wV+v0aAOmYKLfe6yO3WH8VPjol9rF0XeR4MZ6FhWdmS6rW9nZL rIXzyybi2ic8KSXY+f4YnAW/aIhulAj/2zCMAFBDZeefQA7nh0zcBcf4/7S1T2hRsNDy jeOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=iAciP99WkJqCFndKULMJDHw0y1Qqq4nHeDfqKAjwjHQ=; b=5ieb3xxf7NWEPEf6jdv6WUD5R9EFkYmXGNyoCtRkQEd22CHhCGTDRsO4hcIFkfzFkT 38WhBW/74c0LSnlPjCetxAhs3SlpgTww0zXx6OLOEC7/2VikJttT0xRAwZ0w7BTx0iOy I47HIzi4z9tqBIM0n4KbdFHgKWxz917aT7cNoaBCGdJJF95lbFlxSr2Off5j1Evj14s6 xfamOhl0XTKZbNlrMJtDLLtEUtCp3iyEaLRB+TROwgPcDwmmoioyZRv5fSHSq+qM339w nm/lfyeWTTDRZQxUAHAs5oJRySv7CyXrbHzd/tuiERfUKfkSOiyHRa/GFHz+P+woS7HZ Z4TQ== X-Gm-Message-State: AFqh2kphpOjz5wTi0e1yNg5YTaq/ez5f2DzkruDSE0+cdZDEXlm0nfpQ u0XltD4AMHUUnjPPjG78rCrYKWk9SyE= X-Google-Smtp-Source: AMrXdXuN63UT3GyRGoqyCjuqcoivIB+J3FxJH5x6yHyYxyU5TR0mnYXy33RT9GYuGG3WD1JoldjIDA== X-Received: by 2002:a62:5bc6:0:b0:588:9c15:65c4 with SMTP id p189-20020a625bc6000000b005889c1565c4mr6202902pfb.3.1673365331214; Tue, 10 Jan 2023 07:42:11 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id r5-20020aa79ec5000000b00589605fb0a1sm3641558pfq.96.2023.01.10.07.42.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2023 07:42:10 -0800 (PST) From: Miguel Borges de Freitas X-Google-Original-From: Miguel Borges de Freitas Message-Id: <5985bf780ecddd2a608537c4cf91d4514660b8da.1673365329.git.ffmpegagent@gmail.com> In-Reply-To: References: Date: Tue, 10 Jan 2023 15:42:07 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 1/2] libavformat/matroskadec: set fixed duration for subtitles 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 Cc: Miguel Borges de Freitas , Miguel Borges de Freitas <92enen@gmail.com> 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: From: Miguel Borges de Freitas The matroska specification states the start time and duration of subtitle entries are encoded in the block TimeStamp and BlockDuration. Furthermore, for all subtitle formats except S_HDMV/PGS the BlockDuration must always be defined and have an absolute value even if it is simply 0. ffmpeg assumes that a duration of 0 means the duration is still unknown and tries to adjust based on the next packet pts. This is wrong for all formats except S_HDMV/PGS. Since changing the semantics of duration 0 is not an option (touches too many parts of the code) this change introduces AV_PKT_FLAG_FIXED_DURATION flag which decoders might use to flag the duration of a given packet should not be changed. Signed-off-by: Miguel Borges de Freitas --- libavcodec/packet.h | 5 +++++ libavformat/demux.c | 3 ++- libavformat/matroskadec.c | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libavcodec/packet.h b/libavcodec/packet.h index f28e7e7011..699dcc6f79 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -446,6 +446,11 @@ typedef struct AVPacketList { * be discarded by the decoder. I.e. Non-reference frames. */ #define AV_PKT_FLAG_DISPOSABLE 0x0010 +/** + * Flag is used to indicate packets in which the duration is absolute + * and should not be changed. + */ +#define AV_PKT_FLAG_FIXED_DURATION 0x0020 enum AVSideDataParamChangeFlags { #if FF_API_OLD_CHANNEL_LAYOUT diff --git a/libavformat/demux.c b/libavformat/demux.c index 2dfd82a63c..471be5d3dd 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -914,7 +914,8 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, pktl->pkt.dts = cur_dts; if (!sti->avctx->has_b_frames) pktl->pkt.pts = cur_dts; - pktl->pkt.duration = duration; + if ((pktl->pkt.flags & AV_PKT_FLAG_FIXED_DURATION) != AV_PKT_FLAG_FIXED_DURATION) + pktl->pkt.duration = duration; } else break; cur_dts = pktl->pkt.dts + pktl->pkt.duration; diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index d582f566a2..e887f43e1a 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3673,6 +3673,10 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, pkt->pos = pos; pkt->duration = lace_duration; + if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE && + st->codecpar->codec_id != AV_CODEC_ID_HDMV_PGS_SUBTITLE) + pkt->flags |= AV_PKT_FLAG_FIXED_DURATION; + res = avpriv_packet_list_put(&matroska->queue, pkt, NULL, 0); if (res < 0) { av_packet_unref(pkt); -- ffmpeg-codebot _______________________________________________ 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".