[FFmpeg-devel] [PATCH/RFC] Remove assert.h usage.

Clément Bœsch ubitux at gmail.com
Wed May 15 21:29:52 CEST 2013


---
libmpcodecs kept verbatim, ppc untested, dxva untested.
FATE ok with --assert-level=2
---
 ffplay.c                           |  2 --
 libavcodec/aacdec.c                |  1 -
 libavcodec/aacpsy.c                |  6 ++--
 libavcodec/dvbsubdec.c             |  2 +-
 libavcodec/dxva2.c                 |  5 ++--
 libavcodec/dxva2_h264.c            | 19 ++++++------
 libavcodec/dxva2_mpeg2.c           |  3 +-
 libavcodec/dxva2_vc1.c             |  5 ++--
 libavcodec/h263.c                  |  3 --
 libavcodec/h264.c                  | 25 +++++++---------
 libavcodec/h264_direct.c           | 16 ++++-------
 libavcodec/h264_ps.c               |  4 ---
 libavcodec/h264_refs.c             | 23 +++++++--------
 libavcodec/h264_sei.c              |  3 --
 libavcodec/libxvid_rc.c            |  3 --
 libavcodec/lzwenc.c                |  4 +--
 libavcodec/motion_est.c            |  3 --
 libavcodec/mpeg12dec.c             |  2 +-
 libavcodec/mpegvideo.c             | 17 +++++------
 libavcodec/mpegvideo_enc.c         | 29 +++++++++----------
 libavcodec/mpegvideo_xvmc.c        | 21 ++++++--------
 libavcodec/nellymoserenc.c         |  2 +-
 libavcodec/ppc/h264qpel.c          |  1 +
 libavcodec/ppc/h264qpel_template.c |  2 +-
 libavcodec/ppc/mpegvideo_altivec.c |  3 +-
 libavcodec/put_bits.h              |  1 -
 libavcodec/qcelpdec.c              |  9 ++----
 libavcodec/qdm2.c                  |  4 ---
 libavcodec/ratecontrol.c           | 25 +++++++---------
 libavcodec/sinewin_tablegen.h      |  4 +--
 libavcodec/snowdec.c               |  3 --
 libavcodec/snowenc.c               | 59 ++++++++++++++++++--------------------
 libavcodec/svq1dec.c               |  3 --
 libavcodec/utils.c                 |  3 +-
 libavcodec/vc1.c                   |  3 --
 libavcodec/vc1dec.c                |  3 --
 libavcodec/vdpau.c                 | 27 ++++++++---------
 libavcodec/vdpau_mpeg12.c          |  2 +-
 libavcodec/vdpau_mpeg4.c           |  4 +--
 libavcodec/vdpau_vc1.c             |  4 +--
 libavcodec/vorbisenc.c             | 27 ++++++++---------
 libavcodec/wma.c                   |  3 --
 libavcodec/wmadec.c                |  3 --
 libavcodec/wmaenc.c                |  2 +-
 libavfilter/vf_yadif.c             |  3 --
 libavformat/asfdec.c               | 15 ++++------
 libavformat/asfenc.c               |  4 ---
 libavformat/mov.c                  |  4 ---
 libavformat/movenc.c               |  3 --
 libavformat/mpeg.c                 |  2 --
 libavformat/mpegenc.c              | 17 +++++------
 libavformat/mux.c                  |  3 --
 libavformat/rtpdec_h264.c          | 13 ++++-----
 libavformat/rtpdec_qdm2.c          |  2 +-
 libavformat/swf.h                  |  3 --
 libavformat/utils.c                |  8 ++----
 libavutil/internal.h               |  5 ----
 libavutil/softfloat.c              |  1 -
 libswscale/input.c                 |  1 -
 libswscale/output.c                |  1 -
 libswscale/ppc/yuv2rgb_altivec.c   |  1 -
 libswscale/swscale.c               |  1 -
 libswscale/x86/yuv2rgb.c           |  1 -
 tests/tiny_psnr.c                  |  1 -
 64 files changed, 183 insertions(+), 299 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index 80c3091..752407d 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -57,8 +57,6 @@
 
 #include "cmdutils.h"
 
-#include <assert.h>
-
 const char program_name[] = "ffplay";
 const int program_birth_year = 2003;
 
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index cd7bbb0..fdd7101 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -100,7 +100,6 @@
 #include "aacadtsdec.h"
 #include "libavutil/intfloat.h"
 
-#include <assert.h>
 #include <errno.h>
 #include <math.h>
 #include <string.h>
diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index d2a782e..bd7338e 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -487,9 +487,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_assert1(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_assert1(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.
@@ -845,7 +845,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/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 955925a..afac5d2 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -304,7 +304,7 @@ static void delete_region_display_list(DVBSubContext *ctx, DVBSubRegion *region)
                     obj2 = *obj2_ptr;
 
                     while (obj2 != object) {
-                        assert(obj2);
+                        av_assert1(obj2);
                         obj2_ptr = &obj2->next;
                         obj2 = *obj2_ptr;
                     }
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 0997c73..8aab531 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
 #include "dxva2_internal.h"
 
 void *ff_dxva2_get_surface(const Picture *picture)
@@ -37,7 +38,7 @@ unsigned ff_dxva2_get_surface_index(const struct dxva_context *ctx,
         if (ctx->surface[i] == surface)
             return i;
 
-    assert(0);
+    av_assert0(0);
     return 0;
 }
 
@@ -130,7 +131,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, Picture *pic,
 
     /* TODO Film Grain when possible */
 
-    assert(buffer_count == 1 + (qm_size > 0) + 2);
+    av_assert0(buffer_count == 1 + (qm_size > 0) + 2);
 
     exec.NumCompBuffers      = buffer_count;
     exec.pCompressedBuffers  = buffer;
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 1090502..25e69ea 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
 #include "dxva2_internal.h"
 #include "h264.h"
 #include "h264data.h"
@@ -37,7 +38,7 @@ struct dxva2_picture_context {
 static void fill_picture_entry(DXVA_PicEntry_H264 *pic,
                                unsigned index, unsigned flag)
 {
-    assert((index&0x7f) == index && (flag&0x01) == flag);
+    av_assert0((index&0x7f) == index && (flag&0x01) == flag);
     pic->bPicEntry = index | (flag << 7);
 }
 
@@ -180,8 +181,8 @@ static void fill_scaling_lists(struct dxva_context *ctx, const H264Context *h, D
 
 static int is_slice_short(struct dxva_context *ctx)
 {
-    assert(ctx->cfg->ConfigBitstreamRaw == 1 ||
-           ctx->cfg->ConfigBitstreamRaw == 2);
+    av_assert0(ctx->cfg->ConfigBitstreamRaw == 1 ||
+               ctx->cfg->ConfigBitstreamRaw == 2);
     return ctx->cfg->ConfigBitstreamRaw == 2;
 }
 
@@ -300,10 +301,10 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
         static const unsigned start_code_size = sizeof(start_code);
         unsigned position, size;
 
-        assert(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==
-               offsetof(DXVA_Slice_H264_Long,  BSNALunitDataLocation));
-        assert(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==
-               offsetof(DXVA_Slice_H264_Long,  SliceBytesInBuffer));
+        av_assert0(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==
+                   offsetof(DXVA_Slice_H264_Long,  BSNALunitDataLocation));
+        av_assert0(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==
+                   offsetof(DXVA_Slice_H264_Long,  SliceBytesInBuffer));
 
         if (is_slice_short(ctx))
             slice = &ctx_pic->slice_short[i];
@@ -360,7 +361,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
         slice_data = ctx_pic->slice_long;
         slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_long);
     }
-    assert((bs->DataSize & 127) == 0);
+    av_assert0((bs->DataSize & 127) == 0);
     return ff_dxva2_commit_buffer(avctx, ctx, sc,
                                   DXVA2_SliceControlBufferType,
                                   slice_data, slice_size, mb_count);
@@ -377,7 +378,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx,
 
     if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0)
         return -1;
-    assert(ctx_pic);
+    av_assert0(ctx_pic);
 
     /* Fill up DXVA_PicParams_H264 */
     fill_picture_parameters(ctx, h, &ctx_pic->pp);
diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
index 542f17c..d7829ee 100644
--- a/libavcodec/dxva2_mpeg2.c
+++ b/libavcodec/dxva2_mpeg2.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
 #include "dxva2_internal.h"
 
 #define MAX_SLICES (SLICE_MAX_START_CODE - SLICE_MIN_START_CODE + 1)
@@ -214,7 +215,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx,
 
     if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0)
         return -1;
-    assert(ctx_pic);
+    av_assert0(ctx_pic);
 
     fill_picture_parameters(avctx, ctx, s, &ctx_pic->pp);
     fill_quantization_matrices(avctx, ctx, s, &ctx_pic->qm);
diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
index 92c78fd..2fdd55f 100644
--- a/libavcodec/dxva2_vc1.c
+++ b/libavcodec/dxva2_vc1.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
 #include "dxva2_internal.h"
 #include "vc1.h"
 #include "vc1data.h"
@@ -204,7 +205,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
     bs->CompressedBufferType = DXVA2_BitStreamDateBufferType;
     bs->DataSize             = data_size;
     bs->NumMBsInBuffer       = s->mb_width * s->mb_height;
-    assert((bs->DataSize & 127) == 0);
+    av_assert0((bs->DataSize & 127) == 0);
 
     return ff_dxva2_commit_buffer(avctx, ctx, sc,
                                   DXVA2_SliceControlBufferType,
@@ -221,7 +222,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx,
 
     if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0)
         return -1;
-    assert(ctx_pic);
+    av_assert0(ctx_pic);
 
     fill_picture_parameters(avctx, ctx, v, &ctx_pic->pp);
 
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index e60e58e..ce9a66b 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -39,9 +39,6 @@
 #include "flv.h"
 #include "mpeg4video.h"
 
-//#undef NDEBUG
-//#include <assert.h>
-
 uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
 
 
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 3d3746f..04e14fc 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -48,9 +48,6 @@
 #include "vdpau_internal.h"
 #include "libavutil/avassert.h"
 
-// #undef NDEBUG
-#include <assert.h>
-
 const uint16_t ff_h264_mb_sizes[4] = { 256, 384, 512, 768 };
 
 static const uint8_t rem6[QP_MAX_NUM + 1] = {
@@ -1555,8 +1552,8 @@ static void copy_picture_range(Picture **to, Picture **from, int count,
     int i;
 
     for (i = 0; i < count; i++) {
-        assert((IN_RANGE(from[i], old_base, sizeof(*old_base)) ||
-                IN_RANGE(from[i], old_base->DPB,
+        av_assert1((IN_RANGE(from[i], old_base, sizeof(*old_base)) ||
+                    IN_RANGE(from[i], old_base->DPB,
                          sizeof(Picture) * MAX_PICTURE_COUNT) ||
                 !from[i]));
         to[i] = REBASE_PICTURE(from[i], new_base, old_base);
@@ -1856,7 +1853,7 @@ static int h264_frame_start(H264Context *h)
         h->er.next_pic = NULL;
     }
 
-    assert(h->linesize && h->uvlinesize);
+    av_assert0(h->linesize && h->uvlinesize);
 
     for (i = 0; i < 16; i++) {
         h->block_offset[i]           = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * h->linesize * ((scan8[i] - scan8[0]) >> 3);
@@ -1882,7 +1879,7 @@ static int h264_frame_start(H264Context *h)
 
     h->next_output_pic = NULL;
 
-    assert(h->cur_pic_ptr->long_ref == 0);
+    av_assert0(h->cur_pic_ptr->long_ref == 0);
 
     return 0;
 }
@@ -3458,9 +3455,9 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
          * We have to do that before the "dummy" in-between frame allocation,
          * since that can modify h->cur_pic_ptr. */
         if (h0->first_field) {
-            assert(h0->cur_pic_ptr);
-            assert(h0->cur_pic_ptr->f.data[0]);
-            assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
+            av_assert1(h0->cur_pic_ptr);
+            av_assert1(h0->cur_pic_ptr->f.data[0]);
+            av_assert1(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
 
             /* Mark old field/frame as completed */
             if (!last_pic_droppable && h0->cur_pic_ptr->tf.owner == h0->avctx) {
@@ -3551,9 +3548,9 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
          * We're using that to see whether to continue decoding in that
          * frame, or to allocate a new one. */
         if (h0->first_field) {
-            assert(h0->cur_pic_ptr);
-            assert(h0->cur_pic_ptr->f.data[0]);
-            assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
+            av_assert1(h0->cur_pic_ptr);
+            av_assert1(h0->cur_pic_ptr->f.data[0]);
+            av_assert1(h0->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) {
@@ -4983,7 +4980,7 @@ not_extra:
         }
     }
 
-    assert(pict->data[0] || !*got_frame);
+    av_assert0(pict->data[0] || !*got_frame);
 
     return get_consumed_bytes(buf_index, buf_size);
 }
diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
index 2d93c2a..d38842e 100644
--- a/libavcodec/h264_direct.c
+++ b/libavcodec/h264_direct.c
@@ -32,10 +32,6 @@
 #include "rectangle.h"
 #include "thread.h"
 
-//#undef NDEBUG
-#include <assert.h>
-
-
 static int get_scale_factor(H264Context * const h, int poc, int poc1, int i){
     int poc0 = h->ref_list[0][i].poc;
     int td = av_clip(poc1 - poc0, -128, 127);
@@ -172,7 +168,7 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){
     int mv[2];
     int list;
 
-    assert(h->ref_list[1][0].reference & 3);
+    av_assert2(h->ref_list[1][0].reference & 3);
 
     await_reference_mb_row(h, &h->ref_list[1][0], h->mb_y + !!IS_INTERLACED(*mb_type));
 
@@ -200,7 +196,7 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){
                 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_assert2(match_count==1);
                 if(left_ref==ref[list]){
                     mv[list]= AV_RN32A(A);
                 }else if(top_ref==ref[list]){
@@ -371,7 +367,7 @@ single_col:
                 fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1);
                 fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1);
 
-                assert(b8_stride==2);
+                av_assert2(b8_stride==2);
                 /* col_zero_flag */
                 if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && (   l1ref0[i8] == 0
                                               || (l1ref0[i8] < 0 && l1ref1[i8] == 0
@@ -420,7 +416,7 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){
     unsigned int sub_mb_type;
     int i8, i4;
 
-    assert(h->ref_list[1][0].reference & 3);
+    av_assert2(h->ref_list[1][0].reference & 3);
 
     await_reference_mb_row(h, &h->ref_list[1][0], h->mb_y + !!IS_INTERLACED(*mb_type));
 
@@ -506,7 +502,7 @@ single_col:
 
         if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){
             int y_shift  = 2*!IS_INTERLACED(*mb_type);
-            assert(h->sps.direct_8x8_inference_flag);
+            av_assert2(h->sps.direct_8x8_inference_flag);
 
             for(i8=0; i8<4; i8++){
                 const int x8 = i8&1;
@@ -589,7 +585,7 @@ single_col:
                     continue;
                 }
 
-                assert(b8_stride == 2);
+                av_assert2(b8_stride == 2);
                 ref0 = l1ref0[i8];
                 if(ref0 >= 0)
                     ref0 = map_col_to_list0[0][ref0 + ref_offset];
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 42a6903..12ca711 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -32,10 +32,6 @@
 #include "h264data.h" //FIXME FIXME FIXME (just for zigzag_scan)
 #include "golomb.h"
 
-
-//#undef NDEBUG
-#include <assert.h>
-
 #define MAX_LOG2_MAX_FRAME_NUM    (12 + 4)
 #define MIN_LOG2_MAX_FRAME_NUM    4
 
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 8f6262a..b7090d9 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -31,9 +31,6 @@
 #include "h264.h"
 #include "golomb.h"
 
-//#undef NDEBUG
-#include <assert.h>
-
 #define COPY_PICTURE(dst, src) \
 do {\
     *(dst) = *(src);\
@@ -250,8 +247,8 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
 
                         for (i = h->short_ref_count - 1; i >= 0; i--) {
                             ref = h->short_ref[i];
-                            assert(ref->reference);
-                            assert(!ref->long_ref);
+                            av_assert0(ref->reference);
+                            av_assert0(!ref->long_ref);
                             if (ref->frame_num == frame_num &&
                                 (ref->reference & pic_structure))
                                 break;
@@ -269,10 +266,10 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
                             return -1;
                         }
                         ref = h->long_ref[long_idx];
-                        assert(!(ref && !ref->reference));
+                        av_assert0(!(ref && !ref->reference));
                         if (ref && (ref->reference & pic_structure)) {
                             ref->pic_id = pic_id;
-                            assert(ref->long_ref);
+                            av_assert0(ref->long_ref);
                             i = 0;
                         } else {
                             i = -1;
@@ -410,7 +407,7 @@ static Picture *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],
@@ -450,7 +447,7 @@ static Picture *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--;
@@ -467,7 +464,7 @@ void ff_h264_remove_all_refs(H264Context *h)
     for (i = 0; i < 16; i++) {
         remove_long(h, i, 0);
     }
-    assert(h->long_ref_count == 0);
+    av_assert1(h->long_ref_count == 0);
 
     for (i = 0; i < h->short_ref_count; i++) {
         unreference_pic(h, h->short_ref[i], 0);
@@ -649,7 +646,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
             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 (j = mmco[i].long_arg; j < 16; j++) {
                 remove_long(h, j, 0);
@@ -668,7 +665,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
             for (j = 0; j < MAX_DELAYED_PIC_COUNT; j++)
                 h->last_pocs[j] = INT_MIN;
             break;
-        default: assert(0);
+        default: av_assert0(0);
         }
     }
 
@@ -722,7 +719,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
                 if (h->long_ref[i])
                     break;
 
-            assert(i < 16);
+            av_assert0(i < 16);
             remove_long(h, i, 0);
         } else {
             pic = h->short_ref[h->short_ref_count - 1];
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 5f68a13..bc29c50 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -30,9 +30,6 @@
 #include "h264.h"
 #include "golomb.h"
 
-//#undef NDEBUG
-#include <assert.h>
-
 static const uint8_t sei_num_clock_ts_table[9]={
     1,  1,  1,  2,  2,  3,  3,  2,  3
 };
diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c
index 5da435b..3019bee 100644
--- a/libavcodec/libxvid_rc.c
+++ b/libavcodec/libxvid_rc.c
@@ -29,9 +29,6 @@
 #include "libxvid.h"
 #include "mpegvideo.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 av_cold int ff_xvid_rate_control_init(MpegEncContext *s)
 {
     char *tmp_name;
diff --git a/libavcodec/lzwenc.c b/libavcodec/lzwenc.c
index 7e30765..6e3a5cf 100644
--- a/libavcodec/lzwenc.c
+++ b/libavcodec/lzwenc.c
@@ -111,7 +111,7 @@ static inline int hashOffset(const int head)
  */
 static inline void writeCode(LZWEncodeState * s, int c)
 {
-    assert(0 <= c && c < 1 << s->bits);
+    av_assert2(0 <= c && c < 1 << s->bits);
     s->put_bits(&s->pb, s->bits, c);
 }
 
@@ -207,7 +207,7 @@ void ff_lzw_encode_init(LZWEncodeState *s, uint8_t *outbuf, int outsize,
     s->maxbits = maxbits;
     init_put_bits(&s->pb, outbuf, outsize);
     s->bufsize = outsize;
-    assert(s->maxbits >= 9 && s->maxbits <= LZW_MAXBITS);
+    av_assert2(s->maxbits >= 9 && s->maxbits <= LZW_MAXBITS);
     s->maxcode = 1 << s->maxbits;
     s->output_bytes = 0;
     s->last_code = LZW_PREFIX_EMPTY;
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index f4d217b..2536bcc 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -35,9 +35,6 @@
 #include "mathops.h"
 #include "mpegvideo.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 #define P_LEFT P[1]
 #define P_TOP P[2]
 #define P_TOPRIGHT P[3]
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 78c46fe..f8cac01 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -673,7 +673,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
             s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] =
                 mb_type | MB_TYPE_SKIP;
 
-//            assert(s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1] & (MB_TYPE_16x16 | MB_TYPE_16x8));
+//            av_assert2(s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1] & (MB_TYPE_16x16 | MB_TYPE_16x8));
 
             if ((s->mv[0][0][0] | s->mv[0][0][1] | s->mv[1][0][0] | s->mv[1][0][1]) == 0)
                 s->mb_skipped = 1;
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index f63bf12..ad92f64 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -42,9 +42,6 @@
 #include "thread.h"
 #include <limits.h>
 
-//#undef NDEBUG
-//#include <assert.h>
-
 static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s,
                                    int16_t *block, int n, int qscale);
 static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s,
@@ -153,7 +150,7 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
     s->dest[1] = s->current_picture.f.data[1] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
     s->dest[2] = s->current_picture.f.data[2] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
 
-    assert(ref == 0);
+    av_assert2(ref == 0);
     ff_MPV_decode_mb(s, s->block);
 }
 
@@ -254,7 +251,7 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
     }
 
     if (s->avctx->hwaccel) {
-        assert(!pic->hwaccel_picture_private);
+        av_assert0(!pic->hwaccel_picture_private);
         if (s->avctx->hwaccel->priv_data_size) {
             pic->hwaccel_priv_buf = av_buffer_allocz(s->avctx->hwaccel->priv_data_size);
             if (!pic->hwaccel_priv_buf) {
@@ -392,10 +389,10 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)
             free_picture_tables(pic);
 
     if (shared) {
-        assert(pic->f.data[0]);
+        av_assert0(pic->f.data[0]);
         pic->shared = 1;
     } else {
-        assert(!pic->f.data[0]);
+        av_assert0(!pic->f.data[0]);
 
         if (alloc_frame_buffer(s, pic) < 0)
             return -1;
@@ -1670,8 +1667,8 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
             return ret;
     }
 
-    assert(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr &&
-                                                 s->last_picture_ptr->f.data[0]));
+    av_assert2(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr &&
+                                                     s->last_picture_ptr->f.data[0]));
 
     if (s->picture_structure!= PICT_FRAME) {
         int i;
@@ -1763,7 +1760,7 @@ void ff_MPV_frame_end(MpegEncContext *s)
             break;
         }
     }
-    assert(i < MAX_PICTURE_COUNT);
+    av_assert1(i < MAX_PICTURE_COUNT);
 #endif
 
     if (s->encoding) {
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 5858865..21b94fc 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -52,9 +52,6 @@
 #include <limits.h>
 #include "sp5x.h"
 
-//#undef NDEBUG
-//#include <assert.h>
-
 static int encode_picture(MpegEncContext *s, int picture_number);
 static int dct_quantize_refine(MpegEncContext *s, int16_t *block, int16_t *weight, int16_t *orig, int n, int qscale);
 static int sse_mb(MpegEncContext *s);
@@ -1535,7 +1532,7 @@ vbv_retry:
                 goto vbv_retry;
             }
 
-            assert(s->avctx->rc_max_rate);
+            av_assert0(s->avctx->rc_max_rate);
         }
 
         if (s->flags & CODEC_FLAG_PASS1)
@@ -1547,9 +1544,9 @@ vbv_retry:
         }
 
         if (s->flags & CODEC_FLAG_PASS1)
-            assert(avctx->header_bits + avctx->mv_bits + avctx->misc_bits +
-                   avctx->i_tex_bits + avctx->p_tex_bits ==
-                       put_bits_count(&s->pb));
+            av_assert0(avctx->header_bits + avctx->mv_bits + avctx->misc_bits +
+                       avctx->i_tex_bits + avctx->p_tex_bits ==
+                         put_bits_count(&s->pb));
         flush_put_bits(&s->pb);
         s->frame_bits  = put_bits_count(&s->pb);
 
@@ -1601,7 +1598,7 @@ vbv_retry:
                 av_log(s->avctx, AV_LOG_ERROR,
                        "Internal error, negative bits\n");
 
-            assert(s->repeat_first_field == 0);
+            av_assert0(s->repeat_first_field == 0);
 
             vbv_delay = bits * 90000 / s->avctx->rc_max_rate;
             min_delay = (minbits * 90000LL + s->avctx->rc_max_rate - 1) /
@@ -1637,7 +1634,7 @@ vbv_retry:
     } else {
         s->frame_bits = 0;
     }
-    assert((s->frame_bits & 7) == 0);
+    av_assert0((s->frame_bits & 7) == 0);
 
     pkt->size = s->frame_bits / 8;
     *got_packet = !!pkt->size;
@@ -2236,7 +2233,7 @@ static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegE
         s->dest[0] = s->rd_scratchpad;
         s->dest[1] = s->rd_scratchpad + 16*s->linesize;
         s->dest[2] = s->rd_scratchpad + 16*s->linesize + 8;
-        assert(s->linesize >= 32); //FIXME
+        //av_assert2(s->linesize >= 32); //FIXME
     }
 
     encode_mb(s, motion_x, motion_y);
@@ -2583,7 +2580,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
                         if(r % d == 0){
                             current_packet_size=0;
                             s->pb.buf_ptr= s->ptr_lastgob;
-                            assert(put_bits_ptr(&s->pb) == s->ptr_lastgob);
+                            av_assert2(put_bits_ptr(&s->pb) == s->ptr_lastgob);
                         }
                     }
 
@@ -3111,8 +3108,8 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src)
         }
     }
 
-    assert(put_bits_count(&src->pb) % 8 ==0);
-    assert(put_bits_count(&dst->pb) % 8 ==0);
+    av_assert2(put_bits_count(&src->pb) % 8 ==0);
+    av_assert2(put_bits_count(&dst->pb) % 8 ==0);
     avpriv_copy_bits(&dst->pb, src->pb.buf, put_bits_count(&src->pb));
     flush_put_bits(&dst->pb);
 }
@@ -3155,16 +3152,16 @@ static int estimate_qp(MpegEncContext *s, int dry_run){
 
 /* must be called before writing the header */
 static void set_frame_distances(MpegEncContext * s){
-    assert(s->current_picture_ptr->f.pts != AV_NOPTS_VALUE);
+    av_assert2(s->current_picture_ptr->f.pts != AV_NOPTS_VALUE);
     s->time = s->current_picture_ptr->f.pts * s->avctx->time_base.num;
 
     if(s->pict_type==AV_PICTURE_TYPE_B){
         s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
-        assert(s->pb_time > 0 && s->pb_time < s->pp_time);
+        av_assert2(s->pb_time > 0 && s->pb_time < s->pp_time);
     }else{
         s->pp_time= s->time - s->last_non_b_time;
         s->last_non_b_time= s->time;
-        assert(s->picture_number==0 || s->pp_time > 0);
+        av_assert2(s->picture_number==0 || s->pp_time > 0);
     }
 }
 
diff --git a/libavcodec/mpegvideo_xvmc.c b/libavcodec/mpegvideo_xvmc.c
index 6b0c6ac..6efdc91 100644
--- a/libavcodec/mpegvideo_xvmc.c
+++ b/libavcodec/mpegvideo_xvmc.c
@@ -25,9 +25,6 @@
 #include "avcodec.h"
 #include "mpegvideo.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 #include "xvmc.h"
 #include "xvmc_internal.h"
 
@@ -41,7 +38,7 @@
 void ff_xvmc_init_block(MpegEncContext *s)
 {
     struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
-    assert(render && render->xvmc_id == AV_XVMC_ID);
+    av_assert0(render && render->xvmc_id == AV_XVMC_ID);
 
     s->block = (int16_t (*)[64])(render->data_blocks + render->next_free_data_block_num * 64);
 }
@@ -75,7 +72,7 @@ int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
     struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
     const int mb_block_count = 4 + (1 << s->chroma_format);
 
-    assert(avctx);
+    av_assert0(avctx);
     if (!render || render->xvmc_id != AV_XVMC_ID ||
         !render->data_blocks || !render->mv_blocks ||
         (unsigned int)render->allocated_mv_blocks   > INT_MAX/(64*6) ||
@@ -141,7 +138,7 @@ return -1;
 void ff_xvmc_field_end(MpegEncContext *s)
 {
     struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
-    assert(render);
+    av_assert0(render);
 
     if (render->filled_mv_blocks_num > 0)
         ff_mpeg_draw_horiz_band(s, 0, 0);
@@ -182,9 +179,9 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
 
     // start of XVMC-specific code
     render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
-    assert(render);
-    assert(render->xvmc_id == AV_XVMC_ID);
-    assert(render->mv_blocks);
+    av_assert0(render);
+    av_assert0(render->xvmc_id == AV_XVMC_ID);
+    av_assert0(render->mv_blocks);
 
     // take the next free macroblock
     mv_block = &render->mv_blocks[render->start_mv_blocks_num +
@@ -252,7 +249,7 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
                 }
                 break;
             default:
-                assert(0);
+                av_assert0(0);
         }
 
         mv_block->motion_vertical_field_select = 0;
@@ -319,8 +316,8 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
     }
     render->filled_mv_blocks_num++;
 
-    assert(render->filled_mv_blocks_num     <= render->allocated_mv_blocks);
-    assert(render->next_free_data_block_num <= render->allocated_data_blocks);
+    av_assert0(render->filled_mv_blocks_num     <= render->allocated_mv_blocks);
+    av_assert0(render->next_free_data_block_num <= render->allocated_data_blocks);
     /* The above conditions should not be able to fail as long as this function
      * is used and the following 'if ()' automatically calls a callback to free
      * blocks. */
diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c
index b35820a..4d44bb5 100644
--- a/libavcodec/nellymoserenc.c
+++ b/libavcodec/nellymoserenc.c
@@ -264,7 +264,7 @@ static void get_exponent_dynamic(NellyMoserEncodeContext *s, float *cand, int *i
                 }
             }
         }
-        assert(c); //FIXME
+        //av_assert0(c); //FIXME
     }
 
     best_val = INFINITY;
diff --git a/libavcodec/ppc/h264qpel.c b/libavcodec/ppc/h264qpel.c
index bda7b18..19a8c4e 100644
--- a/libavcodec/ppc/h264qpel.c
+++ b/libavcodec/ppc/h264qpel.c
@@ -20,6 +20,7 @@
 
 #include "config.h"
 #include "libavutil/attributes.h"
+#include "libavutil/avassert.h"
 #include "libavutil/cpu.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/ppc/types_altivec.h"
diff --git a/libavcodec/ppc/h264qpel_template.c b/libavcodec/ppc/h264qpel_template.c
index cfc4560..aa5c662 100644
--- a/libavcodec/ppc/h264qpel_template.c
+++ b/libavcodec/ppc/h264qpel_template.c
@@ -21,7 +21,7 @@
 #include "libavutil/mem.h"
 
 #ifdef DEBUG
-#define ASSERT_ALIGNED(ptr) assert(((unsigned long)ptr&0x0000000F));
+#define ASSERT_ALIGNED(ptr) av_assert0(((unsigned long)ptr&0x0000000F));
 #else
 #define ASSERT_ALIGNED(ptr) ;
 #endif
diff --git a/libavcodec/ppc/mpegvideo_altivec.c b/libavcodec/ppc/mpegvideo_altivec.c
index 4e80e3a..3437942 100644
--- a/libavcodec/ppc/mpegvideo_altivec.c
+++ b/libavcodec/ppc/mpegvideo_altivec.c
@@ -26,6 +26,7 @@
 
 #include "config.h"
 #include "libavutil/attributes.h"
+#include "libavutil/avassert.h"
 #include "libavutil/cpu.h"
 #include "libavutil/ppc/types_altivec.h"
 #include "libavutil/ppc/util_altivec.h"
@@ -42,7 +43,7 @@ static void dct_unquantize_h263_altivec(MpegEncContext *s,
     int i, level, qmul, qadd;
     int nCoeffs;
 
-    assert(s->block_last_index[n]>=0);
+    av_assert1(s->block_last_index[n]>=0);
 
     qadd = (qscale - 1) | 1;
     qmul = qscale << 1;
diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h
index 7320443..3868268 100644
--- a/libavcodec/put_bits.h
+++ b/libavcodec/put_bits.h
@@ -28,7 +28,6 @@
 
 #include <stdint.h>
 #include <stdlib.h>
-#include <assert.h>
 
 #include "libavutil/bswap.h"
 #include "libavutil/common.h"
diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c
index f8fe85d..1fb423f 100644
--- a/libavcodec/qcelpdec.c
+++ b/libavcodec/qcelpdec.c
@@ -40,9 +40,6 @@
 #include "acelp_vectors.h"
 #include "lsp.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 typedef enum {
     I_F_Q = -1,    /**< insufficient frame quality */
     SILENCE,
@@ -135,7 +132,7 @@ static int decode_lspf(QCELPContext *q, float *lspf)
         } else {
             erasure_coeff = QCELP_LSP_OCTAVE_PREDICTOR;
 
-            assert(q->bitrate == I_F_Q);
+            av_assert0(q->bitrate == I_F_Q);
 
             if (q->erasure_count > 1)
                 erasure_coeff *= q->erasure_count < 4 ? 0.9 : 0.7;
@@ -239,7 +236,7 @@ static void decode_gain_and_index(QCELPContext *q, float *gain)
                     av_clip((q->prev_g1[0] + q->prev_g1[1]) / 2 - 5, 0, 54);
             subframes_count = 8;
         } else {
-            assert(q->bitrate == I_F_Q);
+            av_assert0(q->bitrate == I_F_Q);
 
             g1[0] = q->prev_g1[1];
             switch (q->erasure_count) {
@@ -486,7 +483,7 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector)
                   else
                       max_pitch_gain = 0.0;
             } else {
-                assert(q->bitrate == SILENCE);
+                av_assert0(q->bitrate == SILENCE);
                 max_pitch_gain = 1.0;
             }
             for (i = 0; i < 4; i++)
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index daf127e..391a328 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -47,10 +47,6 @@
 #include "qdm2data.h"
 #include "qdm2_tablegen.h"
 
-#undef NDEBUG
-#include <assert.h>
-
-
 #define QDM2_LIST_ADD(list, size, packet) \
 do { \
       if (size > 0) { \
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index 2d1baaa..23c9663 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -31,9 +31,6 @@
 #include "mpegvideo.h"
 #include "libavutil/eval.h"
 
-#undef NDEBUG // Always check asserts, the speed effect is far too small to disable them.
-#include <assert.h>
-
 #ifndef M_E
 #define M_E 2.718281828
 #endif
@@ -202,8 +199,8 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
             }
             e = sscanf(p, " in:%d ", &picture_number);
 
-            assert(picture_number >= 0);
-            assert(picture_number < rcc->num_entries);
+            av_assert0(picture_number >= 0);
+            av_assert0(picture_number < rcc->num_entries);
             rce = &rcc->entry[picture_number];
 
             e += sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d",
@@ -476,7 +473,7 @@ static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pic
     int qmin = s->avctx->lmin;
     int qmax = s->avctx->lmax;
 
-    assert(qmin <= qmax);
+    av_assert0(qmin <= qmax);
 
     switch (pict_type) {
     case AV_PICTURE_TYPE_B:
@@ -776,7 +773,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
     }
 
     if (s->flags & CODEC_FLAG_PASS2) {
-        assert(picture_number >= 0);
+        av_assert0(picture_number >= 0);
         if (picture_number >= rcc->num_entries) {
             av_log(s, AV_LOG_ERROR, "Input is longer than 2-pass log file\n");
             return -1;
@@ -811,7 +808,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
     short_term_q = 0; /* avoid warning */
     if (s->flags & CODEC_FLAG_PASS2) {
         if (pict_type != AV_PICTURE_TYPE_I)
-            assert(pict_type == rce->new_pict_type);
+            av_assert0(pict_type == rce->new_pict_type);
 
         q = rce->new_qscale / br_compensation;
         av_dlog(s, "%f %f %f last:%d var:%d type:%d//\n", q, rce->new_qscale,
@@ -851,9 +848,9 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
         if (q < 0)
             return -1;
 
-        assert(q > 0.0);
+        av_assert0(q > 0.0);
         q = get_diff_limited_q(s, rce, q);
-        assert(q > 0.0);
+        av_assert0(q > 0.0);
 
         // FIXME type dependent blur like in 2-pass
         if (pict_type == AV_PICTURE_TYPE_P || s->intra_only) {
@@ -864,13 +861,13 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
             rcc->short_term_qcount++;
             q = short_term_q = rcc->short_term_qsum / rcc->short_term_qcount;
         }
-        assert(q > 0.0);
+        av_assert0(q > 0.0);
 
         q = modify_qscale(s, rce, q, picture_number);
 
         rcc->pass1_wanted_bits += s->bit_rate / fps;
 
-        assert(q > 0.0);
+        av_assert0(q > 0.0);
     }
 
     if (s->avctx->debug & FF_DEBUG_RC) {
@@ -964,7 +961,7 @@ static int init_pass2(MpegEncContext *s)
             qscale[i] = get_qscale(s, &rcc->entry[i], rate_factor, i);
             rcc->last_qscale_for[rce->pict_type] = qscale[i];
         }
-        assert(filter_size % 2 == 1);
+        av_assert0(filter_size % 2 == 1);
 
         /* fixed I/B QP relative to P mode */
         for (i = FFMAX(0, rcc->num_entries - 300); i < rcc->num_entries; i++) {
@@ -1036,7 +1033,7 @@ static int init_pass2(MpegEncContext *s)
         qscale_sum += av_clip(rcc->entry[i].new_qscale / FF_QP2LAMBDA,
                               s->avctx->qmin, s->avctx->qmax);
     }
-    assert(toobig <= 40);
+    av_assert0(toobig <= 40);
     av_log(s->avctx, AV_LOG_DEBUG,
            "[lavc rc] requested bitrate: %d bps  expected bitrate: %d bps\n",
            s->bit_rate,
diff --git a/libavcodec/sinewin_tablegen.h b/libavcodec/sinewin_tablegen.h
index 2b9c4f2..7046ff4 100644
--- a/libavcodec/sinewin_tablegen.h
+++ b/libavcodec/sinewin_tablegen.h
@@ -23,12 +23,12 @@
 #ifndef AVCODEC_SINEWIN_TABLEGEN_H
 #define AVCODEC_SINEWIN_TABLEGEN_H
 
-#include <assert.h>
 // 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>
 #include "libavutil/attributes.h"
 #include "libavutil/common.h"
+#include "libavutil/avassert.h"
 
 #if !CONFIG_HARDCODED_TABLES
 SINETABLE(  32);
@@ -58,7 +58,7 @@ av_cold void ff_sine_window_init(float *window, int n) {
 }
 
 av_cold void ff_init_ff_sine_windows(int index) {
-    assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows));
+    av_assert0(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows));
 #if !CONFIG_HARDCODED_TABLES
     ff_sine_window_init(ff_sine_windows[index], 1 << index);
 #endif
diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
index c8a0327..b222c22 100644
--- a/libavcodec/snowdec.c
+++ b/libavcodec/snowdec.c
@@ -33,9 +33,6 @@
 #include "mpegvideo.h"
 #include "h263.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, IDWTELEM * old_buffer, int plane_index, int add, int mb_y){
     Plane *p= &s->plane[plane_index];
     const int mb_w= s->b_width  << s->block_max_depth;
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 7266ee1..e041052 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -34,9 +34,6 @@
 #include "mpegvideo.h"
 #include "h263.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 #define QUANTIZE2 0
 
 #if QUANTIZE2==1
@@ -62,10 +59,10 @@ static void find_sse(SnowContext *s, Plane *p, int *score, int score_stride, IDW
             int sx= (x-xo + step/2) / step / Q2_STEP;
             int sy= (y-yo + step/2) / step / Q2_STEP;
             int v= r0[x + y*p->width] - r1[x + y*p->width];
-            assert(sx>=0 && sy>=0 && sx < score_stride);
+            av_assert0(sx>=0 && sy>=0 && sx < score_stride);
             v= ((v+8)>>4)<<4;
             score[sx + sy*score_stride] += v*v;
-            assert(score[sx + sy*score_stride] >= 0);
+            av_assert0(score[sx + sy*score_stride] >= 0);
         }
     }
 }
@@ -102,7 +99,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i
             SubBand *b= &p->band[level][orientation];
             IDWTELEM *dst= best_dequant + (b->ibuf - s->spatial_idwt_buffer);
              DWTELEM *src=       buffer + (b-> buf - s->spatial_dwt_buffer);
-            assert(src == b->buf); // code does not depend on this but it is true currently
+            av_assert0(src == b->buf); // code does not depend on this but it is true currently
 
             quantize(s, b, dst, src, b->stride, s->qbias);
         }
@@ -363,7 +360,7 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
     int s_context= 2*left->level + 2*top->level + tl->level + tr->level;
     int ref, best_ref, ref_score, ref_mx, ref_my;
 
-    assert(sizeof(s->block_state) >= 256);
+    av_assert0(sizeof(s->block_state) >= 256);
     if(s->keyframe){
         set_blocks(s, level, x, y, pl, pcb, pcr, 0, 0, 0, BLOCK_INTRA);
         return 0;
@@ -390,8 +387,8 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
     s->m.mb_y= 0;
     c->skip= 0;
 
-    assert(c->  stride ==   stride);
-    assert(c->uvstride == uvstride);
+    av_assert0(c->  stride ==   stride);
+    av_assert0(c->uvstride == uvstride);
 
     c->penalty_factor    = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp);
     c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp);
@@ -430,10 +427,10 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
         ref_score= ff_epzs_motion_search(&s->m, &ref_mx, &ref_my, P, 0, /*ref_index*/ 0, last_mv,
                                          (1<<16)>>shift, level-LOG2_MB_SIZE+4, block_w);
 
-        assert(ref_mx >= c->xmin);
-        assert(ref_mx <= c->xmax);
-        assert(ref_my >= c->ymin);
-        assert(ref_my <= c->ymax);
+        av_assert0(ref_mx >= c->xmin);
+        av_assert0(ref_mx <= c->xmax);
+        av_assert0(ref_my >= c->ymin);
+        av_assert0(ref_my <= c->ymax);
 
         ref_score= c->sub_motion_search(&s->m, &ref_mx, &ref_my, ref_score, 0, 0, level-LOG2_MB_SIZE+4, block_w);
         ref_score= ff_get_mb_score(&s->m, ref_mx, ref_my, 0, 0, level-LOG2_MB_SIZE+4, block_w, 0);
@@ -496,11 +493,11 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
     i_len= ic.bytestream - ic.bytestream_start;
     iscore += (s->lambda2*(get_rac_count(&ic)-base_bits))>>FF_LAMBDA_SHIFT;
 
-//    assert(score==256*256*256*64-1);
-    assert(iscore < 255*255*256 + s->lambda2*10);
-    assert(iscore >= 0);
-    assert(l>=0 && l<=255);
-    assert(pl>=0 && pl<=255);
+//    av_assert0(score==256*256*256*64-1);
+    av_assert0(iscore < 255*255*256 + s->lambda2*10);
+    av_assert0(iscore >= 0);
+    av_assert0(l>=0 && l<=255);
+    av_assert0(pl>=0 && pl<=255);
 
     if(level==0){
         int varc= iscore >> 8;
@@ -776,7 +773,7 @@ static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uin
             }
         }
     }else{
-        assert(block_w==8);
+        av_assert0(block_w==8);
         distortion = s->dsp.me_cmp[0](&s->m, src + sx + sy*ref_stride, dst + sx + sy*ref_stride, ref_stride, block_w*2);
     }
 
@@ -840,7 +837,7 @@ static int get_4block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index){
                 memcpy(dst + w + y2*ref_stride, src + w + y2*ref_stride, x+block_w - w);
         }
 
-        assert(block_w== 8 || block_w==16);
+        av_assert0(block_w== 8 || block_w==16);
         distortion += s->dsp.me_cmp[block_w==8](&s->m, src + x + y*ref_stride, dst + x + y*ref_stride, ref_stride, block_h);
     }
 
@@ -963,10 +960,10 @@ static int encode_subband_c0run(SnowContext *s, SubBand *b, const IDWTELEM *src,
 
                         if(run_index <= max_index)
                             put_symbol2(&s->c, b->state[1], run, 3);
-                        assert(v);
+                        av_assert0(v);
                     }else{
                         run--;
-                        assert(!v);
+                        av_assert0(!v);
                     }
                 }
                 if(v){
@@ -997,8 +994,8 @@ static av_always_inline int check_block(SnowContext *s, int mb_x, int mb_y, int
     unsigned value;
     int rd, index;
 
-    assert(mb_x>=0 && mb_y>=0);
-    assert(mb_x<b_stride);
+    av_assert0(mb_x>=0 && mb_y>=0);
+    av_assert0(mb_x<b_stride);
 
     if(intra){
         block->color[0] = p[0];
@@ -1051,9 +1048,9 @@ static av_always_inline int check_4block_inter(SnowContext *s, int mb_x, int mb_
     backup[2] = block[b_stride];
     backup[3] = block[b_stride + 1];
 
-    assert(mb_x>=0 && mb_y>=0);
-    assert(mb_x<b_stride);
-    assert(((mb_x|mb_y)&1) == 0);
+    av_assert0(mb_x>=0 && mb_y>=0);
+    av_assert0(mb_x<b_stride);
+    av_assert0(((mb_x|mb_y)&1) == 0);
 
     index= (p0 + 31*p1) & (ME_CACHE_SIZE-1);
     value= s->me_cache_generation + (p0>>10) + (p1<<6) + (block->ref<<12);
@@ -1601,7 +1598,7 @@ static int ratecontrol_1pass(SnowContext *s, AVFrame *pict)
 
     /* ugly, ratecontrol just takes a sqrt again */
     coef_sum = (uint64_t)coef_sum * coef_sum >> 16;
-    assert(coef_sum < INT_MAX);
+    av_assert0(coef_sum < INT_MAX);
 
     if(pict->pict_type == AV_PICTURE_TYPE_I){
         s->m.current_picture.mb_var_sum= coef_sum;
@@ -1715,8 +1712,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         int block_height= (height+15)>>4;
         int stride= s->current_picture.linesize[0];
 
-        assert(s->current_picture.data[0]);
-        assert(s->last_picture[0].data[0]);
+        av_assert0(s->current_picture.data[0]);
+        av_assert0(s->last_picture[0].data[0]);
 
         s->m.avctx= s->avctx;
         s->m.current_picture.f.data[0] = s->current_picture.data[0];
@@ -1858,7 +1855,7 @@ redo_frame:
                         decorrelate(s, b, b->ibuf, b->stride, pic->pict_type == AV_PICTURE_TYPE_P, 0);
                     if (!s->no_bitstream)
                     encode_subband(s, b, b->ibuf, b->parent ? b->parent->ibuf : NULL, b->stride, orientation);
-                    assert(b->parent==NULL || b->parent->stride == b->stride*2);
+                    av_assert0(b->parent==NULL || b->parent->stride == b->stride*2);
                     if(orientation==0)
                         correlate(s, b, b->ibuf, b->stride, 1, 0);
                 }
diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c
index 5f43a97..b04334a 100644
--- a/libavcodec/svq1dec.c
+++ b/libavcodec/svq1dec.c
@@ -39,9 +39,6 @@
 #include "mathops.h"
 #include "svq1.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 extern const uint8_t ff_mvtab[33][2];
 
 static VLC svq1_block_type;
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 573bba6..3f841d1 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -38,7 +38,6 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/samplefmt.h"
 #include "libavutil/dict.h"
-#include "libavutil/avassert.h"
 #include "avcodec.h"
 #include "dsputil.h"
 #include "libavutil/opt.h"
@@ -3176,7 +3175,7 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p,
 {
     int i;
 
-    assert(p <= end);
+    av_assert0(p <= end);
     if (p >= end)
         return end;
 
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index 818e8d3..0a2085b 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -37,9 +37,6 @@
 #include "unary.h"
 #include "simple_idct.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 /***********************************************************************/
 /**
  * @name VC-1 Bitplane decoding
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 4cdf470..765494e 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -41,9 +41,6 @@
 #include "vdpau_internal.h"
 #include "libavutil/avassert.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 #define MB_INTRA_VLC_BITS 9
 #define DC_VLC_BITS 9
 
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 04355b0..34b41a8 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -26,9 +26,6 @@
 #include "h264.h"
 #include "vc1.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 #include "vdpau.h"
 #include "vdpau_internal.h"
 
@@ -97,7 +94,7 @@ void ff_vdpau_h264_set_reference_frames(H264Context *h)
     int i, list, pic_frame_idx;
 
     render = (struct vdpau_render_state *)h->cur_pic_ptr->f.data[0];
-    assert(render);
+    av_assert0(render);
 
     rf = &render->info.h264.referenceFrames[0];
 #define H264_RF_COUNT FF_ARRAY_ELEMS(render->info.h264.referenceFrames)
@@ -113,7 +110,7 @@ void ff_vdpau_h264_set_reference_frames(H264Context *h)
             pic_frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num;
 
             render_ref = (struct vdpau_render_state *)pic->f.data[0];
-            assert(render_ref);
+            av_assert0(render_ref);
 
             rf2 = &render->info.h264.referenceFrames[0];
             while (rf2 != rf) {
@@ -160,7 +157,7 @@ void ff_vdpau_h264_set_reference_frames(H264Context *h)
 void ff_vdpau_add_data_chunk(uint8_t *data, const uint8_t *buf, int buf_size)
 {
     struct vdpau_render_state *render = (struct vdpau_render_state*)data;
-    assert(render);
+    av_assert0(render);
 
     render->bitstream_buffers= av_fast_realloc(
         render->bitstream_buffers,
@@ -181,7 +178,7 @@ void ff_vdpau_h264_picture_start(H264Context *h)
     int i;
 
     render = (struct vdpau_render_state *)h->cur_pic_ptr->f.data[0];
-    assert(render);
+    av_assert0(render);
 
     for (i = 0; i < 2; ++i) {
         int foc = h->cur_pic_ptr->field_poc[i];
@@ -198,7 +195,7 @@ void ff_vdpau_h264_picture_complete(H264Context *h)
     struct vdpau_render_state *render;
 
     render = (struct vdpau_render_state *)h->cur_pic_ptr->f.data[0];
-    assert(render);
+    av_assert0(render);
 
     render->info.h264.slice_count = h->slice_num;
     if (render->info.h264.slice_count < 1)
@@ -247,7 +244,7 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
     if (!s->current_picture_ptr) return;
 
     render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
-    assert(render);
+    av_assert0(render);
 
     /* fill VdpPictureInfoMPEG1Or2 struct */
     render->info.mpeg.picture_structure          = s->picture_structure;
@@ -276,7 +273,7 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
     switch(s->pict_type){
     case  AV_PICTURE_TYPE_B:
         next = (struct vdpau_render_state *)s->next_picture.f.data[0];
-        assert(next);
+        av_assert0(next);
         render->info.mpeg.backward_reference     = next->surface;
         // no return here, going to set forward prediction
     case  AV_PICTURE_TYPE_P:
@@ -304,7 +301,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
     struct vdpau_render_state *render, *last, *next;
 
     render = (struct vdpau_render_state *)s->current_picture.f.data[0];
-    assert(render);
+    av_assert0(render);
 
     /*  fill LvPictureInfoVC1 struct */
     render->info.vc1.frame_coding_mode  = v->fcm ? v->fcm + 1 : 0;
@@ -348,7 +345,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
     switch(s->pict_type){
     case  AV_PICTURE_TYPE_B:
         next = (struct vdpau_render_state *)s->next_picture.f.data[0];
-        assert(next);
+        av_assert0(next);
         render->info.vc1.backward_reference = next->surface;
         // no break here, going to set forward prediction
     case  AV_PICTURE_TYPE_P:
@@ -377,7 +374,7 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
     if (!s->current_picture_ptr) return;
 
     render = (struct vdpau_render_state *)s->current_picture_ptr->f.data[0];
-    assert(render);
+    av_assert0(render);
 
     /* fill VdpPictureInfoMPEG4Part2 struct */
     render->info.mpeg4.trd[0]                            = s->pp_time;
@@ -406,13 +403,13 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
     switch (s->pict_type) {
     case AV_PICTURE_TYPE_B:
         next = (struct vdpau_render_state *)s->next_picture.f.data[0];
-        assert(next);
+        av_assert0(next);
         render->info.mpeg4.backward_reference     = next->surface;
         render->info.mpeg4.vop_coding_type        = 2;
         // no break here, going to set forward prediction
     case AV_PICTURE_TYPE_P:
         last = (struct vdpau_render_state *)s->last_picture.f.data[0];
-        assert(last);
+        av_assert0(last);
         render->info.mpeg4.forward_reference      = last->surface;
     }
 
diff --git a/libavcodec/vdpau_mpeg12.c b/libavcodec/vdpau_mpeg12.c
index 74e3f16..d9cce34 100644
--- a/libavcodec/vdpau_mpeg12.c
+++ b/libavcodec/vdpau_mpeg12.c
@@ -43,7 +43,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_picture);
-        assert(ref != VDP_INVALID_HANDLE);
+        av_assert0(ref != VDP_INVALID_HANDLE);
         hwctx->info.mpeg.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 cb8ee0a..0ed64d2 100644
--- a/libavcodec/vdpau_mpeg4.c
+++ b/libavcodec/vdpau_mpeg4.c
@@ -44,13 +44,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_picture);
-        assert(ref != VDP_INVALID_HANDLE);
+        av_assert0(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_picture);
-        assert(ref != VDP_INVALID_HANDLE);
+        av_assert0(ref != VDP_INVALID_HANDLE);
         info->forward_reference  = ref;
     }
 
diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c
index 993ef26..0111845 100644
--- a/libavcodec/vdpau_vc1.c
+++ b/libavcodec/vdpau_vc1.c
@@ -44,12 +44,12 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
     switch (s->pict_type) {
     case AV_PICTURE_TYPE_B:
         ref = ff_vdpau_get_surface_id(&s->next_picture);
-        assert(ref != VDP_INVALID_HANDLE);
+        av_assert0(ref != VDP_INVALID_HANDLE);
         info->backward_reference = ref;
         /* fall-through */
     case AV_PICTURE_TYPE_P:
         ref = ff_vdpau_get_surface_id(&s->last_picture);
-        assert(ref != VDP_INVALID_HANDLE);
+        av_assert0(ref != VDP_INVALID_HANDLE);
         info->forward_reference  = ref;
     }
 
diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index d685996..4771077 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -34,9 +34,6 @@
 #define BITSTREAM_WRITER_LE
 #include "put_bits.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 typedef struct {
     int nentries;
     uint8_t *lens;
@@ -140,9 +137,9 @@ typedef struct {
 static inline int put_codeword(PutBitContext *pb, vorbis_enc_codebook *cb,
                                int entry)
 {
-    assert(entry >= 0);
-    assert(entry < cb->nentries);
-    assert(cb->lens[entry]);
+    av_assert0(entry >= 0);
+    av_assert0(entry < cb->nentries);
+    av_assert0(cb->lens[entry]);
     if (pb->size_in_bits - put_bits_count(pb) < cb->lens[entry])
         return AVERROR(EINVAL);
     put_bits(pb, cb->lens[entry], cb->codewords[entry]);
@@ -198,7 +195,7 @@ static int ready_codebook(vorbis_enc_codebook *cb)
 static int ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
 {
     int i;
-    assert(rc->type == 2);
+    av_assert0(rc->type == 2);
     rc->maxes = av_mallocz(sizeof(float[2]) * rc->classifications);
     if (!rc->maxes)
         return AVERROR(ENOMEM);
@@ -211,8 +208,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_assert0(cb->ndimensions >= 2);
+        av_assert0(cb->lookup);
 
         for (j = 0; j < cb->nentries; j++) {
             float a;
@@ -818,7 +815,7 @@ static int floor_encode(vorbis_enc_context *venc, vorbis_enc_floor *fc,
                     if (coded[counter + k] < maxval)
                         break;
                 }
-                assert(l != csub);
+                av_assert0(l != csub);
                 cval   |= l << cshift;
                 cshift += c->subclass;
             }
@@ -849,7 +846,7 @@ static float *put_vector(vorbis_enc_codebook *book, PutBitContext *pb,
 {
     int i, entry = -1;
     float distance = FLT_MAX;
-    assert(book->dimensions);
+    av_assert0(book->dimensions);
     for (i = 0; i < book->nentries; i++) {
         float * vec = book->dimensions + i * book->ndimensions, d = book->pow2[i];
         int j;
@@ -878,8 +875,8 @@ static int residue_encode(vorbis_enc_context *venc, vorbis_enc_residue *rc,
     int classes[MAX_CHANNELS][NUM_RESIDUE_PARTITIONS];
     int classwords = venc->codebooks[rc->classbook].ndimensions;
 
-    assert(rc->type == 2);
-    assert(real_ch == 2);
+    av_assert0(rc->type == 2);
+    av_assert0(real_ch == 2);
     for (p = 0; p < partitions; p++) {
         float max1 = 0., max2 = 0.;
         int s = rc->begin + p * psize;
@@ -916,8 +913,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_assert0(rc->type == 0 || rc->type == 2);
+                    av_assert0(!(psize % book->ndimensions));
 
                     if (rc->type == 0) {
                         for (k = 0; k < psize; k += book->ndimensions) {
diff --git a/libavcodec/wma.c b/libavcodec/wma.c
index b6dab4b..cc7e952 100644
--- a/libavcodec/wma.c
+++ b/libavcodec/wma.c
@@ -26,9 +26,6 @@
 #include "wma_common.h"
 #include "wmadata.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 /* XXX: use same run/length optimization as mpeg decoders */
 //FIXME maybe split decode / encode or pass flag
 static av_cold void init_coef_vlc(VLC *vlc, uint16_t **prun_table,
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index d46eb33..69ab791 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -38,9 +38,6 @@
 #include "internal.h"
 #include "wma.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 #define EXPVLCBITS 8
 #define EXPMAX ((19+EXPVLCBITS-1)/EXPVLCBITS)
 
diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index d061cde..e74c6a6 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -177,7 +177,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
     }
 
     s->block_len = 1 << s->block_len_bits;
-//     assert((s->block_pos + s->block_len) <= s->frame_len);
+//     av_assert0((s->block_pos + s->block_len) <= s->frame_len);
     bsize = s->frame_len_bits - s->block_len_bits;
 
     //FIXME factor
diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index 5d8934b..75d0d34 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -28,9 +28,6 @@
 #include "video.h"
 #include "yadif.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 #define CHECK(j)\
     {   int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\
                   + FFABS(cur[mrefs  +(j)] - cur[prefs  -(j)])\
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index b2358a7..3d83edd 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -93,9 +93,6 @@ static const AVClass asf_class = {
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
-#undef NDEBUG
-#include <assert.h>
-
 #define ASF_MAX_STREAMS 127
 #define FRAME_HEADER_SIZE 16
 // Fix Me! FRAME_HEADER_SIZE may be different. (17 is known to be too large)
@@ -1123,7 +1120,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
             asf->packet_segments < 1) {
             int ret = asf->packet_size_left + asf->packet_padsize;
 
-            assert(ret >= 0);
+            av_assert0(ret >= 0);
             /* fail safe */
             avio_skip(pb, ret);
 
@@ -1294,8 +1291,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_assert0(offset + asf_st->ds_chunk_size <= asf_st->pkt.size);
+                            av_assert0(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);
@@ -1334,8 +1331,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_assert0(asf->packet_size_left < FRAME_HEADER_SIZE ||
+                       asf->packet_segments < 1);
         asf->packet_time_start = 0;
     }
 }
@@ -1423,7 +1420,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index,
             asf_st = s->streams[i]->priv_data;
             av_assert0(asf_st);
 
-//            assert((asf_st->packet_pos - s->data_offset) % s->packet_size == 0);
+//            av_assert0((asf_st->packet_pos - s->data_offset) % s->packet_size == 0);
             pos = asf_st->packet_pos;
 
             av_add_index_entry(s->streams[i], pos, pts, pkt->size,
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 6daf238..8aa6358 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -27,10 +27,6 @@
 #include "riff.h"
 #include "asf.h"
 
-#undef NDEBUG
-#include <assert.h>
-
-
 #define ASF_INDEXED_INTERVAL    10000000
 #define ASF_INDEX_BLOCK         (1<<9)
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index a28631b..07a75d7 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -53,10 +53,6 @@
 
 #include "qtpalette.h"
 
-
-#undef NDEBUG
-#include <assert.h>
-
 /* those functions parse an atom */
 /* links atom IDs to parse functions */
 typedef struct MOVParseTableEntry {
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8b3ad7f..324edee 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -40,9 +40,6 @@
 #include "rtpenc.h"
 #include "mov_chan.h"
 
-#undef NDEBUG
-#include <assert.h>
-
 static const AVOption options[] = {
     { "movflags", "MOV muxer flags", offsetof(MOVMuxContext, flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
     { "rtphint", "Add RTP hint tracks", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_RTP_HINT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 5d5b09f..10b1402 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -28,8 +28,6 @@
 # include "libavutil/bprint.h"
 #endif
 
-#undef NDEBUG
-#include <assert.h>
 #include "libavutil/avassert.h"
 
 /*********************************************/
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 6f6da5c..639b8b9 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -31,9 +31,6 @@
 
 #define MAX_PAYLOAD_SIZE 4096
 
-#undef NDEBUG
-#include <assert.h>
-
 typedef struct PacketDesc {
     int64_t pts;
     int64_t dts;
@@ -840,7 +837,7 @@ static int flush_packet(AVFormatContext *ctx, int stream_index,
         }
 
         /* output data */
-        assert(payload_size - stuffing_size <= av_fifo_size(stream->fifo));
+        av_assert0(payload_size - stuffing_size <= av_fifo_size(stream->fifo));
         av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, (void*)avio_write);
         stream->bytes_to_iframe -= payload_size - stuffing_size;
     }else{
@@ -948,7 +945,7 @@ retry:
             return 0;
         if(avail_data==0)
             continue;
-        assert(avail_data>0);
+        av_assert0(avail_data>0);
 
         if(space < s->packet_size && !ignore_constraints)
             continue;
@@ -989,14 +986,14 @@ retry:
         goto retry;
     }
 
-    assert(best_i >= 0);
+    av_assert0(best_i >= 0);
 
     st = ctx->streams[best_i];
     stream = st->priv_data;
 
-    assert(av_fifo_size(stream->fifo) > 0);
+    av_assert0(av_fifo_size(stream->fifo) > 0);
 
-    assert(avail_space >= s->packet_size || ignore_constraints);
+    av_assert0(avail_space >= s->packet_size || ignore_constraints);
 
     timestamp_packet= stream->premux_packet;
     if(timestamp_packet->unwritten_size == timestamp_packet->size){
@@ -1013,7 +1010,7 @@ retry:
                 scr / 90000.0, best_i);
         es_size= flush_packet(ctx, best_i, timestamp_packet->pts, timestamp_packet->dts, scr, trailer_size);
     }else{
-        assert(av_fifo_size(stream->fifo) == trailer_size);
+        av_assert0(av_fifo_size(stream->fifo) == trailer_size);
         es_size= flush_packet(ctx, best_i, AV_NOPTS_VALUE, AV_NOPTS_VALUE, scr, trailer_size);
     }
 
@@ -1136,7 +1133,7 @@ static int mpeg_mux_end(AVFormatContext *ctx)
     for(i=0;i<ctx->nb_streams;i++) {
         stream = ctx->streams[i]->priv_data;
 
-        assert(av_fifo_size(stream->fifo) == 0);
+        av_assert0(av_fifo_size(stream->fifo) == 0);
         av_fifo_free(stream->fifo);
     }
     return 0;
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 586137f..084a4cf 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -45,9 +45,6 @@
 #include "network.h"
 #endif
 
-#undef NDEBUG
-#include <assert.h>
-
 /**
  * @file
  * muxing functions for use within libavformat
diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c
index be657c0..ea8defb 100644
--- a/libavformat/rtpdec_h264.c
+++ b/libavformat/rtpdec_h264.c
@@ -40,7 +40,6 @@
 #include "avformat.h"
 
 #include "network.h"
-#include <assert.h>
 
 #include "rtpdec.h"
 #include "rtpdec_formats.h"
@@ -69,8 +68,8 @@ static int sdp_parse_fmtp_config_h264(AVStream *stream,
                                       char *attr, char *value)
 {
     AVCodecContext *codec = stream->codec;
-    assert(codec->codec_id == AV_CODEC_ID_H264);
-    assert(h264_data != NULL);
+    av_assert0(codec->codec_id == AV_CODEC_ID_H264);
+    av_assert0(h264_data != NULL);
 
     if (!strcmp(attr, "packetization-mode")) {
         av_log(codec, AV_LOG_DEBUG, "RTP Packetization Mode: %d\n", atoi(value));
@@ -180,8 +179,8 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
     nal  = buf[0];
     type = nal & 0x1f;
 
-    assert(data);
-    assert(buf);
+    av_assert0(data);
+    av_assert0(buf);
 
     /* Simplify the case (these are all the nal types used internally by
      * the h264 codec). */
@@ -223,7 +222,7 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
                             total_length += sizeof(start_sequence) + nal_size;
                         } else {
                             // copying
-                            assert(dst);
+                            av_assert0(dst);
                             memcpy(dst, start_sequence, sizeof(start_sequence));
                             dst += sizeof(start_sequence);
                             memcpy(dst, src, nal_size);
@@ -250,7 +249,7 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
                     av_new_packet(pkt, total_length);
                     dst = pkt->data;
                 } else {
-                    assert(dst - pkt->data == total_length);
+                    av_assert0(dst - pkt->data == total_length);
                 }
             }
         }
diff --git a/libavformat/rtpdec_qdm2.c b/libavformat/rtpdec_qdm2.c
index 6ce776d..854a181 100644
--- a/libavformat/rtpdec_qdm2.c
+++ b/libavformat/rtpdec_qdm2.c
@@ -190,7 +190,7 @@ static int qdm2_restore_block(PayloadContext *qdm, AVStream *st, AVPacket *pkt)
     uint8_t *p, *csum_pos = NULL;
 
     /* create packet to hold subpkts into a superblock */
-    assert(qdm->cache > 0);
+    av_assert0(qdm->cache > 0);
     for (n = 0; n < 0x80; n++)
         if (qdm->len[n] > 0)
             break;
diff --git a/libavformat/swf.h b/libavformat/swf.h
index b9722c1..c1667b3 100644
--- a/libavformat/swf.h
+++ b/libavformat/swf.h
@@ -120,9 +120,6 @@ enum {
 #define VIDEO_ID 0
 #define SHAPE_ID  1
 
-#undef NDEBUG
-#include <assert.h>
-
 typedef struct SWFContext {
     int64_t duration_pos;
     int64_t tag_pos;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index eff9373..082c19e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -33,7 +33,6 @@
 #include "libavutil/pixdesc.h"
 #include "metadata.h"
 #include "id3v2.h"
-#include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/parseutils.h"
@@ -47,9 +46,6 @@
 #include "network.h"
 #endif
 
-#undef NDEBUG
-#include <assert.h>
-
 /**
  * @file
  * various utility functions for use within FFmpeg
@@ -1949,7 +1945,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,
     while (pos_min < pos_limit) {
         av_dlog(s, "pos_min=0x%"PRIx64" pos_max=0x%"PRIx64" dts_min=%s dts_max=%s\n",
                 pos_min, pos_max, av_ts2str(ts_min), av_ts2str(ts_max));
-        assert(pos_limit <= pos_max);
+        av_assert0(pos_limit <= pos_max);
 
         if(no_change==0){
             int64_t approximate_keyframe_distance= pos_max - pos_limit;
@@ -1983,7 +1979,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,
             av_log(s, AV_LOG_ERROR, "read_timestamp() failed in the middle\n");
             return -1;
         }
-        assert(ts != AV_NOPTS_VALUE);
+        av_assert0(ts != AV_NOPTS_VALUE);
         if (target_ts <= ts) {
             pos_limit = start_pos - 1;
             pos_max = pos;
diff --git a/libavutil/internal.h b/libavutil/internal.h
index c5835fb..9826d0c 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -26,14 +26,9 @@
 #ifndef AVUTIL_INTERNAL_H
 #define AVUTIL_INTERNAL_H
 
-#if !defined(DEBUG) && !defined(NDEBUG)
-#    define NDEBUG
-#endif
-
 #include <limits.h>
 #include <stdint.h>
 #include <stddef.h>
-#include <assert.h>
 #include "config.h"
 #include "attributes.h"
 #include "timer.h"
diff --git a/libavutil/softfloat.c b/libavutil/softfloat.c
index efa0420..bf9cfda 100644
--- a/libavutil/softfloat.c
+++ b/libavutil/softfloat.c
@@ -20,7 +20,6 @@
 
 #include <inttypes.h>
 #include <stdio.h>
-#include <assert.h>
 #include "softfloat.h"
 #include "common.h"
 #include "log.h"
diff --git a/libswscale/input.c b/libswscale/input.c
index 35caa32..09543eb 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -18,7 +18,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <assert.h>
 #include <math.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/libswscale/output.c b/libswscale/output.c
index 9c7284b..31c14f0 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -18,7 +18,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <assert.h>
 #include <math.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
index a2fc884..27de033 100644
--- a/libswscale/ppc/yuv2rgb_altivec.c
+++ b/libswscale/ppc/yuv2rgb_altivec.c
@@ -89,7 +89,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <inttypes.h>
-#include <assert.h>
 
 #include "config.h"
 #include "libswscale/rgb2rgb.h"
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index c5bba82..cec4288 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -18,7 +18,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <assert.h>
 #include <inttypes.h>
 #include <math.h>
 #include <stdio.h>
diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c
index 3938e6b..cceca49 100644
--- a/libswscale/x86/yuv2rgb.c
+++ b/libswscale/x86/yuv2rgb.c
@@ -27,7 +27,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <inttypes.h>
-#include <assert.h>
 
 #include "config.h"
 #include "libswscale/rgb2rgb.h"
diff --git a/tests/tiny_psnr.c b/tests/tiny_psnr.c
index 264aa4d..5d01065 100644
--- a/tests/tiny_psnr.c
+++ b/tests/tiny_psnr.c
@@ -22,7 +22,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <inttypes.h>
-#include <assert.h>
 
 #include "libavutil/intfloat.h"
 
-- 
1.8.2.3



More information about the ffmpeg-devel mailing list