[Mplayer-cvslog] CVS: main dec_audio.c,1.61,1.62 ac3-iec958.c,1.1,1.2 ac3-iec958.h,1.1,1.2

Arpi of Ize arpi at mplayer.dev.hu
Fri Dec 28 13:03:57 CET 2001


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv11700

Modified Files:
	dec_audio.c ac3-iec958.c ac3-iec958.h 
Log Message:
hwac3 fixes by Steven Brookes <stevenjb at mda.co.uk>

Index: dec_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/dec_audio.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- dec_audio.c	28 Dec 2001 06:47:15 -0000	1.61
+++ dec_audio.c	28 Dec 2001 12:03:52 -0000	1.62
@@ -273,6 +273,7 @@
   // Dolby AC3 audio:
   sh_audio->audio_out_minsize=4*256*6;
   sh_audio->sample_format = AFMT_AC3;
+  sh_audio->channels=1;
   break;
 case AFM_GSM:
   // MS-GSM audio codec:
@@ -425,27 +426,32 @@
   break;
 }
 case AFM_HWAC3: {
-  unsigned char *buffer;		    
-  struct hwac3info ai;
-  int len, skipped;
-  len = ds_get_packet(sh_audio->ds, &buffer); // maybe 1 packet is not enough,
-    // at least for mpeg, PS packets contain about max. 2000 bytes of data.
-  if(ac3_iec958_parse_syncinfo(buffer, len, &ai, &skipped) < 0) {
-      mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_AC3notvalid);
-      driver = 0;
-      break;
+  // Dolby AC3 passthrough:
+  int accel=0; // should contain mmx/sse/etc flags
+  a52_samples=a52_init (accel);
+  if (a52_samples == NULL) {
+       mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n");
+       driver=0;break;
   }
-  if(ai.samplerate != 48000) {
-      mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_AC3only48k);
-      driver = 0;
-      break;
+  sh_audio->a_in_buffer_size=3840;
+  sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
+  sh_audio->a_in_buffer_len=0;
+  if(a52_fillbuff(sh_audio)<0) {
+       mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n");
+       driver=0;break;
   }
-  sh_audio->samplerate=ai.samplerate;
-  sh_audio->samplesize=ai.framesize;
+  
+  //sh_audio->samplerate=ai.samplerate;   // SET by a52_fillbuff()
+  //sh_audio->samplesize=ai.framesize;
+  //sh_audio->i_bps=ai.bitrate*(1000/8);  // SET by a52_fillbuff()
+  //sh_audio->ac3_frame=malloc(6144);
+  //sh_audio->o_bps=sh_audio->i_bps;  // XXX FIXME!!! XXX
+
+  // o_bps is calculated from samplesize*channels*samplerate
+  // a single ac3 frame is always translated to 6144 byte packet. (zero padding)
   sh_audio->channels=1;
-  sh_audio->i_bps=ai.bitrate*(1000/8);
-  sh_audio->ac3_frame=malloc(6144);
-  sh_audio->o_bps=sh_audio->i_bps;  // XXX FIXME!!! XXX
+  sh_audio->samplesize=4;   // 1*4*(6*256) = 6144 (very TRICKY!)
+
   break;
 }
 case AFM_ALAW: {
@@ -1000,10 +1006,11 @@
 	break;
       }
       case AFM_HWAC3: // AC3 through SPDIF
-	if(demux_read_data(sh_audio->ds,sh_audio->ac3_frame, 6144) != 6144) 
-	    break; //EOF 
-	ac3_iec958_build_burst(1536, 0x1F, 1, buf, sh_audio->ac3_frame);
-	len = 6144;
+        if(!sh_audio->a_in_buffer_len)
+	    if((len=a52_fillbuff(sh_audio))<0) break; //EOF
+	sh_audio->a_in_buffer_len=0;
+	len = ac3_iec958_build_burst(len, 0x01, 1, sh_audio->a_in_buffer, buf);
+	// len = 6144 = 4*(6*256)
 	break;
 #ifdef USE_WIN32DLL
       case AFM_ACM:
@@ -1122,6 +1129,7 @@
               switch(sh_audio->codec->driver){
                 case AFM_MPEG: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame
                 case AFM_AC3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame
+		case AFM_HWAC3:
                 case AFM_A52: a52_fillbuff(sh_audio);break; // skip AC3 frame
 		case AFM_ACM:
 		case AFM_DSHOW: {

Index: ac3-iec958.c
===================================================================
RCS file: /cvsroot/mplayer/main/ac3-iec958.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ac3-iec958.c	15 Aug 2001 11:46:13 -0000	1.1
+++ ac3-iec958.c	28 Dec 2001 12:03:52 -0000	1.2
@@ -83,23 +83,23 @@
   } bsi;
 }; 
 
-void ac3_iec958_build_burst(int length, int data_type, int big_endian, unsigned char * data, unsigned char * out)
+int ac3_iec958_build_burst(int length, int data_type, int big_endian, unsigned char * data, unsigned char * out)
 {
-	const char sync[4] = { 0x72, 0xF8, 0x1F, 0x4E };
+	const char sync[6] = { 0x72, 0xF8, 0x1F, 0x4E, 0x00, 0x00 };
 
-	memcpy(out, sync, 4);
+	memcpy(out, sync, 6);
 	if (length)
 		out[4] = data_type; /* & 0x1F; */
 	else
 		out[4] = 0;
-	out[5] = 0x00;
-	out[6] = (length*8) & 0xFF;
-	out[7] = ((length*8) >> 8) & 0xFF;
+	out[6] = (length << 3) & 0xFF;
+	out[7] = (length >> 5) & 0xFF;
 	if (big_endian)
 		swab(data, out + 8, length);
 	else
-		memcpy(data, out + 8, length);
+		memcpy(out + 8, data, length);
 	memset(out + 8 + length, 0, 6144 - 8 - length);
+	return 6144;
 }
 
 int ac3_iec958_parse_syncinfo(unsigned char *buf, int size, struct hwac3info *ai, int *skipped)

Index: ac3-iec958.h
===================================================================
RCS file: /cvsroot/mplayer/main/ac3-iec958.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ac3-iec958.h	15 Aug 2001 11:46:13 -0000	1.1
+++ ac3-iec958.h	28 Dec 2001 12:03:52 -0000	1.2
@@ -7,7 +7,7 @@
   int bitrate, framesize, samplerate, bsmod;
 };
 
-void ac3_iec958_build_burst(int length, int data_type, int big_endian, unsigned char * data, unsigned char * out);
+int ac3_iec958_build_burst(int length, int data_type, int big_endian, unsigned char * data, unsigned char * out);
 int ac3_iec958_parse_syncinfo(unsigned char *buf, int size, struct hwac3info *ai, int *skipped);
 
 #endif




More information about the MPlayer-cvslog mailing list