summaryrefslogtreecommitdiff
path: root/libavcodec/g723_1.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-23 03:48:10 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-23 03:57:04 +0200
commit62514ca012c8b0d30c291fc6e58c0de7b452cd89 (patch)
treef46a47c7e82696af668f620224938863191e900f /libavcodec/g723_1.c
parent1eb1392690fdf51cf2a51a8a8203d9fd48010af8 (diff)
g723.1dec: Make postfilter user switchable
Code from qatar (55c3a4f617171ad1138df684cbafa570807bc6a9) Author of the code was probably Mohamed or Kostya Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/g723_1.c')
-rw-r--r--libavcodec/g723_1.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c
index 5f115cfe36..c7f6ac9301 100644
--- a/libavcodec/g723_1.c
+++ b/libavcodec/g723_1.c
@@ -1041,10 +1041,12 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data,
p->interp_index = comp_interp_index(p, p->pitch_lag[1],
&p->sid_gain, &p->cur_gain);
+ if (p->postfilter) {
i = PITCH_MAX;
for (j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++)
comp_ppf_coeff(p, i, p->pitch_lag[j >> 1],
ppf + j, p->cur_rate);
+ }
/* Restore the original excitation */
memcpy(p->excitation, p->prev_excitation,
@@ -1052,6 +1054,7 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data,
memcpy(vector_ptr, out, FRAME_LEN * sizeof(*vector_ptr));
/* Peform pitch postfiltering */
+ if (p->postfilter)
for (i = 0, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++)
ff_acelp_weighted_vector_sum(out + LPC_ORDER + i,
vector_ptr + i,
@@ -1091,7 +1094,8 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data,
0, 1, 1 << 12);
memcpy(p->synth_mem, out + FRAME_LEN, LPC_ORDER * sizeof(int16_t));
- formant_postfilter(p, lpc, out);
+ if (p->postfilter)
+ formant_postfilter(p, lpc, out);
memmove(out, out + LPC_ORDER, sizeof(int16_t)*FRAME_LEN);
p->frame.nb_samples = FRAME_LEN;
@@ -1101,6 +1105,22 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data,
return frame_size[dec_mode];
}
+#define OFFSET(x) offsetof(G723_1_Context, x)
+#define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+
+static const AVOption options[] = {
+ { "postfilter", "postfilter on/off", OFFSET(postfilter), AV_OPT_TYPE_INT,
+ { 1 }, 0, 1, AD },
+ { NULL }
+};
+
+static const AVClass g723_1dec_class = {
+ .class_name = "G.723.1 decoder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_g723_1_decoder = {
.name = "g723_1",
.type = AVMEDIA_TYPE_AUDIO,
@@ -1110,6 +1130,7 @@ AVCodec ff_g723_1_decoder = {
.decode = g723_1_decode_frame,
.long_name = NULL_IF_CONFIG_SMALL("G.723.1"),
.capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
+ .priv_class = &g723_1dec_class,
};
#if CONFIG_G723_1_ENCODER