Skip to content

Commit 26cefe7

Browse files
author
Rémi Denis-Courmont
committed
Use filter_chain_AppendConverter() as appropriate
1 parent e7eaa33 commit 26cefe7

File tree

5 files changed

+31
-36
lines changed

5 files changed

+31
-36
lines changed

modules/stream_out/transcode/video.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,8 @@ static void transcode_video_filter_init( sout_stream_t *p_stream,
299299
&id->p_encoder->fmt_in );
300300
if( p_fmt_out->video.i_chroma != id->p_encoder->fmt_in.video.i_chroma )
301301
{
302-
filter_chain_AppendFilter( id->p_uf_chain,
303-
NULL, NULL,
304-
p_fmt_out,
305-
&id->p_encoder->fmt_in );
302+
filter_chain_AppendConverter( id->p_uf_chain, p_fmt_out,
303+
&id->p_encoder->fmt_in );
306304
}
307305
filter_chain_AppendFromString( id->p_uf_chain, p_stream->p_sys->psz_vf2 );
308306
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 )
338336
( p_fmt_out->video.i_width != id->p_encoder->fmt_in.video.i_width ) ||
339337
( p_fmt_out->video.i_height != id->p_encoder->fmt_in.video.i_height ) )
340338
{
341-
filter_chain_AppendFilter( id->p_uf_chain ? id->p_uf_chain : id->p_f_chain,
342-
NULL, NULL,
343-
p_fmt_out,
344-
&id->p_encoder->fmt_in );
339+
filter_chain_AppendConverter( id->p_uf_chain ? id->p_uf_chain : id->p_f_chain,
340+
p_fmt_out, &id->p_encoder->fmt_in );
345341
}
346342
}
347343

modules/video_chroma/chain.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -275,36 +275,36 @@ static int CreateChain( filter_t *p_parent, es_format_t *p_fmt_mid )
275275
if( p_parent->fmt_in.video.orientation != p_fmt_mid->video.orientation)
276276
{
277277
p_filter = AppendTransform( p_parent->p_sys->p_chain, &p_parent->fmt_in, p_fmt_mid );
278+
// Check if filter was enough:
279+
if( es_format_IsSimilar(&p_filter->fmt_out, &p_parent->fmt_out ))
280+
return VLC_SUCCESS;
281+
if( p_filter == NULL )
282+
return VLC_EGENERIC;
278283
}
279284
else
280285
{
281-
p_filter = filter_chain_AppendFilter( p_parent->p_sys->p_chain, NULL, NULL, NULL, p_fmt_mid );
286+
if( filter_chain_AppendConverter( p_parent->p_sys->p_chain,
287+
NULL, p_fmt_mid ) )
288+
return VLC_EGENERIC;
282289
}
283290

284-
if( !p_filter )
285-
return VLC_EGENERIC;
286-
287-
//Check if first filter was enough (transform filter most likely):
288-
if( es_format_IsSimilar(&p_filter->fmt_out, &p_parent->fmt_out ))
289-
return VLC_SUCCESS;
290-
291291
if( p_fmt_mid->video.orientation != p_parent->fmt_out.video.orientation)
292292
{
293-
p_filter = AppendTransform( p_parent->p_sys->p_chain, p_fmt_mid, &p_parent->fmt_out );
293+
if( AppendTransform( p_parent->p_sys->p_chain, p_fmt_mid,
294+
&p_parent->fmt_out ) == NULL )
295+
goto error;
294296
}
295297
else
296298
{
297-
p_filter = filter_chain_AppendFilter( p_parent->p_sys->p_chain, NULL, NULL, p_fmt_mid, NULL );
299+
if( filter_chain_AppendConverter( p_parent->p_sys->p_chain,
300+
p_fmt_mid, NULL ) )
301+
goto error;
298302
}
299-
300-
if( !p_filter )
301-
{
302-
//Clean up.
303-
filter_chain_Reset( p_parent->p_sys->p_chain, NULL, NULL );
304-
return VLC_EGENERIC;
305-
}
306-
307303
return VLC_SUCCESS;
304+
error:
305+
//Clean up.
306+
filter_chain_Reset( p_parent->p_sys->p_chain, NULL, NULL );
307+
return VLC_EGENERIC;
308308
}
309309

310310
static filter_t * AppendTransform( filter_chain_t *p_chain, es_format_t *p_fmt1, es_format_t *p_fmt2 )

modules/video_filter/canvas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static int Activate( vlc_object_t *p_this )
330330

331331
filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, &fmt );
332332
/* Append scaling module */
333-
if ( !filter_chain_AppendFilter( p_sys->p_chain, NULL, NULL, NULL, NULL ) )
333+
if ( !filter_chain_AppendConverter( p_sys->p_chain, NULL, NULL ) )
334334
{
335335
msg_Err( p_filter, "Could not append scaling filter" );
336336
free( p_sys );

src/video_output/display.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,28 +466,27 @@ static int VoutDisplayCreateRender(vout_display_t *vd)
466466
es_format_InitFromVideo(&src, &v_src);
467467

468468
/* */
469-
filter_t *filter;
469+
int ret;
470+
470471
for (int i = 0; i < 1 + (v_dst_cmp.i_chroma != v_dst.i_chroma); i++) {
471472
es_format_t dst;
472473

473474
es_format_InitFromVideo(&dst, i == 0 ? &v_dst : &v_dst_cmp);
474475

475476
filter_chain_Reset(osys->filters, &src, &dst);
476-
filter = filter_chain_AppendFilter(osys->filters,
477-
NULL, NULL, &src, &dst);
477+
ret = filter_chain_AppendConverter(osys->filters, &src, &dst);
478478
es_format_Clean(&dst);
479-
if (filter)
479+
if (ret == 0)
480480
break;
481481
}
482482
es_format_Clean(&src);
483483

484-
if (filter == NULL) {
484+
if (ret != 0) {
485485
msg_Err(vd, "Failed to adapt decoder format to display");
486486
filter_chain_Delete(osys->filters);
487487
osys->filters = NULL;
488-
return -1;
489488
}
490-
return 0;
489+
return ret;
491490
}
492491

493492
static void VoutDisplayDestroyRender(vout_display_t *vd)

src/video_output/video_output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,8 @@ static void ThreadChangeFilters(vout_thread_t *vout,
769769

770770
if (!es_format_IsSimilar(&fmt_current, &fmt_target)) {
771771
msg_Dbg(vout, "Adding a filter to compensate for format changes");
772-
if (!filter_chain_AppendFilter(vout->p->filter.chain_interactive, NULL, NULL,
773-
&fmt_current, &fmt_target)) {
772+
if (!filter_chain_AppendConverter(vout->p->filter.chain_interactive,
773+
&fmt_current, &fmt_target)) {
774774
msg_Err(vout, "Failed to compensate for the format changes, removing all filters");
775775
filter_chain_Reset(vout->p->filter.chain_static, &fmt_target, &fmt_target);
776776
filter_chain_Reset(vout->p->filter.chain_interactive, &fmt_target, &fmt_target);

0 commit comments

Comments
 (0)