Home | History | Annotate | Download | only in celt

Lines Matching refs:mode

166 static void compute_allocation_table(CELTMode *mode)
172 mode->nbAllocVectors = BITALLOC_SIZE;
173 allocVectors = opus_alloc(sizeof(unsigned char)*(BITALLOC_SIZE*mode->nbEBands));
177 /* Check for standard mode */
178 if (mode->Fs == 400*(opus_int32)mode->shortMdctSize)
180 for (i=0;i<BITALLOC_SIZE*mode->nbEBands;i++)
182 mode->allocVectors = allocVectors;
185 /* If not the standard mode, interpolate */
189 for (j=0;j<mode->nbEBands;j++)
194 if (400*(opus_int32)eband5ms[k] > mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize)
198 allocVectors[i*mode->nbEBands+j] = band_allocation[i*maxBands + maxBands-1];
201 a1 = mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize - 400*(opus_int32)eband5ms[k-1];
202 a0 = 400*(opus_int32)eband5ms[k] - mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize;
203 allocVectors[i*mode->nbEBands+j] = (a0*band_allocation[i*maxBands+k-1]
212 for (j=0;j<mode->nbEBands;j++)
213 printf ("%d ", allocVectors[i*mode->nbEBands+j]);
218 mode->allocVectors = allocVectors;
227 CELTMode *mode=NULL;
306 mode = opus_alloc(sizeof(CELTMode));
307 if (mode==NULL)
309 mode->Fs = Fs;
316 mode->preemph[0] = QCONST16(0.3500061035f, 15);
317 mode->preemph[1] = -QCONST16(0.1799926758f, 15);
318 mode->preemph[2] = QCONST16(0.2719968125f, SIG_SHIFT); /* exact 1/preemph[3] */
319 mode->preemph[3] = QCONST16(3.6765136719f, 13);
322 mode->preemph[0] = QCONST16(0.6000061035f, 15);
323 mode->preemph[1] = -QCONST16(0.1799926758f, 15);
324 mode->preemph[2] = QCONST16(0.4424998650f, SIG_SHIFT); /* exact 1/preemph[3] */
325 mode->preemph[3] = QCONST16(2.2598876953f, 13);
328 mode->preemph[0] = QCONST16(0.7799987793f, 15);
329 mode->preemph[1] = -QCONST16(0.1000061035f, 15);
330 mode->preemph[2] = QCONST16(0.7499771125f, SIG_SHIFT); /* exact 1/preemph[3] */
331 mode->preemph[3] = QCONST16(1.3333740234f, 13);
334 mode->preemph[0] = QCONST16(0.8500061035f, 15);
335 mode->preemph[1] = QCONST16(0.0f, 15);
336 mode->preemph[2] = QCONST16(1.f, SIG_SHIFT);
337 mode->preemph[3] = QCONST16(1.f, 13);
340 mode->maxLM = LM;
341 mode->nbShortMdcts = 1<<LM;
342 mode->shortMdctSize = frame_size/mode->nbShortMdcts;
343 res = (mode->Fs+mode->shortMdctSize)/(2*mode->shortMdctSize);
345 mode->eBands = compute_ebands(Fs, mode->shortMdctSize, res, &mode->nbEBands);
346 if (mode->eBands==NULL)
351 if ((mode->eBands[mode->nbEBands] - mode->eBands[mode->nbEBands-1])<<LM >
357 mode->effEBands = mode->nbEBands;
358 while (mode->eBands[mode->effEBands] > mode->shortMdctSize)
359 mode->effEBands--;
362 mode->overlap = ((mode->shortMdctSize>>2)<<2);
364 compute_allocation_table(mode);
365 if (mode->allocVectors==NULL)
368 window = (opus_val16*)opus_alloc(mode->overlap*sizeof(opus_val16));
373 for (i=0;i<mode->overlap;i++)
374 window[i] = Q15ONE*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap));
376 for (i=0;i<mode->overlap;i++)
377 window[i] = MIN32(32767,floor(.5+32768.*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap))));
379 mode->window = window;
381 logN = (opus_int16*)opus_alloc(mode->nbEBands*sizeof(opus_int16));
385 for (i=0;i<mode->nbEBands;i++)
386 logN[i] = log2_frac(mode->eBands[i+1]-mode->eBands[i], BITRES);
387 mode->logN = logN;
389 compute_pulse_cache(mode, mode->maxLM);
391 if (clt_mdct_init(&mode->mdct, 2*mode->shortMdctSize*mode->nbShortMdcts,
392 mode->maxLM) == 0)
398 return mode;
402 if (mode!=NULL)
403 opus_custom_mode_destroy(mode);
409 void opus_custom_mode_destroy(CELTMode *mode)
411 if (mode == NULL)
418 if (mode == static_mode_list[i])
425 opus_free((opus_int16*)mode->eBands);
426 opus_free((opus_int16*)mode->allocVectors);
428 opus_free((opus_val16*)mode->window);
429 opus_free((opus_int16*)mode->logN);
431 opus_free((opus_int16*)mode->cache.index);
432 opus_free((unsigned char*)mode->cache.bits);
433 opus_free((unsigned char*)mode->cache.caps);
434 clt_mdct_clear(&mode->mdct);
436 opus_free((CELTMode *)mode);