mirror of https://github.com/mpv-player/mpv
find_codec() modified
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@333 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
90b7957f32
commit
d80be73b8e
62
codec-cfg.c
62
codec-cfg.c
|
@ -390,7 +390,7 @@ codecs_t **parse_codec_cfg(char *cfgfile)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
if (!(*codecsp = (codecs_t *) realloc(*codecsp,
|
if (!(*codecsp = (codecs_t *) realloc(*codecsp,
|
||||||
sizeof(codecs_t) * (*nr_codecsp + 1)))) {
|
sizeof(codecs_t) * (*nr_codecsp + 2)))) {
|
||||||
perror("can't realloc '*codecsp'");
|
perror("can't realloc '*codecsp'");
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
@ -403,7 +403,6 @@ codecs_t **parse_codec_cfg(char *cfgfile)
|
||||||
if (get_token(1, 1) < 0)
|
if (get_token(1, 1) < 0)
|
||||||
goto err_out_parse_error;
|
goto err_out_parse_error;
|
||||||
for (i = 0; i < *nr_codecsp - 1; i++) {
|
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)) {
|
if (!strcmp(token[0], (*codecsp)[i].name)) {
|
||||||
PRINT_LINENUM;
|
PRINT_LINENUM;
|
||||||
printf("codec name '%s' isn't unique\n", token[0]);
|
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")) {
|
} else if (!strcmp(token[0], "status")) {
|
||||||
if (get_token(1, 1) < 0)
|
if (get_token(1, 1) < 0)
|
||||||
goto err_out_parse_error;
|
goto err_out_parse_error;
|
||||||
if (!strcasecmp(token[0], ":-)"))
|
if (!strcasecmp(token[0], "working"))
|
||||||
codec->status = CODECS_STATUS_WORKING;
|
codec->status = CODECS_STATUS_WORKING;
|
||||||
else if (!strcasecmp(token[0], ":-("))
|
else if (!strcasecmp(token[0], "crashing"))
|
||||||
codec->status = CODECS_STATUS_NOT_WORKING;
|
codec->status = CODECS_STATUS_NOT_WORKING;
|
||||||
else if (!strcasecmp(token[0], "X-("))
|
else if (!strcasecmp(token[0], "untested"))
|
||||||
codec->status = CODECS_STATUS_UNTESTED;
|
codec->status = CODECS_STATUS_UNTESTED;
|
||||||
else if (!strcasecmp(token[0], ":-|"))
|
else if (!strcasecmp(token[0], "buggy"))
|
||||||
codec->status = CODECS_STATUS_PROBLEMS;
|
codec->status = CODECS_STATUS_PROBLEMS;
|
||||||
else
|
else
|
||||||
goto err_out_parse_error;
|
goto err_out_parse_error;
|
||||||
|
@ -496,6 +495,8 @@ codecs_t **parse_codec_cfg(char *cfgfile)
|
||||||
}
|
}
|
||||||
if (!validate_codec(codec, codec_type))
|
if (!validate_codec(codec, codec_type))
|
||||||
goto err_out_not_valid;
|
goto err_out_not_valid;
|
||||||
|
video_codecs[nr_vcodecs].name = NULL;
|
||||||
|
audio_codecs[nr_acodecs].name = NULL;
|
||||||
ret_codecs[0] = video_codecs;
|
ret_codecs[0] = video_codecs;
|
||||||
ret_codecs[1] = audio_codecs;
|
ret_codecs[1] = audio_codecs;
|
||||||
out:
|
out:
|
||||||
|
@ -520,40 +521,55 @@ err_out_not_valid:
|
||||||
goto err_out;
|
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;
|
int i, j;
|
||||||
codecs_t *c;
|
codecs_t *c;
|
||||||
|
|
||||||
if (audioflag) {
|
if (start) {
|
||||||
i = nr_acodecs;
|
for (/* NOTHING */; start->name; start++) {
|
||||||
c = audio_codecs;
|
for (j = 0; j < CODECS_MAX_FOURCC; j++) {
|
||||||
|
if (start->fourcc[j] == fourcc) {
|
||||||
|
if (fourccmap)
|
||||||
|
*fourccmap = start->fourccmap[j];
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
i = nr_vcodecs;
|
if (audioflag) {
|
||||||
c = video_codecs;
|
i = nr_acodecs;
|
||||||
}
|
c = audio_codecs;
|
||||||
for (/* NOTHING */; i--; c++) {
|
} else {
|
||||||
for (j = 0; j < CODECS_MAX_FOURCC; j++) {
|
i = nr_vcodecs;
|
||||||
if (c->fourcc[j] == fourcc) {
|
c = video_codecs;
|
||||||
if (fourccmap) *fourccmap = c->fourccmap[j];
|
}
|
||||||
return c;
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TESTING
|
#ifdef TESTING
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,6 +50,8 @@ typedef struct {
|
||||||
} codecs_t;
|
} codecs_t;
|
||||||
|
|
||||||
codecs_t** parse_codec_cfg(char *cfgfile);
|
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
|
#endif
|
||||||
|
|
|
@ -792,7 +792,7 @@ fflush(stdout);
|
||||||
//================== Init AUDIO (codec) ==========================
|
//================== Init AUDIO (codec) ==========================
|
||||||
if(has_audio){
|
if(has_audio){
|
||||||
// Go through the codec.conf and find the best codec...
|
// 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){
|
if(!sh_audio->codec){
|
||||||
printf("Can't find codec for audio format 0x%X !\n",sh_audio->format);
|
printf("Can't find codec for audio format 0x%X !\n",sh_audio->format);
|
||||||
has_audio=0;
|
has_audio=0;
|
||||||
|
@ -815,7 +815,7 @@ if(has_audio){
|
||||||
//================== Init VIDEO (codec & libvo) ==========================
|
//================== Init VIDEO (codec & libvo) ==========================
|
||||||
|
|
||||||
// Go through the codec.conf and find the best codec...
|
// 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){
|
if(!sh_video->codec){
|
||||||
printf("Can't find codec for video format 0x%X !\n",sh_video->format);
|
printf("Can't find codec for video format 0x%X !\n",sh_video->format);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Reference in New Issue