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

Calvin Walton <calvin.walton@kepstin.ca> Tue, 27 November 2012 04:50 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 7C37B21F8487 for <codec@ietfa.amsl.com>; Mon, 26 Nov 2012 20:50:43 -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 pGdYvk7w4Z51 for <codec@ietfa.amsl.com>; Mon, 26 Nov 2012 20:50:41 -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 A0E6521F8488 for <codec@ietf.org>; Mon, 26 Nov 2012 20:50:41 -0800 (PST)
Received: by mail-ie0-f172.google.com with SMTP id c13so11049967ieb.31 for <codec@ietf.org>; Mon, 26 Nov 2012 20:50:41 -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=tEO5tFd6PXw50dQnSfpAp4ph/S50Trbyb/BYqevG2Xg=; b=pkXDRnbeu7mC3+XasAyOZRiEtNfUzDRGgO6L6FyVzthuu3eeJW+/x70m8jo5/eexyb ebblT2kpRo+EBvdtbX+d82kKVFIbM7XGglhGb/v2SNYzvZM1rKxVqFq2Iw+Vs5mPA6oZ S1Zqx0KyS00yNnvURw1drdmVrdijQIrgfc46U=
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=tEO5tFd6PXw50dQnSfpAp4ph/S50Trbyb/BYqevG2Xg=; b=nB2RJOUo2Ud1ztTEziEGUQcEorXYYzWUsVXnkrO/2WcIV9DFD5nNH0RF4I/Hjss3PL sagVfBnIYqpWx2V98RlpUb2WsWOtQYs1OExgzuGRgle4bb7gcU+tFRbxwFxCz3nPJSqZ Mfksprbs0jPCp5djA7rbyKAuDAHA3mEeWRgVIyH9jpsCsEitJqEc4S1WUaLxqFHGFAjX /0PLGkDEvjRoq+vT0eVcEsgjUp57CBLTJYAklyMsk7cu9nm5iT0/dhZ2lSVceA0MRLdS 4YY53Ky7I4ZTYucsNpvWhQZ4PjTuV1mik3ldJk4LbDzeSBorOd+1W/Bc3qX2RXGbPL6T VGDg==
Received: by 10.50.173.106 with SMTP id bj10mr17290257igc.13.1353991840939; Mon, 26 Nov 2012 20:50:40 -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 l8sm903866igo.13.2012.11.26.20.50.39 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 20:50:40 -0800 (PST)
Message-ID: <1353991837.2000.41.camel@nayuki.kepstin.ca>
From: Calvin Walton <calvin.walton@kepstin.ca>
To: Gregory Maxwell <gmaxwell@juniper.net>
Date: Mon, 26 Nov 2012 23:50:37 -0500
In-Reply-To: <9B8EA46C78239244B5F7A07E163D3DFE05F88C2D@CH1PRD0511MB432.namprd05.prod.outlook.com>
References: <1352307794.14547.30.camel@ayu> <9B8EA46C78239244B5F7A07E163D3DFE08C500@CH1PRD0511MB432.namprd05.prod.outlook.com> , <1352328081.14547.82.camel@ayu> <9B8EA46C78239244B5F7A07E163D3DFE05F88C2D@CH1PRD0511MB432.namprd05.prod.outlook.com>
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.4.4
Mime-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Gm-Message-State: ALoCoQld/7vnMPxHc9pHio/+5+u0FkYBb+iKL6Dgn9wFpkDNGpySKjuXuvQyYv1zD8jbk41WcTpT
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 04:50:43 -0000

On Mon, 2012-11-26 at 16:30 +0000, Gregory Maxwell wrote:
> Sorry for the delayed response— been tied up on other tasks.
> 
> Calvin Walton [calvin.walton@kepstin.ca] wrote:
> > 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.
> 
> It offers one, yes— but it's not a specification. I was stridently
> corrected by the author of replaygain when I made the same claim that
> you are.
> 
> I'm also advised that most tools are now using the EBU R128 method now
> in any case. And in practice the point is fairly moot as the values
> are effectively compatible on actual audio once the reference level.

Yes... I've since looked into this a bit more. foobar2000 uses the R128
algorithm to calculate the values to store in ReplayGain comments; the
command-line tools vorbisgain and metaflac that I normally use are still
based on the older ReplayGain suggested algorithm.

The ReplayGain reference value is 5 dB louder than the EBU R128 standard
reference value, so compensating for the difference is straightforward.

> > 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.

> > If a player blindly applies only the header output gain value, it has no
> > knowledge of whether the output is loudness normalized or not.
> 
> I'd like to say that there should be an informative tag there to
> indicate whats being done. However: I'm absolutely sure it will be
> reliably set wrong, double so because other than displaying it as
> metadata there is simply nothing most software can do with the
> information. There would be little way for careless implementers to
> discover that they've gotten it wrong... and so the information would
> likely be worse than useless as it would just add complexity without
> concrete value.

If I select to use 'Album Gain' mode for ReplayGain in the playback menu
of my iPod running Rockbox:
http://download.rockbox.org/daily/manual/rockbox-ipodvideo/rockbox-buildch7.html#x10-1270007.9
there is currently no way for the player to know whether or not the
arbitrary value in the header gain field represents R128-normalized
album gain or something completely different.

Most players fall back to using the track gain field if the album gain
is not present - but this can't work properly with the current
specification of Ogg Opus. They must either assume that the user has put
R128 album gain into the header gain field (I think foobar2000 currently
does this), or only use track gain.

My personal suggestion would be to have an R128_ALBUM_GAIN field, with
the same format and similar semantics to the R128_TRACK_GAIN field. In
the case where the album gain is stored in the header gain field, the
R128_ALBUM_GAIN field SHOULD be present and be filled with a value of
'0', indicating that no further adjustment is needed to get R128 album
normalized loudness.

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