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

Calvin Walton <calvin.walton@kepstin.ca> Wed, 07 November 2012 22:41 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 1D6A421F84FF for <codec@ietfa.amsl.com>; Wed, 7 Nov 2012 14:41:36 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.599
X-Spam-Level:
X-Spam-Status: No, score=-3.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, 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 jSJtT0+22bg2 for <codec@ietfa.amsl.com>; Wed, 7 Nov 2012 14:41:31 -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 58B9A21F84DF for <codec@ietf.org>; Wed, 7 Nov 2012 14:41:31 -0800 (PST)
Received: by mail-ie0-f172.google.com with SMTP id 9so3631487iec.31 for <codec@ietf.org>; Wed, 07 Nov 2012 14:41:31 -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; bh=rzQ4+qL7nUiLUpkQ/0h+r48PR/dGQAWZqHRl0HHeCy8=; b=uRtmhNeC5QJWNrg5IeRjaucUznE27GsnOJBXPIhlMi1zGC+/TPYuXq+2PN4RovTf9A XyAylC2rt1fqjADd8jWOo9UKqHSLT7/ezoaIxRG6vTMFkH1IZ5dwp6xjaOje5oPkbnJs zUwAv6Lby4Hv+PztnsIL/geS2bQ9DHuTgvNsQ=
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:x-gm-message-state; bh=rzQ4+qL7nUiLUpkQ/0h+r48PR/dGQAWZqHRl0HHeCy8=; b=BsvD4/g/KTUdxxMdrWh00ZUjXe7B8x3JQxpXfJ9I+ELlgyK8/s/pPk5U18RW7e1YX1 lA50+UNG9fmZFjrKYtmxBhCeEwbqm09qr5sqjfKqhFRJcDiuBv+2hAzaHxs/8mNT88UN J/uFlL8hyGdhkM3fDfM+xEmW2xXqhPN/n0cFup03DX6U/73sspH0hr7h/pIuwCTj/rPO qe5BzWXzx3pAEDAKXLGzQrijyPAPnGdJEabyTkVWieSWUyHdP6X5bIr173ljVS5hUMR9 gdTy5pkNJFQXtOHA/ACCN+Jk7p+TGqTNz4/vYdD8t8vm/2p/MYyp5NcSlFfz2B16SMbq /jyg==
Received: by 10.42.101.11 with SMTP id c11mr5461069ico.52.1352328090991; Wed, 07 Nov 2012 14:41:30 -0800 (PST)
Received: from [192.168.1.149] (CPE586d8fb6db38-CM78cd8e665875.cpe.net.cable.rogers.com. [99.224.21.194]) by mx.google.com with ESMTPS id az6sm2987759igb.11.2012.11.07.14.41.28 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Nov 2012 14:41:29 -0800 (PST)
Message-ID: <1352328081.14547.82.camel@ayu>
From: Calvin Walton <calvin.walton@kepstin.ca>
To: Gregory Maxwell <gmaxwell@juniper.net>
Date: Wed, 07 Nov 2012 17:41:21 -0500
In-Reply-To: <9B8EA46C78239244B5F7A07E163D3DFE08C500@CH1PRD0511MB432.namprd05.prod.outlook.com>
References: <1352307794.14547.30.camel@ayu> <9B8EA46C78239244B5F7A07E163D3DFE08C500@CH1PRD0511MB432.namprd05.prod.outlook.com>
Content-Type: multipart/signed; micalg="sha1"; protocol="application/x-pkcs7-signature"; boundary="=-Fg8nuJgpS8fqd9uVrQ5i"
X-Mailer: Evolution 3.6.0
Mime-Version: 1.0
X-Gm-Message-State: ALoCoQl2pJmZbbHtsJjl+XmQlnrMtguOrEjbAwVLO4KC1f1GqEa/5xaTSWGrjVb6iPJiOUSqmiCg
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: Wed, 07 Nov 2012 22:41:36 -0000

On Wed, 2012-11-07 at 19:46 +0000, Gregory Maxwell wrote:
> Calvin Walton [calvin.walton@kepstin.ca] wrote:
> > While I don't see any technical problems with R128 - it is a good volume
> > normalization scheme - the issue is that it is a *different*
> > normalization scheme from the replaygain tags that are supported in
> 
> Replay gain does not specify a method for measuring the level. The
> R128 measurement technique is, in fact, being used in place of te
> older replay-gain in many places and I wouldn't be surprised if it
> were actually the most popular of the two then.   With that in mind
> the only difference between the two values is the specified meaning
> and a constant scaling factor for the different reference levels.   So
> it's trivial to make software that that can play a mixture of OggOpus
> and replaygain vorbis with the expected constant levels.

Hmm? Replaygain does specify a method. They go into a lot of details on
http://www.replaygain.org/ to describe the loudness filter used, the
method for calculating RMS power levels afterwards, the histogram-based
statistical processing, and how to calibrate the gain level to the -83dB
reference with a pink noise signal.

I agree that it would be possible to write a program that would support
playing back files with either R128 or replaygain values reasonably well
by adjusting the gain to compensate for the different reference points.

> > other audio formats - it gives different results, and isn't directly
> > interoperable, and isn't supported by many existing players.
> 
> Replaygain itself has very spotty support.
> 
> This means that if you create a file with replaygain tags it will have
> _wildly_ different playback levels depending on which player you use.
> So any content distributor can simply not use it if they care about
> things working consistently at all.  The only place it works reliably
> is on your own files... and well, if thats all you care about
> interoperability isn't much of an issue.

> One of the major motivations behind how this this is address in
> OggOpus is that we have the gain header field that gives a default
> playback gain. This works in all existent players... and it allows
> consistent behavior.  And it is supported by every single existing
> decoder that I'm aware of.

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've done a survey of existing player applications with Ogg Opus
> > support. All of these players:
> > * Rockbox (development version with Opus support)
> > * GStreamer-based (e.g. Rhythmbox)
> > will use the REPLAYGAIN_TRACK_GAIN and REPLAYGAIN_ALBUM_GAIN tags (as
> > specified in Vorbis) to apply replaygain to Opus tracks. Both Rockbox
> 
> Can you give me a link to a test file— I tried and it isn't for me.

I can do that; here's the CC attribution, non-commercial, share-alike
track "Discipline" by Nine Inch Nails, with vorbis-style replaygain tags
added, no r128 gain tags present, and opus header gain set to 0. It is
representative of how I've been doing music in my collection:
http://www.kepstin.ca/dump/nin-discipline.opus (~4.1MB, ~128kbit stereo)

Note that both Rockbox and Rhythmbox ship with replaygain correction
turned off by default; it must be manually enabled (It's in the playback
options in Rockbox, and in the Plugins menu in Rhythmbox).

An example gstreamer pipeline for this is
$ gst-launch-1.0 -t filesrc location=nin-discipline.opus \! decodebin \! rgvolume \! pulsesink

(remove the rgvolume element to get the track without replaygain applied)

> > and Gstreamer-based players will first apply the stream header's output
> > gain field prior to applying the replaygain correction; I haven't
> > checked foobar2000 on that point.
> 
> Well thats good.
> 
> > Of the players in that list, only foobar2000 supports the R128 gain tag.
> > I am not sure what happens if both tags are present.
> 
> Thats not correct. The way the spec is constructed and apps are
> implemented gain works fine _without_ supporting the tag.  It
> basically make it work by default. And I think this is a massive
> improvement which would be broken by reintroducing the widespread
> inconsistency of replaygain.

The issue I see here is that the normalization method used for the value
in the opus header output gain field is *not specified* currently. An
application can put any value in that field, and a player cannot assume
that the value is relative to any useful reference point. The only
supported place currently to get a gain with a useful reference point is
the R128_TRACK_GAIN tag.

If a player blindly applies only the header output gain value, it has no
knowledge of whether the output is loudness normalized or not.

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