Re: [codec] OggOpus: Rational for excluding replaygain tags?

Calvin Walton <calvin.walton@kepstin.ca> Tue, 27 November 2012 07:36 UTC

Return-Path: <calvin.walton@kepstin.ca>
X-Original-To: codec@ietfa.amsl.com
Delivered-To: codec@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id F3E8F21F853C for <codec@ietfa.amsl.com>; Mon, 26 Nov 2012 23:36:20 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.785
X-Spam-Level:
X-Spam-Status: No, score=-1.785 tagged_above=-999 required=5 tests=[AWL=-1.815, BAYES_00=-2.599, FB_INCREASE_VOL=3.629, RCVD_IN_DNSWL_LOW=-1]
Received: from mail.ietf.org ([64.170.98.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 33jnywtkeqk0 for <codec@ietfa.amsl.com>; Mon, 26 Nov 2012 23:36:20 -0800 (PST)
Received: from mail-ie0-f172.google.com (mail-ie0-f172.google.com [209.85.223.172]) by ietfa.amsl.com (Postfix) with ESMTP id 08F1521F8565 for <codec@ietf.org>; Mon, 26 Nov 2012 23:36:19 -0800 (PST)
Received: by mail-ie0-f172.google.com with SMTP id c13so11208714ieb.31 for <codec@ietf.org>; Mon, 26 Nov 2012 23:36:19 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kepstin.ca; s=google; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:x-mailer:mime-version:content-transfer-encoding; bh=3X/GakxigwZ7XrfCKjjuN1IAb2Opvejsbc5FChxfBYg=; b=btKggj++Ytup69NvjPw+3WyxaPN516H+Ga1TZJ8DAx2HouYCmct2i9ZB+dDfKKzJ7k UdR+2y1HRViSXQnETdY0xPoDGSvKPWyQAZuiE7iUGEth0P7RVAFlfDjevGMlg2XuobGu fb7JRPiA7wOe/8+lDZZPVLz2HFEP0SogZQ8aI=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:x-mailer:mime-version:content-transfer-encoding :x-gm-message-state; bh=3X/GakxigwZ7XrfCKjjuN1IAb2Opvejsbc5FChxfBYg=; b=JgagBOLW2zpnaUn007OIRH5UkVG3pIds7Zsqnb1UYyEewBheulm+HS6ZEUGjaiOqOK 84Fipz/sI06Ox5dIqb2E/PUQ1l45GcnzGNR9AuJL6BczGCqKEuJWBwdKiMNOUdXP+MdU G839zv9ZfCawTC8CvHTHr86v8IcgveIC4Aeo9AEjNrTosAraXTGPF3W8r/9k2cQXtM4a KzLE2KRpOrs4gKYR1xgfH6HY9ikXb4IgUYwN1Py4VEspczxkNRF2sEyVXZpc/aZb+jGL X0i8dLBuBUn6jUGcVqOH4fICTXfLIphVmMyIqvphHZjITFGH06O1kN9yNFEhTc7jO5Kh x5Sg==
Received: by 10.42.176.194 with SMTP id bf2mr13028272icb.50.1354001779306; Mon, 26 Nov 2012 23:36:19 -0800 (PST)
Received: from [192.168.1.139] (CPE586d8fb6db38-CM78cd8e665875.cpe.net.cable.rogers.com. [174.112.205.165]) by mx.google.com with ESMTPS id eo7sm1161565igc.12.2012.11.26.23.36.17 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 23:36:18 -0800 (PST)
Message-ID: <1354001776.2000.87.camel@nayuki.kepstin.ca>
From: Calvin Walton <calvin.walton@kepstin.ca>
To: Gregory Maxwell <gmaxwell@juniper.net>
Date: Tue, 27 Nov 2012 02:36:16 -0500
In-Reply-To: <1353991837.2000.41.camel@nayuki.kepstin.ca>
References: <1352307794.14547.30.camel@ayu> <9B8EA46C78239244B5F7A07E163D3DFE08C500@CH1PRD0511MB432.namprd05.prod.outlook.com> , <1352328081.14547.82.camel@ayu> <9B8EA46C78239244B5F7A07E163D3DFE05F88C2D@CH1PRD0511MB432.namprd05.prod.outlook.com> <1353991837.2000.41.camel@nayuki.kepstin.ca>
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.4.4
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Gm-Message-State: ALoCoQnqRCvWzrlYxPaMy1yLgSqab/rbX8amgKIen7+uqNeQsxuZzFPJdBMCMyXNU+TJwAOesalF
Cc: "codec@ietf.org" <codec@ietf.org>
Subject: Re: [codec] OggOpus: Rational for excluding replaygain tags?
X-BeenThere: codec@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Codec WG <codec.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/codec>, <mailto:codec-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/codec>
List-Post: <mailto:codec@ietf.org>
List-Help: <mailto:codec-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/codec>, <mailto:codec-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 27 Nov 2012 07:36:21 -0000

On Mon, 2012-11-26 at 23:50 -0500, Calvin Walton wrote:
> On Mon, 2012-11-26 at 16:30 +0000, Gregory Maxwell wrote:
> > > Yes, having the standard gain header that is supported by all decoders
> > > is nice - except for the case of playback of mixed file formats,
> > > particularly by an application that doesn't understand the gain tags in
> > > other formats. In those cases, the Opus files will be significantly
> > > quieter (assuming modern pop mastering...) than the other files, making
> > > them sound "worse" than files without gain applied.
> > 
> > I don't see how you can usefully make an argument here.  If you don't
> > have gain adjustment (on the files or in the application) and you have
> > files from various sources you will have various levels.
> 
> My argument is based on using a player that supports Opus playback,
> supports ReplayGain tags, but does not support R128 gain tags. This is
> the case with some current players (e.g. Rockbox, Rhythmbox).
> 
> All of my existing Ogg Vorbis files with ReplayGain tags will be played
> back 5 dB louder than an Opus file with R128 album gain stored in the
> header gain field. (A workaround for this would be to use the ReplayGain
> preamp to apply a -5 dB gain after the ReplayGain adjustment.)
> 
> Alternately, if the Opus file has a R128_TRACK_GAIN comment present, but
> 0 in the header gain field, it will be played back unnormalized!
> 
> For the case of older versions of Rhythmbox running with a newer
> Gstreamer library backend that supports decoding Opus, this situation
> may be maintained for quite a while.

Sorry for the double post, but I wanted to elaborate on this a bit:

This is why I'm currently putting the Vorbis-style ReplayGain tags into
my Ogg Opus files - they are interoperable with existing players, and
work right now. For the time being, in my personal files I'm using the
following backwards- and hopefully forwards-compatible structure:

New logical stream (#1, serial: 00332868): type opus
Encoded with libopus 1.0.1
User comments section follows...
[...]
	REPLAYGAIN_ALBUM_GAIN=+5.00 dB
	REPLAYGAIN_TRACK_GAIN=+4.72 dB
	REPLAYGAIN_TRACK_PEAK=0.171997
	REPLAYGAIN_ALBUM_PEAK=0.184993
	R128_TRACK_GAIN=-72
Opus stream 1:
	Pre-skip: 356
	Playback gain: -15.2891 dB

where the playback gain is an arbitrary number that bears a striking
resemblance to the R128 album gain, R128_TRACK_GAIN is a relative
adjustment to -23 LUFS reference, the REPLAYGAIN_*_GAIN comments are
relative adjustments to -14 LUFS reference (literally just the
corresponding R128 values +5 dB), and the REPLAYGAIN_*_PEAK tags contain
the peak after playback gain is applied, but before ReplayGain is
applied.

(Note that the ReplayGain peak tags are required to tell the GStreamer
'rgvolume' element that it is safe to increase the volume by 5 dB
without clipping; otherwise it will refuse to go above +0 dB.)

This gives me working volume normalization in all of the players that I
use regularly. Rhythmbox and Rockbox use the ReplayGain comments,
applied after the playback gain field. foobar2000 uses the R128 track
gain comment and the playback gain field (it assumes that playback gain
contains the R128 album gain), adjusts both +5 dB, then uses them as
ReplayGain values.

But the combination certainly looks really ugly, for what that's
worth :)

-- 
Calvin Walton <calvin.walton@kepstin.ca>