1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
use crate::externs::{free, malloc};

#[derive(Copy, Clone)]
#[repr(C)]
pub struct OpusMSDecoder {
    pub layout: ChannelLayout,
}

pub type opus_copy_channel_out_func = Option<
    unsafe fn(
        *mut core::ffi::c_void,
        i32,
        i32,
        *const opus_val16,
        i32,
        i32,
        *mut core::ffi::c_void,
    ) -> (),
>;

pub mod arch_h {
    pub type opus_val16 = f32;
}
pub mod stddef_h {
    pub type size_t = u64;
    pub const NULL: i32 = 0 as i32;
}
pub mod xmmintrin_h {
    #[cfg(target_arch = "x86")]
    pub use core::arch::x86::{__m128, _mm_cvt_ss2si, _mm_cvtss_si32, _mm_set_ss};
    #[cfg(target_arch = "x86_64")]
    pub use core::arch::x86_64::{__m128, _mm_cvt_ss2si, _mm_cvtss_si32, _mm_set_ss};
}
use self::arch_h::opus_val16;
pub use self::stddef_h::{size_t, NULL};
use crate::celt::celt::celt_fatal;
use crate::celt::float_cast::FLOAT2INT16;
use crate::src::opus::opus_packet_parse_impl;
use crate::src::opus_decoder::opus_decode_native;
use crate::src::opus_defines::{
    OPUS_ALLOC_FAIL, OPUS_BAD_ARG, OPUS_BUFFER_TOO_SMALL, OPUS_GET_BANDWIDTH_REQUEST,
    OPUS_GET_FINAL_RANGE_REQUEST, OPUS_GET_GAIN_REQUEST, OPUS_GET_LAST_PACKET_DURATION_REQUEST,
    OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, OPUS_GET_SAMPLE_RATE_REQUEST, OPUS_INTERNAL_ERROR,
    OPUS_INVALID_PACKET, OPUS_OK, OPUS_RESET_STATE, OPUS_SET_GAIN_REQUEST,
    OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, OPUS_UNIMPLEMENTED,
};
use crate::src::opus_multistream::{
    get_left_channel, get_mono_channel, get_right_channel, validate_layout, ChannelLayout,
};
use crate::src::opus_private::align;
use crate::varargs::VarArgs;
use crate::{
    opus_decoder_ctl, opus_decoder_get_size, opus_decoder_init, opus_multistream_decoder_ctl,
    opus_packet_get_nb_samples, OpusDecoder,
};

pub const OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST: i32 = 5122;

unsafe fn validate_ms_decoder(st: *mut OpusMSDecoder) {
    validate_layout(&mut (*st).layout);
}
pub unsafe fn opus_multistream_decoder_get_size(nb_streams: i32, nb_coupled_streams: i32) -> i32 {
    let mut coupled_size: i32 = 0;
    let mut mono_size: i32 = 0;
    if nb_streams < 1 as i32 || nb_coupled_streams > nb_streams || nb_coupled_streams < 0 as i32 {
        return 0 as i32;
    }
    coupled_size = opus_decoder_get_size(2 as i32);
    mono_size = opus_decoder_get_size(1 as i32);
    return align(::core::mem::size_of::<OpusMSDecoder>() as u64 as i32)
        + nb_coupled_streams * align(coupled_size)
        + (nb_streams - nb_coupled_streams) * align(mono_size);
}
pub unsafe fn opus_multistream_decoder_init(
    mut st: *mut OpusMSDecoder,
    Fs: i32,
    channels: i32,
    streams: i32,
    coupled_streams: i32,
    mapping: *const u8,
) -> i32 {
    let mut coupled_size: i32 = 0;
    let mut mono_size: i32 = 0;
    let mut i: i32 = 0;
    let mut ret: i32 = 0;
    let mut ptr: *mut i8 = 0 as *mut i8;
    if channels > 255 as i32
        || channels < 1 as i32
        || coupled_streams > streams
        || streams < 1 as i32
        || coupled_streams < 0 as i32
        || streams > 255 as i32 - coupled_streams
    {
        return OPUS_BAD_ARG;
    }
    (*st).layout.nb_channels = channels;
    (*st).layout.nb_streams = streams;
    (*st).layout.nb_coupled_streams = coupled_streams;
    i = 0 as i32;
    while i < (*st).layout.nb_channels {
        (*st).layout.mapping[i as usize] = *mapping.offset(i as isize);
        i += 1;
    }
    if validate_layout(&mut (*st).layout) == 0 {
        return OPUS_BAD_ARG;
    }
    ptr = (st as *mut i8)
        .offset(align(::core::mem::size_of::<OpusMSDecoder>() as u64 as i32) as isize);
    coupled_size = opus_decoder_get_size(2 as i32);
    mono_size = opus_decoder_get_size(1 as i32);
    i = 0 as i32;
    while i < (*st).layout.nb_coupled_streams {
        ret = opus_decoder_init(ptr as *mut OpusDecoder, Fs, 2 as i32);
        if ret != OPUS_OK {
            return ret;
        }
        ptr = ptr.offset(align(coupled_size) as isize);
        i += 1;
    }
    while i < (*st).layout.nb_streams {
        ret = opus_decoder_init(ptr as *mut OpusDecoder, Fs, 1 as i32);
        if ret != OPUS_OK {
            return ret;
        }
        ptr = ptr.offset(align(mono_size) as isize);
        i += 1;
    }
    return OPUS_OK;
}
pub unsafe fn opus_multistream_decoder_create(
    Fs: i32,
    channels: i32,
    streams: i32,
    coupled_streams: i32,
    mapping: *const u8,
    error: *mut i32,
) -> *mut OpusMSDecoder {
    let mut ret: i32 = 0;
    let mut st: *mut OpusMSDecoder = 0 as *mut OpusMSDecoder;
    if channels > 255 as i32
        || channels < 1 as i32
        || coupled_streams > streams
        || streams < 1 as i32
        || coupled_streams < 0 as i32
        || streams > 255 as i32 - coupled_streams
    {
        if !error.is_null() {
            *error = OPUS_BAD_ARG;
        }
        return NULL as *mut OpusMSDecoder;
    }
    st = malloc(opus_multistream_decoder_get_size(streams, coupled_streams) as size_t)
        as *mut OpusMSDecoder;
    if st.is_null() {
        if !error.is_null() {
            *error = OPUS_ALLOC_FAIL;
        }
        return NULL as *mut OpusMSDecoder;
    }
    ret = opus_multistream_decoder_init(st, Fs, channels, streams, coupled_streams, mapping);
    if !error.is_null() {
        *error = ret;
    }
    if ret != OPUS_OK {
        free(st as *mut core::ffi::c_void);
        st = NULL as *mut OpusMSDecoder;
    }
    return st;
}
unsafe fn opus_multistream_packet_validate(
    mut data: *const u8,
    mut len: i32,
    nb_streams: i32,
    Fs: i32,
) -> i32 {
    let mut s: i32 = 0;
    let mut count: i32 = 0;
    let mut toc: u8 = 0;
    let mut size: [i16; 48] = [0; 48];
    let mut samples: i32 = 0 as i32;
    let mut packet_offset: i32 = 0;
    s = 0 as i32;
    while s < nb_streams {
        let mut tmp_samples: i32 = 0;
        if len <= 0 as i32 {
            return OPUS_INVALID_PACKET;
        }
        count = opus_packet_parse_impl(
            data,
            len,
            (s != nb_streams - 1 as i32) as i32,
            &mut toc,
            NULL as *mut *const u8,
            size.as_mut_ptr(),
            NULL as *mut i32,
            &mut packet_offset,
        );
        if count < 0 as i32 {
            return count;
        }
        tmp_samples = opus_packet_get_nb_samples(data, packet_offset, Fs);
        if s != 0 as i32 && samples != tmp_samples {
            return OPUS_INVALID_PACKET;
        }
        samples = tmp_samples;
        data = data.offset(packet_offset as isize);
        len -= packet_offset;
        s += 1;
    }
    return samples;
}
pub unsafe fn opus_multistream_decode_native(
    st: *mut OpusMSDecoder,
    mut data: *const u8,
    mut len: i32,
    pcm: *mut core::ffi::c_void,
    copy_channel_out: opus_copy_channel_out_func,
    mut frame_size: i32,
    decode_fec: i32,
    soft_clip: i32,
    user_data: *mut core::ffi::c_void,
) -> i32 {
    let mut Fs: i32 = 0;
    let mut coupled_size: i32 = 0;
    let mut mono_size: i32 = 0;
    let mut s: i32 = 0;
    let mut c: i32 = 0;
    let mut ptr: *mut i8 = 0 as *mut i8;
    let mut do_plc: i32 = 0 as i32;
    validate_ms_decoder(st);
    if frame_size <= 0 as i32 {
        return OPUS_BAD_ARG;
    }
    if !(opus_multistream_decoder_ctl!(st, 4029 as i32, &mut Fs) == 0 as i32) {
        celt_fatal(
            b"assertion failed: (opus_multistream_decoder_ctl(st, 4029, ((&Fs) + ((&Fs) - (i32*)(&Fs))))) == OPUS_OK\0"
                as *const u8 as *const i8,
            b"src/opus_multistream_decoder.c\0" as *const u8 as *const i8,
            206 as i32,
        );
    }
    frame_size = if frame_size < Fs / 25 as i32 * 3 as i32 {
        frame_size
    } else {
        Fs / 25 as i32 * 3 as i32
    };
    let vla = (2 as i32 * frame_size) as usize;
    let mut buf: Vec<opus_val16> = ::std::vec::from_elem(0., vla);
    ptr = (st as *mut i8)
        .offset(align(::core::mem::size_of::<OpusMSDecoder>() as u64 as i32) as isize);
    coupled_size = opus_decoder_get_size(2 as i32);
    mono_size = opus_decoder_get_size(1 as i32);
    if len == 0 as i32 {
        do_plc = 1 as i32;
    }
    if len < 0 as i32 {
        return OPUS_BAD_ARG;
    }
    if do_plc == 0 && len < 2 as i32 * (*st).layout.nb_streams - 1 as i32 {
        return OPUS_INVALID_PACKET;
    }
    if do_plc == 0 {
        let ret: i32 = opus_multistream_packet_validate(data, len, (*st).layout.nb_streams, Fs);
        if ret < 0 as i32 {
            return ret;
        } else {
            if ret > frame_size {
                return OPUS_BUFFER_TOO_SMALL;
            }
        }
    }
    s = 0 as i32;
    while s < (*st).layout.nb_streams {
        let mut dec: *mut OpusDecoder = 0 as *mut OpusDecoder;
        let mut packet_offset: i32 = 0;
        let mut ret_0: i32 = 0;
        dec = ptr as *mut OpusDecoder;
        ptr = ptr.offset(
            (if s < (*st).layout.nb_coupled_streams {
                align(coupled_size)
            } else {
                align(mono_size)
            }) as isize,
        );
        if do_plc == 0 && len <= 0 as i32 {
            return OPUS_INTERNAL_ERROR;
        }
        packet_offset = 0 as i32;
        ret_0 = opus_decode_native(
            dec,
            data,
            len,
            buf.as_mut_ptr(),
            frame_size,
            decode_fec,
            (s != (*st).layout.nb_streams - 1 as i32) as i32,
            &mut packet_offset,
            soft_clip,
        );
        data = data.offset(packet_offset as isize);
        len -= packet_offset;
        if ret_0 <= 0 as i32 {
            return ret_0;
        }
        frame_size = ret_0;
        if s < (*st).layout.nb_coupled_streams {
            let mut chan: i32 = 0;
            let mut prev: i32 = 0;
            prev = -(1 as i32);
            loop {
                chan = get_left_channel(&mut (*st).layout, s, prev);
                if !(chan != -(1 as i32)) {
                    break;
                }
                (Some(copy_channel_out.expect("non-null function pointer")))
                    .expect("non-null function pointer")(
                    pcm,
                    (*st).layout.nb_channels,
                    chan,
                    buf.as_mut_ptr(),
                    2 as i32,
                    frame_size,
                    user_data,
                );
                prev = chan;
            }
            prev = -(1 as i32);
            loop {
                chan = get_right_channel(&mut (*st).layout, s, prev);
                if !(chan != -(1 as i32)) {
                    break;
                }
                (Some(copy_channel_out.expect("non-null function pointer")))
                    .expect("non-null function pointer")(
                    pcm,
                    (*st).layout.nb_channels,
                    chan,
                    buf.as_mut_ptr().offset(1 as i32 as isize),
                    2 as i32,
                    frame_size,
                    user_data,
                );
                prev = chan;
            }
        } else {
            let mut chan_0: i32 = 0;
            let mut prev_0: i32 = 0;
            prev_0 = -(1 as i32);
            loop {
                chan_0 = get_mono_channel(&mut (*st).layout, s, prev_0);
                if !(chan_0 != -(1 as i32)) {
                    break;
                }
                (Some(copy_channel_out.expect("non-null function pointer")))
                    .expect("non-null function pointer")(
                    pcm,
                    (*st).layout.nb_channels,
                    chan_0,
                    buf.as_mut_ptr(),
                    1 as i32,
                    frame_size,
                    user_data,
                );
                prev_0 = chan_0;
            }
        }
        s += 1;
    }
    c = 0 as i32;
    while c < (*st).layout.nb_channels {
        if (*st).layout.mapping[c as usize] as i32 == 255 as i32 {
            (Some(copy_channel_out.expect("non-null function pointer")))
                .expect("non-null function pointer")(
                pcm,
                (*st).layout.nb_channels,
                c,
                NULL as *const opus_val16,
                0 as i32,
                frame_size,
                user_data,
            );
        }
        c += 1;
    }
    return frame_size;
}
unsafe fn opus_copy_channel_out_float(
    dst: *mut core::ffi::c_void,
    dst_stride: i32,
    dst_channel: i32,
    src: *const opus_val16,
    src_stride: i32,
    frame_size: i32,
    _user_data: *mut core::ffi::c_void,
) {
    let mut float_dst: *mut f32 = 0 as *mut f32;
    let mut i: i32 = 0;
    float_dst = dst as *mut f32;
    if !src.is_null() {
        i = 0 as i32;
        while i < frame_size {
            *float_dst.offset((i * dst_stride + dst_channel) as isize) =
                *src.offset((i * src_stride) as isize);
            i += 1;
        }
    } else {
        i = 0 as i32;
        while i < frame_size {
            *float_dst.offset((i * dst_stride + dst_channel) as isize) = 0 as i32 as f32;
            i += 1;
        }
    };
}
unsafe fn opus_copy_channel_out_short(
    dst: *mut core::ffi::c_void,
    dst_stride: i32,
    dst_channel: i32,
    src: *const opus_val16,
    src_stride: i32,
    frame_size: i32,
    _user_data: *mut core::ffi::c_void,
) {
    let mut short_dst: *mut i16 = 0 as *mut i16;
    let mut i: i32 = 0;
    short_dst = dst as *mut i16;
    if !src.is_null() {
        i = 0 as i32;
        while i < frame_size {
            *short_dst.offset((i * dst_stride + dst_channel) as isize) =
                FLOAT2INT16(*src.offset((i * src_stride) as isize));
            i += 1;
        }
    } else {
        i = 0 as i32;
        while i < frame_size {
            *short_dst.offset((i * dst_stride + dst_channel) as isize) = 0 as i32 as i16;
            i += 1;
        }
    };
}
pub unsafe fn opus_multistream_decode(
    st: *mut OpusMSDecoder,
    data: *const u8,
    len: i32,
    pcm: *mut i16,
    frame_size: i32,
    decode_fec: i32,
) -> i32 {
    return opus_multistream_decode_native(
        st,
        data,
        len,
        pcm as *mut core::ffi::c_void,
        Some(
            opus_copy_channel_out_short
                as unsafe fn(
                    *mut core::ffi::c_void,
                    i32,
                    i32,
                    *const opus_val16,
                    i32,
                    i32,
                    *mut core::ffi::c_void,
                ) -> (),
        ),
        frame_size,
        decode_fec,
        1 as i32,
        NULL as *mut core::ffi::c_void,
    );
}
pub unsafe fn opus_multistream_decode_float(
    st: *mut OpusMSDecoder,
    data: *const u8,
    len: i32,
    pcm: *mut opus_val16,
    frame_size: i32,
    decode_fec: i32,
) -> i32 {
    return opus_multistream_decode_native(
        st,
        data,
        len,
        pcm as *mut core::ffi::c_void,
        Some(
            opus_copy_channel_out_float
                as unsafe fn(
                    *mut core::ffi::c_void,
                    i32,
                    i32,
                    *const opus_val16,
                    i32,
                    i32,
                    *mut core::ffi::c_void,
                ) -> (),
        ),
        frame_size,
        decode_fec,
        0 as i32,
        NULL as *mut core::ffi::c_void,
    );
}
pub unsafe fn opus_multistream_decoder_ctl_va_list(
    st: *mut OpusMSDecoder,
    request: i32,
    mut ap: VarArgs,
) -> i32 {
    let current_block: u64;
    let mut coupled_size: i32 = 0;
    let mut mono_size: i32 = 0;
    let mut ptr: *mut i8 = 0 as *mut i8;
    let mut ret: i32 = OPUS_OK;
    coupled_size = opus_decoder_get_size(2 as i32);
    mono_size = opus_decoder_get_size(1 as i32);
    ptr = (st as *mut i8)
        .offset(align(::core::mem::size_of::<OpusMSDecoder>() as u64 as i32) as isize);
    match request {
        OPUS_GET_BANDWIDTH_REQUEST
        | OPUS_GET_SAMPLE_RATE_REQUEST
        | OPUS_GET_GAIN_REQUEST
        | OPUS_GET_LAST_PACKET_DURATION_REQUEST
        | OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST => {
            let mut dec: *mut OpusDecoder = 0 as *mut OpusDecoder;
            let value: &mut i32 = ap.arg::<&mut i32>();
            dec = ptr as *mut OpusDecoder;
            ret = opus_decoder_ctl!(dec, request, value);
            current_block = 7343950298149844727;
        }
        OPUS_GET_FINAL_RANGE_REQUEST => {
            let mut s: i32 = 0;
            let value_0 = ap.arg::<&mut u32>();
            let mut tmp: u32 = 0;
            *value_0 = 0 as i32 as u32;
            s = 0 as i32;
            while s < (*st).layout.nb_streams {
                let mut dec_0: *mut OpusDecoder = 0 as *mut OpusDecoder;
                dec_0 = ptr as *mut OpusDecoder;
                if s < (*st).layout.nb_coupled_streams {
                    ptr = ptr.offset(align(coupled_size) as isize);
                } else {
                    ptr = ptr.offset(align(mono_size) as isize);
                }
                ret = opus_decoder_ctl!(dec_0, request, &mut tmp);
                if ret != OPUS_OK {
                    break;
                }
                *value_0 ^= tmp;
                s += 1;
            }
            current_block = 7343950298149844727;
        }
        OPUS_RESET_STATE => {
            let mut s_0: i32 = 0;
            s_0 = 0 as i32;
            while s_0 < (*st).layout.nb_streams {
                let mut dec_1: *mut OpusDecoder = 0 as *mut OpusDecoder;
                dec_1 = ptr as *mut OpusDecoder;
                if s_0 < (*st).layout.nb_coupled_streams {
                    ptr = ptr.offset(align(coupled_size) as isize);
                } else {
                    ptr = ptr.offset(align(mono_size) as isize);
                }
                ret = opus_decoder_ctl!(dec_1, OPUS_RESET_STATE);
                if ret != OPUS_OK {
                    break;
                }
                s_0 += 1;
            }
            current_block = 7343950298149844727;
        }
        OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST => {
            let mut s_1: i32 = 0;
            let mut stream_id: i32 = 0;
            let mut value_1: *mut *mut OpusDecoder = 0 as *mut *mut OpusDecoder;
            stream_id = ap.arg::<i32>();
            if stream_id < 0 as i32 || stream_id >= (*st).layout.nb_streams {
                current_block = 15933654591644784431;
            } else {
                value_1 = ap.arg::<&mut *mut OpusDecoder>();
                s_1 = 0 as i32;
                while s_1 < stream_id {
                    if s_1 < (*st).layout.nb_coupled_streams {
                        ptr = ptr.offset(align(coupled_size) as isize);
                    } else {
                        ptr = ptr.offset(align(mono_size) as isize);
                    }
                    s_1 += 1;
                }
                *value_1 = ptr as *mut OpusDecoder;
                current_block = 7343950298149844727;
            }
        }
        OPUS_SET_GAIN_REQUEST | OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST => {
            let mut s_2: i32 = 0;
            let value_2: i32 = ap.arg::<i32>();
            s_2 = 0 as i32;
            while s_2 < (*st).layout.nb_streams {
                let mut dec_2: *mut OpusDecoder = 0 as *mut OpusDecoder;
                dec_2 = ptr as *mut OpusDecoder;
                if s_2 < (*st).layout.nb_coupled_streams {
                    ptr = ptr.offset(align(coupled_size) as isize);
                } else {
                    ptr = ptr.offset(align(mono_size) as isize);
                }
                ret = opus_decoder_ctl!(dec_2, request, value_2);
                if ret != OPUS_OK {
                    break;
                }
                s_2 += 1;
            }
            current_block = 7343950298149844727;
        }
        _ => {
            ret = OPUS_UNIMPLEMENTED;
            current_block = 7343950298149844727;
        }
    }
    match current_block {
        15933654591644784431 => return OPUS_BAD_ARG,
        _ => return ret,
    };
}
pub unsafe fn opus_multistream_decoder_ctl_impl(
    st: *mut OpusMSDecoder,
    request: i32,
    args: VarArgs,
) -> i32 {
    let mut ret: i32 = 0;
    ret = opus_multistream_decoder_ctl_va_list(st, request, args);
    return ret;
}
#[macro_export]
macro_rules! opus_multistream_decoder_ctl {
    ($st:expr, $request:expr, $($arg:expr),*) => {
        $crate::opus_multistream_decoder_ctl_impl($st, $request, $crate::varargs!($($arg),*))
    };
    ($st:expr, $request:expr) => {
        opus_multistream_decoder_ctl!($st, $request,)
    };
    ($st:expr, $request:expr, $($arg:expr),*,) => {
        opus_multistream_decoder_ctl!($st, $request, $($arg),*)
    };
}
pub unsafe fn opus_multistream_decoder_destroy(st: *mut OpusMSDecoder) {
    free(st as *mut core::ffi::c_void);
}