[FFmpeg-devel] DSD and supporting codec-requested sample rate change

Peter Ross pross at xvid.org
Sat Apr 26 04:42:27 CEST 2014


Quoting Michael Niedermayer <michaelni at gmx.at>:

> On Mon, Apr 21, 2014 at 04:15:09PM +1000, Peter Ross wrote:
>> Hi,
>>
>> Direct Stream Digital (DSD) is the name given to the 1-bit delta   
>> sigma encoding
>> system found in audiophile equipment. It is an alternative to PCM.
>>
[..]
>> 1. DSD->PCM conversion results in a change to the sample rate. For example,
>>     2.8224 MHz 1-bit DSD samples => 352.8 kHz PCM samples; and
>>     5.6448 MHz 1-bit DSD samples => 705.6 kHz PCM samples.
>>
>>    a) Should libswresample return the new sample rate?
>
> id tend to suggest that the sample rates should represent the true
> (in a mathematical sense) samplerates of the signals.
> And i realize that this definition is a bit fuzzy without a definition
> of what a sample is.

Right. Each DSD sample is 1-bit.

>>
>>    b) Should the user of libswresample be expected to know the   
>> change between
>>       DSD->PCM and populate the 'in_sample_rate' and   
>> 'out_sample_rate' accordingly?
>
> id suggest that it should be handled like any other sample format
> but iam not working on this, you do, so there may be better options
> that iam not recognizing ...

Okay.

>> 2. DoP encoding takes DSD 1-bit samples @ 2.8224 MHz and smushes   
>> them into 24-bit
>>    PCM @ 176.4 kHz. How can the DoP codec inform avcodec that the   
>> output packets have
>>    a different sample rate? Editing 'avctx->sample_rate' doesnt   
>> work because other
>>    modules expect this information to remain static.
>
> iam not sure i understand the problem
>
> where does mhz DSD -> khz PCM differ from mhz PCM -> khz PCM ?

DoP is an industry standard that uses PCM to deliver DSD samples to  
external DAC equipment.

The encoding stores 16 x 1-bit DSD samples into each 24-bit PCM sample.
The high 8 bits of each PCM sample indicate an alternating magic  
number, so that capable DACs can detect the marker and process the DSD  
samples. This is known as bit-perfect DSD. Therefore a source stream  
of DSD samples @ 2.8224 Mhz is "encoded" into a 176.4kHz PCM stream  
(2.8224 x 10^6 / 16).

The challenge for FFmpeg is that libavcodec/dopenc.c needs to change  
the sample rate (from 2.8224 MHz to 176.4kHz). Our codecs have not  
traditionally done this; there is no concept of input and output  
sample rate.

A solution I have considered is adding AVCodecContext.dsd_sample_rate  
that would only apply to SAMPLE_FMT_DSD. The dopenc_init() function  
would read dsd_sample_rate and then set sample_rate.

-- Peter
(Roaming)




More information about the ffmpeg-devel mailing list