static gboolean gst_video_convert_set_info (GstVideoFilter * filter, GstCaps * incaps, GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info) { GstVideoConvert *space; space = GST_VIDEO_CONVERT_CAST (filter); if (space->convert) { gst_video_converter_free (space->convert); space->convert = NULL; } /* these must match */ if (in_info->width != out_info->width || in_info->height != out_info->height || in_info->fps_n != out_info->fps_n || in_info->fps_d != out_info->fps_d) goto format_mismatch; /* if present, these must match too */ if (in_info->par_n != out_info->par_n || in_info->par_d != out_info->par_d) goto format_mismatch; /* if present, these must match too */ if (in_info->interlace_mode != out_info->interlace_mode) goto format_mismatch; space->convert = gst_video_converter_new (in_info, out_info, gst_structure_new ("GstVideoConvertConfig", GST_VIDEO_CONVERTER_OPT_DITHER_METHOD, GST_TYPE_VIDEO_DITHER_METHOD, space->dither, GST_VIDEO_CONVERTER_OPT_DITHER_QUANTIZATION, G_TYPE_UINT, space->dither_quantization, NULL)); if (space->convert == NULL) goto no_convert; GST_DEBUG ("reconfigured %d %d", GST_VIDEO_INFO_FORMAT (in_info), GST_VIDEO_INFO_FORMAT (out_info)); return TRUE; /* ERRORS */ format_mismatch: { GST_ERROR_OBJECT (space, "input and output formats do not match"); return FALSE; } no_convert: { GST_ERROR_OBJECT (space, "could not create converter"); return FALSE; } }
static gboolean gst_video_convert_set_info (GstVideoFilter * filter, GstCaps * incaps, GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info) { GstVideoConvert *space; space = GST_VIDEO_CONVERT_CAST (filter); if (space->convert) { videoconvert_convert_free (space->convert); } /* these must match */ if (in_info->width != out_info->width || in_info->height != out_info->height || in_info->fps_n != out_info->fps_n || in_info->fps_d != out_info->fps_d) goto format_mismatch; /* if present, these must match too */ if (in_info->par_n != out_info->par_n || in_info->par_d != out_info->par_d) goto format_mismatch; /* if present, these must match too */ if (in_info->interlace_mode != out_info->interlace_mode) goto format_mismatch; space->convert = videoconvert_convert_new (in_info, out_info); if (space->convert == NULL) goto no_convert; GST_DEBUG ("reconfigured %d %d", GST_VIDEO_INFO_FORMAT (in_info), GST_VIDEO_INFO_FORMAT (out_info)); return TRUE; /* ERRORS */ format_mismatch: { GST_ERROR_OBJECT (space, "input and output formats do not match"); return FALSE; } no_convert: { GST_ERROR_OBJECT (space, "could not create converter"); return FALSE; } }
static GstFlowReturn gst_video_convert_transform_frame (GstVideoFilter * filter, GstVideoFrame * in_frame, GstVideoFrame * out_frame) { GstVideoConvert *space; space = GST_VIDEO_CONVERT_CAST (filter); GST_CAT_DEBUG_OBJECT (GST_CAT_PERFORMANCE, filter, "doing colorspace conversion from %s -> to %s", GST_VIDEO_INFO_NAME (&filter->in_info), GST_VIDEO_INFO_NAME (&filter->out_info)); gst_video_converter_frame (space->convert, in_frame, out_frame); return GST_FLOW_OK; }
static gboolean gst_video_convert_set_info (GstVideoFilter * filter, GstCaps * incaps, GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info) { GstVideoConvert *space; space = GST_VIDEO_CONVERT_CAST (filter); if (space->convert) { gst_video_converter_free (space->convert); space->convert = NULL; } /* these must match */ if (in_info->width != out_info->width || in_info->height != out_info->height || in_info->fps_n != out_info->fps_n || in_info->fps_d != out_info->fps_d) goto format_mismatch; /* if present, these must match too */ if (in_info->par_n != out_info->par_n || in_info->par_d != out_info->par_d) goto format_mismatch; /* if present, these must match too */ if (in_info->interlace_mode != out_info->interlace_mode) goto format_mismatch; space->convert = gst_video_converter_new (in_info, out_info, gst_structure_new ("GstVideoConvertConfig", GST_VIDEO_CONVERTER_OPT_DITHER_METHOD, GST_TYPE_VIDEO_DITHER_METHOD, space->dither, GST_VIDEO_CONVERTER_OPT_DITHER_QUANTIZATION, G_TYPE_UINT, space->dither_quantization, GST_VIDEO_CONVERTER_OPT_CHROMA_RESAMPLER_METHOD, GST_TYPE_VIDEO_RESAMPLER_METHOD, space->chroma_resampler, GST_VIDEO_CONVERTER_OPT_ALPHA_MODE, GST_TYPE_VIDEO_ALPHA_MODE, space->alpha_mode, GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE, G_TYPE_DOUBLE, space->alpha_value, GST_VIDEO_CONVERTER_OPT_CHROMA_MODE, GST_TYPE_VIDEO_CHROMA_MODE, space->chroma_mode, GST_VIDEO_CONVERTER_OPT_MATRIX_MODE, GST_TYPE_VIDEO_MATRIX_MODE, space->matrix_mode, GST_VIDEO_CONVERTER_OPT_GAMMA_MODE, GST_TYPE_VIDEO_GAMMA_MODE, space->gamma_mode, GST_VIDEO_CONVERTER_OPT_PRIMARIES_MODE, GST_TYPE_VIDEO_PRIMARIES_MODE, space->primaries_mode, GST_VIDEO_CONVERTER_OPT_THREADS, G_TYPE_UINT, space->n_threads, NULL)); if (space->convert == NULL) goto no_convert; GST_DEBUG ("reconfigured %d %d", GST_VIDEO_INFO_FORMAT (in_info), GST_VIDEO_INFO_FORMAT (out_info)); return TRUE; /* ERRORS */ format_mismatch: { GST_ERROR_OBJECT (space, "input and output formats do not match"); return FALSE; } no_convert: { GST_ERROR_OBJECT (space, "could not create converter"); return FALSE; } }