| 1 | #![no_main] |
| 2 | |
| 3 | use ec_core::frame::ChannelLayout; |
| 4 | use ec_core::registry::{AudioParameters, CodecId, CodecParameters, MediaParameters}; |
| 5 | use libfuzzer_sys::fuzz_target; |
| 6 | |
| 7 | fuzz_target!(|data: &[u8]| { |
| 8 | let Some((&sel, rest)) = data.split_first() else { |
| 9 | return; |
| 10 | }; |
| 11 | let codec = [ |
| 12 | CodecId::ImaAdpcmWav, |
| 13 | CodecId::MsAdpcm, |
| 14 | CodecId::ImaAdpcmQt, |
| 15 | CodecId::PcmAlaw, |
| 16 | CodecId::PcmMulaw, |
| 17 | ][usize::from(sel) % 5]; |
| 18 | let channels = 1 + usize::from(sel >> 3) % 2; |
| 19 | let mut p = CodecParameters::new(codec); |
| 20 | p.media = MediaParameters::Audio(AudioParameters { |
| 21 | sample_rate: 8000, |
| 22 | layout: ChannelLayout::from_count(channels), |
| 23 | ..AudioParameters::default() |
| 24 | }); |
| 25 | if let Ok(mut d) = ec_pcm_ext::PcmExtDecoder::from_parameters(p) { |
| 26 | let _ = d.decode(rest); |
| 27 | } |
| 28 | }); |