0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

Move dvdsub_id to options struct

Name the field "sub_id" as it's not specific to DVD subs.

Remove some other unused extern declarations together with dvdsub_id
from demux_mkv.c and demux_lavf.c.
This commit is contained in:
Uoti Urpala 2008-04-23 07:41:17 +03:00
parent c0c914effd
commit 66bd120a3a
12 changed files with 55 additions and 62 deletions

View File

@ -117,7 +117,7 @@
// select audio/video/subtitle stream
INTRANGE("aid", audio_id, 0, 8190, 0),
INTRANGE("vid", video_id, 0, 8190, 0),
{"sid", &dvdsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 8190, NULL},
INTRANGE("sid", sub_id, 0, 8190, 0),
FLAG_CONSTANTS("novideo", video_id, -1, -2, 0),
{ "hr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 0, 1, NULL },

View File

@ -1305,6 +1305,7 @@ static int mp_property_sub_pos(m_option_t * prop, int action, void *arg,
static int mp_property_sub(m_option_t * prop, int action, void *arg,
MPContext * mpctx)
{
struct MPOpts *opts = &mpctx->opts;
demux_stream_t *const d_sub = mpctx->d_sub;
const int global_sub_size = mpctx->global_sub_size;
int source = -1, reset_spu = 0;
@ -1345,10 +1346,10 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
}
#ifdef USE_DVDNAV
if (mpctx->stream->type == STREAMTYPE_DVDNAV) {
if (vo_spudec && dvdsub_id >= 0) {
if (vo_spudec && opts->sub_id >= 0) {
unsigned char lang[3];
if (dvdnav_lang_from_sid(mpctx->stream, dvdsub_id, lang)) {
snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
if (dvdnav_lang_from_sid(mpctx->stream, opts->sub_id, lang)) {
snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, lang);
return M_PROPERTY_OK;
}
}
@ -1358,10 +1359,10 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
if ((mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA
|| mpctx->demuxer->type == DEMUXER_TYPE_LAVF
|| mpctx->demuxer->type == DEMUXER_TYPE_OGG)
&& d_sub && d_sub->sh && dvdsub_id >= 0) {
&& d_sub && d_sub->sh && opts->sub_id >= 0) {
const char* lang = ((sh_sub_t*)d_sub->sh)->lang;
if (!lang) lang = MSGTR_Unknown;
snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, lang);
return M_PROPERTY_OK;
}
@ -1374,18 +1375,18 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
}
#ifdef USE_DVDREAD
if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD
&& dvdsub_id >= 0) {
&& opts->sub_id >= 0) {
char lang[3];
int code = dvd_lang_from_sid(mpctx->stream, dvdsub_id);
int code = dvd_lang_from_sid(mpctx->stream, opts->sub_id);
lang[0] = code >> 8;
lang[1] = code;
lang[2] = 0;
snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, lang);
return M_PROPERTY_OK;
}
#endif
if (dvdsub_id >= 0) {
snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, MSGTR_Unknown);
if (opts->sub_id >= 0) {
snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, MSGTR_Unknown);
return M_PROPERTY_OK;
}
snprintf(*(char **) arg, 63, MSGTR_Disabled);
@ -1429,7 +1430,7 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
subdata = NULL;
vobsub_id = -1;
dvdsub_id = -1;
opts->sub_id = -1;
if (d_sub) {
if (d_sub->id > -2)
reset_spu = 1;
@ -1454,17 +1455,17 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
vo_osd_changed(OSDTYPE_SUBTITLE);
}
} else if (source == SUB_SOURCE_DEMUX) {
dvdsub_id =
opts->sub_id =
mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_DEMUX];
if (d_sub && dvdsub_id < MAX_S_STREAMS) {
if (d_sub && opts->sub_id < MAX_S_STREAMS) {
int i = 0;
// default: assume 1:1 mapping of sid and stream id
d_sub->id = dvdsub_id;
d_sub->id = opts->sub_id;
d_sub->sh = mpctx->demuxer->s_streams[d_sub->id];
ds_free_packs(d_sub);
for (i = 0; i < MAX_S_STREAMS; i++) {
sh_sub_t *sh = mpctx->demuxer->s_streams[i];
if (sh && sh->sid == dvdsub_id) {
if (sh && sh->sid == opts->sub_id) {
d_sub->id = i;
d_sub->sh = sh;
break;
@ -1488,9 +1489,9 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,
if (vo_spudec
&& (mpctx->stream->type == STREAMTYPE_DVD
|| mpctx->stream->type == STREAMTYPE_DVDNAV)
&& dvdsub_id < 0 && reset_spu) {
dvdsub_id = -2;
d_sub->id = dvdsub_id;
&& opts->sub_id < 0 && reset_spu) {
opts->sub_id = -2;
d_sub->id = opts->sub_id;
}
#endif
update_subtitles(mpctx->sh_video, d_sub, 1);

View File

@ -12,6 +12,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
.user_correct_pts = -1,
.audio_id = -1,
.video_id = -1,
.sub_id = -2,
.playback_speed = 1.,
};
}

View File

@ -42,9 +42,6 @@
#define PROBE_BUF_SIZE 2048
extern char *audio_lang;
extern char *dvdsub_lang;
extern int dvdsub_id;
static unsigned int opt_probesize = 0;
static unsigned int opt_analyzeduration = 0;
static char *opt_format;

View File

@ -181,11 +181,6 @@ typedef struct mkv_demuxer
#define RAPROPERTIES4_SIZE 56
#define RAPROPERTIES5_SIZE 70
/* for e.g. "-slang ger" */
extern char *dvdsub_lang;
extern char *audio_lang;
extern int dvdsub_id;
/**
* \brief ensures there is space for at least one additional element
* \param array array to grow

View File

@ -8,6 +8,7 @@
#include <math.h>
#include <inttypes.h>
#include "options.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "stream/stream.h"
@ -145,7 +146,6 @@ typedef struct ogg_demuxer {
#define PACKET_IS_SYNCPOINT 0x08
extern char *dvdsub_lang, *audio_lang;
extern int dvdsub_id;
//-------- subtitle support - should be moved to decoder layer, and queue
// - subtitles up in demuxer buffer...
@ -395,7 +395,7 @@ static void demux_ogg_check_comments(demuxer_t *d, ogg_stream_t *os, int id, vor
if (os->text && d->sub->id < 0 && demux_ogg_check_lang(val, dvdsub_lang))
{
d->sub->id = index;
dvdsub_id = index;
d->opts->sub_id = index;
mp_msg(MSGT_DEMUX, MSGL_V, "Ogg demuxer: Displaying subtitle stream id %d which matched -slang %s\n", id, val);
}
else

View File

@ -234,8 +234,6 @@ demuxer_t *new_demuxer(struct MPOpts *opts, stream_t *stream, int type,
return d;
}
extern int dvdsub_id;
sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid)
{
if (id > MAX_S_STREAMS - 1 || id < 0) {

View File

@ -112,7 +112,6 @@ float stream_cache_seek_min_percent=50.0;
#define cache_fill_status 0
#endif
int dvdsub_id=-2;
int vobsub_id=-1;
char* audio_lang=NULL;
char* dvdsub_lang=NULL;
@ -583,14 +582,14 @@ play_next_file:
#ifdef USE_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 && dvdsub_id==-2) dvdsub_id=dvd_sid_from_lang(stream,dvdsub_lang);
if(dvdsub_lang && opts.sub_id==-2) opts.sub_id=dvd_sid_from_lang(stream,dvdsub_lang);
}
#endif
#ifdef USE_DVDNAV
if(stream->type==STREAMTYPE_DVDNAV){
if(audio_lang && opts.audio_id==-1) opts.audio_id=dvdnav_aid_from_lang(stream,audio_lang);
if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=dvdnav_sid_from_lang(stream,dvdsub_lang);
if(dvdsub_lang && opts.sub_id==-2) opts.sub_id=dvdnav_sid_from_lang(stream,dvdsub_lang);
}
#endif
@ -600,8 +599,8 @@ if(stream->type==STREAMTYPE_DVDNAV){
if(demuxer2) opts.audio_id=-2; /* do NOT read audio packets... */
//demuxer=demux_open(stream,file_format,opts.video_id,opts.audio_id,dvdsub_id);
demuxer=demux_open(&opts, stream,file_format,opts.audio_id,opts.video_id,dvdsub_id,filename);
//demuxer=demux_open(stream,file_format,opts.video_id,opts.audio_id,opts.sub_id);
demuxer=demux_open(&opts, stream,file_format,opts.audio_id,opts.video_id,opts.sub_id,filename);
if(!demuxer){
mp_msg(MSGT_DEMUXER, MSGL_FATAL, MSGTR_FormatNotRecognized);
mp_msg(MSGT_DEMUXER, MSGL_FATAL, MSGTR_CannotOpenDemuxer);
@ -610,15 +609,15 @@ if(stream->type==STREAMTYPE_DVDNAV){
select_audio(demuxer, opts.audio_id, audio_lang);
if (dvdsub_id < 0 && dvdsub_lang)
dvdsub_id = demuxer_sub_track_by_lang(demuxer, dvdsub_lang);
if (opts.sub_id < 0 && dvdsub_lang)
opts.sub_id = demuxer_sub_track_by_lang(demuxer, dvdsub_lang);
if (dvdsub_id < 0)
dvdsub_id = demuxer_default_sub_track(demuxer);
if (opts.sub_id < 0)
opts.sub_id = demuxer_default_sub_track(demuxer);
for (i = 0; i < MAX_S_STREAMS; i++) {
sh_sub_t *sh = demuxer->s_streams[i];
if (sh && sh->sid == dvdsub_id) {
if (sh && sh->sid == opts.sub_id) {
demuxer->sub->id = i;
demuxer->sub->sh = sh;
break;
@ -716,7 +715,7 @@ if (!curfile) { // curfile is non zero when a second file is opened
if (vobsub_out) {
unsigned int palette[16], width, height;
unsigned char tmp[3] = { 0, 0, 0 };
if (spudec_ifo && vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, dvdsub_id, tmp) >= 0)
if (spudec_ifo && vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, opts.sub_id, tmp) >= 0)
vobsub_writer = vobsub_out_open(vobsub_out, palette, sh_video->disp_w, sh_video->disp_h,
vobsub_out_id?vobsub_out_id:(char *)tmp, vobsub_out_index);
#ifdef USE_DVDREAD
@ -726,7 +725,7 @@ if (vobsub_out) {
int i;
dvd_priv_t *dvd = (dvd_priv_t*)stream->priv;
for (i = 0; i < dvd->nr_of_subtitles; ++i)
if (dvd->subtitles[i].id == dvdsub_id) {
if (dvd->subtitles[i].id == opts.sub_id) {
tmp[0] = (dvd->subtitles[i].language >> 8) & 0xff;
tmp[1] = dvd->subtitles[i].language & 0xff;
tmp[2] = 0;

View File

@ -1,4 +1,5 @@
#include <stdlib.h>
#include "options.h"
#include "stream/stream.h"
#include "libmpdemux/demuxer.h"
#include "libmpdemux/stheader.h"
@ -26,6 +27,7 @@ subtitle* vo_sub_last = NULL;
void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset)
{
struct MPOpts *opts = sh_video->opts;
unsigned char *packet=NULL;
int len;
char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v';
@ -56,7 +58,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset)
}
// DVD sub:
if (vo_spudec && (vobsub_id >= 0 || (dvdsub_id >= 0 && type == 'v'))) {
if (vo_spudec && (vobsub_id >= 0 || (opts->sub_id >= 0 && type == 'v'))) {
int timestamp;
current_module = "spudec";
spudec_heartbeat(vo_spudec, 90000*sh_video->timer);
@ -100,7 +102,8 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset)
if (spudec_changed(vo_spudec))
vo_osd_changed(OSDTYPE_SPU);
} else if (dvdsub_id >= 0 && (type == 't' || type == 'm' || type == 'a')) {
} else if (opts->sub_id >= 0
&& (type == 't' || type == 'm' || type == 'a')) {
double curpts = sh_video->pts + sub_delay;
double endpts;
vo_sub = &subs;

View File

@ -243,7 +243,6 @@ extern char *demuxer_name; // override demuxer
extern char *audio_demuxer_name; // override audio demuxer
extern char *sub_demuxer_name; // override sub demuxer
int dvdsub_id=-2;
int vobsub_id=-1;
char* audio_lang=NULL;
char* dvdsub_lang=NULL;
@ -1851,7 +1850,7 @@ static void mp_dvdnav_reset_stream (MPContext *ctx) {
resync_audio_stream(ctx->sh_audio);
}
if (ctx->d_sub) dvdsub_id = -2;
if (ctx->d_sub) opts->sub_id = -2;
audio_delay = 0.0f;
@ -3207,8 +3206,8 @@ if(stream_dump_type==5){
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 && dvdsub_id==-2) dvdsub_id=-1;
if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvd_sid_from_lang(mpctx->stream,dvdsub_lang);
if(dvdsub_lang && opts->sub_id==-2) opts->sub_id=-1;
if(dvdsub_lang && opts->sub_id==-1) opts->sub_id=dvd_sid_from_lang(mpctx->stream,dvdsub_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);
@ -3220,8 +3219,8 @@ if(mpctx->stream->type==STREAMTYPE_DVD){
if(mpctx->stream->type==STREAMTYPE_DVDNAV){
current_module="dvdnav lang->id";
if(opts->audio_id==-1) opts->audio_id=dvdnav_aid_from_lang(mpctx->stream,audio_lang);
if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=-1;
if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvdnav_sid_from_lang(mpctx->stream,dvdsub_lang);
if(dvdsub_lang && opts->sub_id==-2) opts->sub_id=-1;
if(dvdsub_lang && opts->sub_id==-1) opts->sub_id=dvdnav_sid_from_lang(mpctx->stream,dvdsub_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 += dvdnav_number_of_subs(mpctx->stream);
@ -3242,7 +3241,7 @@ if(stream_cache_size>0){
//============ Open DEMUXERS --- DETECT file type =======================
current_module="demux_open";
mpctx->demuxer=demux_open(opts, mpctx->stream,mpctx->file_format,opts->audio_id,opts->video_id,dvdsub_id,filename);
mpctx->demuxer=demux_open(opts, mpctx->stream,mpctx->file_format,opts->audio_id,opts->video_id,opts->sub_id,filename);
// HACK to get MOV Reference Files working
@ -3321,9 +3320,9 @@ if (mpctx->stream->type != STREAMTYPE_DVD && mpctx->stream->type != STREAMTYPE_D
maxid = FFMAX(maxid, mpctx->demuxer->s_streams[i]->sid);
mpctx->global_sub_size += maxid + 1;
}
// Make dvdsub_id always selectable if set.
if (mpctx->global_sub_size <= mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id)
mpctx->global_sub_size = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id + 1;
// Make opts->sub_id always selectable if set.
if (mpctx->global_sub_size <= mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts->sub_id)
mpctx->global_sub_size = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts->sub_id + 1;
#ifdef USE_ASS
if (ass_enabled && ass_library) {
@ -3478,16 +3477,16 @@ if(mpctx->sh_video) {
if (mpctx->global_sub_size) {
// find the best sub to use
int vobsub_index_id = vobsub_get_index_by_id(vo_vobsub, vobsub_id);
if (dvdsub_id < 0 && dvdsub_lang)
dvdsub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang);
if (dvdsub_id < 0)
dvdsub_id = demuxer_default_sub_track(mpctx->demuxer);
if (opts->sub_id < 0 && dvdsub_lang)
opts->sub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang);
if (opts->sub_id < 0)
opts->sub_id = demuxer_default_sub_track(mpctx->demuxer);
if (vobsub_index_id >= 0) {
// if user asks for a vobsub id, use that first.
mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_VOBSUB] + vobsub_index_id;
} else if (dvdsub_id >= 0 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
} else if (opts->sub_id >= 0 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
// if user asks for a dvd sub id, use that next.
mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id;
mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts->sub_id;
} else if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] >= 0) {
// if there are text subs to use, use those. (autosubs come last here)
mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_SUBS];

View File

@ -44,7 +44,6 @@ extern int frame_dropping;
extern int auto_quality;
extern int dvdsub_id;
extern int vobsub_id;
static inline void exit_player(const char *how)

View File

@ -14,6 +14,7 @@ typedef struct MPOpts {
int user_correct_pts;
int audio_id;
int video_id;
int sub_id;
float playback_speed;
} MPOpts;