[Mplayer-cvslog] CVS: main codec-cfg.c,1.14,1.15 codec-cfg.h,1.8,1.9

Szabolcs Berecz szabii at users.sourceforge.net
Wed Apr 11 22:55:16 CEST 2001


Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv11791

Modified Files:
	codec-cfg.c codec-cfg.h 
Log Message:
dunno :)

Index: codec-cfg.c
===================================================================
RCS file: /cvsroot/mplayer/main/codec-cfg.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** codec-cfg.c	2001/04/10 23:56:38	1.14
--- codec-cfg.c	2001/04/11 20:55:14	1.15
***************
*** 19,29 ****
  #include "codec-cfg.h"
  
! #ifdef DEBUG
! #	define DBG(str, args...) printf(str, ##args)
! #else
! #	define DBG(str, args...) do {} while (0)
! #endif
! 
! #define PRINT_LINENUM printf("%s(%d): ", cfgfile, line_num)
  
  #define MAX_NR_TOKEN	16
--- 19,23 ----
  #include "codec-cfg.h"
  
! #define PRINT_LINENUM printf(" at line %d\n", line_num)
  
  #define MAX_NR_TOKEN	16
***************
*** 66,76 ****
  		goto err_out_too_many;
  	if (*(--s) != '\0')
! 		return 0;
  	return 1;
  err_out_duplicated:
! 	printf("\nduplicated fourcc/format\n");
  	return 0;
  err_out_too_many:
! 	printf("\ntoo many fourcc/format...\n");
  	return 0;
  }
--- 60,73 ----
  		goto err_out_too_many;
  	if (*(--s) != '\0')
! 		goto err_out_parse_error;
  	return 1;
  err_out_duplicated:
! 	printf("duplicated fourcc/format");
  	return 0;
  err_out_too_many:
! 	printf("too many fourcc/format...");
! 	return 0;
! err_out_parse_error:
! 	printf("parse error");
  	return 0;
  }
***************
*** 79,82 ****
--- 76,80 ----
  {
  	int i, j;
+ 	char *endptr;
  
  	/* find first unused slot */
***************
*** 84,95 ****
  		/* NOTHING */;
  	if (i == CODECS_MAX_FOURCC) {
! 		printf("\ntoo many fourcc/format...\n");
  		return 0;
  	}
  
!         fourcc[i]=fourccmap[i]=strtoul(s,NULL,0);
  	for (j = 0; j < i; j++)
  		if (fourcc[j] == fourcc[i]) {
! 			printf("\nduplicated fourcc/format\n");
  			return 0;
  		}
--- 82,97 ----
  		/* NOTHING */;
  	if (i == CODECS_MAX_FOURCC) {
! 		printf("too many fourcc/format...");
  		return 0;
  	}
  
!         fourcc[i]=fourccmap[i]=strtoul(s,&endptr,0);
! 	if (*endptr != '\0') {
! 		printf("parse error");
! 		return 0;
! 	}
  	for (j = 0; j < i; j++)
  		if (fourcc[j] == fourcc[i]) {
! 			printf("duplicated fourcc/format");
  			return 0;
  		}
***************
*** 147,158 ****
  
  	flags = 0;
! 	if(sflags) do {
! 		for (j = 0; flagstr[j] != NULL; j++)
! 			if (!strncmp(sflags, flagstr[j], strlen(flagstr[j])))
! 				break;
! 		if (flagstr[j] == NULL) return 0; // error!
! 		flags|=(1<<j);
! 		sflags+=strlen(flagstr[j]);
! 	} while (*(sflags++) == ',');
  
  	do {
--- 149,167 ----
  
  	flags = 0;
! 	if(sflags) {
! 		do {
! 			for (j = 0; flagstr[j] != NULL; j++)
! 				if (!strncmp(sflags, flagstr[j],
! 							strlen(flagstr[j])))
! 					break;
! 			if (flagstr[j] == NULL)
! 				goto err_out_parse_error;
! 			flags|=(1<<j);
! 			sflags+=strlen(flagstr[j]);
! 		} while (*(sflags++) == ',');
! 
! 		if (*(--sflags) != '\0')
! 			goto err_out_parse_error;
! 	}
  
  	do {
***************
*** 161,165 ****
  				break;
  		if (fmtstr[j] == NULL)
! 			return 0;
  		outfmt[i] = fmtnum[j];
  		outflags[i] = flags;
--- 170,174 ----
  				break;
  		if (fmtstr[j] == NULL)
! 			goto err_out_parse_error;
  		outfmt[i] = fmtnum[j];
  		outflags[i] = flags;
***************
*** 171,180 ****
  		goto err_out_too_many;
  
! 	if (*(--sfmt) != '\0') return 0;
          
  	return 1;
  err_out_too_many:
! 	printf("\ntoo many out...\n");
  	return 0;
  }
  
--- 180,193 ----
  		goto err_out_too_many;
  
! 	if (*(--sfmt) != '\0')
! 		goto err_out_parse_error;
          
  	return 1;
  err_out_too_many:
! 	printf("too many out...");
  	return 0;
+ err_out_parse_error:
+ 	printf("parse error");
+ 	return 0;
  }
  
***************
*** 258,262 ****
  	}
  	if (!(*d = (char *) realloc(*d, pos + strlen(s) + 1))) {
! 		printf("can't allocate mem for comment\n");
  		return 0;
  	}
--- 271,275 ----
  	}
  	if (!(*d = (char *) realloc(*d, pos + strlen(s) + 1))) {
! 		printf("can't allocate mem for comment. ");
  		return 0;
  	}
***************
*** 265,268 ****
--- 278,310 ----
  }
  
+ static short get_cpuflags(char *s)
+ {
+ 	static char *flagstr[] = {
+ 		"mmx",
+ 		"sse",
+ 		"3dnow",
+ 		NULL
+ 	};
+         int i;
+ 	short flags = 0;
+ 
+ 	do {
+ 		for (i = 0; flagstr[i]; i++)
+ 			if (!strncmp(s, flagstr[i], strlen(flagstr[i])))
+ 				break;
+ 		if (!flagstr[i])
+ 			goto err_out_parse_error;
+ 		flags |= 1<<i;
+ 		s += strlen(flagstr[i]);
+ 	} while (*(s++) == ',');
+ 
+ 	if (*(--s) != '\0')
+ 		goto err_out_parse_error;
+ 
+ 	return flags;
+ err_out_parse_error:
+ 	return 0;
+ }
+ 
  static FILE *fp;
  static int line_num = 0;
***************
*** 278,282 ****
  
  	if (max >= MAX_NR_TOKEN) {
! 		printf("\nget_token(): max >= MAX_NR_TOKEN!\n");
  		goto out_eof;
  	}
--- 320,324 ----
  
  	if (max >= MAX_NR_TOKEN) {
! 		printf("get_token(): max >= MAX_NR_TOKEN!");
  		goto out_eof;
  	}
***************
*** 348,352 ****
  #endif
  
! 	printf("Reading codec config file: %s\n", cfgfile);
  
  	if ((fp = fopen(cfgfile, "r")) == NULL) {
--- 390,394 ----
  #endif
  
! 	printf("Reading %s: ", cfgfile);
  
  	if ((fp = fopen(cfgfile, "r")) == NULL) {
***************
*** 356,360 ****
  
  	if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) {
! 		perror("can't get memory for 'line'");
  		return NULL;
  	}
--- 398,402 ----
  
  	if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) {
! 		printf("can't get memory for 'line': %s\n", strerror(errno));
  		return NULL;
  	}
***************
*** 366,373 ****
  	while ((tmp = get_token(1, 1)) == RET_EOL)
  		/* NOTHING */;
! 	if (tmp != RET_EOF && (!strcmp(token[0], "audiocodec") ||
! 			!strcmp(token[0], "videocodec")))
  		goto loop_enter;
! 	goto out;
  
  	while ((tmp = get_token(1, 1)) != RET_EOF) {
--- 408,416 ----
  	while ((tmp = get_token(1, 1)) == RET_EOL)
  		/* NOTHING */;
! 	if (tmp == RET_EOF)
! 		goto out;
! 	if (!strcmp(token[0], "audiocodec") || !strcmp(token[0], "videocodec"))
  		goto loop_enter;
! 	goto err_out_parse_error;
  
  	while ((tmp = get_token(1, 1)) != RET_EOF) {
***************
*** 387,397 ****
  				nr_codecsp = &nr_acodecs;
  				codecsp = &audio_codecs;
  			} else {
! 				printf("rohattkurva\n");
  				goto err_out;
  			}
  		        if (!(*codecsp = (codecs_t *) realloc(*codecsp,
  				sizeof(codecs_t) * (*nr_codecsp + 2)))) {
! 			    perror("can't realloc '*codecsp'");
  			    goto err_out;
  		        }
--- 430,442 ----
  				nr_codecsp = &nr_acodecs;
  				codecsp = &audio_codecs;
+ #ifdef DEBUG
  			} else {
! 				printf("picsba\n");
  				goto err_out;
+ #endif
  			}
  		        if (!(*codecsp = (codecs_t *) realloc(*codecsp,
  				sizeof(codecs_t) * (*nr_codecsp + 2)))) {
! 			    printf("can't realloc '*codecsp': %s\n", strerror(errno));
  			    goto err_out;
  		        }
***************
*** 406,416 ****
  			for (i = 0; i < *nr_codecsp - 1; i++) {
  				if (!strcmp(token[0], (*codecsp)[i].name)) {
! 					PRINT_LINENUM;
! 					printf("codec name '%s' isn't unique\n", token[0]);
! 					goto err_out;
  				}
  			}
  			if (!(codec->name = strdup(token[0]))) {
! 				perror("can't strdup -> 'name'");
  				goto err_out;
  			}
--- 451,460 ----
  			for (i = 0; i < *nr_codecsp - 1; i++) {
  				if (!strcmp(token[0], (*codecsp)[i].name)) {
! 					printf("codec name '%s' isn't unique", token[0]);
! 					goto err_out_print_linenum;
  				}
  			}
  			if (!(codec->name = strdup(token[0]))) {
! 				printf("can't strdup -> 'name': %s\n", strerror(errno));
  				goto err_out;
  			}
***************
*** 419,423 ****
  				goto err_out_parse_error;
  			if (!(codec->info = strdup(token[0]))) {
! 				perror("can't strdup -> 'info'");
  				goto err_out;
  			}
--- 463,467 ----
  				goto err_out_parse_error;
  			if (!(codec->info = strdup(token[0]))) {
! 				printf("can't strdup -> 'info': %s\n", strerror(errno));
  				goto err_out;
  			}
***************
*** 425,432 ****
  			if (get_token(1, 1) < 0)
  				goto err_out_parse_error;
! 			if (!add_comment(token[0], &codec->comment)) {
! 				PRINT_LINENUM;
! 				printf("add_comment()-tel valami sux\n");
! 			}
  		} else if (!strcmp(token[0], "fourcc")) {
  			if (get_token(1, 2) < 0)
--- 469,473 ----
  			if (get_token(1, 1) < 0)
  				goto err_out_parse_error;
! 			add_comment(token[0], &codec->comment);
  		} else if (!strcmp(token[0], "fourcc")) {
  			if (get_token(1, 2) < 0)
***************
*** 435,454 ****
  						codec->fourcc,
  						codec->fourccmap))
! 				goto err_out_parse_error;
  		} else if (!strcmp(token[0], "format")) {
  			if (get_token(1, 1) < 0)
  				goto err_out_parse_error;
  			if (!add_to_format(token[0], codec->fourcc,codec->fourccmap))
! 				goto err_out_parse_error;
  		} else if (!strcmp(token[0], "driver")) {
  			if (get_token(1, 1) < 0)
  				goto err_out_parse_error;
! 			if ((codec->driver = get_driver(token[0],codec_type)) == -1)
! 				goto err_out;
  		} else if (!strcmp(token[0], "dll")) {
  			if (get_token(1, 1) < 0)
  				goto err_out_parse_error;
  			if (!(codec->dll = strdup(token[0]))) {
! 				perror("can't strdup -> 'dll'");
  				goto err_out;
  			}
--- 476,495 ----
  						codec->fourcc,
  						codec->fourccmap))
! 				goto err_out_print_linenum;
  		} else if (!strcmp(token[0], "format")) {
  			if (get_token(1, 1) < 0)
  				goto err_out_parse_error;
  			if (!add_to_format(token[0], codec->fourcc,codec->fourccmap))
! 				goto err_out_print_linenum;
  		} else if (!strcmp(token[0], "driver")) {
  			if (get_token(1, 1) < 0)
  				goto err_out_parse_error;
! 			if (!(codec->driver = get_driver(token[0],codec_type)))
! 				goto err_out_parse_error;
  		} else if (!strcmp(token[0], "dll")) {
  			if (get_token(1, 1) < 0)
  				goto err_out_parse_error;
  			if (!(codec->dll = strdup(token[0]))) {
! 				printf("can't strdup -> 'dll': %s\n", strerror(errno));
  				goto err_out;
  			}
***************
*** 457,471 ****
  				goto err_out_parse_error;
                          codec->guid.f1=strtoul(token[0],&endptr,0);
! 			if (*endptr != '\0' && *endptr != ',')
  				goto err_out_parse_error;
                          codec->guid.f2=strtoul(token[1],&endptr,0);
! 			if (*endptr != '\0' && *endptr != ',')
  				goto err_out_parse_error;
                          codec->guid.f3=strtoul(token[2],&endptr,0);
! 			if (*endptr != '\0' && *endptr != ',')
  				goto err_out_parse_error;
  			for (i = 0; i < 8; i++) {
                              codec->guid.f4[i]=strtoul(token[i + 3],&endptr,0);
! 				if (*endptr != '\0' && *endptr != ',')
  					goto err_out_parse_error;
  			}
--- 498,516 ----
  				goto err_out_parse_error;
                          codec->guid.f1=strtoul(token[0],&endptr,0);
! 			if ((*endptr != ',' || *(endptr + 1) != '\0') &&
! 					*endptr != '\0')
  				goto err_out_parse_error;
                          codec->guid.f2=strtoul(token[1],&endptr,0);
! 			if ((*endptr != ',' || *(endptr + 1) != '\0') &&
! 					*endptr != '\0')
  				goto err_out_parse_error;
                          codec->guid.f3=strtoul(token[2],&endptr,0);
! 			if ((*endptr != ',' || *(endptr + 1) != '\0') &&
! 					*endptr != '\0')
  				goto err_out_parse_error;
  			for (i = 0; i < 8; i++) {
                              codec->guid.f4[i]=strtoul(token[i + 3],&endptr,0);
! 				if ((*endptr != ',' || *(endptr + 1) != '\0') &&
! 						*endptr != '\0')
  					goto err_out_parse_error;
  			}
***************
*** 475,479 ****
  			if (!add_to_out(token[0], token[1], codec->outfmt,
  						codec->outflags))
! 				goto err_out;
  		} else if (!strcmp(token[0], "flags")) {
  			if (get_token(1, 1) < 0)
--- 520,524 ----
  			if (!add_to_out(token[0], token[1], codec->outfmt,
  						codec->outflags))
! 				goto err_out_print_linenum;
  		} else if (!strcmp(token[0], "flags")) {
  			if (get_token(1, 1) < 0)
***************
*** 496,499 ****
--- 541,549 ----
  			else
  				goto err_out_parse_error;
+ 		} else if (!strcmp(token[0], "cpuflags")) {
+ 			if (get_token(1, 1) < 0)
+ 				goto err_out_parse_error;
+ 			if (!(codec->cpuflags = get_cpuflags(token[0])))
+ 				goto err_out_parse_error;
  		} else
  			goto err_out_parse_error;
***************
*** 501,504 ****
--- 551,555 ----
  	if (!validate_codec(codec, codec_type))
  		goto err_out_not_valid;
+ 	printf("%d audio & %d video codecs\n", nr_acodecs, nr_vcodecs);
  	video_codecs[nr_vcodecs].name = NULL;
  	audio_codecs[nr_acodecs].name = NULL;
***************
*** 510,517 ****
  	return ret_codecs;
  err_out_parse_error:
  	PRINT_LINENUM;
- 	printf("parse error\n");
  err_out:
- 	printf("\nOops\n");
  	if (audio_codecs)
  		free(audio_codecs);
--- 561,568 ----
  	return ret_codecs;
  err_out_parse_error:
+ 	printf("parse error");
+ err_out_print_linenum:
  	PRINT_LINENUM;
  err_out:
  	if (audio_codecs)
  		free(audio_codecs);
***************
*** 522,528 ****
  	return NULL;
  err_out_not_valid:
! 	PRINT_LINENUM;
! 	printf("codec is not definied correctly\n");
! 	goto err_out;
  }
  
--- 573,578 ----
  	return NULL;
  err_out_not_valid:
! 	printf("codec is not definied correctly");
! 	goto err_out_print_linenum;
  }
  
***************
*** 602,610 ****
  		    printf("comment='%s'\n",c->comment);
  		    printf("dll='%s'\n",c->dll);
! 		    printf("flags=%X  driver=%d\n",c->flags,c->driver);
  
  		    for(j=0;j<CODECS_MAX_FOURCC;j++){
  		      if(c->fourcc[j]!=0xFFFFFFFF){
! 			  printf("fourcc %02d:  %08X (%.4s) ===> %08X (%.4s)\n",j,c->fourcc[j],&c->fourcc[j],c->fourccmap[j],&c->fourccmap[j]);
  		      }
  		    }
--- 652,661 ----
  		    printf("comment='%s'\n",c->comment);
  		    printf("dll='%s'\n",c->dll);
! 		    printf("flags=%X  driver=%d status=%d cpuflags=%d\n",
! 				    c->flags, c->driver, c->status, c->cpuflags);
  
  		    for(j=0;j<CODECS_MAX_FOURCC;j++){
  		      if(c->fourcc[j]!=0xFFFFFFFF){
! 			  printf("fourcc %02d:  %08X (%.4s) ===> %08X (%.4s)\n",j,c->fourcc[j],(char *) &c->fourcc[j],c->fourccmap[j],(char *) &c->fourccmap[j]);
  		      }
  		    }
***************
*** 612,616 ****
  		    for(j=0;j<CODECS_MAX_OUTFMT;j++){
  		      if(c->outfmt[j]!=0xFFFFFFFF){
! 			  printf("outfmt %02d:  %08X (%.4s)  flags: %d\n",j,c->outfmt[j],&c->outfmt[j],c->outflags[j]);
  		      }
  		    }
--- 663,667 ----
  		    for(j=0;j<CODECS_MAX_OUTFMT;j++){
  		      if(c->outfmt[j]!=0xFFFFFFFF){
! 			  printf("outfmt %02d:  %08X (%.4s)  flags: %d\n",j,c->outfmt[j],(char *) &c->outfmt[j],c->outflags[j]);
  		      }
  		    }

Index: codec-cfg.h
===================================================================
RCS file: /cvsroot/mplayer/main/codec-cfg.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** codec-cfg.h	2001/04/10 23:18:01	1.8
--- codec-cfg.h	2001/04/11 20:55:14	1.9
***************
*** 48,51 ****
--- 48,52 ----
  	short flags;
  	short status;
+ 	short cpuflags;
  } codecs_t;
  


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list