--- ./libspeex/cb_search.c.dist 2009-04-22 17:21:51.110234240 +0100 +++ ./libspeex/cb_search.c 2009-04-22 17:29:19.640644040 +0100 @@ -255,6 +255,7 @@ int complexity, int update_target ) { + int inner_done, outer_done; int i,j,k,m,n,q; VARDECL(spx_word16_t *resp); #ifdef _USE_SSE @@ -364,8 +365,11 @@ int update_target steps (e.g. NaNs) */ for (j=0;jMULT16_16(best_score[j],ADD16(1,ener16[i-start]))) { @@ -282,7 +286,7 @@ void open_loop_nbest_pitch(spx_word16_t best_score[j]=tmp; best_ener[j]=ener16[i-start]+1; pitch[j]=i; - break; + loop_done=1; } } } --- ./libspeex/sb_celp.c.dist 2009-04-22 17:33:55.139393600 +0100 +++ ./libspeex/sb_celp.c 2009-04-22 17:36:00.241695320 +0100 @@ -303,6 +303,7 @@ void sb_encoder_destroy(void *state) int sb_encode(void *state, void *vin, SpeexBits *bits) { + int loop_done; SBEncState *st; int i, roots, sub; char *stack; @@ -461,7 +462,10 @@ int sb_encode(void *state, void *vin, Sp st->relative_quality+=1.0*(ratio+2); if (st->relative_quality<-1) st->relative_quality=-1; - while (modeid) + + loop_done = 0; + + while (modeid && !loop_done) { int v1; float thresh; @@ -472,7 +476,7 @@ int sb_encode(void *state, void *vin, Sp thresh = (st->vbr_quality-v1) * mode->vbr_thresh[modeid][v1+1] + (1+v1-st->vbr_quality) * mode->vbr_thresh[modeid][v1]; if (st->relative_quality >= thresh && st->sampling_rate*st->submodes[modeid]->bits_per_frame/st->full_frame_size <= st->vbr_max_high) - break; + loop_done = 1; modeid--; } speex_encoder_ctl(state, SPEEX_SET_HIGH_MODE, &modeid);