From 49327f43ca2196122a60314e67eeee929efea873 Mon Sep 17 00:00:00 2001 From: Stephen Torri Date: Fri, 28 Feb 2003 02:51:47 +0000 Subject: 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: :: - assertion '' failed. 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 CVS patchset: 4301 CVS date: 2003/02/28 02:51:47 --- src/libffmpeg/libavcodec/motion_est_template.c | 45 ++++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'src/libffmpeg/libavcodec/motion_est_template.c') 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)<= 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= %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; -- cgit v1.2.3