Mercurial > libavcodec.hg
comparison nellymoserenc.c @ 7762:e2573d045e79 libavcodec
Okayed parts of nellymoserenc.c
author | bwolowiec |
---|---|
date | Sun, 31 Aug 2008 19:26:33 +0000 |
parents | 87ec777690c9 |
children | 152573e499c9 |
comparison
equal
deleted
inserted
replaced
7761:94f82ed28dc4 | 7762:e2573d045e79 |
---|---|
46 #define POW_TABLE_OFFSET 3 | 46 #define POW_TABLE_OFFSET 3 |
47 | 47 |
48 typedef struct NellyMoserEncodeContext { | 48 typedef struct NellyMoserEncodeContext { |
49 AVCodecContext *avctx; | 49 AVCodecContext *avctx; |
50 int last_frame; | 50 int last_frame; |
51 DSPContext dsp; | |
52 MDCTContext mdct_ctx; | |
51 } NellyMoserEncodeContext; | 53 } NellyMoserEncodeContext; |
52 | 54 |
53 static float pow_table[POW_TABLE_SIZE]; ///< -pow(2, -i / 2048.0 - 3.0); | 55 static float pow_table[POW_TABLE_SIZE]; ///< -pow(2, -i / 2048.0 - 3.0); |
54 | 56 |
55 static const uint8_t sf_lut[96] = { | 57 static const uint8_t sf_lut[96] = { |
108 if (avctx->channels != 1) { | 110 if (avctx->channels != 1) { |
109 av_log(avctx, AV_LOG_ERROR, "Nellymoser supports only 1 channel\n"); | 111 av_log(avctx, AV_LOG_ERROR, "Nellymoser supports only 1 channel\n"); |
110 return -1; | 112 return -1; |
111 } | 113 } |
112 | 114 |
115 if (avctx->sample_rate != 8000 && avctx->sample_rate != 11025 && | |
116 avctx->sample_rate != 22050 && avctx->sample_rate != 44100 && | |
117 avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL) { | |
118 av_log(avctx, AV_LOG_ERROR, "Nellymoser works only with 8000, 11025, 22050 and 44100 sample rate\n"); | |
119 return -1; | |
120 } | |
121 | |
113 avctx->frame_size = NELLY_SAMPLES; | 122 avctx->frame_size = NELLY_SAMPLES; |
114 s->avctx = avctx; | 123 s->avctx = avctx; |
115 ff_mdct_init(&s->mdct_ctx, 8, 0); | 124 ff_mdct_init(&s->mdct_ctx, 8, 0); |
116 dsputil_init(&s->dsp, avctx); | 125 dsputil_init(&s->dsp, avctx); |
117 | 126 |
129 | 138 |
130 ff_mdct_end(&s->mdct_ctx); | 139 ff_mdct_end(&s->mdct_ctx); |
131 return 0; | 140 return 0; |
132 } | 141 } |
133 | 142 |
143 #define find_best(val, table, LUT, LUT_add, LUT_size) \ | |
144 best_idx = \ | |
145 LUT[av_clip ((lrintf(val) >> 8) + LUT_add, 0, LUT_size - 1)]; \ | |
146 if (fabs(val - table[best_idx]) > fabs(val - table[best_idx + 1])) \ | |
147 best_idx++; | |
148 | |
134 AVCodec nellymoser_encoder = { | 149 AVCodec nellymoser_encoder = { |
135 .name = "nellymoser", | 150 .name = "nellymoser", |
136 .type = CODEC_TYPE_AUDIO, | 151 .type = CODEC_TYPE_AUDIO, |
137 .id = CODEC_ID_NELLYMOSER, | 152 .id = CODEC_ID_NELLYMOSER, |
138 .priv_data_size = sizeof(NellyMoserEncodeContext), | 153 .priv_data_size = sizeof(NellyMoserEncodeContext), |