changeset 7670:d388a7ee48c5

parse samplerate & channels from LPCM header
author arpi
date Tue, 08 Oct 2002 22:56:43 +0000
parents 0b3b1cbebd99
children 2d186a94dd5f
files libmpcodecs/ad_dvdpcm.c
diffstat 1 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/ad_dvdpcm.c	Tue Oct 08 22:55:55 2002 +0000
+++ b/libmpcodecs/ad_dvdpcm.c	Tue Oct 08 22:56:43 2002 +0000
@@ -19,11 +19,23 @@
 static int init(sh_audio_t *sh)
 {
 /* DVD PCM Audio:*/
-    sh->channels=2;
-    sh->samplerate=48000;
-    sh->i_bps=2*2*48000;
-/*    sh_audio->pcm_bswap=1;*/
-  return 1;
+    if(sh->codecdata_len==3){
+	// we have LPCM header:
+	unsigned char h=sh->codecdata[1];
+	sh->channels=1+(h&7);
+	switch((h>>4)&3){
+	case 0: sh->samplerate=48000;break;
+	case 1: sh->samplerate=96000;break;
+	case 2: sh->samplerate=44100;break;
+	case 3: sh->samplerate=32000;break;
+	}
+    } else {
+	// use defaults:
+	sh->channels=2;
+	sh->samplerate=48000;
+    }
+    sh->i_bps=2*sh->channels*sh->samplerate;
+    return 1;
 }
 
 static int preinit(sh_audio_t *sh)