summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-09-25 23:45:34 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-09-25 23:45:34 +0000
commit1fbd3baf78a734372fc3483155af4fb17ced7019 (patch)
tree5c8aea6ee6872a5773d1ca6d4d4681fa6e5553eb
parent2c23e786e5a6ef60803036d79de380cc7dc1f55c (diff)
downloadmpv-1fbd3baf78a734372fc3483155af4fb17ced7019.tar.bz2
mpv-1fbd3baf78a734372fc3483155af4fb17ced7019.tar.xz
best audio/video codec selection & init moved to libmpcodecs
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7503 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libmpcodecs/dec_audio.c35
-rw-r--r--libmpcodecs/dec_audio.h1
-rw-r--r--libmpcodecs/dec_video.c33
-rw-r--r--libmpcodecs/dec_video.h2
-rw-r--r--mencoder.c65
-rw-r--r--mplayer.c78
6 files changed, 89 insertions, 125 deletions
diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c
index 3def4897d8..01535a3375 100644
--- a/libmpcodecs/dec_audio.c
+++ b/libmpcodecs/dec_audio.c
@@ -129,6 +129,41 @@ int init_audio(sh_audio_t *sh_audio)
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){
diff --git a/libmpcodecs/dec_audio.h b/libmpcodecs/dec_audio.h
index f5a2453ca6..c71a20e568 100644
--- a/libmpcodecs/dec_audio.h
+++ b/libmpcodecs/dec_audio.h
@@ -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);
diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c
index ad4fce1f84..a29e95cf3a 100644
--- a/libmpcodecs/dec_video.c
+++ b/libmpcodecs/dec_video.c
@@ -204,6 +204,39 @@ int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status){
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){
diff --git a/libmpcodecs/dec_video.h b/libmpcodecs/dec_video.h
index cb3a088d63..5663b9071f 100644
--- a/libmpcodecs/dec_video.h
+++ b/libmpcodecs/dec_video.h
@@ -4,6 +4,8 @@ extern int video_read_properties(sh_video_t *sh_video);
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);
diff --git a/mencoder.c b/mencoder.c
index b378accffc..ca079fe83f 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -485,38 +485,11 @@ sh_video=d_video->sh;
if(sh_audio && (out_audio_codec || seek_to_sec || !sh_audio->wf)){
// Go through the codec.conf and find the best codec...
- sh_audio->codec=NULL;
- if(audio_fm) mp_msg(MSGT_MENCODER,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_MENCODER,MSGL_ERR,MSGTR_CantFindAfmtFallback);
- audio_fm=NULL;
- continue;
- }
- mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantFindAudioCodec,sh_audio->format);
- mp_msg(MSGT_MENCODER,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf"));
- sh_audio=d_audio->sh=NULL;
- break;
- }
- if(audio_codec && strcmp(sh_audio->codec->name,audio_codec)) continue;
- else if(audio_fm && strcmp(sh_audio->codec->drv,audio_fm)) continue;
- mp_msg(MSGT_MENCODER,MSGL_INFO,"%s audio codec: [%s] afm:%s (%s)\n",audio_codec?"Forcing":"Detected",sh_audio->codec->name,sh_audio->codec->drv,sh_audio->codec->info);
- break;
- }
-}
-
-if(sh_audio && (out_audio_codec || seek_to_sec || !sh_audio->wf)){
- mp_msg(MSGT_MENCODER,MSGL_V,MSGTR_InitializingAudioCodec);
- if(!init_audio(sh_audio)){
- mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CouldntInitAudioCodec);
- sh_audio=d_audio->sh=NULL;
- } else {
- mp_msg(MSGT_MENCODER,MSGL_INFO,"AUDIO: srate=%d chans=%d bps=%d sfmt=0x%X ratio: %d->%d\n",sh_audio->samplerate,sh_audio->channels,sh_audio->samplesize,
- sh_audio->sample_format,sh_audio->i_bps,sh_audio->o_bps);
+ mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
+ if(!init_best_audio_codec(sh_audio,audio_codec,audio_fm)){
+ sh_audio=d_audio->sh=NULL; // failed to init :(
}
+ mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
}
// set up video encoder:
@@ -659,32 +632,10 @@ default:
sh_video->vfilter=vf_open_filter(sh_video->vfilter,"expand","-1:-1:-1:-1:1");
sh_video->vfilter=append_filters(sh_video->vfilter);
-mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
-// 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_CPLAYER,MSGL_INFO,MSGTR_ForcedVideoCodec,video_codec);
- init_video(sh_video,video_codec,NULL,-1);
-} else {
- int status;
- // try in stability order: UNTESTED, WORKING, BUGGY, BROKEN
- if(video_fm) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_TryForceVideoFmtStr,video_fm);
- for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status){
- if(video_fm) // try first the preferred codec family:
- if(init_video(sh_video,NULL,video_fm,status)) break;
- if(init_video(sh_video,NULL,NULL,status)) break;
- }
-}
-if(!sh_video->inited){
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format);
- mp_msg(MSGT_CPLAYER,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf"));
- mencoder_exit(1,NULL);
-}
-mp_msg(MSGT_CPLAYER,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);
-mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
+ mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
+ init_best_video_codec(sh_video,video_codec,video_fm);
+ mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
+ if(!sh_video->inited) mencoder_exit(1,NULL);
}
diff --git a/mplayer.c b/mplayer.c
index 128717a0fa..74b3d0a4c9 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1200,54 +1200,19 @@ if(sh_video) {
#endif
//================== Init AUDIO (codec) ==========================
-current_module="find_audio_codec";
-
if(sh_audio){
// Go through the codec.conf and find the best codec...
- sh_audio->codec=NULL;
+ current_module="init_audio_codec";
mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
- if(audio_fm) mp_msg(MSGT_CPLAYER,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_CPLAYER,MSGL_ERR,MSGTR_CantFindAfmtFallback);
- audio_fm=NULL;
- continue;
- }
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantFindAudioCodec,sh_audio->format);
- mp_msg(MSGT_CPLAYER,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf"));
- sh_audio=d_audio->sh=NULL;
- break;
- }
- 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_CPLAYER,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;
+ if(!init_best_audio_codec(sh_audio,audio_codec,audio_fm)){
+ sh_audio=d_audio->sh=NULL; // failed to init :(
}
+ mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
}
-current_module="init_audio_codec";
-
-if(sh_audio){
- mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_InitializingAudioCodec);
- if(!init_audio(sh_audio)){
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CouldntInitAudioCodec);
- sh_audio=d_audio->sh=NULL;
- } else {
- mp_msg(MSGT_CPLAYER,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);
- }
-}
+if(!sh_video) goto main; // audio-only
//================== Init VIDEO (codec & libvo) ==========================
-if(!sh_video)
- goto main;
-
current_module="preinit_libvo";
vo_config_count=0;
@@ -1269,40 +1234,15 @@ sh_video->vfilter=append_filters(sh_video->vfilter);
current_module="init_video_codec";
mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
+init_best_video_codec(sh_video,video_codec,video_fm);
+mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
-// 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_CPLAYER,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_CPLAYER,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_CPLAYER,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format);
- mp_msg(MSGT_CPLAYER,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf"));
- mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
if(!sh_audio) goto goto_next_file;
sh_video = d_video->sh = NULL;
goto main; // exit_player(MSGTR_Exit_error);
}
-mp_msg(MSGT_CPLAYER,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);
-mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
-
if(auto_quality>0){
// Auto quality option enabled
output_quality=get_video_quality_max(sh_video);
@@ -1335,7 +1275,9 @@ current_module="init_vo";
#endif
//================== MAIN: ==========================
- main:
+main:
+current_module="main";
+
if(!sh_video) osd_level = 0;
fflush(stdout);