[vlc-devel] [PATCH v2 03/24] mosaic: simplify the picture chain tail handling

Steve Lhomme robux4 at ycbcr.xyz
Fri Sep 18 16:45:09 CEST 2020


Rather than a pointer on the last picture pointer, we use either NULL (no
tail/chain empty) or a pointer to the last picture in the chain.
---
 modules/spu/mosaic.c               | 2 +-
 modules/spu/mosaic.h               | 2 +-
 modules/stream_out/mosaic_bridge.c | 9 ++++++---
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/modules/spu/mosaic.c b/modules/spu/mosaic.c
index b06ca3fd6f4..1b9a1ee8c7c 100644
--- a/modules/spu/mosaic.c
+++ b/modules/spu/mosaic.c
@@ -544,7 +544,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->pp_last = &p_es->p_picture;
+                p_es->tail = NULL;
                 break;
             }
             else
diff --git a/modules/spu/mosaic.h b/modules/spu/mosaic.h
index 41bd00950d4..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 **pp_last;
+    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 518ea73b304..bf05c16a086 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->pp_last = &p_es->p_picture;
+    p_es->tail = NULL;
     p_es->b_empty = false;
 
     vlc_global_unlock( VLC_MOSAIC_MUTEX );
@@ -571,9 +571,12 @@ static void decoder_queue_video( decoder_t *p_dec, picture_t *p_pic )
     /* push the picture in the mosaic-struct structure */
     bridged_es_t *p_es = p_sys->p_es;
     vlc_global_lock( VLC_MOSAIC_MUTEX );
-    *p_es->pp_last = p_new_pic;
+    if (p_es->p_picture == NULL)
+        p_es->p_picture = p_new_pic;
+    else
+        p_es->tail->p_next = p_new_pic;
     p_new_pic->p_next = NULL;
-    p_es->pp_last = &p_new_pic->p_next;
+    p_es->tail = p_new_pic;
     vlc_global_unlock( VLC_MOSAIC_MUTEX );
 }
 
-- 
2.26.2



More information about the vlc-devel mailing list