# HG changeset patch # User reimar # Date 1163946234 0 # Node ID bfd340cdac88900e82ba3cc21d42e4c4746afa49 # Parent a7ffbe50d77ae71d3ae603f1a25cb932e24877b2 Generalize subtitle switching, demux_ogg does not need a special case anymore and demux_mov works now, too. diff -r a7ffbe50d77a -r bfd340cdac88 libmpdemux/demux_mkv.c --- a/libmpdemux/demux_mkv.c Sun Nov 19 14:18:45 2006 +0000 +++ b/libmpdemux/demux_mkv.c Sun Nov 19 14:23:54 2006 +0000 @@ -3864,26 +3864,6 @@ } } -/** \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 diff -r a7ffbe50d77a -r bfd340cdac88 libmpdemux/demux_ogg.c --- a/libmpdemux/demux_ogg.c Sun Nov 19 14:18:45 2006 +0000 +++ b/libmpdemux/demux_ogg.c Sun Nov 19 14:23:54 2006 +0000 @@ -488,7 +488,7 @@ // 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 @@ 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 @@ /* 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. diff -r a7ffbe50d77a -r bfd340cdac88 libmpdemux/matroska.h --- a/libmpdemux/matroska.h Sun Nov 19 14:18:45 2006 +0000 +++ b/libmpdemux/matroska.h Sun Nov 19 14:23:54 2006 +0000 @@ -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); diff -r a7ffbe50d77a -r bfd340cdac88 mplayer.c --- a/mplayer.c Sun Nov 19 14:18:45 2006 +0000 +++ b/mplayer.c Sun Nov 19 14:23:54 2006 +0000 @@ -2246,6 +2246,10 @@ 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 @@ 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 @@ } 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";