alpha: Refactor param/process functions
When ::set_info() is called, the input/output VideoInfo aren't set yet on the videofilter.
This commit is contained in:
parent
47a1da9076
commit
4b2a0aba06
@ -167,8 +167,12 @@ static gboolean gst_alpha_set_info (GstVideoFilter * filter,
|
|||||||
static GstFlowReturn gst_alpha_transform_frame (GstVideoFilter * filter,
|
static GstFlowReturn gst_alpha_transform_frame (GstVideoFilter * filter,
|
||||||
GstVideoFrame * in_frame, GstVideoFrame * out_frame);
|
GstVideoFrame * in_frame, GstVideoFrame * out_frame);
|
||||||
|
|
||||||
|
static void gst_alpha_init_params_full (GstAlpha * alpha,
|
||||||
|
const GstVideoFormatInfo * in_info, const GstVideoFormatInfo * out_info);
|
||||||
static void gst_alpha_init_params (GstAlpha * alpha);
|
static void gst_alpha_init_params (GstAlpha * alpha);
|
||||||
static gboolean gst_alpha_set_process_function (GstAlpha * alpha);
|
static gboolean gst_alpha_set_process_function (GstAlpha * alpha);
|
||||||
|
static gboolean gst_alpha_set_process_function_full (GstAlpha * alpha,
|
||||||
|
GstVideoInfo * in_info, GstVideoInfo * out_info);
|
||||||
|
|
||||||
static void gst_alpha_set_property (GObject * object, guint prop_id,
|
static void gst_alpha_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
@ -524,10 +528,11 @@ gst_alpha_set_info (GstVideoFilter * filter,
|
|||||||
gst_base_transform_set_passthrough (GST_BASE_TRANSFORM_CAST (filter),
|
gst_base_transform_set_passthrough (GST_BASE_TRANSFORM_CAST (filter),
|
||||||
passthrough);
|
passthrough);
|
||||||
|
|
||||||
if (!gst_alpha_set_process_function (alpha) && !passthrough)
|
if (!gst_alpha_set_process_function_full (alpha, in_info, out_info)
|
||||||
|
&& !passthrough)
|
||||||
goto no_process;
|
goto no_process;
|
||||||
|
|
||||||
gst_alpha_init_params (alpha);
|
gst_alpha_init_params_full (alpha, in_info->finfo, out_info->finfo);
|
||||||
|
|
||||||
GST_ALPHA_UNLOCK (alpha);
|
GST_ALPHA_UNLOCK (alpha);
|
||||||
|
|
||||||
@ -2286,18 +2291,15 @@ gst_alpha_chroma_key_packed_422_argb (const GstVideoFrame * in_frame,
|
|||||||
|
|
||||||
/* Protected with the alpha lock */
|
/* Protected with the alpha lock */
|
||||||
static void
|
static void
|
||||||
gst_alpha_init_params (GstAlpha * alpha)
|
gst_alpha_init_params_full (GstAlpha * alpha,
|
||||||
|
const GstVideoFormatInfo * in_info, const GstVideoFormatInfo * out_info)
|
||||||
{
|
{
|
||||||
gfloat kgl;
|
gfloat kgl;
|
||||||
gfloat tmp;
|
gfloat tmp;
|
||||||
gfloat tmp1, tmp2;
|
gfloat tmp1, tmp2;
|
||||||
gfloat y;
|
gfloat y;
|
||||||
const GstVideoFormatInfo *in_info, *out_info;
|
|
||||||
const gint *matrix;
|
const gint *matrix;
|
||||||
|
|
||||||
in_info = GST_VIDEO_FILTER (alpha)->in_info.finfo;
|
|
||||||
out_info = GST_VIDEO_FILTER (alpha)->out_info.finfo;
|
|
||||||
|
|
||||||
/* RGB->RGB: convert to SDTV YUV, chroma keying, convert back
|
/* RGB->RGB: convert to SDTV YUV, chroma keying, convert back
|
||||||
* YUV->RGB: chroma keying, convert to RGB
|
* YUV->RGB: chroma keying, convert to RGB
|
||||||
* RGB->YUV: convert to YUV, chroma keying
|
* RGB->YUV: convert to YUV, chroma keying
|
||||||
@ -2356,17 +2358,20 @@ gst_alpha_init_params (GstAlpha * alpha)
|
|||||||
alpha->noise_level2 = alpha->noise_level * alpha->noise_level;
|
alpha->noise_level2 = alpha->noise_level * alpha->noise_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_alpha_init_params (GstAlpha * alpha)
|
||||||
|
{
|
||||||
|
gst_alpha_init_params_full (alpha, GST_VIDEO_FILTER (alpha)->in_info.finfo,
|
||||||
|
GST_VIDEO_FILTER (alpha)->out_info.finfo);
|
||||||
|
}
|
||||||
|
|
||||||
/* Protected with the alpha lock */
|
/* Protected with the alpha lock */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_alpha_set_process_function (GstAlpha * alpha)
|
gst_alpha_set_process_function_full (GstAlpha * alpha, GstVideoInfo * in_info,
|
||||||
|
GstVideoInfo * out_info)
|
||||||
{
|
{
|
||||||
GstVideoInfo *in_info, *out_info;
|
|
||||||
|
|
||||||
alpha->process = NULL;
|
alpha->process = NULL;
|
||||||
|
|
||||||
in_info = &GST_VIDEO_FILTER_CAST (alpha)->in_info;
|
|
||||||
out_info = &GST_VIDEO_FILTER_CAST (alpha)->out_info;
|
|
||||||
|
|
||||||
switch (alpha->method) {
|
switch (alpha->method) {
|
||||||
case ALPHA_METHOD_SET:
|
case ALPHA_METHOD_SET:
|
||||||
switch (GST_VIDEO_INFO_FORMAT (out_info)) {
|
switch (GST_VIDEO_INFO_FORMAT (out_info)) {
|
||||||
@ -2536,6 +2541,14 @@ gst_alpha_set_process_function (GstAlpha * alpha)
|
|||||||
return alpha->process != NULL;
|
return alpha->process != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_alpha_set_process_function (GstAlpha * alpha)
|
||||||
|
{
|
||||||
|
return gst_alpha_set_process_function_full (alpha,
|
||||||
|
&GST_VIDEO_FILTER_CAST (alpha)->in_info,
|
||||||
|
&GST_VIDEO_FILTER_CAST (alpha)->out_info);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_alpha_before_transform (GstBaseTransform * btrans, GstBuffer * buf)
|
gst_alpha_before_transform (GstBaseTransform * btrans, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user