High Definition Compatible Digital

From Hydrogenaudio Knowledgebase
Revision as of 12:55, 15 July 2016 by Bp (Talk | contribs)

Jump to: navigation, search

High Definition Compatible Digital, or HDCD is a Microsoft proprietary audio encode-decode process that claims to provide increased dynamic range over that of standard Redbook audio CDs, while retaining backward compatibility with existing Compact disc players. —HDCD article at Wikipedia

Decoding the extra information required an HDCD-compatible player or Windows Media Player. There was no public documentation for the process, but it was eventually reverse engineered. Many HDCD-encoded CDs were released from the mid 1990s but started to disappear around 2008. Some CD's with HDCD codes are still appearing, because they were mastered using HDCD equipment, but do not use the core features of HDCD. Microsoft no longer advertises nor supports HDCD.

A lossless copy of CD audio will include the HDCD data. See a list of known HDCD compact discs at Head-Fi.org

Function and features

HDCD encodes a virtual 20 bits of range in a 16-bit stream. Peak extend is worth about one bit of additional range, while Low level gain adjustment is worth about three bits of additional range. HDCD encoding amplifies the audio stream by 6dB to start.

Peak extend
The base 6dB amplification makes the lower levels louder, but the top 9dB is soft-limited, or "squashed", into the top 3dB in the 16-bit stream. When HDCD is being decoded, the top 9dB is reconstructed.
Low-level gain adjustment
The base 6dB amplification can be corrected down during quieter parts via HDCD control codes to restore the original low level.
Filters
There are said to be "a menu" of record and playback filters. Two known to exist the transient filter and the alias filter, but neither are currently supported in any decoding software.

When playing the HDCD-CD in a regular CD player, a listener may hear the uncorrected distortion at the peaks, and the low-level remains uncorrected from the base 6dB amplification.

  • See a full technical examination by Jim Lesurf: Page 1 Page 2

Decoding software

As HDCD is a proprietary extension owned by Microsoft, Windows Media Player was the only software to support it for a long time. A simple closed-source Windows-only decoding tool, called hdcd.exe, appeared in 2007 on the Doom9 Forum, a product of reverse-engineering Windows Media Player. [1] Since that time, an open source implementation has come to exist based on this work. It supports the peak extend and gain HDCD features, while the transient filter feature is detected but not implemented.

All of the open source decoding is based of the work of Christopher J. Key (original reverse-engineering), Chris Moeller (open implementation), and Gumboot (C-optimization). Benjamin Steffes simplified the code, by using some pre-computed tables, etc., for inclusion in FFmpeg. There are slight variations in the output of the different tools.

Audio players

  • Windows Media Player, but there is a bug where HDCD will not be enabled if the HDCD control signal is not detected near the beginning of a song
  • Foobar2000 can decode HDCD to 20-bit PCM via foo_dsp_hdcd (source)
  • dBpoweramp will decode HDCD to 24-bit PCM (uses the hdcd.exe tool for processing)
  • CUETools

hdcd.exe

The original Windows-only closed source tool posted on the Doom9 forums in 2007, by C.J. Key. It only works on wav.

hdcd.exe -o OUT24.wav HDCD16.wav

FFmpeg

FFmpeg version 3.1's libavfilter supports a HDCD filter that will convert HDCD-encoded audio to PCM at up to 20-bit precision. The filter is based on the Foobar2000 component source code.

Notice: There was a bug in FFmpeg (version 3.1.1 and earlier) that prevented low-level gain adjustment from working. It was fixed in this commit.

Example
FLAC with HDCD encoded in 16-bit (perhaps ripped from a CD)
ffmpeg -i input16.flac -af hdcd output24.flac
Example 2
Notice the output from the filter is truncated down to 16-bit because the wav muxer defaults to pcm_s16le...
ffmpeg -i input16.wav -af hdcd output16.wav
Example 3
... if you want to use another format (like pcm_s24le), you have to specify it with the acodec option
ffmpeg -i input16.wav -af hdcd -acodec pcm_s24le output24.wav