[vlc-devel] [PATCH 4/5] sout: transcode: remove static chain

Steve Lhomme robux4 at ycbcr.xyz
Thu Sep 12 09:02:33 CEST 2019


Nitpicking the commit title should mention it's the converter static 
chain. There's still the p_final_conv_static which is a static chain.

On 2019-09-10 16:11, Francois Cartegnie wrote:
> now the converter does proper transform, there's no
> longer need to force transform last
> ---
>   modules/stream_out/transcode/encoder/video.c |  2 +-
>   modules/stream_out/transcode/transcode.h     |  1 -
>   modules/stream_out/transcode/video.c         | 73 ++++++++------------
>   3 files changed, 30 insertions(+), 46 deletions(-)
> 
> diff --git a/modules/stream_out/transcode/encoder/video.c b/modules/stream_out/transcode/encoder/video.c
> index 670f5b819c..b4baddf95b 100644
> --- a/modules/stream_out/transcode/encoder/video.c
> +++ b/modules/stream_out/transcode/encoder/video.c
> @@ -233,7 +233,7 @@ void transcode_encoder_video_configure( vlc_object_t *p_obj,
>       }
>   
>       /* Complete source format */
> -    p_enc_in->orientation = ORIENT_NORMAL;
> +    p_enc_in->orientation = p_dec_out->orientation;
>       p_enc_out->orientation = p_enc_in->orientation;
>   
>       p_enc_in->i_chroma = p_enc->p_encoder->fmt_in.i_codec;
> diff --git a/modules/stream_out/transcode/transcode.h b/modules/stream_out/transcode/transcode.h
> index f38e4892ad..b981860513 100644
> --- a/modules/stream_out/transcode/transcode.h
> +++ b/modules/stream_out/transcode/transcode.h
> @@ -123,7 +123,6 @@ struct sout_stream_id_sys_t
>            {
>                filter_chain_t  *p_f_chain; /**< Video filters */
>                filter_chain_t  *p_conv_nonstatic;
> -             filter_chain_t  *p_conv_static;
>                filter_chain_t  *p_uf_chain; /**< User-specified video filters */
>                filter_chain_t  *p_final_conv_static;
>                filter_t        *p_spu_blender;
> diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
> index ac9c9c2bcd..772a2e069c 100644
> --- a/modules/stream_out/transcode/video.c
> +++ b/modules/stream_out/transcode/video.c
> @@ -48,7 +48,6 @@ static const video_format_t* filtered_video_format( sout_stream_id_sys_t *id,
>       {
>           id->p_final_conv_static,
>           id->p_uf_chain,
> -        id->p_conv_static,
>           id->p_conv_nonstatic,
>           id->p_f_chain,
>       };
> @@ -252,52 +251,38 @@ static int transcode_video_set_conversions( sout_stream_t *p_stream,
>           .sys = id,
>       };
>   
> -    enum
> -    {
> -        STEP_NONSTATIC = 0,
> -        STEP_STATIC,
> -    };
> -    for( int step = STEP_NONSTATIC; step <= STEP_STATIC; step++ )
> -    {
> -        const bool b_do_scale = (*pp_src)->video.i_width != p_dst->video.i_width ||
> -                                (*pp_src)->video.i_height != p_dst->video.i_height;
> -        const bool b_do_chroma = (*pp_src)->video.i_chroma != p_dst->video.i_chroma;
> -        const bool b_do_orient = ((*pp_src)->video.orientation != ORIENT_NORMAL) && b_reorient;
> -
> -        if( step == STEP_STATIC && b_do_orient )
> -            return VLC_EGENERIC;
> -
> -        const es_format_t *p_tmpdst = p_dst;
> +    const bool b_do_scale = (*pp_src)->video.i_width != p_dst->video.i_width ||
> +                            (*pp_src)->video.i_height != p_dst->video.i_height;
> +    const bool b_do_chroma = (*pp_src)->video.i_chroma != p_dst->video.i_chroma;
> +    const bool b_do_orient = ((*pp_src)->video.orientation != ORIENT_NORMAL) && b_reorient;
>   
> -        if( ! (b_do_scale || b_do_chroma || b_do_orient) )
> -            return VLC_SUCCESS;
> +    const es_format_t *p_tmpdst = p_dst;
>   
> -        es_format_t tmpdst;
> -        if( b_do_orient )
> -        {
> -            es_format_Init( &tmpdst, VIDEO_ES, p_dst->video.i_chroma );
> -            video_format_ApplyRotation( &tmpdst.video, &p_dst->video );
> -            p_tmpdst = &tmpdst;
> -        }
> +    if( ! (b_do_scale || b_do_chroma || b_do_orient) )
> +        return VLC_SUCCESS;
>   
> -        msg_Dbg( p_stream, "adding (scale %d,chroma %d, orient %d) converters",
> -                 b_do_scale, b_do_chroma, b_do_orient );
> +    es_format_t tmpdst;
> +    if( b_do_orient )
> +    {
> +        es_format_Init( &tmpdst, VIDEO_ES, p_dst->video.i_chroma );
> +        video_format_ApplyRotation( &tmpdst.video, &p_dst->video );
> +        p_tmpdst = &tmpdst;
> +    }
>   
> -        filter_chain_t **pp_chain = (step == STEP_NONSTATIC)
> -                ? &id->p_conv_nonstatic
> -                : &id->p_conv_static;
> +    msg_Dbg( p_stream, "adding (scale %d,chroma %d, orient %d) converters",
> +             b_do_scale, b_do_chroma, b_do_orient );
>   
> -        *pp_chain = filter_chain_NewVideo( p_stream, step == STEP_NONSTATIC, &owner );
> -        if( !*pp_chain )
> -            return VLC_EGENERIC;
> -        filter_chain_Reset( *pp_chain, *pp_src, p_tmpdst );
> +    id->p_conv_nonstatic = filter_chain_NewVideo( p_stream, true, &owner );
> +    if( !id->p_conv_nonstatic )
> +        return VLC_EGENERIC;
> +    filter_chain_Reset( id->p_conv_nonstatic, *pp_src, p_tmpdst );
>   
> -        if( filter_chain_AppendConverter( *pp_chain, *pp_src, p_tmpdst ) != VLC_SUCCESS )
> -            return VLC_EGENERIC;
> +    if( filter_chain_AppendConverter( id->p_conv_nonstatic,
> +                                      *pp_src, p_tmpdst ) != VLC_SUCCESS )
> +        return VLC_EGENERIC;
>   
> -        *pp_src = filter_chain_GetFmtOut( *pp_chain );
> -        debug_format( p_stream, *pp_src );
> -    }
> +    *pp_src = filter_chain_GetFmtOut( id->p_conv_nonstatic );
> +    debug_format( p_stream, *pp_src );
>   
>       return VLC_SUCCESS;
>   }
> @@ -360,6 +345,9 @@ static int transcode_video_filters_init( sout_stream_t *p_stream,
>   
>       /* Update encoder so it matches filters output */
>       transcode_encoder_update_format_in( id->encoder, p_src );
> +    es_format_t tmp = *transcode_encoder_format_out(id->encoder);
> +    tmp.video.orientation = p_src->video.orientation;
> +    transcode_encoder_update_format_out( id->encoder, &tmp );
>   
>       /* SPU Sources */
>       if( p_cfg->video.psz_spu_sources )
> @@ -386,7 +374,6 @@ void transcode_video_clean( sout_stream_t *p_stream,
>       /* Close filters */
>       transcode_remove_filters( &id->p_f_chain );
>       transcode_remove_filters( &id->p_conv_nonstatic );
> -    transcode_remove_filters( &id->p_conv_static );
>       transcode_remove_filters( &id->p_uf_chain );
>       transcode_remove_filters( &id->p_final_conv_static );
>       if( id->p_spu_blender )
> @@ -540,7 +527,6 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
>                   /* Close filters, encoder format input can't change */
>                   transcode_remove_filters( &id->p_f_chain );
>                   transcode_remove_filters( &id->p_conv_nonstatic );
> -                transcode_remove_filters( &id->p_conv_static );
>                   transcode_remove_filters( &id->p_uf_chain );
>                   transcode_remove_filters( &id->p_final_conv_static );
>                   if( id->p_spu_blender )
> @@ -602,8 +588,7 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
>           {
>               /* Run filter chain */
>               filter_chain_t * primary_chains[] = { id->p_f_chain,
> -                                                  id->p_conv_nonstatic,
> -                                                  id->p_conv_static };
> +                                                  id->p_conv_nonstatic };
>               for( size_t i=0; p_in && i<ARRAY_SIZE(primary_chains); i++ )
>               {
>                   if( !primary_chains[i] )
> -- 
> 2.21.0
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list