internal int opus_multistream_decoder_init( int Fs, int channels, int streams, int coupled_streams, byte[] mapping ) { int i, ret; int decoder_ptr = 0; if ((channels > 255) || (channels < 1) || (coupled_streams > streams) || (streams < 1) || (coupled_streams < 0) || (streams > 255 - coupled_streams)) { throw new ArgumentException("Invalid channel or coupled stream count"); } this.layout.nb_channels = channels; this.layout.nb_streams = streams; this.layout.nb_coupled_streams = coupled_streams; for (i = 0; i < this.layout.nb_channels; i++) { this.layout.mapping[i] = mapping[i]; } if (OpusMultistream.validate_layout(this.layout) == 0) { throw new ArgumentException("Invalid surround channel layout"); } for (i = 0; i < this.layout.nb_coupled_streams; i++) { ret = this.decoders[decoder_ptr].opus_decoder_init(Fs, 2); if (ret != OpusError.OPUS_OK) { return(ret); } decoder_ptr++; } for (; i < this.layout.nb_streams; i++) { ret = this.decoders[decoder_ptr].opus_decoder_init(Fs, 1); if (ret != OpusError.OPUS_OK) { return(ret); } decoder_ptr++; } return(OpusError.OPUS_OK); }
internal int opus_multistream_encoder_init( int Fs, int channels, int streams, int coupled_streams, byte[] mapping, OpusApplication application, int surround ) { int i, ret; int encoder_ptr; if ((channels > 255) || (channels < 1) || (coupled_streams > streams) || (streams < 1) || (coupled_streams < 0) || (streams > 255 - coupled_streams)) { return(OpusError.OPUS_BAD_ARG); } this.layout.nb_channels = channels; this.layout.nb_streams = streams; this.layout.nb_coupled_streams = coupled_streams; this.subframe_mem[0] = this.subframe_mem[1] = this.subframe_mem[2] = 0; if (surround == 0) { this.lfe_stream = -1; } this.bitrate_bps = OpusConstants.OPUS_AUTO; this.application = application; this.variable_duration = OpusFramesize.OPUS_FRAMESIZE_ARG; for (i = 0; i < this.layout.nb_channels; i++) { this.layout.mapping[i] = mapping[i]; } if (OpusMultistream.validate_layout(this.layout) == 0 || validate_encoder_layout(this.layout) == 0) { return(OpusError.OPUS_BAD_ARG); } encoder_ptr = 0; for (i = 0; i < this.layout.nb_coupled_streams; i++) { ret = this.encoders[encoder_ptr].opus_init_encoder(Fs, 2, application); if (ret != OpusError.OPUS_OK) { return(ret); } if (i == this.lfe_stream) { this.encoders[encoder_ptr].IsLFE = true; } encoder_ptr += 1; } for (; i < this.layout.nb_streams; i++) { ret = this.encoders[encoder_ptr].opus_init_encoder(Fs, 1, application); if (i == this.lfe_stream) { this.encoders[encoder_ptr].IsLFE = true; } if (ret != OpusError.OPUS_OK) { return(ret); } encoder_ptr += 1; } if (surround != 0) { Arrays.MemSetInt(this.preemph_mem, 0, channels); Arrays.MemSetInt(this.window_mem, 0, channels * 120); } this.surround = surround; return(OpusError.OPUS_OK); }