summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--codec-cfg.c62
-rw-r--r--codec-cfg.h4
-rw-r--r--mplayer.c4
3 files changed, 44 insertions, 26 deletions
diff --git a/codec-cfg.c b/codec-cfg.c
index 83451a2210..3bf22000db 100644
--- a/codec-cfg.c
+++ b/codec-cfg.c
@@ -390,7 +390,7 @@ codecs_t **parse_codec_cfg(char *cfgfile)
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 @@ codecs_t **parse_codec_cfg(char *cfgfile)
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 @@ codecs_t **parse_codec_cfg(char *cfgfile)
} 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 @@ codecs_t **parse_codec_cfg(char *cfgfile)
}
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 @@ err_out_not_valid:
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)
{
diff --git a/codec-cfg.h b/codec-cfg.h
index fddec5a096..c95de9aba5 100644
--- a/codec-cfg.h
+++ b/codec-cfg.h
@@ -50,6 +50,8 @@ typedef struct {
} 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
diff --git a/mplayer.c b/mplayer.c
index 6ac2b694bf..64bb256ff7 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -792,7 +792,7 @@ fflush(stdout);
//================== 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 @@ if(has_audio){
//================== 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);