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, 12369 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 5th September 2007, 08:58   #4  |  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   #5  |  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 13th September 2007, 12:51   #6  |  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:50   #7  |  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 2nd September 2007, 00:58   #8  |  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 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 9th September 2007, 21:24   #10  |  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   #11  |  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: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 21st September 2007, 07:27   #13  |  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:18   #14  |  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 19th September 2007, 18:40   #15  |  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, 09:12   #16  |  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 30th May 2008, 14:57   #17  |  Link
LogicDeLuxe
Registered User
 
LogicDeLuxe's Avatar
 
Join Date: Nov 2004
Posts: 106
Quote:
Originally Posted by cjk32 View Post
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.
Couldn't you just make it read a separate dither wav file, so the encoder don't have to generate it for itself?
__________________
AMD Ryzen 5, 16 GM RAM, Nvidia GTX 1060, Linux Mint
LogicDeLuxe is offline   Reply With Quote
Old 7th September 2008, 20:15   #18  |  Link
madshi
Registered Developer
 
Join Date: Sep 2006
Posts: 9,140
Just to let you guys know: Chris has been so kind to let me use his HDCD decoder in my eac3to software:

http://forum.doom9.org/showthread.php?t=125966
madshi is offline   Reply With Quote
Old 24th September 2007, 09:49   #19  |  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   #20  |  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
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 07:38.


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