From patchwork Thu Apr 23 23:33:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dale Curtis X-Patchwork-Id: 19203 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:3c87:0:0:0:0:0 with SMTP id j129csp34617yba; Thu, 23 Apr 2020 16:55:08 -0700 (PDT) X-Google-Smtp-Source: APiQypKYe0yqXh4ot5RlzfiExjVppo7iA4EcG7l7MwCDgXVeybSzb8BpJXA3s/GQxZzFMau9bdne X-Received: by 2002:a05:600c:4102:: with SMTP id j2mr7196032wmi.159.1587686107890; Thu, 23 Apr 2020 16:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587686107; cv=none; d=google.com; s=arc-20160816; b=Ocmipxs+iVtQ4j0bgGPgizX2dDFGAEYota9LfWTYT4sQ7FYJxWD930PZRsw0maBsRo uynera+8793PJ7y527BMiqlZRRMlTIBCH1Nm5vamUoijra+Yy6l80BoGi6vSdceSl0YG 5Rf7qYFNsemCY7XmRepd5VEY4ghQJrGwi3iqsYevbP/fjKh1C462Mb40fQKx6xrcFfRn FDXbyAlS6jM1DtZTV/XpxYTeqCvJfD5Jq4edny1wYKK7iDMmligHU5wchn5/xy0zQhpY HKXEZd2I88da712YzGg9NNgCiNWgY3Hwr8gtN1gtgt/L/bxYVoRp0sr2lzAcEyoSsXtx fUXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to; bh=yvwgpL+7QsWz4Ws+cHZZuZGw8iGWbpf2gBgkILvTUu4=; b=eMJx9buXSEex2ZOqNUikl091mlqtOSI9x3m3To/+knmqGXcCc+hXRfmMu9mQeP0J7u tILjCqop2laAt82OllCRs0Z5C61zAvE0GT8Y1rt4ydi0Xnw/xOfJvlq/wksu9OtFFTkQ J7ChT6aV2x7vdtH1niQhWOY7nwdk0Y/b6fXwX8JOH2d6KcUWbOmfxgRHqk7jVO6CHWj4 5M1GJVT5WkT83vJNZbzYEBXcummt0wLpKdPmx5NpRm6uVcjnq8VR0kWHh6Sbc4Yx2gIg INAe5KbPgbPC8n270kCIMvV4cwwNkDYhewoLEMt/TWJTH7X1WsWn7DYCu8dzFMxyQnHV BdSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=SBqtPU91; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e11si4238311wrj.63.2020.04.23.16.55.06; Thu, 23 Apr 2020 16:55:07 -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=@chromium.org header.s=google header.b=SBqtPU91; 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=NONE dis=NONE) header.from=chromium.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B0A7368BFCC; Fri, 24 Apr 2020 02:55:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4882A68B862 for ; Fri, 24 Apr 2020 02:54:58 +0300 (EEST) Received: by mail-oo1-f45.google.com with SMTP id x16so1726656oop.13 for ; Thu, 23 Apr 2020 16:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:from:date:message-id:subject:to; bh=zmTtRKYnLO0T0iiGg3cZjllv3vSQWGnUk07RwGEvPno=; b=SBqtPU91fLWw5YMEsigZDdwVFHN/+s7BNgla1L8X5+LH7iQKvLknE8YGk5VkcxhXSM DL+l3XEt2ZlAvwUDfXLfRM2icNrgH5dlVTMYWcBb4dXI9Abo1cF+PWVjlV3TPThVhZ4+ x8XKjekDobutQ9kRxJbFdI5a6zDkWk9OGF/2I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=zmTtRKYnLO0T0iiGg3cZjllv3vSQWGnUk07RwGEvPno=; b=CRLtzXGVlCax9LBF8wgOuZnuERDZJIo6zwLdybV5qAvsBkHa4TulTUSXkMT2UBC/b9 bLNINWmJgw2uCu+VNfAtC0u1siAjZ6rMliWeFcGKbWKW3Dyik3TomFsI8dAtUvfhk4bE /QE3E45k17kCwiWynEgfM7uKlp66eTL2LyG2QhHJhEA9NvjP3zVHp56vmgU/MR6rSN6g UN0a2AHMZqfi0yPkHweDzcLVgNY4/IKvXEmgF5q4TU+8TGIHJQJaRVeOKohVkPbtpJd/ NZbc86tY9ekAc4KY9aR0+C2SlTzTFqfEiMsqy284yvLHYiOQgZc6ENmYg6thlRCgL8jG U36Q== X-Gm-Message-State: AGi0PuZGqW6xygpNYsM49oZ0cJYzunK38OgUGuiGi3yLl9SUruQTZJ5C UEpJnZZxrvuB3wRDcqp1TrZC/E+L0av+chsu5NLdKcX31ZE= X-Received: by 2002:ab0:485:: with SMTP id 5mr5235030uaw.5.1587684812555; Thu, 23 Apr 2020 16:33:32 -0700 (PDT) MIME-Version: 1.0 From: Dale Curtis Date: Thu, 23 Apr 2020 16:33:21 -0700 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] Don't adjust start time for MP3 files; packets are not adjusted. 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" X-TUID: /t4FulMdePN7 Content-Length: 5148 This is a patch Chromium has carried for a while, we forgot to send it upstream. 7546ac2fee4 made it so that the start_time for mp3 files is adjusted for skip_samples. However, this appears incorrect because subsequent packet timestamps are not adjusted and skip_samples are applied by deleting data from a packet without changing the timestamp. E.g., we are told the start_time is ~25ms and we get a packet with a timestamp of 0 that has had the skip_samples discarded from it. As such rendering engines may incorrectly discard everything prior to the 25ms thinking that is where playback should officially start. Since the samples were deleted without adjusting timestamps though, the true start_time is still 0. Other formats like MP4 with edit lists will adjust both the start time and the timestamps of subsequent packets to avoid this issue. Signed-off-by: Dale Curtis From 1f551502a2e271da044f7e4be4be7ddca7f30bc1 Mon Sep 17 00:00:00 2001 From: Dale Curtis Date: Thu, 23 Apr 2020 16:18:18 -0700 Subject: [PATCH] Don't adjust start time for MP3 files; packets are not adjusted. This is a patch Chromium has carried for a while, we forgot to send it upstream. 7546ac2fee4 made it so that the start_time for mp3 files is adjusted for skip_samples. However, this appears incorrect because subsequent packet timestamps are not adjusted and skip_samples are applied by deleting data from a packet without changing the timestamp. E.g., we are told the start_time is ~25ms and we get a packet with a timestamp of 0 that has had the skip_samples discarded from it. As such rendering engines may incorrectly discard everything prior to the 25ms thinking that is where playback should officially start. Since the samples were deleted without adjusting timestamps though, the true start_time is still 0. Other formats like MP4 with edit lists will adjust both the start time and the timestamps of subsequent packets to avoid this issue. Signed-off-by: Dale Curtis --- libavformat/mp3dec.c | 4 ---- tests/ref/fate/gapless-mp3 | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index b044679c02..efbf836bcc 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -260,10 +260,6 @@ static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st, st->first_discard_sample = -mp3->end_pad + 528 + 1 + mp3->frames * (int64_t)spf; st->last_discard_sample = mp3->frames * (int64_t)spf; } - if (!st->start_time) - st->start_time = av_rescale_q(st->start_skip_samples, - (AVRational){1, c->sample_rate}, - st->time_base); av_log(s, AV_LOG_DEBUG, "pad %d %d\n", mp3->start_pad, mp3-> end_pad); } diff --git a/tests/ref/fate/gapless-mp3 b/tests/ref/fate/gapless-mp3 index ab4f1a0456..e784391153 100644 --- a/tests/ref/fate/gapless-mp3 +++ b/tests/ref/fate/gapless-mp3 @@ -1,4 +1,4 @@ -44b42cc3a898b45507d856d0813f4f26 *tests/data/fate/gapless-mp3.out-1 +ec876434ed65e338e07234e54d136caf *tests/data/fate/gapless-mp3.out-1 c96c3ae7bd3300fd2f4debac222de5b7 ec876434ed65e338e07234e54d136caf *tests/data/fate/gapless-mp3.out-2 c96c3ae7bd3300fd2f4debac222de5b7 -- 2.26.2.303.gf8c07b1a785-goog