Use filter_chain_AppendConverter() as appropriate
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 26 Aug 2016 15:31:29 +0000 (18:31 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 12 Dec 2016 18:51:32 +0000 (20:51 +0200)
modules/stream_out/transcode/video.c
modules/video_chroma/chain.c
modules/video_filter/canvas.c
src/video_output/display.c
src/video_output/video_output.c

index 19ba497..d93c249 100644 (file)
@@ -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 );
     }
 }
 
index 46560fe..55623e2 100644 (file)
@@ -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 )
index b0d7d32..b3096d2 100644 (file)
@@ -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 );
index 19bd459..f550dd0 100644 (file)
@@ -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)
index bb7d72c..cde3808 100644 (file)
@@ -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);