[vlc-commits] [Git][videolan/vlc][master] 2 commits: vout: extract filtering to a separate function

Romain Vimont (@rom1v) gitlab at videolan.org
Tue Jul 20 20:30:05 UTC 2021



Romain Vimont pushed to branch master at VideoLAN / VLC


Commits:
be892430 by Romain Vimont at 2021-07-20T20:19:40+00:00
vout: extract filtering to a separate function

This is a first step to simplify RenderPicture().

- - - - -
2ba73428 by Romain Vimont at 2021-07-20T20:19:40+00:00
vout: extract SPU rendering to a separate function

This simplifies RenderPicture() and reduces the scope of local
variables.

- - - - -


1 changed file:

- src/video_output/video_output.c


Changes:

=====================================
src/video_output/video_output.c
=====================================
@@ -1109,26 +1109,26 @@ static picture_t *ConvertRGB32AndBlend(vout_thread_sys_t *vout, picture_t *pic,
     return NULL;
 }
 
-static int RenderPicture(vout_thread_sys_t *sys, bool render_now)
+static picture_t *FilterPictureInteractive(vout_thread_sys_t *sys)
 {
     // hold it as the filter chain will release it or return it and we release it
     picture_Hold(sys->displayed.current);
 
-    vout_chrono_Start(&sys->render);
-
     vlc_mutex_lock(&sys->filter.lock);
     picture_t *filtered = filter_chain_VideoFilter(sys->filter.chain_interactive, sys->displayed.current);
     vlc_mutex_unlock(&sys->filter.lock);
 
-    if (!filtered)
-        return VLC_EGENERIC;
-
-    if (filtered->date != sys->displayed.current->date)
+    if (filtered && filtered->date != sys->displayed.current->date)
         msg_Warn(&sys->obj, "Unsupported timestamp modifications done by chain_interactive");
 
-    vout_display_t *vd = sys->display;
+    return filtered;
+}
 
-    vlc_mutex_lock(&sys->display_lock);
+static int PrerenderPicture(vout_thread_sys_t *sys, picture_t *filtered,
+                            bool *render_now, picture_t **out_pic,
+                            subpicture_t **out_subpic)
+{
+    vout_display_t *vd = sys->display;
 
     /*
      * Get the rendering date for the current subpicture to be displayed.
@@ -1149,7 +1149,7 @@ static int RenderPicture(vout_thread_sys_t *sys, bool render_now)
         if (unlikely(render_subtitle_date == VLC_TICK_MAX))
         {
             render_subtitle_date = system_now;
-            render_now = true;
+            *render_now = true;
         }
     }
 
@@ -1279,10 +1279,43 @@ static int RenderPicture(vout_thread_sys_t *sys, bool render_now)
         return VLC_EGENERIC;
     }
 
-    if (!do_dr_spu && sys->spu_blend != NULL && subpic != NULL)
-        picture_BlendSubpicture(todisplay, sys->spu_blend, subpic);
+    if (!do_dr_spu && subpic)
+    {
+        if (sys->spu_blend)
+            picture_BlendSubpicture(todisplay, sys->spu_blend, subpic);
 
-    system_now = vlc_tick_now();
+        /* The subpic will not be used anymore */
+        subpicture_Delete(subpic);
+        subpic = NULL;
+    }
+
+    *out_pic = todisplay;
+    *out_subpic = subpic;
+    return VLC_SUCCESS;
+}
+
+static int RenderPicture(vout_thread_sys_t *sys, bool render_now)
+{
+    vout_display_t *vd = sys->display;
+
+    vout_chrono_Start(&sys->render);
+
+    picture_t *filtered = FilterPictureInteractive(sys);
+    if (!filtered)
+        return VLC_EGENERIC;
+
+    vlc_mutex_lock(&sys->display_lock);
+
+    picture_t *todisplay;
+    subpicture_t *subpic;
+    int ret = PrerenderPicture(sys, filtered, &render_now, &todisplay, &subpic);
+    if (ret != VLC_SUCCESS)
+    {
+        vlc_mutex_unlock(&sys->display_lock);
+        return ret;
+    }
+
+    vlc_tick_t system_now = vlc_tick_now();
     const vlc_tick_t pts = todisplay->date;
     vlc_tick_t system_pts = render_now ? system_now :
         vlc_clock_ConvertToSystem(sys->clock, system_now, pts, sys->rate);
@@ -1299,7 +1332,7 @@ static int RenderPicture(vout_thread_sys_t *sys, bool render_now)
     const unsigned frame_rate_base = todisplay->format.i_frame_rate_base;
 
     if (vd->ops->prepare != NULL)
-        vd->ops->prepare(vd, todisplay, do_dr_spu ? subpic : NULL, system_pts);
+        vd->ops->prepare(vd, todisplay, subpic, system_pts);
 
     vout_chrono_Stop(&sys->render);
 #if 0



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dde3546047a896b1c001a15ba062e27ff164feea...2ba734287bedee47bebc14cb37258e473f9b464c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dde3546047a896b1c001a15ba062e27ff164feea...2ba734287bedee47bebc14cb37258e473f9b464c
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list