1
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 06:03:45 +01:00

core: move global "subdata" and "vo_sub_last" to mpctx

This commit is contained in:
Uoti Urpala 2011-01-11 17:48:45 +02:00
parent f95674fb6c
commit a1692437d0
6 changed files with 27 additions and 26 deletions

View File

@ -193,15 +193,16 @@ static void log_sub(struct MPContext *mpctx)
char *fname; char *fname;
FILE *f; FILE *f;
int i; int i;
struct subtitle *vo_sub_last = mpctx->vo_sub_last;
if (subdata == NULL || vo_sub_last == NULL) if (mpctx->subdata == NULL || vo_sub_last == NULL)
return; return;
fname = get_path("subtitle_log"); fname = get_path("subtitle_log");
f = fopen(fname, "a"); f = fopen(fname, "a");
if (!f) if (!f)
return; return;
fprintf(f, "----------------------------------------------------------\n"); fprintf(f, "----------------------------------------------------------\n");
if (subdata->sub_uses_time) { if (mpctx->subdata->sub_uses_time) {
fprintf(f, fprintf(f,
"N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n", "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
mpctx->filename, vo_sub_last->start / 360000, mpctx->filename, vo_sub_last->start / 360000,
@ -1542,8 +1543,8 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg,
*(char **) arg = malloc(64); *(char **) arg = malloc(64);
(*(char **) arg)[63] = 0; (*(char **) arg)[63] = 0;
sub_name = 0; sub_name = 0;
if (subdata) if (mpctx->subdata)
sub_name = subdata->filename; sub_name = mpctx->subdata->filename;
#ifdef CONFIG_ASS #ifdef CONFIG_ASS
if (ass_track && ass_track->name) if (ass_track && ass_track->name)
sub_name = ass_track->name; sub_name = ass_track->name;
@ -1644,7 +1645,7 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg,
mpctx->global_sub_pos, source); mpctx->global_sub_pos, source);
mpctx->set_of_sub_pos = -1; mpctx->set_of_sub_pos = -1;
subdata = NULL; mpctx->subdata = NULL;
vobsub_id = -1; vobsub_id = -1;
opts->sub_id = -1; opts->sub_id = -1;
@ -1667,7 +1668,7 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg,
else else
#endif #endif
{ {
subdata = mpctx->set_of_subtitles[mpctx->set_of_sub_pos]; mpctx->subdata = mpctx->set_of_subtitles[mpctx->set_of_sub_pos];
vo_osd_changed(OSDTYPE_SUBTITLE); vo_osd_changed(OSDTYPE_SUBTITLE);
} }
} else if (source == SUB_SOURCE_DEMUX) { } else if (source == SUB_SOURCE_DEMUX) {
@ -2692,7 +2693,7 @@ static void remove_subtitle_range(MPContext *mpctx, int start, int count)
if (mpctx->set_of_sub_pos >= start && mpctx->set_of_sub_pos < end) { if (mpctx->set_of_sub_pos >= start && mpctx->set_of_sub_pos < end) {
mpctx->global_sub_pos = -2; mpctx->global_sub_pos = -2;
subdata = NULL; mpctx->subdata = NULL;
#ifdef CONFIG_ASS #ifdef CONFIG_ASS
ass_track = NULL; ass_track = NULL;
#endif #endif
@ -2931,7 +2932,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_SUB_STEP: case MP_CMD_SUB_STEP:
if (sh_video) { if (sh_video) {
int movement = cmd->args[0].v.i; int movement = cmd->args[0].v.i;
step_sub(subdata, mpctx->video_pts, movement); step_sub(mpctx->subdata, mpctx->video_pts, movement);
#ifdef CONFIG_ASS #ifdef CONFIG_ASS
if (ass_track) if (ass_track)
sub_delay += sub_delay +=

View File

@ -73,7 +73,6 @@ struct osd_state {
#include "subreader.h" #include "subreader.h"
extern sub_data* subdata; //currently used subtitles
extern subtitle* vo_sub; extern subtitle* vo_sub;
extern void* vo_osd_teletext_page; extern void* vo_osd_teletext_page;

View File

@ -88,6 +88,9 @@ typedef struct MPContext {
struct mp_fifo *key_fifo; struct mp_fifo *key_fifo;
struct input_ctx *input; struct input_ctx *input;
struct osd_state *osd; struct osd_state *osd;
struct sub_data *subdata; // current sub_data style subtitles if any
// last sub_data style sub line if any, used by log_sub() only
struct subtitle *vo_sub_last;
bool add_osd_seek_info; bool add_osd_seek_info;
// if nonzero, hide current OSD contents when GetTimerMS() reaches this // if nonzero, hide current OSD contents when GetTimerMS() reaches this

View File

@ -39,15 +39,13 @@
#include "libmpcodecs/dec_teletext.h" #include "libmpcodecs/dec_teletext.h"
#include "ffmpeg_files/intreadwrite.h" #include "ffmpeg_files/intreadwrite.h"
#include "m_option.h" #include "m_option.h"
#include "mp_core.h"
#ifdef CONFIG_ASS #ifdef CONFIG_ASS
#include "ass_mp.h" #include "ass_mp.h"
ASS_Track *ass_track = 0; // current track to render ASS_Track *ass_track = 0; // current track to render
#endif #endif
sub_data* subdata = NULL;
subtitle* vo_sub_last = NULL;
const char *mencoder_version = "MEncoder " VERSION; const char *mencoder_version = "MEncoder " VERSION;
const char *mplayer_version = "MPlayer " VERSION; const char *mplayer_version = "MPlayer " VERSION;
@ -123,12 +121,13 @@ void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts,
return; return;
} }
// find sub // find sub
if (subdata) { if (mpctx->subdata) {
if (sub_fps==0) sub_fps = sh_video ? sh_video->fps : 25; if (sub_fps==0) sub_fps = sh_video ? sh_video->fps : 25;
current_module = "find_sub"; current_module = "find_sub";
find_sub(mpctx, subdata, curpts * find_sub(mpctx, mpctx->subdata, curpts *
(subdata->sub_uses_time ? 100. : sub_fps)); (mpctx->subdata->sub_uses_time ? 100. : sub_fps));
if (vo_sub) vo_sub_last = vo_sub; if (vo_sub)
mpctx->vo_sub_last = vo_sub;
} }
// DVD sub: // DVD sub:

View File

@ -24,7 +24,6 @@
struct subtitle; struct subtitle;
extern struct ass_track *ass_track; extern struct ass_track *ass_track;
extern struct subtitle *vo_sub_last;
extern const char *mencoder_version; extern const char *mencoder_version;
extern const char *mplayer_version; extern const char *mplayer_version;

View File

@ -4415,14 +4415,14 @@ if(vo_spudec==NULL &&
mpctx->sub_counts[SUB_SOURCE_SUBS] = mpctx->set_of_sub_size; mpctx->sub_counts[SUB_SOURCE_SUBS] = mpctx->set_of_sub_size;
if (select_subtitle(mpctx)) { if (select_subtitle(mpctx)) {
if(subdata) if(mpctx->subdata)
switch (stream_dump_type) { switch (stream_dump_type) {
case 3: list_sub_file(subdata); break; case 3: list_sub_file(mpctx->subdata); break;
case 4: dump_mpsub(subdata, mpctx->sh_video->fps); break; case 4: dump_mpsub(mpctx->subdata, mpctx->sh_video->fps); break;
case 6: dump_srt(subdata, mpctx->sh_video->fps); break; case 6: dump_srt(mpctx->subdata, mpctx->sh_video->fps); break;
case 7: dump_microdvd(subdata, mpctx->sh_video->fps); break; case 7: dump_microdvd(mpctx->subdata, mpctx->sh_video->fps); break;
case 8: dump_jacosub(subdata, mpctx->sh_video->fps); break; case 8: dump_jacosub(mpctx->subdata, mpctx->sh_video->fps); break;
case 9: dump_sami(subdata, mpctx->sh_video->fps); break; case 9: dump_sami(mpctx->subdata, mpctx->sh_video->fps); break;
} }
} }
@ -4645,8 +4645,8 @@ if(mpctx->set_of_sub_size > 0) {
} }
mpctx->set_of_sub_size = 0; mpctx->set_of_sub_size = 0;
} }
vo_sub_last = vo_sub=NULL; mpctx->vo_sub_last = vo_sub=NULL;
subdata=NULL; mpctx->subdata=NULL;
#ifdef CONFIG_ASS #ifdef CONFIG_ASS
ass_track = NULL; ass_track = NULL;
if(ass_library) if(ass_library)