summaryrefslogtreecommitdiff
path: root/libavcodec/nellymoserenc.c
diff options
context:
space:
mode:
authorBartlomiej Wolowiec <bartek.wolowiec@gmail.com>2008-08-31 19:26:33 +0000
committerBartlomiej Wolowiec <bartek.wolowiec@gmail.com>2008-08-31 19:26:33 +0000
commit748384a1868c54346a061c413d3eda2eda5191ce (patch)
treeff9f82113017266c3bc0b8e210c40a2882013398 /libavcodec/nellymoserenc.c
parent1cf151e9aeb2ef4a465adbc9e5c2e49b645a66dc (diff)
Okayed parts of nellymoserenc.c
Originally committed as revision 15126 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/nellymoserenc.c')
-rw-r--r--libavcodec/nellymoserenc.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c
index bc01a50e73..428ce7480d 100644
--- a/libavcodec/nellymoserenc.c
+++ b/libavcodec/nellymoserenc.c
@@ -48,6 +48,8 @@
typedef struct NellyMoserEncodeContext {
AVCodecContext *avctx;
int last_frame;
+ DSPContext dsp;
+ MDCTContext mdct_ctx;
} NellyMoserEncodeContext;
static float pow_table[POW_TABLE_SIZE]; ///< -pow(2, -i / 2048.0 - 3.0);
@@ -110,6 +112,13 @@ static av_cold int encode_init(AVCodecContext *avctx)
return -1;
}
+ if (avctx->sample_rate != 8000 && avctx->sample_rate != 11025 &&
+ avctx->sample_rate != 22050 && avctx->sample_rate != 44100 &&
+ avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
+ av_log(avctx, AV_LOG_ERROR, "Nellymoser works only with 8000, 11025, 22050 and 44100 sample rate\n");
+ return -1;
+ }
+
avctx->frame_size = NELLY_SAMPLES;
s->avctx = avctx;
ff_mdct_init(&s->mdct_ctx, 8, 0);
@@ -131,6 +140,12 @@ static av_cold int encode_end(AVCodecContext *avctx)
return 0;
}
+#define find_best(val, table, LUT, LUT_add, LUT_size) \
+ best_idx = \
+ LUT[av_clip ((lrintf(val) >> 8) + LUT_add, 0, LUT_size - 1)]; \
+ if (fabs(val - table[best_idx]) > fabs(val - table[best_idx + 1])) \
+ best_idx++;
+
AVCodec nellymoser_encoder = {
.name = "nellymoser",
.type = CODEC_TYPE_AUDIO,