From patchwork Thu Apr 21 03:22:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guangyu Sun X-Patchwork-Id: 35366 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b9e:b0:7d:cfb5:dc7c with SMTP id b30csp9769pzh; Wed, 20 Apr 2022 20:23:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJza6zLv7oHoxe9q9SN/aFl7ngxq7x2g9gsfthoo0MuLZ1xYdIIJmiMKWOPmG/ptTG5VV1Kp X-Received: by 2002:a17:907:72d5:b0:6ef:a49f:133a with SMTP id du21-20020a17090772d500b006efa49f133amr16802866ejc.420.1650511387478; Wed, 20 Apr 2022 20:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650511387; cv=none; d=google.com; s=arc-20160816; b=hHz0YUuy2LXEoJE6oa6S2S/dOjxsNRcUXaOOU72s+zP2+PSpYfLNnbDLDZy+lsp93P lQMeAQLn4/IWX5IfVgdBpE3ikfoHPtaGg1o3MS4yuHsugYO64oJ0MqCm6V66Bm1jSPNa 5VUsKYtsyDyha8cNtJ35JPF8Kxmlph3HicOQfWtWhpFpPFBEV7fe5N68QsigTHoMMDYv bC0Gxv30XsBcVlO1EIfiwriul1rtt6lYn9r70VYOtrUw6TyBm0Vp19FfcDn5fiDsAMTr YrIfB5VYaD0/ilz33+zcl3+wN4gOG8QHZZ4s7hHLf2T+Kc6uYEtoaV6hgKfnxOgoGDEK TGMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=Vdr1dELzFkHkdxpxmD4cishBmMk9CcyKJbkSVXftSfo=; b=tmZbvWvsMEhVyXJdo5xU+TwDc2X/9ZgTqe0HfLr/Njhu62yz51MbBukHq+fLQnaE8Z R+f1T9CRxH8WFG0jOqPqHgXmhfgPgtlwzHQRFjrj6pc5OPdCb6Y60f6ysNTQRL7gcKVQ IQmk9+2pIEbFaTZVfYiKV2fQyX+XaItpbErNbMuqJObasFvq0evEL12+kH/KEI6zoHXz LnEMzKkC84FJ306NxeSFOVHPF1DriUpuCWwhR9N39vXOZIFg7AGENEjZ6n4HJ0q7lBPe 8xVullO72xw2b63KyHOOS54orshzw2GpLpIt5eoiNJzV7EeXPYDQNscgmhw/7cVxbf8u aGqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=UC4nWm6b; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s19-20020a056402521300b0041e97a8af3asi3268162edd.476.2022.04.20.20.23.06; Wed, 20 Apr 2022 20:23: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=@gmail.com header.s=20210112 header.b=UC4nWm6b; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DA3E568B2B6; Thu, 21 Apr 2022 06:23:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3E64868B193 for ; Thu, 21 Apr 2022 06:22:56 +0300 (EEST) Received: by mail-pg1-f182.google.com with SMTP id r83so3545181pgr.2 for ; Wed, 20 Apr 2022 20:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=86dpdfzZSTC1PoCeyC8r+pGNZd0U+W+MhlHbksR1OJc=; b=UC4nWm6bLfw6EpacF9fVAYBDHAChlD/f6pKu6vVx58i8OsTmBjyNQDIunq5QfOtsrY 6rZXK2iBM5nuugzlHJJ1zPcvItZ+qyqZSM0ZtZz73E4j3edFqG7ZHkMwwisG9pj5RhQc S0pcqeM/wfDZLdP83xpDROXV1buy0HqcB+BawU+OCqLOQmg8jqIo4vrUfnhSFrMbklij Mo1RWvFQWbr89CGsRTbrjdUVD+73Nfd95pWqTaqo+I/EEBsNLP3R2fpaGHz9JzozHWRT 9CmsxRv1XuAW8ZyHS84TzcSBQfQEvalNPL0FKPyCgwItxziKq+O/fqImmn5wQwGYpIRV OF3Q== 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:mime-version :content-transfer-encoding; bh=86dpdfzZSTC1PoCeyC8r+pGNZd0U+W+MhlHbksR1OJc=; b=UJHOpIPaFxzlqQMfjS8A3ZO5wHUVjyuWZadaFx7qb9A8uGp/t7vsOVHJ2VS6/ISec0 w+jVInOPEiOQscd/zIm0KJu/6Pi/lWDOvQZjJkXstv7pOeXloGq0zqycbvQ7VGk0bVbt GcZk/I0KAONkhxVb41Gqxie6ps++SaikvWMoVCnP3/b9ZEdUOjCubQcU8Ush4Y+zqqvo u7CU2SC+oT0jUApRuhpAmJHW6fRcdBGyj6PQU0BIJXH3QFwCqrMiYn6kOzkX9mYNE/8A CbbH8mNS+Y/dVw5UkQOBBBMmE3zBBwnWPtVAIq698d8nsrR64W5ZyCgwFqtHpYL5oLRv +Lzw== X-Gm-Message-State: AOAM532g02Nx13jTnGU/u6YByYKFFnSDjMmLaKzm/7K0xndhw1oSsLFM nU/0o0F0d/zow1Tbcm1CJSzHOTutpm0= X-Received: by 2002:a65:5181:0:b0:3aa:3668:26a9 with SMTP id h1-20020a655181000000b003aa366826a9mr10617869pgq.184.1650511373785; Wed, 20 Apr 2022 20:22:53 -0700 (PDT) Received: from localhost.localdomain (99-106-168-104.lightspeed.sntcca.sbcglobal.net. [99.106.168.104]) by smtp.gmail.com with ESMTPSA id y9-20020aa79429000000b0050ad02027d9sm2400190pfo.197.2022.04.20.20.22.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Apr 2022 20:22:53 -0700 (PDT) From: Guangyu Sun X-Google-Original-From: Guangyu Sun To: ffmpeg-devel@ffmpeg.org Date: Wed, 20 Apr 2022 20:22:51 -0700 Message-Id: <20220421032251.9866-1-gsun@roblox.com> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/oggparsevorbis: Ignore duration of the first packet 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: m827g4FciqB2 The decoded Data is not returned from the first frame; it must be used to 'prime' the decode engine. The duration of the first packet should be ignored also by the container, to make sure the total duration is trimmed correctly. This commit fixes #6367. dd if=/dev/zero of=./silence.raw count=1 bs=500 oggenc --raw silence.raw --output=silence.ogg oggdec --raw --output silence.oggdec.raw silence.ogg ffmpeg -codec:a libvorbis -i silence.ogg -f s16le -codec:a pcm_s16le silence.libvorbis.ffmpeg.raw ffmpeg -i silence.ogg -f s16le -codec:a pcm_s16le silence.native.ffmpeg.raw ls -l *.raw Signed-off-by: Guangyu Sun --- libavformat/oggparsevorbis.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 289900f7cf..1f922b3c7e 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -479,6 +479,13 @@ static int vorbis_packet(AVFormatContext *s, int idx) flags = 0; } os->pduration = duration; + /* Data is not returned from the first frame; it must be used to 'prime' + * the decode engine. The duration of the first packet should be ignored + * also by the container, to make sure the total duration is trimmed + * correctly. + */ + if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && os->segp == 1) + os->pduration = 0; } /* final packet handling