mirror of https://git.ffmpeg.org/ffmpeg.git
flacdec: move lpc filter to flacdsp
Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
parent
4a8528349f
commit
25accf93ad
|
@ -360,7 +360,7 @@ static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order,
|
|||
static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order,
|
||||
int bps)
|
||||
{
|
||||
int i, j;
|
||||
int i;
|
||||
int coeff_prec, qlevel;
|
||||
int coeffs[32];
|
||||
int32_t *decoded = s->decoded[channel];
|
||||
|
@ -389,38 +389,7 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order,
|
|||
if (decode_residuals(s, channel, pred_order) < 0)
|
||||
return -1;
|
||||
|
||||
if (s->bps > 16) {
|
||||
int64_t sum;
|
||||
for (i = pred_order; i < s->blocksize; i++) {
|
||||
sum = 0;
|
||||
for (j = 0; j < pred_order; j++)
|
||||
sum += (int64_t)coeffs[j] * decoded[i-j-1];
|
||||
decoded[i] += sum >> qlevel;
|
||||
}
|
||||
} else {
|
||||
for (i = pred_order; i < s->blocksize-1; i += 2) {
|
||||
int c;
|
||||
int d = decoded[i-pred_order];
|
||||
int s0 = 0, s1 = 0;
|
||||
for (j = pred_order-1; j > 0; j--) {
|
||||
c = coeffs[j];
|
||||
s0 += c*d;
|
||||
d = decoded[i-j];
|
||||
s1 += c*d;
|
||||
}
|
||||
c = coeffs[0];
|
||||
s0 += c*d;
|
||||
d = decoded[i] += s0 >> qlevel;
|
||||
s1 += c*d;
|
||||
decoded[i+1] += s1 >> qlevel;
|
||||
}
|
||||
if (i < s->blocksize) {
|
||||
int sum = 0;
|
||||
for (j = 0; j < pred_order; j++)
|
||||
sum += coeffs[j] * decoded[i-j-1];
|
||||
decoded[i] += sum >> qlevel;
|
||||
}
|
||||
}
|
||||
s->dsp.lpc(decoded, coeffs, pred_order, qlevel, s->blocksize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,49 @@
|
|||
#define SAMPLE_SIZE 32
|
||||
#include "flacdsp_template.c"
|
||||
|
||||
static void flac_lpc_16_c(int32_t *decoded, const int coeffs[32],
|
||||
int pred_order, int qlevel, int len)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = pred_order; i < len - 1; i += 2) {
|
||||
int c;
|
||||
int d = decoded[i-pred_order];
|
||||
int s0 = 0, s1 = 0;
|
||||
for (j = pred_order-1; j > 0; j--) {
|
||||
c = coeffs[j];
|
||||
s0 += c*d;
|
||||
d = decoded[i-j];
|
||||
s1 += c*d;
|
||||
}
|
||||
c = coeffs[0];
|
||||
s0 += c*d;
|
||||
d = decoded[i] += s0 >> qlevel;
|
||||
s1 += c*d;
|
||||
decoded[i+1] += s1 >> qlevel;
|
||||
}
|
||||
if (i < len) {
|
||||
int sum = 0;
|
||||
for (j = 0; j < pred_order; j++)
|
||||
sum += coeffs[j] * decoded[i-j-1];
|
||||
decoded[i] += sum >> qlevel;
|
||||
}
|
||||
}
|
||||
|
||||
static void flac_lpc_32_c(int32_t *decoded, const int coeffs[32],
|
||||
int pred_order, int qlevel, int len)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = pred_order; i < len; i++) {
|
||||
int64_t sum = 0;
|
||||
for (j = 0; j < pred_order; j++)
|
||||
sum += (int64_t)coeffs[j] * decoded[i-j-1];
|
||||
decoded[i] += sum >> qlevel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt)
|
||||
{
|
||||
switch (fmt) {
|
||||
|
@ -37,6 +80,7 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt)
|
|||
c->decorrelate[1] = flac_decorrelate_ls_c_32;
|
||||
c->decorrelate[2] = flac_decorrelate_rs_c_32;
|
||||
c->decorrelate[3] = flac_decorrelate_ms_c_32;
|
||||
c->lpc = flac_lpc_32_c;
|
||||
break;
|
||||
|
||||
case AV_SAMPLE_FMT_S16:
|
||||
|
@ -44,6 +88,7 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt)
|
|||
c->decorrelate[1] = flac_decorrelate_ls_c_16;
|
||||
c->decorrelate[2] = flac_decorrelate_rs_c_16;
|
||||
c->decorrelate[3] = flac_decorrelate_ms_c_16;
|
||||
c->lpc = flac_lpc_16_c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
typedef struct FLACDSPContext {
|
||||
void (*decorrelate[4])(uint8_t **out, int32_t **in, int channels,
|
||||
int len, int shift);
|
||||
void (*lpc)(int32_t *samples, const int coeffs[32], int order,
|
||||
int qlevel, int len);
|
||||
} FLACDSPContext;
|
||||
|
||||
void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt);
|
||||
|
|
Loading…
Reference in New Issue