[vlc-commits] demux: mkv: use ES_OUT_SPU_SET_HIGHLIGHT

Filip Roséen git at videolan.org
Fri Jul 20 09:37:40 CEST 2018


vlc | branch: master | Filip Roséen <filip at atch.se> | Wed Jul 18 05:09:43 2018 +0200| [d0fbef20966743f3fae281d6be3c9a9428162531] | committer: Thomas Guillem

demux: mkv: use ES_OUT_SPU_SET_HIGHLIGHT

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d0fbef20966743f3fae281d6be3c9a9428162531
---

 modules/demux/mkv/demux.cpp            | 21 -------------------
 modules/demux/mkv/events.cpp           | 38 +++++++++++++++++++---------------
 modules/demux/mkv/matroska_segment.cpp |  1 -
 3 files changed, 21 insertions(+), 39 deletions(-)

diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
index e8cad67162..ed5433f715 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -163,31 +163,10 @@ void demux_sys_t::InitUi()
     /* FIXME hack hack hack hack FIXME */
     /* Get p_input and create variable */
     p_input = demuxer.p_input;
-    if( p_input )
-    {
-        var_Create( p_input, "x-start", VLC_VAR_INTEGER );
-        var_Create( p_input, "y-start", VLC_VAR_INTEGER );
-        var_Create( p_input, "x-end", VLC_VAR_INTEGER );
-        var_Create( p_input, "y-end", VLC_VAR_INTEGER );
-        var_Create( p_input, "color", VLC_VAR_ADDRESS );
-        var_Create( p_input, "menu-palette", VLC_VAR_ADDRESS );
-        var_Create( p_input, "highlight", VLC_VAR_BOOL );
-    }
 }
 
 void demux_sys_t::CleanUi()
 {
-    if( p_input )
-    {
-        var_Destroy( p_input, "highlight" );
-        var_Destroy( p_input, "x-start" );
-        var_Destroy( p_input, "x-end" );
-        var_Destroy( p_input, "y-start" );
-        var_Destroy( p_input, "y-end" );
-        var_Destroy( p_input, "color" );
-        var_Destroy( p_input, "menu-palette" );
-    }
-
     msg_Dbg( &demuxer, "Stopping the UI Hook" );
 }
 
diff --git a/modules/demux/mkv/events.cpp b/modules/demux/mkv/events.cpp
index ba9718522d..015cdf0115 100644
--- a/modules/demux/mkv/events.cpp
+++ b/modules/demux/mkv/events.cpp
@@ -358,6 +358,15 @@ void event_thread_t::HandleMouseEvent( EventInfo const& event )
             // select new button
             if ( best != i_curr_button )
             {
+                // TODO: make sure we do not overflow in the conversion
+                vlc_spu_highlight_t spu_hl = vlc_spu_highlight_t();
+
+                spu_hl.x_start = (int)button_ptr.x_start;
+                spu_hl.y_start = (int)button_ptr.y_start;
+
+                spu_hl.x_end = (int)button_ptr.x_end;
+                spu_hl.y_end = (int)button_ptr.y_end;
+
                 uint32_t i_palette;
 
                 if(button_ptr.btn_coln != 0) {
@@ -372,25 +381,20 @@ void event_thread_t::HandleMouseEvent( EventInfo const& event )
                     uint8_t i_alpha = (i_palette>>(i*4))&0x0f;
                     i_alpha = i_alpha == 0xf ? 0xff : i_alpha << 4;
 
-                    p_sys->palette[i][0] = (i_yuv >> 16) & 0xff;
-                    p_sys->palette[i][1] = (i_yuv >> 0) & 0xff;
-                    p_sys->palette[i][2] = (i_yuv >> 8) & 0xff;
-                    p_sys->palette[i][3] = i_alpha;
+                    spu_hl.palette.palette[i][0] = (i_yuv >> 16) & 0xff;
+                    spu_hl.palette.palette[i][1] = (i_yuv >> 0) & 0xff;
+                    spu_hl.palette.palette[i][2] = (i_yuv >> 8) & 0xff;
+                    spu_hl.palette.palette[i][3] = i_alpha;
                 }
 
-                vlc_global_lock( VLC_HIGHLIGHT_MUTEX );
-                var_SetInteger( p_demux->p_input, "x-start",
-                                button_ptr.x_start );
-                var_SetInteger( p_demux->p_input, "x-end",
-                                button_ptr.x_end );
-                var_SetInteger( p_demux->p_input, "y-start",
-                                button_ptr.y_start );
-                var_SetInteger( p_demux->p_input, "y-end",
-                                button_ptr.y_end );
-                var_SetAddress( p_demux->p_input, "menu-palette",
-                                p_sys->palette );
-                var_SetBool( p_demux->p_input, "highlight", true );
-                vlc_global_unlock( VLC_HIGHLIGHT_MUTEX );
+                /* TODO: only control relevant SPU_ES given who fired the event */
+                for( es_list_t::iterator it = es_list.begin(); it != es_list.end(); ++it )
+                {
+                    if( it->category != SPU_ES )
+                        continue;
+
+                    es_out_Control( p_demux->out, ES_OUT_SPU_SET_HIGHLIGHT, it->es, &spu_hl );
+                }
             }
             vlc_mutex_unlock( &p_sys->lock_demuxer );
             vlc_mutex_lock( &lock );
diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 06a57f612f..ef894574ac 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -1139,7 +1139,6 @@ bool matroska_segment_c::ESCreate()
             if( !default_track || track.b_default )
                 default_track = &track;
         }
-
     }
 
     for( mkv_track_t *track : default_tracks )



More information about the vlc-commits mailing list