diff options
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/dec_audio.c | 18 | ||||
-rw-r--r-- | libmpcodecs/dec_video.c | 19 |
2 files changed, 21 insertions, 16 deletions
diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c index 77764d5928..b7ce68f0b1 100644 --- a/libmpcodecs/dec_audio.c +++ b/libmpcodecs/dec_audio.c @@ -129,7 +129,7 @@ static int init_audio_codec(sh_audio_t *sh_audio) } static int init_audio(sh_audio_t *sh_audio, char *codecname, char *afm, - int status) + int status, stringset_t *selected) { unsigned int orig_fourcc = sh_audio->wf ? sh_audio->wf->wFormatTag : 0; int force = 0; @@ -152,7 +152,7 @@ static int init_audio(sh_audio_t *sh_audio, char *codecname, char *afm, if (sh_audio->wf) sh_audio->wf->wFormatTag = i; // ok we found one codec - if (sh_audio->codec->flags & CODECS_FLAG_SELECTED) + if (stringset_test(selected, sh_audio->codec->name)) continue; // already tried & failed if (codecname && strcmp(sh_audio->codec->name, codecname)) continue; // -ac @@ -160,7 +160,7 @@ static int init_audio(sh_audio_t *sh_audio, char *codecname, char *afm, continue; // afm doesn't match if (!force && sh_audio->codec->status < status) continue; // too unstable - sh_audio->codec->flags |= CODECS_FLAG_SELECTED; // tagging it + stringset_add(selected, sh_audio->codec->name); // tagging it // ok, it matches all rules, let's find the driver! for (i = 0; mpcodecs_ad_drivers[i] != NULL; i++) if (!strcmp(mpcodecs_ad_drivers[i]->info->short_name, @@ -227,24 +227,25 @@ static int init_audio(sh_audio_t *sh_audio, char *codecname, char *afm, int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list, char **audio_fm_list) { + stringset_t selected; char *ac_l_default[2] = { "", (char *) NULL }; // hack: if (!audio_codec_list) audio_codec_list = ac_l_default; // Go through the codec.conf and find the best codec... sh_audio->inited = 0; - codecs_reset_selection(1); + stringset_init(&selected); while (!sh_audio->inited && *audio_codec_list) { char *audio_codec = *(audio_codec_list++); if (audio_codec[0]) { if (audio_codec[0] == '-') { // disable this codec: - select_codec(audio_codec + 1, 1); + stringset_add(&selected, audio_codec + 1); } else { // forced codec by name: mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_ForcedAudioCodec, audio_codec); - init_audio(sh_audio, audio_codec, NULL, -1); + init_audio(sh_audio, audio_codec, NULL, -1, &selected); } } else { int status; @@ -259,17 +260,18 @@ int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list, audio_fm); for (status = CODECS_STATUS__MAX; status >= CODECS_STATUS__MIN; --status) - if (init_audio(sh_audio, NULL, audio_fm, status)) + if (init_audio(sh_audio, NULL, audio_fm, status, &selected)) break; } } if (!sh_audio->inited) for (status = CODECS_STATUS__MAX; status >= CODECS_STATUS__MIN; --status) - if (init_audio(sh_audio, NULL, NULL, status)) + if (init_audio(sh_audio, NULL, NULL, status, &selected)) break; } } + stringset_free(&selected); if (!sh_audio->inited) { mp_msg(MSGT_DECAUDIO, MSGL_ERR, MSGTR_CantFindAudioCodec, diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c index b29c01aba4..403f29d4cd 100644 --- a/libmpcodecs/dec_video.c +++ b/libmpcodecs/dec_video.c @@ -175,7 +175,8 @@ void vfm_help(void){ mpcodecs_vd_drivers[i]->info->comment); } -static int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status){ +static int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status, + stringset_t *selected){ int force = 0; unsigned int orig_fourcc=sh_video->bih?sh_video->bih->biCompression:0; sh_video->codec=NULL; @@ -194,11 +195,11 @@ static int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status) sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL, sh_video->codec,force) )) break; // ok we found one codec - if(sh_video->codec->flags&CODECS_FLAG_SELECTED) continue; // already tried & failed + if(stringset_test(selected, sh_video->codec->name)) continue; // already tried & failed if(codecname && strcmp(sh_video->codec->name,codecname)) continue; // -vc if(vfm && strcmp(sh_video->codec->drv,vfm)) continue; // vfm doesn't match if(!force && sh_video->codec->status<status) continue; // too unstable - sh_video->codec->flags|=CODECS_FLAG_SELECTED; // tagging it + stringset_add(selected, sh_video->codec->name); // tagging it // ok, it matches all rules, let's find the driver! for (i=0; mpcodecs_vd_drivers[i] != NULL; i++) // if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver) break; @@ -279,21 +280,22 @@ static int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status) int init_best_video_codec(sh_video_t *sh_video,char** video_codec_list,char** video_fm_list){ char* vc_l_default[2]={"",(char*)NULL}; +stringset_t selected; // hack: if(!video_codec_list) video_codec_list=vc_l_default; // Go through the codec.conf and find the best codec... sh_video->inited=0; -codecs_reset_selection(0); +stringset_init(&selected); while(!sh_video->inited && *video_codec_list){ char* video_codec=*(video_codec_list++); if(video_codec[0]){ if(video_codec[0]=='-'){ // disable this codec: - select_codec(video_codec+1,0); + stringset_add(&selected, video_codec+1); } else { // forced codec by name: mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_ForcedVideoCodec,video_codec); - init_video(sh_video,video_codec,NULL,-1); + init_video(sh_video,video_codec,NULL,-1, &selected); } } else { int status; @@ -305,14 +307,15 @@ while(!sh_video->inited && *video_codec_list){ char* video_fm=*(fmlist++); 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(init_video(sh_video,NULL,video_fm,status, &selected)) 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(init_video(sh_video,NULL,NULL,status, &selected)) break; } } +stringset_free(&selected); if(!sh_video->inited){ mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format); |