1
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 07:33:46 +01:00

Allow forcing of demuxers and codecs by prepending '+'

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16322 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2005-08-30 23:56:24 +00:00
parent c1f2df8f53
commit 0446e090b1
7 changed files with 65 additions and 29 deletions

View File

@ -787,6 +787,7 @@ Plays a Matroska file in Japanese.
.TP
.B \-audio-demuxer <name> (\-audiofile only)
Force audio demuxer type for \-audiofile.
Use a '+' before the name to force it, this will skip some checks!
Give the demuxer name as printed by \-audio-demuxer help.
For backward compatibility it also accepts the demuxer ID as defined in
libmpdemux/\:demuxer.h.
@ -3136,10 +3137,11 @@ mplayer video.nut \-vf format=bgr15 \-vo tga
.SH "DECODING/\:FILTERING OPTIONS"
.
.TP
.B \-ac <[-]codec1,[-]codec2,...[,]>
.B \-ac <[-|+]codec1,[-|+]codec2,...[,]>
Specify a priority list of audio codecs to be used, according to their codec
name in codecs.conf.
Use a '-' before the codec name to omit it.
Use a '+' before the codec name to force it, this will likely crash!
If the list has a trailing ',' MPlayer will fall back on codecs not
contained in the list.
.br
@ -3541,6 +3543,7 @@ The description of the scale video filter has further information.
Specify a priority list of video codecs to be used, according to their codec
name in codecs.conf.
Use a '-' before the codec name to omit it.
Use a '+' before the codec name to force it, this will likely crash!
If the list has a trailing ',' MPlayer will fall back on codecs not
contained in the list.
.br

View File

@ -757,19 +757,19 @@ void codecs_uninit_free() {
}
codecs_t *find_audio_codec(unsigned int fourcc, unsigned int *fourccmap,
codecs_t *start)
codecs_t *start, int force)
{
return find_codec(fourcc, fourccmap, start, 1);
return find_codec(fourcc, fourccmap, start, 1, force);
}
codecs_t *find_video_codec(unsigned int fourcc, unsigned int *fourccmap,
codecs_t *start)
codecs_t *start, int force)
{
return find_codec(fourcc, fourccmap, start, 0);
return find_codec(fourcc, fourccmap, start, 0, force);
}
codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,
codecs_t *start, int audioflag)
codecs_t *start, int audioflag, int force)
{
int i, j;
codecs_t *c;
@ -806,6 +806,7 @@ codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,
return c;
}
}
if (force) return c;
}
}
return NULL;

View File

@ -59,9 +59,12 @@ typedef struct codecs_st {
} codecs_t;
int parse_codec_cfg(char *cfgfile);
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);
codecs_t* find_video_codec(unsigned int fourcc, unsigned int *fourccmap,
codecs_t *start, int force);
codecs_t* find_audio_codec(unsigned int fourcc, unsigned int *fourccmap,
codecs_t *start, int force);
codecs_t* find_codec(unsigned int fourcc, unsigned int *fourccmap,
codecs_t *start, int audioflag, int force);
void select_codec(char* codecname,int audioflag);
void list_codecs(int audioflag);
void codecs_reset_selection(int audioflag);

View File

@ -119,6 +119,11 @@ int init_audio_codec(sh_audio_t *sh_audio)
int init_audio(sh_audio_t *sh_audio,char* codecname,char* afm,int status){
unsigned int orig_fourcc=sh_audio->wf?sh_audio->wf->wFormatTag:0;
int force = 0;
if (codecname && codecname[0] == '+') {
codecname = &codecname[1];
force = 1;
}
sh_audio->codec=NULL;
while(1){
ad_functions_t* mpadec;
@ -126,14 +131,14 @@ int init_audio(sh_audio_t *sh_audio,char* codecname,char* afm,int status){
sh_audio->ad_driver = 0;
// restore original fourcc:
if(sh_audio->wf) sh_audio->wf->wFormatTag=i=orig_fourcc;
if(!(sh_audio->codec=find_codec(sh_audio->format,
sh_audio->wf?(&i):NULL, sh_audio->codec,1) )) break;
if(!(sh_audio->codec=find_audio_codec(sh_audio->format,
sh_audio->wf?(&i):NULL, sh_audio->codec, force) )) break;
if(sh_audio->wf) sh_audio->wf->wFormatTag=i;
// ok we found one codec
if(sh_audio->codec->flags&CODECS_FLAG_SELECTED) continue; // already tried & failed
if(codecname && strcmp(sh_audio->codec->name,codecname)) continue; // -ac
if(afm && strcmp(sh_audio->codec->drv,afm)) continue; // afm doesn't match
if(sh_audio->codec->status<status) continue; // too unstable
if(!force && sh_audio->codec->status<status) continue; // too unstable
sh_audio->codec->flags|=CODECS_FLAG_SELECTED; // tagging it
// ok, it matches all rules, let's find the driver!
for (i=0; mpcodecs_ad_drivers[i] != NULL; i++)

View File

@ -166,19 +166,24 @@ int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status){
unsigned int orig_fourcc=sh_video->bih?sh_video->bih->biCompression:0;
sh_video->codec=NULL;
sh_video->vf_inited=0;
int force = 0;
if (codecname && codecname[0] == '+') {
codecname = &codecname[1];
force = 1;
}
while(1){
int i;
// restore original fourcc:
if(sh_video->bih) sh_video->bih->biCompression=orig_fourcc;
if(!(sh_video->codec=find_codec(sh_video->format,
if(!(sh_video->codec=find_video_codec(sh_video->format,
sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL,
sh_video->codec,0) )) break;
sh_video->codec,force) )) break;
// ok we found one codec
if(sh_video->codec->flags&CODECS_FLAG_SELECTED) continue; // already tried & failed
if(codecname && strcmp(sh_video->codec->name,codecname)) continue; // -vc
if(vfm && strcmp(sh_video->codec->drv,vfm)) continue; // vfm doesn't match
if(sh_video->codec->status<status) continue; // too unstable
if(!force && sh_video->codec->status<status) continue; // too unstable
sh_video->codec->flags|=CODECS_FLAG_SELECTED; // tagging it
// ok, it matches all rules, let's find the driver!
for (i=0; mpcodecs_vd_drivers[i] != NULL; i++)

View File

@ -528,14 +528,21 @@ void demuxer_help(void)
* Get demuxer type for a given demuxer name
*
* @param demuxer_name string with demuxer name of demuxer number
* @param force will be set if demuxer should be forced.
* May be NULL.
* @return DEMUXER_TYPE_xxx, -1 if error or not found
*/
int get_demuxer_type_from_name(char *demuxer_name)
int get_demuxer_type_from_name(char *demuxer_name, int *force)
{
int i;
long type_int;
char *endptr;
if (!demuxer_name || !demuxer_name[0])
return DEMUXER_TYPE_UNKNOWN;
if (force) *force = demuxer_name[0] == '+';
if (demuxer_name[0] == '+')
demuxer_name = &demuxer_name[1];
for (i = 0; demuxer_list[i]; i++) {
if (demuxer_list[i]->type > DEMUXER_TYPE_MAX) // Can't select special demuxers from commandline
continue;
@ -568,7 +575,9 @@ int extension_parsing=1; // 0=off 1=mixed (used only for unstable formats)
(ex: tv,mf).
*/
static demuxer_t* demux_open_stream(stream_t *stream,int file_format,int audio_id,int video_id,int dvdsub_id,char* filename){
static demuxer_t* demux_open_stream(stream_t *stream, int file_format,
int force, int audio_id, int video_id, int dvdsub_id,
char* filename) {
//int file_format=(*file_format_ptr);
@ -586,7 +595,7 @@ int i;
if (file_format) {
if ((demuxer_desc = get_demuxer_desc_from_type(file_format))) {
demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename);
if (demuxer_desc->check_file) {
if (!force && demuxer_desc->check_file) {
if ((fformat = demuxer_desc->check_file(demuxer)) != 0) {
if (fformat == demuxer_desc->type) {
// Move messages to demuxer detection code?
@ -595,7 +604,8 @@ if (file_format) {
} else {
// Format changed after check, recurse
free_demuxer(demuxer);
return demux_open_stream(stream,fformat,audio_id,video_id,dvdsub_id,filename);
return demux_open_stream(stream, fformat, force,
audio_id, video_id, dvdsub_id, filename);
}
} else {
// Check failed for forced demuxer, quit
@ -621,7 +631,8 @@ for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
} else {
// Format changed after check, recurse
free_demuxer(demuxer);
demuxer=demux_open_stream(stream,fformat,audio_id,video_id,dvdsub_id,filename);
demuxer=demux_open_stream(stream, fformat, force,
audio_id, video_id, dvdsub_id, filename);
if(demuxer) return demuxer; // done!
file_format = DEMUXER_TYPE_UNKNOWN;
}
@ -643,7 +654,8 @@ if(file_format==DEMUXER_TYPE_UNKNOWN && filename && extension_parsing==1){
file_format=demuxer_type_by_filename(filename);
if(file_format!=DEMUXER_TYPE_UNKNOWN){
// we like recursion :)
demuxer=demux_open_stream(stream,file_format,audio_id,video_id,dvdsub_id,filename);
demuxer=demux_open_stream(stream, file_format, force,
audio_id, video_id, dvdsub_id, filename);
if(demuxer) return demuxer; // done!
file_format=DEMUXER_TYPE_UNKNOWN; // continue fuzzy guessing...
mp_msg(MSGT_DEMUXER,MSGL_V,"demuxer: continue fuzzy content-based format guessing...\n");
@ -662,7 +674,8 @@ for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
} else {
// Format changed after check, recurse
free_demuxer(demuxer);
demuxer=demux_open_stream(stream,fformat,audio_id,video_id,dvdsub_id,filename);
demuxer=demux_open_stream(stream, fformat, force,
audio_id, video_id, dvdsub_id, filename);
if(demuxer) return demuxer; // done!
file_format = DEMUXER_TYPE_UNKNOWN;
}
@ -718,16 +731,18 @@ demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int
demuxer_t *vd,*ad = NULL,*sd = NULL;
int afmt =DEMUXER_TYPE_UNKNOWN,sfmt = DEMUXER_TYPE_UNKNOWN ;
int audio_demuxer_type = 0, sub_demuxer_type = 0;
int demuxer_force = 0, audio_demuxer_force = 0,
sub_demuxer_force = 0;
demux_aid_vid_mismatch = 0;
if (demuxer_name && ((demuxer_type = get_demuxer_type_from_name(demuxer_name)) < 0)) {
if ((demuxer_type = get_demuxer_type_from_name(demuxer_name, &demuxer_force)) < 0) {
mp_msg(MSGT_DEMUXER,MSGL_ERR,"-demuxer %s does not exist.\n",demuxer_name);
}
if (audio_demuxer_name && ((audio_demuxer_type = get_demuxer_type_from_name(audio_demuxer_name)) < 0)) {
if ((audio_demuxer_type = get_demuxer_type_from_name(audio_demuxer_name, &audio_demuxer_force)) < 0) {
mp_msg(MSGT_DEMUXER,MSGL_ERR,"-audio-demuxer %s does not exist.\n",audio_demuxer_name);
}
if (sub_demuxer_name && ((sub_demuxer_type = get_demuxer_type_from_name(sub_demuxer_name)) < 0)) {
if ((sub_demuxer_type = get_demuxer_type_from_name(sub_demuxer_name, &sub_demuxer_force)) < 0) {
mp_msg(MSGT_DEMUXER,MSGL_ERR,"-sub-demuxer %s does not exist.\n",sub_demuxer_name);
}
@ -754,14 +769,17 @@ demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int
}
}
vd = demux_open_stream(vs,demuxer_type ? demuxer_type : file_format,audio_stream ? -2 : audio_id,video_id, sub_stream ? -2 : dvdsub_id, filename);
vd = demux_open_stream(vs, demuxer_type ? demuxer_type : file_format,
demuxer_force, audio_stream ? -2 : audio_id, video_id,
sub_stream ? -2 : dvdsub_id, filename);
if(!vd) {
if(as) free_stream(as);
if(ss) free_stream(ss);
return NULL;
}
if(as) {
ad = demux_open_stream(as,audio_demuxer_type ? audio_demuxer_type : afmt,audio_id,-2,-2, audio_stream);
ad = demux_open_stream(as, audio_demuxer_type ? audio_demuxer_type : afmt,
audio_demuxer_force, audio_id, -2, -2, audio_stream);
if(!ad) {
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningAudioDemuxerFailed,audio_stream);
free_stream(as);
@ -770,7 +788,8 @@ demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int
hr_mp3_seek=1; // Enable high res seeking
}
if(ss) {
sd = demux_open_stream(ss,sub_demuxer_type ? sub_demuxer_type : sfmt,-2,-2,dvdsub_id, sub_stream);
sd = demux_open_stream(ss, sub_demuxer_type ? sub_demuxer_type : sfmt,
sub_demuxer_force, -2, -2, dvdsub_id, sub_stream);
if(!sd) {
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningSubtitlesDemuxerFailed,sub_stream);
free_stream(ss);

View File

@ -327,4 +327,4 @@ extern int demuxer_switch_audio(demuxer_t *demuxer, int index);
extern int demuxer_type_by_filename(char* filename);
extern void demuxer_help(void);
extern int get_demuxer_type_from_name(char *demuxer_name);
extern int get_demuxer_type_from_name(char *demuxer_name, int *force);