[FFmpeg-cvslog] g723.1dec: Make postfilter user switchable
Michael Niedermayer
git at videolan.org
Mon Jul 23 03:57:47 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Jul 23 03:48:10 2012 +0200| [62514ca012c8b0d30c291fc6e58c0de7b452cd89] | committer: Michael Niedermayer
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 at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62514ca012c8b0d30c291fc6e58c0de7b452cd89
---
libavcodec/g723_1.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c
index 5f115cf..c7f6ac9 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
More information about the ffmpeg-cvslog
mailing list