In article , Chris
Isbell
wrote:
On Mon, 02 Jul 2012 13:30:33 +0100, Jim Lesurf wrote:
I'd *welcome* you having a look!
[snip]
I have also taken the liberty of looking at the source code.
At the risk of teaching my grandmother how to suck eggs...
The HDCD decoder in hdcd_decode.c has two entry points (called from
dsp_hdcd.cpp):
hdcd_reset: This is passed a decoding context, which it uses to keep
track of where it is in the decoding process. There is one context per
channel and this function is called once per channel for initialisation.
So there are *two* independent 'hdcd_state-t' structures, one for 'left'
and the other for 'right'?
This function is also passed the sample rate.
This puzzled me because my understanding is that HDCD encoded material will
- at input - only ever be 44,100 samples/sec and 16 bit.
That said, another puzzle is that HDCD 'DACs' are supposed to upsample the
output to 88,200 to let them apply the various filters that the specs say
it can select on replay. Again, I could not see any sign of this in the
code and have been suspecting that C.J.Key, etc never were able to find out
what these filters were. Another specific detail omitted from the documents
I've seen!
hdcd_process: This is called every time there is a chunk of data to
decode. It seems as if the sample data contains values for each channel
in turn (e.g. L,R,L,R... for stereo).
This was what puzzled me given the above. So the program uses two state
structures but interleaves the L,R samples when finding the control
sequences?
One of the confusions I had from the (vague) Patent, etc, is that in places
it says the data is given (by implication) independently for L and R so
they can be controlled seperately, but then it seemed odd if they need to
have any gain or peak settings kept in sych to avoid a mess when played as
a 'normal' CD. So I've been suspecting that the data stream in the LSBs in
interleaved whilst the Patent seems to say otherwise.
And is the chunk size fixed somewhere, or can I use any size that suits me?
This was another value that I could not see being set at the start of the
process.
This function is passed the
context, the un-decoded samples, the number of samples and the number of
channels ("stride").
Ah, so 'stride' is always set = 2 for stereo? Again, what is curious about
that is that is supposed to be a stereo only system as it is meant to play
on normal CD players.
Decoding is performed in place, with result
overwriting the input buffer. This function is also called once per
channel for each chunk of data. (The address of the sample data is
offset on each call so that it points to the first entry for the
channel being decoded.)
I'll look at the dsp_hdcd.cpp again, although I do struggle with C++.
Again, what isn't clear to me is how the values in 'samples' are held. Is
this a 32-bit per value signed array? Again, from an audio CD - which is
the only defined way to convey HDCD, all values will be 16bit - so given
the inplace changes to yield 20bit results I assume this all have to be
promoted to 32bit?
FWIW I normally use 32 bit as standard and has suspected that as the output
will be 24bit/sample. However I was also uncertain about the 'window' value
in the state structure being 'uint64_t' which I take to be 64 bit unsigned
(?). Yet elsewhere it seems to be being used with 32bit ones...
Is each decode after the first 'find' of a recognised pattern done after a
readahead of a length set by the updated value of readahead? Again this
wasn't something clear to me, or how the system synchs up.
Another puzzle. The documentation says the control patterns are spread
(scrambled) by a simple MLS. But to my ignorant eye the process used in the
decoding proceedure doesn't look at all like that. It just seems to pick up
a specific set of values. I've been wondering if CJK just found what
patterns correlated with specific reactions of features so just senses them
as a 'lookup' in their scrambled state. (?)
Another aspect of this is that I expect to work using LPCM wave files for
the input source and then write out to another one. (input here being
16bit, and output being 24bit.) The code in the .c file seems to take
dealing with that for granted, which is OK, but made me wonder if I was
missing something!
As with Nick, you would be welcome to email me about this if you want more
info on what the system is claimed to do, and how it is said to do it.
Cheers,
Jim
--
Please use the address on the audiomisc page if you wish to email me.
Electronics
http://www.st-and.ac.uk/~www_pa/Scot...o/electron.htm
Armstrong Audio
http://www.audiomisc.co.uk/Armstrong/armstrong.html
Audio Misc
http://www.audiomisc.co.uk/index.html