Skip to content

Commit

Permalink
Move init_vo_spudec to mp_common.c and reuse it in mencoder.
Browse files Browse the repository at this point in the history
Fixes bug #1932.


git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@33665 b3059339-0415-0410-9bf9-f77b7e298cf2
  • Loading branch information
reimar committed Jun 19, 2011
1 parent dd4b787 commit c581d7a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 70 deletions.
2 changes: 1 addition & 1 deletion command.c
Expand Up @@ -1624,7 +1624,7 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg,
if (d_sub->sh && d_sub->id >= 0) {
sh_sub_t *sh = d_sub->sh;
if (sh->type == 'v')
init_vo_spudec();
init_vo_spudec(mpctx->stream, mpctx->sh_video, sh);
#ifdef CONFIG_ASS
else if (ass_enabled)
ass_track = sh->ass_track;
Expand Down
16 changes: 1 addition & 15 deletions mencoder.c
Expand Up @@ -103,7 +103,6 @@
int vo_doublebuffering=0;
int vo_directrendering=0;
int vo_config_count=1;
int forced_subs_only=0;

//--------------------------

Expand All @@ -120,7 +119,6 @@ int dvdsub_id=-1;
int vobsub_id=-1;
char* audio_lang=NULL;
char* dvdsub_lang=NULL;
static char* spudec_ifo=NULL;

static char** audio_codec_list=NULL; // override audio codec
static char** video_codec_list=NULL; // override video codec
Expand Down Expand Up @@ -809,19 +807,7 @@ if (vobsub_out) {
#endif
}
else {
if (spudec_ifo) {
unsigned int palette[16], width, height;
if (vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, -1, NULL) >= 0)
vo_spudec=spudec_new_scaled(palette, sh_video->disp_w, sh_video->disp_h, NULL, 0);
}
#ifdef CONFIG_DVDREAD
if (vo_spudec==NULL) {
vo_spudec=spudec_new_scaled(stream->type==STREAMTYPE_DVD?((dvd_priv_t *)(stream->priv))->cur_pgc->palette:NULL,
sh_video->disp_w, sh_video->disp_h, NULL, 0);
}
#endif
if (vo_spudec)
spudec_set_forced_subs_only(vo_spudec, forced_subs_only);
init_vo_spudec(stream, sh_video, d_dvdsub ? d_dvdsub->sh : NULL);
}

ostream = open_output_stream(out_filename, 0);
Expand Down
2 changes: 0 additions & 2 deletions mp_core.h
Expand Up @@ -148,12 +148,10 @@ extern int file_filter;
// These appear in options list
extern float playback_speed;
extern int fixed_vo;
extern int forced_subs_only;


void uninit_player(unsigned int mask);
void reinit_audio_chain(void);
void init_vo_spudec(void);
double playing_audio_pts(sh_audio_t *sh_audio, demux_stream_t *d_audio,
const ao_functions_t *audio_out);
void exit_player(enum exit_reason how);
Expand Down
53 changes: 53 additions & 0 deletions mpcommon.c
Expand Up @@ -21,6 +21,8 @@
#endif
#include <stdlib.h>
#include "stream/stream.h"
#include "stream/stream_dvd.h"
#include "stream/stream_dvdnav.h"
#include "libmpdemux/demuxer.h"
#include "libmpdemux/stheader.h"
#include "codec-cfg.h"
Expand Down Expand Up @@ -52,6 +54,8 @@ ASS_Track* ass_track = 0; // current track to render

sub_data* subdata = NULL;
subtitle* vo_sub_last = NULL;
char *spudec_ifo;
int forced_subs_only;

const char *mencoder_version = "MEncoder " VERSION;
const char *mplayer_version = "MPlayer " VERSION;
Expand Down Expand Up @@ -93,6 +97,55 @@ if (HAVE_CMOV)
#endif /* ARCH_X86 */
}

void init_vo_spudec(struct stream *stream, struct sh_video *sh_video, struct sh_sub *sh_sub)
{
unsigned width, height;
spudec_free(vo_spudec);
vo_spudec = NULL;

// we currently can't work without video stream
if (!sh_video)
return;

if (spudec_ifo) {
unsigned int palette[16];
current_module = "spudec_init_vobsub";
if (vobsub_parse_ifo(NULL, spudec_ifo, palette, &width, &height, 1, -1, NULL) >= 0)
vo_spudec = spudec_new_scaled(palette, width, height, NULL, 0);
}

width = sh_video->disp_w;
height = sh_video->disp_h;

#ifdef CONFIG_DVDREAD
if (vo_spudec == NULL && stream->type == STREAMTYPE_DVD) {
current_module = "spudec_init_dvdread";
vo_spudec = spudec_new_scaled(((dvd_priv_t *)(stream->priv))->cur_pgc->palette,
width, height,
NULL, 0);
}
#endif

#ifdef CONFIG_DVDNAV
if (vo_spudec == NULL && stream->type == STREAMTYPE_DVDNAV) {
unsigned int *palette = mp_dvdnav_get_spu_clut(stream);
current_module = "spudec_init_dvdnav";
vo_spudec = spudec_new_scaled(palette, width, height, NULL, 0);
}
#endif

if (vo_spudec == NULL) {
current_module = "spudec_init_normal";
vo_spudec = spudec_new_scaled(NULL, width, height,
sh_sub ? sh_sub->extradata : NULL,
sh_sub ? sh_sub->extradata_len : 0);
spudec_set_font_factor(vo_spudec, font_factor);
}

if (vo_spudec)
spudec_set_forced_subs_only(vo_spudec, forced_subs_only);
}

static int is_text_sub(int type)
{
return type == 't' || type == 'm' || type == 'a';
Expand Down
5 changes: 5 additions & 0 deletions mpcommon.h
Expand Up @@ -27,12 +27,16 @@

#define ROUND(x) ((int)((x) < 0 ? (x) - 0.5 : (x) + 0.5))

struct stream;
struct sh_audio;
struct sh_video;
struct sh_sub;

extern double sub_last_pts;
extern ASS_Track *ass_track;
extern subtitle *vo_sub_last;
extern char *spudec_ifo;
extern int forced_subs_only;

extern int sub_auto;
extern float sub_delay;
Expand Down Expand Up @@ -67,6 +71,7 @@ extern m_config_t *mconfig;
extern const m_option_t noconfig_opts[];

void print_version(const char* name);
void init_vo_spudec(struct stream *stream, struct sh_video *sh_video, struct sh_sub *sh_sub);
void update_subtitles(struct sh_video *sh_video, double refpts, demux_stream_t *d_dvdsub, int reset);
void update_teletext(struct sh_video *sh_video, demuxer_t *demuxer, int reset);
int select_audio(demuxer_t* demuxer, int audio_id, char* audio_lang);
Expand Down
53 changes: 1 addition & 52 deletions mplayer.c
Expand Up @@ -252,9 +252,7 @@ int dvdsub_lang_id;
int vobsub_id = -1;
char *audio_lang;
char *dvdsub_lang;
static char *spudec_ifo;
char *filename;
int forced_subs_only;
int file_filter = 1;

// cache2:
Expand Down Expand Up @@ -1153,55 +1151,6 @@ void update_set_of_subtitles(void)
}
}

void init_vo_spudec(void)
{
unsigned width, height;
spudec_free(vo_spudec);
vo_spudec = NULL;

// we currently can't work without video stream
if (!mpctx->sh_video)
return;

if (spudec_ifo) {
unsigned int palette[16];
current_module = "spudec_init_vobsub";
if (vobsub_parse_ifo(NULL, spudec_ifo, palette, &width, &height, 1, -1, NULL) >= 0)
vo_spudec = spudec_new_scaled(palette, width, height, NULL, 0);
}

width = mpctx->sh_video->disp_w;
height = mpctx->sh_video->disp_h;

#ifdef CONFIG_DVDREAD
if (vo_spudec == NULL && mpctx->stream->type == STREAMTYPE_DVD) {
current_module = "spudec_init_dvdread";
vo_spudec = spudec_new_scaled(((dvd_priv_t *)(mpctx->stream->priv))->cur_pgc->palette,
width, height,
NULL, 0);
}
#endif

#ifdef CONFIG_DVDNAV
if (vo_spudec == NULL && mpctx->stream->type == STREAMTYPE_DVDNAV) {
unsigned int *palette = mp_dvdnav_get_spu_clut(mpctx->stream);
current_module = "spudec_init_dvdnav";
vo_spudec = spudec_new_scaled(palette, width, height, NULL, 0);
}
#endif

if (vo_spudec == NULL) {
sh_sub_t *sh = mpctx->d_sub->sh;
current_module = "spudec_init_normal";
vo_spudec = spudec_new_scaled(NULL, width, height, sh->extradata, sh->extradata_len);
spudec_set_font_factor(vo_spudec, font_factor);
}

if (vo_spudec != NULL) {
mp_property_do("sub_forced_only", M_PROPERTY_SET, &forced_subs_only, mpctx);
}
}

/**
* @brief Append a formatted string.
* @param buf buffer to print into
Expand Down Expand Up @@ -3604,7 +3553,7 @@ int main(int argc, char *argv[])
//================== Read SUBTITLES (DVD & TEXT) ==========================
if (vo_spudec == NULL &&
(mpctx->stream->type == STREAMTYPE_DVD || mpctx->stream->type == STREAMTYPE_DVDNAV)) {
init_vo_spudec();
init_vo_spudec(mpctx->stream, mpctx->sh_video, mpctx->d_sub ? mpctx->d_sub->sh : NULL);
}

if (1 || mpctx->sh_video) {
Expand Down

0 comments on commit c581d7a

Please sign in to comment.