Home | History | Annotate | Download | only in src

Lines Matching refs:st

96 int opus_decoder_init(OpusDecoder *st, opus_int32 Fs, int channels)
106 OPUS_CLEAR((char*)st, opus_decoder_get_size(channels));
113 st->silk_dec_offset = align(sizeof(OpusDecoder));
114 st->celt_dec_offset = st->silk_dec_offset+silkDecSizeBytes;
115 silk_dec = (char*)st+st->silk_dec_offset;
116 celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset);
117 st->stream_channels = st->channels = channels;
119 st->Fs = Fs;
120 st->DecControl.API_sampleRate = st->Fs;
121 st->DecControl.nChannelsAPI = st->channels;
133 st->prev_mode = 0;
134 st->frame_size = Fs/400;
135 st->arch = opus_select_arch();
142 OpusDecoder *st;
150 st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels));
151 if (st == NULL)
157 ret = opus_decoder_init(st, Fs, channels);
162 opus_free(st);
163 st = NULL;
165 return st;
200 static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
232 silk_dec = (char*)st+st->silk_dec_offset;
233 celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset);
234 F20 = st->Fs/50;
244 frame_size = IMIN(frame_size, st->Fs/25*3);
250 frame_size = IMIN(frame_size, st->frame_size);
254 audiosize = st->frame_size;
255 mode = st->mode;
259 mode = st->prev_mode;
264 for (i=0;i<audiosize*st->channels;i++)
275 int ret = opus_decode_frame(st, NULL, 0, pcm, IMIN(audiosize, F20), 0);
281 pcm += ret*st->channels;
305 if (data!=NULL && st->prev_mode > 0 && (
306 (mode == MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY && !st->prev_redundancy)
307 || (mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY) )
313 pcm_transition_celt_size = F5*st->channels;
315 pcm_transition_silk_size = F5*st->channels;
321 opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0);
333 pcm_silk_size = (mode != MODE_CELT_ONLY && !celt_accum) ? IMAX(F10, frame_size)*st->channels : ALLOC_NONE;
348 if (st->prev_mode==MODE_CELT_ONLY)
352 st->DecControl.payloadSize_ms = IMAX(10, 1000 * audiosize / st->Fs);
356 st->DecControl.nChannelsInternal = st->stream_channels;
358 if( st->bandwidth == OPUS_BANDWIDTH_NARROWBAND ) {
359 st->DecControl.internalSampleRate = 8000;
360 } else if( st->bandwidth == OPUS_BANDWIDTH_MEDIUMBAND ) {
361 st->DecControl.internalSampleRate = 12000;
362 } else if( st->bandwidth == OPUS_BANDWIDTH_WIDEBAND ) {
363 st->DecControl.internalSampleRate = 16000;
365 st->DecControl.internalSampleRate = 16000;
370 st->DecControl.internalSampleRate = 16000;
379 silk_ret = silk_Decode( silk_dec, &st->DecControl,
380 lost_flag, first_frame, &dec, pcm_ptr, &silk_frame_size, st->arch );
385 for (i=0;i<frame_size*st->channels;i++)
392 pcm_ptr += silk_frame_size * st->channels;
399 && ec_tell(&dec)+17+20*(st->mode == MODE_HYBRID) <= 8*len)
433 switch(st->bandwidth)
450 celt_decoder_ctl(celt_dec, CELT_SET_CHANNELS(st->stream_channels));
464 opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0);
468 redundant_audio_size = redundancy ? F5*st->channels : ALLOC_NONE;
487 if (mode != st->prev_mode && st->prev_mode > 0 && !st->prev_redundancy)
496 for (i=0;i<frame_size*st->channels;i++)
501 if (st->prev_mode == MODE_HYBRID && !(redundancy && celt_to_silk && st->prev_redundancy) )
511 for (i=0;i<frame_size*st->channels;i++)
514 for (i=0;i<frame_size*st->channels;i++)
533 smooth_fade(pcm+st->channels*(frame_size-F2_5), redundant_audio+st->channels*F2_5,
534 pcm+st->channels*(frame_size-F2_5), F2_5, st->channels, window, st->Fs);
538 for (c=0;c<st->channels;c++)
541 pcm[st->channels*i+c] = redundant_audio[st->channels*i+c];
543 smooth_fade(redundant_audio+st->channels*F2_5, pcm+st->channels*F2_5,
544 pcm+st->channels*F2_5, F2_5, st->channels, window, st->Fs);
550 for (i=0;i<st->channels*F2_5;i++)
552 smooth_fade(pcm_transition+st->channels*F2_5, pcm+st->channels*F2_5,
553 pcm+st->channels*F2_5, F2_5,
554 st->channels, window, st->Fs);
563 st->channels, window, st->Fs);
567 if(st->decode_gain)
570 gain = celt_exp2(MULT16_16_P15(QCONST16(6.48814081e-4f, 25), st->decode_gain));
571 for (i=0;i<frame_size*st->channels;i++)
580 st->rangeFinal = 0;
582 st->rangeFinal = dec.rng ^ redundant_rng;
584 st->prev_mode = mode;
585 st->prev_redundancy = redundancy && !celt_to_silk;
589 if (OPUS_CHECK_ARRAY(pcm, audiosize*st->channels))
598 int opus_decode_native(OpusDecoder *st, const unsigned char *data,
611 if ((decode_fec || len==0 || data==NULL) && frame_size%(st->Fs/400)!=0)
618 ret = opus_decode_frame(st, NULL, 0, pcm+pcm_count*st->channels, frame_size-pcm_count, 0);
624 if (OPUS_CHECK_ARRAY(pcm, pcm_count*st->channels))
626 st->last_packet_duration = pcm_count;
633 packet_frame_size = opus_packet_get_samples_per_frame(data, st->Fs);
648 if (frame_size < packet_frame_size || packet_mode == MODE_CELT_ONLY || st->mode == MODE_CELT_ONLY)
649 return opus_decode_native(st, NULL, 0, pcm, frame_size, 0, 0, NULL, soft_clip);
651 duration_copy = st->last_packet_duration;
654 ret = opus_decode_native(st, NULL, 0, pcm, frame_size-packet_frame_size, 0, 0, NULL, soft_clip);
657 st->last_packet_duration = duration_copy;
663 st->mode = packet_mode;
664 st->bandwidth = packet_bandwidth;
665 st->frame_size = packet_frame_size;
666 st->stream_channels = packet_stream_channels;
667 ret = opus_decode_frame(st, data, size[0], pcm+st->channels*(frame_size-packet_frame_size),
672 if (OPUS_CHECK_ARRAY(pcm, frame_size*st->channels))
674 st->last_packet_duration = frame_size;
683 st->mode = packet_mode;
684 st->bandwidth = packet_bandwidth;
685 st->frame_size = packet_frame_size;
686 st->stream_channels = packet_stream_channels;
692 ret = opus_decode_frame(st, data, size[i], pcm+nb_samples*st->channels, frame_size-nb_samples, 0);
699 st->last_packet_duration = nb_samples;
700 if (OPUS_CHECK_ARRAY(pcm, nb_samples*st->channels))
704 opus_pcm_soft_clip(pcm, nb_samples, st->channels, st->softclip_mem);
706 st->softclip_mem[0]=st->softclip_mem[1]=0;
713 int opus_decode(OpusDecoder *st, const unsigned char *data,
718 return opus_decode_native(st, data, len, pcm, frame_size, decode_fec, 0, NULL, 0);
722 int opus_decode_float(OpusDecoder *st, const unsigned char *data,
737 nb_samples = opus_decoder_get_nb_samples(st, data, len);
743 ALLOC(out, frame_size*st->channels, opus_int16);
745 ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 0);
748 for (i=0;i<ret*st->channels;i++)
758 int opus_decode(OpusDecoder *st, const unsigned char *data,
774 nb_samples = opus_decoder_get_nb_samples(st, data, len);
780 ALLOC(out, frame_size*st->channels, float);
782 ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 1);
785 for (i=0;i<ret*st->channels;i++)
792 int opus_decode_float(OpusDecoder *st, const unsigned char *data,
797 return opus_decode_native(st, data, len, pcm, frame_size, decode_fec, 0, NULL, 0);
802 int opus_decoder_ctl(OpusDecoder *st, int request, ...)
809 silk_dec = (char*)st+st->silk_dec_offset;
810 celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset);
824 *value = st->bandwidth;
834 *value = st->rangeFinal;
839 OPUS_CLEAR((char*)&st->OPUS_DECODER_RESET_START,
841 ((char*)&st->OPUS_DECODER_RESET_START - (char*)st));
845 st->stream_channels = st->channels;
846 st->frame_size = st->Fs/400;
856 *value = st->Fs;
866 if (st->prev_mode == MODE_CELT_ONLY)
869 *value = st->DecControl.prevPitchLag;
879 *value = st->decode_gain;
889 st->decode_gain = value;
899 *value = st->last_packet_duration;
935 void opus_decoder_destroy(OpusDecoder *st)
937 opus_free(st);