summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2019-09-21 13:39:42 +0200
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2019-09-27 10:53:14 +0200
commitf67ec886a3c264d5bc5d39337380e22ee09aafb8 (patch)
treee2a7c94668c4df7d992edf775285addeb6d40097 /gst-libs
parent7fb17b1a34da42b7f55e35a4827b5b6729c66761 (diff)
libs: decoder: h264, h266: fix g_return_val_if_fail() missuse
g_return_val_fail() documentations says: If expr evaluates to FALSE, the current function should be considered to have undefined behaviour (a programmer error). The only correct solution to such an error is to change the module that is calling the current function, so that it avoids this incorrect call. So it was missused in a couple parts of the H264 and H265 internal decoders. This patch changes that to plain conditionals. Also, it was included a couple code-style fixes.
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/vaapi/gstvaapidecoder_h264.c16
-rw-r--r--gst-libs/gst/vaapi/gstvaapidecoder_h265.c17
2 files changed, 20 insertions, 13 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
index b7241844..b20e7272 100644
--- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
+++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
@@ -369,10 +369,15 @@ gst_vaapi_frame_store_add (GstVaapiFrameStore * fs,
field = picture->structure == GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD ?
TOP_FIELD : BOTTOM_FIELD;
- g_return_val_if_fail (fs->buffers[0]->field_poc[field] == G_MAXINT32, FALSE);
+
+ if (fs->buffers[0]->field_poc[field] != G_MAXINT32)
+ return FALSE;
fs->buffers[0]->field_poc[field] = picture->field_poc[field];
- g_return_val_if_fail (picture->field_poc[!field] == G_MAXINT32, FALSE);
+
+ if (picture->field_poc[!field] != G_MAXINT32)
+ return FALSE;
picture->field_poc[!field] = fs->buffers[0]->field_poc[!field];
+
return TRUE;
}
@@ -744,7 +749,8 @@ dpb_output (GstVaapiDecoderH264 * decoder, GstVaapiFrameStore * fs)
for (i = 0; i < fs->num_buffers; i++) {
GstVaapiPictureH264 *const pic = fs->buffers[i];
- g_return_val_if_fail (pic != NULL, FALSE);
+ if (pic == NULL)
+ return FALSE;
pic->output_needed = FALSE;
if (!GST_VAAPI_PICTURE_FLAG_IS_SET (pic, GST_VAAPI_PICTURE_FLAG_GHOST))
picture = pic;
@@ -3994,8 +4000,8 @@ decode_picture (GstVaapiDecoderH264 * decoder, GstVaapiDecoderUnit * unit)
GstVaapiPictureH264 *picture, *first_field;
GstVaapiDecoderStatus status;
- g_return_val_if_fail (pps != NULL, GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN);
- g_return_val_if_fail (sps != NULL, GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN);
+ if (!(pps && sps))
+ return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
status = ensure_context (decoder, sps);
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h265.c b/gst-libs/gst/vaapi/gstvaapidecoder_h265.c
index 7a5a2e61..a04c74b8 100644
--- a/gst-libs/gst/vaapi/gstvaapidecoder_h265.c
+++ b/gst-libs/gst/vaapi/gstvaapidecoder_h265.c
@@ -676,7 +676,8 @@ dpb_output (GstVaapiDecoderH265 * decoder, GstVaapiFrameStore * fs)
g_return_val_if_fail (fs != NULL, FALSE);
picture = fs->buffer;
- g_return_val_if_fail (picture != NULL, FALSE);
+ if (!picture)
+ return FALSE;
picture->output_needed = FALSE;
return gst_vaapi_picture_output (GST_VAAPI_PICTURE_CAST (picture));
@@ -1630,8 +1631,8 @@ init_picture_refs (GstVaapiDecoderH265 * decoder,
{
GstVaapiDecoderH265Private *const priv = &decoder->priv;
guint32 NumRpsCurrTempList0 = 0, NumRpsCurrTempList1 = 0;
- GstVaapiPictureH265 *RefPicListTemp0[16] = { NULL, }, *RefPicListTemp1[16] = {
- NULL,};
+ GstVaapiPictureH265 *RefPicListTemp0[16] = { NULL, };
+ GstVaapiPictureH265 *RefPicListTemp1[16] = { NULL, };
guint i, rIdx = 0;
guint num_ref_idx_l0_active_minus1 = 0;
guint num_ref_idx_l1_active_minus1 = 0;
@@ -2208,9 +2209,9 @@ decode_ref_pic_set (GstVaapiDecoderH265 * decoder,
priv->NumPocLtCurr = priv->NumPocLtFoll = 0;
} else {
GstH265ShortTermRefPicSet *stRefPic = NULL;
- gint32 num_lt_pics, pocLt, PocLsbLt[16] = { 0, }
- , UsedByCurrPicLt[16] = {
- 0,};
+ gint32 num_lt_pics, pocLt;
+ gint32 PocLsbLt[16] = { 0, };
+ gint32 UsedByCurrPicLt[16] = { 0, };
gint32 DeltaPocMsbCycleLt[16] = { 0, };
gint numtotalcurr = 0;
@@ -2306,8 +2307,8 @@ decode_picture (GstVaapiDecoderH265 * decoder, GstVaapiDecoderUnit * unit)
GstVaapiPictureH265 *picture;
GstVaapiDecoderStatus status;
- g_return_val_if_fail (pps != NULL, GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN);
- g_return_val_if_fail (sps != NULL, GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN);
+ if (!(pps && sps))
+ return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
status = ensure_context (decoder, sps);
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)