From patchwork Thu Jan 7 20:55:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Taylor X-Patchwork-Id: 24833 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 72C0C44BB7B for ; Thu, 7 Jan 2021 23:22:58 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 479B6689BDC; Thu, 7 Jan 2021 23:22:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F1A0C689BDC for ; Thu, 7 Jan 2021 23:22:51 +0200 (EET) Received: by mail-io1-f45.google.com with SMTP id n4so7549315iow.12 for ; Thu, 07 Jan 2021 13:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ified.ca; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=k3hij6+yerx4mucPtc1mLbfF+Yg838DvdmrFCP3icG8=; b=XLLZ8ErpPiUqG45SVKqww1GSVzQevdjiHOqI83DRSzrScEMkejEg8DxC+PcuEV1ngD QPCXHZx8e/tiWmx3cKJfb1HMlRrdwdVQMA7AUXSu85xx41ay1orMhoM7/omeUHhbBHRb fElGEYIoap52GoPYTXYR3E/bm2MSz5syt8CuY= 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:mime-version :content-transfer-encoding; bh=k3hij6+yerx4mucPtc1mLbfF+Yg838DvdmrFCP3icG8=; b=XNDsSDjHGNwqXR4LyTJHTWRMNiYiR6xqyT9yVNIE2qf3eDEjKeFAOR5h1e7IenCEKH QjpQcJYpsCdHz/Ajz5jka7dVKHa69wkSqI6zjiSsF5EZy1ybxpVG5XhkB0TWe5RCozl1 35ba5FoTiCCBPCDD6J7OdVHEx7si3CapYQdJTqNwn0sfuoul8BucT0Y93IjCRCTRiiJ/ u5raa6x8/emKRZp1TgENuQrEOP92EuUdgDdJZfeBhDeMhT67cWmx+tCXOKG5RiDUV01t Gw/dIdVTrAfmOw2YKKRQ4x5HUfKWKIUv64JMPFYu6a+/Ov+OezjA9Zy75yx8l9Hu32db RJzg== X-Gm-Message-State: AOAM5314JU+PzoAtFTcpUu2hg2ydjEEHPCzUeyFc71AjSCbR+Dfq/QCa kV4OqqRGnlQLUqfnOV7JFRt8uOaHuw7V+A== X-Google-Smtp-Source: ABdhPJxEygTfqNalKSAlr7HpAgdgSoB/TCCHJ23mAp6bBcc9AhAbFTUwHCqZYiNCUMis2HaF0yvDcA== X-Received: by 2002:a63:4d52:: with SMTP id n18mr3573737pgl.237.1610052965143; Thu, 07 Jan 2021 12:56:05 -0800 (PST) Received: from art-carbon.ingrooves.com ([104.142.113.87]) by smtp.gmail.com with ESMTPSA id d4sm6592080pfo.127.2021.01.07.12.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:56:04 -0800 (PST) From: Arthur Taylor To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Jan 2021 12:55:59 -0800 Message-Id: <20210107205559.6330-1-art@ified.ca> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/libopusenc: Fix for header pre-skip value 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: Arthur Taylor Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The Opus header initial padding preskip amount is always to be expressed relative to 48kHz. However, the encoder delay returned from querying libopus is relative to the encoding samplerate. Multiply by the samplerate conversion factor to correct. Signed-off-by: Arthur Taylor --- libavcodec/libopusenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index bf2d04b4fb..70d17f802b 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -94,7 +94,7 @@ static void libopus_write_header(AVCodecContext *avctx, int stream_count, bytestream_put_buffer(&p, "OpusHead", 8); bytestream_put_byte(&p, 1); /* Version */ bytestream_put_byte(&p, channels); - bytestream_put_le16(&p, avctx->initial_padding); /* Lookahead samples at 48kHz */ + bytestream_put_le16(&p, avctx->initial_padding * 48000 / avctx->sample_rate); /* Lookahead samples at 48kHz */ bytestream_put_le32(&p, avctx->sample_rate); /* Original sample rate */ bytestream_put_le16(&p, 0); /* Gain of 0dB is recommended. */