[vlc-commits] [Git][videolan/vlc][master] 5 commits: vout_subpictures: don't compute the scale if we're not rendering

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Feb 7 18:19:54 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
262ce11f by Steve Lhomme at 2024-02-07T17:53:37+00:00
vout_subpictures: don't compute the scale if we're not rendering

- - - - -
7f28585f by Steve Lhomme at 2024-02-07T17:53:37+00:00
vout_subpictures: only call region_FixFmt() for rendered regions

- - - - -
d2a21b3c by Steve Lhomme at 2024-02-07T17:53:37+00:00
vout_subpictures: use local variable for original dimensions

The values are not going to change in the subpicture at this point.

- - - - -
6a5e1879 by Steve Lhomme at 2024-02-07T17:53:37+00:00
vout_subpictures: remove redundant init

The whole structure is overwritten a few lines below with real values.

- - - - -
03c00e06 by Steve Lhomme at 2024-02-07T17:53:37+00:00
vout_subpictures: assert when the original dimensions are not set

We can't position the region based on its original dimensions if they are not set.

- - - - -


1 changed file:

- src/video_output/vout_subpictures.c


Changes:

=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -593,17 +593,25 @@ static void SpuRegionPlace(int *x, int *y,
     } else {
         if (i_align & SUBPICTURE_ALIGN_TOP)
             *y = region->i_y;
-        else if (i_align & SUBPICTURE_ALIGN_BOTTOM)
-            *y = subpic->i_original_picture_height - region->fmt.i_visible_height - region->i_y;
         else
-            *y = subpic->i_original_picture_height / 2 - region->fmt.i_visible_height / 2;
+        {
+            assert(subpic->i_original_picture_height != 0);
+            if (i_align & SUBPICTURE_ALIGN_BOTTOM)
+                *y = subpic->i_original_picture_height - region->fmt.i_visible_height - region->i_y;
+            else
+                *y = subpic->i_original_picture_height / 2 - region->fmt.i_visible_height / 2;
+        }
 
         if (i_align & SUBPICTURE_ALIGN_LEFT)
             *x = region->i_x;
-        else if (i_align & SUBPICTURE_ALIGN_RIGHT)
-            *x = subpic->i_original_picture_width - region->fmt.i_visible_width - region->i_x;
         else
-            *x = subpic->i_original_picture_width / 2 - region->fmt.i_visible_width / 2;
+        {
+            assert(subpic->i_original_picture_width != 0);
+            if (i_align & SUBPICTURE_ALIGN_RIGHT)
+                *x = subpic->i_original_picture_width - region->fmt.i_visible_width - region->i_x;
+            else
+                *x = subpic->i_original_picture_width / 2 - region->fmt.i_visible_width / 2;
+        }
     }
 }
 
@@ -851,9 +859,6 @@ static subpicture_region_t *SpuRenderRegion(spu_t *spu,
     video_format_t region_fmt;
     picture_t *region_picture;
 
-    /* Invalidate area by default */
-    *dst_area = spu_area_create(0,0, 0,0, scale_size);
-
     /* Force palette if requested
      * FIXME b_force_palette and force_crop are applied to all subpictures using palette
      * instead of only the right one (being the dvd spu).
@@ -1245,9 +1250,6 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
         const unsigned i_original_width = subpic->i_original_picture_width;
         const unsigned i_original_height = subpic->i_original_picture_height;
 
-        vlc_spu_regions_foreach(region, &subpic->regions)
-            region_FixFmt(region);
-
         /* Render all regions
          * We always transform non absolute subtitle into absolute one on the
          * first rendering to allow good subtitle overlap support.
@@ -1255,6 +1257,21 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
         vlc_spu_regions_foreach(region, &subpic->regions) {
             spu_area_t area;
 
+            /* last minute text rendering */
+            subpicture_region_t *rendered_region = region;
+            if (unlikely(subpicture_region_IsText( region )))
+            {
+                subpicture_region_t *rendered_text =
+                    SpuRenderText(spu, region,
+                            i_original_width, i_original_height,
+                            chroma_list);
+                if ( rendered_text  == NULL)
+                    // not a rendering error for Text-To-Speech
+                    continue;
+                rendered_region = rendered_text;
+            }
+            region_FixFmt(rendered_region);
+
             /* Compute region scale AR */
             vlc_rational_t region_sar = (vlc_rational_t) {
                 .num = region->fmt.i_sar_num,
@@ -1263,9 +1280,9 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
             if (region_sar.num <= 0 || region_sar.den <= 0) {
 
                 const uint64_t i_sar_num = (uint64_t)fmt_dst->i_visible_width  *
-                                           fmt_dst->i_sar_num * subpic->i_original_picture_height;
+                                           fmt_dst->i_sar_num * i_original_height;
                 const uint64_t i_sar_den = (uint64_t)fmt_dst->i_visible_height *
-                                           fmt_dst->i_sar_den * subpic->i_original_picture_width;
+                                           fmt_dst->i_sar_den * i_original_width;
 
                 vlc_ureduce(&region_sar.num, &region_sar.den,
                             i_sar_num, i_sar_den, 65536);
@@ -1273,16 +1290,16 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
 
             /* Compute scaling from original size to destination size */
             // ensures that the heights match, the width being cropped.
-            spu_scale_t scale_h = spu_scale_createq((uint64_t)fmt_dst->i_visible_height         * fmt_dst->i_sar_den * region_sar.num,
-                                                  (uint64_t)subpic->i_original_picture_height * fmt_dst->i_sar_num * region_sar.den,
-                                                  fmt_dst->i_visible_height,
-                                                  subpic->i_original_picture_height);
+            spu_scale_t scale_h = spu_scale_createq((uint64_t)fmt_dst->i_visible_height * fmt_dst->i_sar_den * region_sar.num,
+                                                    (uint64_t)i_original_height         * fmt_dst->i_sar_num * region_sar.den,
+                                                    fmt_dst->i_visible_height,
+                                                    i_original_height);
 
             // ensures that the widths match, the height being cropped.
-            spu_scale_t scale_w = spu_scale_createq((uint64_t)fmt_dst->i_visible_width         * fmt_dst->i_sar_den * region_sar.num,
-                                      (uint64_t)subpic->i_original_picture_width * fmt_dst->i_sar_num * region_sar.den,
-                                      fmt_dst->i_visible_width,
-                                      subpic->i_original_picture_width);
+            spu_scale_t scale_w = spu_scale_createq((uint64_t)fmt_dst->i_visible_width * fmt_dst->i_sar_den * region_sar.num,
+                                                    (uint64_t)i_original_width         * fmt_dst->i_sar_num * region_sar.den,
+                                                    fmt_dst->i_visible_width,
+                                                    i_original_width);
 
             // take the scale that will crop the least
             spu_scale_t scale;
@@ -1294,21 +1311,6 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
             /* Check scale validity */
             assert(scale.w != 0 && scale.h != 0);
 
-            /* last minute text rendering */
-            subpicture_region_t *rendered_region = region;
-            if (unlikely(subpicture_region_IsText( region )))
-            {
-                subpicture_region_t *rendered_text =
-                    SpuRenderText(spu, region,
-                            i_original_width, i_original_height,
-                            chroma_list);
-                if ( rendered_text  == NULL)
-                    // not a rendering error for Text-To-Speech
-                    continue;
-                rendered_region = rendered_text;
-                region_FixFmt(rendered_text);
-            }
-
             const bool do_external_scale = external_scale && !subpicture_region_IsText( region );
             spu_scale_t virtual_scale = external_scale ? (spu_scale_t){ SCALE_UNIT, SCALE_UNIT } : scale;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/37bd13516a6a6833b54cabb0e04bd6721cbd78c6...03c00e06dd70d25985a1f3accfcbe1521281afba

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/37bd13516a6a6833b54cabb0e04bd6721cbd78c6...03c00e06dd70d25985a1f3accfcbe1521281afba
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list