changeset 3439:192449c155c7

fixed Waveformatheader emu and added vivo1/2 audio detection
author alex
date Mon, 10 Dec 2001 17:48:09 +0000
parents 963b39283f48
children 03caf0beaecc
files libmpdemux/demux_viv.c
diffstat 1 files changed, 29 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_viv.c	Mon Dec 10 17:37:18 2001 +0000
+++ b/libmpdemux/demux_viv.c	Mon Dec 10 17:48:09 2001 +0000
@@ -34,10 +34,11 @@
     /* audio */
     int		br;
     int		samplerate;
+    int		audio_len;
 } vivo_priv_t;
 
 /* parse all possible extra headers */
-/* (audio headers are seperate - mostly with recordtype=3) */
+/* (audio headers are seperate - mostly with recordtype=3 or 4) */
 #define TEXTPARSE_ALL 1
 
 static void vivo_parse_text_header(demuxer_t *demux, int header_len)
@@ -47,6 +48,7 @@
     int i;
     char *token;
     char *opt, *param;
+    int parser_in_audio_block = 0;
 
     if (!demux->priv)
     {
@@ -84,9 +86,8 @@
 	    mp_msg(MSGT_DEMUX, MSGL_DBG2, "Version: %s\n", param);
 	    if (!strncmp(param, "Vivo/1", 6) || !strncmp(param, "Vivo/2", 6))
 	    {
-//	    if (atoi(param) == 1 || atoi(param) == 2)
 		priv->supported = 1;
-		/* safe version for fourcc */
+		/* save major version for fourcc */
 		priv->version = param[5];
 	    }
 	}
@@ -119,6 +120,14 @@
 	}
 
 	/* audio specific */
+	if (!strcmp(opt, "RecordType"))
+	{
+	    /* 3 by Vivo/1.00, 4 by Vivo/2.00 */
+	    if ((atoi(param) == 3) || (atoi(param) == 4))
+		parser_in_audio_block = 1;
+	    else
+		parser_in_audio_block = 0;
+	}
 	if (!strcmp(opt, "NominalBitrate"))
 	{
 	    mp_msg(MSGT_DEMUX, MSGL_DBG2, "Bitrate: %d\n", atoi(param));
@@ -129,32 +138,36 @@
 	    mp_msg(MSGT_DEMUX, MSGL_DBG2, "Samplerate: %d\n", atoi(param));
 	    priv->samplerate = atoi(param);
 	}
+	if (!strcmp(opt, "Length") && (parser_in_audio_block == 1))
+	{
+	    priv->audio_len = atoi(param); /* 24 or 40 kbps */
+	}
 	
 	/* only for displaying some informations about movie*/
 	if (!strcmp(opt, "Title"))
 	{
-	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Title: %s\n", param);
+//	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Title: %s\n", param);
 	    demux_info_add(demux, "name", param);
 	    priv->title = malloc(strlen(param));
 	    strcpy(priv->title, param);
 	}
 	if (!strcmp(opt, "Author"))
 	{
-	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Author: %s\n", param);
+//	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Author: %s\n", param);
 	    demux_info_add(demux, "author", param);
 	    priv->author = malloc(strlen(param));
 	    strcpy(priv->author, param);
 	}
 	if (!strcmp(opt, "Copyright"))
 	{
-	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Copyright: %s\n", param);
+//	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Copyright: %s\n", param);
 	    demux_info_add(demux, "copyright", param);
 	    priv->copyright = malloc(strlen(param));
 	    strcpy(priv->copyright, param);
 	}
 	if (!strcmp(opt, "Producer"))
 	{
-	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Producer: %s\n", param);
+//	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Producer: %s\n", param);
 	    demux_info_add(demux, "encoder", param);
 	    priv->producer = malloc(strlen(param));
 	    strcpy(priv->producer, param);
@@ -555,13 +568,20 @@
   } else
 {		sh_audio_t* sh=new_sh_audio(demuxer,1);
 
-		sh->format=0x111; // 0x112
+		if (priv->version == '2')
+		    sh->format=0x112; /* Vivo Siren */
+		else
+//		if (priv->version == '1')
+		    sh->format=0x111; /* Vivo G.723 */
+
 //		if (sh->format == 0x111) /* G.723 */
-//		sh->samplesize = demuxer->audio->buffer_size;
+//		sh->samplesize = priv->audio_len; /* 24 or 40 kbps */
 //		printf("samplesize: %d\n", sh->samplesize);
+
 		// Emulate WAVEFORMATEX struct:
 		sh->wf=malloc(sizeof(WAVEFORMATEX));
 		memset(sh->wf,0,sizeof(WAVEFORMATEX));
+		sh->wf->wFormatTag=sh->format;
 		sh->wf->nChannels=1;
 		sh->wf->wBitsPerSample=16;
 //		sh->wf->wBitsPerSample=8;