changeset 3667:ec943f8ec439

add support for priotity <int> in codecs.conf, higher numbers are better
author atmos4
date Sun, 23 Dec 2001 11:58:57 +0000
parents 70c409621d92
children 081d696b453d
files codec-cfg.c codec-cfg.h mencoder.c
diffstat 3 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/codec-cfg.c	Sun Dec 23 01:34:49 2001 +0000
+++ b/codec-cfg.c	Sun Dec 23 11:58:57 2001 +0000
@@ -577,6 +577,11 @@
 				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;
 	}
--- a/codec-cfg.h	Sun Dec 23 01:34:49 2001 +0000
+++ b/codec-cfg.h	Sun Dec 23 11:58:57 2001 +0000
@@ -73,6 +73,7 @@
 	short flags;
 	short status;
 	short cpuflags;
+  short priority;
 } codecs_t;
 
 codecs_t** parse_codec_cfg(char *cfgfile);
--- a/mencoder.c	Sun Dec 23 01:34:49 2001 +0000
+++ b/mencoder.c	Sun Dec 23 11:58:57 2001 +0000
@@ -411,6 +411,9 @@
 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 @@
   }
   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;i<CODECS_MAX_OUTFMT;i++){
     out_fmt=sh_video->codec->outfmt[i];