mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Write for loops in a more standard way. In my opinion, they are much more readable now.
Originally committed as revision 14068 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
b517af05b9
commit
6f1e7a9e09
@ -40,22 +40,27 @@ typedef struct {
|
|||||||
/* Decode and produce output */
|
/* Decode and produce output */
|
||||||
static void decode(Real288_internal *glob, float gain, int cb_coef)
|
static void decode(Real288_internal *glob, float gain, int cb_coef)
|
||||||
{
|
{
|
||||||
unsigned int x, y;
|
int x, y;
|
||||||
double sum, sumsum;
|
double sum, sumsum;
|
||||||
float buffer[5];
|
float buffer[5];
|
||||||
|
|
||||||
for (x=36; x--; glob->sb[x+5] = glob->sb[x]);
|
for (x=35; x >= 0; x--)
|
||||||
|
glob->sb[x+5] = glob->sb[x];
|
||||||
|
|
||||||
for (x=5; x--;) {
|
for (x=4; x >= 0; x--) {
|
||||||
float *p1 = glob->sb+x;
|
float *p1 = glob->sb+x;
|
||||||
float *p2 = glob->pr1;
|
float *p2 = glob->pr1;
|
||||||
for (sum=0, y=36; y--; sum -= (*(++p1))*(*(p2++)));
|
sum = 0;
|
||||||
|
for (y=0; y < 36; y++)
|
||||||
|
sum -= (*(++p1))*(*(p2++));
|
||||||
|
|
||||||
glob->sb[x] = sum;
|
glob->sb[x] = sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert log and do rms */
|
/* convert log and do rms */
|
||||||
for (sum=32, x=10; x--; sum -= glob->pr2[x] * glob->lhist[x]);
|
sum = 32;
|
||||||
|
for (x=0; x < 10; x++)
|
||||||
|
sum -= glob->pr2[x] * glob->lhist[x];
|
||||||
|
|
||||||
if (sum < 0)
|
if (sum < 0)
|
||||||
sum = 0;
|
sum = 0;
|
||||||
@ -64,21 +69,25 @@ static void decode(Real288_internal *glob, float gain, int cb_coef)
|
|||||||
|
|
||||||
sumsum = exp(sum * 0.1151292546497) * gain; /* pow(10.0,sum/20)*f */
|
sumsum = exp(sum * 0.1151292546497) * gain; /* pow(10.0,sum/20)*f */
|
||||||
|
|
||||||
for (sum=0, x=5; x--;) {
|
sum = 0;
|
||||||
|
for (x=0; x < 5; x++) {
|
||||||
buffer[x] = codetable[cb_coef][x] * sumsum;
|
buffer[x] = codetable[cb_coef][x] * sumsum;
|
||||||
sum += buffer[x] * buffer[x];
|
sum += buffer[x] * buffer[x];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sum /= 5) < 1)
|
sum /= 5;
|
||||||
|
if (sum < 1)
|
||||||
sum = 1;
|
sum = 1;
|
||||||
|
|
||||||
/* shift and store */
|
/* shift and store */
|
||||||
for (x=10; --x; glob->lhist[x] = glob->lhist[x-1]);
|
for (x=10; x > 0; x--)
|
||||||
|
glob->lhist[x] = glob->lhist[x-1];
|
||||||
|
|
||||||
*glob->lhist = glob->history[glob->phase] = 10 * log10(sum) - 32;
|
*glob->lhist = glob->history[glob->phase] = 10 * log10(sum) - 32;
|
||||||
|
|
||||||
for (x=1; x < 5; x++)
|
for (x=1; x < 5; x++)
|
||||||
for (y=x; y--; buffer[x] -= glob->pr1[x-y-1] * buffer[y]);
|
for (y=x-1; y >= 0; y--)
|
||||||
|
buffer[x] -= glob->pr1[x-y-1] * buffer[y];
|
||||||
|
|
||||||
/* output */
|
/* output */
|
||||||
for (x=0; x < 5; x++) {
|
for (x=0; x < 5; x++) {
|
||||||
@ -119,7 +128,9 @@ static int pred(float *in, float *tgt, int n)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
f1 = *(p1--);
|
f1 = *(p1--);
|
||||||
for (y=x; --y; f1 += (*(p1--))*(*(p2++)));
|
|
||||||
|
for (y=0; y < x - 1; y++)
|
||||||
|
f1 += (*(p1--))*(*(p2++));
|
||||||
|
|
||||||
p1 = tgt + x - 1;
|
p1 = tgt + x - 1;
|
||||||
p2 = tgt;
|
p2 = tgt;
|
||||||
@ -143,7 +154,9 @@ static void prodsum(float *tgt, float *src, int len, int n)
|
|||||||
while (n >= 0) {
|
while (n >= 0) {
|
||||||
float *p2 = src;
|
float *p2 = src;
|
||||||
float *p1 = p2 - n;
|
float *p1 = p2 - n;
|
||||||
for (sum=0, x=len; x--; sum += (*p1++) * (*p2++));
|
sum = 0;
|
||||||
|
for (x=0; x < len; x++)
|
||||||
|
sum += (*p1++) * (*p2++);
|
||||||
tgt[n--] = sum;
|
tgt[n--] = sum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,14 +196,18 @@ static void update(Real288_internal *glob)
|
|||||||
float buffer1[40], temp1[37];
|
float buffer1[40], temp1[37];
|
||||||
float buffer2[8], temp2[11];
|
float buffer2[8], temp2[11];
|
||||||
|
|
||||||
for (x=0, y=glob->phasep+5; x < 40; buffer1[x++] = glob->output[(y++)%40]);
|
y = glob->phasep+5;
|
||||||
|
for (x=0; x < 40; x++)
|
||||||
|
buffer1[x] = glob->output[(y++)%40];
|
||||||
|
|
||||||
co(36, 40, 35, buffer1, temp1, glob->st1a, glob->st1b, table1);
|
co(36, 40, 35, buffer1, temp1, glob->st1a, glob->st1b, table1);
|
||||||
|
|
||||||
if (pred(temp1, glob->st1, 36))
|
if (pred(temp1, glob->st1, 36))
|
||||||
colmult(glob->pr1, glob->st1, table1a, 36);
|
colmult(glob->pr1, glob->st1, table1a, 36);
|
||||||
|
|
||||||
for (x=0, y=glob->phase + 1; x < 8; buffer2[x++] = glob->history[(y++) % 8]);
|
y = glob->phase + 1;
|
||||||
|
for (x=0; x < 8; x++)
|
||||||
|
buffer2[x] = glob->history[(y++) % 8];
|
||||||
|
|
||||||
co(10, 8, 20, buffer2, temp2, glob->st2a, glob->st2b, table2);
|
co(10, 8, 20, buffer2, temp2, glob->st2a, glob->st2b, table2);
|
||||||
|
|
||||||
@ -223,7 +240,8 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data,
|
|||||||
glob->phasep = (glob->phase = x & 7) * 5;
|
glob->phasep = (glob->phase = x & 7) * 5;
|
||||||
decode(glob, gain, cb_coef);
|
decode(glob, gain, cb_coef);
|
||||||
|
|
||||||
for (y=0; y<5; *(out++) = 8 * glob->output[glob->phasep+(y++)]);
|
for (y=0; y < 5; y++)
|
||||||
|
*(out++) = 8 * glob->output[glob->phasep + y];
|
||||||
|
|
||||||
if (glob->phase == 3)
|
if (glob->phase == 3)
|
||||||
update(glob);
|
update(glob);
|
||||||
|
Loading…
Reference in New Issue
Block a user