summaryrefslogtreecommitdiff
path: root/src/libffmpeg/libavcodec/ratecontrol.c
diff options
context:
space:
mode:
authorStephen Torri <storri@users.sourceforge.net>2003-02-28 02:51:47 +0000
committerStephen Torri <storri@users.sourceforge.net>2003-02-28 02:51:47 +0000
commit49327f43ca2196122a60314e67eeee929efea873 (patch)
tree1b9ce1d2b141d0e411e422df265f6d57183906e1 /src/libffmpeg/libavcodec/ratecontrol.c
parent7eb769e2d3c1abb16e53d87af5f8633967e7f6ce (diff)
downloadxine-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/ratecontrol.c')
-rw-r--r--src/libffmpeg/libavcodec/ratecontrol.c26
1 files changed, 12 insertions, 14 deletions
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--){