Commit 6983eaff authored by Steve Lhomme's avatar Steve Lhomme
Browse files

filters: drain internal filter chains when draining

parent b685d614
......@@ -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
*****************************************************************************/
......
......@@ -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,
};
......
......@@ -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 );
}
......@@ -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.
......
Supports Markdown
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