[FFmpeg-cvslog] flacdec: move lpc filter to flacdsp
Mans Rullgard
git at videolan.org
Wed Jul 4 21:09:48 CEST 2012
ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Mon Jul 2 13:51:04 2012 +0100| [25accf93ad7b0ad3e2a17718e689c05fbc5b5698] | committer: Mans Rullgard
flacdec: move lpc filter to flacdsp
Signed-off-by: Mans Rullgard <mans at mansr.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=25accf93ad7b0ad3e2a17718e689c05fbc5b5698
---
libavcodec/flacdec.c | 35 ++---------------------------------
libavcodec/flacdsp.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
libavcodec/flacdsp.h | 2 ++
3 files changed, 49 insertions(+), 33 deletions(-)
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index daa5bd8..7295e2e 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -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;
}
diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
index b7e0746..fcee8e4 100644
--- a/libavcodec/flacdsp.c
+++ b/libavcodec/flacdsp.c
@@ -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;
}
}
diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
index bb289ee..fe5ca53 100644
--- a/libavcodec/flacdsp.h
+++ b/libavcodec/flacdsp.h
@@ -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);
More information about the ffmpeg-cvslog
mailing list