omxvideoenc: use caps from query in propose_allocation

Prevent crash by not deferencing a NULL pointer if self->input_state
isn't defined when propose_allocation() is called.

https://bugzilla.gnome.org/show_bug.cgi?id=786442
This commit is contained in:
Guillaume Desmottes 2017-08-28 13:56:22 +02:00 committed by Nicolas Dufresne
parent 318ef5b357
commit 79df3b0e8e

View file

@ -1905,15 +1905,28 @@ gst_omx_video_enc_propose_allocation (GstVideoEncoder * encoder,
{
GstOMXVideoEnc *self = GST_OMX_VIDEO_ENC (encoder);
guint num_buffers;
gsize size = self->input_state->info.size;
GstCaps *caps;
GstVideoInfo info;
gst_query_parse_allocation (query, &caps, NULL);
if (!caps) {
GST_WARNING_OBJECT (self, "allocation query does not contain caps");
return FALSE;
}
if (!gst_video_info_from_caps (&info, caps)) {
GST_WARNING_OBJECT (self, "Failed to parse caps %" GST_PTR_FORMAT, caps);
return FALSE;
}
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
num_buffers = self->enc_in_port->port_def.nBufferCountMin + 1;
GST_DEBUG_OBJECT (self,
"request at least %d buffers of size %" G_GSIZE_FORMAT, num_buffers,
size);
gst_query_add_allocation_pool (query, NULL, size, num_buffers, 0);
info.size);
gst_query_add_allocation_pool (query, NULL, info.size, num_buffers, 0);
return
GST_VIDEO_ENCODER_CLASS