summaryrefslogtreecommitdiffstats
path: root/mpcommon.c
diff options
context:
space:
mode:
Diffstat (limited to 'mpcommon.c')
-rw-r--r--mpcommon.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/mpcommon.c b/mpcommon.c
index bdc307baeb..a816e32b3d 100644
--- a/mpcommon.c
+++ b/mpcommon.c
@@ -17,6 +17,8 @@
*/
#include <stdlib.h>
+#include "mpcommon.h"
+#include "options.h"
#include "stream/stream.h"
#include "libmpdemux/demuxer.h"
#include "libmpdemux/stheader.h"
@@ -30,15 +32,14 @@
#include "version.h"
#include "vobsub.h"
#include "libmpcodecs/dec_teletext.h"
-#include "libavutil/intreadwrite.h"
+#include "ffmpeg_files/intreadwrite.h"
#include "m_option.h"
-#include "mpcommon.h"
double sub_last_pts = -303;
#ifdef CONFIG_ASS
-#include "libass/ass_mp.h"
-ass_track_t* ass_track = 0; // current track to render
+#include "ass_mp.h"
+ASS_Track *ass_track = 0; // current track to render
#endif
sub_data* subdata = NULL;
@@ -58,9 +59,9 @@ void print_version(const char* name)
gCpuCaps.has3DNow, gCpuCaps.has3DNowExt,
gCpuCaps.hasSSE, gCpuCaps.hasSSE2, gCpuCaps.hasSSSE3);
#if CONFIG_RUNTIME_CPUDETECT
- mp_msg(MSGT_CPLAYER,MSGL_V, MSGTR_CompiledWithRuntimeDetection);
+ mp_tmsg(MSGT_CPLAYER,MSGL_V, "Compiled with runtime CPU detection.\n");
#else
- mp_msg(MSGT_CPLAYER,MSGL_V, MSGTR_CompiledWithCPUExtensions);
+ mp_tmsg(MSGT_CPLAYER,MSGL_V, "Compiled for x86 CPU with extensions:");
if (HAVE_MMX)
mp_msg(MSGT_CPLAYER,MSGL_V," MMX");
if (HAVE_MMX2)
@@ -83,7 +84,9 @@ if (HAVE_CMOV)
}
-void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvdsub, int reset)
+void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts,
+ sh_video_t *sh_video, double refpts, double sub_offset,
+ demux_stream_t *d_dvdsub, int reset)
{
unsigned char *packet=NULL;
int len;
@@ -92,19 +95,20 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd
if (reset) {
sub_clear_text(&subs, MP_NOPTS_VALUE);
if (vo_sub) {
- set_osd_subtitle(NULL);
+ set_osd_subtitle(mpctx, NULL);
}
if (vo_spudec) {
spudec_reset(vo_spudec);
vo_osd_changed(OSDTYPE_SPU);
}
+ return;
}
// find sub
if (subdata) {
if (sub_fps==0) sub_fps = sh_video ? sh_video->fps : 25;
current_module = "find_sub";
if (refpts > sub_last_pts || refpts < sub_last_pts-1.0) {
- find_sub(subdata, (refpts+sub_delay) *
+ find_sub(mpctx, subdata, (refpts+sub_delay) *
(subdata->sub_uses_time ? 100. : sub_fps));
if (vo_sub) vo_sub_last = vo_sub;
// FIXME! frame counter...
@@ -113,8 +117,7 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd
}
// DVD sub:
- if (vo_config_count && vo_spudec &&
- (vobsub_id >= 0 || (dvdsub_id >= 0 && type == 'v'))) {
+ if (vo_spudec && (vobsub_id >= 0 || (opts->sub_id >= 0 && type == 'v'))) {
int timestamp;
current_module = "spudec";
spudec_heartbeat(vo_spudec, 90000*sh_video->timer);
@@ -158,7 +161,8 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd
if (spudec_changed(vo_spudec))
vo_osd_changed(OSDTYPE_SPU);
- } else if (dvdsub_id >= 0 && (type == 't' || type == 'm' || type == 'a' || type == 'd')) {
+ } else if (opts->sub_id >= 0
+ && (type == 't' || type == 'm' || type == 'a' || type == 'd')) {
double curpts = refpts + sub_delay;
double endpts;
if (type == 'd' && !d_dvdsub->demuxer->teletext) {
@@ -170,10 +174,16 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd
if (d_dvdsub->non_interleaved)
ds_get_next_pts(d_dvdsub);
while (d_dvdsub->first) {
- double subpts = ds_get_next_pts(d_dvdsub);
- if (subpts > curpts)
- break;
- endpts = d_dvdsub->first->endpts;
+ double subpts = ds_get_next_pts(d_dvdsub) + sub_offset;
+ if (subpts > curpts) {
+ // Libass handled subs can be fed to it in advance
+ if (!opts->ass_enabled || type == 'd')
+ break;
+ // Try to avoid demuxing whole file at once
+ if (d_dvdsub->non_interleaved && subpts > curpts + 1)
+ break;
+ }
+ endpts = d_dvdsub->first->endpts + sub_offset;
len = ds_get_packet_sub(d_dvdsub, &packet);
if (type == 'm') {
if (len < 2) continue;
@@ -197,7 +207,7 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd
continue;
}
#ifdef CONFIG_ASS
- if (ass_enabled) {
+ if (opts->ass_enabled) {
sh_sub_t* sh = d_dvdsub->sh;
ass_track = sh ? sh->ass_track : NULL;
if (!ass_track) continue;
@@ -234,13 +244,14 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd
packet = p;
}
sub_add_text(&subs, packet, len, endpts);
- set_osd_subtitle(&subs);
+ set_osd_subtitle(mpctx, &subs);
}
if (d_dvdsub->non_interleaved)
ds_get_next_pts(d_dvdsub);
}
- if (sub_clear_text(&subs, curpts))
- set_osd_subtitle(&subs);
+ if (!opts->ass_enabled)
+ if (sub_clear_text(&subs, curpts))
+ set_osd_subtitle(mpctx, &subs);
}
current_module=NULL;
}
@@ -290,26 +301,17 @@ int select_audio(demuxer_t* demuxer, int audio_id, char* audio_lang)
/* Parse -noconfig common to both programs */
int disable_system_conf=0;
int disable_user_conf=0;
-#ifdef CONFIG_GUI
-int disable_gui_conf=0;
-#endif /* CONFIG_GUI */
/* Disable all configuration files */
static void noconfig_all(void)
{
disable_system_conf = 1;
disable_user_conf = 1;
-#ifdef CONFIG_GUI
- disable_gui_conf = 1;
-#endif /* CONFIG_GUI */
}
const m_option_t noconfig_opts[] = {
{"all", noconfig_all, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 0, NULL},
{"system", &disable_system_conf, CONF_TYPE_FLAG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 1, NULL},
{"user", &disable_user_conf, CONF_TYPE_FLAG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 1, NULL},
-#ifdef CONFIG_GUI
- {"gui", &disable_gui_conf, CONF_TYPE_FLAG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 1, NULL},
-#endif /* CONFIG_GUI */
{NULL, NULL, 0, 0, 0, 0, NULL}
};