Generalize subtitle switching, demux_ogg does not need a special case

anymore and demux_mov works now, too.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21054 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2006-11-19 14:23:54 +00:00
parent 0b062aa447
commit b38e1ca6e7
4 changed files with 21 additions and 46 deletions

View File

@ -3864,26 +3864,6 @@ demux_mkv_control (demuxer_t *demuxer, int cmd, void *arg)
}
}
/** \brief Return the number of subtitle tracks in the file.
\param demuxer The demuxer for which the number of subtitle tracks
should be returned.
*/
int
demux_mkv_num_subs (demuxer_t *demuxer)
{
mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
int i, num;
num = 0;
for (i = 0; i < mkv_d->num_tracks; i++)
if ((mkv_d->tracks[i]->type == MATROSKA_TRACK_SUBTITLE) &&
(mkv_d->tracks[i]->subtitle_type != MATROSKA_SUBTYPE_UNKNOWN))
num++;
return num;
}
/** \brief Change the current subtitle track and return its ID.
Changes the current subtitle track. If the new subtitle track is a

View File

@ -488,7 +488,7 @@ static void demux_ogg_check_comments(demuxer_t *d, ogg_stream_t *os, int id, vor
// check for -slang if subs are uninitialized yet
if (os->text && d->sub->id < 0 && demux_ogg_check_lang(val, dvdsub_lang))
{
d->sub->id = id;
d->sub->id = index;
dvdsub_id = index;
mp_msg(MSGT_DEMUX, MSGL_V, "Ogg demuxer: Displaying subtitle stream id %d which matched -slang %s\n", id, val);
}
@ -538,7 +538,7 @@ static int demux_ogg_add_packet(demux_stream_t* ds,ogg_stream_t* os,int id,ogg_p
vorbis_info_clear(&vi);
}
if (os->text) {
if (id == d->sub->id) // don't want to add subtitles to the demuxer for now
if (id == demux_ogg_sub_id(d->sub->id)) // don't want to add subtitles to the demuxer for now
demux_ogg_add_sub(os,pack);
return 0;
}
@ -718,16 +718,6 @@ extern void print_video_header(BITMAPINFOHEADER *h, int verbose_level);
/* defined in demux_mov.c */
extern unsigned int store_ughvlc(unsigned char *s, unsigned int v);
/** \brief Return the number of subtitle tracks in the file.
\param demuxer The demuxer for which the number of subtitle tracks
should be returned.
*/
int demux_ogg_num_subs(demuxer_t *demuxer) {
ogg_demuxer_t *ogg_d = (ogg_demuxer_t *)demuxer->priv;
return ogg_d->n_text;
}
/** \brief Change the current subtitle stream and return its ID.
\param demuxer The demuxer whose subtitle stream will be changed.

View File

@ -61,7 +61,6 @@
#define MKV_S_SSA "S_SSA" // Deprecated
#define MKV_S_ASS "S_ASS" // Deprecated
int demux_mkv_num_subs(demuxer_t *demuxer);
int demux_mkv_change_subs(demuxer_t *demuxer, int new_num);
void demux_mkv_get_audio_lang(demuxer_t *demuxer, int track_num, char *lang,
int maxlen);

View File

@ -2246,6 +2246,10 @@ static int mp_property_sub(m_option_t* prop,int action,void* arg) {
return M_PROPERTY_OK;
}
#endif
if (dvdsub_id >= 0) {
snprintf(*(char**)arg, 63, "(%d) %s", dvdsub_id, MSGTR_Unknown);
return M_PROPERTY_OK;
}
snprintf(*(char**)arg, 63, MSGTR_Disabled);
return M_PROPERTY_OK;
@ -2316,10 +2320,16 @@ static int mp_property_sub(m_option_t* prop,int action,void* arg) {
spudec_reset(vo_spudec);
}
#endif
#ifdef HAVE_OGGVORBIS
if (demuxer->type == DEMUXER_TYPE_OGG)
d_dvdsub->id = demux_ogg_sub_id(demuxer, dvdsub_id);
#endif
if (stream->type != STREAMTYPE_DVD) {
int i = 0;
for (d_dvdsub->id = 0; d_dvdsub->id < MAX_S_STREAMS; d_dvdsub->id++) {
if (demuxer->s_streams[d_dvdsub->id]) {
if (i == dvdsub_id) break;
i++;
}
}
d_dvdsub->sh = demuxer->s_streams[d_dvdsub->id];
}
if (demuxer->type == DEMUXER_TYPE_MATROSKA) {
d_dvdsub->id = demux_mkv_change_subs(demuxer, dvdsub_id);
#ifdef USE_ASS
@ -4043,18 +4053,14 @@ if(!demuxer)
}
inited_flags|=INITED_DEMUXER;
if (demuxer->type==DEMUXER_TYPE_MATROSKA) {
if (stream->type != STREAMTYPE_DVD) {
int i;
// setup global sub numbering
global_sub_indices[SUB_SOURCE_DEMUX] = global_sub_size; // the global # of the first demux-specific sub.
global_sub_size += demux_mkv_num_subs(demuxer);
for (i = 0; i < MAX_S_STREAMS; i++)
if (demuxer->s_streams[i])
global_sub_size++;
}
#ifdef HAVE_OGGVORBIS
if (demuxer->type==DEMUXER_TYPE_OGG) {
// setup global sub numbering
global_sub_indices[SUB_SOURCE_DEMUX] = global_sub_size; // the global # of the first demux-specific sub.
global_sub_size += demux_ogg_num_subs(demuxer);
}
#endif
current_module="demux_open2";