[Mplayer-cvslog] CVS: main/libmpdemux demux_audio.c,NONE,1.1 genres.h,NONE,1.1 demuxer.h,1.29,1.30 demuxer.c,1.74,1.75 Makefile,1.19,1.20 mp3_hdr.c,1.2,1.3

Alban Bedel CVS albeu at mplayer.dev.hu
Thu Feb 14 14:04:38 CET 2002


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

Modified Files:
	demuxer.h demuxer.c Makefile mp3_hdr.c 
Added Files:
	demux_audio.c genres.h 
Log Message:
Audio file demuxer. Extended version for demuxer info.
genres.h come from id3edit of servex at servex.yi.org found
at http://id3edit.sourceforge.net/ 


--- NEW FILE ---

#include "config.h"

#include <stdlib.h>
#include <stdio.h>
#include "stream.h"
#include "demuxer.h"
#include "stheader.h"
#include "genres.h"

#include <string.h>
#ifdef MP_DEBUG
#include <assert.h>
#endif

#define MP3 1
#define WAV 2


#define HDR_SIZE 4

typedef struct da_priv {
  int frmt;
} da_priv_t;

extern int mp_decode_mp3_header(unsigned char* hbuf);
extern void free_sh_audio(sh_audio_t* sh);


int demux_audio_open(demuxer_t* demuxer) {
  stream_t *s;
  sh_audio_t* sh_audio;
  uint8_t hdr[HDR_SIZE];
  int st_pos = 0,frmt = 0, n = 0, pos = 0, step;
  da_priv_t* priv;
#ifdef MP_DEBUG
  assert(demuxer != NULL);
  assert(demuxer->stream != NULL);
#endif
  
  s = demuxer->stream;

  while(n < 5 && ! s->eof) {
    st_pos = stream_tell(s);
    step = 1;
    if(pos < HDR_SIZE) {
      stream_read(s,&hdr[pos],HDR_SIZE-pos);
      pos = HDR_SIZE;
    }

    if( hdr[0] == 'R' && hdr[1] == 'I' && hdr[2] == 'F' && hdr[3] == 'F' ) {
      stream_skip(s,4);
      if(s->eof)
	break;
      stream_read(s,hdr,4);
      if(s->eof)
	break;
      if(hdr[0] != 'W' || hdr[1] != 'A' || hdr[2] != 'V'  || hdr[3] != 'E' )
	stream_skip(s,-8);
      else
      // We found wav header. Now we can have 'fmt ' or a mp3 header
      // empty the buffer
	step = 4;
    } else if( hdr[0] == 'f' && hdr[1] == 'm' && hdr[2] == 't' && hdr[3] == ' ' ) {
      frmt = WAV;
      break;      
    } else if(mp_decode_mp3_header(hdr) > 0) {
      frmt = MP3;
      break;
    }
    // Add here some other audio format detection
    if(step < HDR_SIZE)
      memmove(hdr,&hdr[step],HDR_SIZE-step);
    pos -= step;
  }

  if(!frmt)
    return 0;

  sh_audio = new_sh_audio(demuxer,0);

  switch(frmt) {
  case MP3:
    sh_audio->format = 0x55;
    stream_seek(s,st_pos);
    demuxer->movi_start = st_pos;
    if(s->end_pos) {
      char tag[4];
      stream_seek(s,s->end_pos-128);
      stream_read(s,tag,3);
      tag[3] = '\0';
      if(strcmp(tag,"TAG"))
	demuxer->movi_end = s->end_pos;
      else {
	char buf[31];
	uint8_t g;
	demuxer->movi_end = stream_tell(s)-3;
	stream_read(s,buf,30);
	buf[30] = '\0';
	demux_info_add(demuxer,"Title",buf);
	stream_read(s,buf,30);
	buf[30] = '\0';
	demux_info_add(demuxer,"Artist",buf);
	stream_read(s,buf,30);
	buf[30] = '\0';
	demux_info_add(demuxer,"Album",buf);
	stream_read(s,buf,4);
	buf[5] = '\0';
	demux_info_add(demuxer,"Year",buf);
	stream_read(s,buf,30);
	buf[30] = '\0';
	demux_info_add(demuxer,"Comment",buf);
	if(buf[28] == 0 && buf[29] != 0) {
	  uint8_t trk = (uint8_t)buf[29];
	  sprintf(buf,"%d",trk);
	  demux_info_add(demuxer,"Track",buf);
	}
	g = stream_read_char(s);
	demux_info_add(demuxer,"Genre",genres[g]);
      }
    }
    break;
  case WAV: {
    WAVEFORMATEX* w;
    int l;
    sh_audio->wf = w = (WAVEFORMATEX*)malloc(sizeof(WAVEFORMATEX));
    l = stream_read_dword_le(s);
    if(l < 16) {
      printf("Bad wav header length : too short !!!\n");
      free_sh_audio(sh_audio);
      return 0;
    }
    w->wFormatTag = sh_audio->format = stream_read_word_le(s);
    w->nChannels = sh_audio->channels = stream_read_word_le(s);
    w->nSamplesPerSec = sh_audio->samplerate = stream_read_dword_le(s);
    w->nAvgBytesPerSec = stream_read_dword_le(s);
    w->nBlockAlign = stream_read_word_le(s);
    w->wBitsPerSample = sh_audio->samplesize = stream_read_word_le(s);
    w->cbSize = 0;
    l -= 16;
    if(l)
      stream_skip(s,l);
    demuxer->movi_start = stream_tell(s);
    demuxer->movi_end = s->end_pos;
  } break;
  }

  priv = (da_priv_t*)malloc(sizeof(da_priv_t));
  priv->frmt = frmt;
  demuxer->priv = priv;
  demuxer->movi_start = st_pos;
  demuxer->audio->id = 0;
  demuxer->audio->sh = sh_audio;
  sh_audio->ds = demuxer->audio;

  if(stream_tell(s) != demuxer->movi_start)
    stream_seek(s,demuxer->movi_start);

  return 1;
}


int demux_audio_fill_buffer(demux_stream_t *ds) {
  sh_audio_t* sh_audio;
  demuxer_t* demux;
  da_priv_t* priv;
  stream_t* s;
#ifdef MP_DEBUG
  assert(ds != NULL);
  assert(ds->sh != NULL);
  assert(ds->demuxer != NULL);
#endif
  sh_audio = ds->sh;
  demux = ds->demuxer;
  priv = demux->priv;
  s = demux->stream;

  if(s->eof || (demux->movi_end && stream_tell(s) >= demux->movi_end) )
    return 0;

  switch(priv->frmt) {
  case MP3 :
    while(! s->eof || (demux->movi_end && stream_tell(s) >= demux->movi_end) ) {
      uint8_t hdr[4];
      int len;
      stream_read(s,hdr,4);
      len = mp_decode_mp3_header(hdr);
      if(len < 0) {
	stream_skip(s,-3);
      } else {
	demux_packet_t* dp;
	if(s->eof  || (demux->movi_end && stream_tell(s) >= demux->movi_end) )
	  return 0;
	dp = new_demux_packet(len);
	memcpy(dp->buffer,hdr,4);
	stream_read(s,dp->buffer + 4,len-4);
	ds_add_packet(ds,dp);
	return 1;
      }
    }
  case WAV : {
    int l = sh_audio->wf->nAvgBytesPerSec;
    demux_packet_t*  dp = new_demux_packet(l);
    stream_read(s,dp->buffer,l);
    ds_add_packet(ds,dp);
    return 1;
  }
  default:
    printf("Audio demuxer : unknow format %d\n",priv->frmt);
  }


  return 0;
}

void demux_audio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
  sh_audio_t* sh_audio;
  stream_t* s;
  int base,pos;
  float len;
  da_priv_t* priv;

  sh_audio = demuxer->audio->sh;
  s = demuxer->stream;
  priv = demuxer->priv;

  base = flags&1 ? demuxer->movi_start : stream_tell(s) ;
  len = (demuxer->movi_end && flags&2) ? (demuxer->movi_end - demuxer->movi_start)*rel_seek_secs : rel_seek_secs;

  pos = base+(len*sh_audio->i_bps);

  if(demuxer->movi_end && pos >= demuxer->movi_end) {
    sh_audio->timer = (stream_tell(s) - demuxer->movi_start)/sh_audio->i_bps;
    return;
  } else if(pos < demuxer->movi_start)
    pos = demuxer->movi_start;
  

  sh_audio->timer = flags&1 ? rel_seek_secs : (pos-demuxer->movi_start)/sh_audio->i_bps;

  switch(priv->frmt) {
  case WAV:
    pos += (pos % (sh_audio->channels * sh_audio->samplesize) );
    break;
  }

  stream_seek(s,pos);

}

--- NEW FILE ---
/***********************************
 * Copyright (C) 2001  Jason Carter
 * See the file "LICENSE" for details
 ***********************************
 * FILE: GENRES.H
 * NAME: ID3EDIT - ID3 tag v 1.1 editor
 * DESCRIPTION: Genres character array 
 * AUTHOR: Jason Carter
 ***********************************
 */


#ifndef _GENRES_H
#define _GENRES_H


char *genres[] = {
"Blues",					/* 0 */
"Classic Rock",				/* 1 */
"Country",					/* 2 */
"Dance",					/* 3 */
"Disco",					/* 4 */
"Funk",						/* 5 */
"Grunge",					/* 6 */
"Hip-Hop",					/* 7 */
"Jazz",						/* 8 */
"Metal",					/* 9 */
"New Age",					/* 10 */
"Oldies",					/* 11 */
"Other",					/* 12 */
"Pop",						/* 13 */
"R&B",						/* 14 */
"Rap",						/* 15 */
"Reggae",					/* 16 */
"Rock",						/* 17 */
"Techno",					/* 18 */
"Industrial",				/* 19 */
"Alternative",				/* 20 */
"Ska",						/* 21 */
"Death Metal",				/* 22 */
"Pranks",					/* 23 */
"Soundtrack",				/* 24 */
"Eurotechno",				/* 25 */
"Ambient",					/* 26 */
"Trip-Hop",					/* 27 */
"Vocal",					/* 28 */
"Jazz+Funk",				/* 29 */
"Fusion",					/* 30 */
"Trance",					/* 31 */
"Classical",				/* 32 */
"Instrumental",				/* 33 */
"Acid",						/* 34 */
"House",					/* 35 */
"Game",						/* 36 */
"Sound Clip",				/* 37 */
"Gospel",					/* 38 */
"Noise",					/* 39 */
"Alternative Rock",			/* 40 */
"Bass",						/* 41 */
"Soul",						/* 42 */
"Punk",						/* 43 */
"Space",					/* 44 */
"Meditative",				/* 45 */
"Instrumental Pop",			/* 46 */
"Instrumental Rock",		/* 47 */
"Ethnic",					/* 48 */
"Gothic",					/* 49 */
"Darkwave",					/* 50 */
"Techno-Industrial",		/* 51 */
"Electronic",				/* 52 */
"Jungle",					/* 53 */
"Pop-Folk",					/* 54 */
"Eurodance",				/* 55 */
"Dream",					/* 56 */
"Southern Rock",			/* 57 */
"Comedy",					/* 58 */
"Cult",						/* 59 */
"Gangsta",					/* 60 */
"Top 40",					/* 61 */
"Christian Rap",			/* 62 */
"Pop/Funk",					/* 63 */
"Native American",			/* 64 */
"Cabaret",					/* 65 */
"New Wave",					/* 66 */
"Psychadelic",				/* 67 */
"Rave",						/* 68 */
"Show Tunes",				/* 69 */
"Trailer",					/* 70 */
"Lo-Fi",					/* 71 */
"Tribal",					/* 72 */
"Acid Punk",				/* 73 */
"Acid Jazz",				/* 74 */
"Polka",					/* 75 */
"Retro",					/* 76 */
"Musical",					/* 77 */
"Rock & Roll",				/* 78 */
"Hard Rock",				/* 79 */
"Folk",						/* 80 */
"Folk/Rock",				/* 81 */
"National Folk",			/* 82 */
"Swing",					/* 83 */
"Fast-Fusion",				/* 84 */
"Bebop",					/* 85 */
"Latin",					/* 86 */
"Revival",					/* 87 */
"Celtic",					/* 88 */
"Bluegrass",				/* 89 */
"Avantgarde",				/* 90 */
"Gothic Rock",				/* 91 */
"Progressive Rock",			/* 92 */
"Psychedelic Rock",			/* 93 */
"Symphonic Rock",			/* 94 */
"Slow Rock",				/* 95 */
"Big Band",					/* 96 */
"Chorus",					/* 97 */
"Easy Listening",			/* 98 */
"Acoustic",					/* 99 */
"Humour",					/* 100 */
"Speech",					/* 101 */
"Chanson",					/* 102 */
"Opera",					/* 103 */
"Chamber Music",			/* 104 */
"Sonata",					/* 105 */
"Symphony",					/* 106 */
"Booty Bass",				/* 107 */
"Primus",					/* 108 */
"Porn Groove",				/* 109 */
"Satire",					/* 110 */
"Slow Jam",					/* 111 */
"Club",						/* 112 */
"Tango",					/* 113 */
"Samba",					/* 114 */
"Folklore",					/* 115 */
"Ballad",					/* 116 */
"Power Ballad",				/* 117 */
"Rhytmic Soul",				/* 118 */
"Freestyle",				/* 119 */
"Duet",						/* 120 */
"Punk Rock",				/* 121 */
"Drum Solo",				/* 122 */
"Acapella",					/* 123 */
"Euro-House",				/* 124 */
"Dance Hall",				/* 125 */
"Goa",						/* 126 */
"Drum & Bass",				/* 127 */
"Club-House",				/* 128 */
"Hardcore",					/* 129 */
"Terror",					/* 130 */
"Indie",					/* 131 */
"BritPop",					/* 132 */
"Negerpunk",				/* 133 */
"Polsk Punk",				/* 134 */
"Beat",						/* 135 */
"Christian Gangsta Rap",	/* 136 */
"Heavy Metal",				/* 137 */
"Black Metal",				/* 138 */
"Crossover",				/* 139 */
"Contemporary Christian",	/* 140 */
"Christian Rock",			/* 141 */
"Unknown",					/* 142 */
"Unknown",					/* 143 */
"Unknown",					/* 144 */
"Unknown",					/* 145 */
"Unknown",					/* 146 */
"Unknown",					/* 147 */
"Unknown",					/* 148 */
"Unknown",					/* 149 */
"Unknown",					/* 150 */
"Unknown",					/* 151 */
"Unknown",					/* 152 */
"Unknown",					/* 153 */
"Unknown",					/* 154 */
"Unknown",					/* 155 */
"Unknown",					/* 156 */
"Unknown",					/* 157 */
"Unknown",					/* 158 */
"Unknown",					/* 159 */
"Unknown",					/* 160 */
"Unknown",					/* 161 */
"Unknown",					/* 162 */
"Unknown",					/* 163 */
"Unknown",					/* 164 */
"Unknown",					/* 165 */
"Unknown",					/* 166 */
"Unknown",					/* 167 */
"Unknown",					/* 168 */
"Unknown",					/* 169 */
"Unknown",					/* 170 */
"Unknown",					/* 171 */
"Unknown",					/* 172 */
"Unknown",					/* 173 */
"Unknown",					/* 174 */
"Unknown",					/* 175 */
"Unknown",					/* 176 */
"Unknown",					/* 177 */
"Unknown",					/* 178 */
"Unknown",					/* 179 */
"Unknown",					/* 180 */
"Unknown",					/* 181 */
"Unknown",					/* 182 */
"Unknown",					/* 183 */
"Unknown",					/* 184 */
"Unknown",					/* 185 */
"Unknown",					/* 186 */
"Unknown",					/* 187 */
"Unknown",					/* 188 */
"Unknown",					/* 189 */
"Unknown",					/* 190 */
"Unknown",					/* 191 */
"Unknown",					/* 192 */
"Unknown",					/* 193 */
"Unknown",					/* 194 */
"Unknown",					/* 195 */
"Unknown",					/* 196 */
"Unknown",					/* 197 */
"Unknown",					/* 198 */
"Unknown",					/* 199 */
"Unknown",					/* 200 */
"Unknown",					/* 201 */
"Unknown",					/* 202 */
"Unknown",					/* 203 */
"Unknown",					/* 204 */
"Unknown",					/* 205 */
"Unknown",					/* 206 */
"Unknown",					/* 207 */
"Unknown",					/* 208 */
"Unknown",					/* 209 */
"Unknown",					/* 210 */
"Unknown",					/* 211 */
"Unknown",					/* 212 */
"Unknown",					/* 213 */
"Unknown",					/* 214 */
"Unknown",					/* 215 */
"Unknown",					/* 216 */
"Unknown",					/* 217 */
"Unknown",					/* 218 */
"Unknown",					/* 219 */
"Unknown",					/* 220 */
"Unknown",					/* 221 */
"Unknown",					/* 222 */
"Unknown",					/* 223 */
"Unknown",					/* 224 */
"Unknown",					/* 225 */
"Unknown",					/* 226 */
"Unknown",					/* 227 */
"Unknown",					/* 228 */
"Unknown",					/* 229 */
"Unknown",					/* 230 */
"Unknown",					/* 231 */
"Unknown",					/* 232 */
"Unknown",					/* 233 */
"Unknown",					/* 234 */
"Unknown",					/* 235 */
"Unknown",					/* 236 */
"Unknown",					/* 237 */
"Unknown",					/* 238 */
"Unknown",					/* 239 */
"Unknown",					/* 240 */
"Unknown",					/* 241 */
"Unknown",					/* 242 */
"Unknown",					/* 243 */
"Unknown",					/* 244 */
"Unknown",					/* 245 */
"Unknown",					/* 246 */
"Unknown",					/* 247 */
"Unknown",					/* 248 */
"Unknown",					/* 249 */
"Unknown",					/* 250 */
"Unknown",					/* 251 */
"Unknown",					/* 252 */
"Unknown",					/* 253 */
"Unknown",					/* 254 */
"Unknown",					/* 255 */
};


#endif /* _GENRES_H */

Index: demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- demuxer.h	10 Feb 2002 18:09:20 -0000	1.29
+++ demuxer.h	14 Feb 2002 13:04:35 -0000	1.30
@@ -19,6 +19,7 @@
 #define DEMUXER_TYPE_FILM 14
 #define DEMUXER_TYPE_ROQ 15
 #define DEMUXER_TYPE_MF 16
+#define DEMUXER_TYPE_AUDIO 17
 
 #define DEMUXER_TIME_NONE 0
 #define DEMUXER_TIME_PTS 1
@@ -94,7 +95,7 @@
   char s_streams[32];   // dvd subtitles (flag)
   
   void* priv;  // fileformat-dependent data
-  demuxer_info_t info;
+  char** info;
 } demuxer_t;
 
 inline static demux_packet_t* new_demux_packet(int len){

Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- demuxer.c	11 Feb 2002 12:11:48 -0000	1.74
+++ demuxer.c	14 Feb 2002 13:04:35 -0000	1.75
@@ -125,6 +125,11 @@
     // free demuxers:
     free_demuxer_stream(demuxer->audio);
     free_demuxer_stream(demuxer->video);
+    if(demuxer->info) {
+      for(i=0;demuxer->info[i] != NULL; i++)
+	free(demuxer->info[i]);
+      free(demuxer->info);
+    }
     free(demuxer);
 }
 
@@ -186,6 +191,7 @@
 extern int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh);
 #endif
 int demux_y4m_fill_buffer(demuxer_t *demux);
+int demux_audio_fill_buffer(demux_stream_t *ds);
 
 int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
   // Note: parameter 'ds' can be NULL!
@@ -209,6 +215,7 @@
     case DEMUXER_TYPE_TV: return demux_tv_fill_buffer(demux, tv_handler);
 #endif
     case DEMUXER_TYPE_Y4M: return demux_y4m_fill_buffer(demux);
+    case DEMUXER_TYPE_AUDIO: return demux_audio_fill_buffer(ds);
   }
   return 0;
 }
@@ -398,6 +405,7 @@
 
 extern int nuv_check_file(demuxer_t *demuxer);
 extern void demux_open_nuv(demuxer_t *demuxer);
+extern int demux_audio_open(demuxer_t* demuxer);
 
 demuxer_t* demux_open(stream_t *stream,int file_format,int audio_id,int video_id,int dvdsub_id){
 
@@ -535,6 +543,15 @@
   } else
       free_demuxer(demuxer);
 }
+//=============== Try to open as audio file: =================
+if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_AUDIO){
+  demuxer=new_demuxer(stream,DEMUXER_TYPE_AUDIO,audio_id,video_id,dvdsub_id);
+  if(demux_audio_open(demuxer)){
+    mp_msg(MSGT_DEMUXER,MSGL_INFO,"Detected audio file\n");
+    file_format=DEMUXER_TYPE_AUDIO;
+  } else
+    free_demuxer(demuxer);
+}
 //=============== Try to open as MPEG-PS file: =================
 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
  int pes=1;
@@ -749,6 +766,7 @@
 int demux_seek_mf(demuxer_t *demuxer,float rel_seek_secs,int flags);
 int demux_seek_nuv(demuxer_t *demuxer,float rel_seek_secs,int flags);
 void demux_seek_mov(demuxer_t *demuxer,float pts,int flags);
+extern void demux_audio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
 
 int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
     demux_stream_t *d_audio=demuxer->audio;
@@ -808,6 +826,8 @@
       demux_seek_fli(demuxer,rel_seek_secs,flags);  break;
   case DEMUXER_TYPE_NUV:
       demux_seek_nuv(demuxer,rel_seek_secs,flags);  break;
+  case DEMUXER_TYPE_AUDIO:
+      demux_audio_seek(demuxer,rel_seek_secs,flags);  break;
 
 
 } // switch(demuxer->file_format)
@@ -817,86 +837,38 @@
 
 int demux_info_add(demuxer_t *demuxer, char *opt, char *param)
 {
-    demuxer_info_t *info = &demuxer->info;
-
-    if (!strcasecmp(opt, "name"))
-    {
-	if (info->name)
-	{
-	    mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->name already present\n!");
-	    return(0);
-	}
-	info->name = strdup(param);
-	return(1);
-    }
-
-    if (!strcasecmp(opt, "author"))
-    {
-	if (info->author)
-	{
-	    mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->author already present\n!");
-	    return(0);
-	}
-	info->author = strdup(param);
-	return(1);
-    }
-
-    if (!strcasecmp(opt, "encoder") || !strcasecmp(opt, "software"))
-    {
-	if (info->encoder)
-	{
-	    mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->encoder already present\n!");
-	    return(0);
-	}
-	info->encoder = strdup(param);
-	return(1);
-    }
+    char **info = demuxer->info;
+    int n = 0;
 
-    if (!strcasecmp(opt, "comment") || !strcasecmp(opt, "comments"))
-    {
-	if (info->comments)
-	{
-	    mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->comments already present\n!");
-	    return(0);
-	}
-	info->comments = strdup(param);
-	return(1);
-    }
 
-    if (!strcasecmp(opt, "copyright"))
-    {
-	if (info->copyright)
-	{
-	    mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->copyright already present\n!");
-	    return(0);
-	}
-	info->copyright = strdup(param);
-	return(1);
-    }
+    for(n = 0; info && info[2*n] != NULL; n++) 
+      {
+	if(!strcasecmp(opt,info[2*n]))
+	  {
+	    mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info %s already present\n!",opt);
+	    return 0;
+	  }
+      }
+    
+    info = demuxer->info = (char**)realloc(info,(2*(n+2))*sizeof(char*));
+    info[2*n] = strdup(opt);
+    info[2*n+1] = strdup(param);
+    memset(&info[2*(n+1)],0,2*sizeof(char*));
 
-    mp_msg(MSGT_DEMUX, MSGL_DBG2, "Unknown demuxer info->%s (=%s)!\n",
-	opt, param);
-    return(1);
+    return 1;
 }
 
 int demux_info_print(demuxer_t *demuxer)
 {
-    demuxer_info_t *info = &demuxer->info;
+    char **info = demuxer->info;
+    int n;
 
-    if (info->name || info->author || info->encoder || info->comments || info->copyright)
-    {
-	mp_msg(MSGT_DEMUX, MSGL_INFO, "Clip info: \n");
-	if (info->name)
-	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Name: %s\n", info->name);
-	if (info->author)
-	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Author: %s\n", info->author);
-	if (info->copyright)
-	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Copyright: %s\n", info->copyright);
-	if (info->comments)
-	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Comments: %s\n", info->comments);
-	if (info->encoder)
-	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Encoder: %s\n", info->encoder);
-    }
+    if(!info)
+      return 0;
+
+    mp_msg(MSGT_DEMUX, MSGL_INFO, "Clip info: \n");
+    for(n = 0; info[2*n] != NULL ; n++)
+      mp_msg(MSGT_DEMUX, MSGL_INFO, " %s: %s\n",info[2*n],info[2*n+1]);
 
     return 0;
 }

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Makefile	6 Feb 2002 20:16:35 -0000	1.19
+++ Makefile	14 Feb 2002 13:04:35 -0000	1.20
@@ -3,7 +3,7 @@
 
 include ../config.mak
 
-SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c
+SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c
 ifeq ($(STREAMING),yes)
 SRCS += asf_streaming.c url.c http.c network.c rtp.c
 endif

Index: mp3_hdr.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/mp3_hdr.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mp3_hdr.c	31 Oct 2001 14:42:32 -0000	1.2
+++ mp3_hdr.c	14 Feb 2002 13:04:35 -0000	1.3
@@ -1,6 +1,7 @@
 #include <stdio.h>
 
 #include "config.h"
+#include "../mp_msg.h"
 
 //----------------------- mp3 audio frame header parser -----------------------
 
@@ -32,12 +33,15 @@
     // head_check:
     if( (newhead & 0xffe00000) != 0xffe00000 ||  
         (newhead & 0x0000fc00) == 0x0000fc00){
-	printf("head_check failed\n");
+	mp_msg(MSGT_DEMUXER,MSGL_DBG2,"head_check failed\n");
 	return -1;
     }
 #endif
 
-    if((4-((newhead>>17)&3))!=3){ printf("not layer-3\n"); return -1;}
+    if((4-((newhead>>17)&3))!=3){ 
+      mp_msg(MSGT_DEMUXER,MSGL_DBG2,"not layer-3\n"); 
+      return -1;
+    }
 
     if( newhead & ((long)1<<20) ) {
       lsf = (newhead & ((long)1<<19)) ? 0x0 : 0x1;
@@ -53,7 +57,7 @@
       sampling_frequency = ((newhead>>10)&0x3) + (lsf*3);
 
     if(sampling_frequency>8){
-	printf("invalid sampling_frequency\n");
+	mp_msg(MSGT_DEMUXER,MSGL_DBG2,"invalid sampling_frequency\n");
 	return -1;  // valid: 0..8
     }
 
@@ -70,7 +74,7 @@
     stereo    = ( (((newhead>>6)&0x3)) == 3) ? 1 : 2;
 
     if(!bitrate_index){
-      fprintf(stderr,"Free format not supported.\n");
+      mp_msg(MSGT_DEMUXER,MSGL_DBG2,"Free format not supported.\n");
       return -1;
     }
 




More information about the MPlayer-cvslog mailing list