diff options
54 files changed, 478 insertions, 381 deletions
diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index 8509ce6e6..e8ae92a34 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -26,7 +26,7 @@ * (c) 2001 James Courtier-Dutton <James@superbug.demon.co.uk> * * - * $Id: audio_alsa_out.c,v 1.85 2002/12/21 12:56:46 miguelfreitas Exp $ + * $Id: audio_alsa_out.c,v 1.86 2003/02/28 02:51:47 storri Exp $ */ #ifdef HAVE_CONFIG_H @@ -521,8 +521,7 @@ static int ao_alsa_write(ao_driver_t *this_gen,int16_t *data, uint32_t count) snd_pcm_status_dump(pcm_stat, jcd_out); #endif if ((res = snd_pcm_prepare(this->audio_fd))<0) { - printf ("audio_alsa_out: xrun: prepare error: %s", snd_strerror(res)); - assert(0); + XINE_ASSERT (0,"audio_alsa_out: xrun: prepare error: %s", snd_strerror(res)); } state = snd_pcm_state(this->audio_fd); #ifdef LOG_DEBUG @@ -556,8 +555,7 @@ static int ao_alsa_write(ao_driver_t *this_gen,int16_t *data, uint32_t count) (state != SND_PCM_STATE_DRAINING) ) { printf("audio_alsa_out:write:BAD STATE2, state = %d, going to try XRUN\n",state); if ((res = snd_pcm_prepare(this->audio_fd))<0) { - printf ("audio_alsa_out: xrun: prepare error: %s", snd_strerror(res)); - assert(0); + XINE_ASSERT(0, "audio_alsa_out: xrun: prepare error: %s", snd_strerror(res)); } } } diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index 786835df7..e7394e48d 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_dvd.c,v 1.130 2003/02/26 20:45:18 mroi Exp $ + * $Id: input_dvd.c,v 1.131 2003/02/28 02:51:48 storri Exp $ * */ @@ -1175,8 +1175,7 @@ static input_plugin_t *open_plugin (input_class_t *class_gen, xine_stream_t *str this = (dvd_input_plugin_t *) xine_xmalloc (sizeof (dvd_input_plugin_t)); if (this == NULL) { - printf("input_dvd.c: xine_xmalloc failed!!!! You have run out of memory\n"); - assert(0); + XINE_ASSERT(0, "input_dvd.c: xine_xmalloc failed!!!! You have run out of memory\n"); } this->input_plugin.get_capabilities = dvd_plugin_get_capabilities; @@ -1569,6 +1568,37 @@ static void *init_class (xine_t *xine, void *data) { /* * $Log: input_dvd.c,v $ + * Revision 1.131 2003/02/28 02:51:48 storri + * Xine assert() replacement: + * + * All assert() function calls, with exceptions of libdvdread and libdvdnav, have been + * replaced with XINE_ASSERT. Functionally XINE_ASSERT behaves just likes its predecesor but its + * adding the ability to print out a stack trace at the point where the assertion fails. + * So here are a few examples. + * + * assert (0); + * + * This use of assert was found in a couple locations most favorably being the default case of a switch + * statement. This was the only thing there. So if the switch statement was unable to find a match + * it would have defaulted to this and the user and the developers would be stuck wonder who died and where. + * + * So it has been replaced with + * + * XINE_ASSERT(0, "We have reach this point and don't have a default case"); + * + * It may seem a bit none descriptive but there is more going on behind the scene. + * + * In addition to checking a condition is true/false, in this case '0', the XINE_ASSERT + * prints out: + * + * <filename>:<function name>:<line number> - assertion '<assertion expression>' failed. <description> + * + * An example of this might be: + * + * input_dvd.c:open_plugin:1178 - assertion '0' failed. xine_malloc failed!!! You have run out of memory + * + * XINE_ASSERT and its helper function, print_trace, are found in src/xine-utils/xineutils.h + * * Revision 1.130 2003/02/26 20:45:18 mroi * adjust input_dvd to handle DVDNAV_WAIT events properly * (that is: wait for the fifos to become empty) diff --git a/src/input/input_mms.c b/src/input/input_mms.c index 8fbf1b63c..ad1640bb2 100644 --- a/src/input/input_mms.c +++ b/src/input/input_mms.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_mms.c,v 1.37 2003/02/24 00:12:06 tmattern Exp $ + * $Id: input_mms.c,v 1.38 2003/02/28 02:51:48 storri Exp $ * * mms input plugin based on work from major mms */ @@ -28,7 +28,6 @@ #include <unistd.h> #include <stdio.h> -#include <assert.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> diff --git a/src/input/input_plugin.h b/src/input/input_plugin.h index d0600bb43..853cb986c 100644 --- a/src/input/input_plugin.h +++ b/src/input/input_plugin.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_plugin.h,v 1.45 2003/02/13 16:24:27 mroi Exp $ + * $Id: input_plugin.h,v 1.46 2003/02/28 02:51:48 storri Exp $ */ #ifndef HAVE_INPUT_PLUGIN_H @@ -25,7 +25,7 @@ #include <inttypes.h> #include <sys/types.h> -#include <assert.h> +#include "xineutils.h" #include "buffer.h" #include "configfile.h" @@ -305,8 +305,8 @@ struct input_plugin_s { * Duplicate two mrls entries (s = source, d = destination). */ #define MRL_DUPLICATE(s, d) { \ - assert((s) != NULL); \ - assert((d) != NULL); \ + XINE_ASSERT((s) != NULL, "value 's' is NULL"); \ + XINE_ASSERT((d) != NULL, "value 'd' is NULL"); \ \ if((s)->origin) { \ if((d)->origin) { \ @@ -351,8 +351,8 @@ struct input_plugin_s { #define MRLS_DUPLICATE(s, d) { \ int i = 0; \ \ - assert((s) != NULL); \ - assert((d) != NULL); \ + XINE_ASSERT((s) != NULL, "value 's' is NULL"); \ + XINE_ASSERT((d) != NULL, "value 'd' is NULL"); \ \ while((s) != NULL) { \ d[i] = (xine_mrl_t *) malloc(sizeof(xine_mrl_t)); \ diff --git a/src/input/input_pnm.c b/src/input/input_pnm.c index ce62a81d8..7de2fb7f1 100644 --- a/src/input/input_pnm.c +++ b/src/input/input_pnm.c @@ -26,7 +26,6 @@ #include <unistd.h> #include <stdio.h> -#include <assert.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> diff --git a/src/input/input_rtsp.c b/src/input/input_rtsp.c index dff1aa851..be8b9a261 100644 --- a/src/input/input_rtsp.c +++ b/src/input/input_rtsp.c @@ -26,7 +26,6 @@ #include <unistd.h> #include <stdio.h> -#include <assert.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c index 09fd00486..01d8f1f10 100644 --- a/src/input/input_v4l.c +++ b/src/input/input_v4l.c @@ -26,7 +26,6 @@ #include <unistd.h> #include <stdio.h> -#include <assert.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> diff --git a/src/input/mms.c b/src/input/mms.c index e52f6277b..abc48ef0a 100644 --- a/src/input/mms.c +++ b/src/input/mms.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: mms.c,v 1.21 2003/02/05 00:10:30 miguelfreitas Exp $ + * $Id: mms.c,v 1.22 2003/02/28 02:51:48 storri Exp $ * * based on work from major mms * utility functions to handle communication with an mms server @@ -29,7 +29,6 @@ #include <unistd.h> #include <stdio.h> -#include <assert.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> diff --git a/src/input/mmsh.c b/src/input/mmsh.c index dc1b757d7..2268292e0 100644 --- a/src/input/mmsh.c +++ b/src/input/mmsh.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: mmsh.c,v 1.12 2003/02/16 15:59:16 tmattern Exp $ + * $Id: mmsh.c,v 1.13 2003/02/28 02:51:48 storri Exp $ * * based on mms.c and specs from avifile * (http://avifile.sourceforge.net/asf-1.0.htm) @@ -29,7 +29,6 @@ #include <unistd.h> #include <stdio.h> -#include <assert.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> diff --git a/src/input/pnm.c b/src/input/pnm.c index 48aac07da..48d544a9b 100644 --- a/src/input/pnm.c +++ b/src/input/pnm.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: pnm.c,v 1.12 2003/02/05 00:10:30 miguelfreitas Exp $ + * $Id: pnm.c,v 1.13 2003/02/28 02:51:48 storri Exp $ * * pnm protocol implementation * based upon code from joschka @@ -25,7 +25,6 @@ #include <unistd.h> #include <stdio.h> -#include <assert.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> diff --git a/src/libfaad/cfft.c b/src/libfaad/cfft.c index a8a6537af..a834c73da 100644 --- a/src/libfaad/cfft.c +++ b/src/libfaad/cfft.c @@ -16,7 +16,7 @@ ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** -** $Id: cfft.c,v 1.4 2003/01/31 01:20:26 storri Exp $ +** $Id: cfft.c,v 1.5 2003/02/28 02:51:48 storri Exp $ **/ /* @@ -32,11 +32,6 @@ #include "structs.h" #include <stdlib.h> -#ifdef _WIN32_WCE -#define assert(x) -#else -#include <assert.h> -#endif #include "cfft.h" #include "cfft_tab.h" diff --git a/src/libfaad/filtbank.c b/src/libfaad/filtbank.c index 24cc03780..d17c95473 100644 --- a/src/libfaad/filtbank.c +++ b/src/libfaad/filtbank.c @@ -16,7 +16,7 @@ ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** -** $Id: filtbank.c,v 1.3 2002/12/16 19:00:02 miguelfreitas Exp $ +** $Id: filtbank.c,v 1.4 2003/02/28 02:51:49 storri Exp $ **/ #include "common.h" @@ -25,9 +25,9 @@ #include <stdlib.h> #include <string.h> #ifdef _WIN32_WCE -#define assert(x) +#define XINE_ASSERT(x) #else -#include <assert.h> +#include "xineutils.h" #endif #include "filtbank.h" @@ -265,7 +265,9 @@ void filter_bank_ltp(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, uint16_t nshort = frame_len/8; uint16_t nflat_ls = (nlong-nshort)/2; - assert(window_sequence != EIGHT_SHORT_SEQUENCE); + XINE_ASSERT(window_sequence != EIGHT_SHORT_SEQUENCE, + "%window_sequence (%d) == EIGHT_SHORT_SEQUENCE (%d)", + window_sequence, EIGHT_SHORT_SEQUENCE); windowed_buf = (real_t*)malloc(nlong*2*sizeof(real_t)); diff --git a/src/libfaad/mdct.c b/src/libfaad/mdct.c index 62031bfed..0f2e3bda7 100644 --- a/src/libfaad/mdct.c +++ b/src/libfaad/mdct.c @@ -16,7 +16,7 @@ ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** -** $Id: mdct.c,v 1.3 2002/12/16 19:00:39 miguelfreitas Exp $ +** $Id: mdct.c,v 1.4 2003/02/28 02:51:49 storri Exp $ **/ /* @@ -40,9 +40,9 @@ #include <stdlib.h> #ifdef _WIN32_WCE -#define assert(x) +#define XINE_ASSERT(x) #else -#include <assert.h> +#include "xineutils.h" #endif #include "cfft.h" @@ -115,7 +115,7 @@ mdct_info *faad_mdct_init(uint16_t N) mdct_info *mdct = (mdct_info*)malloc(sizeof(mdct_info)); - assert(N % 8 == 0); + XINE_ASSERT( (N % 8 == 0), "?"); mdct->N = N; mdct->sincos = (complex_t*)malloc(N/4*sizeof(complex_t)); diff --git a/src/libffmpeg/libavcodec/common.h b/src/libffmpeg/libavcodec/common.h index c2305b45e..893b7ed64 100644 --- a/src/libffmpeg/libavcodec/common.h +++ b/src/libffmpeg/libavcodec/common.h @@ -169,7 +169,6 @@ typedef signed long long INT64; # ifndef DEBUG # define NDEBUG # endif -# include <assert.h> /* dprintf macros */ # if defined(CONFIG_WIN32) && !defined(__MINGW32__) @@ -326,7 +325,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) st_out_bit_counts[st_current_index] += n; #endif // printf("put_bits=%d %x\n", n, value); - assert(n == 32 || value < (1U << n)); + XINE_ASSERT((n == 32 || value < (1U << n)), "?"); bit_buf = s->bit_buf; bit_left = s->bit_left; @@ -903,7 +902,7 @@ static inline int ff_sqrt(int a) * converts fourcc string to int */ static inline int ff_get_fourcc(const char *s){ - assert( strlen(s)==4 ); + XINE_ASSERT( strlen(s)==4, "lenght of value 's' != 4: %d", strlen(s) ); return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24); } diff --git a/src/libffmpeg/libavcodec/dsputil.c b/src/libffmpeg/libavcodec/dsputil.c index 06da93ba7..01bc84a86 100644 --- a/src/libffmpeg/libavcodec/dsputil.c +++ b/src/libffmpeg/libavcodec/dsputil.c @@ -21,6 +21,7 @@ #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" +#include "xineutils.h" int ff_bit_exact=0; @@ -1874,7 +1875,7 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int level= temp[i] + 64; - assert(level - 64); + XINE_ASSERT(level - 64,"?"); if((level&(~127)) == 0){ bits+= last_length[UNI_AC_ENC_INDEX(run, level)]; @@ -1941,7 +1942,7 @@ static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, in level= temp[i] + 64; - assert(level - 64); + XINE_ASSERT(level - 64,"?"); if((level&(~127)) == 0){ bits+= last_length[UNI_AC_ENC_INDEX(run, level)]; diff --git a/src/libffmpeg/libavcodec/h263.c b/src/libffmpeg/libavcodec/h263.c index 06501964b..f50920011 100644 --- a/src/libffmpeg/libavcodec/h263.c +++ b/src/libffmpeg/libavcodec/h263.c @@ -36,9 +36,7 @@ #include "mpegvideo.h" #include "h263data.h" #include "mpeg4data.h" - -//#undef NDEBUG -//#include <assert.h> +#include "xineutils.h" #if 1 #define PRINT_MB_TYPE(a) {} @@ -481,9 +479,11 @@ void mpeg4_encode_mb(MpegEncContext * s, s->last_mv[1][0][1]= 0; } - assert(s->dquant>=-2 && s->dquant<=2); - assert((s->dquant&1)==0); - assert(mb_type>=0); + XINE_ASSERT(s->dquant>=-2 && s->dquant<=2, + "value 's->dquant' is not within rang of -2 to 2: %d", + s->dquant); + XINE_ASSERT((s->dquant&1)==0,"?"); + XINE_ASSERT(mb_type>=0, "value 'mb_type' is < 0: %d", mb_type); /* nothing to do if this MB was skiped in the next P Frame */ if(s->next_picture.mbskip_table[s->mb_y * s->mb_width + s->mb_x]){ //FIXME avoid DCT & ... @@ -501,7 +501,9 @@ void mpeg4_encode_mb(MpegEncContext * s, if ((cbp | motion_x | motion_y | mb_type) ==0) { /* direct MB with MV={0,0} */ - assert(s->dquant==0); + XINE_ASSERT(s->dquant==0, + "value 's->dquant' is not 0: %d", + s->dquant); put_bits(&s->pb, 1, 1); /* mb not coded modb1=1 */ @@ -1179,7 +1181,7 @@ static void h263_encode_motion(MpegEncContext * s, int val, int f_code) val -= 2*l; } - assert(val>=-l && val<l); + XINE_ASSERT(val>=-l && val<l); if (val >= 0) { sign = 0; @@ -1342,8 +1344,8 @@ static void init_uni_dc_tab(void) static void init_uni_mpeg4_rl_tab(RLTable *rl, UINT32 *bits_tab, UINT8 *len_tab){ int slevel, run, last; - assert(MAX_LEVEL >= 64); - assert(MAX_RUN >= 63); + XINE_ASSERT(MAX_LEVEL >= 64, "MAX_LEVEL is < 64: %d", MAX_LEVEL); + XINE_ASSERT(MAX_RUN >= 63, "MAX_RUN is < 63: %d", MAX_RUN); for(slevel=-64; slevel<64; slevel++){ if(slevel==0) continue; @@ -3212,8 +3214,7 @@ int ff_h263_decode_mb(MpegEncContext *s, int modb1; // first bit of modb int modb2; // second bit of modb int mb_type; - int xy; - + s->mb_intra = 0; //B-frames never contain intra blocks s->mcsel=0; // ... true gmc blocks diff --git a/src/libffmpeg/libavcodec/h263dec.c b/src/libffmpeg/libavcodec/h263dec.c index a5dadeec4..ff3773bed 100644 --- a/src/libffmpeg/libavcodec/h263dec.c +++ b/src/libffmpeg/libavcodec/h263dec.c @@ -19,6 +19,7 @@ #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" +#include "xineutils.h" #if 1 #define PRINT_QP(a, b) {} @@ -244,7 +245,8 @@ static int decode_slice(MpegEncContext *s){ s->mb_x= 0; } - assert(s->mb_x==0 && s->mb_y==s->mb_height); + XINE_ASSERT(s->mb_x==0, "s->mb_x (%d) != 0", s->mb_x); + XINE_ASSERT(s->mb_y==s->mb_height, "s->mb_y (%d) != s->mb_height (%d)", s->mb_y, s->mb_height); /* try to detect the padding bug */ if( s->codec_id==CODEC_ID_MPEG4 diff --git a/src/libffmpeg/libavcodec/huffyuv.c b/src/libffmpeg/libavcodec/huffyuv.c index 5f9be9059..eccb57983 100644 --- a/src/libffmpeg/libavcodec/huffyuv.c +++ b/src/libffmpeg/libavcodec/huffyuv.c @@ -389,10 +389,13 @@ static int decode_init(AVCodecContext *avctx) height= s->height= avctx->height; avctx->coded_frame= &s->picture; -s->bgr32=1; - assert(width && height); -//if(avctx->extradata) -// printf("extradata:%X, extradata_size:%d\n", *(uint32_t*)avctx->extradata, avctx->extradata_size); + s->bgr32=1; + XINE_ASSERT(width,"value 'width' is not defined"); + XINE_ASSERT(height, "value 'height' is not defined"); + + //if(avctx->extradata) + // printf("extradata:%X, extradata_size:%d\n", *(uint32_t*)avctx->extradata, avctx->extradata_size); + if(avctx->extradata_size){ if((avctx->bits_per_sample&7) && avctx->bits_per_sample != 12) s->version=1; // do such files exist at all? @@ -464,7 +467,7 @@ s->bgr32=1; } break; default: - assert(0); + XINE_ASSERT(0,"We do not have a default action."); } // printf("pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_sample, s->interlaced); @@ -509,7 +512,8 @@ static int encode_init(AVCodecContext *avctx) width= s->width= avctx->width; height= s->height= avctx->height; - assert(width && height); + XINE_ASSERT(width, "value 'width' is not defined"); + XINE_ASSERT(height, "value 'height' is not defined"); avctx->extradata= av_mallocz(1024*10); avctx->stats_out= av_mallocz(1024*10); diff --git a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c index d936abfd5..be8015dd3 100644 --- a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c +++ b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c @@ -24,6 +24,7 @@ #include "../mpegvideo.h" #include "../avcodec.h" #include "../simple_idct.h" +#include "xineutils.h" extern UINT8 zigzag_direct_noperm[64]; extern UINT16 inv_zigzag_direct16[64]; @@ -41,7 +42,9 @@ static void dct_unquantize_h263_mmx(MpegEncContext *s, qmul = qscale << 1; qadd = (qscale - 1) | 1; - assert(s->block_last_index[n]>=0); + XINE_ASSERT(s->block_last_index[n]>=0, + "value 's->block_last_index[%d] is < 0: %d", + n, s->block_last_index[n]); if (s->mb_intra) { if (!s->h263_aic) { @@ -146,7 +149,9 @@ static void dct_unquantize_mpeg1_mmx(MpegEncContext *s, int nCoeffs; const UINT16 *quant_matrix; - assert(s->block_last_index[n]>=0); + XINE_ASSERT(s->block_last_index[n]>=0, + "value 's->block_last_index[%d] is < 0: %d", + n, s->block_last_index[n]); nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]+1; @@ -274,7 +279,9 @@ static void dct_unquantize_mpeg2_mmx(MpegEncContext *s, int nCoeffs; const UINT16 *quant_matrix; - assert(s->block_last_index[n]>=0); + XINE_ASSERT(s->block_last_index[n]>=0, + "value 's->block_last_index[%d] is < 0: %d", + n, s->block_last_index[n]); if(s->alternate_scan) nCoeffs= 63; //FIXME else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; diff --git a/src/libffmpeg/libavcodec/mjpeg.c b/src/libffmpeg/libavcodec/mjpeg.c index 9617816bb..8df477afa 100644 --- a/src/libffmpeg/libavcodec/mjpeg.c +++ b/src/libffmpeg/libavcodec/mjpeg.c @@ -24,6 +24,7 @@ #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" +#include "xineutils.h" /* use two quantizer tables (one for luminance and one for chrominance) */ /* not yet working */ @@ -477,7 +478,7 @@ static void escape_FF(MpegEncContext *s, int start) uint8_t *buf= s->pb.buf + start; int align= (-(int)(buf))&3; - assert((size&7) == 0); + XINE_ASSERT((size&7) == 0,"?"); size >>= 3; ff_count=0; @@ -533,7 +534,7 @@ void mjpeg_picture_trailer(MpegEncContext *s) put_bits(&s->pb, pad,0xFF>>(8-pad)); flush_put_bits(&s->pb); - assert((s->header_bits&7)==0); + XINE_ASSERT((s->header_bits&7)==0, "?"); escape_FF(s, s->header_bits>>3); diff --git a/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c b/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c index b951cd455..14e001316 100644 --- a/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c +++ b/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c @@ -19,6 +19,7 @@ #include "../dsputil.h" #include "../mpegvideo.h" +#include "xineutils.h" #include <mlib_types.h> #include <mlib_status.h> @@ -31,7 +32,7 @@ static void put_pixels16_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoCopyRef_U8_U8_16x16(dest, (uint8_t *)ref, stride); else @@ -41,7 +42,7 @@ static void put_pixels16_mlib (uint8_t * dest, const uint8_t * ref, static void put_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpX_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride); else @@ -51,7 +52,7 @@ static void put_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref, static void put_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride); else @@ -61,7 +62,7 @@ static void put_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref, static void put_pixels16_xy2_mlib(uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpXY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride); else @@ -74,7 +75,7 @@ static void put_pixels16_xy2_mlib(uint8_t * dest, const uint8_t * ref, static void put_pixels8_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoCopyRef_U8_U8_8x16(dest, (uint8_t *)ref, stride); else @@ -84,7 +85,7 @@ static void put_pixels8_mlib (uint8_t * dest, const uint8_t * ref, static void put_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride); else @@ -94,7 +95,7 @@ static void put_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref, static void put_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride); else @@ -104,7 +105,7 @@ static void put_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref, static void put_pixels8_xy2_mlib(uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride); else @@ -117,7 +118,7 @@ static void put_pixels8_xy2_mlib(uint8_t * dest, const uint8_t * ref, static void avg_pixels16_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoCopyRefAve_U8_U8_16x16(dest, (uint8_t *)ref, stride); else @@ -127,7 +128,7 @@ static void avg_pixels16_mlib (uint8_t * dest, const uint8_t * ref, static void avg_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpAveX_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride); else @@ -137,7 +138,7 @@ static void avg_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref, static void avg_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpAveY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride); else @@ -147,7 +148,7 @@ static void avg_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref, static void avg_pixels16_xy2_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpAveXY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride); else @@ -160,7 +161,7 @@ static void avg_pixels16_xy2_mlib (uint8_t * dest, const uint8_t * ref, static void avg_pixels8_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoCopyRefAve_U8_U8_8x16(dest, (uint8_t *)ref, stride); else @@ -170,7 +171,7 @@ static void avg_pixels8_mlib (uint8_t * dest, const uint8_t * ref, static void avg_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpAveX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride); else @@ -180,7 +181,7 @@ static void avg_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref, static void avg_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpAveY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride); else @@ -190,7 +191,7 @@ static void avg_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref, static void avg_pixels8_xy2_mlib (uint8_t * dest, const uint8_t * ref, int stride, int height) { - assert(height == 16 || height == 8); + XINE_ASSERT((height == 16 || height == 8),"value 'height' is not equal to 8 or 16: %d", height); if (height == 16) mlib_VideoInterpAveXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride); else diff --git a/src/libffmpeg/libavcodec/motion_est.c b/src/libffmpeg/libavcodec/motion_est.c index e4b67b22f..8d004a7c0 100644 --- a/src/libffmpeg/libavcodec/motion_est.c +++ b/src/libffmpeg/libavcodec/motion_est.c @@ -26,9 +26,6 @@ #include "dsputil.h" #include "mpegvideo.h" -//#undef NDEBUG -//#include <assert.h> - #define SQ(a) ((a)*(a)) #define P_LEFT P[1] @@ -961,7 +958,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, Picture * const pic= &s->current_picture; uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; - assert(s->quarter_sample==0 || s->quarter_sample==1); + XINE_ASSERT(s->quarter_sample==0 || s->quarter_sample==1, "value out of range: %d", s->quarter_sample); s->me.penalty_factor = get_penalty_factor(s, s->avctx->me_cmp); s->me.sub_penalty_factor= get_penalty_factor(s, s->avctx->me_sub_cmp); @@ -1132,7 +1129,8 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s, const int mv_stride= s->mb_width + 2; const int xy= mb_x + 1 + (mb_y + 1)*mv_stride; - assert(s->quarter_sample==0 || s->quarter_sample==1); + XINE_ASSERT((s->quarter_sample==0 || s->quarter_sample==1), + "value out of range: %d", s->quarter_sample); s->me.pre_penalty_factor = get_penalty_factor(s, s->avctx->me_pre_cmp); @@ -1298,8 +1296,8 @@ static inline int check_bidir_mv(MpegEncContext * s, dxy = ((motion_fy & 3) << 2) | (motion_fx & 3); src_x = mb_x * 16 + (motion_fx >> 2); src_y = mb_y * 16 + (motion_fy >> 2); - assert(src_x >=-16 && src_x<=s->width); - assert(src_y >=-16 && src_y<=s->height); + XINE_ASSERT(src_x >=-16 && src_x<=s->width, "value (%d) is not within range %d to %d", src_x, -16, s->width); + XINE_ASSERT(src_y >=-16 && src_y<=s->height, "value (%d) is not within range %d to %d", src_y, -16, s->height); ptr = s->last_picture.data[0] + (src_y * s->linesize) + src_x; s->dsp.put_qpel_pixels_tab[0][dxy](dest_y , ptr , s->linesize); @@ -1307,8 +1305,8 @@ static inline int check_bidir_mv(MpegEncContext * s, dxy = ((motion_by & 3) << 2) | (motion_bx & 3); src_x = mb_x * 16 + (motion_bx >> 2); src_y = mb_y * 16 + (motion_by >> 2); - assert(src_x >=-16 && src_x<=s->width); - assert(src_y >=-16 && src_y<=s->height); + XINE_ASSERT(src_x >=-16 && src_x<=s->width, "value (%d) is not within range %d to %d", src_x, -16, s->width); + XINE_ASSERT(src_y >=-16 && src_y<=s->height, "value (%d) is not within range %d to %d", src_y, -16, s->height); ptr = s->next_picture.data[0] + (src_y * s->linesize) + src_x; s->dsp.avg_qpel_pixels_tab[0][dxy](dest_y , ptr , s->linesize); @@ -1316,8 +1314,8 @@ static inline int check_bidir_mv(MpegEncContext * s, dxy = ((motion_fy & 1) << 1) | (motion_fx & 1); src_x = mb_x * 16 + (motion_fx >> 1); src_y = mb_y * 16 + (motion_fy >> 1); - assert(src_x >=-16 && src_x<=s->width); - assert(src_y >=-16 && src_y<=s->height); + XINE_ASSERT(src_x >=-16 && src_x<=s->width, "value (%d) is not within range %d to %d", src_x, -16, s->width); + XINE_ASSERT(src_y >=-16 && src_y<=s->height, "value (%d) is not within range %d to %d", src_y, -16, s->height); ptr = s->last_picture.data[0] + (src_y * s->linesize) + src_x; s->dsp.put_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16); @@ -1325,8 +1323,8 @@ static inline int check_bidir_mv(MpegEncContext * s, dxy = ((motion_by & 1) << 1) | (motion_bx & 1); src_x = mb_x * 16 + (motion_bx >> 1); src_y = mb_y * 16 + (motion_by >> 1); - assert(src_x >=-16 && src_x<=s->width); - assert(src_y >=-16 && src_y<=s->height); + XINE_ASSERT(src_x >=-16 && src_x<=s->width, "value (%d) is not within range %d to %d", src_x, -16, s->width); + XINE_ASSERT(src_y >=-16 && src_y<=s->height, "value (%d) is not within range %d to %d", src_y, -16, s->height); ptr = s->next_picture.data[0] + (src_y * s->linesize) + src_x; s->dsp.avg_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16); @@ -1421,7 +1419,9 @@ static inline int direct_search(MpegEncContext * s, if(s->mv_type == MV_TYPE_16X16) break; } - assert(xmax <= 15 && ymax <= 15 && xmin >= -16 && ymin >= -16); + XINE_ASSERT(xmax <= 15 && ymax <= 15 && xmin >= -16 && ymin >= -16, + "xmax (%d) > 15\nymax (%d) >15\nxmin (%d) < -16\nymin (%d) < -16", + xmax, ymax, xmin, ymin); if(xmax < 0 || xmin >0 || ymax < 0 || ymin > 0){ s->b_direct_mv_table[mot_xy][0]= 0; diff --git a/src/libffmpeg/libavcodec/motion_est_template.c b/src/libffmpeg/libavcodec/motion_est_template.c index 4725ed994..f1ce615ae 100644 --- a/src/libffmpeg/libavcodec/motion_est_template.c +++ b/src/libffmpeg/libavcodec/motion_est_template.c @@ -18,6 +18,8 @@ * */ +#include "xineutils.h" + //lets hope gcc will remove the unused vars ...(gcc 3.2.2 seems to do it ...) //Note, the last line is there to kill these ugly unused var warnings #define LOAD_COMMON(x, y)\ @@ -119,7 +121,9 @@ static int RENAME(hpel_motion_search)(MpegEncContext * s, CHECK_HALF_MV(0, 1, mx , my ) CHECK_HALF_MV(1, 1, mx , my ) - assert(bx >= xmin*2 || bx <= xmax*2 || by >= ymin*2 || by <= ymax*2); + XINE_ASSERT((bx >= xmin*2 || bx <= xmax*2 || by >= ymin*2 || by <= ymax*2), + "bx (%d) is not wihtin range %d to %d.\nby (%d) is not within range %d to %d", + bx, xmin*2, xmax*2, by, ymin*2, ymax*2); *mx_ptr = bx; *my_ptr = by; @@ -183,13 +187,14 @@ static int RENAME(hpel_motion_search)(MpegEncContext * s, int map_generation= s->me.map_generation; uint32_t *map= s->me.map; key= ((my-1)<<ME_MAP_MV_BITS) + (mx) + map_generation; - assert(map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key); + + XINE_ASSERT(map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key,"map[%d] != %d",(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1), key ); key= ((my+1)<<ME_MAP_MV_BITS) + (mx) + map_generation; - assert(map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key); + XINE_ASSERT(map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key,"map[%d] != %d",(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1), key); key= ((my)<<ME_MAP_MV_BITS) + (mx+1) + map_generation; - assert(map[(index+1)&(ME_MAP_SIZE-1)] == key); + XINE_ASSERT(map[(index+1)&(ME_MAP_SIZE-1)] == key, "map[%d] != %d",(index+1)&(ME_MAP_SIZE-1), key); key= ((my)<<ME_MAP_MV_BITS) + (mx-1) + map_generation; - assert(map[(index-1)&(ME_MAP_SIZE-1)] == key); + XINE_ASSERT(map[(index-1)&(ME_MAP_SIZE-1)] == key, "map[%d] != %d",(index-1)&(ME_MAP_SIZE-1), key); #endif if(t<=b){ CHECK_HALF_MV(0, 1, mx ,my-1) @@ -230,7 +235,9 @@ static int RENAME(hpel_motion_search)(MpegEncContext * s, } CHECK_HALF_MV(0, 1, mx , my) } - assert(bx >= xmin*2 && bx <= xmax*2 && by >= ymin*2 && by <= ymax*2); + XINE_ASSERT((bx >= xmin*2 && bx <= xmax*2 && by >= ymin*2 && by <= ymax*2), + "bx (%d) is not wihtin range %d to %d.\nby (%d) is not within range %d to %d", + bx, xmin*2, xmax*2, by, ymin*2, ymax*2); } *mx_ptr = bx; @@ -260,8 +267,9 @@ static int RENAME(hpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pre cmp_sub= s->dsp.mb_cmp[size]; chroma_cmp_sub= s->dsp.mb_cmp[size+1]; - assert(!s->me.skip); - assert(s->avctx->me_sub_cmp != s->avctx->mb_cmp); + XINE_ASSERT(!s->me.skip,"s->me.skip is not NULL"); + XINE_ASSERT((s->avctx->me_sub_cmp != s->avctx->mb_cmp), "s->avctx->me_sub_cmp (%d) != s->avctx->mb_cmp (%d)", + s->avctx->me_sub_cmp, s->avctx->mb_cmp ); CMP_HPEL(d, mx&1, my&1, mx>>1, my>>1, size); //FIXME check cbp before adding penalty for (0,0) vector @@ -389,11 +397,12 @@ static int RENAME(qpel_motion_search)(MpegEncContext * s, cxy= 2*tl + (cx + cy)/4 - (cx2 + cy2) - 2*c; - assert(16*cx2 + 4*cx + 32*c == 32*r); - assert(16*cx2 - 4*cx + 32*c == 32*l); - assert(16*cy2 + 4*cy + 32*c == 32*b); - assert(16*cy2 - 4*cy + 32*c == 32*t); - assert(16*cxy + 16*cy2 + 16*cx2 - 4*cy - 4*cx + 32*c == 32*tl); + XINE_ASSERT(16*cx2 + 4*cx + 32*c == 32*r, "%d != %d",16*cx2 + 4*cx + 32*c, 32*r); + XINE_ASSERT(16*cx2 - 4*cx + 32*c == 32*l, "%d != %d",16*cx2 - 4*cx + 32*c, 32*l); + XINE_ASSERT(16*cy2 + 4*cy + 32*c == 32*b, "%d != %d",16*cy2 + 4*cy + 32*c, 32*b); + XINE_ASSERT(16*cy2 - 4*cy + 32*c == 32*t, "%d != %d",16*cy2 - 4*cy + 32*c, 32*t); + XINE_ASSERT(16*cxy + 16*cy2 + 16*cx2 - 4*cy - 4*cx + 32*c == 32*tl, "%d != %d", + 16*cxy + 16*cy2 + 16*cx2 - 4*cy - 4*cx + 32*c, 32*tl); for(ny= -3; ny <= 3; ny++){ for(nx= -3; nx <= 3; nx++){ @@ -495,7 +504,9 @@ static int RENAME(qpel_motion_search)(MpegEncContext * s, CHECK_QUARTER_MV(1, 1, mx-1, my ) CHECK_QUARTER_MV(1, 0, mx-1, my ) #endif - assert(bx >= xmin*4 && bx <= xmax*4 && by >= ymin*4 && by <= ymax*4); + XINE_ASSERT(bx >= xmin*4 && bx <= xmax*4 && by >= ymin*4 && by <= ymax*4, + "bx (%d) is not wihtin range %d to %d.\nby (%d) is not within range %d to %d", + bx, xmin*4, xmax*4, by, ymin*4, ymax*4); *mx_ptr = bx; *my_ptr = by; @@ -526,8 +537,8 @@ static int RENAME(qpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pre cmp_sub= s->dsp.mb_cmp[size]; chroma_cmp_sub= s->dsp.mb_cmp[size+1]; - assert(!s->me.skip); - assert(s->avctx->me_sub_cmp != s->avctx->mb_cmp); + XINE_ASSERT(!s->me.skip, "value 's->me.skip' is not NULL"); + XINE_ASSERT(s->avctx->me_sub_cmp != s->avctx->mb_cmp, "%d != %d", s->avctx->me_sub_cmp, s->avctx->mb_cmp ); CMP_QPEL(d, mx&3, my&3, mx>>2, my>>2, size); //FIXME check cbp before adding penalty for (0,0) vector @@ -745,7 +756,7 @@ static inline int RENAME(sab_diamond_search)(MpegEncContext * s, int *best, int if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue; - assert(j<MAX_SAB_SIZE); //max j = number of predictors + XINE_ASSERT(j<MAX_SAB_SIZE, "%d >= %d", j, MAX_SAB_SIZE); //max j = number of predictors minima[j].height= score_map[i]; minima[j].x= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS; diff --git a/src/libffmpeg/libavcodec/mpeg12.c b/src/libffmpeg/libavcodec/mpeg12.c index fecb097bd..907b141e9 100644 --- a/src/libffmpeg/libavcodec/mpeg12.c +++ b/src/libffmpeg/libavcodec/mpeg12.c @@ -769,7 +769,7 @@ static int mpeg_decode_mb(MpegEncContext *s, dprintf("decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y); - assert(s->mb_skiped==0); + XINE_ASSERT(s->mb_skiped==0, "s->mp_skiped is not 0: %d", s->mb_skiped); if (--s->mb_incr != 0) { /* skip mb */ diff --git a/src/libffmpeg/libavcodec/mpegvideo.c b/src/libffmpeg/libavcodec/mpegvideo.c index 04908d8ad..45f0c9909 100644 --- a/src/libffmpeg/libavcodec/mpegvideo.c +++ b/src/libffmpeg/libavcodec/mpegvideo.c @@ -30,9 +30,6 @@ #include "fastmemcpy.h" #endif -//#undef NDEBUG -//#include <assert.h> - #define CONFIG_RISKY static void encode_picture(MpegEncContext *s, int picture_number); @@ -283,13 +280,13 @@ int DCT_common_init(MpegEncContext *s) static int alloc_picture(MpegEncContext *s, Picture *pic, int shared){ if(shared){ - assert(pic->data[0]); - assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED); + XINE_ASSERT(pic->data[0], "pic->data[0] is NULL."); + XINE_ASSERT((pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED), "Invalid pic->type: %d", pic->type); pic->type= FF_BUFFER_TYPE_SHARED; }else{ int r; - assert(!pic->data[0]); + XINE_ASSERT(!pic->data[0],"pic->data[0] is not NULL."); r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic); @@ -895,7 +892,7 @@ static int find_unused_picture(MpegEncContext *s, int shared){ } } - assert(i<MAX_PICTURE_COUNT); + XINE_ASSERT(i<MAX_PICTURE_COUNT,"value 'i' is >= MAX_PICTURE_COUNT: %d >= %d", i, MAX_PICTURE_COUNT); return i; } @@ -917,7 +914,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) break; } } - assert(i<MAX_PICTURE_COUNT); + XINE_ASSERT(i<MAX_PICTURE_COUNT,"value 'i' is >= MAX_PICTURE_COUNT: %d >= %d", i, MAX_PICTURE_COUNT); /* release forgotten pictures */ /* if(mpeg124/h263) */ @@ -950,7 +947,7 @@ alloc: if(s->pict_type != I_TYPE && s->last_picture.data[0]==NULL){ fprintf(stderr, "warning: first frame is no keyframe\n"); - assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference + XINE_ASSERT(s->pict_type != B_TYPE, "These should have been dropped if we dont have a reference"); goto alloc; } @@ -1000,7 +997,7 @@ void MPV_frame_end(MpegEncContext *s) break; } } - assert(i<MAX_PICTURE_COUNT); + XINE_ASSERT(i<MAX_PICTURE_COUNT,"value 'i' is >= MAX_PICTURE_COUNT: %d >= %d", i, MAX_PICTURE_COUNT); /* release non refernce frames */ for(i=0; i<MAX_PICTURE_COUNT; i++){ @@ -1136,7 +1133,7 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){ static void select_input_picture(MpegEncContext *s){ int i; - const int encoding_delay= s->max_b_frames; + int coded_pic_num=0; if(s->reordered_input_picture[0]) @@ -1244,8 +1241,11 @@ static void select_input_picture(MpegEncContext *s){ s->current_picture= *pic; }else{ - assert( s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_USER - || s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL); + XINE_ASSERT( + (s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_USER + || s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL), + "s->reordered_input_picture[0]->type is incorrect: %d", + s->reordered_input_picture[0]->type); s->new_picture= *s->reordered_input_picture[0]; @@ -1283,7 +1283,7 @@ int MPV_encode_picture(AVCodecContext *avctx, s->pict_type= s->new_picture.pict_type; if (s->fixed_qscale){ /* the ratecontrol needs the last qscale so we dont touch it for CBR */ s->qscale= (int)(s->new_picture.quality+0.5); - assert(s->qscale); + XINE_ASSERT(s->qscale,"s->qscale is NULL"); } //emms_c(); //printf("qs:%f %f %d\n", s->new_picture.quality, s->current_picture.quality, s->qscale); @@ -2065,11 +2065,11 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) UINT8 *mbskip_ptr = &s->mbskip_table[mb_xy]; const int age= s->current_picture.age; - assert(age); + XINE_ASSERT(age, "value 'age' is NULL"); if (s->mb_skiped) { s->mb_skiped= 0; - assert(s->pict_type!=I_TYPE); + XINE_ASSERT(s->pict_type!=I_TYPE, "s->pict_type (%d) != I_TYPE (%d)", s->pict_type, I_TYPE); (*mbskip_ptr) ++; /* indicate that this time we skiped it */ if(*mbskip_ptr >99) *mbskip_ptr= 99; @@ -2286,7 +2286,7 @@ static inline void auto_requantize_coeffs(MpegEncContext *s, DCTELEM block[6][64 const int minlevel= s->min_qcoeff; int largest=0, smallest=0; - assert(s->adaptive_quant); + XINE_ASSERT(s->adaptive_quant, "s->adaptive_quant is NULL"); for(n=0; n<6; n++){ if(s->mb_intra){ @@ -2439,7 +2439,7 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y) if(s->codec_id==CODEC_ID_MPEG4){ if(!s->mb_intra){ - assert(s->dquant==0 || s->mv_type!=MV_TYPE_8X8); + XINE_ASSERT((s->dquant==0 || s->mv_type!=MV_TYPE_8X8), "?"); if(s->mv_dir&MV_DIRECT) s->dquant=0; @@ -2677,7 +2677,7 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y) case CODEC_ID_MJPEG: mjpeg_encode_mb(s, s->block); break; default: - assert(0); + XINE_ASSERT(0, "We have no default case. So if program control reaches here something is really wrong"); } #endif } @@ -2832,7 +2832,7 @@ static inline int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, in } } - assert(acc>=0); + XINE_ASSERT(acc>=0,"value 'acc' is < 0: %d", acc); return acc; } @@ -3591,7 +3591,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s, int level= coeff[level_index][i]; int unquant_coeff; - assert(level); + XINE_ASSERT(level, "value 'level' is NULL"); if(s->out_format == FMT_H263){ if(level>0){ @@ -3710,7 +3710,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s, return last_non_zero; i= last_i; - assert(last_level); + XINE_ASSERT(last_level, "value 'last_level' is NULL"); //FIXME use permutated scantable block[ s->idct_permutation[ scantable[last_non_zero] ] ]= last_level; i -= last_run + 1; @@ -3719,7 +3719,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s, const int j= s->idct_permutation[ scantable[i - 1 + start_i] ]; block[j]= level_tab[i]; - assert(block[j]); + XINE_ASSERT(block[j], "value 'block[j]' is NULL"); } return last_non_zero; @@ -3926,7 +3926,7 @@ static void dct_unquantize_h263_c(MpegEncContext *s, int i, level, qmul, qadd; int nCoeffs; - assert(s->block_last_index[n]>=0); + XINE_ASSERT(s->block_last_index[n]>=0 , "s->block_last_index[%d] is < 0: %d", n, s->block_last_index[n]); qadd = (qscale - 1) | 1; qmul = qscale << 1; diff --git a/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c b/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c index dd898e158..6c3be0e77 100644 --- a/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c +++ b/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c @@ -21,6 +21,7 @@ #include "../dsputil.h" #include "../mpegvideo.h" #include "dsputil_altivec.h" +#include "xineutils.h" // Swaps two variables (used for altivec registers) #define SWAP(a,b) \ @@ -523,7 +524,7 @@ POWERPC_TBL_DECLARE(altivec_dct_unquantize_h263_num, 1); int i, level, qmul, qadd; int nCoeffs; - assert(s->block_last_index[n]>=0); + XINE_ASSERT(s->block_last_index[n]>=0, "s->block_last_index[%d] < 0", n); POWERPC_TBL_START_COUNT(altivec_dct_unquantize_h263_num, 1); diff --git a/src/libffmpeg/libavcodec/ratecontrol.c b/src/libffmpeg/libavcodec/ratecontrol.c index 6bcbe1c67..03811b549 100644 --- a/src/libffmpeg/libavcodec/ratecontrol.c +++ b/src/libffmpeg/libavcodec/ratecontrol.c @@ -21,9 +21,6 @@ #include "dsputil.h" #include "mpegvideo.h" -#undef NDEBUG // allways check asserts, the speed effect is far too small to disable them -#include <assert.h> - #ifndef M_E #define M_E 2.718281828 #endif @@ -95,8 +92,8 @@ int ff_rate_control_init(MpegEncContext *s) } e= sscanf(p, " in:%d ", &picture_number); - assert(picture_number >= 0); - assert(picture_number < rcc->num_entries); + XINE_ASSERT(picture_number >= 0,"Picture number is not >= 0: %d", picture_number); + XINE_ASSERT(picture_number < rcc->num_entries, "Picture number is not (%d) < rcc->num_entries (%d)", 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", @@ -550,7 +547,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s) int qmin, qmax; float br_compensation; double diff; - double short_term_q; + double short_term_q = 0; double fps; int picture_number= s->picture_number; int64_t wanted_bits; @@ -574,8 +571,8 @@ float ff_rate_estimate_qscale(MpegEncContext *s) } if(s->flags&CODEC_FLAG_PASS2){ - assert(picture_number>=0); - assert(picture_number<rcc->num_entries); + XINE_ASSERT(picture_number>=0,"Picture number is not >=0: %d", picture_number); + XINE_ASSERT(picture_number<rcc->num_entries, "Picture number (%d) is not < rcc->num_entries (%d)", picture_number, rcc->num_entries); rce= &rcc->entry[picture_number]; wanted_bits= rce->expected_bits; }else{ @@ -591,7 +588,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s) if(s->flags&CODEC_FLAG_PASS2){ if(pict_type!=I_TYPE) - assert(pict_type == rce->new_pict_type); + XINE_ASSERT(pict_type == rce->new_pict_type, "pict_type (%d) != rce->new_pict_type (%d)", pict_type, rce->new_pict_type); q= rce->new_qscale / br_compensation; //printf("%f %f %f last:%d var:%d type:%d//\n", q, rce->new_qscale, br_compensation, s->frame_bits, var, pict_type); @@ -631,11 +628,11 @@ float ff_rate_estimate_qscale(MpegEncContext *s) q= get_qscale(s, rce, rate_factor, picture_number); - assert(q>0.0); + XINE_ASSERT(q>0.0, "value 'q' is not > 0.0: %f", q); //printf("%f ", q); q= get_diff_limited_q(s, rce, q); //printf("%f ", q); - assert(q>0.0); + XINE_ASSERT(q>0.0, "value 'q' is not > 0.0: %f", q); if(pict_type==P_TYPE || s->intra_only){ //FIXME type dependant blur like in 2-pass rcc->short_term_qsum*=s->qblur; @@ -647,13 +644,13 @@ float ff_rate_estimate_qscale(MpegEncContext *s) q= short_term_q= rcc->short_term_qsum/rcc->short_term_qcount; //printf("%f ", q); } - assert(q>0.0); + XINE_ASSERT(q>0.0, "value 'q' is not > 0.0: %f", q); q= modify_qscale(s, rce, q, picture_number); rcc->pass1_wanted_bits+= s->bit_rate/fps; - assert(q>0.0); + XINE_ASSERT(q>0.0, "value 'q' is not > 0.0: %f", q); } if(s->avctx->debug&FF_DEBUG_RC){ @@ -764,7 +761,8 @@ static int init_pass2(MpegEncContext *s) for(i=0; i<rcc->num_entries; i++){ qscale[i]= get_qscale(s, &rcc->entry[i], rate_factor, i); } - assert(filter_size%2==1); + /* filter_size%2 == 1 */ + XINE_ASSERT( filter_size%2==1 , "filter size is an even number: %d", filter_size); /* fixed I/B QP relative to P mode */ for(i=rcc->num_entries-1; i>=0; i--){ diff --git a/src/libffmpeg/libavcodec/utils.c b/src/libffmpeg/libavcodec/utils.c index ca71807f7..0959c0cf4 100644 --- a/src/libffmpeg/libavcodec/utils.c +++ b/src/libffmpeg/libavcodec/utils.c @@ -19,6 +19,7 @@ #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" +#include "xineutils.h" void *av_mallocz(unsigned int size) { @@ -124,8 +125,8 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ const int height= s->height; DefaultPicOpaque *opaque; /* - assert(pic->data[0]==NULL); - assert(pic->type==0 || pic->type==FF_TYPE_INTERNAL); + XINE_ASSERT(pic->data[0]==NULL, "pic->data[0] != NULL"); + XINE_ASSERT((pic->type==0) || (pic->type==FF_TYPE_INTERNAL), "pic->type incorrect: %d", pic->type); */ if(pic->opaque){ opaque= (DefaultPicOpaque *)pic->opaque; @@ -202,7 +203,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ int i; - assert(pic->type==FF_BUFFER_TYPE_INTERNAL); + XINE_ASSERT(pic->type==FF_BUFFER_TYPE_INTERNAL, "pic->type does not equal FF_BUFFER_TYPE_INTERNAL: %d", pic->type); for(i=0; i<3; i++) pic->data[i]=NULL; diff --git a/src/libmad/global.h b/src/libmad/global.h index 4bde6a82a..8d6723016 100644 --- a/src/libmad/global.h +++ b/src/libmad/global.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: global.h,v 1.2 2002/04/30 18:46:58 miguelfreitas Exp $ + * $Id: global.h,v 1.3 2003/02/28 02:51:49 storri Exp $ */ # ifndef LIBMAD_GLOBAL_H @@ -47,12 +47,4 @@ # define USE_ASYNC # endif -# if !defined(HAVE_ASSERT_H) -# if defined(NDEBUG) -# define assert(x) /* nothing */ -# else -# define assert(x) do { if (!(x)) abort(); } while (0) -# endif -# endif - # endif diff --git a/src/libmad/layer3.c b/src/libmad/layer3.c index b05dd4cbf..d4db46ffc 100755 --- a/src/libmad/layer3.c +++ b/src/libmad/layer3.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: layer3.c,v 1.3 2002/04/30 18:46:58 miguelfreitas Exp $ + * $Id: layer3.c,v 1.4 2003/02/28 02:51:49 storri Exp $ */ # ifdef HAVE_CONFIG_H @@ -28,16 +28,13 @@ # include <stdlib.h> # include <string.h> -# ifdef HAVE_ASSERT_H -# include <assert.h> -# endif - # ifdef HAVE_LIMITS_H # include <limits.h> # else # define CHAR_BIT 8 # endif +# include "xineutils.h" # include "fixed.h" # include "bit.h" # include "stream.h" @@ -1250,7 +1247,7 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], } } - assert(-bits_left <= MAD_BUFFER_GUARD * CHAR_BIT); + XINE_ASSERT(-bits_left <= (MAD_BUFFER_GUARD * CHAR_BIT), "-bits_left > (MAD_BUFFER_GUARD * CHAR_BIT"); # if 0 && defined(DEBUG) if (bits_left < 0) @@ -2433,8 +2430,8 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) *stream->main_data + stream->md_len - si.main_data_begin); if (md_len > si.main_data_begin) { - assert(stream->md_len + md_len - - si.main_data_begin <= MAD_BUFFER_MDLEN); + XINE_ASSERT((stream->md_len + md_len - + si.main_data_begin) <= MAD_BUFFER_MDLEN, "?"); memcpy(*stream->main_data + stream->md_len, mad_bit_nextbyte(&stream->ptr), diff --git a/src/libmad/timer.c b/src/libmad/timer.c index d2ad43aeb..47dbfca41 100755 --- a/src/libmad/timer.c +++ b/src/libmad/timer.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: timer.c,v 1.3 2002/05/02 16:00:48 jcdutton Exp $ + * $Id: timer.c,v 1.4 2003/02/28 02:51:50 storri Exp $ */ # ifdef HAVE_CONFIG_H @@ -28,9 +28,7 @@ # include <stdio.h> # include <stdlib.h> /* For abort() */ -# ifdef HAVE_ASSERT_H -# include <assert.h> -# endif +# include "xineutils.h" # include "timer.h" @@ -125,7 +123,7 @@ void reduce_rational(unsigned long *numer, unsigned long *denom) factor = gcd(*numer, *denom); - assert(factor != 0); + XINE_ASSERT(factor != 0, "value 'factor' is equal to 0. This will result in a divide by zero error."); *numer /= factor; *denom /= factor; @@ -142,7 +140,7 @@ unsigned long scale_rational(unsigned long numer, unsigned long denom, reduce_rational(&numer, &denom); reduce_rational(&scale, &denom); - assert(denom != 0); + XINE_ASSERT(denom != 0, "value 'denom' is 0. This will result in a divide by zero error"); if (denom < scale) return numer * (scale / denom) + numer * (scale % denom) / denom; diff --git a/src/libspudec/nav_print.c b/src/libspudec/nav_print.c index 81cc44394..48111578b 100644 --- a/src/libspudec/nav_print.c +++ b/src/libspudec/nav_print.c @@ -25,7 +25,7 @@ #include <stdio.h> #include <inttypes.h> -#include <assert.h> +#include "xineutils.h" #include "config.h" // Needed for WORDS_BIGENDIAN #include "nav_types.h" @@ -34,10 +34,10 @@ void print_time(dvd_time_t *dtime) { const char *rate; - assert((dtime->hour>>4) < 0xa && (dtime->hour&0xf) < 0xa); - assert((dtime->minute>>4) < 0x7 && (dtime->minute&0xf) < 0xa); - assert((dtime->second>>4) < 0x7 && (dtime->second&0xf) < 0xa); - assert((dtime->frame_u&0xf) < 0xa); + XINE_ASSERT(((dtime->hour>>4) < 0xa) && ((dtime->hour&0xf) < 0xa),"?"); + XINE_ASSERT(((dtime->minute>>4) < 0x7) && ((dtime->minute&0xf) < 0xa),"?"); + XINE_ASSERT(((dtime->second>>4) < 0x7) && ((dtime->second&0xf) < 0xa), "?"); + XINE_ASSERT((dtime->frame_u&0xf) < 0xa, "?"); printf("%02x:%02x:%02x.%02x", dtime->hour, diff --git a/src/libspudec/nav_read.c b/src/libspudec/nav_read.c index d75166a4f..79a695f0f 100644 --- a/src/libspudec/nav_read.c +++ b/src/libspudec/nav_read.c @@ -19,7 +19,7 @@ #include <stdio.h> #include <string.h> #include <inttypes.h> -#include <assert.h> +#include "xineutils.h" #include "config.h" // Needed for WORDS_BIGENDIAN #include "bswap.h" @@ -35,7 +35,7 @@ void nav_read_pci(pci_t *pci, unsigned char *buffer) { int i, j; - assert(sizeof(pci_t) == PCI_BYTES - 1); // -1 for substream id + XINE_ASSERT(sizeof(pci_t) == (PCI_BYTES - 1), "Incorrect pci_t size: %d", sizeof(pci_t)); // -1 for substream id memcpy(pci, buffer, sizeof(pci_t)); @@ -102,22 +102,23 @@ void nav_read_pci(pci_t *pci, unsigned char *buffer) { /* Asserts */ /* pci pci gi */ - assert(pci->pci_gi.zero1 == 0); + XINE_ASSERT(pci->pci_gi.zero1 == 0, "pci->pci_gi.zero1 != 0"); /* pci hli hli_gi */ - assert(pci->hli.hl_gi.zero1 == 0); - assert(pci->hli.hl_gi.zero2 == 0); - assert(pci->hli.hl_gi.zero3 == 0); - assert(pci->hli.hl_gi.zero4 == 0); - assert(pci->hli.hl_gi.zero5 == 0); + XINE_ASSERT(pci->hli.hl_gi.zero1 == 0, "pci->hli.hl_gi.zero1 != 0"); + XINE_ASSERT(pci->hli.hl_gi.zero2 == 0, "pci->hli.hl_gi.zero2 != 0"); + XINE_ASSERT(pci->hli.hl_gi.zero3 == 0, "pci->hli.hl_gi.zero3 != 0"); + XINE_ASSERT(pci->hli.hl_gi.zero4 == 0, "pci->hli.hl_gi.zero4 != 0"); + XINE_ASSERT(pci->hli.hl_gi.zero5 == 0, "pci->hli.hl_gi.zero5 != 0"); /* Are there buttons defined here? */ if((pci->hli.hl_gi.hli_ss & 0x03) != 0) { - assert(pci->hli.hl_gi.btn_ns != 0); - assert(pci->hli.hl_gi.btngr_ns != 0); + XINE_ASSERT(pci->hli.hl_gi.btn_ns != 0, "pci->li.hl_gi.btn_ns == 0"); + XINE_ASSERT(pci->hli.hl_gi.btngr_ns != 0, "pci->li.hl_gi.btngr_ns == 0"); } else { - assert((pci->hli.hl_gi.btn_ns != 0 && pci->hli.hl_gi.btngr_ns != 0) - || (pci->hli.hl_gi.btn_ns == 0 && pci->hli.hl_gi.btngr_ns == 0)); + XINE_ASSERT((pci->hli.hl_gi.btn_ns != 0 && pci->hli.hl_gi.btngr_ns != 0) + || (pci->hli.hl_gi.btn_ns == 0 && pci->hli.hl_gi.btngr_ns == 0), + "pci->hli.hl_gi.btn_ns & pci->hli.hl_gi.btngr_ns are not both the same"); } /* pci hli btnit */ @@ -126,35 +127,35 @@ void nav_read_pci(pci_t *pci, unsigned char *buffer) { for(i = 0; i < pci->hli.hl_gi.btngr_ns; i++) { for(j = 0; j < (36 / pci->hli.hl_gi.btngr_ns); j++) { int n = (36 / pci->hli.hl_gi.btngr_ns) * i + j; - assert(pci->hli.btnit[n].zero1 == 0); - assert(pci->hli.btnit[n].zero2 == 0); - assert(pci->hli.btnit[n].zero3 == 0); - assert(pci->hli.btnit[n].zero4 == 0); - assert(pci->hli.btnit[n].zero5 == 0); - assert(pci->hli.btnit[n].zero6 == 0); + XINE_ASSERT(pci->hli.btnit[n].zero1 == 0,"pci->hli.btnit[%d].zero1 != 0", n); + XINE_ASSERT(pci->hli.btnit[n].zero2 == 0,"pci->hli.btnit[%d].zero2 != 0", n); + XINE_ASSERT(pci->hli.btnit[n].zero3 == 0,"pci->hli.btnit[%d].zero3 != 0", n); + XINE_ASSERT(pci->hli.btnit[n].zero4 == 0,"pci->hli.btnit[%d].zero4 != 0", n); + XINE_ASSERT(pci->hli.btnit[n].zero5 == 0,"pci->hli.btnit[%d].zero5 != 0", n); + XINE_ASSERT(pci->hli.btnit[n].zero6 == 0,"pci->hli.btnit[%d].zero6 != 0", n); if (j < pci->hli.hl_gi.btn_ns) { - assert(pci->hli.btnit[n].x_start <= pci->hli.btnit[n].x_end); - assert(pci->hli.btnit[n].y_start <= pci->hli.btnit[n].y_end); - assert(pci->hli.btnit[n].up <= pci->hli.hl_gi.btn_ns); - assert(pci->hli.btnit[n].down <= pci->hli.hl_gi.btn_ns); - assert(pci->hli.btnit[n].left <= pci->hli.hl_gi.btn_ns); - assert(pci->hli.btnit[n].right <= pci->hli.hl_gi.btn_ns); + XINE_ASSERT(pci->hli.btnit[n].x_start <= pci->hli.btnit[n].x_end,"?"); + XINE_ASSERT(pci->hli.btnit[n].y_start <= pci->hli.btnit[n].y_end,"?"); + XINE_ASSERT(pci->hli.btnit[n].up <= pci->hli.hl_gi.btn_ns,"?"); + XINE_ASSERT(pci->hli.btnit[n].down <= pci->hli.hl_gi.btn_ns,"?"); + XINE_ASSERT(pci->hli.btnit[n].left <= pci->hli.hl_gi.btn_ns,"?"); + XINE_ASSERT(pci->hli.btnit[n].right <= pci->hli.hl_gi.btn_ns,"?"); //vmcmd_verify(pci->hli.btnit[n].cmd); } else { int k; - assert(pci->hli.btnit[n].btn_coln == 0); - assert(pci->hli.btnit[n].auto_action_mode == 0); - assert(pci->hli.btnit[n].x_start == 0); - assert(pci->hli.btnit[n].y_start == 0); - assert(pci->hli.btnit[n].x_end == 0); - assert(pci->hli.btnit[n].y_end == 0); - assert(pci->hli.btnit[n].up == 0); - assert(pci->hli.btnit[n].down == 0); - assert(pci->hli.btnit[n].left == 0); - assert(pci->hli.btnit[n].right == 0); + XINE_ASSERT(pci->hli.btnit[n].btn_coln == 0,"pci->hli.btnit[%d].btn_coln != 0", n); + XINE_ASSERT(pci->hli.btnit[n].auto_action_mode == 0,"pci->hli.btnit[%d].auto_action_mode != 0", n); + XINE_ASSERT(pci->hli.btnit[n].x_start == 0,"pci->hli.btnit[%d].x_start != 0", n); + XINE_ASSERT(pci->hli.btnit[n].y_start == 0,"pci->hli.btnit[%d].y_start != 0", n); + XINE_ASSERT(pci->hli.btnit[n].x_end == 0,"pci->hli.btnit[%d].x_end != 0", n); + XINE_ASSERT(pci->hli.btnit[n].y_end == 0,"pci->hli.btnit[%d].y_end != 0", n); + XINE_ASSERT(pci->hli.btnit[n].up == 0,"pci->hli.btnit[%d].up != 0", n); + XINE_ASSERT(pci->hli.btnit[n].down == 0,"pci->hli.btnit[%d].down != 0", n); + XINE_ASSERT(pci->hli.btnit[n].left == 0,"pci->hli.btnit[%d].left != 0", n); + XINE_ASSERT(pci->hli.btnit[n].right == 0,"pci->hli.btnit[%d].right != 0", n); for (k = 0; k < 8; k++) - assert(pci->hli.btnit[n].cmd.bytes[k] == 0); //CHECK_ZERO? + XINE_ASSERT(pci->hli.btnit[n].cmd.bytes[k] == 0,"pci->hli.btnit[%d].cmd.bytes[%d] != 0", n, k); //CHECK_ZERO? } } } @@ -165,7 +166,7 @@ void nav_read_pci(pci_t *pci, unsigned char *buffer) { void nav_read_dsi(dsi_t *dsi, unsigned char *buffer) { int i; - assert(sizeof(dsi_t) == DSI_BYTES - 1); // -1 for substream id + XINE_ASSERT(sizeof(dsi_t) == (DSI_BYTES - 1), "sizeof dsi_t is incorrect: %d", sizeof(dsi_t)); // -1 for substream id memcpy(dsi, buffer, sizeof(dsi_t)); @@ -215,7 +216,7 @@ void nav_read_dsi(dsi_t *dsi, unsigned char *buffer) { /* Asserts */ /* dsi dsi gi */ - assert(dsi->dsi_gi.zero1 == 0); + XINE_ASSERT(dsi->dsi_gi.zero1 == 0, "dsi->dsi_gi.zero1 != 0"); #endif } diff --git a/src/libspudec/spu.c b/src/libspudec/spu.c index 92a02228b..069632a22 100644 --- a/src/libspudec/spu.c +++ b/src/libspudec/spu.c @@ -35,7 +35,7 @@ * along with this program; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: spu.c,v 1.60 2003/02/20 18:09:10 siggi Exp $ + * $Id: spu.c,v 1.61 2003/02/28 02:51:50 storri Exp $ * */ @@ -224,7 +224,7 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) { /* FIXME: Add command copying here */ break; default: - assert(0); + XINE_ASSERT(0, "We drop out here for some reason. Why no default behavior?"); break; } pthread_mutex_unlock(&this->nav_pci_lock); diff --git a/src/libspudec/xine_decoder.c b/src/libspudec/xine_decoder.c index 83c974964..4673fb5de 100644 --- a/src/libspudec/xine_decoder.c +++ b/src/libspudec/xine_decoder.c @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.92 2002/12/26 21:53:42 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.93 2003/02/28 02:51:50 storri Exp $ * * stuff needed to turn libspu into a xine decoder plugin */ @@ -30,7 +30,6 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> -#include <assert.h> #include "xine_internal.h" #include "buffer.h" @@ -261,7 +260,7 @@ static void spudec_set_button (spu_decoder_t *this_gen, int32_t button, int32_t pthread_mutex_unlock(&this->nav_pci_lock); } else { fprintf (stderr,"libspudec:xine_decoder.c:spudec_event_listener:HIDE ????\n"); - assert(0); + XINE_ASSERT(0, "We dropped out here for some reason"); overlay_event->object.handle = this->menu_handle; overlay_event->event_type = OVERLAY_EVENT_HIDE; } diff --git a/src/libxineadec/gsm610/long_term.c b/src/libxineadec/gsm610/long_term.c index 932223738..c8564447d 100644 --- a/src/libxineadec/gsm610/long_term.c +++ b/src/libxineadec/gsm610/long_term.c @@ -4,10 +4,10 @@ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ -/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/long_term.c,v 1.1 2002/10/12 19:12:49 tmmm Exp $ */ +/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/long_term.c,v 1.2 2003/02/28 02:51:50 storri Exp $ */ #include <stdio.h> -#include <assert.h> +#include "xineutils.h" #include "private.h" @@ -40,7 +40,7 @@ * uncut one. (For a detailed explanation of why this is altogether * a bad idea, see Henry Spencer and Geoff Collyer, ``#ifdef Considered * Harmful''.) - */ +a */ #ifndef USE_FLOAT_MUL @@ -81,12 +81,13 @@ static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), temp = 0; if (dmax == 0) scal = 0; else { - assert(dmax > 0); + XINE_ASSERT(dmax > 0, "value 'dmax' is not > 0: %d", dmax); temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; - assert(scal >= 0); + + XINE_ASSERT(scal >= 0, "value 'scal' is not >= 0: %d", scal); /* Search for the maximum cross-correlation and coding of the LTP lag */ @@ -106,10 +107,10 @@ static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), /* Rescaling of L_max */ - assert(scal <= 100 && scal >= -100); + XINE_ASSERT((scal <= 100) && (scal >= -100), "value 'scal' is not within range -100 to 100: %d", scal); L_max = L_max >> (6 - scal); /* sub(6, scal) */ - assert( Nc <= 120 && Nc >= 40); + XINE_ASSERT( Nc <= 120 && Nc >= 40, "value 'Nc' is not within range 40 to 120: %d", Nc); /* Compute the power of the reconstructed short term residual * signal dp[..] @@ -181,14 +182,14 @@ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), temp = 0; if (dmax == 0) scal = 0; else { - assert(dmax > 0); + XINE_ASSERT(dmax > 0, "value 'dmax' is not > 0: %d", dmax); temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; - assert(scal >= 0); + XINE_ASSERT(scal >= 0, "value 'scal' is not >= 0: %d", scal); /* Initialization of a working array wt */ @@ -241,10 +242,10 @@ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), /* Rescaling of L_max */ - assert(scal <= 100 && scal >= -100); + XINE_ASSERT( (scal <= 100) && (scal >= -100), "value 'scal' is not within range -100 to 100: %d", scal); L_max = L_max >> (6 - scal); /* sub(6, scal) */ - assert( Nc <= 120 && Nc >= 40); + XINE_ASSERT( Nc <= 120 && Nc >= 40, "value 'Nc' is not within range 40 to 120: %d", Nc); /* Compute the power of the reconstructed short term residual * signal dp[..] @@ -322,14 +323,16 @@ static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), temp = 0; if (dmax == 0) scal = 0; else { - assert(dmax > 0); + XINE_ASSERT(dmax > 0, "value 'dmax' is not > 0: %d", dmax); + temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; - assert(scal >= 0); + XINE_ASSERT(scal >= 0, "value 'scal' is not >= 0: %d", scal); + ltp_cut = (longword)SASR(dmax, scal) * st->ltp_cut / 100; @@ -421,10 +424,11 @@ static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), /* Rescaling of L_max */ - assert(scal <= 100 && scal >= -100); + XINE_ASSERT( (scal <= 100) && (scal >= -100), "value 'scal' is not within range -100 to 100: %d", scal); + L_max = L_max >> (6 - scal); /* sub(6, scal) */ - assert( Nc <= 120 && Nc >= 40); + XINE_ASSERT( Nc <= 120 && Nc >= 40, "value 'Nc' is not within range 40 to 120: %d", Nc); /* Compute the power of the reconstructed short term residual * signal dp[..] @@ -498,14 +502,14 @@ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), temp = 0; if (dmax == 0) scal = 0; else { - assert(dmax > 0); + XINE_ASSERT(dmax > 0, "value 'dmax' is not > 0: %d", dmax); temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; - assert(scal >= 0); + XINE_ASSERT(scal >= 0, "value 'scal' is not >= 0: %d", scal); /* Initialization of a working array wt */ @@ -586,10 +590,13 @@ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), /* Rescaling of L_max */ - assert(scal <= 100 && scal >= -100); + + XINE_ASSERT( (scal <= 100) && (scal >= -100), "value 'scal' is not within range -100 to 100: %d", scal); + L_max = L_max >> (6 - scal); /* sub(6, scal) */ - assert( Nc <= 120 && Nc >= 40); + XINE_ASSERT( Nc <= 120 && Nc >= 40, "value 'Nc' is not within range 40 to 120: %d", Nc); + /* Compute the power of the reconstructed short term residual * signal dp[..] @@ -659,7 +666,7 @@ static void Cut_Fast_Calculation_of_the_LTP_parameters P5((st, else if (-d[k] > wt_max) wt_max = -d[best_k = k]; } - assert(wt_max >= 0); + XINE_ASSERT(wt_max >= 0, "value 'wt_max' is not >= 0: %d", wt_max); wt_float = (float)wt_max; for (k = -120; k < 0; ++k) dp_float[k] = (float)dp[k]; @@ -877,8 +884,12 @@ void Gsm_Long_Term_Predictor P7((S,d,dp,e,dpp,Nc,bc), /* 4x for 160 samples */ word * bc /* gain factor OUT */ ) { - assert( d ); assert( dp ); assert( e ); - assert( dpp); assert( Nc ); assert( bc ); + XINE_ASSERT( d,"value 'd' is NULL"); + XINE_ASSERT( dp, "value 'dp' is NULL"); + XINE_ASSERT( e, "value 'e' is NULL"); + XINE_ASSERT( dpp, "value 'dpp' is NULL"); + XINE_ASSERT( Nc, "value 'Nc' is NULL"); + XINE_ASSERT( bc, "value 'bc' is NULL" ); #if defined(FAST) && defined(USE_FLOAT_MUL) if (S->fast) @@ -924,7 +935,7 @@ void Gsm_Long_Term_Synthesis_Filtering P5((S,Ncr,bcr,erp,drp), */ Nr = Ncr < 40 || Ncr > 120 ? S->nrp : Ncr; S->nrp = Nr; - assert(Nr >= 40 && Nr <= 120); + XINE_ASSERT(Nr >= 40 && Nr <= 120, "value 'Nr' is not within range of 40 to 120: %d", Nr); /* Decoding of the LTP gain bcr */ @@ -933,7 +944,7 @@ void Gsm_Long_Term_Synthesis_Filtering P5((S,Ncr,bcr,erp,drp), /* Computation of the reconstructed short term residual * signal drp[0..39] */ - assert(brp != MIN_WORD); + XINE_ASSERT(brp != MIN_WORD, "value 'brp' is equal to MIN_WORD"); for (k = 0; k <= 39; k++) { drpp = GSM_MULT_R( brp, drp[ k - Nr ] ); diff --git a/src/libxineadec/gsm610/lpc.c b/src/libxineadec/gsm610/lpc.c index 7795ca542..461f0b70f 100644 --- a/src/libxineadec/gsm610/lpc.c +++ b/src/libxineadec/gsm610/lpc.c @@ -4,10 +4,10 @@ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ -/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/lpc.c,v 1.1 2002/10/12 19:12:49 tmmm Exp $ */ +/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/lpc.c,v 1.2 2003/02/28 02:51:50 storri Exp $ */ #include <stdio.h> -#include <assert.h> +#include "xineutils.h" #include "private.h" @@ -54,7 +54,7 @@ static void Autocorrelation P2((s, L_ACF), */ if (smax == 0) scalauto = 0; else { - assert(smax > 0); + XINE_ASSERT(smax > 0, "Scale maximum (smax) is not greater than 0: %d", smax); scalauto = 4 - gsm_norm( (longword)smax << 16 );/* sub(4,..) */ } @@ -139,7 +139,7 @@ static void Autocorrelation P2((s, L_ACF), /* Rescaling of the array s[0..159] */ if (scalauto > 0) { - assert(scalauto <= 4); + XINE_ASSERT(scalauto <= 4, "scalauto is not <= 4: %d", scalauto); for (k = 160; k--; *s++ <<= scalauto) ; } } @@ -194,10 +194,10 @@ static void Reflection_coefficients P2( (L_ACF, r), return; } - assert( L_ACF[0] != 0 ); + XINE_ASSERT( L_ACF[0] != 0 , "L_ACF[0] is NULL"); temp = gsm_norm( L_ACF[0] ); - assert(temp >= 0 && temp < 32); + XINE_ASSERT(temp >= 0 && temp < 32, "temp is not within range 0 to 32: %d", temp); /* ? overflow ? */ for (i = 0; i <= 8; i++) ACF[i] = SASR( L_ACF[i] << temp, 16 ); @@ -221,9 +221,12 @@ static void Reflection_coefficients P2( (L_ACF, r), *r = gsm_div( temp, P[0] ); - assert(*r >= 0); + XINE_ASSERT(*r >= 0, "value 'r' is not >= 0: %d", *r); + if (P[1] > 0) *r = -*r; /* r[n] = sub(0, r[n]) */ - assert (*r != MIN_WORD); + + XINE_ASSERT (*r != MIN_WORD, "value 'r' is equal to MIN_WORD: %d", *r); + if (n == 8) return; /* Schur recursion @@ -264,21 +267,27 @@ static void Transformation_to_Log_Area_Ratios P1((r), temp = *r; temp = GSM_ABS(temp); - assert(temp >= 0); + + XINE_ASSERT(temp >= 0, "value 'temp' is not >= 0: %d", temp); if (temp < 22118) { temp >>= 1; } else if (temp < 31130) { - assert( temp >= 11059 ); + XINE_ASSERT(temp >= 11059, "value 'temp' is not >= 11059: %d", temp); temp -= 11059; } else { - assert( temp >= 26112 ); - temp -= 26112; - temp <<= 2; + XINE_ASSERT(temp >= 26112, "value 'temp' is not >= 26112: %d", temp); + temp -= 26112; + temp <<= 2; } - - *r = *r < 0 ? -temp : temp; - assert( *r != MIN_WORD ); + + if (*r < 0) { + *r = -temp; + } + else { + *r = temp; + } + XINE_ASSERT (*r != MIN_WORD, "value 'r' is equal to MIN_WORD: %d", *r); } } diff --git a/src/libxineadec/gsm610/rpe.c b/src/libxineadec/gsm610/rpe.c index f504573a6..4a9751cfa 100644 --- a/src/libxineadec/gsm610/rpe.c +++ b/src/libxineadec/gsm610/rpe.c @@ -4,11 +4,10 @@ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ -/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/rpe.c,v 1.1 2002/10/12 19:12:49 tmmm Exp $ */ +/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/rpe.c,v 1.2 2003/02/28 02:51:50 storri Exp $ */ #include <stdio.h> -#include <assert.h> - +#include "xineutils.h" #include "private.h" #include "gsm.h" @@ -142,7 +141,7 @@ static void RPE_grid_selection P3((x,xM,Mc_out), * * temp1 = SASR( x[m + 3*i], 2 ); * - * assert(temp1 != MIN_WORD); + * XINE_ASSERT(temp1 != MIN_WORD,"temp1 equals MIN_WORD"); * * L_temp = GSM_L_MULT( temp1, temp1 ); * L_result = GSM_L_ADD( L_temp, L_result ); @@ -246,8 +245,8 @@ static void APCM_quantization_xmaxc_to_exp_mant P3((xmaxc,exp_out,mant_out), mant -= 8; } - assert( exp >= -4 && exp <= 6 ); - assert( mant >= 0 && mant <= 7 ); + XINE_ASSERT( exp >= -4 && exp <= 6,"exp is not within range of -4 to 6: %d", exp ); + XINE_ASSERT( mant >= 0 && mant <= 7,"mant is not within range of 0 to 7: %d", mant ); *exp_out = exp; *mant_out = mant; @@ -290,14 +289,14 @@ static void APCM_quantization P5((xM,xMc,mant_out,exp_out,xmaxc_out), itest |= (temp <= 0); temp = SASR( temp, 1 ); - assert(exp <= 5); + XINE_ASSERT(exp <= 5, "exp is greater than 5: %d", exp); if (itest == 0) exp++; /* exp = add (exp, 1) */ } - assert(exp <= 6 && exp >= 0); + XINE_ASSERT(exp <= 6 && exp >= 0, "exp is not within range of 0 to 6: %d", exp); temp = exp + 5; - assert(temp <= 11 && temp >= 0); + XINE_ASSERT(temp <= 11 && temp >= 0, "temp is within range of 0 to 11: %d", temp); xmaxc = gsm_add( SASR(xmax, temp), exp << 3 ); /* Quantizing and coding of the xM[0..12] RPE sequence @@ -320,15 +319,15 @@ static void APCM_quantization P5((xM,xMc,mant_out,exp_out,xmaxc_out), /* Direct computation of xMc[0..12] using table 4.5 */ - assert( exp <= 4096 && exp >= -4096); - assert( mant >= 0 && mant <= 7 ); + XINE_ASSERT((exp <= 4096) && (exp >= -4096), "exp is not within range of -4069 to 4096: %d", exp ); + XINE_ASSERT((mant >= 0) && (mant <= 7), "mant is not within range of 0 to 7: %d", mant ); temp1 = 6 - exp; /* normalization by the exponent */ temp2 = gsm_NRFAC[ mant ]; /* inverse mantissa */ for (i = 0; i <= 12; i++) { - assert(temp1 >= 0 && temp1 < 16); + XINE_ASSERT(temp1 >= 0 && temp1 < 16, "temp1 is not within range of 0 to 15: %d", temp1); temp = xM[i] << temp1; temp = GSM_MULT( temp, temp2 ); @@ -361,24 +360,26 @@ static void APCM_inverse_quantization P4((xMc,mant,exp,xMp), word temp, temp1, temp2, temp3; longword ltmp; - assert( mant >= 0 && mant <= 7 ); + XINE_ASSERT((mant >= 0) && (mant <= 7), "mant is not within range of 0 to 7: %d", mant ); temp1 = gsm_FAC[ mant ]; /* see 4.2-15 for mant */ temp2 = gsm_sub( 6, exp ); /* see 4.2-15 for exp */ temp3 = gsm_asl( 1, gsm_sub( temp2, 1 )); for (i = 13; i--;) { - - assert( *xMc <= 7 && *xMc >= 0 ); /* 3 bit unsigned */ - - /* temp = gsm_sub( *xMc++ << 1, 7 ); */ - temp = (*xMc++ << 1) - 7; /* restore sign */ - assert( temp <= 7 && temp >= -7 ); /* 4 bit signed */ - - temp <<= 12; /* 16 bit signed */ - temp = GSM_MULT_R( temp1, temp ); - temp = GSM_ADD( temp, temp3 ); - *xMp++ = gsm_asr( temp, temp2 ); + XINE_ASSERT((mant >= 0) && (mant <= 7), "mant is not within range of 0 to 7: %d", mant ); + + XINE_ASSERT((*xMc <= 7) && (*xMc >= 0), "xMc is not 3 bit unsigned: %d", *xMc ); /* 3 bit unsigned */ + + /* temp = gsm_sub( *xMc++ << 1, 7 ); */ + temp = (*xMc++ << 1) - 7; /* restore sign */ + + XINE_ASSERT((temp <= 7) && (temp >= -7), "temp is not 4 bit signed: %d", temp); /* 4 bit signed */ + + temp <<= 12; /* 16 bit signed */ + temp = GSM_MULT_R( temp1, temp ); + temp = GSM_ADD( temp, temp3 ); + *xMp++ = gsm_asr( temp, temp2 ); } } @@ -399,7 +400,7 @@ static void RPE_grid_positioning P3((Mc,xMp,ep), { int i = 13; - assert(0 <= Mc && Mc <= 3); + XINE_ASSERT((0 <= Mc) && (Mc <= 3), "Mc is not within the range of 0 to 3: %d", Mc); switch (Mc) { case 3: *ep++ = 0; diff --git a/src/libxineadec/gsm610/short_term.c b/src/libxineadec/gsm610/short_term.c index 63392eca5..52ac623d2 100644 --- a/src/libxineadec/gsm610/short_term.c +++ b/src/libxineadec/gsm610/short_term.c @@ -4,11 +4,10 @@ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ -/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/short_term.c,v 1.1 2002/10/12 19:12:49 tmmm Exp $ */ +/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/short_term.c,v 1.2 2003/02/28 02:51:50 storri Exp $ */ #include <stdio.h> -#include <assert.h> - +#include "xineutils.h" #include "private.h" #include "gsm.h" @@ -43,7 +42,7 @@ static void Decoding_of_the_coded_Log_Area_Ratios P2((LARc,LARpp), * temp2 = *B << 1; * temp1 = GSM_SUB( temp1, temp2 ); * - * assert(*INVA != MIN_WORD); + * XINE_ASSERT(*INVA != MIN_WORD, "INVA table equlas MIN_WORD"); * * temp1 = GSM_MULT_R( *INVA, temp1 ); * *LARpp = GSM_ADD( temp1, temp1 ); diff --git a/src/video_out/alphablend.c b/src/video_out/alphablend.c index 2f966f7f0..794d602ae 100644 --- a/src/video_out/alphablend.c +++ b/src/video_out/alphablend.c @@ -480,8 +480,9 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, } break; case 6: /* Finished */ - printf("Don't ever get here\n"); - assert(0); + XINE_ASSERT(0,"Don't ever get here\n"); + /* This case will not fall through, XINE_ASSERT contains a call to abort() */ + case 7: /* No button */ clut = (clut_t*) img_overl->color; trans = img_overl->trans; diff --git a/src/video_out/video_out_directfb.c b/src/video_out/video_out_directfb.c index 9c01d12fe..4ddda3eb0 100644 --- a/src/video_out/video_out_directfb.c +++ b/src/video_out/video_out_directfb.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_directfb.c,v 1.14 2002/09/05 20:44:42 mroi Exp $ + * $Id: video_out_directfb.c,v 1.15 2003/02/28 02:51:51 storri Exp $ * * DirectFB based output plugin. * Rich Wareham <richwareham@users.sourceforge.net> @@ -44,7 +44,6 @@ #include <stdlib.h> #include <string.h> #include <math.h> -#include <assert.h> #include "video_out.h" @@ -344,8 +343,8 @@ static void directfb_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen if( !overlay->rgb_clut || !overlay->clip_rgb_clut) directfb_overlay_clut_yuv2rgb(this,overlay); - assert (this->delivered_width == frame->width); - assert (this->delivered_height == frame->height); + XINE_ASSERT (this->delivered_width == frame->width, "Delivered frame width does not match desired width"); + XINE_ASSERT (this->delivered_height == frame->height, "Delivered frame height does not match desire height"); # if BYTES_PER_PIXEL == 3 blend_rgb24 ((uint8_t *)frame->texture, overlay, frame->width, frame->height, diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c index de17a77b3..870f2b6d3 100644 --- a/src/video_out/video_out_opengl.c +++ b/src/video_out/video_out_opengl.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_opengl.c,v 1.24 2003/02/02 12:44:03 esnel Exp $ + * $Id: video_out_opengl.c,v 1.25 2003/02/28 02:51:51 storri Exp $ * * video_out_glut.c, glut based OpenGL rendering interface for xine * Matthias Hopf <mat@mshopf.de> @@ -61,7 +61,6 @@ #include <stdlib.h> #include <string.h> #include <math.h> -#include <assert.h> #include <X11/Xlib.h> @@ -338,7 +337,7 @@ static void opengl_update_frame_format (vo_driver_t *this_gen, frame->chunk[0] = frame->chunk[1] = frame->chunk[2] = NULL; frame->texture = calloc (1, BYTES_PER_PIXEL * image_size); - assert (frame->texture); + XINE_ASSERT(frame->texture, "Frame texture is NULL"); switch (format) { case XINE_IMGFMT_YV12: @@ -501,25 +500,25 @@ static void opengl_render_image (opengl_driver_t *this, opengl_frame_t *frame, /* already initialized? */ if (! this->drawable || ! this->vinfo) - { + { fprintf (stderr, "video_out_opengl: early exit due to missing drawable %lx vinfo %p\n", this->drawable, this->vinfo); return; - } - + } + /* * check for size changes */ if (frame->width != this->last_width || frame->height != this->last_height || frame->ratio_code != this->last_ratio_code) { - - this->last_width = frame->width; - this->last_height = frame->height; - this->last_ratio_code = frame->ratio_code; - - DEBUGF ((stderr, "video_out_opengl: display format changed\n")); - opengl_compute_ideal_size (this); - opengl_compute_output_size (this); + + this->last_width = frame->width; + this->last_height = frame->height; + this->last_ratio_code = frame->ratio_code; + + DEBUGF ((stderr, "video_out_opengl: display format changed\n")); + opengl_compute_ideal_size (this); + opengl_compute_output_size (this); } /* @@ -531,37 +530,42 @@ static void opengl_render_image (opengl_driver_t *this, opengl_frame_t *frame, /* * check whether a new context has to be created */ -DEBUGF ((stderr, "video_out_opengl: CHECK\n")); + DEBUGF ((stderr, "video_out_opengl: CHECK\n")); if (((ctx == this->context || ! ctx) && (this->context_state == CONTEXT_BAD || this->context_state == CONTEXT_SAME_DRAWABLE)) || (self != this->renderthread)) { -static int glxAttrib[] = { -GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None -} ; -DEBUGF ((stderr, "video_out_opengl: ASSERT\n")); - assert (this->vinfo); -DEBUGF ((stderr, "video_out_opengl: PASSED\n")); - if ((this->context_state == CONTEXT_SAME_DRAWABLE) && - (self == this->renderthread)) + + static int glxAttrib[] = { + GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None + } ; + + XINE_ASSERT (this->vinfo, "this->vinfo is NULL"); + + if ((this->context_state == CONTEXT_SAME_DRAWABLE) && + (self == this->renderthread)) { - DEBUGF ((stderr, "destroy: %p\n", this->context)); - /* Unfortunately for _BAD the drawable is already destroyed. - * This cannot be resolved right now and will be a memory leak. */ - if (this->context) - glXDestroyContext (this->display, this->context); + DEBUGF ((stderr, "destroy: %p\n", this->context)); + /* Unfortunately for _BAD the drawable is already destroyed. + * This cannot be resolved right now and will be a memory leak. */ + if (this->context) + glXDestroyContext (this->display, this->context); } -DEBUGF ((stderr, "screen %dx%d\n", ((Screen *) this->screen)->width, ((Screen *)this->screen)->height)); -DEBUGF ((stderr, "glXChooseVisual\n")); -this->vinfo = glXChooseVisual (this->display, this->screen, glxAttrib); - DEBUGF ((stderr, "create display %p vinfo %p\n", this->display, this->vinfo)); - ctx = glXCreateContext (this->display, this->vinfo, NULL, True); - DEBUGF ((stderr, "created\n")); - assert (ctx); - this->context = ctx; - this->context_state = CONTEXT_RELOAD; - this->renderthread = self; + + DEBUGF ((stderr, "screen %dx%d\n", ((Screen *) this->screen)->width, ((Screen *)this->screen)->height)); + DEBUGF ((stderr, "glXChooseVisual\n")); + + this->vinfo = glXChooseVisual (this->display, this->screen, glxAttrib); + DEBUGF ((stderr, "create display %p vinfo %p\n", this->display, this->vinfo)); + ctx = glXCreateContext (this->display, this->vinfo, NULL, True); + DEBUGF ((stderr, "created\n")); + + XINE_ASSERT(ctx, "ctx is NULL"); + + this->context = ctx; + this->context_state = CONTEXT_RELOAD; + this->renderthread = self; } if (this->context_state == CONTEXT_RELOAD && ! ctx) @@ -909,7 +913,7 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, * allocate plugin struct */ this = calloc (1, sizeof (opengl_driver_t)); - assert (this); + XINE_ASSERT (this, "OpenGL driver struct is not defined"); this->config = class->config; this->display = visual->display; diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 622b61f17..b9f30a551 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_xv.c,v 1.158 2003/02/22 16:56:01 hadess Exp $ + * $Id: video_out_xv.c,v 1.159 2003/02/28 02:51:51 storri Exp $ * * video_out_xv.c, X11 video extension interface for xine * @@ -41,7 +41,6 @@ #include <stdlib.h> #include <string.h> #include <math.h> -#include <assert.h> #if defined(__FreeBSD__) #include <machine/param.h> diff --git a/src/video_out/yuv2rgb_mlib.c b/src/video_out/yuv2rgb_mlib.c index a8fbd7c44..cdef81a66 100644 --- a/src/video_out/yuv2rgb_mlib.c +++ b/src/video_out/yuv2rgb_mlib.c @@ -29,7 +29,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include <inttypes.h> #include <mlib_video.h> @@ -83,7 +82,8 @@ static void mlib_yuv420_rgb24 (yuv2rgb_t *this, dy = 0; dst_height = this->next_slice (this, &image); - assert((this->dest_width&1) == 0); /* mlib needs an even YUV2 width */ + XINE_ASSERT((this->dest_width&1) == 0, "mlib needs an even YUV2 width."); + for (;;) { scale_line (pu, this->u_buffer, this->dest_width >> 1, this->step_dx); @@ -160,7 +160,8 @@ static void mlib_yuv420_argb32 (yuv2rgb_t *this, dy = 0; dst_height = this->next_slice (this, &image); - assert((this->dest_width&1) == 0); /* mlib needs an even YUV2 width */ + XINE_ASSERT((this->dest_width&1) == 0, "mlib needs an even YUV2 width"); + for (;;) { scale_line (pu, this->u_buffer, this->dest_width >> 1, this->step_dx); @@ -237,7 +238,8 @@ static void mlib_yuv420_abgr32 (yuv2rgb_t *this, dy = 0; dst_height = this->next_slice (this, &image); - assert((this->dest_width&1) == 0); /* mlib needs an even YUV2 width */ + XINE_ASSERT ((this->dest_width&1) == 0, "mlib needs an even YUV2 width."); + for (;;) { scale_line (pu, this->u_buffer, this->dest_width >> 1, this->step_dx); diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index ed25f69c7..637ec42d2 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -17,7 +17,7 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.108 2003/02/22 14:18:16 mroi Exp $ + * $Id: audio_out.c,v 1.109 2003/02/28 02:51:51 storri Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org> @@ -219,7 +219,7 @@ static void fifo_append_int (audio_fifo_t *fifo, /* buf->next = NULL; */ - assert (!buf->next); + XINE_ASSERT(!buf->next, "Next audio buffer is NULL."); if (!fifo->first) { fifo->first = buf; diff --git a/src/xine-engine/bswap.h b/src/xine-engine/bswap.h index 900ef6271..72a6badbc 100644 --- a/src/xine-engine/bswap.h +++ b/src/xine-engine/bswap.h @@ -6,13 +6,13 @@ #include "config.h" #endif +#include "xineutils.h" + #ifdef HAVE_BYTESWAP_H #include <byteswap.h> -#include <assert.h> #else - #include <inttypes.h> -#include <assert.h> + #ifdef ARCH_X86 inline static unsigned short ByteSwap16(unsigned short x) @@ -106,7 +106,7 @@ inline static unsigned long long int ByteSwap64(unsigned long long int x) inline static void* check_ptr_alignment(void* ptr, int align) { - assert((int)ptr % align == 0); + XINE_ASSERT((int)ptr % align == 0, "Improper pointer alignment."); return ptr; } diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 50892323a..433263d3c 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: configfile.c,v 1.45 2003/02/02 12:33:23 hadess Exp $ + * $Id: configfile.c,v 1.46 2003/02/28 02:51:51 storri Exp $ * * config object (was: file) management - implementation * @@ -32,7 +32,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "configfile.h" #include "xineutils.h" #include "xine_internal.h" @@ -214,8 +213,8 @@ static char *_xine_config_register_string (config_values_t *this, cfg_entry_t *entry; - assert (key); - assert (def_value); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); + XINE_ASSERT(def_value, "Default value is NULL. This is a required argument."); #ifdef LOG printf ("configfile: registering %s\n", key); @@ -279,8 +278,7 @@ static int _xine_config_register_num (config_values_t *this, void *cb_data) { cfg_entry_t *entry; - - assert (key); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); #ifdef LOG printf ("configfile: registering %s\n", key); @@ -338,8 +336,7 @@ static int _xine_config_register_bool (config_values_t *this, void *cb_data) { cfg_entry_t *entry; - - assert (key); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); #ifdef LOG printf ("configfile: registering %s\n", key); @@ -398,8 +395,7 @@ static int _xine_config_register_range (config_values_t *this, void *cb_data) { cfg_entry_t *entry; - - assert (key); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); #ifdef LOG printf ("configfile: registering range %s\n", key); @@ -490,9 +486,8 @@ static int _xine_config_register_enum (config_values_t *this, void *cb_data) { cfg_entry_t *entry; - - assert (key); - assert (values); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); + XINE_ASSERT(values, "Argument 'values' is NULL. This is a required argument."); #ifdef LOG printf ("configfile: registering enum %s\n", key); @@ -898,8 +893,8 @@ static void xine_config_unregister_cb (config_values_t *this, cfg_entry_t *entry; - assert (this); - assert (key); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); + XINE_ASSERT(this, "Argument 'this' is NULL. Cannot find key if this is not set."); entry = _xine_config_lookup_entry (this, key); if (entry) { diff --git a/src/xine-engine/lrb.c b/src/xine-engine/lrb.c index c3be42039..63072472b 100644 --- a/src/xine-engine/lrb.c +++ b/src/xine-engine/lrb.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: lrb.c,v 1.3 2002/10/23 17:12:31 guenter Exp $ + * $Id: lrb.c,v 1.4 2003/02/28 02:51:51 storri Exp $ * */ @@ -25,7 +25,6 @@ #include "config.h" #endif -#include <assert.h> #include "lrb.h" #include "xineutils.h" @@ -49,7 +48,7 @@ void lrb_drop (lrb_t *this) { buf_element_t *buf = this->oldest; - assert (buf); + XINE_ASSERT(buf, "Oldest buffer element is NULL"); this->oldest = buf->next; diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index 500e13eb4..71e057f78 100644 --- a/src/xine-engine/metronom.c +++ b/src/xine-engine/metronom.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: metronom.c,v 1.111 2003/01/28 17:07:53 f1rmb Exp $ + * $Id: metronom.c,v 1.112 2003/02/28 02:51:51 storri Exp $ */ #ifdef HAVE_CONFIG_H @@ -32,7 +32,6 @@ #include <math.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "xine_internal.h" #include "metronom.h" diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index faee09e35..7f4001ed8 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out.c,v 1.146 2003/02/22 14:22:13 mroi Exp $ + * $Id: video_out.c,v 1.147 2003/02/28 02:51:51 storri Exp $ * * frame allocation / queuing / scheduling / output functions */ @@ -34,7 +34,6 @@ #include <string.h> #include <zlib.h> #include <pthread.h> -#include <assert.h> #define XINE_ENABLE_EXPERIMENTAL_FEATURES @@ -126,7 +125,7 @@ static void vo_append_to_img_buf_queue_int (img_buf_fifo_t *queue, vo_frame_t *img) { /* img already enqueue? (serious leak) */ - assert (img->next==NULL); + XINE_ASSERT (img->next==NULL, "Image is already enqueue. Next image is not NULL"); img->next = NULL; diff --git a/src/xine-engine/vo_scale.c b/src/xine-engine/vo_scale.c index a785c9f5d..ed024a1dc 100644 --- a/src/xine-engine/vo_scale.c +++ b/src/xine-engine/vo_scale.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: vo_scale.c,v 1.18 2002/11/25 16:56:06 mroi Exp $ + * $Id: vo_scale.c,v 1.19 2003/02/28 02:51:51 storri Exp $ * * Contains common code to calculate video scaling parameters. * In short, it will map frame dimensions to screen/window size. @@ -101,7 +101,8 @@ void vo_scale_compute_ideal_size (vo_scale_t *this) { this->video_pixel_aspect = desired_ratio / image_ratio; - assert (this->gui_pixel_aspect != 0.0); + XINE_ASSERT(this->gui_pixel_aspect != 0.0, "GUI pixel aspect is not 0.0: %f",this->gui_pixel_aspect); + if (fabs (this->video_pixel_aspect / this->gui_pixel_aspect - 1.0) < 0.01) { this->video_pixel_aspect = this->gui_pixel_aspect; diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h index e7e48d5af..2179823c8 100644 --- a/src/xine-utils/attributes.h +++ b/src/xine-utils/attributes.h @@ -21,6 +21,9 @@ /* use gcc attribs to align critical data structures */ +#ifndef ATTRIBUTE_H_ +#define ATTRIBUTE_H_ + #ifdef ATTRIBUTE_ALIGNED_MAX #define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) #else @@ -36,3 +39,6 @@ #undef ATTRIBUTE_PACKED #define __attribute__(x) /**/ #endif + +#endif /* ATTRIBUTE_H_ */ + diff --git a/src/xine-utils/xine_check.c b/src/xine-utils/xine_check.c index 88b6bff79..33519c342 100644 --- a/src/xine-utils/xine_check.c +++ b/src/xine-utils/xine_check.c @@ -84,7 +84,7 @@ static void set_hc_result(xine_health_check_t* hc, int state, char *format, ...) size = strlen(format) + 1; if ((buf = malloc(size)) == NULL) { - printf ("xine_heck: GASP, malloc() failed\n"); + printf ("xine_check: GASP, malloc() failed\n"); abort(); } diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h index 0656a5f1f..d1e2d1981 100644 --- a/src/xine-utils/xineutils.h +++ b/src/xine-utils/xineutils.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xineutils.h,v 1.33 2003/02/02 06:07:20 tmmm Exp $ + * $Id: xineutils.h,v 1.34 2003/02/28 02:51:52 storri Exp $ * */ #ifndef XINEUTILS_H @@ -30,12 +30,19 @@ extern "C" { #include <unistd.h> #include <stdlib.h> #include <string.h> +#include <stdarg.h> #include <inttypes.h> #include <pthread.h> #include "attributes.h" #include "compat.h" #include "xmlparser.h" #include "xine_buffer.h" +#include "configfile.h" +#include "config.h" + +#include <stdio.h> +#include <string.h> +#include <execinfo.h> #ifdef __SUNPRO_C #define inline @@ -784,6 +791,40 @@ extern int v_g_table[256]; extern int v_b_table[256]; + /* Code Taken from GNU C Library manual */ +/* Obtain a backtrace and print it to stdout. */ +static void +print_trace (void) +{ + void *array[10]; + size_t size; + char **strings; + size_t i; + + size = backtrace (array, 10); + strings = backtrace_symbols (array, size); + + printf ("Obtained %zd stack frames.\n", size); + + for (i = 0; i < size; i++) { + printf ("%s\n", strings[i]); + } + free (strings); +} + +/** + * Provide assert like feature with better description of failure + * Thanks to Mark Thomas + */ +#define XINE_ASSERT(exp, desc, args...) \ + if (!(exp)) { \ + printf("%s:%s:%d: assertion `" #exp "' failed. " desc "\n\n", \ + __FILE__, __FUNCTION__, __LINE__, ##args); \ + print_trace(); \ + abort(); \ + } + + /******** double chained lists with builtin iterator *******/ typedef struct xine_node_s { |