comparison mpegaudioenc.c @ 6961:1cf8c883365f libavcodec

Prevent scalefactors from overflowing. fixes issue351
author michael
date Sun, 01 Jun 2008 01:07:59 +0000
parents f2fc71a9c89f
children e943e1409077
comparison
equal deleted inserted replaced
6960:cdde357b67d8 6961:1cf8c883365f
385 v = abs(*p); 385 v = abs(*p);
386 if (v > vmax) 386 if (v > vmax)
387 vmax = v; 387 vmax = v;
388 } 388 }
389 /* compute the scale factor index using log 2 computations */ 389 /* compute the scale factor index using log 2 computations */
390 if (vmax > 0) { 390 if (vmax > 1) {
391 n = av_log2(vmax); 391 n = av_log2(vmax);
392 /* n is the position of the MSB of vmax. now 392 /* n is the position of the MSB of vmax. now
393 use at most 2 compares to find the index */ 393 use at most 2 compares to find the index */
394 index = (21 - n) * 3 - 3; 394 index = (21 - n) * 3 - 3;
395 if (index >= 0) { 395 if (index >= 0) {