|
|
|
@ -40,22 +40,27 @@ typedef struct { |
|
|
|
|
/* Decode and produce output */ |
|
|
|
|
static void decode(Real288_internal *glob, float gain, int cb_coef) |
|
|
|
|
{ |
|
|
|
|
unsigned int x, y; |
|
|
|
|
int x, y; |
|
|
|
|
double sum, sumsum; |
|
|
|
|
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 *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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* 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) |
|
|
|
|
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 */ |
|
|
|
|
|
|
|
|
|
for (sum=0, x=5; x--;) { |
|
|
|
|
sum = 0; |
|
|
|
|
for (x=0; x < 5; x++) { |
|
|
|
|
buffer[x] = codetable[cb_coef][x] * sumsum; |
|
|
|
|
sum += buffer[x] * buffer[x]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((sum /= 5) < 1) |
|
|
|
|
sum /= 5; |
|
|
|
|
if (sum < 1) |
|
|
|
|
sum = 1; |
|
|
|
|
|
|
|
|
|
/* 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; |
|
|
|
|
|
|
|
|
|
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 */ |
|
|
|
|
for (x=0; x < 5; x++) { |
|
|
|
@ -119,7 +128,9 @@ static int pred(float *in, float *tgt, int n) |
|
|
|
|
return 1; |
|
|
|
|
|
|
|
|
|
f1 = *(p1--); |
|
|
|
|
for (y=x; --y; f1 += (*(p1--))*(*(p2++))); |
|
|
|
|
|
|
|
|
|
for (y=0; y < x - 1; y++) |
|
|
|
|
f1 += (*(p1--))*(*(p2++)); |
|
|
|
|
|
|
|
|
|
p1 = tgt + x - 1; |
|
|
|
|
p2 = tgt; |
|
|
|
@ -143,7 +154,9 @@ static void prodsum(float *tgt, float *src, int len, int n) |
|
|
|
|
while (n >= 0) { |
|
|
|
|
float *p2 = src; |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -183,14 +196,18 @@ static void update(Real288_internal *glob) |
|
|
|
|
float buffer1[40], temp1[37]; |
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
if (pred(temp1, glob->st1, 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); |
|
|
|
|
|
|
|
|
@ -223,7 +240,8 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data, |
|
|
|
|
glob->phasep = (glob->phase = x & 7) * 5; |
|
|
|
|
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) |
|
|
|
|
update(glob); |
|
|
|
|