[vlc-devel] [PATCH 16/19] filters: drain internal filter chains when draining
Steve Lhomme
robux4 at ycbcr.xyz
Tue Oct 13 15:51:59 CEST 2020
---
modules/video_chroma/chain.c | 9 ++++++++-
modules/video_chroma/cvpx.c | 7 +++++++
modules/video_filter/canvas.c | 8 +++++++-
modules/video_filter/edgedetection.c | 27 ++++++++++++++++++++++-----
4 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/modules/video_chroma/chain.c b/modules/video_chroma/chain.c
index 347c8d58da7..9d4bbd62707 100644
--- a/modules/video_chroma/chain.c
+++ b/modules/video_chroma/chain.c
@@ -53,6 +53,7 @@ vlc_module_end ()
*****************************************************************************/
static picture_t *Chain ( filter_t *, picture_t * );
static void Flush ( filter_t * );
+static picture_t *Drain ( filter_t * );
static int BuildTransformChain( filter_t *p_filter );
static int BuildChromaResize( filter_t * );
@@ -153,7 +154,7 @@ static const struct filter_video_callbacks filter_video_chain_cbs =
};
static const struct vlc_filter_operations filter_ops = {
- .filter_video = Chain, .flush = Flush, .close = Destroy,
+ .filter_video = Chain, .flush = Flush, .drain_video = Drain, .close = Destroy,
};
/*****************************************************************************
@@ -279,6 +280,12 @@ static void Flush( filter_t *p_filter )
filter_chain_VideoFlush( p_sys->p_chain );
}
+static picture_t *Drain( filter_t *p_filter )
+{
+ filter_sys_t *p_sys = p_filter->p_sys;
+ return filter_chain_VideoDrain( p_sys->p_chain );
+}
+
/*****************************************************************************
* Builders
*****************************************************************************/
diff --git a/modules/video_chroma/cvpx.c b/modules/video_chroma/cvpx.c
index 0f732e0e4cc..0ad207aae08 100644
--- a/modules/video_chroma/cvpx.c
+++ b/modules/video_chroma/cvpx.c
@@ -508,6 +508,12 @@ chain_CVPX_Filter(filter_t *filter, picture_t *pic)
return filter_chain_VideoFilter(chain, pic);
}
+static picture_t * chain_CVPX_Drain(filter_t *filter)
+{
+ filter_chain_t *chain = filter->p_sys;
+ return filter_chain_VideoDrain(chain);
+}
+
static void
chain_CVPX_Flush(filter_t *filter)
{
@@ -557,6 +563,7 @@ static const vlc_fourcc_t supported_sw_chromas[] = {
static const struct vlc_filter_operations chain_CVPX_ops = {
.filter_video = chain_CVPX_Filter, .flush = chain_CVPX_Flush,
+ .drain_video = chain_CVPX_Drain,
.close = Close_chain_CVPX,
};
diff --git a/modules/video_filter/canvas.c b/modules/video_filter/canvas.c
index b3610d8d1aa..1f0c7d58396 100644
--- a/modules/video_filter/canvas.c
+++ b/modules/video_filter/canvas.c
@@ -42,6 +42,7 @@ static int Activate( filter_t * );
static void Destroy( filter_t * );
static picture_t *Filter( filter_t *, picture_t * );
static void Flush( filter_t * );
+static picture_t *Drain( filter_t * );
/* This module effectively implements a form of picture-in-picture.
* - The outer picture is called the canvas.
@@ -146,7 +147,7 @@ static const struct filter_video_callbacks canvas_cbs =
static const struct vlc_filter_operations filter_ops =
{
- .filter_video = Filter, .flush = Flush, .close = Destroy,
+ .filter_video = Filter, .flush = Flush, .drain_video = Drain, .close = Destroy,
};
/*****************************************************************************
@@ -407,3 +408,8 @@ static void Flush( filter_t *p_filter )
filter_chain_VideoFlush( p_sys->p_chain );
}
+static picture_t *Drain( filter_t *p_filter )
+{
+ filter_sys_t *p_sys = p_filter->p_sys;
+ return filter_chain_VideoDrain( p_sys->p_chain );
+}
diff --git a/modules/video_filter/edgedetection.c b/modules/video_filter/edgedetection.c
index 84b6dbe8faa..eb96f56af2c 100644
--- a/modules/video_filter/edgedetection.c
+++ b/modules/video_filter/edgedetection.c
@@ -49,6 +49,7 @@ static int Open( filter_t * );
static void Close( filter_t * );
static picture_t *new_frame( filter_t * );
static picture_t *Filter( filter_t *, picture_t * );
+static picture_t *Drain( filter_t * );
static uint8_t sobel( const uint8_t *, const int, const int, int, int);
/* Kernel for X axis */
@@ -89,7 +90,7 @@ static void Flush( filter_t *p_filter )
static const struct vlc_filter_operations filter_ops =
{
- .filter_video = Filter, .flush = Flush, .close = Close,
+ .filter_video = Filter, .flush = Flush, .drain_video = Drain, .close = Close,
};
/*****************************************************************************
@@ -162,11 +163,11 @@ static picture_t *new_frame( filter_t *p_filter )
* edges in a black-and-white image. The sobel operator is applied to
* every pixel in the frame for both X and Y axis.
******************************************************************************/
-static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
+static picture_t *FilterFromFiltered( filter_t *p_filter,
+ const video_format_t *out_fmt,
+ picture_t *p_filtered_frame )
{
- picture_t *p_filtered_frame =
- filter_chain_VideoFilter( (filter_chain_t *)p_filter->p_sys, p_pic );
- picture_t *p_out_frame = picture_NewFromFormat( &p_pic->format );
+ picture_t *p_out_frame = picture_NewFromFormat( out_fmt );
if ( p_out_frame == NULL )
{
picture_Release( p_filtered_frame );
@@ -190,6 +191,22 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
return p_out_frame;
}
+static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
+{
+ filter_chain_t *p_sys = p_filter->p_sys;
+ picture_t *p_filtered_frame = filter_chain_VideoFilter( p_sys, p_pic );
+ return FilterFromFiltered( p_filter, &p_pic->format, p_filtered_frame );
+}
+
+static picture_t *Drain( filter_t *p_filter )
+{
+ filter_chain_t *p_sys = p_filter->p_sys;
+ picture_t *p_drained = filter_chain_VideoDrain( p_sys );
+ if (!p_drained)
+ return NULL;
+ return FilterFromFiltered( p_filter, &p_filter->fmt_out.video, p_drained );
+}
+
/******************************************************************************
* Sobel Operator.
* Calculates the gradients for both X and Y directions in a frame.
--
2.26.2
More information about the vlc-devel
mailing list