comparison mplayer.c @ 29854:00ebdb6cb87f

Factor out code that decides which subtitle to play.
author reimar
date Wed, 11 Nov 2009 11:19:50 +0000
parents edecbb61e41f
children 5e279f7d7e5d
comparison
equal deleted inserted replaced
29853:415169f556ed 29854:00ebdb6cb87f
1831 while (time_frame > 0) 1831 while (time_frame > 0)
1832 time_frame-=GetRelativeTime(); // burn the CPU 1832 time_frame-=GetRelativeTime(); // burn the CPU
1833 } 1833 }
1834 } 1834 }
1835 return time_frame; 1835 return time_frame;
1836 }
1837
1838 static void select_subtitle(MPContext *mpctx) {
1839 // find the best sub to use
1840 int vobsub_index_id = vobsub_get_index_by_id(vo_vobsub, vobsub_id);
1841 mpctx->global_sub_pos = -1; // no subs by default
1842 if (vobsub_index_id >= 0) {
1843 // if user asks for a vobsub id, use that first.
1844 mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_VOBSUB] + vobsub_index_id;
1845 } else if (dvdsub_id >= 0 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
1846 // if user asks for a dvd sub id, use that next.
1847 mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id;
1848 } else if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] >= 0) {
1849 // if there are text subs to use, use those. (autosubs come last here)
1850 mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_SUBS];
1851 } else if (dvdsub_id == -1 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
1852 // finally select subs by language and container hints
1853 if (dvdsub_id == -1 && dvdsub_lang)
1854 dvdsub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang);
1855 if (dvdsub_id == -1)
1856 dvdsub_id = demuxer_default_sub_track(mpctx->demuxer);
1857 if (dvdsub_id >= 0)
1858 mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id;
1859 }
1860 // rather than duplicate code, use the SUB_SELECT handler to init the right one.
1861 mpctx->global_sub_pos--;
1862 mp_property_do("sub",M_PROPERTY_STEP_UP,NULL, mpctx);
1836 } 1863 }
1837 1864
1838 #ifdef CONFIG_DVDNAV 1865 #ifdef CONFIG_DVDNAV
1839 #ifndef FF_B_TYPE 1866 #ifndef FF_B_TYPE
1840 #define FF_B_TYPE 3 1867 #define FF_B_TYPE 3
3473 mpctx->global_sub_size += mpctx->set_of_sub_size; 3500 mpctx->global_sub_size += mpctx->set_of_sub_size;
3474 } 3501 }
3475 } 3502 }
3476 3503
3477 if (mpctx->global_sub_size) { 3504 if (mpctx->global_sub_size) {
3478 // find the best sub to use 3505 select_subtitle(mpctx);
3479 int vobsub_index_id = vobsub_get_index_by_id(vo_vobsub, vobsub_id);
3480 mpctx->global_sub_pos = -1; // no subs by default
3481 if (vobsub_index_id >= 0) {
3482 // if user asks for a vobsub id, use that first.
3483 mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_VOBSUB] + vobsub_index_id;
3484 } else if (dvdsub_id >= 0 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
3485 // if user asks for a dvd sub id, use that next.
3486 mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id;
3487 } else if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] >= 0) {
3488 // if there are text subs to use, use those. (autosubs come last here)
3489 mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_SUBS];
3490 } else if (dvdsub_id == -1 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
3491 // finally select subs by language and container hints
3492 if (dvdsub_id == -1 && dvdsub_lang)
3493 dvdsub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang);
3494 if (dvdsub_id == -1)
3495 dvdsub_id = demuxer_default_sub_track(mpctx->demuxer);
3496 if (dvdsub_id >= 0)
3497 mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id;
3498 }
3499 // rather than duplicate code, use the SUB_SELECT handler to init the right one.
3500 mpctx->global_sub_pos--;
3501 mp_property_do("sub",M_PROPERTY_STEP_UP,NULL, mpctx);
3502 if(subdata) 3506 if(subdata)
3503 switch (stream_dump_type) { 3507 switch (stream_dump_type) {
3504 case 3: list_sub_file(subdata); break; 3508 case 3: list_sub_file(subdata); break;
3505 case 4: dump_mpsub(subdata, mpctx->sh_video->fps); break; 3509 case 4: dump_mpsub(subdata, mpctx->sh_video->fps); break;
3506 case 6: dump_srt(subdata, mpctx->sh_video->fps); break; 3510 case 6: dump_srt(subdata, mpctx->sh_video->fps); break;