[vlc-devel] [PATCH 02/10] Add secondary property to decoder

Roland Bewick roland.bewick at gmail.com
Sun May 5 12:01:42 CEST 2019


to control the alignment, margin and synchronization of subpictures
---
 include/vlc_subpicture.h |  1 +
 src/input/decoder.c      | 14 ++++++++++++++
 src/input/decoder.h      |  7 +++++++
 src/input/es_out.c       |  3 +++
 4 files changed, 25 insertions(+)

diff --git a/include/vlc_subpicture.h b/include/vlc_subpicture.h
index ea618e8aa1..d36ed2c055 100644
--- a/include/vlc_subpicture.h
+++ b/include/vlc_subpicture.h
@@ -192,6 +192,7 @@ struct subpicture_t
      * subtitle type. */
     /**@{*/
     bool         b_subtitle;            /**< the picture is a movie subtitle */
+    bool         b_secondary;           /**< use secondary subtrack settings */
     bool         b_absolute;                       /**< position is absolute */
     int          i_original_picture_width;  /**< original width of the movie */
     int          i_original_picture_height;/**< original height of the movie */
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 36b5ac8f89..b5fe1c2ca3 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -86,6 +86,9 @@ struct decoder_owner
     /* Current format in use by the output */
     es_format_t    fmt;
 
+    /* Use secondary ES settings */
+    bool b_secondary;
+
     /* */
     atomic_bool    b_fmt_description;
     vlc_meta_t     *p_description;
@@ -642,6 +645,7 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
         p_subpic->i_channel = p_owner->i_spu_channel;
         p_subpic->i_order = p_owner->i_spu_order++;
         p_subpic->b_subtitle = true;
+        p_subpic->b_secondary = p_owner->b_secondary;
     }
 
     return p_subpic;
@@ -1783,6 +1787,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
     p_owner->p_sout = p_sout;
     p_owner->p_sout_input = NULL;
     p_owner->p_packetizer = NULL;
+    p_owner->b_secondary = false;
 
     atomic_init( &p_owner->b_fmt_description, false );
     p_owner->p_description = NULL;
@@ -2370,6 +2375,15 @@ int input_DecoderGetCcState( decoder_t *p_dec, vlc_fourcc_t codec,
     return VLC_SUCCESS;
 }
 
+int input_DecoderSetSecondary( decoder_t *dec, bool b_secondary )
+{
+    struct decoder_owner *p_owner = dec_get_owner( dec );
+    assert( dec->fmt_in.i_cat == SPU_ES );
+
+    p_owner->b_secondary = b_secondary;
+    return VLC_SUCCESS;
+}
+
 void input_DecoderChangePause( decoder_t *p_dec, bool b_paused, vlc_tick_t i_date )
 {
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
diff --git a/src/input/decoder.h b/src/input/decoder.h
index f9928edb45..8fdb9c174b 100644
--- a/src/input/decoder.h
+++ b/src/input/decoder.h
@@ -109,6 +109,13 @@ bool input_DecoderHasFormatChanged( decoder_t *p_dec, es_format_t *p_fmt, vlc_me
  */
 size_t input_DecoderGetFifoSize( decoder_t *p_dec );
 
+/**
+ * This function marks the decoder as secondary so that secondary
+ * properties can be applied (e.g.) secondary subtitle alignment
+ * and synchronization for dual subtitles.
+ */
+int input_DecoderSetSecondary( decoder_t *dec, bool b_secondary );
+
 void input_DecoderSetVoutMouseEvent( decoder_t *, vlc_mouse_event, void * );
 int  input_DecoderAddVoutOverlay( decoder_t *, subpicture_t *, int * );
 int  input_DecoderFlushVoutOverlay( decoder_t *, int );
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 78d0d3330b..824d64b3c0 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -2210,6 +2210,9 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
     if( p_esprops && p_sys->i_mode == ES_OUT_MODE_AUTO && EsIsSelected( es ) && 
         !b_select_secondary_subtitle )
         p_esprops->p_main_es = es;
+
+    if (es->fmt.i_cat == SPU_ES && es->p_dec)
+         input_DecoderSetSecondary( es->p_dec, b_select_secondary_subtitle );
 }
 
 static void EsOutCreateCCChannels( es_out_t *out, vlc_fourcc_t codec, uint64_t i_bitmap,
-- 
2.17.1



More information about the vlc-devel mailing list