[vlc-commits] [Git][videolan/vlc][master] 6 commits: vlc_filter: fix the note on filter_chain_DeleteFilter()

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Wed Oct 4 08:29:09 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
a2c7b94b by Steve Lhomme at 2023-10-04T08:10:07+00:00
vlc_filter: fix the note on filter_chain_DeleteFilter()

The comment from b89b01bb6d1aa41a8877b1ba1ab8f393e15aa052 is bogus,
filter_chain_AppendInner() is not public, but filter_chain_AppendConverter()
and filter_chain_AppendFilter() are.

- - - - -
afb59ab1 by Steve Lhomme at 2023-10-04T08:10:07+00:00
vout/opengl: keep the original viewpoint on startup

If there was a value it should be kept for a potential UpdateFormat call.

- - - - -
7a910a3b by Steve Lhomme at 2023-10-04T08:10:07+00:00
glwin32: support UpdateFormat callback

Similar to the base opengl display module.

- - - - -
470ab5eb by Steve Lhomme at 2023-10-04T08:10:07+00:00
video_output: update the filter pool on successful update_format

There is no converter to the previous input format of the display. The last
filter is expecting to receive pictures in this format, not the old one.

- - - - -
c1535e55 by Steve Lhomme at 2023-10-04T08:10:07+00:00
filter_chain: log the pointer of the filter chain

They can be combined so it helps find who is in what chain.

- - - - -
db905e5c by Steve Lhomme at 2023-10-04T08:10:07+00:00
video_output: use a define for the size of private_pool

- - - - -


6 changed files:

- include/vlc_filter.h
- modules/video_chroma/chain.c
- modules/video_output/opengl/display.c
- modules/video_output/win32/glwin32.c
- src/misc/filter_chain.c
- src/video_output/video_output.c


Changes:

=====================================
include/vlc_filter.h
=====================================
@@ -564,7 +564,8 @@ VLC_API int filter_chain_AppendFromString(filter_chain_t *chain,
  * \param chain filter chain to remove the filter from
  * \param filter filter to remove from the chain and delete
  *
- * \note the filter must be created with filter_chain_AppendInner().
+ * \note the filter must be created with filter_chain_AppendConverter() or
+ * filter_chain_AppendFilter().
  */
 VLC_API void filter_chain_DeleteFilter(filter_chain_t *chain,
                                        filter_t *filter);


=====================================
modules/video_chroma/chain.c
=====================================
@@ -417,8 +417,8 @@ static int BuildFilterChain( filter_t *p_filter )
             i_chroma == p_filter->fmt_out.i_codec )
             continue;
 
-        msg_Dbg( p_filter, "Trying to use chroma %4.4s as middle man",
-                 (char*)&i_chroma );
+        msg_Dbg( p_filter, "Trying to use chroma %4.4s as middle man in chain (%p)",
+                 (char*)&i_chroma, (void*)p_sys->p_chain );
 
         es_format_Clean( &fmt_mid );
         es_format_Copy( &fmt_mid, &p_filter->fmt_in );


=====================================
modules/video_output/opengl/display.c
=====================================
@@ -259,7 +259,7 @@ static int Open(vout_display_t *vd,
     if (sys->vgl == NULL)
         goto error;
 
-    vlc_viewpoint_init(&sys->viewpoint);
+    sys->viewpoint = vd->cfg->viewpoint;
 
     vd->info.subpicture_chromas = spu_chromas;
     vd->ops = &ops;


=====================================
modules/video_output/win32/glwin32.c
=====================================
@@ -66,6 +66,7 @@ typedef struct vout_display_sys_t
 
     vlc_gl_t              *gl;
     vout_display_opengl_t *vgl;
+    vlc_viewpoint_t       viewpoint;
 } vout_display_sys_t;
 
 static void           Prepare(vout_display_t *, picture_t *, subpicture_t *, vlc_tick_t);
@@ -74,7 +75,11 @@ static void           Display(vout_display_t *, picture_t *);
 static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
 {
     vout_display_sys_t *sys = vd->sys;
-    return vout_display_opengl_SetViewpoint(sys->vgl, vp);
+    int ret = vout_display_opengl_SetViewpoint(sys->vgl, vp);
+    if (ret != VLC_SUCCESS)
+        return ret;
+    sys->viewpoint = *vp;
+    return VLC_SUCCESS;
 }
 
 static int Control(vout_display_t *vd, int query)
@@ -102,12 +107,39 @@ static vlc_window_t *EmbedVideoWindow_Create(vout_display_t *vd)
     return wnd;
 }
 
+static int
+UpdateFormat(vout_display_t *vd, const video_format_t *fmt,
+             vlc_video_context *vctx)
+{
+    vout_display_sys_t *sys = vd->sys;
+
+    int ret = vlc_gl_MakeCurrent(sys->gl);
+    if (ret != VLC_SUCCESS)
+        return ret;
+
+    ret = vout_display_opengl_UpdateFormat(sys->vgl, fmt, vctx);
+
+    // /* Force to recompute the viewport on next picture */
+    sys->area.place_changed = true;
+
+    /* Restore viewpoint */
+    int vp_ret = vout_display_opengl_SetViewpoint(sys->vgl, &sys->viewpoint);
+    /* The viewpoint previously applied is necessarily valid */
+    assert(vp_ret == VLC_SUCCESS);
+    (void) vp_ret;
+
+    vlc_gl_ReleaseCurrent(sys->gl);
+
+    return ret;
+}
+
 static const struct vlc_display_operations ops = {
     .close = Close,
     .prepare = Prepare,
     .display = Display,
     .control = Control,
     .set_viewpoint = SetViewpoint,
+    .update_format = UpdateFormat,
 };
 
 /**
@@ -161,6 +193,8 @@ static int Open(vout_display_t *vd,
     if (!sys->vgl)
         goto error;
 
+    sys->viewpoint = vd->cfg->viewpoint;
+
     /* Setup vout_display now that everything is fine */
     vd->info.subpicture_chromas = subpicture_chromas;
 


=====================================
src/misc/filter_chain.c
=====================================
@@ -262,9 +262,9 @@ static filter_t *filter_chain_AppendInner( filter_chain_t *chain,
     vlc_mouse_Init( &chained->mouse );
     vlc_picture_chain_Init( &chained->pending );
 
-    msg_Dbg( chain->obj, "Filter '%s' (%p) appended to chain",
+    msg_Dbg( chain->obj, "Filter '%s' (%p) appended to chain (%p)",
              (name != NULL) ? name : module_GetShortName(filter->p_module),
-             (void *)filter );
+             (void *)filter, (void *)chain );
     return filter;
 
 error:


=====================================
src/video_output/video_output.c
=====================================
@@ -176,6 +176,10 @@ typedef struct vout_thread_sys_t
     container_of(vout, vout_thread_sys_t, obj.obj)
 
 
+/* Amount of pictures in the private pool:
+ * 3 for interactive+static filters, 1 for SPU blending, 1 for currently displayed */
+#define FILTER_POOL_SIZE  (3+1+1)
+
 /* Maximum delay between 2 displayed pictures.
  * XXX it is needed for now but should be removed in the long term.
  */
@@ -882,19 +886,35 @@ static void ChangeFilters(vout_thread_sys_t *vout)
         bool only_chroma_changed = es_format_IsSimilar(&tmp, &fmt_target);
         if (only_chroma_changed)
         {
-            msg_Dbg(&vout->obj, "Changing vout format to %4.4s",
-                                (const char *) &p_fmt_current->video.i_chroma);
-            /* Only the chroma changed, request the vout to update the format */
-            ret = vout_SetDisplayFormat(sys->display, &p_fmt_current->video,
-                                        vctx_current);
-            if (ret != VLC_SUCCESS)
-                msg_Dbg(&vout->obj, "Changing vout format to %4.4s failed",
-                        (const char *) &p_fmt_current->video.i_chroma);
+            picture_pool_t *new_private_pool =
+                    picture_pool_NewFromFormat(&p_fmt_current->video,
+                                               FILTER_POOL_SIZE);
+            if (new_private_pool != NULL)
+            {
+                msg_Dbg(&vout->obj, "Changing vout format to %4.4s",
+                                    (const char *) &p_fmt_current->video.i_chroma);
+                /* Only the chroma changed, request the vout to update the format */
+                ret = vout_SetDisplayFormat(sys->display, &p_fmt_current->video,
+                                            vctx_current);
+                if (ret != VLC_SUCCESS)
+                {
+                    picture_pool_Release(new_private_pool);
+                    msg_Dbg(&vout->obj, "Changing vout format to %4.4s failed",
+                            (const char *) &p_fmt_current->video.i_chroma);
+                }
+                else
+                {
+                    // update the pool
+                    picture_pool_Release(sys->private_pool);
+                    sys->private_pool = new_private_pool;
+                }
+            }
         }
 
         if (ret != VLC_SUCCESS)
         {
-            msg_Dbg(&vout->obj, "Adding a filter to compensate for format changes");
+            msg_Dbg(&vout->obj, "Adding a filter to compensate for format changes in interactive chain (%p)",
+                    (void*)sys->filter.chain_interactive);
             if (filter_chain_AppendConverter(sys->filter.chain_interactive,
                                              &fmt_target) != VLC_SUCCESS) {
                 msg_Err(&vout->obj, "Failed to compensate for the format changes, removing all filters");
@@ -1732,12 +1752,8 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
     dcfg.display.width = sys->window_width;
     dcfg.display.height = sys->window_height;
 
-    const unsigned private_picture  = 4; /* XXX 3 for filter, 1 for SPU */
-    const unsigned kept_picture     = 1; /* last displayed picture */
-
     sys->private_pool =
-        picture_pool_NewFromFormat(&sys->original,
-                                   private_picture + kept_picture);
+        picture_pool_NewFromFormat(&sys->original, FILTER_POOL_SIZE);
     if (sys->private_pool == NULL) {
         vlc_queuedmutex_unlock(&sys->display_lock);
         goto error;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fb5cfd5204bdada4a1f2fbe08cec816b424fc513...db905e5c7a1dbdee4c5ef08e452e5e8c9ca2bce8

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