Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] all: Replace assert by av_assert
@ 2025-03-23 17:01 Andreas Rheinhardt
  2025-03-25 10:10 ` Michael Niedermayer
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Rheinhardt @ 2025-03-23 17:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 27 bytes --]

Patch attached.

- Andreas

[-- Attachment #2: 0001-all-Replace-assert-by-av_assert.patch --]
[-- Type: text/x-patch, Size: 22528 bytes --]

From a6481493a5a9acf0968798dd5afd72239acca11c Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 23 Mar 2025 17:50:54 +0100
Subject: [PATCH] all: Replace assert by av_assert

Also remove the assert.h inclusion from lavu/internal.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aacpsy.c             |  7 ++++---
 libavcodec/encode.c             |  2 ++
 libavcodec/h264_direct.c        | 14 +++++++-------
 libavcodec/h264_refs.c          | 20 +++++++++-----------
 libavcodec/h264_slice.c         |  6 +++---
 libavcodec/mips/mpegvideo_mmi.c |  3 ++-
 libavcodec/mpegvideo_enc.c      |  7 ++++---
 libavcodec/mpegvideoencdsp.c    |  1 -
 libavcodec/sinewin_tablegen.h   |  9 +++++++++
 libavcodec/vdpau_mpeg12.c       |  4 +++-
 libavcodec/vdpau_mpeg4.c        |  6 ++++--
 libavcodec/vdpau_vc1.c          |  6 ++++--
 libavcodec/vorbisenc.c          | 14 ++++++--------
 libavfilter/vf_tonemap_opencl.c |  4 ++++
 libavformat/asfdec_f.c          | 15 ++++++---------
 libavutil/internal.h            |  5 -----
 16 files changed, 67 insertions(+), 56 deletions(-)

diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index 019be09fa3..a57c60e49d 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -25,6 +25,7 @@
  */
 
 #include "libavutil/attributes.h"
+#include "libavutil/avassert.h"
 #include "libavutil/ffmath.h"
 #include "libavutil/mem.h"
 
@@ -504,9 +505,9 @@ static int calc_bit_demand(AacPsyContext *ctx, float pe, int bits, int size,
     fill_level = av_clipf((float)ctx->fill_level / size, clip_low, clip_high);
     clipped_pe = av_clipf(pe, ctx->pe.min, ctx->pe.max);
     bit_save   = (fill_level + bitsave_add) * bitsave_slope;
-    assert(bit_save <= 0.3f && bit_save >= -0.05000001f);
+    av_assert2(bit_save <= 0.3f && bit_save >= -0.05000001f);
     bit_spend  = (fill_level + bitspend_add) * bitspend_slope;
-    assert(bit_spend <= 0.5f && bit_spend >= -0.1f);
+    av_assert2(bit_spend <= 0.5f && bit_spend >= -0.1f);
     /* The bit factor graph in the spec is obviously incorrect.
      *      bit_spend + ((bit_spend - bit_spend))...
      * The reference encoder subtracts everything from 1, but also seems incorrect.
@@ -904,7 +905,7 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
         /* Calculate the energies of each sub-shortblock */
         for (i = 0; i < PSY_LAME_NUM_SUBBLOCKS; i++) {
             energy_subshort[i] = pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 1) * PSY_LAME_NUM_SUBBLOCKS)];
-            assert(pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)] > 0);
+            av_assert2(pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)] > 0);
             attack_intensity[i] = energy_subshort[i] / pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)];
             energy_short[0] += energy_subshort[i];
         }
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index cd10dcf3cd..d1a1a7f9e8 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -18,6 +18,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <assert.h>
+
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
index 587274aa6d..4ce11507e9 100644
--- a/libavcodec/h264_direct.c
+++ b/libavcodec/h264_direct.c
@@ -32,7 +32,7 @@
 #include "rectangle.h"
 #include "threadframe.h"
 
-#include <assert.h>
+#include "libavutil/avassert.h"
 
 static int get_scale_factor(const H264SliceContext *sl,
                             int poc, int poc1, int i)
@@ -212,7 +212,7 @@ static void pred_spatial_direct_motion(const H264Context *const h, H264SliceCont
     int mv[2];
     int list;
 
-    assert(sl->ref_list[1][0].reference & 3);
+    av_assert1(sl->ref_list[1][0].reference & 3);
 
     await_reference_mb_row(h, &sl->ref_list[1][0],
                            sl->mb_y + !!IS_INTERLACED(*mb_type));
@@ -247,7 +247,7 @@ static void pred_spatial_direct_motion(const H264Context *const h, H264SliceCont
                 mv[list] = pack16to32(mid_pred(A[0], B[0], C[0]),
                                       mid_pred(A[1], B[1], C[1]));
             } else {
-                assert(match_count == 1);
+                av_assert1(match_count == 1);
                 if (left_ref == ref[list])
                     mv[list] = AV_RN32A(A);
                 else if (top_ref == ref[list])
@@ -438,7 +438,7 @@ single_col:
             fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8,
                            (uint8_t)ref[1], 1);
 
-            assert(b8_stride == 2);
+            av_assert1(b8_stride == 2);
             /* col_zero_flag */
             if (!IS_INTRA(mb_type_col[0]) && !sl->ref_list[1][0].parent->long_ref &&
                 (l1ref0[i8] == 0 ||
@@ -496,7 +496,7 @@ static void pred_temp_direct_motion(const H264Context *const h, H264SliceContext
     unsigned int sub_mb_type;
     int i8, i4;
 
-    assert(sl->ref_list[1][0].reference & 3);
+    av_assert1(sl->ref_list[1][0].reference & 3);
 
     await_reference_mb_row(h, &sl->ref_list[1][0],
                            sl->mb_y + !!IS_INTERLACED(*mb_type));
@@ -593,7 +593,7 @@ single_col:
 
         if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) {
             int y_shift = 2 * !IS_INTERLACED(*mb_type);
-            assert(h->ps.sps->direct_8x8_inference_flag);
+            av_assert1(h->ps.sps->direct_8x8_inference_flag);
 
             for (i8 = 0; i8 < 4; i8++) {
                 const int x8 = i8 & 1;
@@ -680,7 +680,7 @@ single_col:
                     continue;
                 }
 
-                assert(b8_stride == 2);
+                av_assert1(b8_stride == 2);
                 ref0 = l1ref0[i8];
                 if (ref0 >= 0)
                     ref0 = map_col_to_list0[0][ref0 + ref_offset];
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 050ca92292..c0b4b76374 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -34,8 +34,6 @@
 #include "golomb.h"
 #include "mpegutils.h"
 
-#include <assert.h>
-
 static void pic_as_field(H264Ref *pic, const int parity)
 {
     for (int i = 0; i < FF_ARRAY_ELEMS(pic->data); ++i) {
@@ -330,8 +328,8 @@ int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
 
                 for (i = h->short_ref_count - 1; i >= 0; i--) {
                     ref = h->short_ref[i];
-                    assert(ref->reference);
-                    assert(!ref->long_ref);
+                    av_assert1(ref->reference);
+                    av_assert1(!ref->long_ref);
                     if (ref->frame_num == frame_num &&
                         (ref->reference & pic_structure))
                         break;
@@ -352,10 +350,10 @@ int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
                     return AVERROR_INVALIDDATA;
                 }
                 ref = h->long_ref[long_idx];
-                assert(!(ref && !ref->reference));
+                av_assert1(!(ref && !ref->reference));
                 if (ref && (ref->reference & pic_structure)) {
                     ref->pic_id = pic_id;
-                    assert(ref->long_ref);
+                    av_assert1(ref->long_ref);
                     i = 0;
                 } else {
                     i = -1;
@@ -512,7 +510,7 @@ static H264Picture *find_short(H264Context *h, int frame_num, int *idx)
  */
 static void remove_short_at_index(H264Context *h, int i)
 {
-    assert(i >= 0 && i < h->short_ref_count);
+    av_assert1(i >= 0 && i < h->short_ref_count);
     h->short_ref[i] = NULL;
     if (--h->short_ref_count)
         memmove(&h->short_ref[i], &h->short_ref[i + 1],
@@ -551,7 +549,7 @@ static H264Picture *remove_long(H264Context *h, int i, int ref_mask)
     pic = h->long_ref[i];
     if (pic) {
         if (unreference_pic(h, pic, ref_mask)) {
-            assert(h->long_ref[i]->long_ref == 1);
+            av_assert1(h->long_ref[i]->long_ref == 1);
             h->long_ref[i]->long_ref = 0;
             h->long_ref[i]           = NULL;
             h->long_ref_count--;
@@ -565,7 +563,7 @@ void ff_h264_remove_all_refs(H264Context *h)
 {
     for (int i = 0; i < 16; i++)
         remove_long(h, i, 0);
-    assert(h->long_ref_count == 0);
+    av_assert1(h->long_ref_count == 0);
 
     if (h->short_ref_count && !h->last_pic_for_ec.f->data[0]) {
         ff_h264_unref_picture(&h->last_pic_for_ec);
@@ -708,7 +706,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
             current_ref_assigned = 1;
             break;
         case MMCO_SET_MAX_LONG:
-            assert(mmco[i].long_arg <= 16);
+            av_assert1(mmco[i].long_arg <= 16);
             // just remove the long term which index is greater than new max
             for (int j = mmco[i].long_arg; j < 16; j++)
                 remove_long(h, j, 0);
@@ -780,7 +778,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
                 if (h->long_ref[i])
                     break;
 
-            assert(i < 16);
+            av_assert1(i < 16);
             remove_long(h, i, 0);
         } else {
             H264Picture *pic = h->short_ref[h->short_ref_count - 1];
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 726a56d004..5f3273007e 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -571,7 +571,7 @@ static int h264_frame_start(H264Context *h)
     if (h->sei.common.unregistered.x264_build >= 0)
         h->x264_build = h->sei.common.unregistered.x264_build;
 
-    assert(h->cur_pic_ptr->long_ref == 0);
+    av_assert1(h->cur_pic_ptr->long_ref == 0);
 
     return 0;
 }
@@ -1448,7 +1448,7 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl,
         int last_field = last_pic_structure == PICT_BOTTOM_FIELD;
         av_assert0(h->cur_pic_ptr);
         av_assert0(h->cur_pic_ptr->f->buf[0]);
-        assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
+        av_assert1(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
 
         /* Mark old field/frame as completed */
         if (h->cur_pic_ptr->tf.owner[last_field] == h->avctx) {
@@ -1568,7 +1568,7 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl,
     if (h->first_field) {
         av_assert0(h->cur_pic_ptr);
         av_assert0(h->cur_pic_ptr->f->buf[0]);
-        assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
+        av_assert1(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
 
         /* figure out if we have a complementary field pair */
         if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
diff --git a/libavcodec/mips/mpegvideo_mmi.c b/libavcodec/mips/mpegvideo_mmi.c
index 87d4aafd8c..83b9dd9a85 100644
--- a/libavcodec/mips/mpegvideo_mmi.c
+++ b/libavcodec/mips/mpegvideo_mmi.c
@@ -23,6 +23,7 @@
  */
 
 #include "mpegvideo_mips.h"
+#include "libavutil/avassert.h"
 #include "libavutil/mips/mmiutils.h"
 
 void ff_dct_unquantize_h263_intra_mmi(MpegEncContext *s, int16_t *block,
@@ -354,7 +355,7 @@ void ff_dct_unquantize_mpeg2_intra_mmi(MpegEncContext *s, int16_t *block,
     DECLARE_VAR_ALL64;
     DECLARE_VAR_ADDRT;
 
-    assert(s->block_last_index[n]>=0);
+    av_assert2(s->block_last_index[n]>=0);
 
     nCoeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
 
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 493a3edde6..3dcc4e8753 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -35,6 +35,7 @@
 
 #include <stdint.h>
 
+#include "libavutil/avassert.h"
 #include "libavutil/emms.h"
 #include "libavutil/internal.h"
 #include "libavutil/intmath.h"
@@ -1970,9 +1971,9 @@ vbv_retry:
                                        s->pict_type);
 
         if (avctx->flags & AV_CODEC_FLAG_PASS1)
-            assert(put_bits_count(&s->pb) == s->header_bits + s->mv_bits +
-                                             s->misc_bits + s->i_tex_bits +
-                                             s->p_tex_bits);
+            av_assert1(put_bits_count(&s->pb) == s->header_bits + s->mv_bits +
+                                                 s->misc_bits + s->i_tex_bits +
+                                                 s->p_tex_bits);
         flush_put_bits(&s->pb);
         s->frame_bits  = put_bits_count(&s->pb);
 
diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c
index 5e4c446d99..ec748e9871 100644
--- a/libavcodec/mpegvideoencdsp.c
+++ b/libavcodec/mpegvideoencdsp.c
@@ -16,7 +16,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <assert.h>
 #include <stdint.h>
 #include <string.h>
 
diff --git a/libavcodec/sinewin_tablegen.h b/libavcodec/sinewin_tablegen.h
index 6887d59cfe..845e084f3d 100644
--- a/libavcodec/sinewin_tablegen.h
+++ b/libavcodec/sinewin_tablegen.h
@@ -23,7 +23,12 @@
 #ifndef AVCODEC_SINEWIN_TABLEGEN_H
 #define AVCODEC_SINEWIN_TABLEGEN_H
 
+#ifdef BUILD_TABLES
 #include <assert.h>
+#else
+#include "libavutil/avassert.h"
+#endif
+
 // do not use libavutil/libm.h since this is compiled both
 // for the host and the target and config.h is only valid for the target
 #include <math.h>
@@ -100,7 +105,11 @@ static AVOnce init_sine_window_once[9] = {
 
 av_cold void ff_init_ff_sine_windows(int index)
 {
+#ifdef BUILD_TABLES
     assert(index >= 5 && index < FF_ARRAY_ELEMS(ff_sine_windows));
+#else
+    av_assert1(index >= 5 && index < FF_ARRAY_ELEMS(ff_sine_windows));
+#endif
 #if !CONFIG_HARDCODED_TABLES
 #ifdef BUILD_TABLES
     ff_sine_window_init(ff_sine_windows[index], 1 << index);
diff --git a/libavcodec/vdpau_mpeg12.c b/libavcodec/vdpau_mpeg12.c
index 4d16f18089..4a22655014 100644
--- a/libavcodec/vdpau_mpeg12.c
+++ b/libavcodec/vdpau_mpeg12.c
@@ -31,6 +31,8 @@
 #include "vdpau.h"
 #include "vdpau_internal.h"
 
+#include "libavutil/avassert.h"
+
 static int vdpau_mpeg_start_frame(AVCodecContext *avctx,
                                   const AVBufferRef *buffer_ref,
                                   const uint8_t *buffer, uint32_t size)
@@ -49,7 +51,7 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx,
     switch (s->pict_type) {
     case AV_PICTURE_TYPE_B:
         ref = ff_vdpau_get_surface_id(s->next_pic.ptr->f);
-        assert(ref != VDP_INVALID_HANDLE);
+        av_assert1(ref != VDP_INVALID_HANDLE);
         info->backward_reference = ref;
         /* fall through to forward prediction */
     case AV_PICTURE_TYPE_P:
diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c
index 24ae10b3c3..7e0bc2d9c3 100644
--- a/libavcodec/vdpau_mpeg4.c
+++ b/libavcodec/vdpau_mpeg4.c
@@ -29,6 +29,8 @@
 #include "vdpau.h"
 #include "vdpau_internal.h"
 
+#include "libavutil/avassert.h"
+
 static int vdpau_mpeg4_start_frame(AVCodecContext *avctx,
                                    const AVBufferRef *buffer_ref,
                                    const uint8_t *buffer, uint32_t size)
@@ -49,13 +51,13 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx,
     switch (s->pict_type) {
     case AV_PICTURE_TYPE_B:
         ref = ff_vdpau_get_surface_id(s->next_pic.ptr->f);
-        assert(ref != VDP_INVALID_HANDLE);
+        av_assert1(ref != VDP_INVALID_HANDLE);
         info->backward_reference = ref;
         info->vop_coding_type    = 2;
         /* fall-through */
     case AV_PICTURE_TYPE_P:
         ref = ff_vdpau_get_surface_id(s->last_pic.ptr->f);
-        assert(ref != VDP_INVALID_HANDLE);
+        av_assert1(ref != VDP_INVALID_HANDLE);
         info->forward_reference  = ref;
     }
 
diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c
index af6973ea6a..c15ff23c09 100644
--- a/libavcodec/vdpau_vc1.c
+++ b/libavcodec/vdpau_vc1.c
@@ -31,6 +31,8 @@
 #include "vdpau.h"
 #include "vdpau_internal.h"
 
+#include "libavutil/avassert.h"
+
 static int vdpau_vc1_start_frame(AVCodecContext *avctx,
                                  const AVBufferRef *buffer_ref,
                                  const uint8_t *buffer, uint32_t size)
@@ -50,14 +52,14 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
     case AV_PICTURE_TYPE_B:
         if (s->next_pic.ptr) {
             ref = ff_vdpau_get_surface_id(s->next_pic.ptr->f);
-            assert(ref != VDP_INVALID_HANDLE);
+            av_assert1(ref != VDP_INVALID_HANDLE);
             info->backward_reference = ref;
         }
         /* fall-through */
     case AV_PICTURE_TYPE_P:
         if (s->last_pic.ptr) {
             ref = ff_vdpau_get_surface_id(s->last_pic.ptr->f);
-            assert(ref != VDP_INVALID_HANDLE);
+            av_assert1(ref != VDP_INVALID_HANDLE);
             info->forward_reference  = ref;
         }
     }
diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index 99ac72c910..8a02a64038 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -43,8 +43,6 @@
 #define BITSTREAM_WRITER_LE
 #include "put_bits.h"
 
-#undef NDEBUG
-#include <assert.h>
 
 typedef struct vorbis_enc_codebook {
     int nentries;
@@ -227,8 +225,8 @@ static int ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
         if (j == 8) // zero
             continue;
         cb = &venc->codebooks[rc->books[i][j]];
-        assert(cb->ndimensions >= 2);
-        assert(cb->lookup);
+        av_assert1(cb->ndimensions >= 2);
+        av_assert1(cb->lookup);
 
         for (j = 0; j < cb->nentries; j++) {
             float a;
@@ -864,7 +862,7 @@ static int floor_encode(vorbis_enc_context *venc, vorbis_enc_floor *fc,
                     if (coded[counter + k] < maxval)
                         break;
                 }
-                assert(l != csub);
+                av_assert2(l != csub);
                 cval   |= l << cshift;
                 cshift += c->subclass;
             }
@@ -895,7 +893,7 @@ static float *put_vector(vorbis_enc_codebook *book, PutBitContext *pb,
 {
     int i, entry = -1;
     float distance = FLT_MAX;
-    assert(book->dimensions);
+    av_assert2(book->dimensions);
     for (i = 0; i < book->nentries; i++) {
         float * vec = book->dimensions + i * book->ndimensions, d = book->pow2[i];
         int j;
@@ -962,8 +960,8 @@ static int residue_encode(vorbis_enc_context *venc, vorbis_enc_residue *rc,
                     if (nbook == -1)
                         continue;
 
-                    assert(rc->type == 0 || rc->type == 2);
-                    assert(!(psize % book->ndimensions));
+                    av_assert2(rc->type == 0 || rc->type == 2);
+                    av_assert2(!(psize % book->ndimensions));
 
                     if (rc->type == 0) {
                         for (k = 0; k < psize; k += book->ndimensions) {
diff --git a/libavfilter/vf_tonemap_opencl.c b/libavfilter/vf_tonemap_opencl.c
index 758c0e5e94..474aaa11e5 100644
--- a/libavfilter/vf_tonemap_opencl.c
+++ b/libavfilter/vf_tonemap_opencl.c
@@ -30,6 +30,10 @@
 #include "video.h"
 #include "colorspace.h"
 
+#if !defined(DEBUG) && !defined(NDEBUG)
+#    define NDEBUG
+#endif
+
 // TODO:
 // - separate peak-detection from tone-mapping kernel to solve
 //    one-frame-delay issue.
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 2441cadb44..ccf706f73b 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -131,9 +131,6 @@ static const AVClass asf_class = {
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
-#undef NDEBUG
-#include <assert.h>
-
 #define ASF_MAX_STREAMS 127
 #define FRAME_HEADER_SIZE 6
 // Fix Me! FRAME_HEADER_SIZE may be different.
@@ -1145,7 +1142,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
             if (asf->packet_size_left && asf->packet_size_left < FRAME_HEADER_SIZE)
                 av_log(s, AV_LOG_WARNING, "Skip due to FRAME_HEADER_SIZE\n");
 
-            assert(ret >= 0);
+            av_assert1(ret >= 0);
             /* fail safe */
             avio_skip(pb, ret);
 
@@ -1335,8 +1332,8 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
                             int row = off / asf_st->ds_span;
                             int col = off % asf_st->ds_span;
                             int idx = row + col * asf_st->ds_packet_size / asf_st->ds_chunk_size;
-                            assert(offset + asf_st->ds_chunk_size <= asf_st->pkt.size);
-                            assert(idx + 1 <= asf_st->pkt.size / asf_st->ds_chunk_size);
+                            av_assert1(offset + asf_st->ds_chunk_size <= asf_st->pkt.size);
+                            av_assert1(idx + 1 <= asf_st->pkt.size / asf_st->ds_chunk_size);
                             memcpy(newdata + offset,
                                    asf_st->pkt.data + idx * asf_st->ds_chunk_size,
                                    asf_st->ds_chunk_size);
@@ -1372,8 +1369,8 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
         if ((ret = asf_parse_packet(s, s->pb, pkt)) <= 0)
             return ret;
         if ((ret = asf_get_packet(s, s->pb)) < 0)
-            assert(asf->packet_size_left < FRAME_HEADER_SIZE ||
-                   asf->packet_segments < 1);
+            av_assert1(asf->packet_size_left < FRAME_HEADER_SIZE ||
+                       asf->packet_segments < 1);
         asf->packet_time_start = 0;
     }
 }
@@ -1474,7 +1471,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index,
 
             asf_st = &asf->streams[s->streams[i]->id];
 
-//            assert((asf_st->packet_pos - s->data_offset) % s->packet_size == 0);
+//            av_assert1((asf_st->packet_pos - s->data_offset) % s->packet_size == 0);
             pos = asf_st->packet_pos;
             av_assert1(pkt->pos == asf_st->packet_pos);
 
diff --git a/libavutil/internal.h b/libavutil/internal.h
index ac1af367e9..8cc79612aa 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -26,17 +26,12 @@
 #ifndef AVUTIL_INTERNAL_H
 #define AVUTIL_INTERNAL_H
 
-#if !defined(DEBUG) && !defined(NDEBUG)
-#    define NDEBUG
-#endif
-
 // This can be enabled to allow detection of additional integer overflows with ubsan
 //#define CHECKED
 
 #include <limits.h>
 #include <stdint.h>
 #include <stddef.h>
-#include <assert.h>
 #include <stdio.h>
 #include "config.h"
 #include "attributes.h"
-- 
2.45.2


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] all: Replace assert by av_assert
  2025-03-23 17:01 [FFmpeg-devel] [PATCH] all: Replace assert by av_assert Andreas Rheinhardt
@ 2025-03-25 10:10 ` Michael Niedermayer
  2025-03-25 10:20   ` Andreas Rheinhardt
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Niedermayer @ 2025-03-25 10:10 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1980 bytes --]

On Sun, Mar 23, 2025 at 06:01:01PM +0100, Andreas Rheinhardt wrote:
> Patch attached.
> 
> - Andreas

>  libavcodec/aacpsy.c             |    7 ++++---
>  libavcodec/encode.c             |    2 ++
>  libavcodec/h264_direct.c        |   14 +++++++-------
>  libavcodec/h264_refs.c          |   20 +++++++++-----------
>  libavcodec/h264_slice.c         |    6 +++---
>  libavcodec/mips/mpegvideo_mmi.c |    3 ++-
>  libavcodec/mpegvideo_enc.c      |    7 ++++---
>  libavcodec/mpegvideoencdsp.c    |    1 -
>  libavcodec/sinewin_tablegen.h   |    9 +++++++++
>  libavcodec/vdpau_mpeg12.c       |    4 +++-
>  libavcodec/vdpau_mpeg4.c        |    6 ++++--
>  libavcodec/vdpau_vc1.c          |    6 ++++--
>  libavcodec/vorbisenc.c          |   14 ++++++--------
>  libavfilter/vf_tonemap_opencl.c |    4 ++++
>  libavformat/asfdec_f.c          |   15 ++++++---------
>  libavutil/internal.h            |    5 -----
>  16 files changed, 67 insertions(+), 56 deletions(-)
> 4b05bc0165c919f3f4cfc4cee50ccd15a74cc4fe  0001-all-Replace-assert-by-av_assert.patch
> From a6481493a5a9acf0968798dd5afd72239acca11c Mon Sep 17 00:00:00 2001
> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> Date: Sun, 23 Mar 2025 17:50:54 +0100
> Subject: [PATCH] all: Replace assert by av_assert
> 
> Also remove the assert.h inclusion from lavu/internal.h.

breaks:

./ffmpeg -i ~/tickets/2254/ttvHD_vlc_sample.ts -an -vframes 5 -bitexact -f framecrc -

Assertion h->cur_pic_ptr->reference != (1 << 2) failed at libavcodec/h264_slice.c:1451

I have more files hitting the same above


i also see a Assertion b8_stride == 2 failed at libavcodec/h264_direct.c:441
in freh5.264.SIGABRT.9f5.65
i did not verify with bisect that this is from this patchset too

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] all: Replace assert by av_assert
  2025-03-25 10:10 ` Michael Niedermayer
@ 2025-03-25 10:20   ` Andreas Rheinhardt
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2025-03-25 10:20 UTC (permalink / raw)
  To: ffmpeg-devel

Michael Niedermayer:
> On Sun, Mar 23, 2025 at 06:01:01PM +0100, Andreas Rheinhardt wrote:
>> Patch attached.
>>
>> - Andreas
> 
>>  libavcodec/aacpsy.c             |    7 ++++---
>>  libavcodec/encode.c             |    2 ++
>>  libavcodec/h264_direct.c        |   14 +++++++-------
>>  libavcodec/h264_refs.c          |   20 +++++++++-----------
>>  libavcodec/h264_slice.c         |    6 +++---
>>  libavcodec/mips/mpegvideo_mmi.c |    3 ++-
>>  libavcodec/mpegvideo_enc.c      |    7 ++++---
>>  libavcodec/mpegvideoencdsp.c    |    1 -
>>  libavcodec/sinewin_tablegen.h   |    9 +++++++++
>>  libavcodec/vdpau_mpeg12.c       |    4 +++-
>>  libavcodec/vdpau_mpeg4.c        |    6 ++++--
>>  libavcodec/vdpau_vc1.c          |    6 ++++--
>>  libavcodec/vorbisenc.c          |   14 ++++++--------
>>  libavfilter/vf_tonemap_opencl.c |    4 ++++
>>  libavformat/asfdec_f.c          |   15 ++++++---------
>>  libavutil/internal.h            |    5 -----
>>  16 files changed, 67 insertions(+), 56 deletions(-)
>> 4b05bc0165c919f3f4cfc4cee50ccd15a74cc4fe  0001-all-Replace-assert-by-av_assert.patch
>> From a6481493a5a9acf0968798dd5afd72239acca11c Mon Sep 17 00:00:00 2001
>> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> Date: Sun, 23 Mar 2025 17:50:54 +0100
>> Subject: [PATCH] all: Replace assert by av_assert
>>
>> Also remove the assert.h inclusion from lavu/internal.h.
> 
> breaks:
> 
> ./ffmpeg -i ~/tickets/2254/ttvHD_vlc_sample.ts -an -vframes 5 -bitexact -f framecrc -
> 
> Assertion h->cur_pic_ptr->reference != (1 << 2) failed at libavcodec/h264_slice.c:1451
> 
> I have more files hitting the same above
> 
> 
> i also see a Assertion b8_stride == 2 failed at libavcodec/h264_direct.c:441
> in freh5.264.SIGABRT.9f5.65

Interesting. It shows that nobody (not even the fuzzers) actually
defines DEBUG in order to stop disabling C asserts. I thought that these
asserts were tested which would make converting them to av_assert easy.
Honestly, I don't have time atm to dig into why exactly these asserts
exist and (if they are actually still necessary or not just superseded)
how to fix them. So this patch is put on hold.
Anyway, thanks for testing.

> i did not verify with bisect that this is from this patchset too

The underlying issue is definitely not from this issue.

- Andreas

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-25 10:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-23 17:01 [FFmpeg-devel] [PATCH] all: Replace assert by av_assert Andreas Rheinhardt
2025-03-25 10:10 ` Michael Niedermayer
2025-03-25 10:20   ` Andreas Rheinhardt

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git