[vlc-commits] [Git][videolan/vlc][master] 6 commits: Revert "svg: fix height calculation"

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Sep 17 09:27:19 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
591551b7 by Alexandre Janniaux at 2026-09-17T09:08:49+00:00
Revert "svg: fix height calculation"

This reverts commit aababdeb4b4d4ffb6f5f405832d40dac64d8ac71.

Reverted to properly revert "svg: replace deprecated
rsvg_handle_get_dimensions"

- - - - -
9c985436 by Alexandre Janniaux at 2026-09-17T09:08:49+00:00
Revert "svg: reject invalid dimensions"

This reverts commit 0e2dcf179052f7395202655681841bf7ed4bb60a.

Reverted to properly revert "svg: replace deprecated
rsvg_handle_get_dimensions"

- - - - -
59cd6fb6 by Alexandre Janniaux at 2026-09-17T09:08:49+00:00
Revert "svg: cosmetic fix"

This reverts commit a6bc53071b52fd9fe772e8ba2928d070d36f9b94.

Reverted to properly revert "svg: replace deprecated
rsvg_handle_get_dimensions"

- - - - -
b46ef90c by Alexandre Janniaux at 2026-09-17T09:08:49+00:00
Revert "svg: replace deprecated rsvg_handle_get_dimensions"

This reverts commit 5512290f5e7848700a97e18233ffe5ab0ff5aacf.

Ref #30123, fix the regression where the text renderer doesn't display
anything anymore.

In addition, 7639a634373f98363a0ad28b8970901f40486ec5 was written in a
weird way where it would check the size or the viewbox, even though the
SVG document is generated by the text renderer itself.

- - - - -
8954b96a by Marvin Scholz at 2026-09-17T09:08:49+00:00
text_renderer: svg: simplify using vlc_memstream

Simplify the SegmentsToSVG function which concatenates the
individual segments of text with the proper SVG markup around
them by using vlc_memstream allowing to greatly simplify
error checks.

- - - - -
9fa049c5 by Marvin Scholz at 2026-09-17T09:08:49+00:00
text_renderer: svg: do not use deprecated APIs

Update to non-deprecated APIs when a new enough version of
librsvg is used.

- - - - -


4 changed files:

- modules/codec/svg.c
- modules/stream_out/chromecast/cast.cpp
- modules/stream_out/meson.build
- modules/text_renderer/svg.c


Changes:

=====================================
modules/codec/svg.c
=====================================
@@ -148,34 +148,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         goto done;
 
     RsvgDimensionData dim;
-    #if LIBRSVG_MAJOR_VERSION > 2 || ( LIBRSVG_MAJOR_VERSION == 2 && LIBRSVG_MINOR_VERSION >= 52 )
-    gboolean has_width, has_height, has_viewbox;
-    RsvgLength width, height;
-    RsvgRectangle viewbox;
-
-    rsvg_handle_get_intrinsic_dimensions( rsvg, &has_width, &width, &has_height, &height, &has_viewbox, &viewbox );
-
-    if( has_width && has_height && width.unit == RSVG_UNIT_PX && height.unit == RSVG_UNIT_PX )
-    {
-        dim.width = (int) width.length;
-        dim.height = (int) height.length;
-    }
-    else if( has_viewbox )
-    {
-        dim.width = (int) viewbox.width;
-        dim.height = (int) viewbox.height;
-    }
-    else
-    {
-        dim.width = 0;
-        dim.height = 0;
-    }
-    #else
     rsvg_handle_get_dimensions( rsvg, &dim );
-    #endif
-
-    if( dim.width <= 0 || dim.height <= 0 )
-        goto done;
 
     if( p_sys->f_scale > 0.0 )
     {
@@ -193,7 +166,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         else if( p_sys->i_width > 0 && p_sys->i_height < 0 )
         {
             i_width  = p_sys->i_width;
-            i_height = dim.height * p_sys->i_width / dim.width;
+            i_height = dim.height * p_sys->i_width / dim.height;
         }
         else if( p_sys->i_width > 0 && p_sys->i_height > 0 )
         {


=====================================
modules/stream_out/chromecast/cast.cpp
=====================================
@@ -235,6 +235,14 @@ vlc_module_begin ()
     add_obsolete_string(SOUT_CFG_PREFIX "mime") /* since 4.0.0 */
     add_renderer_opts(SOUT_CFG_PREFIX)
 
+    add_submodule()
+        /* Same module, usable in a non-terminal position of the chain. The
+         * elementary streams all end up in the internal chain built by Open(),
+         * so p_next never sees any of them: whatever follows in the enclosing
+         * chain only gets to run its activate function. */
+        add_shortcut("chromecast")
+        set_capability("sout filter", 0)
+        set_callback(Open)
     add_submodule()
         /* sout proxy that start the cc input when all streams are loaded */
         add_shortcut("chromecast-proxy")


=====================================
modules/stream_out/meson.build
=====================================
@@ -21,6 +21,13 @@ vlc_modules += {
     'shortname' : 's_o_dela',
 }
 
+# sideload
+vlc_modules += {
+    'name' : 'stream_out_sideload',
+    'sources' : files('sideload.c'),
+    'shortname' : 's_o_side',
+}
+
 # stats
 vlc_modules += {
     'name' : 'stream_out_stats',


=====================================
modules/text_renderer/svg.c
=====================================
@@ -41,6 +41,7 @@
 #include <glib.h>
 #include <glib/gstdio.h>
 #include <glib-object.h>                                  /* g_object_unref( ) */
+#include <vlc_memstream.h>
 #include <librsvg/rsvg.h>
 #include <cairo.h>
 
@@ -77,6 +78,9 @@ vlc_module_begin ()
     set_callback_text_renderer( Create, 99 )
 vlc_module_end ()
 
+static void svg_RescaletoFit (filter_t *, double *width, double *height);
+static picture_t * svg_RenderPicture ( filter_t *p_filter, const char * );
+
 static void svg_LoadTemplate( filter_t *p_filter )
 {
     filter_sys_t *p_sys = p_filter->p_sys;
@@ -207,27 +211,46 @@ static void Destroy( filter_t *p_filter )
     free( p_sys );
 }
 
-static void svg_RescaletoFit( filter_t *p_filter, int *width, int *height, float *scale )
+static void svg_RescaletoFit(filter_t *p_filter, double *width, double *height)
 {
-    *scale = 1.0;
+    double scale = 1.0;
 
     if( *width > 0 && *height > 0 )
     {
         if( (unsigned)*width > p_filter->fmt_out.video.i_visible_width )
-            *scale = (1.0 * p_filter->fmt_out.video.i_visible_width / *width);
+            scale = ((double)p_filter->fmt_out.video.i_visible_width / *width);
 
         if( (unsigned)*height > p_filter->fmt_out.video.i_visible_height )
         {
-            float y_scale = (1.0 * p_filter->fmt_out.video.i_visible_height / *height);
-            if( y_scale < *scale )
-                *scale = y_scale;
+            double y_scale = ((double)p_filter->fmt_out.video.i_visible_height / *height);
+            if( y_scale < scale )
+                scale = y_scale;
         }
 
-        *width *= *scale;
-        *height *= *scale;
+        *width *= scale;
+        *height *= scale;
     }
 }
 
+static bool svg_GetDimensionsInPixels( RsvgHandle *handle, double *width, double *height )
+{
+#if LIBRSVG_CHECK_VERSION(2, 52, 0)
+    RsvgRectangle outRect;
+    if (!rsvg_handle_get_geometry_for_element( handle, NULL, &outRect, NULL, NULL ))
+        return false;
+
+    *width = outRect.width;
+    *height = outRect.height;
+    return true;
+#else
+    RsvgDimensionData dim;
+    rsvg_handle_get_dimensions( handle, &dim );
+    *width = dim.width;
+    *height = dim.height;
+    return true;
+#endif
+}
+
 static picture_t * svg_RenderPicture( filter_t *p_filter,
                                       const char *psz_svgdata )
 {
@@ -242,41 +265,20 @@ static picture_t * svg_RenderPicture( filter_t *p_filter,
         return NULL;
     }
 
-    RsvgDimensionData dim;
-    #if LIBRSVG_MAJOR_VERSION > 2 || ( LIBRSVG_MAJOR_VERSION == 2 && LIBRSVG_MINOR_VERSION >= 52 )
-    gboolean has_width, has_height, has_viewbox;
-    RsvgLength width, height;
-    RsvgRectangle viewbox;
-
-    rsvg_handle_get_intrinsic_dimensions( p_handle, &has_width, &width, &has_height, &height, &has_viewbox, &viewbox );
-
-    if( has_width && has_height && width.unit == RSVG_UNIT_PX && height.unit == RSVG_UNIT_PX )
-    {
-        dim.width = (int) width.length;
-        dim.height = (int) height.length;
-    }
-    else if( has_viewbox )
-    {
-        dim.width = (int) viewbox.width;
-        dim.height = (int) viewbox.height;
-    }
-    else
-    {
-        dim.width = 0;
-        dim.height = 0;
+    double width, height;
+    if (!svg_GetDimensionsInPixels( p_handle, &width, &height )) {
+        msg_Err( p_filter, "Unable to obtain SVG dimensions for rendering" );
+        g_object_unref(G_OBJECT(p_handle));
+        return NULL;
     }
-    #else
-    rsvg_handle_get_dimensions( p_handle, &dim );
-    #endif
-    float scale;
-    svg_RescaletoFit( p_filter, &dim.width, &dim.height, &scale );
+    svg_RescaletoFit(p_filter, &width, &height);
 
     /* Create a new subpicture region */
     video_format_t fmt;
     video_format_Init( &fmt, VLC_CODEC_BGRA ); /* CAIRO_FORMAT_ARGB32 == VLC_CODEC_BGRA, go figure */
     fmt.i_chroma = VLC_CODEC_BGRA;
-    fmt.i_width = fmt.i_visible_width = dim.width;
-    fmt.i_height = fmt.i_visible_height = dim.height;
+    fmt.i_width = fmt.i_visible_width = ceil(width);
+    fmt.i_height = fmt.i_visible_height = height;
     fmt.transfer = TRANSFER_FUNC_SRGB;
     fmt.primaries = COLOR_PRIMARIES_SRGB;
     fmt.space = COLOR_SPACE_SRGB;
@@ -312,7 +314,11 @@ static picture_t * svg_RenderPicture( filter_t *p_filter,
         return NULL;
     }
 
+#if LIBRSVG_CHECK_VERSION(2, 46, 0)
+    if ( ! rsvg_handle_render_document( p_handle, cr, &(RsvgRectangle){ .height = height, .width = width }, NULL ) )
+#else
     if( ! rsvg_handle_render_cairo( p_handle, cr ) )
+#endif
     {
         msg_Err( p_filter, "error while rendering SVG" );
         cairo_destroy( cr );
@@ -331,28 +337,29 @@ static picture_t * svg_RenderPicture( filter_t *p_filter,
 
 static char * SegmentsToSVG( text_segment_t *p_segment, int i_height, int *pi_total_size )
 {
-    char *psz_result = NULL;
+    struct vlc_memstream stream;
+    vlc_memstream_open(&stream);
 
     i_height = 6 * i_height / 100;
     *pi_total_size = 0;
 
     for( ; p_segment; p_segment = p_segment->p_next )
     {
-        char *psz_prev = psz_result;
         char *psz_encoded = vlc_xml_encode( p_segment->psz_text );
-        if( psz_encoded == NULL ||
-            asprintf( &psz_result, "%s<tspan x='0' dy='%upx'>%s</tspan>\n",
-                                   (psz_prev) ? psz_prev : "",
-                                    i_height,
-                                    psz_encoded ) < 0 )
-            psz_result = NULL;
-        free( psz_prev );
+        if ( !psz_encoded )
+            continue;
+
+        vlc_memstream_printf( &stream, "<tspan x='0' dy='%upx'>%s</tspan>\n",
+                              i_height, psz_encoded );
         free( psz_encoded );
 
         *pi_total_size += i_height;
     }
 
-    return psz_result;
+    if (vlc_memstream_close( &stream ))
+        return NULL;
+
+    return stream.ptr;
 }
 
 static subpicture_region_t *RenderText( filter_t *p_filter,



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/95c76de40b1200cb10165bc7a47d3e3fd48c70bf...9fa049c5fe2f7110733930bed2f863c90229ef3b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/95c76de40b1200cb10165bc7a47d3e3fd48c70bf...9fa049c5fe2f7110733930bed2f863c90229ef3b
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list