Lines Matching defs:st
101 int opus_decoder_init(OpusDecoder *st, opus_int32 Fs, int channels)
111 OPUS_CLEAR((char*)st, opus_decoder_get_size(channels));
118 st->silk_dec_offset = align(sizeof(OpusDecoder));
119 st->celt_dec_offset = st->silk_dec_offset+silkDecSizeBytes;
120 silk_dec = (char*)st+st->silk_dec_offset;
121 celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset);
122 st->stream_channels = st->channels = channels;
124 st->Fs = Fs;
125 st->DecControl.API_sampleRate = st->Fs;
126 st->DecControl.nChannelsAPI = st->channels;
138 st->prev_mode = 0;
139 st->frame_size = Fs/400;
146 OpusDecoder *st;
154 st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels));
155 if (st == NULL)
161 ret = opus_decoder_init(st, Fs, channels);
166 opus_free(st);
167 st = NULL;
169 return st;
204 static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
235 silk_dec = (char*)st+st->silk_dec_offset;
236 celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset);
237 F20 = st->Fs/50;
247 frame_size = IMIN(frame_size, st->Fs/25*3);
253 frame_size = IMIN(frame_size, st->frame_size);
257 audiosize = st->frame_size;
258 mode = st->mode;
262 mode = st->prev_mode;
267 for (i=0;i<audiosize*st->channels;i++)
278 int ret = opus_decode_frame(st, NULL, 0, pcm, IMIN(audiosize, F20), 0);
284 pcm += ret*st->channels;
300 if (data!=NULL && st->prev_mode > 0 && (
301 (mode == MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY && !st->prev_redundancy)
302 || (mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY) )
308 pcm_transition_celt_size = F5*st->channels;
310 pcm_transition_silk_size = F5*st->channels;
316 opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0);
328 pcm_silk_size = (mode != MODE_CELT_ONLY) ? IMAX(F10, frame_size)*st->channels : ALLOC_NONE;
337 if (st->prev_mode==MODE_CELT_ONLY)
341 st->DecControl.payloadSize_ms = IMAX(10, 1000 * audiosize / st->Fs);
345 st->DecControl.nChannelsInternal = st->stream_channels;
347 if( st->bandwidth == OPUS_BANDWIDTH_NARROWBAND ) {
348 st->DecControl.internalSampleRate = 8000;
349 } else if( st->bandwidth == OPUS_BANDWIDTH_MEDIUMBAND ) {
350 st->DecControl.internalSampleRate = 12000;
351 } else if( st->bandwidth == OPUS_BANDWIDTH_WIDEBAND ) {
352 st->DecControl.internalSampleRate = 16000;
354 st->DecControl.internalSampleRate = 16000;
359 st->DecControl.internalSampleRate = 16000;
368 silk_ret = silk_Decode( silk_dec, &st->DecControl,
374 for (i=0;i<frame_size*st->channels;i++)
381 pcm_ptr += silk_frame_size * st->channels;
388 && ec_tell(&dec)+17+20*(st->mode == MODE_HYBRID) <= 8*len)
422 switch(st->bandwidth)
439 celt_decoder_ctl(celt_dec, CELT_SET_CHANNELS(st->stream_channels));
453 opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0);
457 redundant_audio_size = redundancy ? F5*st->channels : ALLOC_NONE;
476 if (mode != st->prev_mode && st->prev_mode > 0 && !st->prev_redundancy)
483 for (i=0;i<frame_size*st->channels;i++)
487 if (st->prev_mode == MODE_HYBRID && !(redundancy && celt_to_silk && st->prev_redundancy) )
497 for (i=0;i<frame_size*st->channels;i++)
500 for (i=0;i<frame_size*st->channels;i++)
519 smooth_fade(pcm+st->channels*(frame_size-F2_5), redundant_audio+st->channels*F2_5,
520 pcm+st->channels*(frame_size-F2_5), F2_5, st->channels, window, st->Fs);
524 st->channels;c++)
527 pcm[st->channels*i+c] = redundant_audio[st->channels*i+c];
529 smooth_fade(redundant_audio+st->channels*F2_5, pcm+st->channels*F2_5,
530 pcm+st->channels*F2_5, F2_5, st->channels, window, st->Fs);
536 for (i=0;i<st->channels*F2_5;i++)
538 smooth_fade(pcm_transition+st->channels*F2_5, pcm+st->channels*F2_5,
539 pcm+st->channels*F2_5, F2_5,
540 st->channels, window, st->Fs);
549 st->channels, window, st->Fs);
553 if(st->decode_gain)
556 gain = celt_exp2(MULT16_16_P15(QCONST16(6.48814081e-4f, 25), st->decode_gain));
557 for (i=0;i<frame_size*st->channels;i++)
566 st->rangeFinal = 0;
568 st->rangeFinal = dec.rng ^ redundant_rng;
570 st->prev_mode = mode;
571 st->prev_redundancy = redundancy && !celt_to_silk;
575 if (OPUS_CHECK_ARRAY(pcm, audiosize*st->channels))
584 int opus_decode_native(OpusDecoder *st, const unsigned char *data,
597 if ((decode_fec || len==0 || data==NULL) && frame_size%(st->Fs/400)!=0)
604 ret = opus_decode_frame(st, NULL, 0, pcm+pcm_count*st->channels, frame_size-pcm_count, 0);
610 if (OPUS_CHECK_ARRAY(pcm, pcm_count*st->channels))
612 st->last_packet_duration = pcm_count;
619 packet_frame_size = opus_packet_get_samples_per_frame(data, st->Fs);
634 if (frame_size < packet_frame_size || packet_mode == MODE_CELT_ONLY || st->mode == MODE_CELT_ONLY)
635 return opus_decode_native(st, NULL, 0, pcm, frame_size, 0, 0, NULL, soft_clip);
637 duration_copy = st->last_packet_duration;
640 ret = opus_decode_native(st, NULL, 0, pcm, frame_size-packet_frame_size, 0, 0, NULL, soft_clip);
643 st->last_packet_duration = duration_copy;
649 st->mode = packet_mode;
650 st->bandwidth = packet_bandwidth;
651 st->frame_size = packet_frame_size;
652 st->stream_channels = packet_stream_channels;
653 ret = opus_decode_frame(st, data, size[0], pcm+st->channels*(frame_size-packet_frame_size),
658 if (OPUS_CHECK_ARRAY(pcm, frame_size*st->channels))
660 st->last_packet_duration = frame_size;
669 st->mode = packet_mode;
670 st->bandwidth = packet_bandwidth;
671 st->frame_size = packet_frame_size;
672 st->stream_channels = packet_stream_channels;
678 ret = opus_decode_frame(st, data, size[i], pcm+nb_samples*st->channels, frame_size-nb_samples, 0);
685 st->last_packet_duration = nb_samples;
686 if (OPUS_CHECK_ARRAY(pcm, nb_samples*st->channels))
690 opus_pcm_soft_clip(pcm, nb_samples, st->channels, st->softclip_mem);
692 st->softclip_mem[0]=st->softclip_mem[1]=0;
699 int opus_decode(OpusDecoder *st, const unsigned char *data,
704 return opus_decode_native(st, data, len, pcm, frame_size, decode_fec, 0, NULL, 0);
708 int opus_decode_float(OpusDecoder *st, const unsigned char *data,
720 ALLOC(out, frame_size*st->channels, opus_int16);
722 ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 0);
725 for (i=0;i<ret*st->channels;i++)
735 int opus_decode(OpusDecoder *st, const unsigned char *data,
748 ALLOC(out, frame_size*st->channels, float);
750 ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 1);
753 for (i=0;i<ret*st->channels;i++)
760 int opus_decode_float(OpusDecoder *st, const unsigned char *data,
765 return opus_decode_native(st, data, len, pcm, frame_size, decode_fec, 0, NULL, 0);
770 int opus_decoder_ctl(OpusDecoder *st, int request, ...)
777 silk_dec = (char*)st+st->silk_dec_offset;
778 celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset);
792 *value = st->bandwidth;
802 *value = st->rangeFinal;
807 OPUS_CLEAR((char*)&st->OPUS_DECODER_RESET_START,
809 ((char*)&st->OPUS_DECODER_RESET_START - (char*)st));
813 st->stream_channels = st->channels;
814 st->frame_size = st->Fs/400;
824 *value = st->Fs;
834 if (st->prev_mode == MODE_CELT_ONLY)
837 *value = st->DecControl.prevPitchLag;
847 *value = st->decode_gain;
857 st->decode_gain = value;
867 *value = st->last_packet_duration;
883 void opus_decoder_destroy(OpusDecoder *st)
885 opus_free(st);