From e0faf28d8e0beb236c5e53b96f88e89fe6775dc6 Mon Sep 17 00:00:00 2001 From: atmos4 Date: Sun, 23 Dec 2001 11:58:57 +0000 Subject: add support for priotity in codecs.conf, higher numbers are better git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3668 b3059339-0415-0410-9bf9-f77b7e298cf2 --- codec-cfg.c | 5 +++++ codec-cfg.h | 1 + mencoder.c | 17 ++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/codec-cfg.c b/codec-cfg.c index 54e6fbb8e6..68ab3e5045 100644 --- a/codec-cfg.c +++ b/codec-cfg.c @@ -577,6 +577,11 @@ codecs_t **parse_codec_cfg(char *cfgfile) goto err_out_parse_error; if (!(codec->cpuflags = get_cpuflags(token[0]))) goto err_out_parse_error; + } else if (!strcasecmp(token[0], "priority")) { + if (get_token(1, 1) < 0) + goto err_out_parse_error; + //printf("\n\n!!!cfg-parse: priority %s (%d) found!!!\n\n", token[0], atoi(token[0])); // ::atmos + codec->priority = atoi(token[0]); } else goto err_out_parse_error; } diff --git a/codec-cfg.h b/codec-cfg.h index e9bb61f56e..c2bb91f0a9 100644 --- a/codec-cfg.h +++ b/codec-cfg.h @@ -73,6 +73,7 @@ typedef struct codecs_st { short flags; short status; short cpuflags; + short priority; } codecs_t; codecs_t** parse_codec_cfg(char *cfgfile); diff --git a/mencoder.c b/mencoder.c index 17fe21711b..8739c57a97 100644 --- a/mencoder.c +++ b/mencoder.c @@ -411,6 +411,9 @@ sh_video->codec=NULL; if(out_video_codec>1){ if(video_family!=-1) mp_msg(MSGT_MENCODER,MSGL_INFO,MSGTR_TryForceVideoFmt,video_family); +{ +short bestprio=-1; +struct codecs_st *bestcodec=NULL; while(1){ sh_video->codec=find_codec(sh_video->format, sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL,sh_video->codec,0); @@ -427,10 +430,22 @@ while(1){ } if(video_codec && strcmp(sh_video->codec->name,video_codec)) continue; else if(video_family!=-1 && sh_video->codec->driver!=video_family) continue; + else if(sh_video->codec && sh_video->codec->priority > bestprio) { + //printf("\n\n!!! setting bestprio from %d to %d for %s!!!\n\n", bestprio, sh_video->codec->priority, sh_video->codec->name); + bestprio=sh_video->codec->priority; + bestcodec=sh_video->codec; + continue; + } break; } +if(bestprio!=-1) { + //printf("chose codec %s by priority.\n", bestcodec->name); + sh_video->codec=bestcodec; +} + +} -mp_msg(MSGT_MENCODER,MSGL_INFO,"%s video codec: [%s] drv:%d (%s)\n",video_codec?"Forcing":"Detected",sh_video->codec->name,sh_video->codec->driver,sh_video->codec->info); +mp_msg(MSGT_MENCODER,MSGL_INFO,"%s video codec: [%s] drv:%d prio:%d (%s)\n",video_codec?"Forcing":"Detected",sh_video->codec->name,sh_video->codec->driver,sh_video->codec->priority!=-1?sh_video->codec->priority:0,sh_video->codec->info); for(i=0;icodec->outfmt[i]; -- cgit v1.2.3