Skip to contentSkip to conversation

pcm: 2nd round of pcm_misc DSD fixes

PATCH Superseded Jurgen Kramer 3 participants 3 messages Aug 15, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pcm: 2nd round of pcm_misc DSD fixes

Functions 'snd_pcm_format_silence_64' and 'snd_pcm_format_size' also need to be able to handle the DSD formats.

---
 src/pcm/pcm_misc.c | 4 ++++
 1 file changed, 4 insertions(+)
src/pcm/pcm_misc.c +4 -0
index 24d52f9..c52e7bf 100644
@@ -317,11 +317,13 @@ ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples)
 	switch (format) {
 	case SNDRV_PCM_FORMAT_S8:
 	case SNDRV_PCM_FORMAT_U8:
+	case SNDRV_PCM_FORMAT_DSD_U8:
 		return samples;
 	case SNDRV_PCM_FORMAT_S16_LE:
 	case SNDRV_PCM_FORMAT_S16_BE:
 	case SNDRV_PCM_FORMAT_U16_LE:
 	case SNDRV_PCM_FORMAT_U16_BE:
+	case SNDRV_PCM_FORMAT_DSD_U16_LE:
 		return samples * 2;
 	case SNDRV_PCM_FORMAT_S18_3LE:
 	case SNDRV_PCM_FORMAT_S18_3BE:
@@ -387,6 +389,8 @@ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
 	case SNDRV_PCM_FORMAT_S20_3BE:
 	case SNDRV_PCM_FORMAT_S18_3LE:
 	case SNDRV_PCM_FORMAT_S18_3BE:
+	case SNDRV_PCM_FORMAT_DSD_U8:
+	case SNDRV_PCM_FORMAT_DSD_U16_LE:
 		return 0;
 	case SNDRV_PCM_FORMAT_U8:
 		return 0x8080808080808080ULL;
Signature · 1 line
1.9.3
#1 lore raw
Quoted 2 lines · Jurgen Kramer

Functions 'snd_pcm_format_silence_64' and 'snd_pcm_format_size' also need to be able to handle the DSD formats.

0 is not a DSD silence value. It is the most negative value, similar to -32768 for S16 samples. We need something that will average to zero.

ffmpeg uses a repeating pattern of 0x69 here, with this comment:

/* 0x69 = 01101001
* This pattern "on repeat" makes a low energy 352.8 kHz tone
* and a high energy 1.0584 MHz tone which should be filtered
* out completely by any playback system --> silence */

https://ffmpeg.org/pipermail/ffmpeg-cvslog/2014-April/076427.html

Quoted 34 lines
---
  src/pcm/pcm_misc.c | 4 ++++
  1 file changed, 4 insertions(+)
src/pcm/pcm_misc.c +4 -0
index 24d52f9..c52e7bf 100644
@@ -317,11 +317,13 @@ ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples)
  	switch (format) {
  	case SNDRV_PCM_FORMAT_S8:
  	case SNDRV_PCM_FORMAT_U8:
+	case SNDRV_PCM_FORMAT_DSD_U8:
  		return samples;
  	case SNDRV_PCM_FORMAT_S16_LE:
  	case SNDRV_PCM_FORMAT_S16_BE:
  	case SNDRV_PCM_FORMAT_U16_LE:
  	case SNDRV_PCM_FORMAT_U16_BE:
+	case SNDRV_PCM_FORMAT_DSD_U16_LE:
  		return samples * 2;
  	case SNDRV_PCM_FORMAT_S18_3LE:
  	case SNDRV_PCM_FORMAT_S18_3BE:
@@ -387,6 +389,8 @@ u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format)
  	case SNDRV_PCM_FORMAT_S20_3BE:
  	case SNDRV_PCM_FORMAT_S18_3LE:
  	case SNDRV_PCM_FORMAT_S18_3BE:
+	case SNDRV_PCM_FORMAT_DSD_U8:
+	case SNDRV_PCM_FORMAT_DSD_U16_LE:
  		return 0;
  	case SNDRV_PCM_FORMAT_U8:
  		return 0x8080808080808080ULL;
Signature · 1 line
Alexander E. Patrakov
#2 lore raw

At Fri, 15 Aug 2014 15:02:35 +0600,

Quoted 10 lines · Alexander E. Patrakov
Quoted 2 lines · Jurgen Kramer

Functions 'snd_pcm_format_silence_64' and 'snd_pcm_format_size' also need to be able to handle the DSD formats.

0 is not a DSD silence value. It is the most negative value, similar to -32768 for S16 samples. We need something that will average to zero.

ffmpeg uses a repeating pattern of 0x69 here, with this comment:

Quoted 7 lines

/* 0x69 = 01101001
* This pattern "on repeat" makes a low energy 352.8 kHz tone
* and a high energy 1.0584 MHz tone which should be filtered
* out completely by any playback system --> silence */

https://ffmpeg.org/pipermail/ffmpeg-cvslog/2014-April/076427.html

Good point. We need a fix in the kernel side, too.

Takashi