[vlc-devel] [PATCH 17/19] filter_chain: keep the input video context
Steve Lhomme
robux4 at ycbcr.xyz
Tue Nov 5 16:18:44 CET 2019
It will be passed to the first filter when it's created.
Add function to get the output video context similar to how we get the output
video format.
---
include/vlc_filter.h | 11 +++++--
modules/stream_out/mosaic_bridge.c | 8 +++--
modules/stream_out/sdi/SDIStream.cpp | 8 ++---
modules/stream_out/sdi/SDIStream.hpp | 2 +-
modules/stream_out/transcode/video.c | 24 +++++++++------
modules/video_chroma/chain.c | 46 +++++++++++++++-------------
modules/video_filter/canvas.c | 4 +--
modules/video_filter/edgedetection.c | 2 +-
src/misc/filter_chain.c | 29 +++++++++++++-----
src/video_output/display.c | 4 +--
src/video_output/video_output.c | 12 ++++----
11 files changed, 91 insertions(+), 59 deletions(-)
diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 7ccf271d794..8a3bc6290c2 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -359,7 +359,10 @@ VLC_API void filter_chain_Delete( filter_chain_t * );
* \param p_fmt_in new fmt_in params
* \param p_fmt_out new fmt_out params
*/
-VLC_API void filter_chain_Reset( filter_chain_t *, const es_format_t *, const es_format_t * );
+VLC_API void filter_chain_Reset( filter_chain_t *,
+ const es_format_t *,
+ vlc_video_context *vctx_in,
+ const es_format_t * );
/**
* Remove all existing filters
@@ -378,7 +381,8 @@ VLC_API void filter_chain_Clear(filter_chain_t *);
* \return a pointer to the filter or NULL on error
*/
VLC_API filter_t *filter_chain_AppendFilter(filter_chain_t *chain,
- const char *name, config_chain_t *cfg, const es_format_t *fmt_in,
+ const char *name, config_chain_t *cfg,
+ const es_format_t *fmt_in, vlc_video_context *vctx_in,
const es_format_t *fmt_out);
/**
@@ -391,7 +395,8 @@ VLC_API filter_t *filter_chain_AppendFilter(filter_chain_t *chain,
* \retval -1 on failure
*/
VLC_API int filter_chain_AppendConverter(filter_chain_t *chain,
- const es_format_t *fmt_in, const es_format_t *fmt_out);
+ const es_format_t *fmt_in, vlc_video_context *vctx_in,
+ const es_format_t *fmt_out);
/**
* Append new filter to filter chain from string.
diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c
index 268a9588e75..4f51ad46b94 100644
--- a/modules/stream_out/mosaic_bridge.c
+++ b/modules/stream_out/mosaic_bridge.c
@@ -420,9 +420,13 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
// at this point the decoder may not have called video_update_format_decoder()
// so we don't know the actual decoder format yet
es_format_Copy( &fmt, &p_sys->p_decoder->fmt_out );
+ vlc_video_context *vctx = NULL; // TODO p_sys->p_decoder->vctx_out;
if( p_sys->i_chroma )
+ {
fmt.video.i_chroma = p_sys->i_chroma;
- filter_chain_Reset( p_sys->p_vf2, &fmt, &fmt );
+ vctx = NULL;
+ }
+ filter_chain_Reset( p_sys->p_vf2, &fmt, vctx, &fmt );
es_format_Clean( &fmt );
filter_chain_AppendFromString( p_sys->p_vf2, psz_chain );
}
@@ -607,7 +611,7 @@ static int video_update_format_decoder( decoder_t *p_dec, vlc_video_context *vct
es_format_InitFromVideo( &fmt, &p_dec->fmt_out.video );
if( p_sys->i_chroma )
fmt.video.i_chroma = p_sys->i_chroma;
- filter_chain_Reset( p_sys->p_vf2, &fmt, &fmt );
+ filter_chain_Reset( p_sys->p_vf2, &fmt, vctx, &fmt );
es_format_Clean( &fmt );
filter_chain_AppendFromString( p_sys->p_vf2, psz_chain );
free( psz_chain );
diff --git a/modules/stream_out/sdi/SDIStream.cpp b/modules/stream_out/sdi/SDIStream.cpp
index 03ef5c3a8ad..dba001579f6 100644
--- a/modules/stream_out/sdi/SDIStream.cpp
+++ b/modules/stream_out/sdi/SDIStream.cpp
@@ -541,7 +541,7 @@ static const struct filter_video_callbacks transcode_filter_video_cbs =
transcode_video_filter_buffer_new,
};
-filter_chain_t * VideoDecodedStream::VideoFilterCreate(const es_format_t *p_srcfmt)
+filter_chain_t * VideoDecodedStream::VideoFilterCreate(const es_format_t *p_srcfmt, vlc_video_context *vctx)
{
filter_chain_t *p_chain;
filter_owner_t owner;
@@ -551,11 +551,11 @@ filter_chain_t * VideoDecodedStream::VideoFilterCreate(const es_format_t *p_srcf
p_chain = filter_chain_NewVideo(p_stream, false, &owner);
if(!p_chain)
return NULL;
- filter_chain_Reset(p_chain, p_srcfmt, &requestedoutput);
+ filter_chain_Reset(p_chain, p_srcfmt, vctx, &requestedoutput);
if(p_srcfmt->video.i_chroma != requestedoutput.video.i_chroma)
{
- if(filter_chain_AppendConverter(p_chain, p_srcfmt, &requestedoutput) != VLC_SUCCESS)
+ if(filter_chain_AppendConverter(p_chain, p_srcfmt, vctx, &requestedoutput) != VLC_SUCCESS)
{
filter_chain_Delete(p_chain);
return NULL;
@@ -585,7 +585,7 @@ void VideoDecodedStream::Output(picture_t *p_pic)
if(p_filters_chain)
filter_chain_Delete(p_filters_chain);
- p_filters_chain = VideoFilterCreate(&p_owner->last_fmt_update);
+ p_filters_chain = VideoFilterCreate(&p_owner->last_fmt_update, p_owner->last_fmt_vctx);
if(!p_filters_chain)
{
picture_Release(p_pic);
diff --git a/modules/stream_out/sdi/SDIStream.hpp b/modules/stream_out/sdi/SDIStream.hpp
index 03c3f57db12..1eb624e12ae 100644
--- a/modules/stream_out/sdi/SDIStream.hpp
+++ b/modules/stream_out/sdi/SDIStream.hpp
@@ -170,7 +170,7 @@ namespace sdi_sout
const decoder_cc_desc_t * );
static vlc_decoder_device * VideoDecCallback_get_device(decoder_t *);
static int VideoDecCallback_update_format(decoder_t *, vlc_video_context *);
- filter_chain_t * VideoFilterCreate(const es_format_t *);
+ filter_chain_t * VideoFilterCreate(const es_format_t *, vlc_video_context *);
virtual void ReleaseDecoder();
void Output(picture_t *);
void QueueCC(block_t *);
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 0b2362f7b6f..949be0b91e6 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -109,9 +109,9 @@ static int video_update_format_decoder( decoder_t *p_dec, vlc_video_context *vct
msg_Dbg( p_obj, "Checking if filter chain %4.4s -> %4.4s is possible",
(char *)&p_dec->fmt_out.i_codec, (char*)&p_enc_in->i_codec );
test_chain = filter_chain_NewVideo( p_obj, false, NULL );
- filter_chain_Reset( test_chain, &p_dec->fmt_out, &p_dec->fmt_out );
+ filter_chain_Reset( test_chain, &p_dec->fmt_out, vctx, &p_dec->fmt_out );
- int chain_works = filter_chain_AppendConverter( test_chain, &p_dec->fmt_out, p_enc_in );
+ int chain_works = filter_chain_AppendConverter( test_chain, &p_dec->fmt_out, vctx, p_enc_in );
filter_chain_Delete( test_chain );
msg_Dbg( p_obj, "Filter chain testing done, input chroma %4.4s seems to be %s for transcode",
@@ -252,6 +252,7 @@ static const struct filter_video_callbacks transcode_filter_video_cbs =
static int transcode_video_set_conversions( sout_stream_t *p_stream,
sout_stream_id_sys_t *id,
const es_format_t **pp_src,
+ vlc_video_context **pp_src_vctx,
const es_format_t *p_dst,
bool b_reorient )
{
@@ -298,12 +299,13 @@ static int transcode_video_set_conversions( sout_stream_t *p_stream,
*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 );
+ filter_chain_Reset( *pp_chain, *pp_src, *pp_src_vctx, p_tmpdst );
- if( filter_chain_AppendConverter( *pp_chain, *pp_src, p_tmpdst ) != VLC_SUCCESS )
+ if( filter_chain_AppendConverter( *pp_chain, *pp_src, *pp_src_vctx, p_tmpdst ) != VLC_SUCCESS )
return VLC_EGENERIC;
*pp_src = filter_chain_GetFmtOut( *pp_chain );
+ *pp_src_vctx = NULL /* TODO */;
debug_format( p_stream, *pp_src );
}
@@ -319,6 +321,7 @@ static int transcode_video_filters_init( sout_stream_t *p_stream,
const sout_filters_config_t *p_cfg,
bool b_master_sync,
const es_format_t *p_src,
+ vlc_video_context *src_ctx,
const es_format_t *p_dst,
sout_stream_id_sys_t *id )
{
@@ -330,7 +333,7 @@ static int transcode_video_filters_init( sout_stream_t *p_stream,
id->p_f_chain = filter_chain_NewVideo( p_stream, false, &owner );
if( !id->p_f_chain )
return VLC_EGENERIC;
- filter_chain_Reset( id->p_f_chain, p_src, p_src );
+ filter_chain_Reset( id->p_f_chain, p_src, src_ctx, p_src );
/* Deinterlace */
if( p_cfg->video.psz_deinterlace != NULL )
@@ -338,18 +341,20 @@ static int transcode_video_filters_init( sout_stream_t *p_stream,
filter_chain_AppendFilter( id->p_f_chain,
p_cfg->video.psz_deinterlace,
p_cfg->video.p_deinterlace_cfg,
- p_src, p_src );
+ p_src, src_ctx, p_src );
p_src = filter_chain_GetFmtOut( id->p_f_chain );
+ src_ctx = NULL /* TODO */;
}
if( b_master_sync )
{
- filter_chain_AppendFilter( id->p_f_chain, "fps", NULL, p_src, p_dst );
+ filter_chain_AppendFilter( id->p_f_chain, "fps", NULL, p_src, src_ctx, p_dst );
p_src = filter_chain_GetFmtOut( id->p_f_chain );
+ src_ctx = NULL /* TODO */;
}
/* Chroma and other conversions */
- if( transcode_video_set_conversions( p_stream, id, &p_src, p_dst,
+ if( transcode_video_set_conversions( p_stream, id, &p_src, &src_ctx, p_dst,
p_cfg->video.b_reorient ) != VLC_SUCCESS )
return VLC_EGENERIC;
@@ -360,7 +365,7 @@ static int transcode_video_filters_init( sout_stream_t *p_stream,
id->p_uf_chain = filter_chain_NewVideo( p_stream, true, &owner );
if(!id->p_uf_chain)
return VLC_EGENERIC;
- filter_chain_Reset( id->p_uf_chain, p_src, p_dst );
+ filter_chain_Reset( id->p_uf_chain, p_src, src_ctx, p_dst );
filter_chain_AppendFromString( id->p_uf_chain, p_cfg->psz_filters );
p_src = filter_chain_GetFmtOut( id->p_uf_chain );
debug_format( p_stream, p_src );
@@ -567,6 +572,7 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
id->p_filterscfg,
(id->p_enccfg->video.fps.num > 0),
&tmpfmt,
+ NULL /* TODO */,
transcode_encoder_format_in( id->encoder ),
id ) != VLC_SUCCESS )
goto error;
diff --git a/modules/video_chroma/chain.c b/modules/video_chroma/chain.c
index f87e30a4aaa..66dd2559711 100644
--- a/modules/video_chroma/chain.c
+++ b/modules/video_chroma/chain.c
@@ -60,9 +60,10 @@ static int BuildChromaResize( filter_t * );
static int BuildChromaChain( filter_t *p_filter );
static int BuildFilterChain( filter_t *p_filter );
-static int CreateChain( filter_t *p_filter, const es_format_t *p_fmt_mid );
+static int CreateChain( filter_t *p_filter, const es_format_t *p_fmt_mid, vlc_video_context *vctx_mid );
static int CreateResizeChromaChain( filter_t *p_filter, const es_format_t *p_fmt_mid );
-static filter_t * AppendTransform( filter_chain_t *p_chain, const es_format_t *p_fmt_in,
+static filter_t * AppendTransform( filter_chain_t *p_chain,
+ const es_format_t *p_fmt_in, vlc_video_context *vctx_in,
const es_format_t *p_fmt_out );
static void EsFormatMergeSize( es_format_t *p_dst,
const es_format_t *p_base,
@@ -279,7 +280,7 @@ static int BuildTransformChain( filter_t *p_filter )
msg_Dbg( p_filter, "Trying to build transform, then chroma+resize" );
es_format_Copy( &fmt_mid, &p_filter->fmt_in );
video_format_TransformTo(&fmt_mid.video, p_filter->fmt_out.video.orientation);
- i_ret = CreateChain( p_filter, &fmt_mid );
+ i_ret = CreateChain( p_filter, &fmt_mid, p_filter->vctx_in );
es_format_Clean( &fmt_mid );
if( i_ret == VLC_SUCCESS )
return VLC_SUCCESS;
@@ -287,7 +288,7 @@ static int BuildTransformChain( filter_t *p_filter )
/* Lets try resize+chroma first, then transform */
msg_Dbg( p_filter, "Trying to build chroma+resize" );
EsFormatMergeSize( &fmt_mid, &p_filter->fmt_out, &p_filter->fmt_in );
- i_ret = CreateChain( p_filter, &fmt_mid );
+ i_ret = CreateChain( p_filter, &fmt_mid, p_filter->vctx_in );
es_format_Clean( &fmt_mid );
return i_ret;
}
@@ -309,7 +310,7 @@ static int BuildChromaResize( filter_t *p_filter )
/* Lets try it the other way arround (chroma and then resize) */
msg_Dbg( p_filter, "Trying to build chroma+resize" );
EsFormatMergeSize( &fmt_mid, &p_filter->fmt_out, &p_filter->fmt_in );
- i_ret = CreateChain( p_filter, &fmt_mid );
+ i_ret = CreateChain( p_filter, &fmt_mid, p_filter->vctx_in );
es_format_Clean( &fmt_mid );
if( i_ret == VLC_SUCCESS )
return VLC_SUCCESS;
@@ -342,7 +343,7 @@ static int BuildChromaChain( filter_t *p_filter )
fmt_mid.video.i_bmask = 0;
video_format_FixRgb(&fmt_mid.video);
- i_ret = CreateChain( p_filter, &fmt_mid );
+ i_ret = CreateChain( p_filter, &fmt_mid, NULL );
es_format_Clean( &fmt_mid );
if( i_ret == VLC_SUCCESS )
@@ -371,7 +372,7 @@ static int BuildFilterChain( filter_t *p_filter )
const vlc_fourcc_t *pi_allowed_chromas = get_allowed_chromas( p_filter );
for( int i = 0; pi_allowed_chromas[i]; i++ )
{
- filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, &p_filter->fmt_out );
+ filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, p_filter->vctx_in, &p_filter->fmt_out );
const vlc_fourcc_t i_chroma = pi_allowed_chromas[i];
if( i_chroma == p_filter->fmt_in.i_codec ||
@@ -390,12 +391,12 @@ static int BuildFilterChain( filter_t *p_filter )
video_format_FixRgb(&fmt_mid.video);
if( filter_chain_AppendConverter( p_sys->p_chain,
- NULL, &fmt_mid ) == VLC_SUCCESS )
+ NULL, NULL, &fmt_mid ) == VLC_SUCCESS )
{
p_sys->p_video_filter =
filter_chain_AppendFilter( p_sys->p_chain,
p_filter->psz_name, p_filter->p_cfg,
- &fmt_mid, &fmt_mid );
+ &fmt_mid, p_filter->vctx_in, &fmt_mid );
if( p_sys->p_video_filter )
{
filter_AddProxyCallbacks( p_filter,
@@ -411,7 +412,7 @@ static int BuildFilterChain( filter_t *p_filter )
es_format_Clean( &fmt_mid );
}
if( i_ret != VLC_SUCCESS )
- filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, &p_filter->fmt_out );
+ filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, p_filter->vctx_in, &p_filter->fmt_out );
return i_ret;
}
@@ -419,14 +420,14 @@ static int BuildFilterChain( filter_t *p_filter )
/*****************************************************************************
*
*****************************************************************************/
-static int CreateChain( filter_t *p_filter, const es_format_t *p_fmt_mid )
+static int CreateChain( filter_t *p_filter, const es_format_t *p_fmt_mid, vlc_video_context *vctx_mid )
{
filter_sys_t *p_sys = p_filter->p_sys;
- filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, &p_filter->fmt_out );
+ filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, p_filter->vctx_in, &p_filter->fmt_out );
if( p_filter->fmt_in.video.orientation != p_fmt_mid->video.orientation)
{
- filter_t *p_transform = AppendTransform( p_sys->p_chain, &p_filter->fmt_in, p_fmt_mid );
+ filter_t *p_transform = AppendTransform( p_sys->p_chain, &p_filter->fmt_in, p_filter->vctx_in, p_fmt_mid );
// Check if filter was enough:
if( p_transform == NULL )
return VLC_EGENERIC;
@@ -436,20 +437,20 @@ static int CreateChain( filter_t *p_filter, const es_format_t *p_fmt_mid )
else
{
if( filter_chain_AppendConverter( p_sys->p_chain,
- NULL, p_fmt_mid ) )
+ NULL, p_filter->vctx_in, p_fmt_mid ) )
return VLC_EGENERIC;
}
if( p_fmt_mid->video.orientation != p_filter->fmt_out.video.orientation)
{
- if( AppendTransform( p_sys->p_chain, p_fmt_mid,
+ if( AppendTransform( p_sys->p_chain, p_fmt_mid, vctx_mid,
&p_filter->fmt_out ) == NULL )
goto error;
}
else
{
if( filter_chain_AppendConverter( p_sys->p_chain,
- p_fmt_mid, &p_filter->fmt_out ) )
+ p_fmt_mid, vctx_mid, &p_filter->fmt_out ) )
goto error;
}
return VLC_SUCCESS;
@@ -462,10 +463,10 @@ error:
static int CreateResizeChromaChain( filter_t *p_filter, const es_format_t *p_fmt_mid )
{
filter_sys_t *p_sys = p_filter->p_sys;
- filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, &p_filter->fmt_out );
+ filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, p_filter->vctx_in, &p_filter->fmt_out );
int i_ret = filter_chain_AppendConverter( p_sys->p_chain,
- NULL, p_fmt_mid );
+ NULL, NULL, p_fmt_mid );
if( i_ret != VLC_SUCCESS )
return i_ret;
@@ -481,19 +482,20 @@ static int CreateResizeChromaChain( filter_t *p_filter, const es_format_t *p_fmt
fmt_out.video.i_chroma = p_filter->fmt_out.video.i_chroma;
i_ret = filter_chain_AppendConverter( p_sys->p_chain,
- NULL, &fmt_out );
+ NULL, NULL, &fmt_out );
es_format_Clean( &fmt_out );
}
else
i_ret = filter_chain_AppendConverter( p_sys->p_chain,
- NULL, &p_filter->fmt_out );
+ NULL, NULL, &p_filter->fmt_out );
if( i_ret != VLC_SUCCESS )
filter_chain_Clear( p_sys->p_chain );
return i_ret;
}
-static filter_t * AppendTransform( filter_chain_t *p_chain, const es_format_t *p_fmt1,
+static filter_t * AppendTransform( filter_chain_t *p_chain,
+ const es_format_t *p_fmt1, vlc_video_context *vctx_in,
const es_format_t *p_fmt2 )
{
video_transform_t transform = video_format_GetTransform(p_fmt1->video.orientation, p_fmt2->video.orientation);
@@ -537,7 +539,7 @@ static filter_t * AppendTransform( filter_chain_t *p_chain, const es_format_t *p
snprintf( config, 100, "transform{type=%s}", type );
char *next = config_ChainCreate( &name, &cfg, config );
- filter_t *p_filter = filter_chain_AppendFilter( p_chain, name, cfg, p_fmt1, p_fmt2 );
+ filter_t *p_filter = filter_chain_AppendFilter( p_chain, name, cfg, p_fmt1, vctx_in, p_fmt2 );
config_ChainDestroy(cfg);
free(name);
diff --git a/modules/video_filter/canvas.c b/modules/video_filter/canvas.c
index 3e834c017c6..c58e3ff7a9b 100644
--- a/modules/video_filter/canvas.c
+++ b/modules/video_filter/canvas.c
@@ -333,9 +333,9 @@ static int Activate( vlc_object_t *p_this )
fmt.video.i_width = p_filter->fmt_in.video.i_width * fmt.video.i_visible_width / p_filter->fmt_in.video.i_visible_width;
fmt.video.i_height = p_filter->fmt_in.video.i_height * fmt.video.i_visible_height / p_filter->fmt_in.video.i_visible_height;
- filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, &fmt );
+ filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, p_filter->vctx_in, &fmt );
/* Append scaling module */
- if ( filter_chain_AppendConverter( p_sys->p_chain, NULL, NULL ) )
+ if ( filter_chain_AppendConverter( p_sys->p_chain, NULL, NULL, NULL ) )
{
msg_Err( p_filter, "Could not append scaling filter" );
free( p_sys );
diff --git a/modules/video_filter/edgedetection.c b/modules/video_filter/edgedetection.c
index e9ed9c7380c..20149af9fa2 100644
--- a/modules/video_filter/edgedetection.c
+++ b/modules/video_filter/edgedetection.c
@@ -105,7 +105,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
}
/* Clear filter chain */
- filter_chain_Reset( sys, &p_filter->fmt_in, &p_filter->fmt_in);
+ filter_chain_Reset( sys, &p_filter->fmt_in, p_filter->vctx_in, &p_filter->fmt_in);
/* Add adjust filter to turn frame black-and-white */
i_ret = filter_chain_AppendFromString( sys, "adjust{saturation=0}" );
if ( i_ret == -1 )
diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
index e982c097668..210cf4640c3 100644
--- a/src/misc/filter_chain.c
+++ b/src/misc/filter_chain.c
@@ -51,6 +51,7 @@ struct filter_chain_t
chained_filter_t *first, *last; /**< List of filters */
es_format_t fmt_in; /**< Chain input format (constant) */
+ vlc_video_context *vctx_in;
es_format_t reset_fmt_out; /**< Chain output format after a reset */
bool is_reset;
bool b_allow_fmt_out_change; /**< Each filter can change the output */
@@ -83,6 +84,7 @@ static filter_chain_t *filter_chain_NewInner( vlc_object_t *obj,
chain->b_allow_fmt_out_change = fmt_out_change;
chain->filter_cap = cap;
chain->conv_cap = conv_cap;
+ chain->vctx_in = NULL;
return chain;
}
@@ -166,13 +168,16 @@ void filter_chain_Delete( filter_chain_t *p_chain )
es_format_Clean( &p_chain->fmt_in );
es_format_Clean( &p_chain->reset_fmt_out );
+ if ( p_chain->vctx_in )
+ vlc_video_context_Release( p_chain->vctx_in );
free( p_chain );
}
/**
* Filter chain reinitialisation
*/
-void filter_chain_Reset( filter_chain_t *p_chain, const es_format_t *p_fmt_in,
+void filter_chain_Reset( filter_chain_t *p_chain,
+ const es_format_t *p_fmt_in, vlc_video_context *vctx_in,
const es_format_t *p_fmt_out )
{
filter_chain_Clear( p_chain );
@@ -180,6 +185,9 @@ void filter_chain_Reset( filter_chain_t *p_chain, const es_format_t *p_fmt_in,
assert(p_fmt_in != NULL);
es_format_Clean( &p_chain->fmt_in );
es_format_Copy( &p_chain->fmt_in, p_fmt_in );
+ if ( p_chain->vctx_in )
+ vlc_video_context_Release( p_chain->vctx_in );
+ p_chain->vctx_in = vctx_in ? vlc_video_context_Hold(vctx_in) : NULL;
assert(p_fmt_out != NULL);
es_format_Clean( &p_chain->reset_fmt_out );
@@ -189,7 +197,8 @@ void filter_chain_Reset( filter_chain_t *p_chain, const es_format_t *p_fmt_in,
static filter_t *filter_chain_AppendInner( filter_chain_t *chain,
const char *name, const char *capability, config_chain_t *cfg,
- const es_format_t *fmt_in, const es_format_t *fmt_out )
+ const es_format_t *fmt_in, vlc_video_context *vctx_in,
+ const es_format_t *fmt_out )
{
chained_filter_t *chained =
vlc_custom_create( chain->obj, sizeof(*chained), "filter" );
@@ -203,13 +212,17 @@ static filter_t *filter_chain_AppendInner( filter_chain_t *chain,
if( chain->last != NULL )
fmt_in = &chain->last->filter.fmt_out;
else
+ {
fmt_in = &chain->fmt_in;
+ vctx_in = chain->vctx_in;
+ }
}
if( fmt_out == NULL )
fmt_out = &chain->reset_fmt_out;
es_format_Copy( &filter->fmt_in, fmt_in );
+ filter->vctx_in = vctx_in;
es_format_Copy( &filter->fmt_out, fmt_out );
filter->b_allow_fmt_out_change = chain->b_allow_fmt_out_change;
filter->p_cfg = cfg;
@@ -274,17 +287,19 @@ error:
filter_t *filter_chain_AppendFilter( filter_chain_t *chain,
const char *name, config_chain_t *cfg,
- const es_format_t *fmt_in, const es_format_t *fmt_out )
+ const es_format_t *fmt_in, vlc_video_context *vctx_in,
+ const es_format_t *fmt_out )
{
return filter_chain_AppendInner( chain, name, chain->filter_cap, cfg,
- fmt_in, fmt_out );
+ fmt_in, vctx_in, fmt_out );
}
int filter_chain_AppendConverter( filter_chain_t *chain,
- const es_format_t *fmt_in, const es_format_t *fmt_out )
+ const es_format_t *fmt_in, vlc_video_context *vctx_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, vctx_in, fmt_out ) != NULL ? 0 : -1;
}
void filter_chain_DeleteFilter( filter_chain_t *chain, filter_t *filter )
@@ -339,7 +354,7 @@ int filter_chain_AppendFromString( filter_chain_t *chain, const char *str )
buf = next;
filter_t *filter = filter_chain_AppendFilter( chain, name, cfg,
- NULL, NULL );
+ NULL, NULL, NULL );
if( cfg )
config_ChainDestroy( cfg );
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 083699cf65e..8ac66896bdf 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -338,8 +338,8 @@ static int VoutDisplayCreateRender(vout_display_t *vd)
es_format_InitFromVideo(&dst, i == 0 ? &v_dst : &v_dst_cmp);
- filter_chain_Reset(osys->converters, &src, &dst);
- ret = filter_chain_AppendConverter(osys->converters, &src, &dst);
+ filter_chain_Reset(osys->converters, &src, osys->src_vctx, &dst);
+ ret = filter_chain_AppendConverter(osys->converters, &src, osys->src_vctx, &dst);
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 7674579bc30..0361d9cb18c 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -823,12 +823,12 @@ static void ThreadChangeFilters(vout_thread_t *vout,
filter_chain_t *chain = a == 0 ? vout->p->filter.chain_static :
vout->p->filter.chain_interactive;
- filter_chain_Reset(chain, p_fmt_current, p_fmt_current);
+ filter_chain_Reset(chain, p_fmt_current, NULL /* TODO */, p_fmt_current);
for (size_t i = 0; i < vlc_array_count(array); i++) {
vout_filter_t *e = vlc_array_item_at_index(array, i);
msg_Dbg(vout, "Adding '%s' as %s", e->name, a == 0 ? "static" : "interactive");
filter_t *filter = filter_chain_AppendFilter(chain, e->name, e->cfg,
- NULL, NULL);
+ NULL, NULL, NULL);
if (!filter)
{
msg_Err(vout, "Failed to add filter '%s'", e->name);
@@ -850,11 +850,11 @@ static void ThreadChangeFilters(vout_thread_t *vout,
if (!es_format_IsSimilar(p_fmt_current, &fmt_input)) {
msg_Dbg(vout, "Adding a filter to compensate for format changes");
if (filter_chain_AppendConverter(vout->p->filter.chain_interactive,
- p_fmt_current, &fmt_input) != 0) {
+ p_fmt_current, NULL /* TODO */, &fmt_input) != 0) {
msg_Err(vout, "Failed to compensate for the format changes, removing all filters");
ThreadDelAllFilterCallbacks(vout);
- filter_chain_Reset(vout->p->filter.chain_static, &fmt_input, &fmt_input);
- filter_chain_Reset(vout->p->filter.chain_interactive, &fmt_input, &fmt_input);
+ filter_chain_Reset(vout->p->filter.chain_static, &fmt_input, NULL /* TODO */, &fmt_input);
+ filter_chain_Reset(vout->p->filter.chain_interactive, &fmt_input, NULL /* TODO */, &fmt_input);
}
}
@@ -979,7 +979,7 @@ static picture_t *ConvertRGB32AndBlend(vout_thread_t *vout, picture_t *pic,
dst.video.i_chroma = VLC_CODEC_RGB32;
video_format_FixRgb(&dst.video);
- if (filter_chain_AppendConverter(filterc, &src, &dst) != 0)
+ if (filter_chain_AppendConverter(filterc, &src, NULL /* TODO */, &dst) != 0)
{
filter_chain_Delete(filterc);
return NULL;
--
2.17.1
More information about the vlc-devel
mailing list