@scrypted/libav 1.0.166 → 1.0.168
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/opus/.gitattributes +10 -0
- package/opus/.gitlab-ci.yml +122 -0
- package/opus/AUTHORS +6 -0
- package/opus/CMakeLists.txt +755 -0
- package/opus/COPYING +44 -0
- package/opus/ChangeLog +0 -0
- package/opus/LICENSE_PLEASE_READ.txt +22 -0
- package/opus/Makefile.am +497 -0
- package/opus/Makefile.mips +169 -0
- package/opus/Makefile.unix +167 -0
- package/opus/NEWS +0 -0
- package/opus/README +189 -0
- package/opus/README.draft +54 -0
- package/opus/autogen.bat +13 -0
- package/opus/autogen.sh +16 -0
- package/opus/celt/_kiss_fft_guts.h +188 -0
- package/opus/celt/arch.h +390 -0
- package/opus/celt/arm/arm2gnu.pl +353 -0
- package/opus/celt/arm/arm_celt_map.c +171 -0
- package/opus/celt/arm/armcpu.c +291 -0
- package/opus/celt/arm/armcpu.h +90 -0
- package/opus/celt/arm/armopts.s.in +37 -0
- package/opus/celt/arm/celt_fft_ne10.c +173 -0
- package/opus/celt/arm/celt_mdct_ne10.c +258 -0
- package/opus/celt/arm/celt_neon_intr.c +272 -0
- package/opus/celt/arm/celt_pitch_xcorr_arm.s +551 -0
- package/opus/celt/arm/fft_arm.h +71 -0
- package/opus/celt/arm/fixed_arm64.h +35 -0
- package/opus/celt/arm/fixed_armv4.h +80 -0
- package/opus/celt/arm/fixed_armv5e.h +151 -0
- package/opus/celt/arm/kiss_fft_armv4.h +121 -0
- package/opus/celt/arm/kiss_fft_armv5e.h +118 -0
- package/opus/celt/arm/mdct_arm.h +59 -0
- package/opus/celt/arm/meson.build +12 -0
- package/opus/celt/arm/pitch_arm.h +160 -0
- package/opus/celt/arm/pitch_neon_intr.c +288 -0
- package/opus/celt/bands.c +1686 -0
- package/opus/celt/bands.h +123 -0
- package/opus/celt/celt.c +317 -0
- package/opus/celt/celt.h +255 -0
- package/opus/celt/celt_decoder.c +1616 -0
- package/opus/celt/celt_encoder.c +2854 -0
- package/opus/celt/celt_lpc.c +364 -0
- package/opus/celt/celt_lpc.h +66 -0
- package/opus/celt/cpu_support.h +72 -0
- package/opus/celt/cwrs.c +715 -0
- package/opus/celt/cwrs.h +48 -0
- package/opus/celt/dump_modes/dump_modes.c +400 -0
- package/opus/celt/dump_modes/dump_modes_arch.h +45 -0
- package/opus/celt/dump_modes/dump_modes_arm_ne10.c +152 -0
- package/opus/celt/ecintrin.h +91 -0
- package/opus/celt/entcode.c +153 -0
- package/opus/celt/entcode.h +152 -0
- package/opus/celt/entdec.c +266 -0
- package/opus/celt/entdec.h +110 -0
- package/opus/celt/entenc.c +305 -0
- package/opus/celt/entenc.h +119 -0
- package/opus/celt/fixed_c5x.h +79 -0
- package/opus/celt/fixed_c6x.h +70 -0
- package/opus/celt/fixed_debug.h +839 -0
- package/opus/celt/fixed_generic.h +201 -0
- package/opus/celt/float_cast.h +152 -0
- package/opus/celt/kiss_fft.c +648 -0
- package/opus/celt/kiss_fft.h +217 -0
- package/opus/celt/laplace.c +235 -0
- package/opus/celt/laplace.h +57 -0
- package/opus/celt/mathops.c +217 -0
- package/opus/celt/mathops.h +479 -0
- package/opus/celt/mdct.c +372 -0
- package/opus/celt/mdct.h +115 -0
- package/opus/celt/meson.build +64 -0
- package/opus/celt/mfrngcod.h +48 -0
- package/opus/celt/mips/celt_mipsr1.h +152 -0
- package/opus/celt/mips/fixed_generic_mipsr1.h +126 -0
- package/opus/celt/mips/kiss_fft_mipsr1.h +167 -0
- package/opus/celt/mips/mdct_mipsr1.h +288 -0
- package/opus/celt/mips/pitch_mipsr1.h +161 -0
- package/opus/celt/mips/vq_mipsr1.h +116 -0
- package/opus/celt/modes.c +450 -0
- package/opus/celt/modes.h +75 -0
- package/opus/celt/opus_custom_demo.c +451 -0
- package/opus/celt/os_support.h +99 -0
- package/opus/celt/pitch.c +555 -0
- package/opus/celt/pitch.h +203 -0
- package/opus/celt/quant_bands.c +562 -0
- package/opus/celt/quant_bands.h +66 -0
- package/opus/celt/rate.c +646 -0
- package/opus/celt/rate.h +101 -0
- package/opus/celt/stack_alloc.h +185 -0
- package/opus/celt/static_modes_fixed.h +1541 -0
- package/opus/celt/static_modes_fixed_arm_ne10.h +388 -0
- package/opus/celt/static_modes_float.h +888 -0
- package/opus/celt/static_modes_float_arm_ne10.h +404 -0
- package/opus/celt/tests/meson.build +19 -0
- package/opus/celt/tests/test_unit_cwrs32.c +162 -0
- package/opus/celt/tests/test_unit_dft.c +181 -0
- package/opus/celt/tests/test_unit_entropy.c +383 -0
- package/opus/celt/tests/test_unit_laplace.c +94 -0
- package/opus/celt/tests/test_unit_mathops.c +369 -0
- package/opus/celt/tests/test_unit_mdct.c +233 -0
- package/opus/celt/tests/test_unit_rotation.c +87 -0
- package/opus/celt/tests/test_unit_types.c +50 -0
- package/opus/celt/vq.c +442 -0
- package/opus/celt/vq.h +79 -0
- package/opus/celt/x86/celt_lpc_sse.h +67 -0
- package/opus/celt/x86/celt_lpc_sse4_1.c +96 -0
- package/opus/celt/x86/pitch_avx.c +101 -0
- package/opus/celt/x86/pitch_sse.c +185 -0
- package/opus/celt/x86/pitch_sse.h +216 -0
- package/opus/celt/x86/pitch_sse2.c +95 -0
- package/opus/celt/x86/pitch_sse4_1.c +240 -0
- package/opus/celt/x86/vq_sse.h +52 -0
- package/opus/celt/x86/vq_sse2.c +217 -0
- package/opus/celt/x86/x86_arch_macros.h +47 -0
- package/opus/celt/x86/x86_celt_map.c +187 -0
- package/opus/celt/x86/x86cpu.c +184 -0
- package/opus/celt/x86/x86cpu.h +112 -0
- package/opus/celt_headers.mk +54 -0
- package/opus/celt_sources.mk +55 -0
- package/opus/cmake/CFeatureCheck.cmake +39 -0
- package/opus/cmake/OpusBuildtype.cmake +27 -0
- package/opus/cmake/OpusConfig.cmake +118 -0
- package/opus/cmake/OpusConfig.cmake.in +20 -0
- package/opus/cmake/OpusFunctions.cmake +231 -0
- package/opus/cmake/OpusPackageVersion.cmake +70 -0
- package/opus/cmake/OpusSources.cmake +71 -0
- package/opus/cmake/README.md +132 -0
- package/opus/cmake/RunTest.cmake +61 -0
- package/opus/cmake/config.h.cmake.in +1 -0
- package/opus/cmake/cpu_info_by_asm.c +31 -0
- package/opus/cmake/cpu_info_by_c.c +9 -0
- package/opus/cmake/vla.c +7 -0
- package/opus/configure.ac +1091 -0
- package/opus/dnn/LPCNet.yml +24 -0
- package/opus/dnn/README +1 -0
- package/opus/dnn/README.md +126 -0
- package/opus/dnn/adaconvtest.c +449 -0
- package/opus/dnn/arm/arm_dnn_map.c +88 -0
- package/opus/dnn/arm/dnn_arm.h +104 -0
- package/opus/dnn/arm/nnet_dotprod.c +38 -0
- package/opus/dnn/arm/nnet_neon.c +38 -0
- package/opus/dnn/burg.c +246 -0
- package/opus/dnn/burg.h +41 -0
- package/opus/dnn/common.h +56 -0
- package/opus/dnn/datasets.txt +163 -0
- package/opus/dnn/download_model.bat +9 -0
- package/opus/dnn/download_model.sh +30 -0
- package/opus/dnn/dred_coding.c +44 -0
- package/opus/dnn/dred_coding.h +36 -0
- package/opus/dnn/dred_config.h +54 -0
- package/opus/dnn/dred_decoder.c +129 -0
- package/opus/dnn/dred_decoder.h +49 -0
- package/opus/dnn/dred_encoder.c +363 -0
- package/opus/dnn/dred_encoder.h +71 -0
- package/opus/dnn/dred_rdovae.h +42 -0
- package/opus/dnn/dred_rdovae_dec.c +139 -0
- package/opus/dnn/dred_rdovae_dec.h +53 -0
- package/opus/dnn/dred_rdovae_enc.c +110 -0
- package/opus/dnn/dred_rdovae_enc.h +52 -0
- package/opus/dnn/dump_data.c +238 -0
- package/opus/dnn/dump_lpcnet_tables.c +104 -0
- package/opus/dnn/fargan.c +225 -0
- package/opus/dnn/fargan.h +68 -0
- package/opus/dnn/fargan_demo.c +217 -0
- package/opus/dnn/freq.c +328 -0
- package/opus/dnn/freq.h +61 -0
- package/opus/dnn/fwgan.c +322 -0
- package/opus/dnn/fwgan.h +83 -0
- package/opus/dnn/kiss99.c +81 -0
- package/opus/dnn/kiss99.h +46 -0
- package/opus/dnn/lossgen.c +192 -0
- package/opus/dnn/lossgen.h +55 -0
- package/opus/dnn/lossgen_demo.c +22 -0
- package/opus/dnn/lpcnet.c +283 -0
- package/opus/dnn/lpcnet.h +183 -0
- package/opus/dnn/lpcnet_enc.c +230 -0
- package/opus/dnn/lpcnet_plc.c +211 -0
- package/opus/dnn/lpcnet_private.h +90 -0
- package/opus/dnn/lpcnet_tables.c +307 -0
- package/opus/dnn/meson.build +64 -0
- package/opus/dnn/nndsp.c +416 -0
- package/opus/dnn/nndsp.h +143 -0
- package/opus/dnn/nnet.c +149 -0
- package/opus/dnn/nnet.h +163 -0
- package/opus/dnn/nnet_arch.h +247 -0
- package/opus/dnn/nnet_default.c +35 -0
- package/opus/dnn/osce.c +1419 -0
- package/opus/dnn/osce.h +84 -0
- package/opus/dnn/osce_config.h +60 -0
- package/opus/dnn/osce_features.c +454 -0
- package/opus/dnn/osce_features.h +50 -0
- package/opus/dnn/osce_structs.h +125 -0
- package/opus/dnn/parse_lpcnet_weights.c +238 -0
- package/opus/dnn/pitchdnn.c +79 -0
- package/opus/dnn/pitchdnn.h +34 -0
- package/opus/dnn/tansig_table.h +50 -0
- package/opus/dnn/test_vec.c +128 -0
- package/opus/dnn/torch/dnntools/dnntools/__init__.py +2 -0
- package/opus/dnn/torch/dnntools/dnntools/quantization/__init__.py +1 -0
- package/opus/dnn/torch/dnntools/dnntools/quantization/softquant.py +113 -0
- package/opus/dnn/torch/dnntools/dnntools/relegance/__init__.py +2 -0
- package/opus/dnn/torch/dnntools/dnntools/relegance/meta_critic.py +85 -0
- package/opus/dnn/torch/dnntools/dnntools/relegance/relegance.py +449 -0
- package/opus/dnn/torch/dnntools/dnntools/sparsification/__init__.py +6 -0
- package/opus/dnn/torch/dnntools/dnntools/sparsification/base_sparsifier.py +58 -0
- package/opus/dnn/torch/dnntools/dnntools/sparsification/common.py +123 -0
- package/opus/dnn/torch/dnntools/dnntools/sparsification/conv1d_sparsifier.py +133 -0
- package/opus/dnn/torch/dnntools/dnntools/sparsification/conv_transpose1d_sparsifier.py +134 -0
- package/opus/dnn/torch/dnntools/dnntools/sparsification/gru_sparsifier.py +178 -0
- package/opus/dnn/torch/dnntools/dnntools/sparsification/linear_sparsifier.py +128 -0
- package/opus/dnn/torch/dnntools/dnntools/sparsification/utils.py +64 -0
- package/opus/dnn/torch/dnntools/requirements.txt +1 -0
- package/opus/dnn/torch/dnntools/setup.py +48 -0
- package/opus/dnn/torch/fargan/README.md +54 -0
- package/opus/dnn/torch/fargan/adv_train_fargan.py +277 -0
- package/opus/dnn/torch/fargan/dataset.py +61 -0
- package/opus/dnn/torch/fargan/dump_fargan_weights.py +112 -0
- package/opus/dnn/torch/fargan/fargan.py +322 -0
- package/opus/dnn/torch/fargan/filters.py +46 -0
- package/opus/dnn/torch/fargan/rc.py +29 -0
- package/opus/dnn/torch/fargan/stft_loss.py +186 -0
- package/opus/dnn/torch/fargan/test_fargan.py +128 -0
- package/opus/dnn/torch/fargan/train_fargan.py +168 -0
- package/opus/dnn/torch/fwgan/dump_model_weights.py +88 -0
- package/opus/dnn/torch/fwgan/inference.py +141 -0
- package/opus/dnn/torch/fwgan/models/__init__.py +7 -0
- package/opus/dnn/torch/fwgan/models/fwgan400.py +308 -0
- package/opus/dnn/torch/fwgan/models/fwgan500.py +260 -0
- package/opus/dnn/torch/lossgen/README.md +27 -0
- package/opus/dnn/torch/lossgen/export_lossgen.py +101 -0
- package/opus/dnn/torch/lossgen/lossgen.py +29 -0
- package/opus/dnn/torch/lossgen/process_data.sh +17 -0
- package/opus/dnn/torch/lossgen/test_lossgen.py +42 -0
- package/opus/dnn/torch/lossgen/train_lossgen.py +99 -0
- package/opus/dnn/torch/lpcnet/README.md +27 -0
- package/opus/dnn/torch/lpcnet/add_dataset_config.py +77 -0
- package/opus/dnn/torch/lpcnet/data/__init__.py +1 -0
- package/opus/dnn/torch/lpcnet/data/lpcnet_dataset.py +227 -0
- package/opus/dnn/torch/lpcnet/engine/lpcnet_engine.py +141 -0
- package/opus/dnn/torch/lpcnet/make_default_setup.py +56 -0
- package/opus/dnn/torch/lpcnet/make_test_config.py +78 -0
- package/opus/dnn/torch/lpcnet/models/__init__.py +8 -0
- package/opus/dnn/torch/lpcnet/models/lpcnet.py +303 -0
- package/opus/dnn/torch/lpcnet/models/multi_rate_lpcnet.py +437 -0
- package/opus/dnn/torch/lpcnet/print_lpcnet_complexity.py +64 -0
- package/opus/dnn/torch/lpcnet/scripts/collect_multi_run_results.py +190 -0
- package/opus/dnn/torch/lpcnet/scripts/loop_run.sh +52 -0
- package/opus/dnn/torch/lpcnet/scripts/make_animation.py +67 -0
- package/opus/dnn/torch/lpcnet/scripts/modify_dataset_target.py +17 -0
- package/opus/dnn/torch/lpcnet/scripts/multi_run.sh +17 -0
- package/opus/dnn/torch/lpcnet/scripts/run_inference_test.sh +22 -0
- package/opus/dnn/torch/lpcnet/scripts/update_checkpoints.py +54 -0
- package/opus/dnn/torch/lpcnet/scripts/update_output_folder.sh +22 -0
- package/opus/dnn/torch/lpcnet/scripts/update_setups.py +57 -0
- package/opus/dnn/torch/lpcnet/test_lpcnet.py +89 -0
- package/opus/dnn/torch/lpcnet/train_lpcnet.py +272 -0
- package/opus/dnn/torch/lpcnet/utils/__init__.py +4 -0
- package/opus/dnn/torch/lpcnet/utils/data.py +141 -0
- package/opus/dnn/torch/lpcnet/utils/endoscopy.py +234 -0
- package/opus/dnn/torch/lpcnet/utils/layers/__init__.py +3 -0
- package/opus/dnn/torch/lpcnet/utils/layers/dual_fc.py +44 -0
- package/opus/dnn/torch/lpcnet/utils/layers/pcm_embeddings.py +71 -0
- package/opus/dnn/torch/lpcnet/utils/layers/subconditioner.py +497 -0
- package/opus/dnn/torch/lpcnet/utils/misc.py +65 -0
- package/opus/dnn/torch/lpcnet/utils/pcm.py +35 -0
- package/opus/dnn/torch/lpcnet/utils/sample.py +44 -0
- package/opus/dnn/torch/lpcnet/utils/sparsification/__init__.py +2 -0
- package/opus/dnn/torch/lpcnet/utils/sparsification/common.py +121 -0
- package/opus/dnn/torch/lpcnet/utils/sparsification/gru_sparsifier.py +187 -0
- package/opus/dnn/torch/lpcnet/utils/templates.py +157 -0
- package/opus/dnn/torch/lpcnet/utils/ulaw.py +58 -0
- package/opus/dnn/torch/lpcnet/utils/wav.py +43 -0
- package/opus/dnn/torch/neural-pitch/README.md +18 -0
- package/opus/dnn/torch/neural-pitch/data_augmentation.py +149 -0
- package/opus/dnn/torch/neural-pitch/download_demand.sh +43 -0
- package/opus/dnn/torch/neural-pitch/evaluation.py +349 -0
- package/opus/dnn/torch/neural-pitch/experiments.py +38 -0
- package/opus/dnn/torch/neural-pitch/export_neuralpitch_weights.py +109 -0
- package/opus/dnn/torch/neural-pitch/models.py +178 -0
- package/opus/dnn/torch/neural-pitch/neural_pitch_update.py +179 -0
- package/opus/dnn/torch/neural-pitch/ptdb_process.sh +34 -0
- package/opus/dnn/torch/neural-pitch/run_crepe.py +72 -0
- package/opus/dnn/torch/neural-pitch/training.py +162 -0
- package/opus/dnn/torch/neural-pitch/utils.py +59 -0
- package/opus/dnn/torch/osce/README.md +66 -0
- package/opus/dnn/torch/osce/adv_train_model.py +462 -0
- package/opus/dnn/torch/osce/adv_train_vocoder.py +451 -0
- package/opus/dnn/torch/osce/create_testvectors.py +165 -0
- package/opus/dnn/torch/osce/data/__init__.py +2 -0
- package/opus/dnn/torch/osce/data/lpcnet_vocoding_dataset.py +225 -0
- package/opus/dnn/torch/osce/data/silk_conversion_set.py +132 -0
- package/opus/dnn/torch/osce/data/silk_enhancement_set.py +140 -0
- package/opus/dnn/torch/osce/engine/engine.py +103 -0
- package/opus/dnn/torch/osce/engine/vocoder_engine.py +101 -0
- package/opus/dnn/torch/osce/export_model_weights.py +174 -0
- package/opus/dnn/torch/osce/losses/stft_loss.py +277 -0
- package/opus/dnn/torch/osce/losses/td_lowpass.py +34 -0
- package/opus/dnn/torch/osce/make_default_setup.py +93 -0
- package/opus/dnn/torch/osce/models/__init__.py +42 -0
- package/opus/dnn/torch/osce/models/fd_discriminator.py +974 -0
- package/opus/dnn/torch/osce/models/lace.py +190 -0
- package/opus/dnn/torch/osce/models/lavoce.py +274 -0
- package/opus/dnn/torch/osce/models/lavoce_400.py +254 -0
- package/opus/dnn/torch/osce/models/lpcnet_feature_net.py +91 -0
- package/opus/dnn/torch/osce/models/nns_base.py +69 -0
- package/opus/dnn/torch/osce/models/no_lace.py +218 -0
- package/opus/dnn/torch/osce/models/scale_embedding.py +68 -0
- package/opus/dnn/torch/osce/models/shape_up_48.py +179 -0
- package/opus/dnn/torch/osce/models/silk_feature_net.py +86 -0
- package/opus/dnn/torch/osce/models/silk_feature_net_pl.py +127 -0
- package/opus/dnn/torch/osce/requirements.txt +9 -0
- package/opus/dnn/torch/osce/resources/training_files.txt +107716 -0
- package/opus/dnn/torch/osce/resources/validation_files.txt +26929 -0
- package/opus/dnn/torch/osce/scripts/concatenator.py +85 -0
- package/opus/dnn/torch/osce/silk_16_to_48.py +28 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/commonvoice_clip_selection.py +123 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/create_input_data.sh +25 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/env.rc +7 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/evaluate.py +113 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/lace_loss_metric.py +330 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/make_boxplots.py +116 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/make_boxplots_moctest.py +109 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/make_tables.py +124 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/make_tables_moctest.py +121 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/moc.py +182 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/moc2.py +190 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/process_dataset.sh +98 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/run_nomad.py +138 -0
- package/opus/dnn/torch/osce/stndrd/evaluation/run_osce_test.py +196 -0
- package/opus/dnn/torch/osce/stndrd/presentation/endoscopy.py +205 -0
- package/opus/dnn/torch/osce/stndrd/presentation/lace_demo.ipynb +313 -0
- package/opus/dnn/torch/osce/stndrd/presentation/linear_prediction.ipynb +320 -0
- package/opus/dnn/torch/osce/stndrd/presentation/playback.py +25 -0
- package/opus/dnn/torch/osce/stndrd/presentation/postfilter.ipynb +275 -0
- package/opus/dnn/torch/osce/stndrd/presentation/spectrogram.ipynb +173 -0
- package/opus/dnn/torch/osce/test_model.py +96 -0
- package/opus/dnn/torch/osce/test_vocoder.py +103 -0
- package/opus/dnn/torch/osce/train_model.py +307 -0
- package/opus/dnn/torch/osce/train_vocoder.py +287 -0
- package/opus/dnn/torch/osce/utils/ada_conv.py +71 -0
- package/opus/dnn/torch/osce/utils/complexity.py +8 -0
- package/opus/dnn/torch/osce/utils/endoscopy.py +205 -0
- package/opus/dnn/torch/osce/utils/layers/fir.py +27 -0
- package/opus/dnn/torch/osce/utils/layers/limited_adaptive_comb1d.py +230 -0
- package/opus/dnn/torch/osce/utils/layers/limited_adaptive_conv1d.py +200 -0
- package/opus/dnn/torch/osce/utils/layers/noise_shaper.py +100 -0
- package/opus/dnn/torch/osce/utils/layers/pitch_auto_correlator.py +84 -0
- package/opus/dnn/torch/osce/utils/layers/silk_upsampler.py +167 -0
- package/opus/dnn/torch/osce/utils/layers/td_shaper.py +145 -0
- package/opus/dnn/torch/osce/utils/lpcnet_features.py +112 -0
- package/opus/dnn/torch/osce/utils/misc.py +95 -0
- package/opus/dnn/torch/osce/utils/moc.py +153 -0
- package/opus/dnn/torch/osce/utils/pitch.py +122 -0
- package/opus/dnn/torch/osce/utils/silk_features.py +144 -0
- package/opus/dnn/torch/osce/utils/softquant.py +110 -0
- package/opus/dnn/torch/osce/utils/spec.py +210 -0
- package/opus/dnn/torch/osce/utils/templates.py +347 -0
- package/opus/dnn/torch/plc/export_plc.py +100 -0
- package/opus/dnn/torch/plc/plc.py +144 -0
- package/opus/dnn/torch/plc/plc_dataset.py +60 -0
- package/opus/dnn/torch/plc/train_plc.py +145 -0
- package/opus/dnn/torch/rdovae/README.md +55 -0
- package/opus/dnn/torch/rdovae/download_datasets.sh +6 -0
- package/opus/dnn/torch/rdovae/export_rdovae_weights.py +365 -0
- package/opus/dnn/torch/rdovae/fec_encoder.py +212 -0
- package/opus/dnn/torch/rdovae/import_rdovae_weights.py +143 -0
- package/opus/dnn/torch/rdovae/packets/__init__.py +1 -0
- package/opus/dnn/torch/rdovae/packets/fec_packets.c +142 -0
- package/opus/dnn/torch/rdovae/packets/fec_packets.h +34 -0
- package/opus/dnn/torch/rdovae/packets/fec_packets.py +108 -0
- package/opus/dnn/torch/rdovae/process_speech.sh +7 -0
- package/opus/dnn/torch/rdovae/rdovae/__init__.py +2 -0
- package/opus/dnn/torch/rdovae/rdovae/dataset.py +67 -0
- package/opus/dnn/torch/rdovae/rdovae/rdovae.py +719 -0
- package/opus/dnn/torch/rdovae/requirements.txt +4 -0
- package/opus/dnn/torch/rdovae/train_rdovae.py +278 -0
- package/opus/dnn/torch/testsuite/README.md +46 -0
- package/opus/dnn/torch/testsuite/examples/lpcnet_c_example.yml +6 -0
- package/opus/dnn/torch/testsuite/examples/lpcnet_c_plc_example.yml +5 -0
- package/opus/dnn/torch/testsuite/examples/lpcnet_torch_example.yml +5 -0
- package/opus/dnn/torch/testsuite/requirements.txt +12 -0
- package/opus/dnn/torch/testsuite/run_test.py +375 -0
- package/opus/dnn/torch/testsuite/utils/__init__.py +0 -0
- package/opus/dnn/torch/testsuite/utils/files.py +54 -0
- package/opus/dnn/torch/testsuite/utils/pesq.py +43 -0
- package/opus/dnn/torch/testsuite/utils/pitch.py +61 -0
- package/opus/dnn/torch/weight-exchange/README.md +21 -0
- package/opus/dnn/torch/weight-exchange/requirements.txt +1 -0
- package/opus/dnn/torch/weight-exchange/setup.py +48 -0
- package/opus/dnn/torch/weight-exchange/wexchange/__init__.py +30 -0
- package/opus/dnn/torch/weight-exchange/wexchange/c_export/__init__.py +31 -0
- package/opus/dnn/torch/weight-exchange/wexchange/c_export/c_writer.py +181 -0
- package/opus/dnn/torch/weight-exchange/wexchange/c_export/common.py +386 -0
- package/opus/dnn/torch/weight-exchange/wexchange/tf/__init__.py +5 -0
- package/opus/dnn/torch/weight-exchange/wexchange/tf/tf.py +188 -0
- package/opus/dnn/torch/weight-exchange/wexchange/torch/__init__.py +37 -0
- package/opus/dnn/torch/weight-exchange/wexchange/torch/torch.py +433 -0
- package/opus/dnn/training_tf2/dataloader.py +49 -0
- package/opus/dnn/training_tf2/decode_rdovae.py +111 -0
- package/opus/dnn/training_tf2/diffembed.py +49 -0
- package/opus/dnn/training_tf2/dump_lpcnet.py +388 -0
- package/opus/dnn/training_tf2/dump_plc.py +296 -0
- package/opus/dnn/training_tf2/dump_rdovae.py +306 -0
- package/opus/dnn/training_tf2/encode_rdovae.py +125 -0
- package/opus/dnn/training_tf2/fec_encoder.py +256 -0
- package/opus/dnn/training_tf2/fec_packets.c +142 -0
- package/opus/dnn/training_tf2/fec_packets.h +34 -0
- package/opus/dnn/training_tf2/fec_packets.py +108 -0
- package/opus/dnn/training_tf2/keraslayerdump.py +189 -0
- package/opus/dnn/training_tf2/lossfuncs.py +99 -0
- package/opus/dnn/training_tf2/lpcnet.py +339 -0
- package/opus/dnn/training_tf2/lpcnet_plc.py +101 -0
- package/opus/dnn/training_tf2/mdense.py +95 -0
- package/opus/dnn/training_tf2/pade.py +70 -0
- package/opus/dnn/training_tf2/parameters.py +29 -0
- package/opus/dnn/training_tf2/plc_loader.py +73 -0
- package/opus/dnn/training_tf2/rdovae.py +372 -0
- package/opus/dnn/training_tf2/rdovae_exchange.py +138 -0
- package/opus/dnn/training_tf2/rdovae_import.py +123 -0
- package/opus/dnn/training_tf2/test_lpcnet.py +120 -0
- package/opus/dnn/training_tf2/test_plc.py +92 -0
- package/opus/dnn/training_tf2/tf_funcs.py +70 -0
- package/opus/dnn/training_tf2/train_lpcnet.py +214 -0
- package/opus/dnn/training_tf2/train_plc.py +197 -0
- package/opus/dnn/training_tf2/train_rdovae.py +151 -0
- package/opus/dnn/training_tf2/ulaw.py +19 -0
- package/opus/dnn/training_tf2/uniform_noise.py +78 -0
- package/opus/dnn/vec.h +389 -0
- package/opus/dnn/vec_avx.h +884 -0
- package/opus/dnn/vec_neon.h +473 -0
- package/opus/dnn/write_lpcnet_weights.c +97 -0
- package/opus/dnn/x86/dnn_x86.h +121 -0
- package/opus/dnn/x86/nnet_avx2.c +40 -0
- package/opus/dnn/x86/nnet_sse2.c +40 -0
- package/opus/dnn/x86/nnet_sse4_1.c +40 -0
- package/opus/dnn/x86/x86_dnn_map.c +83 -0
- package/opus/doc/Doxyfile.in +340 -0
- package/opus/doc/Makefile.am +45 -0
- package/opus/doc/build_draft.sh +113 -0
- package/opus/doc/build_isobmff.sh +50 -0
- package/opus/doc/build_oggdraft.sh +52 -0
- package/opus/doc/customdoxygen.css +1011 -0
- package/opus/doc/draft-ietf-codec-oggopus.xml +1873 -0
- package/opus/doc/draft-ietf-codec-opus-update.xml +513 -0
- package/opus/doc/draft-ietf-codec-opus.xml +8276 -0
- package/opus/doc/draft-ietf-payload-rtp-opus.xml +960 -0
- package/opus/doc/footer.html +32 -0
- package/opus/doc/header.html +61 -0
- package/opus/doc/meson.build +33 -0
- package/opus/doc/opus_in_isobmff.css +60 -0
- package/opus/doc/opus_in_isobmff.html +692 -0
- package/opus/doc/opus_logo.svg +157 -0
- package/opus/doc/opus_update.patch +244 -0
- package/opus/doc/release.txt +43 -0
- package/opus/doc/trivial_example.c +171 -0
- package/opus/include/meson.build +13 -0
- package/opus/include/opus.h +1172 -0
- package/opus/include/opus_custom.h +381 -0
- package/opus/include/opus_defines.h +830 -0
- package/opus/include/opus_multistream.h +736 -0
- package/opus/include/opus_projection.h +643 -0
- package/opus/include/opus_types.h +166 -0
- package/opus/lpcnet_headers.mk +44 -0
- package/opus/lpcnet_sources.mk +44 -0
- package/opus/m4/as-gcc-inline-assembly.m4 +98 -0
- package/opus/m4/ax_add_fortify_source.m4 +53 -0
- package/opus/m4/opus-intrinsics.m4 +29 -0
- package/opus/meson/README.md +88 -0
- package/opus/meson/get-version.py +86 -0
- package/opus/meson/read-sources-list.py +28 -0
- package/opus/meson.build +745 -0
- package/opus/meson_options.txt +27 -0
- package/opus/opus-uninstalled.pc.in +12 -0
- package/opus/opus.m4 +117 -0
- package/opus/opus.pc.in +16 -0
- package/opus/opus_headers.mk +8 -0
- package/opus/opus_sources.mk +17 -0
- package/opus/releases.sha2 +85 -0
- package/opus/scripts/dump_rnn.py +57 -0
- package/opus/scripts/local_build.py +220 -0
- package/opus/scripts/rnn_train.py +67 -0
- package/opus/scripts/shrink_model.sh +7 -0
- package/opus/silk/A2NLSF.c +267 -0
- package/opus/silk/API.h +156 -0
- package/opus/silk/CNG.c +188 -0
- package/opus/silk/HP_variable_cutoff.c +77 -0
- package/opus/silk/Inlines.h +188 -0
- package/opus/silk/LPC_analysis_filter.c +111 -0
- package/opus/silk/LPC_fit.c +82 -0
- package/opus/silk/LPC_inv_pred_gain.c +141 -0
- package/opus/silk/LP_variable_cutoff.c +135 -0
- package/opus/silk/MacroCount.h +710 -0
- package/opus/silk/MacroDebug.h +945 -0
- package/opus/silk/NLSF2A.c +141 -0
- package/opus/silk/NLSF_VQ.c +76 -0
- package/opus/silk/NLSF_VQ_weights_laroia.c +80 -0
- package/opus/silk/NLSF_decode.c +93 -0
- package/opus/silk/NLSF_del_dec_quant.c +215 -0
- package/opus/silk/NLSF_encode.c +124 -0
- package/opus/silk/NLSF_stabilize.c +142 -0
- package/opus/silk/NLSF_unpack.c +55 -0
- package/opus/silk/NSQ.c +437 -0
- package/opus/silk/NSQ.h +101 -0
- package/opus/silk/NSQ_del_dec.c +733 -0
- package/opus/silk/PLC.c +493 -0
- package/opus/silk/PLC.h +65 -0
- package/opus/silk/SigProc_FIX.h +643 -0
- package/opus/silk/VAD.c +360 -0
- package/opus/silk/VQ_WMat_EC.c +131 -0
- package/opus/silk/ana_filt_bank_1.c +74 -0
- package/opus/silk/arm/LPC_inv_pred_gain_arm.h +57 -0
- package/opus/silk/arm/LPC_inv_pred_gain_neon_intr.c +288 -0
- package/opus/silk/arm/NSQ_del_dec_arm.h +100 -0
- package/opus/silk/arm/NSQ_del_dec_neon_intr.c +1138 -0
- package/opus/silk/arm/NSQ_neon.c +112 -0
- package/opus/silk/arm/NSQ_neon.h +114 -0
- package/opus/silk/arm/SigProc_FIX_armv4.h +47 -0
- package/opus/silk/arm/SigProc_FIX_armv5e.h +61 -0
- package/opus/silk/arm/arm_silk_map.c +128 -0
- package/opus/silk/arm/biquad_alt_arm.h +68 -0
- package/opus/silk/arm/biquad_alt_neon_intr.c +156 -0
- package/opus/silk/arm/macros_arm64.h +39 -0
- package/opus/silk/arm/macros_armv4.h +110 -0
- package/opus/silk/arm/macros_armv5e.h +220 -0
- package/opus/silk/biquad_alt.c +121 -0
- package/opus/silk/bwexpander.c +51 -0
- package/opus/silk/bwexpander_32.c +51 -0
- package/opus/silk/check_control_input.c +106 -0
- package/opus/silk/code_signs.c +115 -0
- package/opus/silk/control.h +161 -0
- package/opus/silk/control_SNR.c +113 -0
- package/opus/silk/control_audio_bandwidth.c +132 -0
- package/opus/silk/control_codec.c +423 -0
- package/opus/silk/debug.c +174 -0
- package/opus/silk/debug.h +267 -0
- package/opus/silk/dec_API.c +465 -0
- package/opus/silk/decode_core.c +243 -0
- package/opus/silk/decode_frame.c +169 -0
- package/opus/silk/decode_indices.c +151 -0
- package/opus/silk/decode_parameters.c +115 -0
- package/opus/silk/decode_pitch.c +77 -0
- package/opus/silk/decode_pulses.c +115 -0
- package/opus/silk/decoder_set_fs.c +108 -0
- package/opus/silk/define.h +235 -0
- package/opus/silk/enc_API.c +593 -0
- package/opus/silk/encode_indices.c +181 -0
- package/opus/silk/encode_pulses.c +206 -0
- package/opus/silk/errors.h +98 -0
- package/opus/silk/fixed/LTP_analysis_filter_FIX.c +90 -0
- package/opus/silk/fixed/LTP_scale_ctrl_FIX.c +58 -0
- package/opus/silk/fixed/apply_sine_window_FIX.c +101 -0
- package/opus/silk/fixed/arm/warped_autocorrelation_FIX_arm.h +68 -0
- package/opus/silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c +265 -0
- package/opus/silk/fixed/autocorr_FIX.c +48 -0
- package/opus/silk/fixed/burg_modified_FIX.c +280 -0
- package/opus/silk/fixed/corrMatrix_FIX.c +150 -0
- package/opus/silk/fixed/encode_frame_FIX.c +444 -0
- package/opus/silk/fixed/find_LPC_FIX.c +151 -0
- package/opus/silk/fixed/find_LTP_FIX.c +99 -0
- package/opus/silk/fixed/find_pitch_lags_FIX.c +143 -0
- package/opus/silk/fixed/find_pred_coefs_FIX.c +146 -0
- package/opus/silk/fixed/k2a_FIX.c +54 -0
- package/opus/silk/fixed/k2a_Q16_FIX.c +54 -0
- package/opus/silk/fixed/main_FIX.h +244 -0
- package/opus/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h +336 -0
- package/opus/silk/fixed/mips/prefilter_FIX_mipsr1.h +184 -0
- package/opus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h +165 -0
- package/opus/silk/fixed/noise_shape_analysis_FIX.c +407 -0
- package/opus/silk/fixed/pitch_analysis_core_FIX.c +721 -0
- package/opus/silk/fixed/process_gains_FIX.c +117 -0
- package/opus/silk/fixed/regularize_correlations_FIX.c +47 -0
- package/opus/silk/fixed/residual_energy16_FIX.c +103 -0
- package/opus/silk/fixed/residual_energy_FIX.c +98 -0
- package/opus/silk/fixed/schur64_FIX.c +93 -0
- package/opus/silk/fixed/schur_FIX.c +107 -0
- package/opus/silk/fixed/structs_FIX.h +116 -0
- package/opus/silk/fixed/vector_ops_FIX.c +102 -0
- package/opus/silk/fixed/warped_autocorrelation_FIX.c +92 -0
- package/opus/silk/fixed/x86/burg_modified_FIX_sse4_1.c +400 -0
- package/opus/silk/fixed/x86/vector_ops_FIX_sse4_1.c +93 -0
- package/opus/silk/float/LPC_analysis_filter_FLP.c +249 -0
- package/opus/silk/float/LPC_inv_pred_gain_FLP.c +73 -0
- package/opus/silk/float/LTP_analysis_filter_FLP.c +75 -0
- package/opus/silk/float/LTP_scale_ctrl_FLP.c +58 -0
- package/opus/silk/float/SigProc_FLP.h +205 -0
- package/opus/silk/float/apply_sine_window_FLP.c +81 -0
- package/opus/silk/float/autocorrelation_FLP.c +53 -0
- package/opus/silk/float/burg_modified_FLP.c +187 -0
- package/opus/silk/float/bwexpander_FLP.c +49 -0
- package/opus/silk/float/corrMatrix_FLP.c +95 -0
- package/opus/silk/float/encode_frame_FLP.c +432 -0
- package/opus/silk/float/energy_FLP.c +59 -0
- package/opus/silk/float/find_LPC_FLP.c +105 -0
- package/opus/silk/float/find_LTP_FLP.c +65 -0
- package/opus/silk/float/find_pitch_lags_FLP.c +132 -0
- package/opus/silk/float/find_pred_coefs_FLP.c +117 -0
- package/opus/silk/float/inner_product_FLP.c +59 -0
- package/opus/silk/float/k2a_FLP.c +54 -0
- package/opus/silk/float/main_FLP.h +290 -0
- package/opus/silk/float/noise_shape_analysis_FLP.c +350 -0
- package/opus/silk/float/pitch_analysis_core_FLP.c +630 -0
- package/opus/silk/float/process_gains_FLP.c +103 -0
- package/opus/silk/float/regularize_correlations_FLP.c +48 -0
- package/opus/silk/float/residual_energy_FLP.c +117 -0
- package/opus/silk/float/scale_copy_vector_FLP.c +57 -0
- package/opus/silk/float/scale_vector_FLP.c +56 -0
- package/opus/silk/float/schur_FLP.c +70 -0
- package/opus/silk/float/sort_FLP.c +83 -0
- package/opus/silk/float/structs_FLP.h +112 -0
- package/opus/silk/float/warped_autocorrelation_FLP.c +75 -0
- package/opus/silk/float/wrappers_FLP.c +209 -0
- package/opus/silk/float/x86/inner_product_FLP_avx2.c +85 -0
- package/opus/silk/gain_quant.c +142 -0
- package/opus/silk/init_decoder.c +84 -0
- package/opus/silk/init_encoder.c +68 -0
- package/opus/silk/inner_prod_aligned.c +47 -0
- package/opus/silk/interpolate.c +51 -0
- package/opus/silk/lin2log.c +46 -0
- package/opus/silk/log2lin.c +58 -0
- package/opus/silk/macros.h +151 -0
- package/opus/silk/main.h +486 -0
- package/opus/silk/meson.build +69 -0
- package/opus/silk/mips/NSQ_del_dec_mipsr1.h +410 -0
- package/opus/silk/mips/macros_mipsr1.h +92 -0
- package/opus/silk/mips/sigproc_fix_mipsr1.h +60 -0
- package/opus/silk/pitch_est_defines.h +88 -0
- package/opus/silk/pitch_est_tables.c +99 -0
- package/opus/silk/process_NLSFs.c +107 -0
- package/opus/silk/quant_LTP_gains.c +132 -0
- package/opus/silk/resampler.c +215 -0
- package/opus/silk/resampler_down2.c +74 -0
- package/opus/silk/resampler_down2_3.c +103 -0
- package/opus/silk/resampler_private.h +88 -0
- package/opus/silk/resampler_private_AR2.c +55 -0
- package/opus/silk/resampler_private_IIR_FIR.c +107 -0
- package/opus/silk/resampler_private_down_FIR.c +194 -0
- package/opus/silk/resampler_private_up2_HQ.c +113 -0
- package/opus/silk/resampler_rom.c +96 -0
- package/opus/silk/resampler_rom.h +68 -0
- package/opus/silk/resampler_structs.h +60 -0
- package/opus/silk/shell_coder.c +151 -0
- package/opus/silk/sigm_Q15.c +76 -0
- package/opus/silk/sort.c +154 -0
- package/opus/silk/stereo_LR_to_MS.c +229 -0
- package/opus/silk/stereo_MS_to_LR.c +85 -0
- package/opus/silk/stereo_decode_pred.c +73 -0
- package/opus/silk/stereo_encode_pred.c +62 -0
- package/opus/silk/stereo_find_predictor.c +79 -0
- package/opus/silk/stereo_quant_pred.c +73 -0
- package/opus/silk/structs.h +357 -0
- package/opus/silk/sum_sqr_shift.c +83 -0
- package/opus/silk/table_LSF_cos.c +70 -0
- package/opus/silk/tables.h +114 -0
- package/opus/silk/tables_LTP.c +294 -0
- package/opus/silk/tables_NLSF_CB_NB_MB.c +195 -0
- package/opus/silk/tables_NLSF_CB_WB.c +234 -0
- package/opus/silk/tables_gain.c +63 -0
- package/opus/silk/tables_other.c +124 -0
- package/opus/silk/tables_pitch_lag.c +69 -0
- package/opus/silk/tables_pulses_per_block.c +264 -0
- package/opus/silk/tests/meson.build +8 -0
- package/opus/silk/tests/test_unit_LPC_inv_pred_gain.c +130 -0
- package/opus/silk/tuning_parameters.h +155 -0
- package/opus/silk/typedef.h +81 -0
- package/opus/silk/x86/NSQ_del_dec_avx2.c +1075 -0
- package/opus/silk/x86/NSQ_del_dec_sse4_1.c +915 -0
- package/opus/silk/x86/NSQ_sse4_1.c +772 -0
- package/opus/silk/x86/SigProc_FIX_sse.h +99 -0
- package/opus/silk/x86/VAD_sse4_1.c +289 -0
- package/opus/silk/x86/VQ_WMat_EC_sse4_1.c +173 -0
- package/opus/silk/x86/main_sse.h +299 -0
- package/opus/silk/x86/x86_silk_map.c +179 -0
- package/opus/silk_headers.mk +44 -0
- package/opus/silk_sources.mk +164 -0
- package/opus/src/analysis.c +979 -0
- package/opus/src/analysis.h +103 -0
- package/opus/src/extensions.c +663 -0
- package/opus/src/mapping_matrix.c +993 -0
- package/opus/src/mapping_matrix.h +165 -0
- package/opus/src/meson.build +45 -0
- package/opus/src/mlp.c +132 -0
- package/opus/src/mlp.h +60 -0
- package/opus/src/mlp_data.c +672 -0
- package/opus/src/opus.c +362 -0
- package/opus/src/opus_compare.c +382 -0
- package/opus/src/opus_decoder.c +1579 -0
- package/opus/src/opus_demo.c +1194 -0
- package/opus/src/opus_encoder.c +3180 -0
- package/opus/src/opus_multistream.c +92 -0
- package/opus/src/opus_multistream_decoder.c +563 -0
- package/opus/src/opus_multistream_encoder.c +1321 -0
- package/opus/src/opus_private.h +263 -0
- package/opus/src/opus_projection_decoder.c +283 -0
- package/opus/src/opus_projection_encoder.c +522 -0
- package/opus/src/repacketizer.c +469 -0
- package/opus/src/repacketizer_demo.c +247 -0
- package/opus/src/tansig_table.h +45 -0
- package/opus/tar_list.txt +28 -0
- package/opus/tests/meson.build +39 -0
- package/opus/tests/opus_build_test.sh +29 -0
- package/opus/tests/opus_decode_fuzzer.c +124 -0
- package/opus/tests/opus_decode_fuzzer.options +2 -0
- package/opus/tests/opus_encode_regressions.c +1034 -0
- package/opus/tests/random_config.sh +126 -0
- package/opus/tests/run_vectors.sh +143 -0
- package/opus/tests/test_opus_api.c +1904 -0
- package/opus/tests/test_opus_common.h +86 -0
- package/opus/tests/test_opus_custom.c +694 -0
- package/opus/tests/test_opus_decode.c +481 -0
- package/opus/tests/test_opus_dred.c +107 -0
- package/opus/tests/test_opus_encode.c +738 -0
- package/opus/tests/test_opus_extensions.c +750 -0
- package/opus/tests/test_opus_padding.c +94 -0
- package/opus/tests/test_opus_projection.c +384 -0
- package/opus/training/rnn_dump.py +66 -0
- package/opus/training/rnn_train.py +177 -0
- package/opus/training/txt2hdf5.py +12 -0
- package/opus/update_version +65 -0
- package/package.json +2 -2
- package/src/build-ffmpeg-msys.sh +8 -2
|
@@ -0,0 +1,1904 @@
|
|
|
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
|
+
}
|