Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st August 2007, 21:57   #1  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
HDCD Software Decoder

Hello all,

I've seen comments from a few people wanting to know how hdcd works, so I decided to take a look at it as an academic exercise.

Attached is a 'reference decoder', which reads a 16-bit wav from from stdin, upconverts it to 24-bit using embedded hdcd information where present, and writes the output to stdout. To use, simply run:

hdcd.exe < 16bit.wav > 24bit.wav

If embedded hdcd information is detected, a notification will be written to stderr. Non hdcd's will also work, although the only result will be to halve their volume.

Let me know how you get on,

Chris
Attached Files
File Type: zip hdcd.zip (31.2 KB, 9928 views)
cjk32 is offline   Reply With Quote
Old 22nd August 2007, 09:01   #2  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
Until the attachment's approved, it can be downloaded from,

http://www.srcf.ucam.org/~cjk32/hdcd/hdcd.zip
cjk32 is offline   Reply With Quote
Old 24th August 2007, 11:04   #3  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
and if anyone wants binaries for different platforms, please let me know.
cjk32 is offline   Reply With Quote
Old 2nd September 2007, 00:58   #4  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Excellent work! I want to use it in my audio conversion batch. It's too bad that non-HDCD materials will have the volume halved. It is possible to avoid the effect or to implement a test mode (e.g. make a quick scan of a few portions and return an errorlevel of 1 for non-HDCD)?
henryho_hk is offline   Reply With Quote
Old 5th September 2007, 08:58   #5  |  Link
nazg00l
Registered User
 
Join Date: Aug 2007
Posts: 1
Quote:
Originally Posted by cjk32 View Post
and if anyone wants binaries for different platforms, please let me know.
Ummm... Would it be a big problem for you to compile the program for Linux? Or at least for plain DOS?
(There are several free DOS clones/emulators for Linux; theoretically the current version could perhaps run under Wine emulator, but there are problems with stream redirections, which require the Windows shell, which is not free...)
nazg00l is offline   Reply With Quote
Old 8th September 2007, 13:19   #6  |  Link
Onward
Registered User
 
Join Date: Aug 2007
Posts: 1
A mac (intel/universal) binary would be nice
Onward is offline   Reply With Quote
Old 9th September 2007, 21:24   #7  |  Link
abcx
Registered User
 
Join Date: Jan 2007
Posts: 21
Looks great. Thanks
abcx is offline   Reply With Quote
Old 11th September 2007, 10:53   #8  |  Link
jolson
Registered User
 
Join Date: Dec 2006
Posts: 117
And... - any noticable sound improvement?
jolson is offline   Reply With Quote
Old 13th September 2007, 12:47   #9  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
Quote:
Originally Posted by henryho_hk View Post
Excellent work! I want to use it in my audio conversion batch. It's too bad that non-HDCD materials will have the volume halved. It is possible to avoid the effect or to implement a test mode (e.g. make a quick scan of a few portions and return an errorlevel of 1 for non-HDCD)?
Apolgies, I've been away for a the past fews days. The volume is halved, both for technical reasons and to maintain bit compatibility with wmp. There is now a test mode, if you download the latest version from the website, and run 'hdcd.exe -h', it'll show you your options.

In general, it's worth looking at the website to check for newer versions. I'll keep the older versions online too, and hdcd.zip will point to the latest 'stable' version.
cjk32 is offline   Reply With Quote
Old 13th September 2007, 12:50   #10  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
Quote:
Originally Posted by nazg00l View Post
Ummm... Would it be a big problem for you to compile the program for Linux? Or at least for plain DOS?
(There are several free DOS clones/emulators for Linux; theoretically the current version could perhaps run under Wine emulator, but there are problems with stream redirections, which require the Windows shell, which is not free...)
Hi,

If you can give me some pointers to a suitable toolkit, I'll have a go at compiling for DOS.

For other platforms, could you contact me privately. Microsoft want to charge royalties for use of hdcd technology on non MS platforms, so I'd like to keep any such binaries limited to individuals for now.

Regards,

Chris
cjk32 is offline   Reply With Quote
Old 13th September 2007, 12:51   #11  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
Quote:
Originally Posted by Onward View Post
A mac (intel/universal) binary would be nice
Could you contact me privately, see my previous post.
cjk32 is offline   Reply With Quote
Old 13th September 2007, 12:54   #12  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
Quote:
Originally Posted by jolson View Post
And... - any noticable sound improvement?
Well, for most HDCDs, the decoded cd will sound better than the original due to the removal of the peak compression the was applied during encoding.

Whether the 24bit decoded version will sound audibly different from a 16bit downsampled version of the same is entirely different question. Anyone care to do some ABXing?

Regards,

Chris
cjk32 is offline   Reply With Quote
Old 19th September 2007, 18:40   #13  |  Link
bxxxb
Registered User
 
Join Date: Sep 2007
Posts: 1
Hi, probably stupid question, but is it possible to make a HDCD software encoder?

Tnx....
bxxxb is offline   Reply With Quote
Old 21st September 2007, 07:27   #14  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Quote:
Originally Posted by cjk32 View Post
Anyone care to do some ABXing?
It's really difficult ABX'ing uncompressed sound with computer audio devices.

BTW, I have problems working with flac.exe and hdcd.exe in a pipe chain. When I do something like "flac -d in_hdcd16.flac - | hdcd | flac -c - out_24.flac" (not the exact commandline, but you can get the idea), flac.exe will prompt an error saying no audio data found. Does anyone have the same problem?

Last edited by henryho_hk; 21st September 2007 at 07:32.
henryho_hk is offline   Reply With Quote
Old 21st September 2007, 09:12   #15  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
Quote:
Originally Posted by bxxxb View Post
Hi, probably stupid question, but is it possible to make a HDCD software encoder?

Tnx....
It's certainly feasible to create an encoder that supports the same features that the decoder currently does. The only non trivial point would be to produce a good dithering system, ideally as close to the one used in the original encoders, although I expect a little bit of reading would make this fairly simple.

Less simple is to be able to use dynamic filter switching. This requires knowledge of the filter's characteristics (hopefully gleanable from test tracks played through an upsampling decoder), as well as an algorithm to choose which filter to use.

On the other hand, whether there is any actual use for an encoder is another question. I'd really like to perform / see the results of an ABX between the following:

A) 24 bit original encoder that's been hdcd encoded and decoded
B) 24 bit original truncated / dithered to 16 bit (and then padded back to 24 bit if it makes the technical details any easier)

The other benefit I should probably mention is that tracks encoder using peak extension and gain adjustment will play back rather compressed on non hdcd players. In some cases, this may well be what you want, e.g. car audio, portable music players.

I suspect I'll probably end up writing an encoder just to play with. It might well make ABXing things a lot easier!

Regards,

Chris
cjk32 is offline   Reply With Quote
Old 21st September 2007, 09:18   #16  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
Quote:
Originally Posted by henryho_hk View Post
It's really difficult ABX'ing uncompressed sound with computer audio devices.
How so? Is it just getting a sufficently good signal out of the computer so as to make the differences even measurable?

Quote:
Originally Posted by henryho_hk View Post
BTW, I have problems working with flac.exe and hdcd.exe in a pipe chain. When I do something like "flac -d in_hdcd16.flac - | hdcd | flac -c - out_24.flac" (not the exact commandline, but you can get the idea), flac.exe will prompt an error saying no audio data found. Does anyone have the same problem?
Which version are you using? Versions before r172 had problems when being piped to (windows doesn't like it if you fseek on a pipe). This was fixed in r172, although I'd strongly recommend using r185 instead, as r172 had some serious problems when peak extend was used along with gain adjustment. I think I'll probably remove r172, and when I've had a few reports of success, make r185 the next version.

Regards,

Chris
cjk32 is offline   Reply With Quote
Old 24th September 2007, 09:49   #17  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Yup, I think mainstream computer audio has difficulty reproducing good signals for us to ABX'ing these "lossless" signals. The first problem would be probably be the dynamic range. I am now actually trying it (16bit dither by foobar, on-board ALC888, desktop speaker). I know headphones would be better but the audio output is too high and too noisy. I wonder if Live24 would do a better job.

R185 is doing great at piping. Something like "flac -d -c hdcd_orig_16bit.flac | hdcd | flac -5 -f - -o decoded_24bit.flac" is now working perfectly. Thanks.

A foobar plugin would be great too.
henryho_hk is offline   Reply With Quote
Old 24th September 2007, 15:51   #18  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
Quote:
Originally Posted by henryho_hk View Post
R185 is doing great at piping. Something like "flac -d -c hdcd_orig_16bit.flac | hdcd | flac -5 -f - -o decoded_24bit.flac" is now working perfectly. Thanks.
Glad to see that it's working.

Quote:
Originally Posted by henryho_hk View Post
A foobar plugin would be great too.
Ive no experience with foorbar at all, and am highly unlikely ever to write such a plug in. However, I am finalising an API to the code, and will release the necessary headers along with a static and dynamic library should anyone wish to implement this themselves.

Regards,

Chris
cjk32 is offline   Reply With Quote
Old 26th September 2007, 10:17   #19  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
What does it mean by "Transient filter (Unsupported)"?
henryho_hk is offline   Reply With Quote
Old 27th September 2007, 08:46   #20  |  Link
cjk32
Registered User
 
Join Date: Jun 2007
Posts: 12
Quote:
Originally Posted by henryho_hk View Post
What does it mean by "Transient filter (Unsupported)"?
HDCD allows the use of three features: peak extend, gain adjustment and reconstruction filter switching. Windows media player supports peak extend and gain adjustment, and it has hence been possible to fully implement these features.

Filter switching, however, only makes sense when you are upsampling, something which wmp doesn't do, and there's hence no reference to implement it from. Investigation of various test CDs and various (usually contradictory) literature has led to the conlusion that there are only two filters available at playback, the normal filter and the transient filter.

The reason for this conlusion is that of the three bits of each hdcd code remaining after peak extend and gain adjustment, wmp abandons two, but explicitly stores the remaining one (suggesting that this is the only important remaing bit, giving only two options).

An ivestigation of when this bit was set was what lead to the conclusions that it is intended to cover transients. If you take a look at,

http://www.srcf.ucam.org/~cjk32/hdcd...3%20Panama.PNG

the right channel is untouched, and the left channel shows that value of this remaining bit. It is set to for a period covering each of the drum beats, and similar behaviour is observed with many other tracks.

The intention is to try to add upsampling to the code once the filter's responses are known. I'm hoping that someone with a hardware HDCD decoder (which should be upsample and switch filters) will be able to play the following test tracks through it to ascertain the impulse / frequency response,

http://www.srcf.ucam.org/~cjk32/hdcd/transient_filter/

These are a frequency sweep and an impulse train with hdcd codes embedded to either enable the normal or trainsient filter (_nf.wav, _tf.wav). If anyone does have a go with these, please don;t put the impulse train through speakers (or amp?), I can't imagine it'll do them any good.

Chris
cjk32 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:47.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.