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

Function imc_decode_init

libavcodec/imc.c:188–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188static av_cold int imc_decode_init(AVCodecContext *avctx)
189{
190 int i, j, ret;
191 IMCContext *q = avctx->priv_data;
192 static AVOnce init_static_once = AV_ONCE_INIT;
193 float scale = 1.0f / (16384);
194
195 if (avctx->codec_id == AV_CODEC_ID_IAC && avctx->sample_rate > 96000) {
196 av_log(avctx, AV_LOG_ERROR,
197 "Strange sample rate of %i, file likely corrupt or "
198 "needing a new table derivation method.\n",
199 avctx->sample_rate);
200 return AVERROR_PATCHWELCOME;
201 }
202
203 if (avctx->codec_id == AV_CODEC_ID_IMC) {
204 av_channel_layout_uninit(&avctx->ch_layout);
205 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
206 }
207
208 if (avctx->ch_layout.nb_channels > 2) {
209 avpriv_request_sample(avctx, "Number of channels > 2");
210 return AVERROR_PATCHWELCOME;
211 }
212
213 for (j = 0; j < avctx->ch_layout.nb_channels; j++) {
214 q->chctx[j].decoder_reset = 1;
215
216 for (i = 0; i < BANDS; i++)
217 q->chctx[j].old_floor[i] = 1.0;
218 }
219
220 /* Build mdct window, a simple sine window normalized with sqrt(2) */
221 ff_sine_window_init(q->mdct_sine_window, COEFFS);
222 for (i = 0; i < COEFFS; i++)
223 q->mdct_sine_window[i] *= sqrt(2.0);
224
225 /* Generate a square root table */
226 for (i = 0; i < 30; i++)
227 q->sqrt_tab[i] = sqrt(i);
228
229 if (avctx->codec_id == AV_CODEC_ID_IAC) {
230 iac_generate_tabs(q, avctx->sample_rate);
231 } else {
232 memcpy(q->cyclTab, cyclTab, sizeof(cyclTab));
233 memcpy(q->cyclTab2, cyclTab2, sizeof(cyclTab2));
234 memcpy(q->weights1, imc_weights1, sizeof(imc_weights1));
235 memcpy(q->weights2, imc_weights2, sizeof(imc_weights2));
236 }
237
238 q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
239 if (!q->fdsp)
240 return AVERROR(ENOMEM);
241
242 ret = av_tx_init(&q->mdct, &q->mdct_fn, AV_TX_FLOAT_MDCT, 1, COEFFS, &scale, 0);
243 if (ret < 0)
244 return ret;
245

Callers

nothing calls this directly

Calls 9

av_logFunction · 0.85
av_channel_layout_uninitFunction · 0.85
avpriv_request_sampleFunction · 0.85
ff_sine_window_initFunction · 0.85
iac_generate_tabsFunction · 0.85
avpriv_float_dsp_allocFunction · 0.85
av_tx_initFunction · 0.85
ff_bswapdsp_initFunction · 0.85
ff_thread_onceFunction · 0.85

Tested by

no test coverage detected