[vlc-devel] [PATCH 1/8] filter_chain: uniform filter_chain_Append{Converter, Filter} return type
RĂ©mi Denis-Courmont
remi at remlab.net
Tue Jun 27 18:54:24 CEST 2017
Nack. There is a reason why converters don't return a pointer. It makes no
sense, since a converter is not named in the pipeline, and should never have a
callback variable.
All you need to know is whether the conversion is supported or is not.
On mardi 27 juin 2017 17:38:41 EEST Victorien Le Couviour--Tuffet wrote:
> ---
> include/vlc_filter.h | 5 ++---
> modules/stream_out/transcode/video.c | 2 +-
> modules/video_chroma/chain.c | 10 +++++-----
> src/misc/filter_chain.c | 4 ++--
> src/video_output/display.c | 3 ++-
> src/video_output/video_output.c | 4 ++--
> 6 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/include/vlc_filter.h b/include/vlc_filter.h
> index a3ecc2c1b3..3db7281671 100644
> --- a/include/vlc_filter.h
> +++ b/include/vlc_filter.h
> @@ -330,10 +330,9 @@ VLC_API filter_t
> *filter_chain_AppendFilter(filter_chain_t *chain, * \param chain filter
> chain to append a filter to
> * \param fmt_in filter input format
> * \param fmt_out filter output format
> - * \retval 0 on success
> - * \retval -1 on failure
> + * \return a pointer to the filter or NULL on error
> */
> -VLC_API int filter_chain_AppendConverter(filter_chain_t *chain,
> +VLC_API filter_t *filter_chain_AppendConverter(filter_chain_t *chain,
> const es_format_t *fmt_in, const es_format_t *fmt_out);
>
> /**
> diff --git a/modules/stream_out/transcode/video.c
> b/modules/stream_out/transcode/video.c index 50b21bc0ff..b4bc000db3 100644
> --- a/modules/stream_out/transcode/video.c
> +++ b/modules/stream_out/transcode/video.c
> @@ -69,7 +69,7 @@ static int video_update_format_decoder( decoder_t *p_dec )
> filter_chain_Reset( test_chain, &p_dec->fmt_out, &p_dec->fmt_out );
>
> int chain_works = filter_chain_AppendConverter( test_chain,
> &p_dec->fmt_out, - &id->p_encoder->fmt_in
> );
> + &id->p_encoder->fmt_in
> ) != NULL ? 0 : -1; filter_chain_Delete( test_chain );
> msg_Dbg( stream, "Filter chain testing done, input chroma %4.4s seems
> to be %s for transcode", (char *)&p_dec->fmt_out.video.i_chroma,
> diff --git a/modules/video_chroma/chain.c b/modules/video_chroma/chain.c
> index be4c26e611..eb20daa817 100644
> --- a/modules/video_chroma/chain.c
> +++ b/modules/video_chroma/chain.c
> @@ -310,7 +310,7 @@ static int BuildFilterChain( filter_t *p_filter )
> video_format_FixRgb(&fmt_mid.video);
>
> if( filter_chain_AppendConverter( p_filter->p_sys->p_chain,
> - NULL, &fmt_mid ) == VLC_SUCCESS )
> + NULL, &fmt_mid ) )
> {
> if( filter_chain_AppendFilter( p_filter->p_sys->p_chain,
> p_filter->psz_name,
> p_filter->p_cfg, @@ -355,8 +355,8 @@ static int CreateChain( filter_t
> *p_parent, es_format_t *p_fmt_mid ) }
> else
> {
> - if( filter_chain_AppendConverter( p_parent->p_sys->p_chain,
> - NULL, p_fmt_mid ) )
> + if( !filter_chain_AppendConverter( p_parent->p_sys->p_chain,
> + NULL, p_fmt_mid ) )
> return VLC_EGENERIC;
> }
>
> @@ -368,8 +368,8 @@ static int CreateChain( filter_t *p_parent, es_format_t
> *p_fmt_mid ) }
> else
> {
> - if( filter_chain_AppendConverter( p_parent->p_sys->p_chain,
> - p_fmt_mid, NULL ) )
> + if( !filter_chain_AppendConverter( p_parent->p_sys->p_chain,
> + p_fmt_mid, NULL ) )
> goto error;
> }
> return VLC_SUCCESS;
> diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
> index 741a63c9ad..7e038dbbb8 100644
> --- a/src/misc/filter_chain.c
> +++ b/src/misc/filter_chain.c
> @@ -274,11 +274,11 @@ filter_t *filter_chain_AppendFilter( filter_chain_t
> *chain, fmt_in, fmt_out );
> }
>
> -int filter_chain_AppendConverter( filter_chain_t *chain,
> +filter_t *filter_chain_AppendConverter( filter_chain_t *chain,
> const es_format_t *fmt_in, const es_format_t *fmt_out )
> {
> return filter_chain_AppendInner( chain, NULL, chain->conv_cap, NULL,
> - fmt_in, fmt_out ) != NULL ? 0 : -1;
> + fmt_in, fmt_out );
> }
>
> void filter_chain_DeleteFilter( filter_chain_t *chain, filter_t *filter )
> diff --git a/src/video_output/display.c b/src/video_output/display.c
> index aaa24b053d..57210df5fd 100644
> --- a/src/video_output/display.c
> +++ b/src/video_output/display.c
> @@ -462,7 +462,8 @@ static int VoutDisplayCreateRender(vout_display_t *vd)
> es_format_InitFromVideo(&dst, i == 0 ? &v_dst : &v_dst_cmp);
>
> filter_chain_Reset(osys->filters, &src, &dst);
> - ret = filter_chain_AppendConverter(osys->filters, &src, &dst);
> + ret = filter_chain_AppendConverter(osys->filters, &src, &dst)
> + != NULL ? 0 : -1;
> es_format_Clean(&dst);
> if (ret == 0)
> break;
> diff --git a/src/video_output/video_output.c
> b/src/video_output/video_output.c index c1ddc6a4d5..e46859ddd1 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -854,8 +854,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_AppendConverter(vout->p->filter.chain_interactive,
> - &fmt_current, &fmt_target) != 0)
> { + 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"); ThreadDelAllFilterCallbacks(vout);
> filter_chain_Reset(vout->p->filter.chain_static,
> &fmt_target, &fmt_target);
More information about the vlc-devel
mailing list