[MPlayer-cvslog] r33665 - in trunk: command.c mencoder.c mp_core.h mpcommon.c mpcommon.h mplayer.c

reimar subversion at mplayerhq.hu
Sun Jun 19 18:48:33 CEST 2011


Author: reimar
Date: Sun Jun 19 18:48:33 2011
New Revision: 33665

Log:
Move init_vo_spudec to mp_common.c and reuse it in mencoder.

Fixes bug #1932.

Modified:
   trunk/command.c
   trunk/mencoder.c
   trunk/mp_core.h
   trunk/mpcommon.c
   trunk/mpcommon.h
   trunk/mplayer.c

Modified: trunk/command.c
==============================================================================
--- trunk/command.c	Sun Jun 19 18:28:18 2011	(r33664)
+++ trunk/command.c	Sun Jun 19 18:48:33 2011	(r33665)
@@ -1624,7 +1624,7 @@ static int mp_property_sub(m_option_t *p
             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;

Modified: trunk/mencoder.c
==============================================================================
--- trunk/mencoder.c	Sun Jun 19 18:28:18 2011	(r33664)
+++ trunk/mencoder.c	Sun Jun 19 18:48:33 2011	(r33665)
@@ -103,7 +103,6 @@
 int vo_doublebuffering=0;
 int vo_directrendering=0;
 int vo_config_count=1;
-int forced_subs_only=0;
 
 //--------------------------
 
@@ -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
@@ -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);

Modified: trunk/mp_core.h
==============================================================================
--- trunk/mp_core.h	Sun Jun 19 18:28:18 2011	(r33664)
+++ trunk/mp_core.h	Sun Jun 19 18:48:33 2011	(r33665)
@@ -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);

Modified: trunk/mpcommon.c
==============================================================================
--- trunk/mpcommon.c	Sun Jun 19 18:28:18 2011	(r33664)
+++ trunk/mpcommon.c	Sun Jun 19 18:48:33 2011	(r33665)
@@ -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"
@@ -52,6 +54,8 @@ ASS_Track* ass_track = 0; // current tra
 
 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;
@@ -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';

Modified: trunk/mpcommon.h
==============================================================================
--- trunk/mpcommon.h	Sun Jun 19 18:28:18 2011	(r33664)
+++ trunk/mpcommon.h	Sun Jun 19 18:48:33 2011	(r33665)
@@ -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;
@@ -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);

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Sun Jun 19 18:28:18 2011	(r33664)
+++ trunk/mplayer.c	Sun Jun 19 18:48:33 2011	(r33665)
@@ -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:
@@ -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
@@ -3604,7 +3553,7 @@ goto_enable_cache:
 //================== 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) {


More information about the MPlayer-cvslog mailing list