]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/av1_metadata_bsf.c
avcodec/wmalosslessdec: Replace negative channel check by assert
[ffmpeg] / libavcodec / av1_metadata_bsf.c
index 842b80c2011c85844b8ee0f18692ca4c86bccb88..dd0c9b6148f3eea0ec104fdf1c9432c5ac53a749 100644 (file)
@@ -61,12 +61,7 @@ static int av1_metadata_update_sequence_header(AVBSFContext *bsf,
     if (ctx->color_primaries >= 0          ||
         ctx->transfer_characteristics >= 0 ||
         ctx->matrix_coefficients >= 0) {
-        if (!clc->color_description_present_flag) {
-            clc->color_description_present_flag = 1;
-            clc->color_primaries          = AVCOL_PRI_UNSPECIFIED;
-            clc->transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
-            clc->matrix_coefficients      = AVCOL_SPC_UNSPECIFIED;
-        }
+        clc->color_description_present_flag = 1;
 
         if (ctx->color_primaries >= 0)
             clc->color_primaries = ctx->color_primaries;
@@ -133,6 +128,12 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
         goto fail;
     }
 
+    if (frag->nb_units == 0) {
+        av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n");
+        err = AVERROR_INVALIDDATA;
+        goto fail;
+    }
+
     for (i = 0; i < frag->nb_units; i++) {
         if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) {
             obu = frag->units[i].content;
@@ -161,13 +162,8 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
 
     if (ctx->delete_padding) {
         for (i = frag->nb_units - 1; i >= 0; i--) {
-            if (frag->units[i].type == AV1_OBU_PADDING) {
-                err = ff_cbs_delete_unit(ctx->cbc, frag, i);
-                if (err < 0) {
-                    av_log(bsf, AV_LOG_ERROR, "Failed to delete Padding OBU.\n");
-                    goto fail;
-                }
-            }
+            if (frag->units[i].type == AV1_OBU_PADDING)
+                ff_cbs_delete_unit(ctx->cbc, frag, i);
         }
     }