From patchwork Wed Jun 24 13:47:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20581 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 9F34244B3C4 for ; Wed, 24 Jun 2020 16:53:58 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8C8F868B643; Wed, 24 Jun 2020 16:53:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CD71D68B5CC for ; Wed, 24 Jun 2020 16:53:49 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id g75so2398112wme.5 for ; Wed, 24 Jun 2020 06:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b2msGN5z/4GaYtciIha1z2QlagS/aZHgfoBsHUKikPw=; b=LMOtVfXSv+BKhnS8P1U9wh2+WqwThMHfM3Lc4Jk97hlSzq0p+v34jknelxRZ1M3HLw WCil44VQCH9XATpj2R0Ox5Uj63xrb8k2jPSE73H4qxjJFkSyxsItwb/dJoT3Rc3+NYJk cRV9AdOs0IJqmL7Camy5PNdwyR9L7rblfk0/c2PnNZKkccZzgncQwVTZSpvIj9kDZHB9 wSBTGCfL4kdZgwqg7ftH0UJxyYsIdp22FL06ObG6EH2VlhV33t9+gpPlNVm3+gKIkxan MYvKwGDFb2rOG+TjqVFgMw+Tp9wscd1Q4VPn4e3/W8AuGy+wbnM7X68/fZggxSQfAQFM 79gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b2msGN5z/4GaYtciIha1z2QlagS/aZHgfoBsHUKikPw=; b=ZnCJ2vCXRpG1B+jW9Jg05xt5hrkfAO/7qbihWYY9vDDUtfwk1XNIcX2pPDH0x0XVyC feaM+HVO2P058jVFtXOgCwKVlO/fVHGSUzwEAfD1rHe8AuJ6kYSjMSe6qXWIcYq5fN4Y si2i8Xsef/LG7qy+9UJcqqw09rV18ud42jTdN/HKOi2KptDTyTrXG+NJe+wBEv6sYcCO Me8Ax6TRbDGT63k5/emkFnUxYD3V5hZWI+RsMvtIxxRad2NejR8f17ImbfsgaXOiQywg fKK9tJVfAKyN0IzFIT65DpSEmCa2a7WumP4dhtktO1GuCStCdpKGCgI6FU4aycHJ/Crz tVlA== X-Gm-Message-State: AOAM532Aqt8quRx/nJ+tK10/YEL2bGGhJU5Kvg8zTlt1gBlBHYW0SPOq K3OQwSiUtXvDaxjQag3OyoTcllzX X-Google-Smtp-Source: ABdhPJwcUMgaKxB+zSqqpRx7noOYNmEybC0vLuU7jS7X3VoMDUfyhZtFgezvVkQ0ZPH90+QWlRVDoA== X-Received: by 2002:a1c:2ec7:: with SMTP id u190mr23555697wmu.48.1593006825956; Wed, 24 Jun 2020 06:53:45 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id y25sm8172390wma.19.2020.06.24.06.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 06:53:45 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Jun 2020 15:47:01 +0200 Message-Id: <20200624134705.14833-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200624134705.14833-1-andreas.rheinhardt@gmail.com> References: <20200624134705.14833-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/9] avformat/smacker: Improve timestamps 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" A Smacker file can contain up to seven audio tracks. Up until now, the pts for the i. audio packet contained in a Smacker frame was simply the end timestamp of the last i. audio packet contained in an earlier Smacker frame. The problem with this is that a Smacker stream need not contain data in every Smacker frame and so the current i. audio packet present may come from a different underlying stream than the last i. audio packet contained in an earlier frame. The sample hypnotix.smk* exhibits this. It has three audio tracks and the first of the three has a longer first packet, so that the audio for the first track is contained in only 235 packets contained in the first 235 Smacker frames; the end timestamp of this track is 166696 (about 7.56s at a timebase of 1/22050); the other two audio tracks both have 253 packets contained in the first 253 Smacker frames. Up until now, the 236th packet of the second track being the first audio packet in the 236th Smacker frame would get the end timestamp of the last first audio packet from the last Smacker frame containing a first audio packet and said last audio packet is the first audio packet from the 235th Smacker frame from the first audio track, so that the timestamp is 166696. In contrast, the 236th packet from the third track (whose packets contain the same number of samples as the packets from the second track) has a timestamp of 156116 (because its timestamp is derived from the end timestamp of the 235th packet of the second audio track). In the end, the second track ended up being 177360/22050 s = 8.044s long; in contrast, the third track was 166780/22050 s = 7.56s long which also coincided with the video. This commit fixes this by not using timestamps from other tracks for a packet's pts. *: https://samples.ffmpeg.org/game-formats/smacker/wetlands/hypnotix.smk Signed-off-by: Andreas Rheinhardt --- libavformat/smacker.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavformat/smacker.c b/libavformat/smacker.c index 4990b7d920..0138af3d14 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -58,7 +58,6 @@ typedef struct SmackerContext { uint8_t pal[768]; int indexes[7]; int videoindex; - int curstream; int64_t aud_pts[7]; } SmackerContext; @@ -247,7 +246,6 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) if (!smk->next_audio_index) { smk->frame_size = smk->frm_size[smk->cur_frame] & (~3); smk->next_frame_pos = avio_tell(s->pb) + smk->frame_size; - smk->curstream = 0; flags = smk->frm_flags[smk->cur_frame]; smk->flags = flags >> 1; /* handle palette change event */ @@ -323,10 +321,9 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) goto next_frame; } pkt->stream_index = smk->indexes[i]; - pkt->pts = smk->aud_pts[smk->curstream]; - smk->aud_pts[smk->curstream] += AV_RL32(pkt->data); + pkt->pts = smk->aud_pts[i]; + smk->aud_pts[i] += AV_RL32(pkt->data); smk->next_audio_index = i + 1; - smk->curstream++; return 0; } }