[Mplayer-cvslog] CVS: main dec_audio.c,1.65,1.66

Alex Beregszaszi alex at mplayer.dev.hu
Sat Dec 29 02:32:58 CET 2001


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

Modified Files:
	dec_audio.c 
Log Message:
more mad fix

Index: dec_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/dec_audio.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- dec_audio.c	29 Dec 2001 00:24:19 -0000	1.65
+++ dec_audio.c	29 Dec 2001 01:32:46 -0000	1.66
@@ -104,6 +104,7 @@
   if(sh_audio->a_in_buffer_len < length) {
     int len = demux_read_data(sh_audio->ds, sh_audio->a_in_buffer+sh_audio->a_in_buffer_len, length-sh_audio->a_in_buffer_len);
     sh_audio->a_in_buffer_len += len;
+//    printf("mad_prepare_buffer: read %d bytes\n", len);
   }
 }
 
@@ -137,6 +138,7 @@
 static void mad_sync(sh_audio_t* sh_audio, struct mad_stream* ms)
 {
     int len;
+#if 1
     int skipped = 0;
 
 //    printf("buffer len: %d\n", sh_audio->a_in_buffer_len);    
@@ -154,15 +156,27 @@
     if (skipped)
     {
 	printf("Audio synced, skipped bytes: %d\n", skipped);
-	ms->skiplen += skipped;
-    }
-    
-    if (sh_audio->a_in_buffer_len - skipped < MAD_BUFFER_GUARD)
-	printf("Mad reports: too small buffer\n");
+//	ms->skiplen += skipped;
+//	printf("skiplen: %d (skipped: %d)\n", ms->skiplen, skipped);
+
+//	if (sh_audio->a_in_buffer_len - skipped < MAD_BUFFER_GUARD)
+//	    printf("Mad reports: too small buffer\n");
 
-    mad_prepare_buffer(sh_audio, ms, sh_audio->a_in_buffer_len-skipped);
-    mad_stream_buffer(ms, sh_audio->a_in_buffer+skipped, sh_audio->a_in_buffer_len-skipped);
-#if 0    
+//	mad_stream_buffer(ms, sh_audio->a_in_buffer+skipped, sh_audio->a_in_buffer_len-skipped);
+//	mad_prepare_buffer(sh_audio, ms, sh_audio->a_in_buffer_len-skipped);
+
+	/* move frame to the beginning of the buffer and fill up to a_in_buffer_size */
+	sh_audio->a_in_buffer_len -= skipped;
+	memcpy(sh_audio->a_in_buffer, sh_audio->a_in_buffer+skipped, sh_audio->a_in_buffer_len);
+	mad_prepare_buffer(sh_audio, ms, sh_audio->a_in_buffer_size);
+	mad_stream_buffer(ms, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len);
+//	printf("bufflen: %d\n", sh_audio->a_in_buffer_len);
+	
+//	len = mp_decode_mp3_header(sh_audio->a_in_buffer);
+//	printf("len: %d\n", len);
+	ms->md_len = len;
+    }
+#else
     len = mad_stream_sync(&ms);
     if (len == -1)
     {
@@ -170,6 +184,37 @@
     }
 #endif
 }
+
+static void mad_print_error(struct mad_stream *mad_stream)
+{
+    printf("error (0x%x): ", mad_stream->error);
+    switch(mad_stream->error)
+    {
+	case MAD_ERROR_BUFLEN:	printf("buffer too small");		break;
+	case MAD_ERROR_BUFPTR:	printf("invalid buffer pointer"); 	break;
+	case MAD_ERROR_NOMEM:	printf("not enought memory");		break;
+	case MAD_ERROR_LOSTSYNC:	printf("lost sync");		break;
+	case MAD_ERROR_BADLAYER:	printf("bad layer");		break;
+	case MAD_ERROR_BADBITRATE:	printf("bad bitrate");		break;
+	case MAD_ERROR_BADSAMPLERATE:	printf("bad samplerate");	break;
+	case MAD_ERROR_BADEMPHASIS:	printf("bad emphasis");		break;
+	case MAD_ERROR_BADCRC:		printf("bad crc");		break;
+	case MAD_ERROR_BADBITALLOC:	printf("forbidden bit alloc val"); break;
+	case MAD_ERROR_BADSCALEFACTOR:	printf("bad scalefactor index"); break;
+	case MAD_ERROR_BADFRAMELEN:	printf("bad frame length");	break;
+	case MAD_ERROR_BADBIGVALUES:	printf("bad bigvalues count");	break;
+	case MAD_ERROR_BADBLOCKTYPE:	printf("reserved blocktype");	break;
+	case MAD_ERROR_BADSCFSI:	printf("bad scalefactor selinfo"); break;
+	case MAD_ERROR_BADDATAPTR:	printf("bad maindatabegin ptr"); break;
+	case MAD_ERROR_BADPART3LEN:	printf("bad audio data len");	break;
+	case MAD_ERROR_BADHUFFTABLE:	printf("bad huffman table sel"); break;
+	case MAD_ERROR_BADHUFFDATA:	printf("huffman data overrun");	break;
+	case MAD_ERROR_BADSTEREO:	printf("incomp. blocktype for JS"); break;
+	default:
+	    printf("unknown error");
+    }
+    printf("\n");
+}
 #endif
 
 
@@ -740,6 +785,7 @@
      else
        {
 	 printf(__FILE__ ":%d:mad: frame decoding failed\n", __LINE__);
+	 mad_print_error(&mad_stream);
        }
      
      switch (mad_frame.header.mode)
@@ -1130,8 +1176,7 @@
 	  {
 	    printf(__FILE__ ":%d:mad: frame decoding failed (error: %d)\n", __LINE__,
 		mad_stream.error);
-	    if (mad_stream.error & MAD_ERROR_LOSTSYNC)
-		printf("lost sync\n");
+	    mad_print_error(&mad_stream);
 	  }
 	
 	break;




More information about the MPlayer-cvslog mailing list