Commit 26cefe73 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use filter_chain_AppendConverter() as appropriate

parent e7eaa33c
......@@ -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 );
}
}
......
......@@ -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 )
......
......@@ -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 );
......
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment