diff options
author | Stephen Torri <storri@users.sourceforge.net> | 2003-02-28 02:51:47 +0000 |
---|---|---|
committer | Stephen Torri <storri@users.sourceforge.net> | 2003-02-28 02:51:47 +0000 |
commit | 49327f43ca2196122a60314e67eeee929efea873 (patch) | |
tree | 1b9ce1d2b141d0e411e422df265f6d57183906e1 /src/libffmpeg/libavcodec/motion_est_template.c | |
parent | 7eb769e2d3c1abb16e53d87af5f8633967e7f6ce (diff) | |
download | xine-lib-49327f43ca2196122a60314e67eeee929efea873.tar.gz xine-lib-49327f43ca2196122a60314e67eeee929efea873.tar.bz2 |
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
CVS patchset: 4301
CVS date: 2003/02/28 02:51:47
Diffstat (limited to 'src/libffmpeg/libavcodec/motion_est_template.c')
-rw-r--r-- | src/libffmpeg/libavcodec/motion_est_template.c | 45 |
1 files changed, 28 insertions, 17 deletions
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; |