From 09bc1d630f3e0e1b7c7bf7aa1fb8384f2f6aef61 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 4 Jun 2018 12:20:03 +0200 Subject: [PATCH] omxvideoenc: validate cpb-size and initial-delay cpb-size cannot be smaller than initial-delay. --- omx/gstomxvideoenc.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 18d0252ab5..86da12c202 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -612,20 +612,28 @@ set_zynqultrascaleplus_props (GstOMXVideoEnc * self) } if (self->control_rate != OMX_Video_ControlRateDisable) { - OMX_ALG_VIDEO_PARAM_CODED_PICTURE_BUFFER cpb; + if (self->cpb_size < self->initial_delay) { + GST_ERROR_OBJECT (self, + "cpb-size (%d) cannot be smaller than initial-delay (%d)", + self->cpb_size, self->initial_delay); + g_critical ("cpb-size (%d) cannot be smaller than initial-delay (%d)", + self->cpb_size, self->initial_delay); + } else { + OMX_ALG_VIDEO_PARAM_CODED_PICTURE_BUFFER cpb; - GST_OMX_INIT_STRUCT (&cpb); - cpb.nPortIndex = self->enc_out_port->index; - cpb.nCodedPictureBufferSize = self->cpb_size; - cpb.nInitialRemovalDelay = self->initial_delay; + GST_OMX_INIT_STRUCT (&cpb); + cpb.nPortIndex = self->enc_out_port->index; + cpb.nCodedPictureBufferSize = self->cpb_size; + cpb.nInitialRemovalDelay = self->initial_delay; - GST_DEBUG_OBJECT (self, "setting cpb size to %d and initial delay to %d", - self->cpb_size, self->initial_delay); + GST_DEBUG_OBJECT (self, "setting cpb size to %d and initial delay to %d", + self->cpb_size, self->initial_delay); - err = - gst_omx_component_set_parameter (self->enc, - (OMX_INDEXTYPE) OMX_ALG_IndexParamVideoCodedPictureBuffer, &cpb); - CHECK_ERR ("cpb size & initial delay"); + err = + gst_omx_component_set_parameter (self->enc, + (OMX_INDEXTYPE) OMX_ALG_IndexParamVideoCodedPictureBuffer, &cpb); + CHECK_ERR ("cpb size & initial delay"); + } } {