static void _gst_gl_color_convert_set_format_unlocked (GstGLColorConvert * convert, GstVideoInfo * in_info, GstVideoInfo * out_info) { g_return_if_fail (convert != NULL); g_return_if_fail (in_info); g_return_if_fail (out_info); g_return_if_fail (GST_VIDEO_INFO_FORMAT (in_info) != GST_VIDEO_FORMAT_UNKNOWN); g_return_if_fail (GST_VIDEO_INFO_FORMAT (in_info) != GST_VIDEO_FORMAT_ENCODED); g_return_if_fail (GST_VIDEO_INFO_FORMAT (out_info) != GST_VIDEO_FORMAT_UNKNOWN); g_return_if_fail (GST_VIDEO_INFO_FORMAT (out_info) != GST_VIDEO_FORMAT_ENCODED); if (gst_video_info_is_equal (&convert->in_info, in_info) && gst_video_info_is_equal (&convert->out_info, out_info)) return; gst_gl_color_convert_reset (convert); convert->in_info = *in_info; convert->out_info = *out_info; convert->initted = FALSE; }
static void gst_validate_ssim_configure_converter (GstValidateSsim * self, gint index, gboolean force, GstVideoFormat in_format, gint width, gint height) { SSimConverterInfo *info = g_list_nth_data (self->priv->converters, index); if (!info) { info = g_slice_new0 (SSimConverterInfo); self->priv->converters = g_list_insert (self->priv->converters, info, index); } if (force || info->in_info.height != height || info->in_info.width != width || info->in_info.finfo->format != in_format) { gst_video_info_init (&info->in_info); gst_video_info_set_format (&info->in_info, in_format, width, height); if (info->converter) gst_video_converter_free (info->converter); info->out_info = self->priv->out_info; if (gst_video_info_is_equal (&info->in_info, &info->out_info)) info->converter = NULL; else info->converter = gst_video_converter_new (&info->in_info, &info->out_info, NULL); } }
gboolean gst_imx_blitter_set_input_video_info(GstImxBlitter *blitter, GstVideoInfo const *input_video_info) { GstImxBlitterClass *klass; g_assert(blitter != NULL); g_assert(input_video_info != NULL); klass = GST_IMX_BLITTER_CLASS(G_OBJECT_GET_CLASS(blitter)); /* Don't actually do anything unless the video info changed */ if (gst_video_info_is_equal(&(blitter->input_video_info), input_video_info)) return TRUE; if (klass->set_input_video_info != NULL) { if (!klass->set_input_video_info(blitter, input_video_info)) return FALSE; } blitter->input_video_info = *input_video_info; /* Destroy the existing buffer pool, since it is no longer usable * (the new video info has a different size) * the next time the buffer pool is needed, it will be recreated * in blit() with the new input video info */ if (blitter->dma_bufferpool != NULL) { gst_object_unref(GST_OBJECT(blitter->dma_bufferpool)); blitter->dma_bufferpool = NULL; } return TRUE; }
/** * gst_vaapi_encoder_set_codec_state: * @encoder: a #GstVaapiEncoder * @state : a #GstVideoCodecState * * Notifies the encoder about the source surface properties. The * accepted set of properties is: video resolution, colorimetry, * pixel-aspect-ratio and framerate. * * This function is a synchronization point for codec configuration. * This means that, at this point, the encoder is reconfigured to * match the new properties and any other change beyond this point has * zero effect. * * Return value: a #GstVaapiEncoderStatus */ GstVaapiEncoderStatus gst_vaapi_encoder_set_codec_state (GstVaapiEncoder * encoder, GstVideoCodecState * state) { GstVaapiEncoderStatus status; g_return_val_if_fail (encoder != NULL, GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_PARAMETER); g_return_val_if_fail (state != NULL, GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_PARAMETER); if (encoder->num_codedbuf_queued > 0) goto error_operation_failed; if (!gst_video_info_is_equal (&state->info, &encoder->video_info)) { status = check_video_info (encoder, &state->info); if (status != GST_VAAPI_ENCODER_STATUS_SUCCESS) return status; encoder->video_info = state->info; } return gst_vaapi_encoder_reconfigure_internal (encoder); /* ERRORS */ error_operation_failed: { GST_ERROR ("could not change codec state after encoding started"); return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED; } }
static void _gst_gl_upload_set_format_unlocked (GstGLUpload * upload, GstVideoInfo * in_info) { g_return_if_fail (upload != NULL); g_return_if_fail (GST_VIDEO_INFO_FORMAT (in_info) != GST_VIDEO_FORMAT_UNKNOWN); g_return_if_fail (GST_VIDEO_INFO_FORMAT (in_info) != GST_VIDEO_FORMAT_ENCODED); if (gst_video_info_is_equal (&upload->in_info, in_info)) return; gst_gl_upload_reset (upload); upload->convert = gst_gl_color_convert_new (upload->context); upload->in_info = *in_info; upload->initted = FALSE; }
/** * gst_gl_download_set_format: * @download: a #GstGLDownload * @v_format: a #GstVideoFormat * @out_width: the width to download to * @out_height: the height to download to * * Initializes @download with the information required for download. */ void gst_gl_download_set_format (GstGLDownload * download, GstVideoInfo * out_info) { g_return_if_fail (download != NULL); g_return_if_fail (GST_VIDEO_INFO_FORMAT (out_info) != GST_VIDEO_FORMAT_UNKNOWN); g_return_if_fail (GST_VIDEO_INFO_FORMAT (out_info) != GST_VIDEO_FORMAT_ENCODED); GST_OBJECT_LOCK (download); if (gst_video_info_is_equal (&download->info, out_info)) { GST_OBJECT_UNLOCK (download); return; } gst_gl_download_reset (download); download->initted = FALSE; download->info = *out_info; GST_OBJECT_UNLOCK (download); }
gboolean gtk_gst_base_widget_set_format (GtkGstBaseWidget * widget, GstVideoInfo * v_info) { GTK_GST_BASE_WIDGET_LOCK (widget); if (gst_video_info_is_equal (&widget->v_info, v_info)) { GTK_GST_BASE_WIDGET_UNLOCK (widget); return TRUE; } if (!_calculate_par (widget, v_info)) { GTK_GST_BASE_WIDGET_UNLOCK (widget); return FALSE; } widget->pending_resize = TRUE; widget->pending_v_info = *v_info; GTK_GST_BASE_WIDGET_UNLOCK (widget); return TRUE; }
static GstBuffer * _gst_gl_color_convert_perform_unlocked (GstGLColorConvert * convert, GstBuffer * inbuf) { g_return_val_if_fail (convert != NULL, FALSE); g_return_val_if_fail (inbuf, FALSE); if (gst_video_info_is_equal (&convert->in_info, &convert->out_info)) return gst_buffer_ref (inbuf); convert->inbuf = inbuf; gst_gl_context_thread_add (convert->context, (GstGLContextThreadFunc) _do_convert, convert); if (!convert->priv->result) { if (convert->outbuf) gst_object_unref (convert->outbuf); convert->outbuf = NULL; return NULL; } return convert->outbuf; }
static gboolean gst_msdkvpp_propose_allocation (GstBaseTransform * trans, GstQuery * decide_query, GstQuery * query) { GstMsdkVPP *thiz = GST_MSDKVPP (trans); GstVideoInfo info; GstBufferPool *pool = NULL; GstAllocator *allocator = NULL; GstCaps *caps; GstStructure *config; gboolean need_pool; GstAllocationParams params; guint size; guint min_buffers = thiz->async_depth + 1; gst_query_parse_allocation (query, &caps, &need_pool); if (!caps) { GST_ERROR_OBJECT (thiz, "Failed to parse the allocation caps"); return FALSE; } if (!gst_video_info_from_caps (&info, caps)) { GST_ERROR_OBJECT (thiz, "Failed to get video info"); return FALSE; } /* if upstream allocation query supports dmabuf-capsfeatures, * we do allocate dmabuf backed memory */ if (_gst_caps_has_feature (caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) { GST_INFO_OBJECT (thiz, "MSDK VPP srcpad uses DMABuf memory"); thiz->use_sinkpad_dmabuf = TRUE; } if (need_pool) { /* alwys provide a new pool for upstream to help re-negotiation * more info here: https://bugzilla.gnome.org/show_bug.cgi?id=748344 */ pool = gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SINK, caps, min_buffers); } /* Update the internal pool if any allocation attribute changed */ if (!gst_video_info_is_equal (&thiz->sinkpad_buffer_pool_info, &info)) { gst_object_unref (thiz->sinkpad_buffer_pool); thiz->sinkpad_buffer_pool = gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SINK, caps, min_buffers); } /* get the size and allocator params from configured pool and set it in query */ if (!need_pool) pool = gst_object_ref (thiz->sinkpad_buffer_pool); config = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool)); gst_buffer_pool_config_get_params (config, NULL, &size, NULL, NULL); if (gst_buffer_pool_config_get_allocator (config, &allocator, ¶ms)) gst_query_add_allocation_param (query, allocator, ¶ms); gst_structure_free (config); /* if upstream does't have a pool requirement, set only * size, min_buffers and max_buffers in query */ gst_query_add_allocation_pool (query, need_pool ? pool : NULL, size, min_buffers, 0); gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); gst_object_unref (pool); return GST_BASE_TRANSFORM_CLASS (parent_class)->propose_allocation (trans, decide_query, query); }
static gboolean gst_msdkvpp_set_caps (GstBaseTransform * trans, GstCaps * caps, GstCaps * out_caps) { GstMsdkVPP *thiz = GST_MSDKVPP (trans); GstVideoInfo in_info, out_info; gboolean sinkpad_info_changed = FALSE; gboolean srcpad_info_changed = FALSE; gboolean deinterlace; if (gst_caps_get_features (caps, 0) != gst_caps_get_features (out_caps, 0)) thiz->need_vpp = 1; gst_video_info_from_caps (&in_info, caps); gst_video_info_from_caps (&out_info, out_caps); if (!gst_video_info_is_equal (&in_info, &thiz->sinkpad_info)) sinkpad_info_changed = TRUE; if (!gst_video_info_is_equal (&out_info, &thiz->srcpad_info)) srcpad_info_changed = TRUE; thiz->sinkpad_info = in_info; thiz->srcpad_info = out_info; #ifndef _WIN32 thiz->use_video_memory = TRUE; #else thiz->use_video_memory = FALSE; #endif if (!sinkpad_info_changed && !srcpad_info_changed && thiz->initialized) return TRUE; /* check for deinterlace requirement */ deinterlace = gst_msdkvpp_is_deinterlace_enabled (thiz, &in_info); if (deinterlace) thiz->flags |= GST_MSDK_FLAG_DEINTERLACE; thiz->buffer_duration = GST_VIDEO_INFO_FPS_N (&out_info) > 0 ? gst_util_uint64_scale (GST_SECOND, GST_VIDEO_INFO_FPS_D (&out_info), GST_VIDEO_INFO_FPS_N (&out_info)) : 0; if (!gst_msdkvpp_initialize (thiz)) return FALSE; /* set passthrough according to filter operation change */ gst_msdkvpp_set_passthrough (thiz); /* Ensure sinkpad buffer pool */ thiz->sinkpad_buffer_pool = gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SINK, caps, thiz->in_num_surfaces); if (!thiz->sinkpad_buffer_pool) { GST_ERROR_OBJECT (thiz, "Failed to ensure the sinkpad buffer pool"); return FALSE; } /* Ensure a srcpad buffer pool */ thiz->srcpad_buffer_pool = gst_msdkvpp_create_buffer_pool (thiz, GST_PAD_SRC, out_caps, thiz->out_num_surfaces); if (!thiz->srcpad_buffer_pool) { GST_ERROR_OBJECT (thiz, "Failed to ensure the srcpad buffer pool"); return FALSE; } return TRUE; }