1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-31 19:52:16 +00:00

options: move -alang and -slang to option struct

The option field corresponding to -slang is now called "sub_lang"
instead of the old misleading global name "dvdsub_lang". The code
handling -slang in subreader.c looks rather broken; disable it instead
of converting it to use the option field.
This commit is contained in:
Uoti Urpala 2010-05-21 23:57:29 +03:00
parent de5566f0b5
commit b3a688d45f
8 changed files with 41 additions and 42 deletions

View File

@ -60,8 +60,6 @@
#endif /* CONFIG_DVDREAD */
OPT_INTPAIR("chapter", chapterrange, 0),
OPT_INTRANGE("edition", edition_id, 0, -1, 8190),
{"alang", &audio_lang, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"slang", &dvdsub_lang, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"dvdauth", "libcss is obsolete. Try libdvdread instead.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
{"dvdkey", "libcss is obsolete. Try libdvdread instead.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
@ -146,6 +144,10 @@
OPT_INTRANGE("sid", sub_id, 0, -2, 8190),
OPT_FLAG_CONSTANTS("nosub", sub_id, 0, -1, -2),
OPT_FLAG_CONSTANTS("novideo", video_id, 0, -1, -2),
OPT_FLAG_CONSTANTS("sound", audio_id, 0, -2, -1),
OPT_FLAG_CONSTANTS("nosound", audio_id, 0, -1, -2),
OPT_STRING("alang", audio_lang, 0),
OPT_STRING("slang", sub_lang, 0),
{ "hr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 0, 1, NULL },
{ "nohr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 1, 0, NULL},
@ -222,10 +224,6 @@
{"stereo", &fakemono, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
#endif
// disable audio
OPT_FLAG_CONSTANTS("sound", audio_id, 0, -2, -1),
OPT_FLAG_CONSTANTS("nosound", audio_id, 0, -1, -2),
{"af*", &af_cfg.list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
{"af-adv", (void *) audio_filter_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},

View File

@ -26,6 +26,7 @@
#include "config.h"
#include "mp_msg.h"
#include "options.h"
#include "stream/stream.h"
#include "demuxer.h"
@ -57,7 +58,6 @@ typedef struct mpg_demuxer {
int a_stream_ids[MAX_A_STREAMS];
} mpg_demuxer_t;
extern char* dvdsub_lang;
static int mpeg_pts_error=0;
off_t ps_probe = 0;
@ -482,7 +482,7 @@ static int demux_mpg_read_packet(demuxer_t *demux,int id){
if(demux->sub->id > -1)
demux->sub->id &= 0x1F;
if(!dvdsub_lang && demux->sub->id == -1)
if(!demux->opts->sub_lang && demux->sub->id == -1)
demux->sub->id = aid;
if(demux->sub->id==aid){
ds=demux->sub;

View File

@ -163,8 +163,6 @@ typedef struct ogg_demuxer {
#define PACKET_LEN_BITS2 0x02
#define PACKET_IS_SYNCPOINT 0x08
extern char *dvdsub_lang, *audio_lang;
//-------- subtitle support - should be moved to decoder layer, and queue
// - subtitles up in demuxer buffer...
@ -449,7 +447,8 @@ static void demux_ogg_check_comments(demuxer_t *d, ogg_stream_t *os,
sh->lang = strdup(val);
}
// check for -slang if subs are uninitialized yet
if (os->text && d->sub->id < 0 && demux_ogg_check_lang(val, dvdsub_lang)) {
if (os->text && d->sub->id < 0
&& demux_ogg_check_lang(val, d->opts->sub_lang)) {
d->sub->id = index;
d->opts->sub_id = index;
mp_msg(MSGT_DEMUX, MSGL_V,

View File

@ -28,6 +28,7 @@
#include "config.h"
#include "mp_msg.h"
#include "options.h"
#include "stream/stream.h"
#include "demuxer.h"
@ -60,7 +61,6 @@ int ts_prog;
int ts_keep_broken=0;
off_t ts_probe = 0;
int audio_substream_id = -1;
extern char *dvdsub_lang, *audio_lang; //for -alang
typedef enum
{
@ -1007,17 +1007,17 @@ static demuxer_t *demux_open_ts(demuxer_t * demuxer)
params.prog = ts_prog;
params.probe = ts_probe;
if(dvdsub_lang != NULL)
if(demuxer->opts->sub_lang != NULL)
{
strncpy(params.slang, dvdsub_lang, 3);
strncpy(params.slang, demuxer->opts->sub_lang, 3);
params.slang[3] = 0;
}
else
memset(params.slang, 0, 4);
if(audio_lang != NULL)
if(demuxer->opts->audio_lang != NULL)
{
strncpy(params.alang, audio_lang, 3);
strncpy(params.alang, demuxer->opts->audio_lang, 3);
params.alang[3] = 0;
}
else
@ -2937,10 +2937,10 @@ static int ts_parse(demuxer_t *demuxer , ES_stream_t *es, unsigned char *packet,
int asgn = 0;
uint8_t *lang;
if(dvdsub_lang)
if(demuxer->opts->sub_lang)
{
if ((lang = pid_lang_from_pmt(priv, pid)))
asgn = (strncmp(lang, dvdsub_lang, 3) == 0);
asgn = (strncmp(lang, demuxer->opts->sub_lang, 3) == 0);
}
else //no language specified with -slang
asgn = 1;

View File

@ -125,8 +125,6 @@ float stream_cache_seek_min_percent=50.0;
#endif
int vobsub_id=-1;
char* audio_lang=NULL;
char* dvdsub_lang=NULL;
static char* spudec_ifo=NULL;
static char** audio_codec_list=NULL; // override audio codec
@ -735,15 +733,15 @@ play_next_file:
#ifdef CONFIG_DVDREAD
if(stream->type==STREAMTYPE_DVD){
if(audio_lang && opts.audio_id==-1) opts.audio_id=dvd_aid_from_lang(stream,audio_lang);
if(dvdsub_lang && opts.sub_id==-1) opts.sub_id=dvd_sid_from_lang(stream,dvdsub_lang);
if(opts.audio_lang && opts.audio_id==-1) opts.audio_id=dvd_aid_from_lang(stream,opts.audio_lang);
if(opts.sub_lang && opts.sub_id==-1) opts.sub_id=dvd_sid_from_lang(stream,opts.sub_lang);
}
#endif
#ifdef CONFIG_DVDNAV
if(stream->type==STREAMTYPE_DVDNAV){
if(audio_lang && opts.audio_id==-1) opts.audio_id=mp_dvdnav_aid_from_lang(stream,audio_lang);
if(dvdsub_lang && opts.sub_id==-1) opts.sub_id=mp_dvdnav_sid_from_lang(stream,dvdsub_lang);
if(opts.audio_lang && opts.audio_id==-1) opts.audio_id=mp_dvdnav_aid_from_lang(stream,opts.audio_lang);
if(opts.sub_lang && opts.sub_id==-1) opts.sub_id=mp_dvdnav_sid_from_lang(stream,opts.sub_lang);
}
#endif
@ -768,10 +766,10 @@ if(stream->type==STREAMTYPE_DVDNAV){
demuxer_switch_video(demuxer, opts.video_id);
}
}
select_audio(demuxer, opts.audio_id, audio_lang);
select_audio(demuxer, opts.audio_id, opts.audio_lang);
if (opts.sub_id < -1 && dvdsub_lang)
opts.sub_id = demuxer_sub_track_by_lang(demuxer, dvdsub_lang);
if (opts.sub_id < -1 && opts.sub_lang)
opts.sub_id = demuxer_sub_track_by_lang(demuxer, opts.sub_lang);
if (opts.sub_id < -1)
opts.sub_id = demuxer_default_sub_track(demuxer);

View File

@ -313,8 +313,6 @@ extern char *sub_demuxer_name; // override sub demuxer
// in particular the subtitle ID for a language changes
int dvdsub_lang_id;
int vobsub_id=-1;
char* audio_lang=NULL;
char* dvdsub_lang=NULL;
static char* spudec_ifo=NULL;
int forced_subs_only=0;
int file_filter=1;
@ -1915,8 +1913,8 @@ static void select_subtitle(MPContext *mpctx)
mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_SUBS];
} else if (opts->sub_id == -1 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
// finally select subs by language and container hints
if (opts->sub_id == -1 && dvdsub_lang)
opts->sub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang);
if (opts->sub_id == -1 && opts->sub_lang)
opts->sub_id = demuxer_sub_track_by_lang(mpctx->demuxer, opts->sub_lang);
if (opts->sub_id == -1)
opts->sub_id = demuxer_default_sub_track(mpctx->demuxer);
if (opts->sub_id >= 0)
@ -1985,8 +1983,8 @@ static void mp_dvdnav_reset_stream (MPContext *ctx) {
audio_delay = 0.0f;
ctx->global_sub_size = ctx->global_sub_indices[SUB_SOURCE_DEMUX] + mp_dvdnav_number_of_subs(ctx->stream);
if (dvdsub_lang && opts->sub_id == dvdsub_lang_id) {
dvdsub_lang_id = mp_dvdnav_sid_from_lang(ctx->stream, dvdsub_lang);
if (opts->sub_lang && opts->sub_id == dvdsub_lang_id) {
dvdsub_lang_id = mp_dvdnav_sid_from_lang(ctx->stream, opts->sub_lang);
if (dvdsub_lang_id != opts->sub_id) {
opts->sub_id = dvdsub_lang_id;
select_subtitle(ctx);
@ -3530,7 +3528,7 @@ if (edl_output_filename) {
}
if(vo_vobsub){
mpctx->initialized_flags|=INITIALIZED_VOBSUB;
vobsub_set_from_lang(vo_vobsub, dvdsub_lang);
vobsub_set_from_lang(vo_vobsub, opts->sub_lang);
mp_property_do("sub_forced_only", M_PROPERTY_SET, &forced_subs_only, mpctx);
// setup global sub numbering
@ -3622,8 +3620,8 @@ if(stream_dump_type==5){
#ifdef CONFIG_DVDREAD
if(mpctx->stream->type==STREAMTYPE_DVD){
current_module="dvd lang->id";
if(opts->audio_id==-1) opts->audio_id=dvd_aid_from_lang(mpctx->stream,audio_lang);
if(dvdsub_lang && opts->sub_id==-1) opts->sub_id=dvd_sid_from_lang(mpctx->stream,dvdsub_lang);
if(opts->audio_id==-1) opts->audio_id=dvd_aid_from_lang(mpctx->stream,opts->audio_lang);
if(opts->sub_lang && opts->sub_id==-1) opts->sub_id=dvd_sid_from_lang(mpctx->stream,opts->sub_lang);
// setup global sub numbering
mpctx->global_sub_indices[SUB_SOURCE_DEMUX] = mpctx->global_sub_size; // the global # of the first demux-specific sub.
mpctx->global_sub_size += dvd_number_of_subs(mpctx->stream);
@ -3634,10 +3632,10 @@ if(mpctx->stream->type==STREAMTYPE_DVD){
#ifdef CONFIG_DVDNAV
if(mpctx->stream->type==STREAMTYPE_DVDNAV){
current_module="dvdnav lang->id";
if(opts->audio_id==-1) opts->audio_id=mp_dvdnav_aid_from_lang(mpctx->stream,audio_lang);
if(opts->audio_id==-1) opts->audio_id=mp_dvdnav_aid_from_lang(mpctx->stream,opts->audio_lang);
dvdsub_lang_id = -3;
if(dvdsub_lang && opts->sub_id==-1)
dvdsub_lang_id = opts->sub_id = mp_dvdnav_sid_from_lang(mpctx->stream,dvdsub_lang);
if(opts->sub_lang && opts->sub_id==-1)
dvdsub_lang_id = opts->sub_id = mp_dvdnav_sid_from_lang(mpctx->stream,opts->sub_lang);
// setup global sub numbering
mpctx->global_sub_indices[SUB_SOURCE_DEMUX] = mpctx->global_sub_size; // the global # of the first demux-specific sub.
mpctx->global_sub_size += mp_dvdnav_number_of_subs(mpctx->stream);
@ -3781,7 +3779,7 @@ if (ts_prog) {
mp_property_do("switch_program", M_PROPERTY_SET, &tmp, mpctx);
}
// select audio stream
select_audio(mpctx->demuxer, opts->audio_id, audio_lang);
select_audio(mpctx->demuxer, opts->audio_id, opts->audio_lang);
// DUMP STREAMS:
if((stream_dump_type)&&(stream_dump_type<4)){

View File

@ -39,6 +39,8 @@ typedef struct MPOpts {
int audio_id;
int video_id;
int sub_id;
char *audio_lang;
char *sub_lang;
float playback_speed;
struct m_obj_settings *vf_settings;
int softzoom;

View File

@ -53,8 +53,6 @@ int flip_hebrew = 1; ///flip subtitles using fribidi
int fribidi_flip_commas = 0; ///flip comma when fribidi is used
#endif
extern char* dvdsub_lang;
/* Maximal length of line of a subtitle */
#define LINE_LEN 1000
static float mpsub_position=0;
@ -1888,11 +1886,17 @@ char** sub_filenames(const char* path, char *fname)
strcpy_strip_ext(f_fname_noext, f_fname);
strcpy_trim(f_fname_trim, f_fname_noext);
/* The code using sub language here is broken - it assumes strict
* "videoname languagename" syntax for the subtitle file, which is
* very unlikely to match especially if language name uses "en,de"
* syntax... */
tmp_sub_id = NULL;
#if 0
if (dvdsub_lang && !whiteonly(dvdsub_lang)) {
tmp_sub_id = malloc(strlen(dvdsub_lang)+1);
strcpy_trim(tmp_sub_id, dvdsub_lang);
}
#endif
// 0 = nothing
// 1 = any subtitle file