From patchwork Sun Nov 15 08:59:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Lhomme X-Patchwork-Id: 23645 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7B93844AB38 for ; Sun, 15 Nov 2020 11:00:12 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5A96168B9D1; Sun, 15 Nov 2020 11:00:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78D7F68B930 for ; Sun, 15 Nov 2020 11:00:04 +0200 (EET) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4CYmPJ0Qd6zQl1t for ; Sun, 15 Nov 2020 10:00:04 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id 2DdUacWOL_8N for ; Sun, 15 Nov 2020 10:00:01 +0100 (CET) From: Steve Lhomme To: ffmpeg-devel@ffmpeg.org Date: Sun, 15 Nov 2020 09:59:48 +0100 Message-Id: <20201115085948.26003-2-robux4@ycbcr.xyz> In-Reply-To: <20201115085948.26003-1-robux4@ycbcr.xyz> References: <20201115085948.26003-1-robux4@ycbcr.xyz> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.11 / 15.00 / 15.00 X-Rspamd-Queue-Id: 19CBA17EB X-Rspamd-UID: 865c82 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/matroskadec: adjust the cluster time to the track timebase X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" The Block timestamp read in matroska_parse_block() is in track timebase and is passed on as such to the AVPacket which uses this timebase. In the normal case the Cluster and Track timebases are the same because the track->time_scale is 1.0. But when it is not the case, the values in Cluster timebase need to be transformed in Track timebase so they can be added together. --- libavformat/matroskadec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index ba0e2956df..137674c068 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3581,7 +3581,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf if (cluster_time != (uint64_t) -1 && (block_time >= 0 || cluster_time >= -block_time)) { - timecode = cluster_time + block_time - track->codec_delay_in_track_tb; + uint64_t timecode_cluster_in_track_tb = (double) cluster_time / track->time_scale; + timecode = timecode_cluster_in_track_tb + block_time - track->codec_delay_in_track_tb; if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE && timecode < track->end_timecode) is_keyframe = 0; /* overlapping subtitles are not key frame */