[vlc-commits] Use filter_chain_AppendConverter() as appropriate

Rémi Denis-Courmont git at videolan.org
Mon Dec 12 19:53:40 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Aug 26 18:31:29 2016 +0300| [26cefe733f7566b4612a6c1bcc743540f45b0aa6] | committer: Rémi Denis-Courmont

Use filter_chain_AppendConverter() as appropriate

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=26cefe733f7566b4612a6c1bcc743540f45b0aa6
---

 modules/stream_out/transcode/video.c | 12 ++++--------
 modules/video_chroma/chain.c         | 36 ++++++++++++++++++------------------
 modules/video_filter/canvas.c        |  2 +-
 src/video_output/display.c           | 13 ++++++-------
 src/video_output/video_output.c      |  4 ++--
 5 files changed, 31 insertions(+), 36 deletions(-)

diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 19ba497..d93c249 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -299,10 +299,8 @@ static void transcode_video_filter_init( sout_stream_t *p_stream,
                             &id->p_encoder->fmt_in );
         if( p_fmt_out->video.i_chroma != id->p_encoder->fmt_in.video.i_chroma )
         {
-            filter_chain_AppendFilter( id->p_uf_chain,
-                                   NULL, NULL,
-                                   p_fmt_out,
-                                   &id->p_encoder->fmt_in );
+            filter_chain_AppendConverter( id->p_uf_chain, p_fmt_out,
+                                           &id->p_encoder->fmt_in );
         }
         filter_chain_AppendFromString( id->p_uf_chain, p_stream->p_sys->psz_vf2 );
         p_fmt_out = filter_chain_GetFmtOut( id->p_uf_chain );
@@ -338,10 +336,8 @@ static void conversion_video_filter_append( sout_stream_id_sys_t *id )
         ( p_fmt_out->video.i_width != id->p_encoder->fmt_in.video.i_width ) ||
         ( p_fmt_out->video.i_height != id->p_encoder->fmt_in.video.i_height ) )
     {
-        filter_chain_AppendFilter( id->p_uf_chain ? id->p_uf_chain : id->p_f_chain,
-                                   NULL, NULL,
-                                   p_fmt_out,
-                                   &id->p_encoder->fmt_in );
+        filter_chain_AppendConverter( id->p_uf_chain ? id->p_uf_chain : id->p_f_chain,
+                                      p_fmt_out, &id->p_encoder->fmt_in );
     }
 }
 
diff --git a/modules/video_chroma/chain.c b/modules/video_chroma/chain.c
index 46560fe..55623e2 100644
--- a/modules/video_chroma/chain.c
+++ b/modules/video_chroma/chain.c
@@ -275,36 +275,36 @@ static int CreateChain( filter_t *p_parent, es_format_t *p_fmt_mid )
     if( p_parent->fmt_in.video.orientation != p_fmt_mid->video.orientation)
     {
         p_filter = AppendTransform( p_parent->p_sys->p_chain, &p_parent->fmt_in, p_fmt_mid );
+        // Check if filter was enough:
+        if( es_format_IsSimilar(&p_filter->fmt_out, &p_parent->fmt_out ))
+           return VLC_SUCCESS;
+        if( p_filter == NULL )
+            return VLC_EGENERIC;
     }
     else
     {
-        p_filter = filter_chain_AppendFilter( p_parent->p_sys->p_chain, NULL, NULL, NULL, p_fmt_mid );
+        if( filter_chain_AppendConverter( p_parent->p_sys->p_chain,
+                                          NULL, p_fmt_mid ) )
+            return VLC_EGENERIC;
     }
 
-    if( !p_filter )
-        return VLC_EGENERIC;
-
-    //Check if first filter was enough (transform filter most likely):
-    if( es_format_IsSimilar(&p_filter->fmt_out, &p_parent->fmt_out ))
-       return VLC_SUCCESS;
-
     if( p_fmt_mid->video.orientation != p_parent->fmt_out.video.orientation)
     {
-        p_filter = AppendTransform( p_parent->p_sys->p_chain, p_fmt_mid, &p_parent->fmt_out );
+        if( AppendTransform( p_parent->p_sys->p_chain, p_fmt_mid,
+                             &p_parent->fmt_out ) == NULL )
+            goto error;
     }
     else
     {
-        p_filter = filter_chain_AppendFilter( p_parent->p_sys->p_chain, NULL, NULL, p_fmt_mid, NULL );
+        if( filter_chain_AppendConverter( p_parent->p_sys->p_chain,
+                                          p_fmt_mid, NULL ) )
+            goto error;
     }
-
-    if( !p_filter )
-    {
-        //Clean up.
-        filter_chain_Reset( p_parent->p_sys->p_chain, NULL, NULL );
-        return VLC_EGENERIC;
-    }
-
     return VLC_SUCCESS;
+error:
+    //Clean up.
+    filter_chain_Reset( p_parent->p_sys->p_chain, NULL, NULL );
+    return VLC_EGENERIC;
 }
 
 static filter_t * AppendTransform( filter_chain_t *p_chain, es_format_t *p_fmt1, es_format_t *p_fmt2 )
diff --git a/modules/video_filter/canvas.c b/modules/video_filter/canvas.c
index b0d7d32..b3096d2 100644
--- a/modules/video_filter/canvas.c
+++ b/modules/video_filter/canvas.c
@@ -330,7 +330,7 @@ static int Activate( vlc_object_t *p_this )
 
     filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, &fmt );
     /* Append scaling module */
-    if ( !filter_chain_AppendFilter( p_sys->p_chain, NULL, NULL, NULL, NULL ) )
+    if ( !filter_chain_AppendConverter( p_sys->p_chain, NULL, NULL ) )
     {
         msg_Err( p_filter, "Could not append scaling filter" );
         free( p_sys );
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 19bd459..f550dd0 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -466,28 +466,27 @@ static int VoutDisplayCreateRender(vout_display_t *vd)
     es_format_InitFromVideo(&src, &v_src);
 
     /* */
-    filter_t *filter;
+    int ret;
+
     for (int i = 0; i < 1 + (v_dst_cmp.i_chroma != v_dst.i_chroma); i++) {
         es_format_t dst;
 
         es_format_InitFromVideo(&dst, i == 0 ? &v_dst : &v_dst_cmp);
 
         filter_chain_Reset(osys->filters, &src, &dst);
-        filter = filter_chain_AppendFilter(osys->filters,
-                                           NULL, NULL, &src, &dst);
+        ret = filter_chain_AppendConverter(osys->filters, &src, &dst);
         es_format_Clean(&dst);
-        if (filter)
+        if (ret == 0)
             break;
     }
     es_format_Clean(&src);
 
-    if (filter == NULL) {
+    if (ret != 0) {
         msg_Err(vd, "Failed to adapt decoder format to display");
         filter_chain_Delete(osys->filters);
         osys->filters = NULL;
-        return -1;
     }
-    return 0;
+    return ret;
 }
 
 static void VoutDisplayDestroyRender(vout_display_t *vd)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index bb7d72c..cde3808 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -769,8 +769,8 @@ static void ThreadChangeFilters(vout_thread_t *vout,
 
     if (!es_format_IsSimilar(&fmt_current, &fmt_target)) {
         msg_Dbg(vout, "Adding a filter to compensate for format changes");
-        if (!filter_chain_AppendFilter(vout->p->filter.chain_interactive, NULL, NULL,
-                                       &fmt_current, &fmt_target)) {
+        if (!filter_chain_AppendConverter(vout->p->filter.chain_interactive,
+                                          &fmt_current, &fmt_target)) {
             msg_Err(vout, "Failed to compensate for the format changes, removing all filters");
             filter_chain_Reset(vout->p->filter.chain_static,      &fmt_target, &fmt_target);
             filter_chain_Reset(vout->p->filter.chain_interactive, &fmt_target, &fmt_target);



More information about the vlc-commits mailing list