[vlc-commits] [Git][videolan/vlc][master] 9 commits: video_output: rename do_dr_spu

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Aug 10 13:43:33 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
b3149c0e by Steve Lhomme at 2023-08-10T13:01:06+00:00
video_output: rename do_dr_spu

This name is confusing with the video direct rendering. It is more useful
to know that the display module will do the blending or not.

There is no early or late SPU blending. The key factor is whether the
(local) blending is done before the converter or after the converter.

- - - - -
6e347df7 by Steve Lhomme at 2023-08-10T13:01:06+00:00
vout: don't mix meaning for flag

early_spu_blend means we don't need to process the orientation of the
picture before we blend. We can test whether manual blending is used
with the direct_render_spu flag.

Now the manual blending calls are balanced.

- - - - -
67624171 by Steve Lhomme at 2023-08-10T13:01:06+00:00
vout: factorize code to release the subpicture when blending manually

Now that both code paths that would release the subpicture is explicitly
exclusive we don't have to worry if one was called before.

- - - - -
bb011948 by Steve Lhomme at 2023-08-10T13:01:06+00:00
subpictures: only get ephemer date when we need it

- - - - -
94c3f4ff by Steve Lhomme at 2023-08-10T13:01:06+00:00
subpictures: mark subpicture_New() failure as unlikely

- - - - -
7fdb0a7c by Steve Lhomme at 2023-08-10T13:01:06+00:00
subpicture: use size_t for subpicture count

It's the type of the variable we receive.

- - - - -
05be389d by Steve Lhomme at 2023-08-10T13:01:06+00:00
vout/display: fix bogus copy/paste

13282687881f743ac31b5f8db8e1f94111058196 reworked the original code
and the bottom value was capped by i_y_offset + i_visible_height.

- - - - -
804b14d3 by Steve Lhomme at 2023-08-10T13:01:06+00:00
vout/display: handle cropping bigger than visible dimensions

Before it would just set the top/left values to 0, the visible width and
the scaled height, always favoring the smaller value of the two.

- - - - -
6a445c0a by Steve Lhomme at 2023-08-10T13:01:06+00:00
vout/display: use unsigned variables for cropping

None of the values can be negative.

- - - - -


3 changed files:

- src/video_output/display.c
- src/video_output/video_output.c
- src/video_output/vout_subpictures.c


Changes:

=====================================
src/video_output/display.c
=====================================
@@ -323,23 +323,28 @@ static int VoutDisplayCreateRender(vout_display_t *vd)
     return ret;
 }
 
-static void VoutDisplayCropRatio(int *left, int *top, int *right, int *bottom,
+static void VoutDisplayCropRatio(unsigned *left, unsigned *top, unsigned *right, unsigned *bottom,
                                  const video_format_t *source,
                                  unsigned num, unsigned den)
 {
     unsigned scaled_width  = (uint64_t)source->i_visible_height * num * source->i_sar_den / den / source->i_sar_num;
     unsigned scaled_height = (uint64_t)source->i_visible_width  * den * source->i_sar_num / num / source->i_sar_den;
 
-    if (scaled_width < source->i_visible_width) {
+    if (source->i_visible_width > scaled_width) {
         *left   = (source->i_visible_width - scaled_width) / 2;
         *top    = 0;
         *right  = *left + scaled_width;
         *bottom = *top  + source->i_visible_height;
-    } else {
+    } else if (source->i_visible_height > scaled_height) {
         *left   = 0;
         *top    = (source->i_visible_height - scaled_height) / 2;
         *right  = *left + source->i_visible_width;
         *bottom = *top  + scaled_height;
+    } else {
+        *left   = 0;
+        *top    = 0;
+        *right  = source->i_visible_width;
+        *bottom = source->i_visible_height;
     }
 }
 
@@ -416,7 +421,7 @@ static void vout_display_Reset(vout_display_t *vd)
 static int vout_UpdateSourceCrop(vout_display_t *vd)
 {
     vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
-    int left, top, right, bottom;
+    unsigned left, top, right, bottom;
 
     video_format_Print(VLC_OBJECT(vd), "SOURCE ", &osys->source);
 
@@ -451,14 +456,10 @@ static int vout_UpdateSourceCrop(vout_display_t *vd)
         left = right - 1;
     if (top >= bottom)
         top = bottom - 1;
-    if (left < 0)
-        left = 0;
-    if (top < 0)
-        top = 0;
-    if ((unsigned)right > osys->source.i_visible_width)
+    if (right > osys->source.i_visible_width)
         right = osys->source.i_visible_width;
-    if ((unsigned)bottom > osys->source.i_visible_height)
-        right = osys->source.i_visible_height;
+    if (bottom > osys->source.i_visible_height)
+        bottom = osys->source.i_visible_height;
 
     osys->source.i_x_offset += left;
     osys->source.i_y_offset += top;


=====================================
src/video_output/video_output.c
=====================================
@@ -1124,24 +1124,25 @@ static int PrerenderPicture(vout_thread_sys_t *sys, picture_t *filtered,
 
     /*
      * Check whether we let the display draw the subpicture itself (when
-     * do_dr_spu=true), and if we can fallback to blending the subpicture
-     * ourselves (do_early_spu=true).
+     * vd_does_blending=true), and if we can fallback to blending the subpicture
+     * ourselves (blending_before_converter=true).
      */
     const bool do_snapshot = vout_snapshot_IsRequested(sys->snapshot);
-    const bool do_dr_spu = !do_snapshot &&
-                           vd->info.subpicture_chromas &&
-                           *vd->info.subpicture_chromas != 0;
+    const bool vd_does_blending = !do_snapshot &&
+                                   vd->info.subpicture_chromas &&
+                                   *vd->info.subpicture_chromas != 0;
 
-    //FIXME: Denying do_early_spu if vd->source->orientation != ORIENT_NORMAL
+    //FIXME: Denying blending_before_converter if vd->source->orientation != ORIENT_NORMAL
     //will have the effect that snapshots miss the subpictures. We do this
     //because there is currently no way to transform subpictures to match
     //the source format.
-    const bool do_early_spu = !do_dr_spu &&
-                               vd->source->orientation == ORIENT_NORMAL;
+    // In early SPU blending the blending is done into the source chroma,
+    // otherwise it's done in the display chroma
+    const bool blending_before_converter = vd->source->orientation == ORIENT_NORMAL;
 
     const vlc_fourcc_t *subpicture_chromas;
     video_format_t fmt_spu;
-    if (do_dr_spu) {
+    if (vd_does_blending) {
         vout_display_place_t place;
         vout_display_PlacePicture(&place, vd->source, &vd->cfg->display);
 
@@ -1156,7 +1157,7 @@ static int PrerenderPicture(vout_thread_sys_t *sys, picture_t *filtered,
         }
         subpicture_chromas = vd->info.subpicture_chromas;
     } else {
-        if (do_early_spu) {
+        if (blending_before_converter) {
             fmt_spu = *vd->source;
         } else {
             fmt_spu = *vd->fmt;
@@ -1197,7 +1198,7 @@ static int PrerenderPicture(vout_thread_sys_t *sys, picture_t *filtered,
      */
     picture_t *todisplay = filtered;
     picture_t *snap_pic = todisplay;
-    if (do_early_spu && subpic) {
+    if (!vd_does_blending && blending_before_converter && subpic) {
         if (sys->spu_blend) {
             picture_t *blent = picture_pool_Get(sys->private.private_pool);
             if (blent) {
@@ -1221,8 +1222,6 @@ static int PrerenderPicture(vout_thread_sys_t *sys, picture_t *filtered,
                 }
             }
         }
-        subpicture_Delete(subpic);
-        subpic = NULL;
     }
 
     /*
@@ -1246,11 +1245,14 @@ static int PrerenderPicture(vout_thread_sys_t *sys, picture_t *filtered,
         return VLC_EGENERIC;
     }
 
-    if (!do_dr_spu && subpic)
+    if (!vd_does_blending && !blending_before_converter && subpic)
     {
         if (sys->spu_blend)
             picture_BlendSubpicture(todisplay, sys->spu_blend, subpic);
+    }
 
+    if (subpic && !vd_does_blending)
+    {
         /* The subpic will not be used anymore */
         subpicture_Delete(subpic);
         subpic = NULL;


=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -743,11 +743,11 @@ spu_SelectSubpictures(spu_t *spu, vlc_tick_t system_now,
             }
 
             const vlc_tick_t stop_date = current->b_subtitle ? __MAX(start_date, sys->last_sort_date) : system_now;
-            const vlc_tick_t ephemer_date  = current->b_subtitle ? ephemer_subtitle_date  : ephemer_osd_date;
 
             /* Destroy late and obsolete ephemer subpictures */
             bool is_rejected = is_late && render_entry->stop <= stop_date;
             if (current->b_ephemer) {
+                const vlc_tick_t ephemer_date = current->b_subtitle ? ephemer_subtitle_date : ephemer_osd_date;
                 if (render_entry->start < ephemer_date)
                     is_rejected = true;
                 else if (render_entry->start == ephemer_date &&
@@ -1143,12 +1143,12 @@ static subpicture_t *SpuRenderSubpictures(spu_t *spu,
                                           bool external_scale)
 {
     /* Count the number of regions and subtitle regions */
-    unsigned int subtitle_region_count = 0;
-    unsigned int region_count          = 0;
-    for (unsigned i = 0; i < i_subpicture; i++) {
+    size_t subtitle_region_count = 0;
+    size_t region_count          = 0;
+    for (size_t i = 0; i < i_subpicture; i++) {
         const subpicture_t *subpic = p_entries[i].subpic;
 
-        unsigned count = 0;
+        size_t count = 0;
         for (subpicture_region_t *r = subpic->p_region; r != NULL; r = r->p_next)
             count++;
 
@@ -1156,12 +1156,12 @@ static subpicture_t *SpuRenderSubpictures(spu_t *spu,
             subtitle_region_count += count;
         region_count += count;
     }
-    if (region_count <= 0)
+    if (region_count == 0)
         return NULL;
 
     /* Create the output subpicture */
     subpicture_t *output = subpicture_New(NULL);
-    if (!output)
+    if (unlikely(output == NULL))
         return NULL;
     output->i_order = p_entries[i_subpicture - 1].subpic->i_order;
     output->i_original_picture_width  = fmt_dst->i_visible_width;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e8af0221767591b35c81561b8308f5051e594055...6a445c0a04199ed918e5e4cc1fa96efe2c1a1ee5

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e8af0221767591b35c81561b8308f5051e594055...6a445c0a04199ed918e5e4cc1fa96efe2c1a1ee5
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