[vlc-devel] [PATCH 04/22] mosaic: use the picture_chain API

Steve Lhomme robux4 at ycbcr.xyz
Thu Sep 17 17:33:26 CEST 2020


p_es->p_picture represent the picture chain and p_es->chain_tail the tail that
is used to append pictures.
---
 modules/spu/mosaic.c               |  9 ++++-----
 modules/spu/mosaic.h               |  2 +-
 modules/stream_out/mosaic_bridge.c | 15 ++++++++-------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/modules/spu/mosaic.c b/modules/spu/mosaic.c
index 9ae3b2c83cd..60e42ab8f52 100644
--- a/modules/spu/mosaic.c
+++ b/modules/spu/mosaic.c
@@ -532,11 +532,10 @@ static subpicture_t *Filter( filter_t *p_filter, vlc_tick_t date )
         while ( p_es->p_picture != NULL
                  && p_es->p_picture->date + p_sys->i_delay < date )
         {
-            if ( p_es->p_picture->p_next != NULL )
+            if ( !picture_chain_empty( p_es->p_picture ) )
             {
-                picture_t *p_next = p_es->p_picture->p_next;
-                picture_Release( p_es->p_picture );
-                p_es->p_picture = p_next;
+                picture_t *es_picture = picture_chain_pop_front( &p_es->p_picture );
+                picture_Release( es_picture );
             }
             else if ( p_es->p_picture->date + p_sys->i_delay + BLANK_DELAY <
                         date )
@@ -544,7 +543,7 @@ static subpicture_t *Filter( filter_t *p_filter, vlc_tick_t date )
                 /* Display blank */
                 picture_Release( p_es->p_picture );
                 p_es->p_picture = NULL;
-                p_es->chain_tail = NULL;
+                p_es->tail      = NULL;
                 break;
             }
             else
diff --git a/modules/spu/mosaic.h b/modules/spu/mosaic.h
index 699d61f2751..cebd24c83a8 100644
--- a/modules/spu/mosaic.h
+++ b/modules/spu/mosaic.h
@@ -25,7 +25,7 @@ typedef struct bridged_es_t
 {
     es_format_t fmt;
     picture_t *p_picture;
-    picture_t *chain_tail;
+    picture_t *tail;
     bool b_empty;
     char *psz_id;
 
diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c
index fcc6ad7ca35..53a370cec84 100644
--- a/modules/stream_out/mosaic_bridge.c
+++ b/modules/stream_out/mosaic_bridge.c
@@ -417,7 +417,7 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
     //p_es->fmt = *p_fmt;
     p_es->psz_id = p_sys->psz_id;
     p_es->p_picture = NULL;
-    p_es->chain_tail = NULL;
+    p_es->tail = NULL;
     p_es->b_empty = false;
 
     vlc_global_unlock( VLC_MOSAIC_MUTEX );
@@ -462,9 +462,8 @@ static void Del( sout_stream_t *p_stream, void *id )
     p_es->b_empty = true;
     while ( p_es->p_picture )
     {
-        picture_t *p_next = p_es->p_picture->p_next;
-        picture_Release( p_es->p_picture );
-        p_es->p_picture = p_next;
+        picture_t *es_picture = picture_chain_pop_front( &p_es->p_picture );
+        picture_Release( es_picture );
     }
 
     for ( i = 0; i < p_bridge->i_es_num; i++ )
@@ -572,11 +571,13 @@ static void decoder_queue_video( decoder_t *p_dec, picture_t *p_pic )
     bridged_es_t *p_es = p_sys->p_es;
     vlc_global_lock( VLC_MOSAIC_MUTEX );
     if (p_es->p_picture == NULL)
+    {
         p_es->p_picture = p_new_pic;
+        p_es->tail      = p_new_pic;
+        p_new_pic->p_next = NULL;
+    }
     else
-        p_es->chain_tail->p_next = p_new_pic;
-    p_new_pic->p_next = NULL;
-    p_es->chain_tail = p_new_pic;
+        p_es->tail = picture_chain_append( p_es->tail, p_new_pic );
     vlc_global_unlock( VLC_MOSAIC_MUTEX );
 }
 
-- 
2.26.2



More information about the vlc-devel mailing list