mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
moved combined vobsub_lang into sub_select
add support for dvd subs and ogg subs into sub_select document sub_select vobsub_lang left as a link to sub_select for backwards compatibility git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13090 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
@@ -71,8 +71,13 @@ sub_visibility
|
||||
get_sub_visibility
|
||||
Print out subtitle visibility (1 == on, 0 == off).
|
||||
|
||||
sub_select
|
||||
Cycle through the subtitle set. Supported subtitle sources are -sub
|
||||
options on the command line, VOBSubs, DVD subtitles, and OGG text
|
||||
streams.
|
||||
|
||||
vobsub_lang
|
||||
Switch the subtitle language when using VOBSub subtitles.
|
||||
This is a stub linked to sub_select for backwards compatibility.
|
||||
|
||||
get_percent_pos
|
||||
Print out the current position in the file, in integer percentage [0-100).
|
||||
|
||||
@@ -77,7 +77,7 @@ static mp_cmd_t mp_cmds[] = {
|
||||
{ MP_CMD_SUB_POS, "sub_pos", 1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
|
||||
{ MP_CMD_SUB_ALIGNMENT, "sub_alignment",0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } },
|
||||
{ MP_CMD_SUB_VISIBILITY, "sub_visibility", 0, { {-1,{0}} } },
|
||||
{ MP_CMD_VOBSUB_LANG, "vobsub_lang", 0, { {-1,{0}} } },
|
||||
{ MP_CMD_SUB_SELECT, "vobsub_lang", 0, { {-1,{0}} } }, // for compatibility
|
||||
{ MP_CMD_SUB_SELECT, "sub_select", 0, { {-1,{0}} } },
|
||||
{ MP_CMD_GET_PERCENT_POS, "get_percent_pos", 0, { {-1,{0}} } },
|
||||
{ MP_CMD_GET_TIME_LENGTH, "get_time_length", 0, { {-1,{0}} } },
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#define MP_CMD_VF_CHANGE_RECTANGLE 28
|
||||
#define MP_CMD_GAMMA 29
|
||||
#define MP_CMD_SUB_VISIBILITY 30
|
||||
#define MP_CMD_VOBSUB_LANG 31
|
||||
// #define MP_CMD_VOBSUB_LANG 31 // combined with SUB_SELECT
|
||||
#define MP_CMD_MENU 32
|
||||
#define MP_CMD_SET_MENU 33
|
||||
#define MP_CMD_GET_TIME_LENGTH 34
|
||||
|
||||
@@ -655,12 +655,18 @@ void demux_ogg_scan_stream(demuxer_t* demuxer) {
|
||||
extern void print_wave_header(WAVEFORMATEX *h);
|
||||
extern void print_video_header(BITMAPINFOHEADER *h);
|
||||
|
||||
static int n_text = 0;
|
||||
static int *text_ids = NULL;
|
||||
|
||||
int demux_ogg_num_subs() { return n_text; }
|
||||
int demux_ogg_sub_id(int index) { return (index < 0) ? index : text_ids[index]; }
|
||||
|
||||
/// Open an ogg physical stream
|
||||
int demux_ogg_open(demuxer_t* demuxer) {
|
||||
ogg_demuxer_t* ogg_d;
|
||||
stream_t *s;
|
||||
char* buf;
|
||||
int np,s_no, n_audio = 0, n_video = 0, n_text = 0;
|
||||
int np,s_no, n_audio = 0, n_video = 0;
|
||||
int audio_id = -1, video_id = -1, text_id = -1;
|
||||
ogg_sync_state* sync;
|
||||
ogg_page* page;
|
||||
@@ -902,6 +908,8 @@ int demux_ogg_open(demuxer_t* demuxer) {
|
||||
if (demuxer->sub->id == n_text)
|
||||
text_id = ogg_d->num_sub;
|
||||
n_text++;
|
||||
text_ids = (int *)realloc(text_ids, sizeof(int) * n_text);
|
||||
text_ids[n_text - 1] = ogg_d->num_sub;
|
||||
demux_ogg_init_sub();
|
||||
//// Unknown header type
|
||||
} else
|
||||
|
||||
@@ -636,6 +636,25 @@ if(lang){
|
||||
return d->nr_of_channels ? d->audio_streams[0].id : -1;
|
||||
}
|
||||
|
||||
int dvd_number_of_subs(stream_t *stream)
|
||||
{
|
||||
dvd_priv_t *d;
|
||||
if (!stream) return -1;
|
||||
d = stream->priv;
|
||||
if (!d) return -1;
|
||||
return d->nr_of_subtitles;
|
||||
}
|
||||
|
||||
int dvd_lang_from_sid(stream_t *stream, int id)
|
||||
{
|
||||
dvd_priv_t *d;
|
||||
if (!stream) return 0;
|
||||
d = stream->priv;
|
||||
if (!d) return 0;
|
||||
if (id >= d->nr_of_subtitles) return 0;
|
||||
return d->subtitles[id].language;
|
||||
}
|
||||
|
||||
int dvd_sid_from_lang(stream_t *stream, unsigned char* lang){
|
||||
dvd_priv_t *d=stream->priv;
|
||||
int code,i;
|
||||
|
||||
@@ -321,6 +321,8 @@ typedef struct {
|
||||
stream_language_t subtitles[32];
|
||||
} dvd_priv_t;
|
||||
|
||||
int dvd_number_of_subs(stream_t *stream);
|
||||
int dvd_lang_from_sid(stream_t *stream, int id);
|
||||
int dvd_aid_from_lang(stream_t *stream, unsigned char* lang);
|
||||
int dvd_sid_from_lang(stream_t *stream, unsigned char* lang);
|
||||
int dvd_chapter_from_cell(dvd_priv_t *dvd,int title,int cell);
|
||||
|
||||
72
mplayer.c
72
mplayer.c
@@ -1587,7 +1587,7 @@ if(!sh_video && !sh_audio){
|
||||
demux_info_print(demuxer);
|
||||
|
||||
//================== Read SUBTITLES (DVD & TEXT) ==========================
|
||||
if(d_dvdsub->id >= 0 && vo_spudec==NULL && sh_video){
|
||||
if(vo_spudec==NULL && sh_video && stream->type==STREAMTYPE_DVD){
|
||||
|
||||
if (spudec_ifo) {
|
||||
unsigned int palette[16], width, height;
|
||||
@@ -3115,19 +3115,6 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still)
|
||||
}
|
||||
#endif
|
||||
} break;
|
||||
case MP_CMD_VOBSUB_LANG:
|
||||
if (vo_vobsub)
|
||||
{
|
||||
int new_id = vobsub_id + 1;
|
||||
if (vobsub_id < 0)
|
||||
new_id = 0;
|
||||
if ((unsigned int) new_id >= vobsub_get_indexes_count(vo_vobsub))
|
||||
new_id = -1;
|
||||
if(new_id != vobsub_id)
|
||||
osd_show_vobsub_changed = 9;
|
||||
vobsub_id = new_id;
|
||||
}
|
||||
break;
|
||||
case MP_CMD_SUB_SELECT:
|
||||
#ifdef USE_SUB
|
||||
if (set_of_sub_size > 0){ //change subtitle file
|
||||
@@ -3138,6 +3125,41 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still)
|
||||
vo_osd_changed(OSDTYPE_SUBTITLE);
|
||||
}
|
||||
#endif
|
||||
if (vo_vobsub)
|
||||
{
|
||||
int new_id = vobsub_id + 1;
|
||||
if (vobsub_id < 0)
|
||||
new_id = 0;
|
||||
if ((unsigned int) new_id >= vobsub_get_indexes_count(vo_vobsub))
|
||||
new_id = -1;
|
||||
if(new_id != vobsub_id)
|
||||
osd_show_vobsub_changed = sh_video->fps;
|
||||
vobsub_id = new_id;
|
||||
}
|
||||
if (vo_spudec && stream->type == STREAMTYPE_DVD)
|
||||
{
|
||||
int new_id = dvdsub_id + 1;
|
||||
if (dvdsub_id < 0)
|
||||
new_id = 0;
|
||||
if ((unsigned int) new_id >= dvd_number_of_subs(stream))
|
||||
new_id = -1;
|
||||
if(new_id != dvdsub_id)
|
||||
osd_show_vobsub_changed = sh_video->fps;
|
||||
d_dvdsub->id = dvdsub_id = new_id;
|
||||
spudec_reset(vo_spudec);
|
||||
}
|
||||
if (d_dvdsub && demuxer->type == DEMUXER_TYPE_OGG)
|
||||
{
|
||||
int new_id = dvdsub_id + 1;
|
||||
if (dvdsub_id < 0)
|
||||
new_id = 0;
|
||||
if ((unsigned int) new_id >= demux_ogg_num_subs())
|
||||
new_id = -1;
|
||||
if (new_id != dvdsub_id)
|
||||
osd_show_vobsub_changed = sh_video->fps;
|
||||
dvdsub_id = new_id;
|
||||
d_dvdsub->id = demux_ogg_sub_id(new_id);
|
||||
}
|
||||
break;
|
||||
case MP_CMD_SUB_FORCED_ONLY:
|
||||
if (vo_spudec) {
|
||||
@@ -3560,10 +3582,28 @@ if(rel_seek_secs || abs_seek_pos){
|
||||
osd_show_sub_visibility--;
|
||||
} else
|
||||
if (osd_show_vobsub_changed) {
|
||||
const char *language = "none";
|
||||
if (vo_vobsub && vobsub_id >= 0)
|
||||
if (vo_vobsub && vobsub_id >= 0) {
|
||||
const char *language = "none";
|
||||
language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id);
|
||||
snprintf(osd_text_tmp, 63, "Subtitles: (%d) %s", vobsub_id, language ? language : "unknown");
|
||||
}
|
||||
if (d_dvdsub && demuxer->type == DEMUXER_TYPE_OGG) {
|
||||
if (dvdsub_id < 0)
|
||||
snprintf(osd_text_tmp, 63, "Subtitles: (off)");
|
||||
else
|
||||
snprintf(osd_text_tmp, 63, "Subtitles: (%d)", dvdsub_id);
|
||||
}
|
||||
if (vo_spudec) {
|
||||
char lang[5] = "none";
|
||||
int code = 0;
|
||||
if (dvdsub_id >= 0) code = dvd_lang_from_sid(stream, dvdsub_id);
|
||||
if (code) {
|
||||
lang[0] = code >> 8;
|
||||
lang[1] = code;
|
||||
lang[2] = 0;
|
||||
}
|
||||
snprintf(osd_text_tmp, 63, "Subtitles: (%d) %s", dvdsub_id, lang);
|
||||
}
|
||||
osd_show_vobsub_changed--;
|
||||
} else
|
||||
#ifdef USE_SUB
|
||||
|
||||
Reference in New Issue
Block a user