Signed-off-by: Peter Meerwald <[email protected]>
---
libavcodec/Makefile | 4 ++--
libavcodec/g722.c | 22 ----------------------
libavcodec/g722.h | 5 +++--
libavcodec/g722dec.c | 4 +++-
libavcodec/g722dsp.c | 27 +++++++++++++++++++++++++++
libavcodec/g722dsp.h | 30 ++++++++++++++++++++++++++++++
libavcodec/g722enc.c | 4 +++-
7 files changed, 68 insertions(+), 28 deletions(-)
create mode 100644 libavcodec/g722dsp.c
create mode 100644 libavcodec/g722dsp.h
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8c0c345..6038804 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -511,8 +511,8 @@ OBJS-$(CONFIG_ADPCM_EA_R1_DECODER) += adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_EA_R2_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_EA_R3_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_EA_XAS_DECODER) += adpcm.o adpcm_data.o
-OBJS-$(CONFIG_ADPCM_G722_DECODER) += g722.o g722dec.o
-OBJS-$(CONFIG_ADPCM_G722_ENCODER) += g722.o g722enc.o
+OBJS-$(CONFIG_ADPCM_G722_DECODER) += g722.o g722dsp.o g722dec.o
+OBJS-$(CONFIG_ADPCM_G722_ENCODER) += g722.o g722dsp.o g722enc.o
OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o
OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o adpcm_data.o
diff --git a/libavcodec/g722.c b/libavcodec/g722.c
index a911bc7..74c0868 100644
--- a/libavcodec/g722.c
+++ b/libavcodec/g722.c
@@ -72,16 +72,6 @@ const int16_t ff_g722_low_inv_quant6[64] = {
};
/**
- * quadrature mirror filter (QMF) coefficients
- *
- * ITU-T G.722 Table 11
- */
-static const int16_t qmf_coeffs[12] = {
- 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11,
-};
-
-
-/**
* adaptive predictor
*
* @param cur_diff the dequantized and scaled delta calculated from the
@@ -157,15 +147,3 @@ void ff_g722_update_high_predictor(struct G722Band *band,
const int dhigh,
high_log_factor_step[ihigh&1], 0, 22528);
band->scale_factor = linear_scale_factor(band->log_factor - (10 << 11));
}
-
-void ff_g722_apply_qmf(const int16_t *prev_samples, int *xout1, int *xout2)
-{
- int i;
-
- *xout1 = 0;
- *xout2 = 0;
- for (i = 0; i < 12; i++) {
- MAC16(*xout2, prev_samples[2*i ], qmf_coeffs[i ]);
- MAC16(*xout1, prev_samples[2*i+1], qmf_coeffs[11-i]);
- }
-}
diff --git a/libavcodec/g722.h b/libavcodec/g722.h
index 71d03fc..4830170 100644
--- a/libavcodec/g722.h
+++ b/libavcodec/g722.h
@@ -27,6 +27,7 @@
#include <stdint.h>
#include "avcodec.h"
+#include "g722dsp.h"
#define PREV_SAMPLES_BUF_SIZE 1024
@@ -61,6 +62,8 @@ typedef struct G722Context {
int value;
int prev;
} *paths[2];
+
+ G722DSPContext dsp;
} G722Context;
extern const int16_t ff_g722_high_inv_quant[4];
@@ -72,6 +75,4 @@ void ff_g722_update_low_predictor(struct G722Band *band,
const int ilow);
void ff_g722_update_high_predictor(struct G722Band *band, const int dhigh,
const int ihigh);
-void ff_g722_apply_qmf(const int16_t *prev_samples, int *xout1, int *xout2);
-
#endif /* AVCODEC_G722_H */
diff --git a/libavcodec/g722dec.c b/libavcodec/g722dec.c
index 26f288b..6e14b68 100644
--- a/libavcodec/g722dec.c
+++ b/libavcodec/g722dec.c
@@ -67,6 +67,8 @@ static av_cold int g722_decode_init(AVCodecContext * avctx)
c->band[1].scale_factor = 2;
c->prev_samples_pos = 22;
+ ff_g722dsp_init(&c->dsp);
+
return 0;
}
@@ -122,7 +124,7 @@ static int g722_decode_frame(AVCodecContext *avctx, void
*data,
c->prev_samples[c->prev_samples_pos++] = rlow + rhigh;
c->prev_samples[c->prev_samples_pos++] = rlow - rhigh;
- ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24,
+ c->dsp.apply_qmf(c->prev_samples + c->prev_samples_pos - 24,
&xout1, &xout2);
*out_buf++ = av_clip_int16(xout1 >> 11);
*out_buf++ = av_clip_int16(xout2 >> 11);
diff --git a/libavcodec/g722dsp.c b/libavcodec/g722dsp.c
new file mode 100644
index 0000000..4041141
--- /dev/null
+++ b/libavcodec/g722dsp.c
@@ -0,0 +1,27 @@
+#include "g722dsp.h"
+#include "mathops.h"
+
+/**
+ * quadrature mirror filter (QMF) coefficients
+ *
+ * ITU-T G.722 Table 11
+ */
+static const int16_t qmf_coeffs[12] = {
+ 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11,
+};
+
+static void g722_apply_qmf(const int16_t *prev_samples, int *xout1, int *xout2)
+{
+ int i;
+
+ *xout1 = 0;
+ *xout2 = 0;
+ for (i = 0; i < 12; i++) {
+ MAC16(*xout2, prev_samples[2*i ], qmf_coeffs[i ]);
+ MAC16(*xout1, prev_samples[2*i+1], qmf_coeffs[11-i]);
+ }
+}
+
+void ff_g722dsp_init(struct G722DSPContext *c) {