MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / encode_init

Function encode_init

libavcodec/nellymoserenc.c:170–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170static av_cold int encode_init(AVCodecContext *avctx)
171{
172 static AVOnce init_static_once = AV_ONCE_INIT;
173 NellyMoserEncodeContext *s = avctx->priv_data;
174 float scale = 32768.0;
175 int ret;
176
177 if (avctx->sample_rate != 8000 && avctx->sample_rate != 16000 &&
178 avctx->sample_rate != 11025 &&
179 avctx->sample_rate != 22050 && avctx->sample_rate != 44100 &&
180 avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
181 av_log(avctx, AV_LOG_ERROR, "Nellymoser works only with 8000, 16000, 11025, 22050 and 44100 sample rate\n");
182 return AVERROR(EINVAL);
183 }
184
185 avctx->frame_size = NELLY_SAMPLES;
186 avctx->initial_padding = NELLY_BUF_LEN;
187 ff_af_queue_init(avctx, &s->afq);
188 s->avctx = avctx;
189 if ((ret = av_tx_init(&s->mdct_ctx, &s->mdct_fn, AV_TX_FLOAT_MDCT, 0, 128, &scale, 0)) < 0)
190 return ret;
191 s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
192 if (!s->fdsp)
193 return AVERROR(ENOMEM);
194
195 if (s->avctx->trellis) {
196 s->opt = av_malloc(NELLY_BANDS * OPT_SIZE * sizeof(float ));
197 s->path = av_malloc(NELLY_BANDS * OPT_SIZE * sizeof(uint8_t));
198 if (!s->opt || !s->path)
199 return AVERROR(ENOMEM);
200 }
201
202 ff_thread_once(&init_static_once, nellymoser_init_static);
203
204 return 0;
205}
206
207#define find_best(val, table, LUT, LUT_add, LUT_size) \
208 best_idx = \

Callers

nothing calls this directly

Calls 6

av_logFunction · 0.85
ff_af_queue_initFunction · 0.85
av_tx_initFunction · 0.85
avpriv_float_dsp_allocFunction · 0.85
ff_thread_onceFunction · 0.85
av_mallocFunction · 0.50

Tested by

no test coverage detected