@scrypted/libav 1.0.169 → 1.0.171
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/build-ffmpeg-linux.sh +2 -1
- package/opus/.gitattributes +0 -10
- package/opus/.gitlab-ci.yml +0 -122
- package/opus/AUTHORS +0 -6
- package/opus/CMakeLists.txt +0 -755
- package/opus/COPYING +0 -44
- package/opus/ChangeLog +0 -0
- package/opus/LICENSE_PLEASE_READ.txt +0 -22
- package/opus/Makefile.am +0 -497
- package/opus/Makefile.mips +0 -169
- package/opus/Makefile.unix +0 -167
- package/opus/NEWS +0 -0
- package/opus/README +0 -189
- package/opus/README.draft +0 -54
- package/opus/autogen.bat +0 -13
- package/opus/autogen.sh +0 -16
- package/opus/celt/_kiss_fft_guts.h +0 -188
- package/opus/celt/arch.h +0 -390
- package/opus/celt/arm/arm2gnu.pl +0 -353
- package/opus/celt/arm/arm_celt_map.c +0 -171
- package/opus/celt/arm/armcpu.c +0 -291
- package/opus/celt/arm/armcpu.h +0 -90
- package/opus/celt/arm/armopts.s.in +0 -37
- package/opus/celt/arm/celt_fft_ne10.c +0 -173
- package/opus/celt/arm/celt_mdct_ne10.c +0 -258
- package/opus/celt/arm/celt_neon_intr.c +0 -272
- package/opus/celt/arm/celt_pitch_xcorr_arm.s +0 -551
- package/opus/celt/arm/fft_arm.h +0 -71
- package/opus/celt/arm/fixed_arm64.h +0 -35
- package/opus/celt/arm/fixed_armv4.h +0 -80
- package/opus/celt/arm/fixed_armv5e.h +0 -151
- package/opus/celt/arm/kiss_fft_armv4.h +0 -121
- package/opus/celt/arm/kiss_fft_armv5e.h +0 -118
- package/opus/celt/arm/mdct_arm.h +0 -59
- package/opus/celt/arm/meson.build +0 -12
- package/opus/celt/arm/pitch_arm.h +0 -160
- package/opus/celt/arm/pitch_neon_intr.c +0 -288
- package/opus/celt/bands.c +0 -1686
- package/opus/celt/bands.h +0 -123
- package/opus/celt/celt.c +0 -317
- package/opus/celt/celt.h +0 -255
- package/opus/celt/celt_decoder.c +0 -1616
- package/opus/celt/celt_encoder.c +0 -2854
- package/opus/celt/celt_lpc.c +0 -364
- package/opus/celt/celt_lpc.h +0 -66
- package/opus/celt/cpu_support.h +0 -72
- package/opus/celt/cwrs.c +0 -715
- package/opus/celt/cwrs.h +0 -48
- package/opus/celt/dump_modes/dump_modes.c +0 -400
- package/opus/celt/dump_modes/dump_modes_arch.h +0 -45
- package/opus/celt/dump_modes/dump_modes_arm_ne10.c +0 -152
- package/opus/celt/ecintrin.h +0 -91
- package/opus/celt/entcode.c +0 -153
- package/opus/celt/entcode.h +0 -152
- package/opus/celt/entdec.c +0 -266
- package/opus/celt/entdec.h +0 -110
- package/opus/celt/entenc.c +0 -305
- package/opus/celt/entenc.h +0 -119
- package/opus/celt/fixed_c5x.h +0 -79
- package/opus/celt/fixed_c6x.h +0 -70
- package/opus/celt/fixed_debug.h +0 -839
- package/opus/celt/fixed_generic.h +0 -201
- package/opus/celt/float_cast.h +0 -152
- package/opus/celt/kiss_fft.c +0 -648
- package/opus/celt/kiss_fft.h +0 -217
- package/opus/celt/laplace.c +0 -235
- package/opus/celt/laplace.h +0 -57
- package/opus/celt/mathops.c +0 -217
- package/opus/celt/mathops.h +0 -479
- package/opus/celt/mdct.c +0 -372
- package/opus/celt/mdct.h +0 -115
- package/opus/celt/meson.build +0 -64
- package/opus/celt/mfrngcod.h +0 -48
- package/opus/celt/mips/celt_mipsr1.h +0 -152
- package/opus/celt/mips/fixed_generic_mipsr1.h +0 -126
- package/opus/celt/mips/kiss_fft_mipsr1.h +0 -167
- package/opus/celt/mips/mdct_mipsr1.h +0 -288
- package/opus/celt/mips/pitch_mipsr1.h +0 -161
- package/opus/celt/mips/vq_mipsr1.h +0 -116
- package/opus/celt/modes.c +0 -450
- package/opus/celt/modes.h +0 -75
- package/opus/celt/opus_custom_demo.c +0 -451
- package/opus/celt/os_support.h +0 -99
- package/opus/celt/pitch.c +0 -555
- package/opus/celt/pitch.h +0 -203
- package/opus/celt/quant_bands.c +0 -562
- package/opus/celt/quant_bands.h +0 -66
- package/opus/celt/rate.c +0 -646
- package/opus/celt/rate.h +0 -101
- package/opus/celt/stack_alloc.h +0 -185
- package/opus/celt/static_modes_fixed.h +0 -1541
- package/opus/celt/static_modes_fixed_arm_ne10.h +0 -388
- package/opus/celt/static_modes_float.h +0 -888
- package/opus/celt/static_modes_float_arm_ne10.h +0 -404
- package/opus/celt/tests/meson.build +0 -19
- package/opus/celt/tests/test_unit_cwrs32.c +0 -162
- package/opus/celt/tests/test_unit_dft.c +0 -181
- package/opus/celt/tests/test_unit_entropy.c +0 -383
- package/opus/celt/tests/test_unit_laplace.c +0 -94
- package/opus/celt/tests/test_unit_mathops.c +0 -369
- package/opus/celt/tests/test_unit_mdct.c +0 -233
- package/opus/celt/tests/test_unit_rotation.c +0 -87
- package/opus/celt/tests/test_unit_types.c +0 -50
- package/opus/celt/vq.c +0 -442
- package/opus/celt/vq.h +0 -79
- package/opus/celt/x86/celt_lpc_sse.h +0 -67
- package/opus/celt/x86/celt_lpc_sse4_1.c +0 -96
- package/opus/celt/x86/pitch_avx.c +0 -101
- package/opus/celt/x86/pitch_sse.c +0 -185
- package/opus/celt/x86/pitch_sse.h +0 -216
- package/opus/celt/x86/pitch_sse2.c +0 -95
- package/opus/celt/x86/pitch_sse4_1.c +0 -240
- package/opus/celt/x86/vq_sse.h +0 -52
- package/opus/celt/x86/vq_sse2.c +0 -217
- package/opus/celt/x86/x86_arch_macros.h +0 -47
- package/opus/celt/x86/x86_celt_map.c +0 -187
- package/opus/celt/x86/x86cpu.c +0 -184
- package/opus/celt/x86/x86cpu.h +0 -112
- package/opus/celt_headers.mk +0 -54
- package/opus/celt_sources.mk +0 -55
- package/opus/cmake/CFeatureCheck.cmake +0 -39
- package/opus/cmake/OpusBuildtype.cmake +0 -27
- package/opus/cmake/OpusConfig.cmake +0 -118
- package/opus/cmake/OpusConfig.cmake.in +0 -20
- package/opus/cmake/OpusFunctions.cmake +0 -231
- package/opus/cmake/OpusPackageVersion.cmake +0 -70
- package/opus/cmake/OpusSources.cmake +0 -71
- package/opus/cmake/README.md +0 -132
- package/opus/cmake/RunTest.cmake +0 -61
- package/opus/cmake/config.h.cmake.in +0 -1
- package/opus/cmake/cpu_info_by_asm.c +0 -31
- package/opus/cmake/cpu_info_by_c.c +0 -9
- package/opus/cmake/vla.c +0 -7
- package/opus/configure.ac +0 -1091
- package/opus/dnn/LPCNet.yml +0 -24
- package/opus/dnn/README +0 -1
- package/opus/dnn/README.md +0 -126
- package/opus/dnn/adaconvtest.c +0 -449
- package/opus/dnn/arm/arm_dnn_map.c +0 -88
- package/opus/dnn/arm/dnn_arm.h +0 -104
- package/opus/dnn/arm/nnet_dotprod.c +0 -38
- package/opus/dnn/arm/nnet_neon.c +0 -38
- package/opus/dnn/burg.c +0 -246
- package/opus/dnn/burg.h +0 -41
- package/opus/dnn/common.h +0 -56
- package/opus/dnn/datasets.txt +0 -163
- package/opus/dnn/download_model.bat +0 -9
- package/opus/dnn/download_model.sh +0 -30
- package/opus/dnn/dred_coding.c +0 -44
- package/opus/dnn/dred_coding.h +0 -36
- package/opus/dnn/dred_config.h +0 -54
- package/opus/dnn/dred_decoder.c +0 -129
- package/opus/dnn/dred_decoder.h +0 -49
- package/opus/dnn/dred_encoder.c +0 -363
- package/opus/dnn/dred_encoder.h +0 -71
- package/opus/dnn/dred_rdovae.h +0 -42
- package/opus/dnn/dred_rdovae_dec.c +0 -139
- package/opus/dnn/dred_rdovae_dec.h +0 -53
- package/opus/dnn/dred_rdovae_enc.c +0 -110
- package/opus/dnn/dred_rdovae_enc.h +0 -52
- package/opus/dnn/dump_data.c +0 -238
- package/opus/dnn/dump_lpcnet_tables.c +0 -104
- package/opus/dnn/fargan.c +0 -225
- package/opus/dnn/fargan.h +0 -68
- package/opus/dnn/fargan_demo.c +0 -217
- package/opus/dnn/freq.c +0 -328
- package/opus/dnn/freq.h +0 -61
- package/opus/dnn/fwgan.c +0 -322
- package/opus/dnn/fwgan.h +0 -83
- package/opus/dnn/kiss99.c +0 -81
- package/opus/dnn/kiss99.h +0 -46
- package/opus/dnn/lossgen.c +0 -192
- package/opus/dnn/lossgen.h +0 -55
- package/opus/dnn/lossgen_demo.c +0 -22
- package/opus/dnn/lpcnet.c +0 -283
- package/opus/dnn/lpcnet.h +0 -183
- package/opus/dnn/lpcnet_enc.c +0 -230
- package/opus/dnn/lpcnet_plc.c +0 -211
- package/opus/dnn/lpcnet_private.h +0 -90
- package/opus/dnn/lpcnet_tables.c +0 -307
- package/opus/dnn/meson.build +0 -64
- package/opus/dnn/nndsp.c +0 -416
- package/opus/dnn/nndsp.h +0 -143
- package/opus/dnn/nnet.c +0 -149
- package/opus/dnn/nnet.h +0 -163
- package/opus/dnn/nnet_arch.h +0 -247
- package/opus/dnn/nnet_default.c +0 -35
- package/opus/dnn/osce.c +0 -1419
- package/opus/dnn/osce.h +0 -84
- package/opus/dnn/osce_config.h +0 -60
- package/opus/dnn/osce_features.c +0 -454
- package/opus/dnn/osce_features.h +0 -50
- package/opus/dnn/osce_structs.h +0 -125
- package/opus/dnn/parse_lpcnet_weights.c +0 -238
- package/opus/dnn/pitchdnn.c +0 -79
- package/opus/dnn/pitchdnn.h +0 -34
- package/opus/dnn/tansig_table.h +0 -50
- package/opus/dnn/test_vec.c +0 -128
- package/opus/dnn/torch/dnntools/dnntools/__init__.py +0 -2
- package/opus/dnn/torch/dnntools/dnntools/quantization/__init__.py +0 -1
- package/opus/dnn/torch/dnntools/dnntools/quantization/softquant.py +0 -113
- package/opus/dnn/torch/dnntools/dnntools/relegance/__init__.py +0 -2
- package/opus/dnn/torch/dnntools/dnntools/relegance/meta_critic.py +0 -85
- package/opus/dnn/torch/dnntools/dnntools/relegance/relegance.py +0 -449
- package/opus/dnn/torch/dnntools/dnntools/sparsification/__init__.py +0 -6
- package/opus/dnn/torch/dnntools/dnntools/sparsification/base_sparsifier.py +0 -58
- package/opus/dnn/torch/dnntools/dnntools/sparsification/common.py +0 -123
- package/opus/dnn/torch/dnntools/dnntools/sparsification/conv1d_sparsifier.py +0 -133
- package/opus/dnn/torch/dnntools/dnntools/sparsification/conv_transpose1d_sparsifier.py +0 -134
- package/opus/dnn/torch/dnntools/dnntools/sparsification/gru_sparsifier.py +0 -178
- package/opus/dnn/torch/dnntools/dnntools/sparsification/linear_sparsifier.py +0 -128
- package/opus/dnn/torch/dnntools/dnntools/sparsification/utils.py +0 -64
- package/opus/dnn/torch/dnntools/requirements.txt +0 -1
- package/opus/dnn/torch/dnntools/setup.py +0 -48
- package/opus/dnn/torch/fargan/README.md +0 -54
- package/opus/dnn/torch/fargan/adv_train_fargan.py +0 -277
- package/opus/dnn/torch/fargan/dataset.py +0 -61
- package/opus/dnn/torch/fargan/dump_fargan_weights.py +0 -112
- package/opus/dnn/torch/fargan/fargan.py +0 -322
- package/opus/dnn/torch/fargan/filters.py +0 -46
- package/opus/dnn/torch/fargan/rc.py +0 -29
- package/opus/dnn/torch/fargan/stft_loss.py +0 -186
- package/opus/dnn/torch/fargan/test_fargan.py +0 -128
- package/opus/dnn/torch/fargan/train_fargan.py +0 -168
- package/opus/dnn/torch/fwgan/dump_model_weights.py +0 -88
- package/opus/dnn/torch/fwgan/inference.py +0 -141
- package/opus/dnn/torch/fwgan/models/__init__.py +0 -7
- package/opus/dnn/torch/fwgan/models/fwgan400.py +0 -308
- package/opus/dnn/torch/fwgan/models/fwgan500.py +0 -260
- package/opus/dnn/torch/lossgen/README.md +0 -27
- package/opus/dnn/torch/lossgen/export_lossgen.py +0 -101
- package/opus/dnn/torch/lossgen/lossgen.py +0 -29
- package/opus/dnn/torch/lossgen/process_data.sh +0 -17
- package/opus/dnn/torch/lossgen/test_lossgen.py +0 -42
- package/opus/dnn/torch/lossgen/train_lossgen.py +0 -99
- package/opus/dnn/torch/lpcnet/README.md +0 -27
- package/opus/dnn/torch/lpcnet/add_dataset_config.py +0 -77
- package/opus/dnn/torch/lpcnet/data/__init__.py +0 -1
- package/opus/dnn/torch/lpcnet/data/lpcnet_dataset.py +0 -227
- package/opus/dnn/torch/lpcnet/engine/lpcnet_engine.py +0 -141
- package/opus/dnn/torch/lpcnet/make_default_setup.py +0 -56
- package/opus/dnn/torch/lpcnet/make_test_config.py +0 -78
- package/opus/dnn/torch/lpcnet/models/__init__.py +0 -8
- package/opus/dnn/torch/lpcnet/models/lpcnet.py +0 -303
- package/opus/dnn/torch/lpcnet/models/multi_rate_lpcnet.py +0 -437
- package/opus/dnn/torch/lpcnet/print_lpcnet_complexity.py +0 -64
- package/opus/dnn/torch/lpcnet/scripts/collect_multi_run_results.py +0 -190
- package/opus/dnn/torch/lpcnet/scripts/loop_run.sh +0 -52
- package/opus/dnn/torch/lpcnet/scripts/make_animation.py +0 -67
- package/opus/dnn/torch/lpcnet/scripts/modify_dataset_target.py +0 -17
- package/opus/dnn/torch/lpcnet/scripts/multi_run.sh +0 -17
- package/opus/dnn/torch/lpcnet/scripts/run_inference_test.sh +0 -22
- package/opus/dnn/torch/lpcnet/scripts/update_checkpoints.py +0 -54
- package/opus/dnn/torch/lpcnet/scripts/update_output_folder.sh +0 -22
- package/opus/dnn/torch/lpcnet/scripts/update_setups.py +0 -57
- package/opus/dnn/torch/lpcnet/test_lpcnet.py +0 -89
- package/opus/dnn/torch/lpcnet/train_lpcnet.py +0 -272
- package/opus/dnn/torch/lpcnet/utils/__init__.py +0 -4
- package/opus/dnn/torch/lpcnet/utils/data.py +0 -141
- package/opus/dnn/torch/lpcnet/utils/endoscopy.py +0 -234
- package/opus/dnn/torch/lpcnet/utils/layers/__init__.py +0 -3
- package/opus/dnn/torch/lpcnet/utils/layers/dual_fc.py +0 -44
- package/opus/dnn/torch/lpcnet/utils/layers/pcm_embeddings.py +0 -71
- package/opus/dnn/torch/lpcnet/utils/layers/subconditioner.py +0 -497
- package/opus/dnn/torch/lpcnet/utils/misc.py +0 -65
- package/opus/dnn/torch/lpcnet/utils/pcm.py +0 -35
- package/opus/dnn/torch/lpcnet/utils/sample.py +0 -44
- package/opus/dnn/torch/lpcnet/utils/sparsification/__init__.py +0 -2
- package/opus/dnn/torch/lpcnet/utils/sparsification/common.py +0 -121
- package/opus/dnn/torch/lpcnet/utils/sparsification/gru_sparsifier.py +0 -187
- package/opus/dnn/torch/lpcnet/utils/templates.py +0 -157
- package/opus/dnn/torch/lpcnet/utils/ulaw.py +0 -58
- package/opus/dnn/torch/lpcnet/utils/wav.py +0 -43
- package/opus/dnn/torch/neural-pitch/README.md +0 -18
- package/opus/dnn/torch/neural-pitch/data_augmentation.py +0 -149
- package/opus/dnn/torch/neural-pitch/download_demand.sh +0 -43
- package/opus/dnn/torch/neural-pitch/evaluation.py +0 -349
- package/opus/dnn/torch/neural-pitch/experiments.py +0 -38
- package/opus/dnn/torch/neural-pitch/export_neuralpitch_weights.py +0 -109
- package/opus/dnn/torch/neural-pitch/models.py +0 -178
- package/opus/dnn/torch/neural-pitch/neural_pitch_update.py +0 -179
- package/opus/dnn/torch/neural-pitch/ptdb_process.sh +0 -34
- package/opus/dnn/torch/neural-pitch/run_crepe.py +0 -72
- package/opus/dnn/torch/neural-pitch/training.py +0 -162
- package/opus/dnn/torch/neural-pitch/utils.py +0 -59
- package/opus/dnn/torch/osce/README.md +0 -66
- package/opus/dnn/torch/osce/adv_train_model.py +0 -462
- package/opus/dnn/torch/osce/adv_train_vocoder.py +0 -451
- package/opus/dnn/torch/osce/create_testvectors.py +0 -165
- package/opus/dnn/torch/osce/data/__init__.py +0 -2
- package/opus/dnn/torch/osce/data/lpcnet_vocoding_dataset.py +0 -225
- package/opus/dnn/torch/osce/data/silk_conversion_set.py +0 -132
- package/opus/dnn/torch/osce/data/silk_enhancement_set.py +0 -140
- package/opus/dnn/torch/osce/engine/engine.py +0 -103
- package/opus/dnn/torch/osce/engine/vocoder_engine.py +0 -101
- package/opus/dnn/torch/osce/export_model_weights.py +0 -174
- package/opus/dnn/torch/osce/losses/stft_loss.py +0 -277
- package/opus/dnn/torch/osce/losses/td_lowpass.py +0 -34
- package/opus/dnn/torch/osce/make_default_setup.py +0 -93
- package/opus/dnn/torch/osce/models/__init__.py +0 -42
- package/opus/dnn/torch/osce/models/fd_discriminator.py +0 -974
- package/opus/dnn/torch/osce/models/lace.py +0 -190
- package/opus/dnn/torch/osce/models/lavoce.py +0 -274
- package/opus/dnn/torch/osce/models/lavoce_400.py +0 -254
- package/opus/dnn/torch/osce/models/lpcnet_feature_net.py +0 -91
- package/opus/dnn/torch/osce/models/nns_base.py +0 -69
- package/opus/dnn/torch/osce/models/no_lace.py +0 -218
- package/opus/dnn/torch/osce/models/scale_embedding.py +0 -68
- package/opus/dnn/torch/osce/models/shape_up_48.py +0 -179
- package/opus/dnn/torch/osce/models/silk_feature_net.py +0 -86
- package/opus/dnn/torch/osce/models/silk_feature_net_pl.py +0 -127
- package/opus/dnn/torch/osce/requirements.txt +0 -9
- package/opus/dnn/torch/osce/resources/training_files.txt +0 -107716
- package/opus/dnn/torch/osce/resources/validation_files.txt +0 -26929
- package/opus/dnn/torch/osce/scripts/concatenator.py +0 -85
- package/opus/dnn/torch/osce/silk_16_to_48.py +0 -28
- package/opus/dnn/torch/osce/stndrd/evaluation/commonvoice_clip_selection.py +0 -123
- package/opus/dnn/torch/osce/stndrd/evaluation/create_input_data.sh +0 -25
- package/opus/dnn/torch/osce/stndrd/evaluation/env.rc +0 -7
- package/opus/dnn/torch/osce/stndrd/evaluation/evaluate.py +0 -113
- package/opus/dnn/torch/osce/stndrd/evaluation/lace_loss_metric.py +0 -330
- package/opus/dnn/torch/osce/stndrd/evaluation/make_boxplots.py +0 -116
- package/opus/dnn/torch/osce/stndrd/evaluation/make_boxplots_moctest.py +0 -109
- package/opus/dnn/torch/osce/stndrd/evaluation/make_tables.py +0 -124
- package/opus/dnn/torch/osce/stndrd/evaluation/make_tables_moctest.py +0 -121
- package/opus/dnn/torch/osce/stndrd/evaluation/moc.py +0 -182
- package/opus/dnn/torch/osce/stndrd/evaluation/moc2.py +0 -190
- package/opus/dnn/torch/osce/stndrd/evaluation/process_dataset.sh +0 -98
- package/opus/dnn/torch/osce/stndrd/evaluation/run_nomad.py +0 -138
- package/opus/dnn/torch/osce/stndrd/evaluation/run_osce_test.py +0 -196
- package/opus/dnn/torch/osce/stndrd/presentation/endoscopy.py +0 -205
- package/opus/dnn/torch/osce/stndrd/presentation/lace_demo.ipynb +0 -313
- package/opus/dnn/torch/osce/stndrd/presentation/linear_prediction.ipynb +0 -320
- package/opus/dnn/torch/osce/stndrd/presentation/playback.py +0 -25
- package/opus/dnn/torch/osce/stndrd/presentation/postfilter.ipynb +0 -275
- package/opus/dnn/torch/osce/stndrd/presentation/spectrogram.ipynb +0 -173
- package/opus/dnn/torch/osce/test_model.py +0 -96
- package/opus/dnn/torch/osce/test_vocoder.py +0 -103
- package/opus/dnn/torch/osce/train_model.py +0 -307
- package/opus/dnn/torch/osce/train_vocoder.py +0 -287
- package/opus/dnn/torch/osce/utils/ada_conv.py +0 -71
- package/opus/dnn/torch/osce/utils/complexity.py +0 -8
- package/opus/dnn/torch/osce/utils/endoscopy.py +0 -205
- package/opus/dnn/torch/osce/utils/layers/fir.py +0 -27
- package/opus/dnn/torch/osce/utils/layers/limited_adaptive_comb1d.py +0 -230
- package/opus/dnn/torch/osce/utils/layers/limited_adaptive_conv1d.py +0 -200
- package/opus/dnn/torch/osce/utils/layers/noise_shaper.py +0 -100
- package/opus/dnn/torch/osce/utils/layers/pitch_auto_correlator.py +0 -84
- package/opus/dnn/torch/osce/utils/layers/silk_upsampler.py +0 -167
- package/opus/dnn/torch/osce/utils/layers/td_shaper.py +0 -145
- package/opus/dnn/torch/osce/utils/lpcnet_features.py +0 -112
- package/opus/dnn/torch/osce/utils/misc.py +0 -95
- package/opus/dnn/torch/osce/utils/moc.py +0 -153
- package/opus/dnn/torch/osce/utils/pitch.py +0 -122
- package/opus/dnn/torch/osce/utils/silk_features.py +0 -144
- package/opus/dnn/torch/osce/utils/softquant.py +0 -110
- package/opus/dnn/torch/osce/utils/spec.py +0 -210
- package/opus/dnn/torch/osce/utils/templates.py +0 -347
- package/opus/dnn/torch/plc/export_plc.py +0 -100
- package/opus/dnn/torch/plc/plc.py +0 -144
- package/opus/dnn/torch/plc/plc_dataset.py +0 -60
- package/opus/dnn/torch/plc/train_plc.py +0 -145
- package/opus/dnn/torch/rdovae/README.md +0 -55
- package/opus/dnn/torch/rdovae/download_datasets.sh +0 -6
- package/opus/dnn/torch/rdovae/export_rdovae_weights.py +0 -365
- package/opus/dnn/torch/rdovae/fec_encoder.py +0 -212
- package/opus/dnn/torch/rdovae/import_rdovae_weights.py +0 -143
- package/opus/dnn/torch/rdovae/packets/__init__.py +0 -1
- package/opus/dnn/torch/rdovae/packets/fec_packets.c +0 -142
- package/opus/dnn/torch/rdovae/packets/fec_packets.h +0 -34
- package/opus/dnn/torch/rdovae/packets/fec_packets.py +0 -108
- package/opus/dnn/torch/rdovae/process_speech.sh +0 -7
- package/opus/dnn/torch/rdovae/rdovae/__init__.py +0 -2
- package/opus/dnn/torch/rdovae/rdovae/dataset.py +0 -67
- package/opus/dnn/torch/rdovae/rdovae/rdovae.py +0 -719
- package/opus/dnn/torch/rdovae/requirements.txt +0 -4
- package/opus/dnn/torch/rdovae/train_rdovae.py +0 -278
- package/opus/dnn/torch/testsuite/README.md +0 -46
- package/opus/dnn/torch/testsuite/examples/lpcnet_c_example.yml +0 -6
- package/opus/dnn/torch/testsuite/examples/lpcnet_c_plc_example.yml +0 -5
- package/opus/dnn/torch/testsuite/examples/lpcnet_torch_example.yml +0 -5
- package/opus/dnn/torch/testsuite/requirements.txt +0 -12
- package/opus/dnn/torch/testsuite/run_test.py +0 -375
- package/opus/dnn/torch/testsuite/utils/__init__.py +0 -0
- package/opus/dnn/torch/testsuite/utils/files.py +0 -54
- package/opus/dnn/torch/testsuite/utils/pesq.py +0 -43
- package/opus/dnn/torch/testsuite/utils/pitch.py +0 -61
- package/opus/dnn/torch/weight-exchange/README.md +0 -21
- package/opus/dnn/torch/weight-exchange/requirements.txt +0 -1
- package/opus/dnn/torch/weight-exchange/setup.py +0 -48
- package/opus/dnn/torch/weight-exchange/wexchange/__init__.py +0 -30
- package/opus/dnn/torch/weight-exchange/wexchange/c_export/__init__.py +0 -31
- package/opus/dnn/torch/weight-exchange/wexchange/c_export/c_writer.py +0 -181
- package/opus/dnn/torch/weight-exchange/wexchange/c_export/common.py +0 -386
- package/opus/dnn/torch/weight-exchange/wexchange/tf/__init__.py +0 -5
- package/opus/dnn/torch/weight-exchange/wexchange/tf/tf.py +0 -188
- package/opus/dnn/torch/weight-exchange/wexchange/torch/__init__.py +0 -37
- package/opus/dnn/torch/weight-exchange/wexchange/torch/torch.py +0 -433
- package/opus/dnn/training_tf2/dataloader.py +0 -49
- package/opus/dnn/training_tf2/decode_rdovae.py +0 -111
- package/opus/dnn/training_tf2/diffembed.py +0 -49
- package/opus/dnn/training_tf2/dump_lpcnet.py +0 -388
- package/opus/dnn/training_tf2/dump_plc.py +0 -296
- package/opus/dnn/training_tf2/dump_rdovae.py +0 -306
- package/opus/dnn/training_tf2/encode_rdovae.py +0 -125
- package/opus/dnn/training_tf2/fec_encoder.py +0 -256
- package/opus/dnn/training_tf2/fec_packets.c +0 -142
- package/opus/dnn/training_tf2/fec_packets.h +0 -34
- package/opus/dnn/training_tf2/fec_packets.py +0 -108
- package/opus/dnn/training_tf2/keraslayerdump.py +0 -189
- package/opus/dnn/training_tf2/lossfuncs.py +0 -99
- package/opus/dnn/training_tf2/lpcnet.py +0 -339
- package/opus/dnn/training_tf2/lpcnet_plc.py +0 -101
- package/opus/dnn/training_tf2/mdense.py +0 -95
- package/opus/dnn/training_tf2/pade.py +0 -70
- package/opus/dnn/training_tf2/parameters.py +0 -29
- package/opus/dnn/training_tf2/plc_loader.py +0 -73
- package/opus/dnn/training_tf2/rdovae.py +0 -372
- package/opus/dnn/training_tf2/rdovae_exchange.py +0 -138
- package/opus/dnn/training_tf2/rdovae_import.py +0 -123
- package/opus/dnn/training_tf2/test_lpcnet.py +0 -120
- package/opus/dnn/training_tf2/test_plc.py +0 -92
- package/opus/dnn/training_tf2/tf_funcs.py +0 -70
- package/opus/dnn/training_tf2/train_lpcnet.py +0 -214
- package/opus/dnn/training_tf2/train_plc.py +0 -197
- package/opus/dnn/training_tf2/train_rdovae.py +0 -151
- package/opus/dnn/training_tf2/ulaw.py +0 -19
- package/opus/dnn/training_tf2/uniform_noise.py +0 -78
- package/opus/dnn/vec.h +0 -389
- package/opus/dnn/vec_avx.h +0 -884
- package/opus/dnn/vec_neon.h +0 -473
- package/opus/dnn/write_lpcnet_weights.c +0 -97
- package/opus/dnn/x86/dnn_x86.h +0 -121
- package/opus/dnn/x86/nnet_avx2.c +0 -40
- package/opus/dnn/x86/nnet_sse2.c +0 -40
- package/opus/dnn/x86/nnet_sse4_1.c +0 -40
- package/opus/dnn/x86/x86_dnn_map.c +0 -83
- package/opus/doc/Doxyfile.in +0 -340
- package/opus/doc/Makefile.am +0 -45
- package/opus/doc/build_draft.sh +0 -113
- package/opus/doc/build_isobmff.sh +0 -50
- package/opus/doc/build_oggdraft.sh +0 -52
- package/opus/doc/customdoxygen.css +0 -1011
- package/opus/doc/draft-ietf-codec-oggopus.xml +0 -1873
- package/opus/doc/draft-ietf-codec-opus-update.xml +0 -513
- package/opus/doc/draft-ietf-codec-opus.xml +0 -8276
- package/opus/doc/draft-ietf-payload-rtp-opus.xml +0 -960
- package/opus/doc/footer.html +0 -32
- package/opus/doc/header.html +0 -61
- package/opus/doc/meson.build +0 -33
- package/opus/doc/opus_in_isobmff.css +0 -60
- package/opus/doc/opus_in_isobmff.html +0 -692
- package/opus/doc/opus_logo.svg +0 -157
- package/opus/doc/opus_update.patch +0 -244
- package/opus/doc/release.txt +0 -43
- package/opus/doc/trivial_example.c +0 -171
- package/opus/include/meson.build +0 -13
- package/opus/include/opus.h +0 -1172
- package/opus/include/opus_custom.h +0 -381
- package/opus/include/opus_defines.h +0 -830
- package/opus/include/opus_multistream.h +0 -736
- package/opus/include/opus_projection.h +0 -643
- package/opus/include/opus_types.h +0 -166
- package/opus/lpcnet_headers.mk +0 -44
- package/opus/lpcnet_sources.mk +0 -44
- package/opus/m4/as-gcc-inline-assembly.m4 +0 -98
- package/opus/m4/ax_add_fortify_source.m4 +0 -53
- package/opus/m4/opus-intrinsics.m4 +0 -29
- package/opus/meson/README.md +0 -88
- package/opus/meson/get-version.py +0 -86
- package/opus/meson/read-sources-list.py +0 -28
- package/opus/meson.build +0 -745
- package/opus/meson_options.txt +0 -27
- package/opus/opus-uninstalled.pc.in +0 -12
- package/opus/opus.m4 +0 -117
- package/opus/opus.pc.in +0 -16
- package/opus/opus_headers.mk +0 -8
- package/opus/opus_sources.mk +0 -17
- package/opus/releases.sha2 +0 -85
- package/opus/scripts/dump_rnn.py +0 -57
- package/opus/scripts/local_build.py +0 -220
- package/opus/scripts/rnn_train.py +0 -67
- package/opus/scripts/shrink_model.sh +0 -7
- package/opus/silk/A2NLSF.c +0 -267
- package/opus/silk/API.h +0 -156
- package/opus/silk/CNG.c +0 -188
- package/opus/silk/HP_variable_cutoff.c +0 -77
- package/opus/silk/Inlines.h +0 -188
- package/opus/silk/LPC_analysis_filter.c +0 -111
- package/opus/silk/LPC_fit.c +0 -82
- package/opus/silk/LPC_inv_pred_gain.c +0 -141
- package/opus/silk/LP_variable_cutoff.c +0 -135
- package/opus/silk/MacroCount.h +0 -710
- package/opus/silk/MacroDebug.h +0 -945
- package/opus/silk/NLSF2A.c +0 -141
- package/opus/silk/NLSF_VQ.c +0 -76
- package/opus/silk/NLSF_VQ_weights_laroia.c +0 -80
- package/opus/silk/NLSF_decode.c +0 -93
- package/opus/silk/NLSF_del_dec_quant.c +0 -215
- package/opus/silk/NLSF_encode.c +0 -124
- package/opus/silk/NLSF_stabilize.c +0 -142
- package/opus/silk/NLSF_unpack.c +0 -55
- package/opus/silk/NSQ.c +0 -437
- package/opus/silk/NSQ.h +0 -101
- package/opus/silk/NSQ_del_dec.c +0 -733
- package/opus/silk/PLC.c +0 -493
- package/opus/silk/PLC.h +0 -65
- package/opus/silk/SigProc_FIX.h +0 -643
- package/opus/silk/VAD.c +0 -360
- package/opus/silk/VQ_WMat_EC.c +0 -131
- package/opus/silk/ana_filt_bank_1.c +0 -74
- package/opus/silk/arm/LPC_inv_pred_gain_arm.h +0 -57
- package/opus/silk/arm/LPC_inv_pred_gain_neon_intr.c +0 -288
- package/opus/silk/arm/NSQ_del_dec_arm.h +0 -100
- package/opus/silk/arm/NSQ_del_dec_neon_intr.c +0 -1138
- package/opus/silk/arm/NSQ_neon.c +0 -112
- package/opus/silk/arm/NSQ_neon.h +0 -114
- package/opus/silk/arm/SigProc_FIX_armv4.h +0 -47
- package/opus/silk/arm/SigProc_FIX_armv5e.h +0 -61
- package/opus/silk/arm/arm_silk_map.c +0 -128
- package/opus/silk/arm/biquad_alt_arm.h +0 -68
- package/opus/silk/arm/biquad_alt_neon_intr.c +0 -156
- package/opus/silk/arm/macros_arm64.h +0 -39
- package/opus/silk/arm/macros_armv4.h +0 -110
- package/opus/silk/arm/macros_armv5e.h +0 -220
- package/opus/silk/biquad_alt.c +0 -121
- package/opus/silk/bwexpander.c +0 -51
- package/opus/silk/bwexpander_32.c +0 -51
- package/opus/silk/check_control_input.c +0 -106
- package/opus/silk/code_signs.c +0 -115
- package/opus/silk/control.h +0 -161
- package/opus/silk/control_SNR.c +0 -113
- package/opus/silk/control_audio_bandwidth.c +0 -132
- package/opus/silk/control_codec.c +0 -423
- package/opus/silk/debug.c +0 -174
- package/opus/silk/debug.h +0 -267
- package/opus/silk/dec_API.c +0 -465
- package/opus/silk/decode_core.c +0 -243
- package/opus/silk/decode_frame.c +0 -169
- package/opus/silk/decode_indices.c +0 -151
- package/opus/silk/decode_parameters.c +0 -115
- package/opus/silk/decode_pitch.c +0 -77
- package/opus/silk/decode_pulses.c +0 -115
- package/opus/silk/decoder_set_fs.c +0 -108
- package/opus/silk/define.h +0 -235
- package/opus/silk/enc_API.c +0 -593
- package/opus/silk/encode_indices.c +0 -181
- package/opus/silk/encode_pulses.c +0 -206
- package/opus/silk/errors.h +0 -98
- package/opus/silk/fixed/LTP_analysis_filter_FIX.c +0 -90
- package/opus/silk/fixed/LTP_scale_ctrl_FIX.c +0 -58
- package/opus/silk/fixed/apply_sine_window_FIX.c +0 -101
- package/opus/silk/fixed/arm/warped_autocorrelation_FIX_arm.h +0 -68
- package/opus/silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c +0 -265
- package/opus/silk/fixed/autocorr_FIX.c +0 -48
- package/opus/silk/fixed/burg_modified_FIX.c +0 -280
- package/opus/silk/fixed/corrMatrix_FIX.c +0 -150
- package/opus/silk/fixed/encode_frame_FIX.c +0 -444
- package/opus/silk/fixed/find_LPC_FIX.c +0 -151
- package/opus/silk/fixed/find_LTP_FIX.c +0 -99
- package/opus/silk/fixed/find_pitch_lags_FIX.c +0 -143
- package/opus/silk/fixed/find_pred_coefs_FIX.c +0 -146
- package/opus/silk/fixed/k2a_FIX.c +0 -54
- package/opus/silk/fixed/k2a_Q16_FIX.c +0 -54
- package/opus/silk/fixed/main_FIX.h +0 -244
- package/opus/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h +0 -336
- package/opus/silk/fixed/mips/prefilter_FIX_mipsr1.h +0 -184
- package/opus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h +0 -165
- package/opus/silk/fixed/noise_shape_analysis_FIX.c +0 -407
- package/opus/silk/fixed/pitch_analysis_core_FIX.c +0 -721
- package/opus/silk/fixed/process_gains_FIX.c +0 -117
- package/opus/silk/fixed/regularize_correlations_FIX.c +0 -47
- package/opus/silk/fixed/residual_energy16_FIX.c +0 -103
- package/opus/silk/fixed/residual_energy_FIX.c +0 -98
- package/opus/silk/fixed/schur64_FIX.c +0 -93
- package/opus/silk/fixed/schur_FIX.c +0 -107
- package/opus/silk/fixed/structs_FIX.h +0 -116
- package/opus/silk/fixed/vector_ops_FIX.c +0 -102
- package/opus/silk/fixed/warped_autocorrelation_FIX.c +0 -92
- package/opus/silk/fixed/x86/burg_modified_FIX_sse4_1.c +0 -400
- package/opus/silk/fixed/x86/vector_ops_FIX_sse4_1.c +0 -93
- package/opus/silk/float/LPC_analysis_filter_FLP.c +0 -249
- package/opus/silk/float/LPC_inv_pred_gain_FLP.c +0 -73
- package/opus/silk/float/LTP_analysis_filter_FLP.c +0 -75
- package/opus/silk/float/LTP_scale_ctrl_FLP.c +0 -58
- package/opus/silk/float/SigProc_FLP.h +0 -205
- package/opus/silk/float/apply_sine_window_FLP.c +0 -81
- package/opus/silk/float/autocorrelation_FLP.c +0 -53
- package/opus/silk/float/burg_modified_FLP.c +0 -187
- package/opus/silk/float/bwexpander_FLP.c +0 -49
- package/opus/silk/float/corrMatrix_FLP.c +0 -95
- package/opus/silk/float/encode_frame_FLP.c +0 -432
- package/opus/silk/float/energy_FLP.c +0 -59
- package/opus/silk/float/find_LPC_FLP.c +0 -105
- package/opus/silk/float/find_LTP_FLP.c +0 -65
- package/opus/silk/float/find_pitch_lags_FLP.c +0 -132
- package/opus/silk/float/find_pred_coefs_FLP.c +0 -117
- package/opus/silk/float/inner_product_FLP.c +0 -59
- package/opus/silk/float/k2a_FLP.c +0 -54
- package/opus/silk/float/main_FLP.h +0 -290
- package/opus/silk/float/noise_shape_analysis_FLP.c +0 -350
- package/opus/silk/float/pitch_analysis_core_FLP.c +0 -630
- package/opus/silk/float/process_gains_FLP.c +0 -103
- package/opus/silk/float/regularize_correlations_FLP.c +0 -48
- package/opus/silk/float/residual_energy_FLP.c +0 -117
- package/opus/silk/float/scale_copy_vector_FLP.c +0 -57
- package/opus/silk/float/scale_vector_FLP.c +0 -56
- package/opus/silk/float/schur_FLP.c +0 -70
- package/opus/silk/float/sort_FLP.c +0 -83
- package/opus/silk/float/structs_FLP.h +0 -112
- package/opus/silk/float/warped_autocorrelation_FLP.c +0 -75
- package/opus/silk/float/wrappers_FLP.c +0 -209
- package/opus/silk/float/x86/inner_product_FLP_avx2.c +0 -85
- package/opus/silk/gain_quant.c +0 -142
- package/opus/silk/init_decoder.c +0 -84
- package/opus/silk/init_encoder.c +0 -68
- package/opus/silk/inner_prod_aligned.c +0 -47
- package/opus/silk/interpolate.c +0 -51
- package/opus/silk/lin2log.c +0 -46
- package/opus/silk/log2lin.c +0 -58
- package/opus/silk/macros.h +0 -151
- package/opus/silk/main.h +0 -486
- package/opus/silk/meson.build +0 -69
- package/opus/silk/mips/NSQ_del_dec_mipsr1.h +0 -410
- package/opus/silk/mips/macros_mipsr1.h +0 -92
- package/opus/silk/mips/sigproc_fix_mipsr1.h +0 -60
- package/opus/silk/pitch_est_defines.h +0 -88
- package/opus/silk/pitch_est_tables.c +0 -99
- package/opus/silk/process_NLSFs.c +0 -107
- package/opus/silk/quant_LTP_gains.c +0 -132
- package/opus/silk/resampler.c +0 -215
- package/opus/silk/resampler_down2.c +0 -74
- package/opus/silk/resampler_down2_3.c +0 -103
- package/opus/silk/resampler_private.h +0 -88
- package/opus/silk/resampler_private_AR2.c +0 -55
- package/opus/silk/resampler_private_IIR_FIR.c +0 -107
- package/opus/silk/resampler_private_down_FIR.c +0 -194
- package/opus/silk/resampler_private_up2_HQ.c +0 -113
- package/opus/silk/resampler_rom.c +0 -96
- package/opus/silk/resampler_rom.h +0 -68
- package/opus/silk/resampler_structs.h +0 -60
- package/opus/silk/shell_coder.c +0 -151
- package/opus/silk/sigm_Q15.c +0 -76
- package/opus/silk/sort.c +0 -154
- package/opus/silk/stereo_LR_to_MS.c +0 -229
- package/opus/silk/stereo_MS_to_LR.c +0 -85
- package/opus/silk/stereo_decode_pred.c +0 -73
- package/opus/silk/stereo_encode_pred.c +0 -62
- package/opus/silk/stereo_find_predictor.c +0 -79
- package/opus/silk/stereo_quant_pred.c +0 -73
- package/opus/silk/structs.h +0 -357
- package/opus/silk/sum_sqr_shift.c +0 -83
- package/opus/silk/table_LSF_cos.c +0 -70
- package/opus/silk/tables.h +0 -114
- package/opus/silk/tables_LTP.c +0 -294
- package/opus/silk/tables_NLSF_CB_NB_MB.c +0 -195
- package/opus/silk/tables_NLSF_CB_WB.c +0 -234
- package/opus/silk/tables_gain.c +0 -63
- package/opus/silk/tables_other.c +0 -124
- package/opus/silk/tables_pitch_lag.c +0 -69
- package/opus/silk/tables_pulses_per_block.c +0 -264
- package/opus/silk/tests/meson.build +0 -8
- package/opus/silk/tests/test_unit_LPC_inv_pred_gain.c +0 -130
- package/opus/silk/tuning_parameters.h +0 -155
- package/opus/silk/typedef.h +0 -81
- package/opus/silk/x86/NSQ_del_dec_avx2.c +0 -1075
- package/opus/silk/x86/NSQ_del_dec_sse4_1.c +0 -915
- package/opus/silk/x86/NSQ_sse4_1.c +0 -772
- package/opus/silk/x86/SigProc_FIX_sse.h +0 -99
- package/opus/silk/x86/VAD_sse4_1.c +0 -289
- package/opus/silk/x86/VQ_WMat_EC_sse4_1.c +0 -173
- package/opus/silk/x86/main_sse.h +0 -299
- package/opus/silk/x86/x86_silk_map.c +0 -179
- package/opus/silk_headers.mk +0 -44
- package/opus/silk_sources.mk +0 -164
- package/opus/src/analysis.c +0 -979
- package/opus/src/analysis.h +0 -103
- package/opus/src/extensions.c +0 -663
- package/opus/src/mapping_matrix.c +0 -993
- package/opus/src/mapping_matrix.h +0 -165
- package/opus/src/meson.build +0 -45
- package/opus/src/mlp.c +0 -132
- package/opus/src/mlp.h +0 -60
- package/opus/src/mlp_data.c +0 -672
- package/opus/src/opus.c +0 -362
- package/opus/src/opus_compare.c +0 -382
- package/opus/src/opus_decoder.c +0 -1579
- package/opus/src/opus_demo.c +0 -1194
- package/opus/src/opus_encoder.c +0 -3180
- package/opus/src/opus_multistream.c +0 -92
- package/opus/src/opus_multistream_decoder.c +0 -563
- package/opus/src/opus_multistream_encoder.c +0 -1321
- package/opus/src/opus_private.h +0 -263
- package/opus/src/opus_projection_decoder.c +0 -283
- package/opus/src/opus_projection_encoder.c +0 -522
- package/opus/src/repacketizer.c +0 -469
- package/opus/src/repacketizer_demo.c +0 -247
- package/opus/src/tansig_table.h +0 -45
- package/opus/tar_list.txt +0 -28
- package/opus/tests/meson.build +0 -39
- package/opus/tests/opus_build_test.sh +0 -29
- package/opus/tests/opus_decode_fuzzer.c +0 -124
- package/opus/tests/opus_decode_fuzzer.options +0 -2
- package/opus/tests/opus_encode_regressions.c +0 -1034
- package/opus/tests/random_config.sh +0 -126
- package/opus/tests/run_vectors.sh +0 -143
- package/opus/tests/test_opus_api.c +0 -1904
- package/opus/tests/test_opus_common.h +0 -86
- package/opus/tests/test_opus_custom.c +0 -694
- package/opus/tests/test_opus_decode.c +0 -481
- package/opus/tests/test_opus_dred.c +0 -107
- package/opus/tests/test_opus_encode.c +0 -738
- package/opus/tests/test_opus_extensions.c +0 -750
- package/opus/tests/test_opus_padding.c +0 -94
- package/opus/tests/test_opus_projection.c +0 -384
- package/opus/training/rnn_dump.py +0 -66
- package/opus/training/rnn_train.py +0 -177
- package/opus/training/txt2hdf5.py +0 -12
- package/opus/update_version +0 -65
- package/test.mp4 +0 -0
|
@@ -1,1904 +0,0 @@
|
|
|
1
|
-
/* Copyright (c) 2011-2013 Xiph.Org Foundation
|
|
2
|
-
Written by Gregory Maxwell */
|
|
3
|
-
/*
|
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
|
5
|
-
modification, are permitted provided that the following conditions
|
|
6
|
-
are met:
|
|
7
|
-
|
|
8
|
-
- Redistributions of source code must retain the above copyright
|
|
9
|
-
notice, this list of conditions and the following disclaimer.
|
|
10
|
-
|
|
11
|
-
- Redistributions in binary form must reproduce the above copyright
|
|
12
|
-
notice, this list of conditions and the following disclaimer in the
|
|
13
|
-
documentation and/or other materials provided with the distribution.
|
|
14
|
-
|
|
15
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
16
|
-
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
17
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
18
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
19
|
-
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
-
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
-
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
22
|
-
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/* This tests the API presented by the libopus system.
|
|
29
|
-
It does not attempt to extensively exercise the codec internals.
|
|
30
|
-
The strategy here is to simply the API interface invariants:
|
|
31
|
-
That sane options are accepted, insane options are rejected,
|
|
32
|
-
and that nothing blows up. In particular we don't actually test
|
|
33
|
-
that settings are heeded by the codec (though we do check that
|
|
34
|
-
get after set returns a sane value when it should). Other
|
|
35
|
-
tests check the actual codec behavior.
|
|
36
|
-
In cases where its reasonable to do so we test exhaustively,
|
|
37
|
-
but its not reasonable to do so in all cases.
|
|
38
|
-
Although these tests are simple they found several library bugs
|
|
39
|
-
when they were initially developed. */
|
|
40
|
-
|
|
41
|
-
/* These tests are more sensitive if compiled with -DVALGRIND and
|
|
42
|
-
run inside valgrind. Malloc failure testing requires glibc. */
|
|
43
|
-
|
|
44
|
-
#ifdef HAVE_CONFIG_H
|
|
45
|
-
#include "config.h"
|
|
46
|
-
#endif
|
|
47
|
-
|
|
48
|
-
#include <stdio.h>
|
|
49
|
-
#include <stdlib.h>
|
|
50
|
-
#include <stdint.h>
|
|
51
|
-
#include <string.h>
|
|
52
|
-
#include "arch.h"
|
|
53
|
-
#include "opus_multistream.h"
|
|
54
|
-
#include "opus.h"
|
|
55
|
-
#include "test_opus_common.h"
|
|
56
|
-
|
|
57
|
-
#ifdef VALGRIND
|
|
58
|
-
#include <valgrind/memcheck.h>
|
|
59
|
-
#define VG_UNDEF(x,y) VALGRIND_MAKE_MEM_UNDEFINED((x),(y))
|
|
60
|
-
#define VG_CHECK(x,y) VALGRIND_CHECK_MEM_IS_DEFINED((x),(y))
|
|
61
|
-
#else
|
|
62
|
-
#define VG_UNDEF(x,y)
|
|
63
|
-
#define VG_CHECK(x,y)
|
|
64
|
-
#endif
|
|
65
|
-
|
|
66
|
-
#if defined(HAVE___MALLOC_HOOK)
|
|
67
|
-
#define MALLOC_FAIL
|
|
68
|
-
#include "os_support.h"
|
|
69
|
-
#include <malloc.h>
|
|
70
|
-
|
|
71
|
-
static const opus_int32 opus_apps[3] = {OPUS_APPLICATION_VOIP,
|
|
72
|
-
OPUS_APPLICATION_AUDIO,OPUS_APPLICATION_RESTRICTED_LOWDELAY};
|
|
73
|
-
|
|
74
|
-
void *malloc_hook(__attribute__((unused)) size_t size,
|
|
75
|
-
__attribute__((unused)) const void *caller)
|
|
76
|
-
{
|
|
77
|
-
return 0;
|
|
78
|
-
}
|
|
79
|
-
#endif
|
|
80
|
-
|
|
81
|
-
opus_int32 *null_int_ptr = (opus_int32 *)NULL;
|
|
82
|
-
opus_uint32 *null_uint_ptr = (opus_uint32 *)NULL;
|
|
83
|
-
|
|
84
|
-
static const opus_int32 opus_rates[5] = {48000,24000,16000,12000,8000};
|
|
85
|
-
|
|
86
|
-
opus_int32 test_dec_api(void)
|
|
87
|
-
{
|
|
88
|
-
opus_uint32 dec_final_range;
|
|
89
|
-
OpusDecoder *dec;
|
|
90
|
-
OpusDecoder *dec2;
|
|
91
|
-
opus_int32 i,j,cfgs;
|
|
92
|
-
unsigned char packet[1276];
|
|
93
|
-
#ifndef DISABLE_FLOAT_API
|
|
94
|
-
float fbuf[960*2];
|
|
95
|
-
#endif
|
|
96
|
-
short sbuf[960*2];
|
|
97
|
-
int c,err;
|
|
98
|
-
|
|
99
|
-
cfgs=0;
|
|
100
|
-
/*First test invalid configurations which should fail*/
|
|
101
|
-
fprintf(stdout,"\n Decoder basic API tests\n");
|
|
102
|
-
fprintf(stdout," ---------------------------------------------------\n");
|
|
103
|
-
for(c=0;c<4;c++)
|
|
104
|
-
{
|
|
105
|
-
i=opus_decoder_get_size(c);
|
|
106
|
-
if(((c==1||c==2)&&(i<=2048||i>1<<18))||((c!=1&&c!=2)&&i!=0))test_failed();
|
|
107
|
-
fprintf(stdout," opus_decoder_get_size(%d)=%d ...............%s OK.\n",c,i,i>0?"":"....");
|
|
108
|
-
cfgs++;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/*Test with unsupported sample rates*/
|
|
112
|
-
for(c=0;c<4;c++)
|
|
113
|
-
{
|
|
114
|
-
for(i=-7;i<=96000;i++)
|
|
115
|
-
{
|
|
116
|
-
int fs;
|
|
117
|
-
if((i==8000||i==12000||i==16000||i==24000||i==48000)&&(c==1||c==2))continue;
|
|
118
|
-
switch(i)
|
|
119
|
-
{
|
|
120
|
-
case(-5):fs=-8000;break;
|
|
121
|
-
case(-6):fs=INT32_MAX;break;
|
|
122
|
-
case(-7):fs=INT32_MIN;break;
|
|
123
|
-
default:fs=i;
|
|
124
|
-
}
|
|
125
|
-
err = OPUS_OK;
|
|
126
|
-
VG_UNDEF(&err,sizeof(err));
|
|
127
|
-
dec = opus_decoder_create(fs, c, &err);
|
|
128
|
-
if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed();
|
|
129
|
-
cfgs++;
|
|
130
|
-
dec = opus_decoder_create(fs, c, 0);
|
|
131
|
-
if(dec!=NULL)test_failed();
|
|
132
|
-
cfgs++;
|
|
133
|
-
dec=malloc(opus_decoder_get_size(2));
|
|
134
|
-
if(dec==NULL)test_failed();
|
|
135
|
-
err = opus_decoder_init(dec,fs,c);
|
|
136
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
137
|
-
cfgs++;
|
|
138
|
-
free(dec);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
VG_UNDEF(&err,sizeof(err));
|
|
143
|
-
dec = opus_decoder_create(48000, 2, &err);
|
|
144
|
-
if(err!=OPUS_OK || dec==NULL)test_failed();
|
|
145
|
-
VG_CHECK(dec,opus_decoder_get_size(2));
|
|
146
|
-
cfgs++;
|
|
147
|
-
|
|
148
|
-
fprintf(stdout," opus_decoder_create() ........................ OK.\n");
|
|
149
|
-
fprintf(stdout," opus_decoder_init() .......................... OK.\n");
|
|
150
|
-
|
|
151
|
-
err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(null_uint_ptr));
|
|
152
|
-
if(err != OPUS_BAD_ARG)test_failed();
|
|
153
|
-
VG_UNDEF(&dec_final_range,sizeof(dec_final_range));
|
|
154
|
-
err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range));
|
|
155
|
-
if(err!=OPUS_OK)test_failed();
|
|
156
|
-
VG_CHECK(&dec_final_range,sizeof(dec_final_range));
|
|
157
|
-
fprintf(stdout," OPUS_GET_FINAL_RANGE ......................... OK.\n");
|
|
158
|
-
cfgs++;
|
|
159
|
-
|
|
160
|
-
err=opus_decoder_ctl(dec,OPUS_UNIMPLEMENTED);
|
|
161
|
-
if(err!=OPUS_UNIMPLEMENTED)test_failed();
|
|
162
|
-
fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n");
|
|
163
|
-
cfgs++;
|
|
164
|
-
|
|
165
|
-
err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH(null_int_ptr));
|
|
166
|
-
if(err != OPUS_BAD_ARG)test_failed();
|
|
167
|
-
VG_UNDEF(&i,sizeof(i));
|
|
168
|
-
err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH(&i));
|
|
169
|
-
if(err != OPUS_OK || i!=0)test_failed();
|
|
170
|
-
fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n");
|
|
171
|
-
cfgs++;
|
|
172
|
-
|
|
173
|
-
err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE(null_int_ptr));
|
|
174
|
-
if(err != OPUS_BAD_ARG)test_failed();
|
|
175
|
-
VG_UNDEF(&i,sizeof(i));
|
|
176
|
-
err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE(&i));
|
|
177
|
-
if(err != OPUS_OK || i!=48000)test_failed();
|
|
178
|
-
fprintf(stdout," OPUS_GET_SAMPLE_RATE ......................... OK.\n");
|
|
179
|
-
cfgs++;
|
|
180
|
-
|
|
181
|
-
/*GET_PITCH has different execution paths depending on the previously decoded frame.*/
|
|
182
|
-
err=opus_decoder_ctl(dec, OPUS_GET_PITCH(null_int_ptr));
|
|
183
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
184
|
-
cfgs++;
|
|
185
|
-
VG_UNDEF(&i,sizeof(i));
|
|
186
|
-
err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i));
|
|
187
|
-
if(err != OPUS_OK || i>0 || i<-1)test_failed();
|
|
188
|
-
cfgs++;
|
|
189
|
-
VG_UNDEF(packet,sizeof(packet));
|
|
190
|
-
packet[0]=63<<2;packet[1]=packet[2]=0;
|
|
191
|
-
if(opus_decode(dec, packet, 3, sbuf, 960, 0)!=960)test_failed();
|
|
192
|
-
cfgs++;
|
|
193
|
-
VG_UNDEF(&i,sizeof(i));
|
|
194
|
-
err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i));
|
|
195
|
-
if(err != OPUS_OK || i>0 || i<-1)test_failed();
|
|
196
|
-
cfgs++;
|
|
197
|
-
packet[0]=1;
|
|
198
|
-
if(opus_decode(dec, packet, 1, sbuf, 960, 0)!=960)test_failed();
|
|
199
|
-
cfgs++;
|
|
200
|
-
VG_UNDEF(&i,sizeof(i));
|
|
201
|
-
err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i));
|
|
202
|
-
if(err != OPUS_OK || i>0 || i<-1)test_failed();
|
|
203
|
-
cfgs++;
|
|
204
|
-
fprintf(stdout," OPUS_GET_PITCH ............................... OK.\n");
|
|
205
|
-
|
|
206
|
-
err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(null_int_ptr));
|
|
207
|
-
if(err != OPUS_BAD_ARG)test_failed();
|
|
208
|
-
VG_UNDEF(&i,sizeof(i));
|
|
209
|
-
err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&i));
|
|
210
|
-
if(err != OPUS_OK || i!=960)test_failed();
|
|
211
|
-
cfgs++;
|
|
212
|
-
fprintf(stdout," OPUS_GET_LAST_PACKET_DURATION ................ OK.\n");
|
|
213
|
-
|
|
214
|
-
VG_UNDEF(&i,sizeof(i));
|
|
215
|
-
err=opus_decoder_ctl(dec, OPUS_GET_GAIN(&i));
|
|
216
|
-
VG_CHECK(&i,sizeof(i));
|
|
217
|
-
if(err != OPUS_OK || i!=0)test_failed();
|
|
218
|
-
cfgs++;
|
|
219
|
-
err=opus_decoder_ctl(dec, OPUS_GET_GAIN(null_int_ptr));
|
|
220
|
-
if(err != OPUS_BAD_ARG)test_failed();
|
|
221
|
-
cfgs++;
|
|
222
|
-
err=opus_decoder_ctl(dec, OPUS_SET_GAIN(-32769));
|
|
223
|
-
if(err != OPUS_BAD_ARG)test_failed();
|
|
224
|
-
cfgs++;
|
|
225
|
-
err=opus_decoder_ctl(dec, OPUS_SET_GAIN(32768));
|
|
226
|
-
if(err != OPUS_BAD_ARG)test_failed();
|
|
227
|
-
cfgs++;
|
|
228
|
-
err=opus_decoder_ctl(dec, OPUS_SET_GAIN(-15));
|
|
229
|
-
if(err != OPUS_OK)test_failed();
|
|
230
|
-
cfgs++;
|
|
231
|
-
VG_UNDEF(&i,sizeof(i));
|
|
232
|
-
err=opus_decoder_ctl(dec, OPUS_GET_GAIN(&i));
|
|
233
|
-
VG_CHECK(&i,sizeof(i));
|
|
234
|
-
if(err != OPUS_OK || i!=-15)test_failed();
|
|
235
|
-
cfgs++;
|
|
236
|
-
fprintf(stdout," OPUS_SET_GAIN ................................ OK.\n");
|
|
237
|
-
fprintf(stdout," OPUS_GET_GAIN ................................ OK.\n");
|
|
238
|
-
|
|
239
|
-
/*Reset the decoder*/
|
|
240
|
-
dec2=malloc(opus_decoder_get_size(2));
|
|
241
|
-
memcpy(dec2,dec,opus_decoder_get_size(2));
|
|
242
|
-
if(opus_decoder_ctl(dec, OPUS_RESET_STATE)!=OPUS_OK)test_failed();
|
|
243
|
-
if(memcmp(dec2,dec,opus_decoder_get_size(2))==0)test_failed();
|
|
244
|
-
free(dec2);
|
|
245
|
-
fprintf(stdout," OPUS_RESET_STATE ............................. OK.\n");
|
|
246
|
-
cfgs++;
|
|
247
|
-
|
|
248
|
-
VG_UNDEF(packet,sizeof(packet));
|
|
249
|
-
packet[0]=0;
|
|
250
|
-
if(opus_decoder_get_nb_samples(dec,packet,1)!=480)test_failed();
|
|
251
|
-
if(opus_packet_get_nb_samples(packet,1,48000)!=480)test_failed();
|
|
252
|
-
if(opus_packet_get_nb_samples(packet,1,96000)!=960)test_failed();
|
|
253
|
-
if(opus_packet_get_nb_samples(packet,1,32000)!=320)test_failed();
|
|
254
|
-
if(opus_packet_get_nb_samples(packet,1,8000)!=80)test_failed();
|
|
255
|
-
packet[0]=3;
|
|
256
|
-
if(opus_packet_get_nb_samples(packet,1,24000)!=OPUS_INVALID_PACKET)test_failed();
|
|
257
|
-
packet[0]=(63<<2)|3;
|
|
258
|
-
packet[1]=63;
|
|
259
|
-
if(opus_packet_get_nb_samples(packet,0,24000)!=OPUS_BAD_ARG)test_failed();
|
|
260
|
-
if(opus_packet_get_nb_samples(packet,2,48000)!=OPUS_INVALID_PACKET)test_failed();
|
|
261
|
-
if(opus_decoder_get_nb_samples(dec,packet,2)!=OPUS_INVALID_PACKET)test_failed();
|
|
262
|
-
fprintf(stdout," opus_{packet,decoder}_get_nb_samples() ....... OK.\n");
|
|
263
|
-
cfgs+=9;
|
|
264
|
-
|
|
265
|
-
if(OPUS_BAD_ARG!=opus_packet_get_nb_frames(packet,0))test_failed();
|
|
266
|
-
for(i=0;i<256;i++) {
|
|
267
|
-
int l1res[4]={1,2,2,OPUS_INVALID_PACKET};
|
|
268
|
-
packet[0]=i;
|
|
269
|
-
if(l1res[packet[0]&3]!=opus_packet_get_nb_frames(packet,1))test_failed();
|
|
270
|
-
cfgs++;
|
|
271
|
-
for(j=0;j<256;j++) {
|
|
272
|
-
packet[1]=j;
|
|
273
|
-
if(((packet[0]&3)!=3?l1res[packet[0]&3]:packet[1]&63)!=opus_packet_get_nb_frames(packet,2))test_failed();
|
|
274
|
-
cfgs++;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
fprintf(stdout," opus_packet_get_nb_frames() .................. OK.\n");
|
|
278
|
-
|
|
279
|
-
for(i=0;i<256;i++) {
|
|
280
|
-
int bw;
|
|
281
|
-
packet[0]=i;
|
|
282
|
-
bw=packet[0]>>4;
|
|
283
|
-
bw=OPUS_BANDWIDTH_NARROWBAND+(((((bw&7)*9)&(63-(bw&8)))+2+12*((bw&8)!=0))>>4);
|
|
284
|
-
if(bw!=opus_packet_get_bandwidth(packet))test_failed();
|
|
285
|
-
cfgs++;
|
|
286
|
-
}
|
|
287
|
-
fprintf(stdout," opus_packet_get_bandwidth() .................. OK.\n");
|
|
288
|
-
|
|
289
|
-
for(i=0;i<256;i++) {
|
|
290
|
-
int fp3s,rate;
|
|
291
|
-
packet[0]=i;
|
|
292
|
-
fp3s=packet[0]>>3;
|
|
293
|
-
fp3s=((((3-(fp3s&3))*13&119)+9)>>2)*((fp3s>13)*(3-((fp3s&3)==3))+1)*25;
|
|
294
|
-
for(rate=0;rate<5;rate++) {
|
|
295
|
-
if((opus_rates[rate]*3/fp3s)!=opus_packet_get_samples_per_frame(packet,opus_rates[rate]))test_failed();
|
|
296
|
-
cfgs++;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
fprintf(stdout," opus_packet_get_samples_per_frame() .......... OK.\n");
|
|
300
|
-
|
|
301
|
-
packet[0]=(63<<2)+3;
|
|
302
|
-
packet[1]=49;
|
|
303
|
-
for(j=2;j<51;j++)packet[j]=0;
|
|
304
|
-
VG_UNDEF(sbuf,sizeof(sbuf));
|
|
305
|
-
if(opus_decode(dec, packet, 51, sbuf, 960, 0)!=OPUS_INVALID_PACKET)test_failed();
|
|
306
|
-
cfgs++;
|
|
307
|
-
packet[0]=(63<<2);
|
|
308
|
-
packet[1]=packet[2]=0;
|
|
309
|
-
if(opus_decode(dec, packet, -1, sbuf, 960, 0)!=OPUS_BAD_ARG)test_failed();
|
|
310
|
-
cfgs++;
|
|
311
|
-
if(opus_decode(dec, packet, 3, sbuf, 60, 0)!=OPUS_BUFFER_TOO_SMALL)test_failed();
|
|
312
|
-
cfgs++;
|
|
313
|
-
if(opus_decode(dec, packet, 3, sbuf, 480, 0)!=OPUS_BUFFER_TOO_SMALL)test_failed();
|
|
314
|
-
cfgs++;
|
|
315
|
-
if(opus_decode(dec, packet, 3, sbuf, 960, 0)!=960)test_failed();
|
|
316
|
-
cfgs++;
|
|
317
|
-
fprintf(stdout," opus_decode() ................................ OK.\n");
|
|
318
|
-
#ifndef DISABLE_FLOAT_API
|
|
319
|
-
VG_UNDEF(fbuf,sizeof(fbuf));
|
|
320
|
-
if(opus_decode_float(dec, packet, 3, fbuf, 960, 0)!=960)test_failed();
|
|
321
|
-
cfgs++;
|
|
322
|
-
fprintf(stdout," opus_decode_float() .......................... OK.\n");
|
|
323
|
-
#endif
|
|
324
|
-
|
|
325
|
-
#if 0
|
|
326
|
-
/*These tests are disabled because the library crashes with null states*/
|
|
327
|
-
if(opus_decoder_ctl(0,OPUS_RESET_STATE) !=OPUS_INVALID_STATE)test_failed();
|
|
328
|
-
if(opus_decoder_init(0,48000,1) !=OPUS_INVALID_STATE)test_failed();
|
|
329
|
-
if(opus_decode(0,packet,1,outbuf,2880,0) !=OPUS_INVALID_STATE)test_failed();
|
|
330
|
-
if(opus_decode_float(0,packet,1,0,2880,0) !=OPUS_INVALID_STATE)test_failed();
|
|
331
|
-
if(opus_decoder_get_nb_samples(0,packet,1) !=OPUS_INVALID_STATE)test_failed();
|
|
332
|
-
if(opus_packet_get_nb_frames(NULL,1) !=OPUS_BAD_ARG)test_failed();
|
|
333
|
-
if(opus_packet_get_bandwidth(NULL) !=OPUS_BAD_ARG)test_failed();
|
|
334
|
-
if(opus_packet_get_samples_per_frame(NULL,48000)!=OPUS_BAD_ARG)test_failed();
|
|
335
|
-
#endif
|
|
336
|
-
opus_decoder_destroy(dec);
|
|
337
|
-
cfgs++;
|
|
338
|
-
fprintf(stdout," All decoder interface tests passed\n");
|
|
339
|
-
fprintf(stdout," (%6d API invocations)\n",cfgs);
|
|
340
|
-
return cfgs;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
opus_int32 test_msdec_api(void)
|
|
344
|
-
{
|
|
345
|
-
opus_uint32 dec_final_range;
|
|
346
|
-
OpusMSDecoder *dec;
|
|
347
|
-
OpusDecoder *streamdec;
|
|
348
|
-
opus_int32 i,j,cfgs;
|
|
349
|
-
unsigned char packet[1276];
|
|
350
|
-
unsigned char mapping[256];
|
|
351
|
-
#ifndef DISABLE_FLOAT_API
|
|
352
|
-
float fbuf[960*2];
|
|
353
|
-
#endif
|
|
354
|
-
short sbuf[960*2];
|
|
355
|
-
int a,b,c,err;
|
|
356
|
-
|
|
357
|
-
mapping[0]=0;
|
|
358
|
-
mapping[1]=1;
|
|
359
|
-
for(i=2;i<256;i++)VG_UNDEF(&mapping[i],sizeof(unsigned char));
|
|
360
|
-
|
|
361
|
-
cfgs=0;
|
|
362
|
-
/*First test invalid configurations which should fail*/
|
|
363
|
-
fprintf(stdout,"\n Multistream decoder basic API tests\n");
|
|
364
|
-
fprintf(stdout," ---------------------------------------------------\n");
|
|
365
|
-
for(a=-1;a<4;a++)
|
|
366
|
-
{
|
|
367
|
-
for(b=-1;b<4;b++)
|
|
368
|
-
{
|
|
369
|
-
i=opus_multistream_decoder_get_size(a,b);
|
|
370
|
-
if(((a>0&&b<=a&&b>=0)&&(i<=2048||i>((1<<18)*a)))||((a<1||b>a||b<0)&&i!=0))test_failed();
|
|
371
|
-
fprintf(stdout," opus_multistream_decoder_get_size(%2d,%2d)=%d %sOK.\n",a,b,i,i>0?"":"... ");
|
|
372
|
-
cfgs++;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/*Test with unsupported sample rates*/
|
|
377
|
-
for(c=1;c<3;c++)
|
|
378
|
-
{
|
|
379
|
-
for(i=-7;i<=96000;i++)
|
|
380
|
-
{
|
|
381
|
-
int fs;
|
|
382
|
-
if((i==8000||i==12000||i==16000||i==24000||i==48000)&&(c==1||c==2))continue;
|
|
383
|
-
switch(i)
|
|
384
|
-
{
|
|
385
|
-
case(-5):fs=-8000;break;
|
|
386
|
-
case(-6):fs=INT32_MAX;break;
|
|
387
|
-
case(-7):fs=INT32_MIN;break;
|
|
388
|
-
default:fs=i;
|
|
389
|
-
}
|
|
390
|
-
err = OPUS_OK;
|
|
391
|
-
VG_UNDEF(&err,sizeof(err));
|
|
392
|
-
dec = opus_multistream_decoder_create(fs, c, 1, c-1, mapping, &err);
|
|
393
|
-
if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed();
|
|
394
|
-
cfgs++;
|
|
395
|
-
dec = opus_multistream_decoder_create(fs, c, 1, c-1, mapping, 0);
|
|
396
|
-
if(dec!=NULL)test_failed();
|
|
397
|
-
cfgs++;
|
|
398
|
-
dec=malloc(opus_multistream_decoder_get_size(1,1));
|
|
399
|
-
if(dec==NULL)test_failed();
|
|
400
|
-
err = opus_multistream_decoder_init(dec,fs,c,1,c-1, mapping);
|
|
401
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
402
|
-
cfgs++;
|
|
403
|
-
free(dec);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
for(c=0;c<2;c++)
|
|
408
|
-
{
|
|
409
|
-
int *ret_err;
|
|
410
|
-
ret_err = c?0:&err;
|
|
411
|
-
|
|
412
|
-
mapping[0]=0;
|
|
413
|
-
mapping[1]=1;
|
|
414
|
-
for(i=2;i<256;i++)VG_UNDEF(&mapping[i],sizeof(unsigned char));
|
|
415
|
-
|
|
416
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
417
|
-
dec = opus_multistream_decoder_create(48000, 2, 1, 0, mapping, ret_err);
|
|
418
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
419
|
-
if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed();
|
|
420
|
-
cfgs++;
|
|
421
|
-
|
|
422
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
423
|
-
mapping[0]=mapping[1]=0;
|
|
424
|
-
dec = opus_multistream_decoder_create(48000, 2, 1, 0, mapping, ret_err);
|
|
425
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
426
|
-
if((ret_err && *ret_err!=OPUS_OK) || dec==NULL)test_failed();
|
|
427
|
-
cfgs++;
|
|
428
|
-
opus_multistream_decoder_destroy(dec);
|
|
429
|
-
cfgs++;
|
|
430
|
-
|
|
431
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
432
|
-
dec = opus_multistream_decoder_create(48000, 1, 4, 1, mapping, ret_err);
|
|
433
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
434
|
-
if((ret_err && *ret_err!=OPUS_OK) || dec==NULL)test_failed();
|
|
435
|
-
cfgs++;
|
|
436
|
-
|
|
437
|
-
err = opus_multistream_decoder_init(dec,48000, 1, 0, 0, mapping);
|
|
438
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
439
|
-
cfgs++;
|
|
440
|
-
|
|
441
|
-
err = opus_multistream_decoder_init(dec,48000, 1, 1, -1, mapping);
|
|
442
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
443
|
-
cfgs++;
|
|
444
|
-
|
|
445
|
-
opus_multistream_decoder_destroy(dec);
|
|
446
|
-
cfgs++;
|
|
447
|
-
|
|
448
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
449
|
-
dec = opus_multistream_decoder_create(48000, 2, 1, 1, mapping, ret_err);
|
|
450
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
451
|
-
if((ret_err && *ret_err!=OPUS_OK) || dec==NULL)test_failed();
|
|
452
|
-
cfgs++;
|
|
453
|
-
opus_multistream_decoder_destroy(dec);
|
|
454
|
-
cfgs++;
|
|
455
|
-
|
|
456
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
457
|
-
dec = opus_multistream_decoder_create(48000, 255, 255, 1, mapping, ret_err);
|
|
458
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
459
|
-
if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed();
|
|
460
|
-
cfgs++;
|
|
461
|
-
|
|
462
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
463
|
-
dec = opus_multistream_decoder_create(48000, -1, 1, 1, mapping, ret_err);
|
|
464
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
465
|
-
if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed();
|
|
466
|
-
cfgs++;
|
|
467
|
-
|
|
468
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
469
|
-
dec = opus_multistream_decoder_create(48000, 0, 1, 1, mapping, ret_err);
|
|
470
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
471
|
-
if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed();
|
|
472
|
-
cfgs++;
|
|
473
|
-
|
|
474
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
475
|
-
dec = opus_multistream_decoder_create(48000, 1, -1, 2, mapping, ret_err);
|
|
476
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
477
|
-
if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed();
|
|
478
|
-
cfgs++;
|
|
479
|
-
|
|
480
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
481
|
-
dec = opus_multistream_decoder_create(48000, 1, -1, -1, mapping, ret_err);
|
|
482
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
483
|
-
if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed();
|
|
484
|
-
cfgs++;
|
|
485
|
-
|
|
486
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
487
|
-
dec = opus_multistream_decoder_create(48000, 256, 255, 1, mapping, ret_err);
|
|
488
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
489
|
-
if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed();
|
|
490
|
-
cfgs++;
|
|
491
|
-
|
|
492
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
493
|
-
dec = opus_multistream_decoder_create(48000, 256, 255, 0, mapping, ret_err);
|
|
494
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
495
|
-
if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed();
|
|
496
|
-
cfgs++;
|
|
497
|
-
|
|
498
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
499
|
-
mapping[0]=255;
|
|
500
|
-
mapping[1]=1;
|
|
501
|
-
mapping[2]=2;
|
|
502
|
-
dec = opus_multistream_decoder_create(48000, 3, 2, 0, mapping, ret_err);
|
|
503
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
504
|
-
if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed();
|
|
505
|
-
cfgs++;
|
|
506
|
-
|
|
507
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
508
|
-
mapping[0]=0;
|
|
509
|
-
mapping[1]=0;
|
|
510
|
-
mapping[2]=0;
|
|
511
|
-
dec = opus_multistream_decoder_create(48000, 3, 2, 1, mapping, ret_err);
|
|
512
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
513
|
-
if((ret_err && *ret_err!=OPUS_OK) || dec==NULL)test_failed();
|
|
514
|
-
cfgs++;
|
|
515
|
-
opus_multistream_decoder_destroy(dec);
|
|
516
|
-
cfgs++;
|
|
517
|
-
|
|
518
|
-
VG_UNDEF(ret_err,sizeof(*ret_err));
|
|
519
|
-
mapping[0]=0;
|
|
520
|
-
mapping[1]=255;
|
|
521
|
-
mapping[2]=1;
|
|
522
|
-
mapping[3]=2;
|
|
523
|
-
mapping[4]=3;
|
|
524
|
-
dec = opus_multistream_decoder_create(48001, 5, 4, 1, mapping, ret_err);
|
|
525
|
-
if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));}
|
|
526
|
-
if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed();
|
|
527
|
-
cfgs++;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
VG_UNDEF(&err,sizeof(err));
|
|
531
|
-
mapping[0]=0;
|
|
532
|
-
mapping[1]=255;
|
|
533
|
-
mapping[2]=1;
|
|
534
|
-
mapping[3]=2;
|
|
535
|
-
dec = opus_multistream_decoder_create(48000, 4, 2, 1, mapping, &err);
|
|
536
|
-
VG_CHECK(&err,sizeof(err));
|
|
537
|
-
if(err!=OPUS_OK || dec==NULL)test_failed();
|
|
538
|
-
cfgs++;
|
|
539
|
-
|
|
540
|
-
fprintf(stdout," opus_multistream_decoder_create() ............ OK.\n");
|
|
541
|
-
fprintf(stdout," opus_multistream_decoder_init() .............. OK.\n");
|
|
542
|
-
|
|
543
|
-
VG_UNDEF(&dec_final_range,sizeof(dec_final_range));
|
|
544
|
-
err=opus_multistream_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range));
|
|
545
|
-
if(err!=OPUS_OK)test_failed();
|
|
546
|
-
VG_CHECK(&dec_final_range,sizeof(dec_final_range));
|
|
547
|
-
fprintf(stdout," OPUS_GET_FINAL_RANGE ......................... OK.\n");
|
|
548
|
-
cfgs++;
|
|
549
|
-
|
|
550
|
-
streamdec=0;
|
|
551
|
-
VG_UNDEF(&streamdec,sizeof(streamdec));
|
|
552
|
-
err=opus_multistream_decoder_ctl(dec, OPUS_MULTISTREAM_GET_DECODER_STATE(-1,&streamdec));
|
|
553
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
554
|
-
cfgs++;
|
|
555
|
-
err=opus_multistream_decoder_ctl(dec, OPUS_MULTISTREAM_GET_DECODER_STATE(1,&streamdec));
|
|
556
|
-
if(err!=OPUS_OK||streamdec==NULL)test_failed();
|
|
557
|
-
VG_CHECK(streamdec,opus_decoder_get_size(1));
|
|
558
|
-
cfgs++;
|
|
559
|
-
err=opus_multistream_decoder_ctl(dec, OPUS_MULTISTREAM_GET_DECODER_STATE(2,&streamdec));
|
|
560
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
561
|
-
cfgs++;
|
|
562
|
-
err=opus_multistream_decoder_ctl(dec, OPUS_MULTISTREAM_GET_DECODER_STATE(0,&streamdec));
|
|
563
|
-
if(err!=OPUS_OK||streamdec==NULL)test_failed();
|
|
564
|
-
VG_CHECK(streamdec,opus_decoder_get_size(1));
|
|
565
|
-
fprintf(stdout," OPUS_MULTISTREAM_GET_DECODER_STATE ........... OK.\n");
|
|
566
|
-
cfgs++;
|
|
567
|
-
|
|
568
|
-
for(j=0;j<2;j++)
|
|
569
|
-
{
|
|
570
|
-
OpusDecoder *od;
|
|
571
|
-
err=opus_multistream_decoder_ctl(dec,OPUS_MULTISTREAM_GET_DECODER_STATE(j,&od));
|
|
572
|
-
if(err != OPUS_OK)test_failed();
|
|
573
|
-
VG_UNDEF(&i,sizeof(i));
|
|
574
|
-
err=opus_decoder_ctl(od, OPUS_GET_GAIN(&i));
|
|
575
|
-
VG_CHECK(&i,sizeof(i));
|
|
576
|
-
if(err != OPUS_OK || i!=0)test_failed();
|
|
577
|
-
cfgs++;
|
|
578
|
-
}
|
|
579
|
-
err=opus_multistream_decoder_ctl(dec,OPUS_SET_GAIN(15));
|
|
580
|
-
if(err!=OPUS_OK)test_failed();
|
|
581
|
-
fprintf(stdout," OPUS_SET_GAIN ................................ OK.\n");
|
|
582
|
-
for(j=0;j<2;j++)
|
|
583
|
-
{
|
|
584
|
-
OpusDecoder *od;
|
|
585
|
-
err=opus_multistream_decoder_ctl(dec,OPUS_MULTISTREAM_GET_DECODER_STATE(j,&od));
|
|
586
|
-
if(err != OPUS_OK)test_failed();
|
|
587
|
-
VG_UNDEF(&i,sizeof(i));
|
|
588
|
-
err=opus_decoder_ctl(od, OPUS_GET_GAIN(&i));
|
|
589
|
-
VG_CHECK(&i,sizeof(i));
|
|
590
|
-
if(err != OPUS_OK || i!=15)test_failed();
|
|
591
|
-
cfgs++;
|
|
592
|
-
}
|
|
593
|
-
fprintf(stdout," OPUS_GET_GAIN ................................ OK.\n");
|
|
594
|
-
|
|
595
|
-
VG_UNDEF(&i,sizeof(i));
|
|
596
|
-
err=opus_multistream_decoder_ctl(dec, OPUS_GET_BANDWIDTH(&i));
|
|
597
|
-
if(err != OPUS_OK || i!=0)test_failed();
|
|
598
|
-
fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n");
|
|
599
|
-
cfgs++;
|
|
600
|
-
|
|
601
|
-
err=opus_multistream_decoder_ctl(dec,OPUS_UNIMPLEMENTED);
|
|
602
|
-
if(err!=OPUS_UNIMPLEMENTED)test_failed();
|
|
603
|
-
fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n");
|
|
604
|
-
cfgs++;
|
|
605
|
-
|
|
606
|
-
#if 0
|
|
607
|
-
/*Currently unimplemented for multistream*/
|
|
608
|
-
/*GET_PITCH has different execution paths depending on the previously decoded frame.*/
|
|
609
|
-
err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(null_int_ptr));
|
|
610
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
611
|
-
cfgs++;
|
|
612
|
-
VG_UNDEF(&i,sizeof(i));
|
|
613
|
-
err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(&i));
|
|
614
|
-
if(err != OPUS_OK || i>0 || i<-1)test_failed();
|
|
615
|
-
cfgs++;
|
|
616
|
-
VG_UNDEF(packet,sizeof(packet));
|
|
617
|
-
packet[0]=63<<2;packet[1]=packet[2]=0;
|
|
618
|
-
if(opus_multistream_decode(dec, packet, 3, sbuf, 960, 0)!=960)test_failed();
|
|
619
|
-
cfgs++;
|
|
620
|
-
VG_UNDEF(&i,sizeof(i));
|
|
621
|
-
err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(&i));
|
|
622
|
-
if(err != OPUS_OK || i>0 || i<-1)test_failed();
|
|
623
|
-
cfgs++;
|
|
624
|
-
packet[0]=1;
|
|
625
|
-
if(opus_multistream_decode(dec, packet, 1, sbuf, 960, 0)!=960)test_failed();
|
|
626
|
-
cfgs++;
|
|
627
|
-
VG_UNDEF(&i,sizeof(i));
|
|
628
|
-
err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(&i));
|
|
629
|
-
if(err != OPUS_OK || i>0 || i<-1)test_failed();
|
|
630
|
-
cfgs++;
|
|
631
|
-
fprintf(stdout," OPUS_GET_PITCH ............................... OK.\n");
|
|
632
|
-
#endif
|
|
633
|
-
|
|
634
|
-
/*Reset the decoder*/
|
|
635
|
-
if(opus_multistream_decoder_ctl(dec, OPUS_RESET_STATE)!=OPUS_OK)test_failed();
|
|
636
|
-
fprintf(stdout," OPUS_RESET_STATE ............................. OK.\n");
|
|
637
|
-
cfgs++;
|
|
638
|
-
|
|
639
|
-
opus_multistream_decoder_destroy(dec);
|
|
640
|
-
cfgs++;
|
|
641
|
-
VG_UNDEF(&err,sizeof(err));
|
|
642
|
-
dec = opus_multistream_decoder_create(48000, 2, 1, 1, mapping, &err);
|
|
643
|
-
if(err!=OPUS_OK || dec==NULL)test_failed();
|
|
644
|
-
cfgs++;
|
|
645
|
-
|
|
646
|
-
packet[0]=(63<<2)+3;
|
|
647
|
-
packet[1]=49;
|
|
648
|
-
for(j=2;j<51;j++)packet[j]=0;
|
|
649
|
-
VG_UNDEF(sbuf,sizeof(sbuf));
|
|
650
|
-
if(opus_multistream_decode(dec, packet, 51, sbuf, 960, 0)!=OPUS_INVALID_PACKET)test_failed();
|
|
651
|
-
cfgs++;
|
|
652
|
-
packet[0]=(63<<2);
|
|
653
|
-
packet[1]=packet[2]=0;
|
|
654
|
-
if(opus_multistream_decode(dec, packet, -1, sbuf, 960, 0)!=OPUS_BAD_ARG){printf("%d\n",opus_multistream_decode(dec, packet, -1, sbuf, 960, 0));test_failed();}
|
|
655
|
-
cfgs++;
|
|
656
|
-
if(opus_multistream_decode(dec, packet, 3, sbuf, -960, 0)!=OPUS_BAD_ARG)test_failed();
|
|
657
|
-
cfgs++;
|
|
658
|
-
if(opus_multistream_decode(dec, packet, 3, sbuf, 60, 0)!=OPUS_BUFFER_TOO_SMALL)test_failed();
|
|
659
|
-
cfgs++;
|
|
660
|
-
if(opus_multistream_decode(dec, packet, 3, sbuf, 480, 0)!=OPUS_BUFFER_TOO_SMALL)test_failed();
|
|
661
|
-
cfgs++;
|
|
662
|
-
if(opus_multistream_decode(dec, packet, 3, sbuf, 960, 0)!=960)test_failed();
|
|
663
|
-
cfgs++;
|
|
664
|
-
fprintf(stdout," opus_multistream_decode() .................... OK.\n");
|
|
665
|
-
#ifndef DISABLE_FLOAT_API
|
|
666
|
-
VG_UNDEF(fbuf,sizeof(fbuf));
|
|
667
|
-
if(opus_multistream_decode_float(dec, packet, 3, fbuf, 960, 0)!=960)test_failed();
|
|
668
|
-
cfgs++;
|
|
669
|
-
fprintf(stdout," opus_multistream_decode_float() .............. OK.\n");
|
|
670
|
-
#endif
|
|
671
|
-
|
|
672
|
-
#if 0
|
|
673
|
-
/*These tests are disabled because the library crashes with null states*/
|
|
674
|
-
if(opus_multistream_decoder_ctl(0,OPUS_RESET_STATE) !=OPUS_INVALID_STATE)test_failed();
|
|
675
|
-
if(opus_multistream_decoder_init(0,48000,1) !=OPUS_INVALID_STATE)test_failed();
|
|
676
|
-
if(opus_multistream_decode(0,packet,1,outbuf,2880,0) !=OPUS_INVALID_STATE)test_failed();
|
|
677
|
-
if(opus_multistream_decode_float(0,packet,1,0,2880,0) !=OPUS_INVALID_STATE)test_failed();
|
|
678
|
-
if(opus_multistream_decoder_get_nb_samples(0,packet,1) !=OPUS_INVALID_STATE)test_failed();
|
|
679
|
-
#endif
|
|
680
|
-
opus_multistream_decoder_destroy(dec);
|
|
681
|
-
cfgs++;
|
|
682
|
-
fprintf(stdout," All multistream decoder interface tests passed\n");
|
|
683
|
-
fprintf(stdout," (%6d API invocations)\n",cfgs);
|
|
684
|
-
return cfgs;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
#ifdef VALGRIND
|
|
688
|
-
#define UNDEFINE_FOR_PARSE toc=-1; \
|
|
689
|
-
frames[0]=(unsigned char *)0; \
|
|
690
|
-
frames[1]=(unsigned char *)0; \
|
|
691
|
-
payload_offset=-1; \
|
|
692
|
-
VG_UNDEF(&toc,sizeof(toc)); \
|
|
693
|
-
VG_UNDEF(frames,sizeof(frames));\
|
|
694
|
-
VG_UNDEF(&payload_offset,sizeof(payload_offset));
|
|
695
|
-
#else
|
|
696
|
-
#define UNDEFINE_FOR_PARSE toc=-1; \
|
|
697
|
-
frames[0]=(unsigned char *)0; \
|
|
698
|
-
frames[1]=(unsigned char *)0; \
|
|
699
|
-
payload_offset=-1;
|
|
700
|
-
#endif
|
|
701
|
-
|
|
702
|
-
/* This test exercises the heck out of the libopus parser.
|
|
703
|
-
It is much larger than the parser itself in part because
|
|
704
|
-
it tries to hit a lot of corner cases that could never
|
|
705
|
-
fail with the libopus code, but might be problematic for
|
|
706
|
-
other implementations. */
|
|
707
|
-
opus_int32 test_parse(void)
|
|
708
|
-
{
|
|
709
|
-
opus_int32 i,j,jj,sz;
|
|
710
|
-
unsigned char packet[1276];
|
|
711
|
-
opus_int32 cfgs,cfgs_total;
|
|
712
|
-
unsigned char toc;
|
|
713
|
-
const unsigned char *frames[48];
|
|
714
|
-
short size[48];
|
|
715
|
-
int payload_offset, ret;
|
|
716
|
-
fprintf(stdout,"\n Packet header parsing tests\n");
|
|
717
|
-
fprintf(stdout," ---------------------------------------------------\n");
|
|
718
|
-
memset(packet,0,sizeof(char)*1276);
|
|
719
|
-
packet[0]=63<<2;
|
|
720
|
-
if(opus_packet_parse(packet,1,&toc,frames,0,&payload_offset)!=OPUS_BAD_ARG)test_failed();
|
|
721
|
-
cfgs_total=cfgs=1;
|
|
722
|
-
/*code 0*/
|
|
723
|
-
for(i=0;i<64;i++)
|
|
724
|
-
{
|
|
725
|
-
packet[0]=i<<2;
|
|
726
|
-
UNDEFINE_FOR_PARSE
|
|
727
|
-
ret=opus_packet_parse(packet,4,&toc,frames,size,&payload_offset);
|
|
728
|
-
cfgs++;
|
|
729
|
-
if(ret!=1)test_failed();
|
|
730
|
-
if(size[0]!=3)test_failed();
|
|
731
|
-
if(frames[0]!=packet+1)test_failed();
|
|
732
|
-
}
|
|
733
|
-
fprintf(stdout," code 0 (%2d cases) ............................ OK.\n",cfgs);
|
|
734
|
-
cfgs_total+=cfgs;cfgs=0;
|
|
735
|
-
|
|
736
|
-
/*code 1, two frames of the same size*/
|
|
737
|
-
for(i=0;i<64;i++)
|
|
738
|
-
{
|
|
739
|
-
packet[0]=(i<<2)+1;
|
|
740
|
-
for(jj=0;jj<=1275*2+3;jj++)
|
|
741
|
-
{
|
|
742
|
-
UNDEFINE_FOR_PARSE
|
|
743
|
-
ret=opus_packet_parse(packet,jj,&toc,frames,size,&payload_offset);
|
|
744
|
-
cfgs++;
|
|
745
|
-
if((jj&1)==1 && jj<=2551)
|
|
746
|
-
{
|
|
747
|
-
/* Must pass if payload length even (packet length odd) and
|
|
748
|
-
size<=2551, must fail otherwise. */
|
|
749
|
-
if(ret!=2)test_failed();
|
|
750
|
-
if(size[0]!=size[1] || size[0]!=((jj-1)>>1))test_failed();
|
|
751
|
-
if(frames[0]!=packet+1)test_failed();
|
|
752
|
-
if(frames[1]!=frames[0]+size[0])test_failed();
|
|
753
|
-
if((toc>>2)!=i)test_failed();
|
|
754
|
-
} else if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
fprintf(stdout," code 1 (%6d cases) ........................ OK.\n",cfgs);
|
|
758
|
-
cfgs_total+=cfgs;cfgs=0;
|
|
759
|
-
|
|
760
|
-
for(i=0;i<64;i++)
|
|
761
|
-
{
|
|
762
|
-
/*code 2, length code overflow*/
|
|
763
|
-
packet[0]=(i<<2)+2;
|
|
764
|
-
UNDEFINE_FOR_PARSE
|
|
765
|
-
ret=opus_packet_parse(packet,1,&toc,frames,size,&payload_offset);
|
|
766
|
-
cfgs++;
|
|
767
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
768
|
-
packet[1]=252;
|
|
769
|
-
UNDEFINE_FOR_PARSE
|
|
770
|
-
ret=opus_packet_parse(packet,2,&toc,frames,size,&payload_offset);
|
|
771
|
-
cfgs++;
|
|
772
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
773
|
-
for(j=0;j<1275;j++)
|
|
774
|
-
{
|
|
775
|
-
if(j<252)packet[1]=j;
|
|
776
|
-
else{packet[1]=252+(j&3);packet[2]=(j-252)>>2;}
|
|
777
|
-
/*Code 2, one too short*/
|
|
778
|
-
UNDEFINE_FOR_PARSE
|
|
779
|
-
ret=opus_packet_parse(packet,j+(j<252?2:3)-1,&toc,frames,size,&payload_offset);
|
|
780
|
-
cfgs++;
|
|
781
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
782
|
-
/*Code 2, one too long*/
|
|
783
|
-
UNDEFINE_FOR_PARSE
|
|
784
|
-
ret=opus_packet_parse(packet,j+(j<252?2:3)+1276,&toc,frames,size,&payload_offset);
|
|
785
|
-
cfgs++;
|
|
786
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
787
|
-
/*Code 2, second zero*/
|
|
788
|
-
UNDEFINE_FOR_PARSE
|
|
789
|
-
ret=opus_packet_parse(packet,j+(j<252?2:3),&toc,frames,size,&payload_offset);
|
|
790
|
-
cfgs++;
|
|
791
|
-
if(ret!=2)test_failed();
|
|
792
|
-
if(size[0]!=j||size[1]!=0)test_failed();
|
|
793
|
-
if(frames[1]!=frames[0]+size[0])test_failed();
|
|
794
|
-
if((toc>>2)!=i)test_failed();
|
|
795
|
-
/*Code 2, normal*/
|
|
796
|
-
UNDEFINE_FOR_PARSE
|
|
797
|
-
ret=opus_packet_parse(packet,(j<<1)+4,&toc,frames,size,&payload_offset);
|
|
798
|
-
cfgs++;
|
|
799
|
-
if(ret!=2)test_failed();
|
|
800
|
-
if(size[0]!=j||size[1]!=(j<<1)+3-j-(j<252?1:2))test_failed();
|
|
801
|
-
if(frames[1]!=frames[0]+size[0])test_failed();
|
|
802
|
-
if((toc>>2)!=i)test_failed();
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
fprintf(stdout," code 2 (%6d cases) ........................ OK.\n",cfgs);
|
|
806
|
-
cfgs_total+=cfgs;cfgs=0;
|
|
807
|
-
|
|
808
|
-
for(i=0;i<64;i++)
|
|
809
|
-
{
|
|
810
|
-
packet[0]=(i<<2)+3;
|
|
811
|
-
/*code 3, length code overflow*/
|
|
812
|
-
UNDEFINE_FOR_PARSE
|
|
813
|
-
ret=opus_packet_parse(packet,1,&toc,frames,size,&payload_offset);
|
|
814
|
-
cfgs++;
|
|
815
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
816
|
-
}
|
|
817
|
-
fprintf(stdout," code 3 m-truncation (%2d cases) ............... OK.\n",cfgs);
|
|
818
|
-
cfgs_total+=cfgs;cfgs=0;
|
|
819
|
-
|
|
820
|
-
for(i=0;i<64;i++)
|
|
821
|
-
{
|
|
822
|
-
/*code 3, m is zero or 49-63*/
|
|
823
|
-
packet[0]=(i<<2)+3;
|
|
824
|
-
for(jj=49;jj<=64;jj++)
|
|
825
|
-
{
|
|
826
|
-
packet[1]=0+(jj&63); /*CBR, no padding*/
|
|
827
|
-
UNDEFINE_FOR_PARSE
|
|
828
|
-
ret=opus_packet_parse(packet,1275,&toc,frames,size,&payload_offset);
|
|
829
|
-
cfgs++;
|
|
830
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
831
|
-
packet[1]=128+(jj&63); /*VBR, no padding*/
|
|
832
|
-
UNDEFINE_FOR_PARSE
|
|
833
|
-
ret=opus_packet_parse(packet,1275,&toc,frames,size,&payload_offset);
|
|
834
|
-
cfgs++;
|
|
835
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
836
|
-
packet[1]=64+(jj&63); /*CBR, padding*/
|
|
837
|
-
UNDEFINE_FOR_PARSE
|
|
838
|
-
ret=opus_packet_parse(packet,1275,&toc,frames,size,&payload_offset);
|
|
839
|
-
cfgs++;
|
|
840
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
841
|
-
packet[1]=128+64+(jj&63); /*VBR, padding*/
|
|
842
|
-
UNDEFINE_FOR_PARSE
|
|
843
|
-
ret=opus_packet_parse(packet,1275,&toc,frames,size,&payload_offset);
|
|
844
|
-
cfgs++;
|
|
845
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
fprintf(stdout," code 3 m=0,49-64 (%2d cases) ................ OK.\n",cfgs);
|
|
849
|
-
cfgs_total+=cfgs;cfgs=0;
|
|
850
|
-
|
|
851
|
-
for(i=0;i<64;i++)
|
|
852
|
-
{
|
|
853
|
-
packet[0]=(i<<2)+3;
|
|
854
|
-
/*code 3, m is one, cbr*/
|
|
855
|
-
packet[1]=1;
|
|
856
|
-
for(j=0;j<1276;j++)
|
|
857
|
-
{
|
|
858
|
-
UNDEFINE_FOR_PARSE
|
|
859
|
-
ret=opus_packet_parse(packet,j+2,&toc,frames,size,&payload_offset);
|
|
860
|
-
cfgs++;
|
|
861
|
-
if(ret!=1)test_failed();
|
|
862
|
-
if(size[0]!=j)test_failed();
|
|
863
|
-
if((toc>>2)!=i)test_failed();
|
|
864
|
-
}
|
|
865
|
-
UNDEFINE_FOR_PARSE
|
|
866
|
-
ret=opus_packet_parse(packet,1276+2,&toc,frames,size,&payload_offset);
|
|
867
|
-
cfgs++;
|
|
868
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
869
|
-
}
|
|
870
|
-
fprintf(stdout," code 3 m=1 CBR (%2d cases) ................. OK.\n",cfgs);
|
|
871
|
-
cfgs_total+=cfgs;cfgs=0;
|
|
872
|
-
|
|
873
|
-
for(i=0;i<64;i++)
|
|
874
|
-
{
|
|
875
|
-
int frame_samp;
|
|
876
|
-
/*code 3, m>1 CBR*/
|
|
877
|
-
packet[0]=(i<<2)+3;
|
|
878
|
-
frame_samp=opus_packet_get_samples_per_frame(packet,48000);
|
|
879
|
-
for(j=2;j<49;j++)
|
|
880
|
-
{
|
|
881
|
-
packet[1]=j;
|
|
882
|
-
for(sz=2;sz<((j+2)*1275);sz++)
|
|
883
|
-
{
|
|
884
|
-
UNDEFINE_FOR_PARSE
|
|
885
|
-
ret=opus_packet_parse(packet,sz,&toc,frames,size,&payload_offset);
|
|
886
|
-
cfgs++;
|
|
887
|
-
/*Must be <=120ms, must be evenly divisible, can't have frames>1275 bytes*/
|
|
888
|
-
if(frame_samp*j<=5760 && (sz-2)%j==0 && (sz-2)/j<1276)
|
|
889
|
-
{
|
|
890
|
-
if(ret!=j)test_failed();
|
|
891
|
-
for(jj=1;jj<ret;jj++)if(frames[jj]!=frames[jj-1]+size[jj-1])test_failed();
|
|
892
|
-
if((toc>>2)!=i)test_failed();
|
|
893
|
-
} else if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
/*Super jumbo packets*/
|
|
897
|
-
packet[1]=5760/frame_samp;
|
|
898
|
-
UNDEFINE_FOR_PARSE
|
|
899
|
-
ret=opus_packet_parse(packet,1275*packet[1]+2,&toc,frames,size,&payload_offset);
|
|
900
|
-
cfgs++;
|
|
901
|
-
if(ret!=packet[1])test_failed();
|
|
902
|
-
for(jj=0;jj<ret;jj++)if(size[jj]!=1275)test_failed();
|
|
903
|
-
}
|
|
904
|
-
fprintf(stdout," code 3 m=1-48 CBR (%2d cases) .......... OK.\n",cfgs);
|
|
905
|
-
cfgs_total+=cfgs;cfgs=0;
|
|
906
|
-
|
|
907
|
-
for(i=0;i<64;i++)
|
|
908
|
-
{
|
|
909
|
-
int frame_samp;
|
|
910
|
-
/*Code 3 VBR, m one*/
|
|
911
|
-
packet[0]=(i<<2)+3;
|
|
912
|
-
packet[1]=128+1;
|
|
913
|
-
frame_samp=opus_packet_get_samples_per_frame(packet,48000);
|
|
914
|
-
for(jj=0;jj<1276;jj++)
|
|
915
|
-
{
|
|
916
|
-
UNDEFINE_FOR_PARSE
|
|
917
|
-
ret=opus_packet_parse(packet,2+jj,&toc,frames,size,&payload_offset);
|
|
918
|
-
cfgs++;
|
|
919
|
-
if(ret!=1)test_failed();
|
|
920
|
-
if(size[0]!=jj)test_failed();
|
|
921
|
-
if((toc>>2)!=i)test_failed();
|
|
922
|
-
}
|
|
923
|
-
UNDEFINE_FOR_PARSE
|
|
924
|
-
ret=opus_packet_parse(packet,2+1276,&toc,frames,size,&payload_offset);
|
|
925
|
-
cfgs++;
|
|
926
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
927
|
-
for(j=2;j<49;j++)
|
|
928
|
-
{
|
|
929
|
-
packet[1]=128+j;
|
|
930
|
-
/*Length code overflow*/
|
|
931
|
-
UNDEFINE_FOR_PARSE
|
|
932
|
-
ret=opus_packet_parse(packet,2+j-2,&toc,frames,size,&payload_offset);
|
|
933
|
-
cfgs++;
|
|
934
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
935
|
-
packet[2]=252;
|
|
936
|
-
packet[3]=0;
|
|
937
|
-
for(jj=4;jj<2+j;jj++)packet[jj]=0;
|
|
938
|
-
UNDEFINE_FOR_PARSE
|
|
939
|
-
ret=opus_packet_parse(packet,2+j,&toc,frames,size,&payload_offset);
|
|
940
|
-
cfgs++;
|
|
941
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
942
|
-
/*One byte too short*/
|
|
943
|
-
for(jj=2;jj<2+j;jj++)packet[jj]=0;
|
|
944
|
-
UNDEFINE_FOR_PARSE
|
|
945
|
-
ret=opus_packet_parse(packet,2+j-2,&toc,frames,size,&payload_offset);
|
|
946
|
-
cfgs++;
|
|
947
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
948
|
-
/*One byte too short thanks to length coding*/
|
|
949
|
-
packet[2]=252;
|
|
950
|
-
packet[3]=0;
|
|
951
|
-
for(jj=4;jj<2+j;jj++)packet[jj]=0;
|
|
952
|
-
UNDEFINE_FOR_PARSE
|
|
953
|
-
ret=opus_packet_parse(packet,2+j+252-1,&toc,frames,size,&payload_offset);
|
|
954
|
-
cfgs++;
|
|
955
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
956
|
-
/*Most expensive way of coding zeros*/
|
|
957
|
-
for(jj=2;jj<2+j;jj++)packet[jj]=0;
|
|
958
|
-
UNDEFINE_FOR_PARSE
|
|
959
|
-
ret=opus_packet_parse(packet,2+j-1,&toc,frames,size,&payload_offset);
|
|
960
|
-
cfgs++;
|
|
961
|
-
if(frame_samp*j<=5760){
|
|
962
|
-
if(ret!=j)test_failed();
|
|
963
|
-
for(jj=0;jj<j;jj++)if(size[jj]!=0)test_failed();
|
|
964
|
-
if((toc>>2)!=i)test_failed();
|
|
965
|
-
} else if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
966
|
-
/*Quasi-CBR use of mode 3*/
|
|
967
|
-
for(sz=0;sz<8;sz++)
|
|
968
|
-
{
|
|
969
|
-
const int tsz[8]={50,201,403,700,1472,5110,20400,61298};
|
|
970
|
-
int pos=0;
|
|
971
|
-
int as=(tsz[sz]+i-j-2)/j;
|
|
972
|
-
for(jj=0;jj<j-1;jj++)
|
|
973
|
-
{
|
|
974
|
-
if(as<252){packet[2+pos]=as;pos++;}
|
|
975
|
-
else{packet[2+pos]=252+(as&3);packet[3+pos]=(as-252)>>2;pos+=2;}
|
|
976
|
-
}
|
|
977
|
-
UNDEFINE_FOR_PARSE
|
|
978
|
-
ret=opus_packet_parse(packet,tsz[sz]+i,&toc,frames,size,&payload_offset);
|
|
979
|
-
cfgs++;
|
|
980
|
-
if(frame_samp*j<=5760 && as<1276 && (tsz[sz]+i-2-pos-as*(j-1))<1276){
|
|
981
|
-
if(ret!=j)test_failed();
|
|
982
|
-
for(jj=0;jj<j-1;jj++)if(size[jj]!=as)test_failed();
|
|
983
|
-
if(size[j-1]!=(tsz[sz]+i-2-pos-as*(j-1)))test_failed();
|
|
984
|
-
if((toc>>2)!=i)test_failed();
|
|
985
|
-
} else if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
fprintf(stdout," code 3 m=1-48 VBR (%2d cases) ............. OK.\n",cfgs);
|
|
990
|
-
cfgs_total+=cfgs;cfgs=0;
|
|
991
|
-
|
|
992
|
-
for(i=0;i<64;i++)
|
|
993
|
-
{
|
|
994
|
-
packet[0]=(i<<2)+3;
|
|
995
|
-
/*Padding*/
|
|
996
|
-
packet[1]=128+1+64;
|
|
997
|
-
/*Overflow the length coding*/
|
|
998
|
-
for(jj=2;jj<127;jj++)packet[jj]=255;
|
|
999
|
-
UNDEFINE_FOR_PARSE
|
|
1000
|
-
ret=opus_packet_parse(packet,127,&toc,frames,size,&payload_offset);
|
|
1001
|
-
cfgs++;
|
|
1002
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
1003
|
-
|
|
1004
|
-
for(sz=0;sz<4;sz++)
|
|
1005
|
-
{
|
|
1006
|
-
const int tsz[4]={0,72,512,1275};
|
|
1007
|
-
for(jj=sz;jj<65025;jj+=11)
|
|
1008
|
-
{
|
|
1009
|
-
int pos;
|
|
1010
|
-
for(pos=0;pos<jj/254;pos++)packet[2+pos]=255;
|
|
1011
|
-
packet[2+pos]=jj%254;
|
|
1012
|
-
pos++;
|
|
1013
|
-
if(sz==0&&i==63)
|
|
1014
|
-
{
|
|
1015
|
-
/*Code more padding than there is room in the packet*/
|
|
1016
|
-
UNDEFINE_FOR_PARSE
|
|
1017
|
-
ret=opus_packet_parse(packet,2+jj+pos-1,&toc,frames,size,&payload_offset);
|
|
1018
|
-
cfgs++;
|
|
1019
|
-
if(ret!=OPUS_INVALID_PACKET)test_failed();
|
|
1020
|
-
}
|
|
1021
|
-
UNDEFINE_FOR_PARSE
|
|
1022
|
-
ret=opus_packet_parse(packet,2+jj+tsz[sz]+i+pos,&toc,frames,size,&payload_offset);
|
|
1023
|
-
cfgs++;
|
|
1024
|
-
if(tsz[sz]+i<1276)
|
|
1025
|
-
{
|
|
1026
|
-
if(ret!=1)test_failed();
|
|
1027
|
-
if(size[0]!=tsz[sz]+i)test_failed();
|
|
1028
|
-
if((toc>>2)!=i)test_failed();
|
|
1029
|
-
} else if (ret!=OPUS_INVALID_PACKET)test_failed();
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
fprintf(stdout," code 3 padding (%2d cases) ............... OK.\n",cfgs);
|
|
1034
|
-
cfgs_total+=cfgs;
|
|
1035
|
-
fprintf(stdout," opus_packet_parse ............................ OK.\n");
|
|
1036
|
-
fprintf(stdout," All packet parsing tests passed\n");
|
|
1037
|
-
fprintf(stdout," (%d API invocations)\n",cfgs_total);
|
|
1038
|
-
return cfgs_total;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
/* This is a helper macro for the encoder tests.
|
|
1042
|
-
The encoder api tests all have a pattern of set-must-fail, set-must-fail,
|
|
1043
|
-
set-must-pass, get-and-compare, set-must-pass, get-and-compare. */
|
|
1044
|
-
#define CHECK_SETGET(setcall,getcall,badv,badv2,goodv,goodv2,sok,gok) \
|
|
1045
|
-
i=(badv);\
|
|
1046
|
-
if(opus_encoder_ctl(enc,setcall)==OPUS_OK)test_failed();\
|
|
1047
|
-
i=(badv2);\
|
|
1048
|
-
if(opus_encoder_ctl(enc,setcall)==OPUS_OK)test_failed();\
|
|
1049
|
-
j=i=(goodv);\
|
|
1050
|
-
if(opus_encoder_ctl(enc,setcall)!=OPUS_OK)test_failed();\
|
|
1051
|
-
i=-12345;\
|
|
1052
|
-
VG_UNDEF(&i,sizeof(i)); \
|
|
1053
|
-
err=opus_encoder_ctl(enc,getcall);\
|
|
1054
|
-
if(err!=OPUS_OK || i!=j)test_failed();\
|
|
1055
|
-
j=i=(goodv2);\
|
|
1056
|
-
if(opus_encoder_ctl(enc,setcall)!=OPUS_OK)test_failed();\
|
|
1057
|
-
fprintf(stdout,sok);\
|
|
1058
|
-
i=-12345;\
|
|
1059
|
-
VG_UNDEF(&i,sizeof(i)); \
|
|
1060
|
-
err=opus_encoder_ctl(enc,getcall);\
|
|
1061
|
-
if(err!=OPUS_OK || i!=j)test_failed();\
|
|
1062
|
-
fprintf(stdout,gok);\
|
|
1063
|
-
cfgs+=6;
|
|
1064
|
-
|
|
1065
|
-
opus_int32 test_enc_api(void)
|
|
1066
|
-
{
|
|
1067
|
-
opus_uint32 enc_final_range;
|
|
1068
|
-
OpusEncoder *enc;
|
|
1069
|
-
opus_int32 i,j;
|
|
1070
|
-
unsigned char packet[1276];
|
|
1071
|
-
#ifndef DISABLE_FLOAT_API
|
|
1072
|
-
float fbuf[960*2];
|
|
1073
|
-
#endif
|
|
1074
|
-
short sbuf[960*2];
|
|
1075
|
-
int c,err,cfgs;
|
|
1076
|
-
|
|
1077
|
-
cfgs=0;
|
|
1078
|
-
/*First test invalid configurations which should fail*/
|
|
1079
|
-
fprintf(stdout,"\n Encoder basic API tests\n");
|
|
1080
|
-
fprintf(stdout," ---------------------------------------------------\n");
|
|
1081
|
-
for(c=0;c<4;c++)
|
|
1082
|
-
{
|
|
1083
|
-
i=opus_encoder_get_size(c);
|
|
1084
|
-
if(((c==1||c==2)&&(i<=2048||i>1<<18))||((c!=1&&c!=2)&&i!=0))test_failed();
|
|
1085
|
-
fprintf(stdout," opus_encoder_get_size(%d)=%d ...............%s OK.\n",c,i,i>0?"":"....");
|
|
1086
|
-
cfgs++;
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
/*Test with unsupported sample rates, channel counts*/
|
|
1090
|
-
for(c=0;c<4;c++)
|
|
1091
|
-
{
|
|
1092
|
-
for(i=-7;i<=96000;i++)
|
|
1093
|
-
{
|
|
1094
|
-
int fs;
|
|
1095
|
-
if((i==8000||i==12000||i==16000||i==24000||i==48000)&&(c==1||c==2))continue;
|
|
1096
|
-
switch(i)
|
|
1097
|
-
{
|
|
1098
|
-
case(-5):fs=-8000;break;
|
|
1099
|
-
case(-6):fs=INT32_MAX;break;
|
|
1100
|
-
case(-7):fs=INT32_MIN;break;
|
|
1101
|
-
default:fs=i;
|
|
1102
|
-
}
|
|
1103
|
-
err = OPUS_OK;
|
|
1104
|
-
VG_UNDEF(&err,sizeof(err));
|
|
1105
|
-
enc = opus_encoder_create(fs, c, OPUS_APPLICATION_VOIP, &err);
|
|
1106
|
-
if(err!=OPUS_BAD_ARG || enc!=NULL)test_failed();
|
|
1107
|
-
cfgs++;
|
|
1108
|
-
enc = opus_encoder_create(fs, c, OPUS_APPLICATION_VOIP, 0);
|
|
1109
|
-
if(enc!=NULL)test_failed();
|
|
1110
|
-
cfgs++;
|
|
1111
|
-
opus_encoder_destroy(enc);
|
|
1112
|
-
enc=malloc(opus_encoder_get_size(2));
|
|
1113
|
-
if(enc==NULL)test_failed();
|
|
1114
|
-
err = opus_encoder_init(enc, fs, c, OPUS_APPLICATION_VOIP);
|
|
1115
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1116
|
-
cfgs++;
|
|
1117
|
-
free(enc);
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
enc = opus_encoder_create(48000, 2, OPUS_AUTO, NULL);
|
|
1122
|
-
if(enc!=NULL)test_failed();
|
|
1123
|
-
cfgs++;
|
|
1124
|
-
|
|
1125
|
-
VG_UNDEF(&err,sizeof(err));
|
|
1126
|
-
enc = opus_encoder_create(48000, 2, OPUS_AUTO, &err);
|
|
1127
|
-
if(err!=OPUS_BAD_ARG || enc!=NULL)test_failed();
|
|
1128
|
-
cfgs++;
|
|
1129
|
-
|
|
1130
|
-
VG_UNDEF(&err,sizeof(err));
|
|
1131
|
-
enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_VOIP, NULL);
|
|
1132
|
-
if(enc==NULL)test_failed();
|
|
1133
|
-
opus_encoder_destroy(enc);
|
|
1134
|
-
cfgs++;
|
|
1135
|
-
|
|
1136
|
-
VG_UNDEF(&err,sizeof(err));
|
|
1137
|
-
enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_RESTRICTED_LOWDELAY, &err);
|
|
1138
|
-
if(err!=OPUS_OK || enc==NULL)test_failed();
|
|
1139
|
-
cfgs++;
|
|
1140
|
-
err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i));
|
|
1141
|
-
if(err!=OPUS_OK || i<0 || i>32766)test_failed();
|
|
1142
|
-
cfgs++;
|
|
1143
|
-
opus_encoder_destroy(enc);
|
|
1144
|
-
|
|
1145
|
-
VG_UNDEF(&err,sizeof(err));
|
|
1146
|
-
enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_AUDIO, &err);
|
|
1147
|
-
if(err!=OPUS_OK || enc==NULL)test_failed();
|
|
1148
|
-
cfgs++;
|
|
1149
|
-
err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i));
|
|
1150
|
-
if(err!=OPUS_OK || i<0 || i>32766)test_failed();
|
|
1151
|
-
opus_encoder_destroy(enc);
|
|
1152
|
-
cfgs++;
|
|
1153
|
-
|
|
1154
|
-
VG_UNDEF(&err,sizeof(err));
|
|
1155
|
-
enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_VOIP, &err);
|
|
1156
|
-
if(err!=OPUS_OK || enc==NULL)test_failed();
|
|
1157
|
-
cfgs++;
|
|
1158
|
-
|
|
1159
|
-
fprintf(stdout," opus_encoder_create() ........................ OK.\n");
|
|
1160
|
-
fprintf(stdout," opus_encoder_init() .......................... OK.\n");
|
|
1161
|
-
|
|
1162
|
-
i=-12345;
|
|
1163
|
-
VG_UNDEF(&i,sizeof(i));
|
|
1164
|
-
err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i));
|
|
1165
|
-
if(err!=OPUS_OK || i<0 || i>32766)test_failed();
|
|
1166
|
-
cfgs++;
|
|
1167
|
-
err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(null_int_ptr));
|
|
1168
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1169
|
-
cfgs++;
|
|
1170
|
-
fprintf(stdout," OPUS_GET_LOOKAHEAD ........................... OK.\n");
|
|
1171
|
-
|
|
1172
|
-
err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE(&i));
|
|
1173
|
-
if(err!=OPUS_OK || i!=48000)test_failed();
|
|
1174
|
-
cfgs++;
|
|
1175
|
-
err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE(null_int_ptr));
|
|
1176
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1177
|
-
cfgs++;
|
|
1178
|
-
fprintf(stdout," OPUS_GET_SAMPLE_RATE ......................... OK.\n");
|
|
1179
|
-
|
|
1180
|
-
if(opus_encoder_ctl(enc,OPUS_UNIMPLEMENTED)!=OPUS_UNIMPLEMENTED)test_failed();
|
|
1181
|
-
fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n");
|
|
1182
|
-
cfgs++;
|
|
1183
|
-
|
|
1184
|
-
err=opus_encoder_ctl(enc,OPUS_GET_APPLICATION(null_int_ptr));
|
|
1185
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1186
|
-
cfgs++;
|
|
1187
|
-
CHECK_SETGET(OPUS_SET_APPLICATION(i),OPUS_GET_APPLICATION(&i),-1,OPUS_AUTO,
|
|
1188
|
-
OPUS_APPLICATION_AUDIO,OPUS_APPLICATION_RESTRICTED_LOWDELAY,
|
|
1189
|
-
" OPUS_SET_APPLICATION ......................... OK.\n",
|
|
1190
|
-
" OPUS_GET_APPLICATION ......................... OK.\n")
|
|
1191
|
-
|
|
1192
|
-
err=opus_encoder_ctl(enc,OPUS_GET_BITRATE(null_int_ptr));
|
|
1193
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1194
|
-
cfgs++;
|
|
1195
|
-
if(opus_encoder_ctl(enc,OPUS_SET_BITRATE(1073741832))!=OPUS_OK)test_failed();
|
|
1196
|
-
cfgs++;
|
|
1197
|
-
VG_UNDEF(&i,sizeof(i));
|
|
1198
|
-
if(opus_encoder_ctl(enc,OPUS_GET_BITRATE(&i))!=OPUS_OK)test_failed();
|
|
1199
|
-
if(i>700000||i<256000)test_failed();
|
|
1200
|
-
cfgs++;
|
|
1201
|
-
CHECK_SETGET(OPUS_SET_BITRATE(i),OPUS_GET_BITRATE(&i),-12345,0,
|
|
1202
|
-
500,256000,
|
|
1203
|
-
" OPUS_SET_BITRATE ............................. OK.\n",
|
|
1204
|
-
" OPUS_GET_BITRATE ............................. OK.\n")
|
|
1205
|
-
|
|
1206
|
-
err=opus_encoder_ctl(enc,OPUS_GET_FORCE_CHANNELS(null_int_ptr));
|
|
1207
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1208
|
-
cfgs++;
|
|
1209
|
-
CHECK_SETGET(OPUS_SET_FORCE_CHANNELS(i),OPUS_GET_FORCE_CHANNELS(&i),-1,3,
|
|
1210
|
-
1,OPUS_AUTO,
|
|
1211
|
-
" OPUS_SET_FORCE_CHANNELS ...................... OK.\n",
|
|
1212
|
-
" OPUS_GET_FORCE_CHANNELS ...................... OK.\n")
|
|
1213
|
-
|
|
1214
|
-
i=-2;
|
|
1215
|
-
if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))==OPUS_OK)test_failed();
|
|
1216
|
-
cfgs++;
|
|
1217
|
-
i=OPUS_BANDWIDTH_FULLBAND+1;
|
|
1218
|
-
if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))==OPUS_OK)test_failed();
|
|
1219
|
-
cfgs++;
|
|
1220
|
-
i=OPUS_BANDWIDTH_NARROWBAND;
|
|
1221
|
-
if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))!=OPUS_OK)test_failed();
|
|
1222
|
-
cfgs++;
|
|
1223
|
-
i=OPUS_BANDWIDTH_FULLBAND;
|
|
1224
|
-
if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))!=OPUS_OK)test_failed();
|
|
1225
|
-
cfgs++;
|
|
1226
|
-
i=OPUS_BANDWIDTH_WIDEBAND;
|
|
1227
|
-
if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))!=OPUS_OK)test_failed();
|
|
1228
|
-
cfgs++;
|
|
1229
|
-
i=OPUS_BANDWIDTH_MEDIUMBAND;
|
|
1230
|
-
if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))!=OPUS_OK)test_failed();
|
|
1231
|
-
cfgs++;
|
|
1232
|
-
fprintf(stdout," OPUS_SET_BANDWIDTH ........................... OK.\n");
|
|
1233
|
-
/*We don't test if the bandwidth has actually changed.
|
|
1234
|
-
because the change may be delayed until the encoder is advanced.*/
|
|
1235
|
-
i=-12345;
|
|
1236
|
-
VG_UNDEF(&i,sizeof(i));
|
|
1237
|
-
err=opus_encoder_ctl(enc,OPUS_GET_BANDWIDTH(&i));
|
|
1238
|
-
if(err!=OPUS_OK || (i!=OPUS_BANDWIDTH_NARROWBAND&&
|
|
1239
|
-
i!=OPUS_BANDWIDTH_MEDIUMBAND&&i!=OPUS_BANDWIDTH_WIDEBAND&&
|
|
1240
|
-
i!=OPUS_BANDWIDTH_FULLBAND&&i!=OPUS_AUTO))test_failed();
|
|
1241
|
-
cfgs++;
|
|
1242
|
-
if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(OPUS_AUTO))!=OPUS_OK)test_failed();
|
|
1243
|
-
cfgs++;
|
|
1244
|
-
err=opus_encoder_ctl(enc,OPUS_GET_BANDWIDTH(null_int_ptr));
|
|
1245
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1246
|
-
cfgs++;
|
|
1247
|
-
fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n");
|
|
1248
|
-
|
|
1249
|
-
i=-2;
|
|
1250
|
-
if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))==OPUS_OK)test_failed();
|
|
1251
|
-
cfgs++;
|
|
1252
|
-
i=OPUS_BANDWIDTH_FULLBAND+1;
|
|
1253
|
-
if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))==OPUS_OK)test_failed();
|
|
1254
|
-
cfgs++;
|
|
1255
|
-
i=OPUS_BANDWIDTH_NARROWBAND;
|
|
1256
|
-
if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))!=OPUS_OK)test_failed();
|
|
1257
|
-
cfgs++;
|
|
1258
|
-
i=OPUS_BANDWIDTH_FULLBAND;
|
|
1259
|
-
if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))!=OPUS_OK)test_failed();
|
|
1260
|
-
cfgs++;
|
|
1261
|
-
i=OPUS_BANDWIDTH_WIDEBAND;
|
|
1262
|
-
if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))!=OPUS_OK)test_failed();
|
|
1263
|
-
cfgs++;
|
|
1264
|
-
i=OPUS_BANDWIDTH_MEDIUMBAND;
|
|
1265
|
-
if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))!=OPUS_OK)test_failed();
|
|
1266
|
-
cfgs++;
|
|
1267
|
-
fprintf(stdout," OPUS_SET_MAX_BANDWIDTH ....................... OK.\n");
|
|
1268
|
-
/*We don't test if the bandwidth has actually changed.
|
|
1269
|
-
because the change may be delayed until the encoder is advanced.*/
|
|
1270
|
-
i=-12345;
|
|
1271
|
-
VG_UNDEF(&i,sizeof(i));
|
|
1272
|
-
err=opus_encoder_ctl(enc,OPUS_GET_MAX_BANDWIDTH(&i));
|
|
1273
|
-
if(err!=OPUS_OK || (i!=OPUS_BANDWIDTH_NARROWBAND&&
|
|
1274
|
-
i!=OPUS_BANDWIDTH_MEDIUMBAND&&i!=OPUS_BANDWIDTH_WIDEBAND&&
|
|
1275
|
-
i!=OPUS_BANDWIDTH_FULLBAND))test_failed();
|
|
1276
|
-
cfgs++;
|
|
1277
|
-
err=opus_encoder_ctl(enc,OPUS_GET_MAX_BANDWIDTH(null_int_ptr));
|
|
1278
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1279
|
-
cfgs++;
|
|
1280
|
-
fprintf(stdout," OPUS_GET_MAX_BANDWIDTH ....................... OK.\n");
|
|
1281
|
-
|
|
1282
|
-
err=opus_encoder_ctl(enc,OPUS_GET_DTX(null_int_ptr));
|
|
1283
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1284
|
-
cfgs++;
|
|
1285
|
-
CHECK_SETGET(OPUS_SET_DTX(i),OPUS_GET_DTX(&i),-1,2,
|
|
1286
|
-
1,0,
|
|
1287
|
-
" OPUS_SET_DTX ................................. OK.\n",
|
|
1288
|
-
" OPUS_GET_DTX ................................. OK.\n")
|
|
1289
|
-
|
|
1290
|
-
err=opus_encoder_ctl(enc,OPUS_GET_COMPLEXITY(null_int_ptr));
|
|
1291
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1292
|
-
cfgs++;
|
|
1293
|
-
CHECK_SETGET(OPUS_SET_COMPLEXITY(i),OPUS_GET_COMPLEXITY(&i),-1,11,
|
|
1294
|
-
0,10,
|
|
1295
|
-
" OPUS_SET_COMPLEXITY .......................... OK.\n",
|
|
1296
|
-
" OPUS_GET_COMPLEXITY .......................... OK.\n")
|
|
1297
|
-
|
|
1298
|
-
err=opus_encoder_ctl(enc,OPUS_GET_INBAND_FEC(null_int_ptr));
|
|
1299
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1300
|
-
cfgs++;
|
|
1301
|
-
CHECK_SETGET(OPUS_SET_INBAND_FEC(i),OPUS_GET_INBAND_FEC(&i),-1,3,
|
|
1302
|
-
1,0,
|
|
1303
|
-
" OPUS_SET_INBAND_FEC .......................... OK.\n",
|
|
1304
|
-
" OPUS_GET_INBAND_FEC .......................... OK.\n")
|
|
1305
|
-
|
|
1306
|
-
err=opus_encoder_ctl(enc,OPUS_GET_PACKET_LOSS_PERC(null_int_ptr));
|
|
1307
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1308
|
-
cfgs++;
|
|
1309
|
-
CHECK_SETGET(OPUS_SET_PACKET_LOSS_PERC(i),OPUS_GET_PACKET_LOSS_PERC(&i),-1,101,
|
|
1310
|
-
100,0,
|
|
1311
|
-
" OPUS_SET_PACKET_LOSS_PERC .................... OK.\n",
|
|
1312
|
-
" OPUS_GET_PACKET_LOSS_PERC .................... OK.\n")
|
|
1313
|
-
|
|
1314
|
-
err=opus_encoder_ctl(enc,OPUS_GET_VBR(null_int_ptr));
|
|
1315
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1316
|
-
cfgs++;
|
|
1317
|
-
CHECK_SETGET(OPUS_SET_VBR(i),OPUS_GET_VBR(&i),-1,2,
|
|
1318
|
-
1,0,
|
|
1319
|
-
" OPUS_SET_VBR ................................. OK.\n",
|
|
1320
|
-
" OPUS_GET_VBR ................................. OK.\n")
|
|
1321
|
-
|
|
1322
|
-
/* err=opus_encoder_ctl(enc,OPUS_GET_VOICE_RATIO(null_int_ptr));
|
|
1323
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1324
|
-
cfgs++;
|
|
1325
|
-
CHECK_SETGET(OPUS_SET_VOICE_RATIO(i),OPUS_GET_VOICE_RATIO(&i),-2,101,
|
|
1326
|
-
0,50,
|
|
1327
|
-
" OPUS_SET_VOICE_RATIO ......................... OK.\n",
|
|
1328
|
-
" OPUS_GET_VOICE_RATIO ......................... OK.\n")*/
|
|
1329
|
-
|
|
1330
|
-
err=opus_encoder_ctl(enc,OPUS_GET_VBR_CONSTRAINT(null_int_ptr));
|
|
1331
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1332
|
-
cfgs++;
|
|
1333
|
-
CHECK_SETGET(OPUS_SET_VBR_CONSTRAINT(i),OPUS_GET_VBR_CONSTRAINT(&i),-1,2,
|
|
1334
|
-
1,0,
|
|
1335
|
-
" OPUS_SET_VBR_CONSTRAINT ...................... OK.\n",
|
|
1336
|
-
" OPUS_GET_VBR_CONSTRAINT ...................... OK.\n")
|
|
1337
|
-
|
|
1338
|
-
err=opus_encoder_ctl(enc,OPUS_GET_SIGNAL(null_int_ptr));
|
|
1339
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1340
|
-
cfgs++;
|
|
1341
|
-
CHECK_SETGET(OPUS_SET_SIGNAL(i),OPUS_GET_SIGNAL(&i),-12345,0x7FFFFFFF,
|
|
1342
|
-
OPUS_SIGNAL_MUSIC,OPUS_AUTO,
|
|
1343
|
-
" OPUS_SET_SIGNAL .............................. OK.\n",
|
|
1344
|
-
" OPUS_GET_SIGNAL .............................. OK.\n")
|
|
1345
|
-
|
|
1346
|
-
err=opus_encoder_ctl(enc,OPUS_GET_LSB_DEPTH(null_int_ptr));
|
|
1347
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1348
|
-
cfgs++;
|
|
1349
|
-
CHECK_SETGET(OPUS_SET_LSB_DEPTH(i),OPUS_GET_LSB_DEPTH(&i),7,25,16,24,
|
|
1350
|
-
" OPUS_SET_LSB_DEPTH ........................... OK.\n",
|
|
1351
|
-
" OPUS_GET_LSB_DEPTH ........................... OK.\n")
|
|
1352
|
-
|
|
1353
|
-
err=opus_encoder_ctl(enc,OPUS_GET_PREDICTION_DISABLED(&i));
|
|
1354
|
-
if(i!=0)test_failed();
|
|
1355
|
-
cfgs++;
|
|
1356
|
-
err=opus_encoder_ctl(enc,OPUS_GET_PREDICTION_DISABLED(null_int_ptr));
|
|
1357
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1358
|
-
cfgs++;
|
|
1359
|
-
CHECK_SETGET(OPUS_SET_PREDICTION_DISABLED(i),OPUS_GET_PREDICTION_DISABLED(&i),-1,2,1,0,
|
|
1360
|
-
" OPUS_SET_PREDICTION_DISABLED ................. OK.\n",
|
|
1361
|
-
" OPUS_GET_PREDICTION_DISABLED ................. OK.\n")
|
|
1362
|
-
|
|
1363
|
-
err=opus_encoder_ctl(enc,OPUS_GET_EXPERT_FRAME_DURATION(null_int_ptr));
|
|
1364
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1365
|
-
cfgs++;
|
|
1366
|
-
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_2_5_MS));
|
|
1367
|
-
if(err!=OPUS_OK)test_failed();
|
|
1368
|
-
cfgs++;
|
|
1369
|
-
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_5_MS));
|
|
1370
|
-
if(err!=OPUS_OK)test_failed();
|
|
1371
|
-
cfgs++;
|
|
1372
|
-
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_10_MS));
|
|
1373
|
-
if(err!=OPUS_OK)test_failed();
|
|
1374
|
-
cfgs++;
|
|
1375
|
-
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_20_MS));
|
|
1376
|
-
if(err!=OPUS_OK)test_failed();
|
|
1377
|
-
cfgs++;
|
|
1378
|
-
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_40_MS));
|
|
1379
|
-
if(err!=OPUS_OK)test_failed();
|
|
1380
|
-
cfgs++;
|
|
1381
|
-
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_60_MS));
|
|
1382
|
-
if(err!=OPUS_OK)test_failed();
|
|
1383
|
-
cfgs++;
|
|
1384
|
-
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_80_MS));
|
|
1385
|
-
if(err!=OPUS_OK)test_failed();
|
|
1386
|
-
cfgs++;
|
|
1387
|
-
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_100_MS));
|
|
1388
|
-
if(err!=OPUS_OK)test_failed();
|
|
1389
|
-
cfgs++;
|
|
1390
|
-
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_120_MS));
|
|
1391
|
-
if(err!=OPUS_OK)test_failed();
|
|
1392
|
-
cfgs++;
|
|
1393
|
-
CHECK_SETGET(OPUS_SET_EXPERT_FRAME_DURATION(i),OPUS_GET_EXPERT_FRAME_DURATION(&i),0,-1,
|
|
1394
|
-
OPUS_FRAMESIZE_60_MS,OPUS_FRAMESIZE_ARG,
|
|
1395
|
-
" OPUS_SET_EXPERT_FRAME_DURATION ............... OK.\n",
|
|
1396
|
-
" OPUS_GET_EXPERT_FRAME_DURATION ............... OK.\n")
|
|
1397
|
-
|
|
1398
|
-
/*OPUS_SET_FORCE_MODE is not tested here because it's not a public API, however the encoder tests use it*/
|
|
1399
|
-
|
|
1400
|
-
err=opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE(null_uint_ptr));
|
|
1401
|
-
if(err!=OPUS_BAD_ARG)test_failed();
|
|
1402
|
-
cfgs++;
|
|
1403
|
-
if(opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE(&enc_final_range))!=OPUS_OK)test_failed();
|
|
1404
|
-
cfgs++;
|
|
1405
|
-
fprintf(stdout," OPUS_GET_FINAL_RANGE ......................... OK.\n");
|
|
1406
|
-
|
|
1407
|
-
/*Reset the encoder*/
|
|
1408
|
-
if(opus_encoder_ctl(enc, OPUS_RESET_STATE)!=OPUS_OK)test_failed();
|
|
1409
|
-
cfgs++;
|
|
1410
|
-
fprintf(stdout," OPUS_RESET_STATE ............................. OK.\n");
|
|
1411
|
-
|
|
1412
|
-
memset(sbuf,0,sizeof(short)*2*960);
|
|
1413
|
-
VG_UNDEF(packet,sizeof(packet));
|
|
1414
|
-
i=opus_encode(enc, sbuf, 960, packet, sizeof(packet));
|
|
1415
|
-
if(i<1 || (i>(opus_int32)sizeof(packet)))test_failed();
|
|
1416
|
-
VG_CHECK(packet,i);
|
|
1417
|
-
cfgs++;
|
|
1418
|
-
fprintf(stdout," opus_encode() ................................ OK.\n");
|
|
1419
|
-
#ifndef DISABLE_FLOAT_API
|
|
1420
|
-
memset(fbuf,0,sizeof(float)*2*960);
|
|
1421
|
-
VG_UNDEF(packet,sizeof(packet));
|
|
1422
|
-
i=opus_encode_float(enc, fbuf, 960, packet, sizeof(packet));
|
|
1423
|
-
if(i<1 || (i>(opus_int32)sizeof(packet)))test_failed();
|
|
1424
|
-
VG_CHECK(packet,i);
|
|
1425
|
-
cfgs++;
|
|
1426
|
-
fprintf(stdout," opus_encode_float() .......................... OK.\n");
|
|
1427
|
-
#endif
|
|
1428
|
-
|
|
1429
|
-
#if 0
|
|
1430
|
-
/*These tests are disabled because the library crashes with null states*/
|
|
1431
|
-
if(opus_encoder_ctl(0,OPUS_RESET_STATE) !=OPUS_INVALID_STATE)test_failed();
|
|
1432
|
-
if(opus_encoder_init(0,48000,1,OPUS_APPLICATION_VOIP) !=OPUS_INVALID_STATE)test_failed();
|
|
1433
|
-
if(opus_encode(0,sbuf,960,packet,sizeof(packet)) !=OPUS_INVALID_STATE)test_failed();
|
|
1434
|
-
if(opus_encode_float(0,fbuf,960,packet,sizeof(packet))!=OPUS_INVALID_STATE)test_failed();
|
|
1435
|
-
#endif
|
|
1436
|
-
opus_encoder_destroy(enc);
|
|
1437
|
-
cfgs++;
|
|
1438
|
-
fprintf(stdout," All encoder interface tests passed\n");
|
|
1439
|
-
fprintf(stdout," (%d API invocations)\n",cfgs);
|
|
1440
|
-
return cfgs;
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
#define max_out (1276*48+48*2+2)
|
|
1444
|
-
int test_repacketizer_api(void)
|
|
1445
|
-
{
|
|
1446
|
-
int ret,cfgs,i,j,k;
|
|
1447
|
-
OpusRepacketizer *rp;
|
|
1448
|
-
unsigned char *packet;
|
|
1449
|
-
unsigned char *po;
|
|
1450
|
-
cfgs=0;
|
|
1451
|
-
fprintf(stdout,"\n Repacketizer tests\n");
|
|
1452
|
-
fprintf(stdout," ---------------------------------------------------\n");
|
|
1453
|
-
|
|
1454
|
-
packet=malloc(max_out);
|
|
1455
|
-
if(packet==NULL)test_failed();
|
|
1456
|
-
memset(packet,0,max_out);
|
|
1457
|
-
po=malloc(max_out+256);
|
|
1458
|
-
if(po==NULL)test_failed();
|
|
1459
|
-
|
|
1460
|
-
i=opus_repacketizer_get_size();
|
|
1461
|
-
if(i<=0)test_failed();
|
|
1462
|
-
cfgs++;
|
|
1463
|
-
fprintf(stdout," opus_repacketizer_get_size()=%d ............. OK.\n",i);
|
|
1464
|
-
|
|
1465
|
-
rp=malloc(i);
|
|
1466
|
-
rp=opus_repacketizer_init(rp);
|
|
1467
|
-
if(rp==NULL)test_failed();
|
|
1468
|
-
cfgs++;
|
|
1469
|
-
free(rp);
|
|
1470
|
-
fprintf(stdout," opus_repacketizer_init ....................... OK.\n");
|
|
1471
|
-
|
|
1472
|
-
rp=opus_repacketizer_create();
|
|
1473
|
-
if(rp==NULL)test_failed();
|
|
1474
|
-
cfgs++;
|
|
1475
|
-
fprintf(stdout," opus_repacketizer_create ..................... OK.\n");
|
|
1476
|
-
|
|
1477
|
-
if(opus_repacketizer_get_nb_frames(rp)!=0)test_failed();
|
|
1478
|
-
cfgs++;
|
|
1479
|
-
fprintf(stdout," opus_repacketizer_get_nb_frames .............. OK.\n");
|
|
1480
|
-
|
|
1481
|
-
/*Length overflows*/
|
|
1482
|
-
VG_UNDEF(packet,4);
|
|
1483
|
-
if(opus_repacketizer_cat(rp,packet,0)!=OPUS_INVALID_PACKET)test_failed(); /* Zero len */
|
|
1484
|
-
cfgs++;
|
|
1485
|
-
packet[0]=1;
|
|
1486
|
-
if(opus_repacketizer_cat(rp,packet,2)!=OPUS_INVALID_PACKET)test_failed(); /* Odd payload code 1 */
|
|
1487
|
-
cfgs++;
|
|
1488
|
-
packet[0]=2;
|
|
1489
|
-
if(opus_repacketizer_cat(rp,packet,1)!=OPUS_INVALID_PACKET)test_failed(); /* Code 2 overflow one */
|
|
1490
|
-
cfgs++;
|
|
1491
|
-
packet[0]=3;
|
|
1492
|
-
if(opus_repacketizer_cat(rp,packet,1)!=OPUS_INVALID_PACKET)test_failed(); /* Code 3 no count */
|
|
1493
|
-
cfgs++;
|
|
1494
|
-
packet[0]=2;
|
|
1495
|
-
packet[1]=255;
|
|
1496
|
-
if(opus_repacketizer_cat(rp,packet,2)!=OPUS_INVALID_PACKET)test_failed(); /* Code 2 overflow two */
|
|
1497
|
-
cfgs++;
|
|
1498
|
-
packet[0]=2;
|
|
1499
|
-
packet[1]=250;
|
|
1500
|
-
if(opus_repacketizer_cat(rp,packet,251)!=OPUS_INVALID_PACKET)test_failed(); /* Code 2 overflow three */
|
|
1501
|
-
cfgs++;
|
|
1502
|
-
packet[0]=3;
|
|
1503
|
-
packet[1]=0;
|
|
1504
|
-
if(opus_repacketizer_cat(rp,packet,2)!=OPUS_INVALID_PACKET)test_failed(); /* Code 3 m=0 */
|
|
1505
|
-
cfgs++;
|
|
1506
|
-
packet[1]=49;
|
|
1507
|
-
if(opus_repacketizer_cat(rp,packet,100)!=OPUS_INVALID_PACKET)test_failed(); /* Code 3 m=49 */
|
|
1508
|
-
cfgs++;
|
|
1509
|
-
packet[0]=0;
|
|
1510
|
-
if(opus_repacketizer_cat(rp,packet,3)!=OPUS_OK)test_failed();
|
|
1511
|
-
cfgs++;
|
|
1512
|
-
packet[0]=1<<2;
|
|
1513
|
-
if(opus_repacketizer_cat(rp,packet,3)!=OPUS_INVALID_PACKET)test_failed(); /* Change in TOC */
|
|
1514
|
-
cfgs++;
|
|
1515
|
-
|
|
1516
|
-
/* Code 0,1,3 CBR -> Code 0,1,3 CBR */
|
|
1517
|
-
opus_repacketizer_init(rp);
|
|
1518
|
-
for(j=0;j<32;j++)
|
|
1519
|
-
{
|
|
1520
|
-
/* TOC types, test half with stereo */
|
|
1521
|
-
int maxi;
|
|
1522
|
-
packet[0]=((j<<1)+(j&1))<<2;
|
|
1523
|
-
maxi=960/opus_packet_get_samples_per_frame(packet,8000);
|
|
1524
|
-
for(i=1;i<=maxi;i++)
|
|
1525
|
-
{
|
|
1526
|
-
/* Number of CBR frames in the input packets */
|
|
1527
|
-
int maxp;
|
|
1528
|
-
packet[0]=((j<<1)+(j&1))<<2;
|
|
1529
|
-
if(i>1)packet[0]+=i==2?1:3;
|
|
1530
|
-
packet[1]=i>2?i:0;
|
|
1531
|
-
maxp=960/(i*opus_packet_get_samples_per_frame(packet,8000));
|
|
1532
|
-
for(k=0;k<=(1275+75);k+=3)
|
|
1533
|
-
{
|
|
1534
|
-
/*Payload size*/
|
|
1535
|
-
opus_int32 cnt,rcnt;
|
|
1536
|
-
if(k%i!=0)continue; /* Only testing CBR here, payload must be a multiple of the count */
|
|
1537
|
-
for(cnt=0;cnt<maxp+2;cnt++)
|
|
1538
|
-
{
|
|
1539
|
-
if(cnt>0)
|
|
1540
|
-
{
|
|
1541
|
-
ret=opus_repacketizer_cat(rp,packet,k+(i>2?2:1));
|
|
1542
|
-
if((cnt<=maxp&&k<=(1275*i))?ret!=OPUS_OK:ret!=OPUS_INVALID_PACKET)test_failed();
|
|
1543
|
-
cfgs++;
|
|
1544
|
-
}
|
|
1545
|
-
rcnt=k<=(1275*i)?(cnt<maxp?cnt:maxp):0;
|
|
1546
|
-
if(opus_repacketizer_get_nb_frames(rp)!=rcnt*i)test_failed();
|
|
1547
|
-
cfgs++;
|
|
1548
|
-
ret=opus_repacketizer_out_range(rp,0,rcnt*i,po,max_out);
|
|
1549
|
-
if(rcnt>0)
|
|
1550
|
-
{
|
|
1551
|
-
int len;
|
|
1552
|
-
len=k*rcnt+((rcnt*i)>2?2:1);
|
|
1553
|
-
if(ret!=len)test_failed();
|
|
1554
|
-
if((rcnt*i)<2&&(po[0]&3)!=0)test_failed(); /* Code 0 */
|
|
1555
|
-
if((rcnt*i)==2&&(po[0]&3)!=1)test_failed(); /* Code 1 */
|
|
1556
|
-
if((rcnt*i)>2&&(((po[0]&3)!=3)||(po[1]!=rcnt*i)))test_failed(); /* Code 3 CBR */
|
|
1557
|
-
cfgs++;
|
|
1558
|
-
if(opus_repacketizer_out(rp,po,len)!=len)test_failed();
|
|
1559
|
-
cfgs++;
|
|
1560
|
-
if(opus_packet_unpad(po,len)!=len)test_failed();
|
|
1561
|
-
cfgs++;
|
|
1562
|
-
if(opus_packet_pad(po,len,len+1)!=OPUS_OK)test_failed();
|
|
1563
|
-
cfgs++;
|
|
1564
|
-
if(opus_packet_pad(po,len+1,len+256)!=OPUS_OK)test_failed();
|
|
1565
|
-
cfgs++;
|
|
1566
|
-
if(opus_packet_unpad(po,len+256)!=len)test_failed();
|
|
1567
|
-
cfgs++;
|
|
1568
|
-
if(opus_multistream_packet_unpad(po,len,1)!=len)test_failed();
|
|
1569
|
-
cfgs++;
|
|
1570
|
-
if(opus_multistream_packet_pad(po,len,len+1,1)!=OPUS_OK)test_failed();
|
|
1571
|
-
cfgs++;
|
|
1572
|
-
if(opus_multistream_packet_pad(po,len+1,len+256,1)!=OPUS_OK)test_failed();
|
|
1573
|
-
cfgs++;
|
|
1574
|
-
if(opus_multistream_packet_unpad(po,len+256,1)!=len)test_failed();
|
|
1575
|
-
cfgs++;
|
|
1576
|
-
if(opus_repacketizer_out(rp,po,len-1)!=OPUS_BUFFER_TOO_SMALL)test_failed();
|
|
1577
|
-
cfgs++;
|
|
1578
|
-
if(len>1)
|
|
1579
|
-
{
|
|
1580
|
-
if(opus_repacketizer_out(rp,po,1)!=OPUS_BUFFER_TOO_SMALL)test_failed();
|
|
1581
|
-
cfgs++;
|
|
1582
|
-
}
|
|
1583
|
-
if(opus_repacketizer_out(rp,po,0)!=OPUS_BUFFER_TOO_SMALL)test_failed();
|
|
1584
|
-
cfgs++;
|
|
1585
|
-
} else if (ret!=OPUS_BAD_ARG)test_failed(); /* M must not be 0 */
|
|
1586
|
-
}
|
|
1587
|
-
opus_repacketizer_init(rp);
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
|
-
/*Change in input count code, CBR out*/
|
|
1593
|
-
opus_repacketizer_init(rp);
|
|
1594
|
-
packet[0]=0;
|
|
1595
|
-
if(opus_repacketizer_cat(rp,packet,5)!=OPUS_OK)test_failed();
|
|
1596
|
-
cfgs++;
|
|
1597
|
-
packet[0]+=1;
|
|
1598
|
-
if(opus_repacketizer_cat(rp,packet,9)!=OPUS_OK)test_failed();
|
|
1599
|
-
cfgs++;
|
|
1600
|
-
i=opus_repacketizer_out(rp,po,max_out);
|
|
1601
|
-
if((i!=(4+8+2))||((po[0]&3)!=3)||((po[1]&63)!=3)||((po[1]>>7)!=0))test_failed();
|
|
1602
|
-
cfgs++;
|
|
1603
|
-
i=opus_repacketizer_out_range(rp,0,1,po,max_out);
|
|
1604
|
-
if(i!=5||(po[0]&3)!=0)test_failed();
|
|
1605
|
-
cfgs++;
|
|
1606
|
-
i=opus_repacketizer_out_range(rp,1,2,po,max_out);
|
|
1607
|
-
if(i!=5||(po[0]&3)!=0)test_failed();
|
|
1608
|
-
cfgs++;
|
|
1609
|
-
|
|
1610
|
-
/*Change in input count code, VBR out*/
|
|
1611
|
-
opus_repacketizer_init(rp);
|
|
1612
|
-
packet[0]=1;
|
|
1613
|
-
if(opus_repacketizer_cat(rp,packet,9)!=OPUS_OK)test_failed();
|
|
1614
|
-
cfgs++;
|
|
1615
|
-
packet[0]=0;
|
|
1616
|
-
if(opus_repacketizer_cat(rp,packet,3)!=OPUS_OK)test_failed();
|
|
1617
|
-
cfgs++;
|
|
1618
|
-
i=opus_repacketizer_out(rp,po,max_out);
|
|
1619
|
-
if((i!=(2+8+2+2))||((po[0]&3)!=3)||((po[1]&63)!=3)||((po[1]>>7)!=1))test_failed();
|
|
1620
|
-
cfgs++;
|
|
1621
|
-
|
|
1622
|
-
/*VBR in, VBR out*/
|
|
1623
|
-
opus_repacketizer_init(rp);
|
|
1624
|
-
packet[0]=2;
|
|
1625
|
-
packet[1]=4;
|
|
1626
|
-
if(opus_repacketizer_cat(rp,packet,8)!=OPUS_OK)test_failed();
|
|
1627
|
-
cfgs++;
|
|
1628
|
-
if(opus_repacketizer_cat(rp,packet,8)!=OPUS_OK)test_failed();
|
|
1629
|
-
cfgs++;
|
|
1630
|
-
i=opus_repacketizer_out(rp,po,max_out);
|
|
1631
|
-
if((i!=(2+1+1+1+4+2+4+2))||((po[0]&3)!=3)||((po[1]&63)!=4)||((po[1]>>7)!=1))test_failed();
|
|
1632
|
-
cfgs++;
|
|
1633
|
-
|
|
1634
|
-
/*VBR in, CBR out*/
|
|
1635
|
-
opus_repacketizer_init(rp);
|
|
1636
|
-
packet[0]=2;
|
|
1637
|
-
packet[1]=4;
|
|
1638
|
-
if(opus_repacketizer_cat(rp,packet,10)!=OPUS_OK)test_failed();
|
|
1639
|
-
cfgs++;
|
|
1640
|
-
if(opus_repacketizer_cat(rp,packet,10)!=OPUS_OK)test_failed();
|
|
1641
|
-
cfgs++;
|
|
1642
|
-
i=opus_repacketizer_out(rp,po,max_out);
|
|
1643
|
-
if((i!=(2+4+4+4+4))||((po[0]&3)!=3)||((po[1]&63)!=4)||((po[1]>>7)!=0))test_failed();
|
|
1644
|
-
cfgs++;
|
|
1645
|
-
|
|
1646
|
-
/*Count 0 in, VBR out*/
|
|
1647
|
-
for(j=0;j<32;j++)
|
|
1648
|
-
{
|
|
1649
|
-
/* TOC types, test half with stereo */
|
|
1650
|
-
int maxi,sum,rcnt;
|
|
1651
|
-
packet[0]=((j<<1)+(j&1))<<2;
|
|
1652
|
-
maxi=960/opus_packet_get_samples_per_frame(packet,8000);
|
|
1653
|
-
sum=0;
|
|
1654
|
-
rcnt=0;
|
|
1655
|
-
opus_repacketizer_init(rp);
|
|
1656
|
-
for(i=1;i<=maxi+2;i++)
|
|
1657
|
-
{
|
|
1658
|
-
int len;
|
|
1659
|
-
ret=opus_repacketizer_cat(rp,packet,i);
|
|
1660
|
-
if(rcnt<maxi)
|
|
1661
|
-
{
|
|
1662
|
-
if(ret!=OPUS_OK)test_failed();
|
|
1663
|
-
rcnt++;
|
|
1664
|
-
sum+=i-1;
|
|
1665
|
-
} else if (ret!=OPUS_INVALID_PACKET)test_failed();
|
|
1666
|
-
cfgs++;
|
|
1667
|
-
len=sum+(rcnt<2?1:rcnt<3?2:2+rcnt-1);
|
|
1668
|
-
if(opus_repacketizer_out(rp,po,max_out)!=len)test_failed();
|
|
1669
|
-
if(rcnt>2&&(po[1]&63)!=rcnt)test_failed();
|
|
1670
|
-
if(rcnt==2&&(po[0]&3)!=2)test_failed();
|
|
1671
|
-
if(rcnt==1&&(po[0]&3)!=0)test_failed();
|
|
1672
|
-
cfgs++;
|
|
1673
|
-
if(opus_repacketizer_out(rp,po,len)!=len)test_failed();
|
|
1674
|
-
cfgs++;
|
|
1675
|
-
if(opus_packet_unpad(po,len)!=len)test_failed();
|
|
1676
|
-
cfgs++;
|
|
1677
|
-
if(opus_packet_pad(po,len,len+1)!=OPUS_OK)test_failed();
|
|
1678
|
-
cfgs++;
|
|
1679
|
-
if(opus_packet_pad(po,len+1,len+256)!=OPUS_OK)test_failed();
|
|
1680
|
-
cfgs++;
|
|
1681
|
-
if(opus_packet_unpad(po,len+256)!=len)test_failed();
|
|
1682
|
-
cfgs++;
|
|
1683
|
-
if(opus_multistream_packet_unpad(po,len,1)!=len)test_failed();
|
|
1684
|
-
cfgs++;
|
|
1685
|
-
if(opus_multistream_packet_pad(po,len,len+1,1)!=OPUS_OK)test_failed();
|
|
1686
|
-
cfgs++;
|
|
1687
|
-
if(opus_multistream_packet_pad(po,len+1,len+256,1)!=OPUS_OK)test_failed();
|
|
1688
|
-
cfgs++;
|
|
1689
|
-
if(opus_multistream_packet_unpad(po,len+256,1)!=len)test_failed();
|
|
1690
|
-
cfgs++;
|
|
1691
|
-
if(opus_repacketizer_out(rp,po,len-1)!=OPUS_BUFFER_TOO_SMALL)test_failed();
|
|
1692
|
-
cfgs++;
|
|
1693
|
-
if(len>1)
|
|
1694
|
-
{
|
|
1695
|
-
if(opus_repacketizer_out(rp,po,1)!=OPUS_BUFFER_TOO_SMALL)test_failed();
|
|
1696
|
-
cfgs++;
|
|
1697
|
-
}
|
|
1698
|
-
if(opus_repacketizer_out(rp,po,0)!=OPUS_BUFFER_TOO_SMALL)test_failed();
|
|
1699
|
-
cfgs++;
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
po[0]='O';
|
|
1704
|
-
po[1]='p';
|
|
1705
|
-
if(opus_packet_pad(po,4,4)!=OPUS_OK)test_failed();
|
|
1706
|
-
cfgs++;
|
|
1707
|
-
if(opus_multistream_packet_pad(po,4,4,1)!=OPUS_OK)test_failed();
|
|
1708
|
-
cfgs++;
|
|
1709
|
-
if(opus_packet_pad(po,4,5)!=OPUS_INVALID_PACKET)test_failed();
|
|
1710
|
-
cfgs++;
|
|
1711
|
-
if(opus_multistream_packet_pad(po,4,5,1)!=OPUS_INVALID_PACKET)test_failed();
|
|
1712
|
-
cfgs++;
|
|
1713
|
-
if(opus_packet_pad(po,0,5)!=OPUS_BAD_ARG)test_failed();
|
|
1714
|
-
cfgs++;
|
|
1715
|
-
if(opus_multistream_packet_pad(po,0,5,1)!=OPUS_BAD_ARG)test_failed();
|
|
1716
|
-
cfgs++;
|
|
1717
|
-
if(opus_packet_unpad(po,0)!=OPUS_BAD_ARG)test_failed();
|
|
1718
|
-
cfgs++;
|
|
1719
|
-
if(opus_multistream_packet_unpad(po,0,1)!=OPUS_BAD_ARG)test_failed();
|
|
1720
|
-
cfgs++;
|
|
1721
|
-
if(opus_packet_unpad(po,4)!=OPUS_INVALID_PACKET)test_failed();
|
|
1722
|
-
cfgs++;
|
|
1723
|
-
if(opus_multistream_packet_unpad(po,4,1)!=OPUS_INVALID_PACKET)test_failed();
|
|
1724
|
-
cfgs++;
|
|
1725
|
-
po[0]=0;
|
|
1726
|
-
po[1]=0;
|
|
1727
|
-
po[2]=0;
|
|
1728
|
-
if(opus_packet_pad(po,5,4)!=OPUS_BAD_ARG)test_failed();
|
|
1729
|
-
cfgs++;
|
|
1730
|
-
if(opus_multistream_packet_pad(po,5,4,1)!=OPUS_BAD_ARG)test_failed();
|
|
1731
|
-
cfgs++;
|
|
1732
|
-
|
|
1733
|
-
fprintf(stdout," opus_repacketizer_cat ........................ OK.\n");
|
|
1734
|
-
fprintf(stdout," opus_repacketizer_out ........................ OK.\n");
|
|
1735
|
-
fprintf(stdout," opus_repacketizer_out_range .................. OK.\n");
|
|
1736
|
-
fprintf(stdout," opus_packet_pad .............................. OK.\n");
|
|
1737
|
-
fprintf(stdout," opus_packet_unpad ............................ OK.\n");
|
|
1738
|
-
fprintf(stdout," opus_multistream_packet_pad .................. OK.\n");
|
|
1739
|
-
fprintf(stdout," opus_multistream_packet_unpad ................ OK.\n");
|
|
1740
|
-
|
|
1741
|
-
opus_repacketizer_destroy(rp);
|
|
1742
|
-
cfgs++;
|
|
1743
|
-
free(packet);
|
|
1744
|
-
free(po);
|
|
1745
|
-
fprintf(stdout," All repacketizer tests passed\n");
|
|
1746
|
-
fprintf(stdout," (%7d API invocations)\n",cfgs);
|
|
1747
|
-
|
|
1748
|
-
return cfgs;
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
#ifdef MALLOC_FAIL
|
|
1752
|
-
/* GLIBC 2.14 declares __malloc_hook as deprecated, generating a warning
|
|
1753
|
-
* under GCC. However, this is the cleanest way to test malloc failure
|
|
1754
|
-
* handling in our codebase, and the lack of thread safety isn't an
|
|
1755
|
-
* issue here. We therefore disable the warning for this function.
|
|
1756
|
-
*/
|
|
1757
|
-
#if OPUS_GNUC_PREREQ(4,6)
|
|
1758
|
-
/* Save the current warning settings */
|
|
1759
|
-
#pragma GCC diagnostic push
|
|
1760
|
-
#endif
|
|
1761
|
-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
1762
|
-
|
|
1763
|
-
typedef void *(*mhook)(size_t __size, __const void *);
|
|
1764
|
-
#endif
|
|
1765
|
-
|
|
1766
|
-
int test_malloc_fail(void)
|
|
1767
|
-
{
|
|
1768
|
-
#ifdef MALLOC_FAIL
|
|
1769
|
-
OpusDecoder *dec;
|
|
1770
|
-
OpusEncoder *enc;
|
|
1771
|
-
OpusRepacketizer *rp;
|
|
1772
|
-
unsigned char mapping[256] = {0,1};
|
|
1773
|
-
OpusMSDecoder *msdec;
|
|
1774
|
-
OpusMSEncoder *msenc;
|
|
1775
|
-
int rate,c,app,cfgs,err,useerr;
|
|
1776
|
-
int *ep;
|
|
1777
|
-
mhook orig_malloc;
|
|
1778
|
-
cfgs=0;
|
|
1779
|
-
#endif
|
|
1780
|
-
fprintf(stdout,"\n malloc() failure tests\n");
|
|
1781
|
-
fprintf(stdout," ---------------------------------------------------\n");
|
|
1782
|
-
#ifdef MALLOC_FAIL
|
|
1783
|
-
orig_malloc=__malloc_hook;
|
|
1784
|
-
__malloc_hook=malloc_hook;
|
|
1785
|
-
ep=(int *)opus_alloc(sizeof(int));
|
|
1786
|
-
if(ep!=NULL)
|
|
1787
|
-
{
|
|
1788
|
-
if(ep)free(ep);
|
|
1789
|
-
__malloc_hook=orig_malloc;
|
|
1790
|
-
#endif
|
|
1791
|
-
fprintf(stdout," opus_decoder_create() ................... SKIPPED.\n");
|
|
1792
|
-
fprintf(stdout," opus_encoder_create() ................... SKIPPED.\n");
|
|
1793
|
-
fprintf(stdout," opus_repacketizer_create() .............. SKIPPED.\n");
|
|
1794
|
-
fprintf(stdout," opus_multistream_decoder_create() ....... SKIPPED.\n");
|
|
1795
|
-
fprintf(stdout," opus_multistream_encoder_create() ....... SKIPPED.\n");
|
|
1796
|
-
fprintf(stdout,"(Test only supported with GLIBC and without valgrind)\n");
|
|
1797
|
-
return 0;
|
|
1798
|
-
#ifdef MALLOC_FAIL
|
|
1799
|
-
}
|
|
1800
|
-
for(useerr=0;useerr<2;useerr++)
|
|
1801
|
-
{
|
|
1802
|
-
ep=useerr?&err:0;
|
|
1803
|
-
for(rate=0;rate<5;rate++)
|
|
1804
|
-
{
|
|
1805
|
-
for(c=1;c<3;c++)
|
|
1806
|
-
{
|
|
1807
|
-
err=1;
|
|
1808
|
-
if(useerr)
|
|
1809
|
-
{
|
|
1810
|
-
VG_UNDEF(&err,sizeof(err));
|
|
1811
|
-
}
|
|
1812
|
-
dec=opus_decoder_create(opus_rates[rate], c, ep);
|
|
1813
|
-
if(dec!=NULL||(useerr&&err!=OPUS_ALLOC_FAIL))
|
|
1814
|
-
{
|
|
1815
|
-
__malloc_hook=orig_malloc;
|
|
1816
|
-
test_failed();
|
|
1817
|
-
}
|
|
1818
|
-
cfgs++;
|
|
1819
|
-
msdec=opus_multistream_decoder_create(opus_rates[rate], c, 1, c-1, mapping, ep);
|
|
1820
|
-
if(msdec!=NULL||(useerr&&err!=OPUS_ALLOC_FAIL))
|
|
1821
|
-
{
|
|
1822
|
-
__malloc_hook=orig_malloc;
|
|
1823
|
-
test_failed();
|
|
1824
|
-
}
|
|
1825
|
-
cfgs++;
|
|
1826
|
-
for(app=0;app<3;app++)
|
|
1827
|
-
{
|
|
1828
|
-
if(useerr)
|
|
1829
|
-
{
|
|
1830
|
-
VG_UNDEF(&err,sizeof(err));
|
|
1831
|
-
}
|
|
1832
|
-
enc=opus_encoder_create(opus_rates[rate], c, opus_apps[app],ep);
|
|
1833
|
-
if(enc!=NULL||(useerr&&err!=OPUS_ALLOC_FAIL))
|
|
1834
|
-
{
|
|
1835
|
-
__malloc_hook=orig_malloc;
|
|
1836
|
-
test_failed();
|
|
1837
|
-
}
|
|
1838
|
-
cfgs++;
|
|
1839
|
-
msenc=opus_multistream_encoder_create(opus_rates[rate], c, 1, c-1, mapping, opus_apps[app],ep);
|
|
1840
|
-
if(msenc!=NULL||(useerr&&err!=OPUS_ALLOC_FAIL))
|
|
1841
|
-
{
|
|
1842
|
-
__malloc_hook=orig_malloc;
|
|
1843
|
-
test_failed();
|
|
1844
|
-
}
|
|
1845
|
-
cfgs++;
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
rp=opus_repacketizer_create();
|
|
1851
|
-
if(rp!=NULL)
|
|
1852
|
-
{
|
|
1853
|
-
__malloc_hook=orig_malloc;
|
|
1854
|
-
test_failed();
|
|
1855
|
-
}
|
|
1856
|
-
cfgs++;
|
|
1857
|
-
__malloc_hook=orig_malloc;
|
|
1858
|
-
fprintf(stdout," opus_decoder_create() ........................ OK.\n");
|
|
1859
|
-
fprintf(stdout," opus_encoder_create() ........................ OK.\n");
|
|
1860
|
-
fprintf(stdout," opus_repacketizer_create() ................... OK.\n");
|
|
1861
|
-
fprintf(stdout," opus_multistream_decoder_create() ............ OK.\n");
|
|
1862
|
-
fprintf(stdout," opus_multistream_encoder_create() ............ OK.\n");
|
|
1863
|
-
fprintf(stdout," All malloc failure tests passed\n");
|
|
1864
|
-
fprintf(stdout," (%2d API invocations)\n",cfgs);
|
|
1865
|
-
return cfgs;
|
|
1866
|
-
#endif
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
#ifdef MALLOC_FAIL
|
|
1870
|
-
#if __GNUC_PREREQ(4,6)
|
|
1871
|
-
#pragma GCC diagnostic pop /* restore -Wdeprecated-declarations */
|
|
1872
|
-
#endif
|
|
1873
|
-
#endif
|
|
1874
|
-
|
|
1875
|
-
int main(int _argc, char **_argv)
|
|
1876
|
-
{
|
|
1877
|
-
opus_int32 total;
|
|
1878
|
-
const char * oversion;
|
|
1879
|
-
if(_argc>1)
|
|
1880
|
-
{
|
|
1881
|
-
fprintf(stderr,"Usage: %s\n",_argv[0]);
|
|
1882
|
-
return 1;
|
|
1883
|
-
}
|
|
1884
|
-
iseed=0;
|
|
1885
|
-
|
|
1886
|
-
oversion=opus_get_version_string();
|
|
1887
|
-
if(!oversion)test_failed();
|
|
1888
|
-
fprintf(stderr,"Testing the %s API deterministically\n", oversion);
|
|
1889
|
-
if(opus_strerror(-32768)==NULL)test_failed();
|
|
1890
|
-
if(opus_strerror(32767)==NULL)test_failed();
|
|
1891
|
-
if(strlen(opus_strerror(0))<1)test_failed();
|
|
1892
|
-
total=4;
|
|
1893
|
-
|
|
1894
|
-
total+=test_dec_api();
|
|
1895
|
-
total+=test_msdec_api();
|
|
1896
|
-
total+=test_parse();
|
|
1897
|
-
total+=test_enc_api();
|
|
1898
|
-
total+=test_repacketizer_api();
|
|
1899
|
-
total+=test_malloc_fail();
|
|
1900
|
-
|
|
1901
|
-
fprintf(stderr,"\nAll API tests passed.\nThe libopus API was invoked %d times.\n",total);
|
|
1902
|
-
|
|
1903
|
-
return 0;
|
|
1904
|
-
}
|