Commit 352cc4c8 authored by Alexandre Janniaux's avatar Alexandre Janniaux Committed by François Cartegnie
Browse files

video_chroma: cvpx: forward the host filter to buffer new

Allocate a new picture by forwarding the host filter whenever the last
filter of the cvpx chain asked a new video buffer.

The host filter and last CVPX buffer are supposed to have the same
format, but the host filter might play a different role in its parent
filter chain than the requesting filter. In particular, filter chain
will try to detect the last filter, which can only work for filters
belonging to the chain.

Fix a crash when plugging a chain NV12->RV32 which creates first a
converter (cvpx) CVPX_NV12 -> CVPX_I420 -> I420 and then another
converter I420 -> RV32 filter, leading to the cvpx filter allocating
the wrong type of output frame.

Fixes #27721
parent cb07a077
......@@ -560,6 +560,18 @@ static const struct vlc_filter_operations chain_CVPX_ops = {
.close = Close_chain_CVPX,
};
static picture_t *VideoBufferNew(filter_t *filter)
{
filter_t *cvpx_chain = filter->owner.sys;
return filter_NewPicture(cvpx_chain);
}
static struct vlc_decoder_device *VideoHoldDevice(vlc_object_t *obj, void *sys)
{
filter_t *cvpx_chain = sys;
return filter_HoldDecoderDevice(cvpx_chain);
}
static int
Open_chain_CVPX(filter_t *filter)
{
......@@ -624,9 +636,21 @@ Open_chain_CVPX(filter_t *filter)
(const char *)&input_chroma,
(const char *)&output_chroma);
static const struct filter_video_callbacks owner_cbs =
{
.buffer_new = VideoBufferNew,
.hold_device = VideoHoldDevice,
};
const struct filter_owner_t owner =
{
.sys = filter,
.video = &owner_cbs,
};
/* We create a filter chain to encapsulate the two converters. */
filter_chain_t *chain =
filter_chain_NewVideo(filter, false, &filter->owner);
filter_chain_NewVideo(filter, false, &owner);
if (chain == NULL)
return VLC_ENOMEM;
......
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