mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
video: Handle errors in gst_video_info_set_format() / gst_video_info_align()
https://bugzilla.gnome.org/show_bug.cgi?id=774588
This commit is contained in:
parent
17cdd369e6
commit
681d97aed7
6 changed files with 38 additions and 11 deletions
|
@ -640,7 +640,10 @@ _new_output_state (GstVideoFormat fmt, guint width, guint height,
|
|||
state = g_slice_new0 (GstVideoCodecState);
|
||||
state->ref_count = 1;
|
||||
gst_video_info_init (&state->info);
|
||||
gst_video_info_set_format (&state->info, fmt, width, height);
|
||||
if (!gst_video_info_set_format (&state->info, fmt, width, height)) {
|
||||
g_slice_free (GstVideoCodecState, state);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (reference) {
|
||||
GstVideoInfo *tgt, *ref;
|
||||
|
@ -3466,6 +3469,8 @@ gst_video_decoder_set_output_state (GstVideoDecoder * decoder,
|
|||
|
||||
/* Create the new output state */
|
||||
state = _new_output_state (fmt, width, height, reference);
|
||||
if (!state)
|
||||
return NULL;
|
||||
|
||||
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
|
||||
|
||||
|
|
|
@ -517,7 +517,11 @@ _new_output_state (GstCaps * caps, GstVideoCodecState * reference)
|
|||
state = g_slice_new0 (GstVideoCodecState);
|
||||
state->ref_count = 1;
|
||||
gst_video_info_init (&state->info);
|
||||
gst_video_info_set_format (&state->info, GST_VIDEO_FORMAT_ENCODED, 0, 0);
|
||||
|
||||
if (!gst_video_info_set_format (&state->info, GST_VIDEO_FORMAT_ENCODED, 0, 0)) {
|
||||
g_slice_free (GstVideoCodecState, state);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
state->caps = caps;
|
||||
|
||||
|
@ -2275,6 +2279,8 @@ gst_video_encoder_set_output_state (GstVideoEncoder * encoder, GstCaps * caps,
|
|||
g_return_val_if_fail (caps != NULL, NULL);
|
||||
|
||||
state = _new_output_state (caps, reference);
|
||||
if (!state)
|
||||
return NULL;
|
||||
|
||||
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
|
||||
if (priv->output_state)
|
||||
|
|
|
@ -270,7 +270,8 @@ gst_buffer_add_video_meta (GstBuffer * buffer,
|
|||
GstVideoMeta *meta;
|
||||
GstVideoInfo info;
|
||||
|
||||
gst_video_info_set_format (&info, format, width, height);
|
||||
if (!gst_video_info_set_format (&info, format, width, height))
|
||||
return NULL;
|
||||
|
||||
meta =
|
||||
gst_buffer_add_video_meta_full (buffer, flags, format, width,
|
||||
|
|
|
@ -186,7 +186,9 @@ video_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
|||
priv->video_align.stride_align[n] = max_align;
|
||||
|
||||
/* apply the alignment to the info */
|
||||
gst_video_info_align (&info, &priv->video_align);
|
||||
if (!gst_video_info_align (&info, &priv->video_align))
|
||||
goto failed_to_align;
|
||||
|
||||
gst_buffer_pool_config_set_video_alignment (config, &priv->video_align);
|
||||
|
||||
if (priv->params.align < max_align) {
|
||||
|
@ -227,7 +229,11 @@ wrong_size:
|
|||
GST_WARNING_OBJECT (pool,
|
||||
"Provided size is to small for the caps: %u", size);
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
failed_to_align:
|
||||
{
|
||||
GST_WARNING_OBJECT (pool, "Failed to align");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -175,11 +175,14 @@ gst_video_blend_scale_linear_RGBA (GstVideoInfo * src, GstBuffer * src_buffer,
|
|||
|
||||
g_return_if_fail (dest_buffer != NULL);
|
||||
|
||||
tmpbuf = g_malloc (dest_width * 8 * 4);
|
||||
|
||||
gst_video_info_init (dest);
|
||||
gst_video_info_set_format (dest, GST_VIDEO_INFO_FORMAT (src),
|
||||
dest_width, dest_height);
|
||||
if (!gst_video_info_set_format (dest, GST_VIDEO_INFO_FORMAT (src),
|
||||
dest_width, dest_height)) {
|
||||
g_warn_if_reached ();
|
||||
return;
|
||||
}
|
||||
|
||||
tmpbuf = g_malloc (dest_width * 8 * 4);
|
||||
|
||||
*dest_buffer = gst_buffer_new_and_alloc (GST_VIDEO_INFO_SIZE (dest));
|
||||
|
||||
|
|
|
@ -739,7 +739,10 @@ gst_video_overlay_rectangle_new_raw (GstBuffer * pixels,
|
|||
rect->scaled_rectangles = NULL;
|
||||
|
||||
gst_video_info_init (&rect->info);
|
||||
gst_video_info_set_format (&rect->info, format, width, height);
|
||||
if (!gst_video_info_set_format (&rect->info, format, width, height)) {
|
||||
gst_mini_object_unref (GST_MINI_OBJECT_CAST (rect));
|
||||
return NULL;
|
||||
}
|
||||
if (flags & GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA)
|
||||
rect->info.flags |= GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA;
|
||||
|
||||
|
@ -1059,7 +1062,10 @@ gst_video_overlay_rectangle_convert (GstVideoInfo * src, GstBuffer * src_buffer,
|
|||
height = GST_VIDEO_INFO_HEIGHT (src);
|
||||
|
||||
gst_video_info_init (dest);
|
||||
gst_video_info_set_format (dest, dest_format, width, height);
|
||||
if (!gst_video_info_set_format (dest, dest_format, width, height)) {
|
||||
g_warn_if_reached ();
|
||||
return;
|
||||
}
|
||||
|
||||
*dest_buffer = gst_buffer_new_and_alloc (GST_VIDEO_INFO_SIZE (dest));
|
||||
|
||||
|
|
Loading…
Reference in a new issue