changeset 332:a5c6f9d536dd

find_codec() modified
author szabii
date Tue, 10 Apr 2001 23:18:01 +0000
parents 0f1737e626fa
children c6aca7445c10
files codec-cfg.c codec-cfg.h mplayer.c
diffstat 3 files changed, 44 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/codec-cfg.c	Tue Apr 10 21:41:31 2001 +0000
+++ b/codec-cfg.c	Tue Apr 10 23:18:01 2001 +0000
@@ -390,7 +390,7 @@
 				goto err_out;
 			}
 		        if (!(*codecsp = (codecs_t *) realloc(*codecsp,
-				sizeof(codecs_t) * (*nr_codecsp + 1)))) {
+				sizeof(codecs_t) * (*nr_codecsp + 2)))) {
 			    perror("can't realloc '*codecsp'");
 			    goto err_out;
 		        }
@@ -403,7 +403,6 @@
 			if (get_token(1, 1) < 0)
 				goto err_out_parse_error;
 			for (i = 0; i < *nr_codecsp - 1; i++) {
-#warning audio meg videocodecnek lehet ugyanaz a neve? (most lehet...)
 				if (!strcmp(token[0], (*codecsp)[i].name)) {
 					PRINT_LINENUM;
 					printf("codec name '%s' isn't unique\n", token[0]);
@@ -481,13 +480,13 @@
 		} else if (!strcmp(token[0], "status")) {
 			if (get_token(1, 1) < 0)
 				goto err_out_parse_error;
-			if (!strcasecmp(token[0], ":-)"))
+			if (!strcasecmp(token[0], "working"))
 				codec->status = CODECS_STATUS_WORKING;
-			else if (!strcasecmp(token[0], ":-("))
+			else if (!strcasecmp(token[0], "crashing"))
 				codec->status = CODECS_STATUS_NOT_WORKING;
-			else if (!strcasecmp(token[0], "X-("))
+			else if (!strcasecmp(token[0], "untested"))
 				codec->status = CODECS_STATUS_UNTESTED;
-			else if (!strcasecmp(token[0], ":-|"))
+			else if (!strcasecmp(token[0], "buggy"))
 				codec->status = CODECS_STATUS_PROBLEMS;
 			else
 				goto err_out_parse_error;
@@ -496,6 +495,8 @@
 	}
 	if (!validate_codec(codec, codec_type))
 		goto err_out_not_valid;
+	video_codecs[nr_vcodecs].name = NULL;
+	audio_codecs[nr_acodecs].name = NULL;
 	ret_codecs[0] = video_codecs;
 	ret_codecs[1] = audio_codecs;
 out:
@@ -520,40 +521,55 @@
 	goto err_out;
 }
 
-codecs_t *find_audio_codec(unsigned int fourcc, unsigned int *fourccmap)
+codecs_t *find_audio_codec(unsigned int fourcc, unsigned int *fourccmap,
+		codecs_t *start)
 {
-	return find_codec(fourcc, fourccmap, 1);
+	return find_codec(fourcc, fourccmap, start, 1);
 }
 
-codecs_t *find_video_codec(unsigned int fourcc, unsigned int *fourccmap)
+codecs_t *find_video_codec(unsigned int fourcc, unsigned int *fourccmap,
+		codecs_t *start)
 {
-	return find_codec(fourcc, fourccmap, 0);
+	return find_codec(fourcc, fourccmap, start, 0);
 }
 
-codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,int audioflag)
+codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,
+		codecs_t *start, int audioflag)
 {
 	int i, j;
 	codecs_t *c;
 
-	if (audioflag) {
-		i = nr_acodecs;
-		c = audio_codecs;
+	if (start) {
+		for (/* NOTHING */; start->name; start++) {
+			for (j = 0; j < CODECS_MAX_FOURCC; j++) {
+				if (start->fourcc[j] == fourcc) {
+					if (fourccmap)
+						*fourccmap = start->fourccmap[j];
+					return start;
+				}
+			}
+		}
 	} else {
-		i = nr_vcodecs;
-		c = video_codecs;
-	}
-	for (/* NOTHING */; i--; c++) {
-		for (j = 0; j < CODECS_MAX_FOURCC; j++) {
-			if (c->fourcc[j] == fourcc) {
-				if (fourccmap) *fourccmap = c->fourccmap[j];
-				return c;
+		if (audioflag) {
+			i = nr_acodecs;
+			c = audio_codecs;
+		} else {
+			i = nr_vcodecs;
+			c = video_codecs;
+		}
+		for (/* NOTHING */; i--; c++) {
+			for (j = 0; j < CODECS_MAX_FOURCC; j++) {
+				if (c->fourcc[j] == fourcc) {
+					if (fourccmap)
+						*fourccmap = c->fourccmap[j];
+					return c;
+				}
 			}
 		}
 	}
 	return NULL;
 }
 
-
 #ifdef TESTING
 int main(void)
 {
--- a/codec-cfg.h	Tue Apr 10 21:41:31 2001 +0000
+++ b/codec-cfg.h	Tue Apr 10 23:18:01 2001 +0000
@@ -50,6 +50,8 @@
 } codecs_t;
 
 codecs_t** parse_codec_cfg(char *cfgfile);
-codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,int audioflag);
+codecs_t* find_video_codec(unsigned int fourcc, unsigned int *fourccmap, codecs_t *start);
+codecs_t* find_audio_codec(unsigned int fourcc, unsigned int *fourccmap, codecs_t *start);
+codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,codecs_t *start,int audioflag);
 
 #endif
--- a/mplayer.c	Tue Apr 10 21:41:31 2001 +0000
+++ b/mplayer.c	Tue Apr 10 23:18:01 2001 +0000
@@ -792,7 +792,7 @@
 //================== Init AUDIO (codec) ==========================
 if(has_audio){
   // Go through the codec.conf and find the best codec...
-  sh_audio->codec=find_codec(sh_audio->format,NULL,1);
+  sh_audio->codec=find_codec(sh_audio->format,NULL,NULL,1);
   if(!sh_audio->codec){
     printf("Can't find codec for audio format 0x%X !\n",sh_audio->format);
     has_audio=0;
@@ -815,7 +815,7 @@
 //================== Init VIDEO (codec & libvo) ==========================
 
 // Go through the codec.conf and find the best codec...
-sh_video->codec=find_codec(sh_video->format,(unsigned int*) &sh_video->bih.biCompression,0);
+sh_video->codec=find_codec(sh_video->format,(unsigned int*) &sh_video->bih.biCompression,NULL,0);
 if(!sh_video->codec){
     printf("Can't find codec for video format 0x%X !\n",sh_video->format);
     exit(1);