[Mplayer-cvslog] CVS: main/libmpcodecs dec_audio.c,1.10,1.11 dec_audio.h,1.3,1.4 dec_video.c,1.150,1.151 dec_video.h,1.11,1.12

Arpi of Ize arpi at mplayerhq.hu
Thu Sep 26 01:45:36 CEST 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv19126/libmpcodecs

Modified Files:
	dec_audio.c dec_audio.h dec_video.c dec_video.h 
Log Message:
best audio/video codec selection & init moved to libmpcodecs


Index: dec_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/dec_audio.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- dec_audio.c	1 Sep 2002 23:33:30 -0000	1.10
+++ dec_audio.c	25 Sep 2002 23:45:34 -0000	1.11
@@ -129,6 +129,41 @@
   return 1;
 }
 
+int init_best_audio_codec(sh_audio_t *sh_audio,char* audio_codec,char* audio_fm){
+  // Go through the codec.conf and find the best codec...
+  sh_audio->codec=NULL;
+  if(audio_fm) mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_TryForceAudioFmtStr,audio_fm);
+  while(1){
+    sh_audio->codec=find_codec(sh_audio->format,NULL,sh_audio->codec,1);
+    if(!sh_audio->codec){
+      if(audio_fm) {
+        sh_audio->codec=NULL; /* re-search */
+        mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_CantFindAfmtFallback);
+        audio_fm=NULL;
+        continue;
+      }
+      mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_CantFindAudioCodec,sh_audio->format);
+      mp_msg(MSGT_DECAUDIO,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf"));
+      return 0;
+    }
+    if(audio_codec && strcmp(sh_audio->codec->name,audio_codec)) continue;
+    if(audio_fm && strcmp(sh_audio->codec->drv,audio_fm)) continue;
+    mp_msg(MSGT_DECAUDIO,MSGL_INFO,"%s audio codec: [%s] afm:%s (%s)\n",
+	audio_codec?mp_gettext("Forcing"):mp_gettext("Detected"),sh_audio->codec->name,sh_audio->codec->drv,sh_audio->codec->info);
+    break;
+  }
+  // found it...
+  if(!init_audio(sh_audio)){
+    mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_CouldntInitAudioCodec);
+    return 0;
+  }
+  mp_msg(MSGT_DECAUDIO,MSGL_INFO,"AUDIO: %d Hz, %d ch, sfmt: 0x%X (%d bps), ratio: %d->%d (%3.1f kbit)\n",
+	sh_audio->samplerate,sh_audio->channels,
+	sh_audio->sample_format,sh_audio->samplesize,
+        sh_audio->i_bps,sh_audio->o_bps,sh_audio->i_bps*8*0.001);
+  return 1; // success!
+}
+
 void uninit_audio(sh_audio_t *sh_audio)
 {
     if(sh_audio->inited){

Index: dec_audio.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/dec_audio.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- dec_audio.h	31 Aug 2002 13:09:23 -0000	1.3
+++ dec_audio.h	25 Sep 2002 23:45:34 -0000	1.4
@@ -1,6 +1,7 @@
 
 // dec_audio.c:
 extern void afm_help();
+extern int init_best_audio_codec(sh_audio_t *sh_audio,char* audio_codec,char* audio_fm);
 extern int init_audio(sh_audio_t *sh_audio);
 extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen);
 extern void resync_audio_stream(sh_audio_t *sh_audio);

Index: dec_video.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/dec_video.c,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -r1.150 -r1.151
--- dec_video.c	10 Sep 2002 22:18:32 -0000	1.150
+++ dec_video.c	25 Sep 2002 23:45:34 -0000	1.151
@@ -204,6 +204,39 @@
     return 0;
 }
 
+int init_best_video_codec(sh_video_t *sh_video,char* video_codec,char* video_fm){
+// Go through the codec.conf and find the best codec...
+sh_video->inited=0;
+codecs_reset_selection(0);
+if(video_codec){
+    // forced codec by name:
+    mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_ForcedVideoCodec,video_codec);
+    init_video(sh_video,video_codec,NULL,-1);
+} else {
+    int status;
+    // try in stability order: UNTESTED, WORKING, BUGGY. never try CRASHING.
+    if(video_fm){
+	// try first the preferred codec family:
+	mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_TryForceVideoFmtStr,video_fm);
+	for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status)
+	    if(init_video(sh_video,NULL,video_fm,status)) break;
+    }
+    if(!sh_video->inited)
+	for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status)
+	    if(init_video(sh_video,NULL,NULL,status)) break;
+}
+
+if(!sh_video->inited){
+    mp_msg(MSGT_DECVIDEO,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf"));
+    mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format);
+    return 0; // failed
+}
+
+mp_msg(MSGT_DECVIDEO,MSGL_INFO,"%s video codec: [%s] vfm:%s (%s)\n",
+    video_codec?mp_gettext("Forcing"):mp_gettext("Detected"),sh_video->codec->name,sh_video->codec->drv,sh_video->codec->info);
+return 1; // success
+}
+
 extern int vo_directrendering;
 
 int decode_video(sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){

Index: dec_video.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/dec_video.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- dec_video.h	22 Sep 2002 02:33:25 -0000	1.11
+++ dec_video.h	25 Sep 2002 23:45:34 -0000	1.12
@@ -4,6 +4,8 @@
 
 extern void vfm_help();
 
+extern int init_best_video_codec(sh_video_t *sh_video,char* video_codec,char* video_fm);
+
 //extern int init_video(sh_video_t *sh_video, int *pitches);
 extern int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status);
 extern void uninit_video(sh_video_t *sh_video);




More information about the MPlayer-cvslog mailing list