diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2009-11-11 11:19:50 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2009-11-11 11:19:50 +0000 |
commit | d1e5bdf365db1a480bcbaccddcd79912c4eae998 (patch) | |
tree | b0f13304027e061e6d88d23de99d4d0ca33ecb5f | |
parent | 05721f9672916da34d73693490842f5fe078535b (diff) | |
download | mpv-d1e5bdf365db1a480bcbaccddcd79912c4eae998.tar.bz2 mpv-d1e5bdf365db1a480bcbaccddcd79912c4eae998.tar.xz |
Factor out code that decides which subtitle to play.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29896 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | mplayer.c | 52 |
1 files changed, 28 insertions, 24 deletions
@@ -1835,6 +1835,33 @@ static float timing_sleep(float time_frame) return time_frame; } +static void select_subtitle(MPContext *mpctx) { + // find the best sub to use + int vobsub_index_id = vobsub_get_index_by_id(vo_vobsub, vobsub_id); + mpctx->global_sub_pos = -1; // no subs by default + 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) { + // if user asks for a dvd sub id, use that next. + mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_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]; + } else if (dvdsub_id == -1 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) { + // finally select subs by language and container hints + if (dvdsub_id == -1 && dvdsub_lang) + dvdsub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang); + if (dvdsub_id == -1) + dvdsub_id = demuxer_default_sub_track(mpctx->demuxer); + if (dvdsub_id >= 0) + mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id; + } + // rather than duplicate code, use the SUB_SELECT handler to init the right one. + mpctx->global_sub_pos--; + mp_property_do("sub",M_PROPERTY_STEP_UP,NULL, mpctx); +} + #ifdef CONFIG_DVDNAV #ifndef FF_B_TYPE #define FF_B_TYPE 3 @@ -3475,30 +3502,7 @@ if(1 || 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); - mpctx->global_sub_pos = -1; // no subs by default - 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) { - // if user asks for a dvd sub id, use that next. - mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_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]; - } else if (dvdsub_id == -1 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) { - // finally select subs by language and container hints - if (dvdsub_id == -1 && dvdsub_lang) - dvdsub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang); - if (dvdsub_id == -1) - dvdsub_id = demuxer_default_sub_track(mpctx->demuxer); - if (dvdsub_id >= 0) - mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id; - } - // rather than duplicate code, use the SUB_SELECT handler to init the right one. - mpctx->global_sub_pos--; - mp_property_do("sub",M_PROPERTY_STEP_UP,NULL, mpctx); + select_subtitle(mpctx); if(subdata) switch (stream_dump_type) { case 3: list_sub_file(subdata); break; |