static gboolean gst_imx_blitter_video_transform_set_caps(GstBaseTransform *transform, GstCaps *in, GstCaps *out) { gboolean inout_info_equal; GstVideoInfo in_info, out_info; GstImxBlitterVideoTransform *blitter_video_transform = GST_IMX_BLITTER_VIDEO_TRANSFORM(transform); GstImxBlitterVideoTransformClass *klass = GST_IMX_BLITTER_VIDEO_TRANSFORM_CLASS(G_OBJECT_GET_CLASS(transform)); GstImxCanvas *canvas = &(blitter_video_transform->canvas); GstImxRegion source_subset; g_assert(klass->are_video_infos_equal != NULL); g_assert(blitter_video_transform->blitter != NULL); if (!gst_video_info_from_caps(&in_info, in) || !gst_video_info_from_caps(&out_info, out)) { GST_ERROR_OBJECT(transform, "caps are invalid"); blitter_video_transform->inout_info_set = FALSE; return FALSE; } inout_info_equal = klass->are_video_infos_equal(blitter_video_transform, &in_info, &out_info); if (inout_info_equal) GST_DEBUG_OBJECT(transform, "input and output caps are equal"); else GST_DEBUG_OBJECT(transform, "input and output caps are not equal: input: %" GST_PTR_FORMAT " output: %" GST_PTR_FORMAT, (gpointer)in, (gpointer)out); gst_imx_blitter_set_input_video_info(blitter_video_transform->blitter, &in_info); gst_imx_blitter_set_output_video_info(blitter_video_transform->blitter, &out_info); /* setting new caps changes the canvas, so recalculate it * the recalculation here is done without any input cropping, so set * last_frame_with_cropdata to FALSE, in case subsequent frames do * contain crop metadata */ blitter_video_transform->last_frame_with_cropdata = FALSE; /* the canvas always encompasses the entire output frame */ canvas->outer_region.x1 = 0; canvas->outer_region.y1 = 0; canvas->outer_region.x2 = GST_VIDEO_INFO_WIDTH(&out_info); canvas->outer_region.y2 = GST_VIDEO_INFO_HEIGHT(&out_info); gst_imx_canvas_calculate_inner_region(canvas, &in_info); gst_imx_canvas_clip(canvas, &(canvas->outer_region), &in_info, NULL, &source_subset); gst_imx_blitter_set_input_region(blitter_video_transform->blitter, &source_subset); gst_imx_blitter_set_output_canvas(blitter_video_transform->blitter, canvas); blitter_video_transform->input_video_info = in_info; blitter_video_transform->output_video_info = out_info; blitter_video_transform->inout_info_equal = inout_info_equal; blitter_video_transform->inout_info_set = TRUE; return TRUE; }
static gboolean gst_imx_blitter_video_transform_set_caps(GstBaseTransform *transform, GstCaps *in, GstCaps *out) { gboolean inout_info_equal; GstVideoInfo in_info, out_info; GstImxBlitterVideoTransform *blitter_video_transform = GST_IMX_BLITTER_VIDEO_TRANSFORM(transform); GstImxBlitterVideoTransformClass *klass = GST_IMX_BLITTER_VIDEO_TRANSFORM_CLASS(G_OBJECT_GET_CLASS(transform)); g_assert(klass->are_video_infos_equal != NULL); g_assert(blitter_video_transform->blitter != NULL); if (!gst_video_info_from_caps(&in_info, in) || !gst_video_info_from_caps(&out_info, out)) { GST_ERROR_OBJECT(transform, "caps are invalid"); blitter_video_transform->inout_info_set = FALSE; return FALSE; } inout_info_equal = klass->are_video_infos_equal(blitter_video_transform, &in_info, &out_info); if (inout_info_equal) GST_DEBUG_OBJECT(transform, "input and output caps are equal"); else GST_DEBUG_OBJECT(transform, "input and output caps are not equal: input: %" GST_PTR_FORMAT " output: %" GST_PTR_FORMAT, (gpointer)in, (gpointer)out); if (!gst_imx_base_blitter_set_input_video_info(blitter_video_transform->blitter, &in_info)) { GST_ERROR_OBJECT(transform, "could not use input caps: %" GST_PTR_FORMAT, (gpointer)in); blitter_video_transform->inout_info_set = FALSE; return FALSE; } blitter_video_transform->input_video_info = in_info; blitter_video_transform->output_video_info = out_info; blitter_video_transform->inout_info_equal = inout_info_equal; blitter_video_transform->inout_info_set = TRUE; return TRUE; }