aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Soulier <asoulier@google.com>2023-12-27 16:36:57 -0800
committerAntoine Soulier <asoulier@google.com>2023-12-28 10:16:57 -0800
commit6c99421bac3272bc347c2bb528548ca99fc4fea8 (patch)
tree9a2bd14d08e48917d9f59eff537b94afc5378701
parent0aac2a41e135930e200865dd37127c4d104542b0 (diff)
downloadliblc3-6c99421bac3272bc347c2bb528548ca99fc4fea8.tar.gz
fuzz: Update with LC3-Plus LC3-Plus HR parameters
-rw-r--r--fuzz/dfuzz.cc9
-rw-r--r--fuzz/efuzz.cc5
2 files changed, 9 insertions, 5 deletions
diff --git a/fuzz/dfuzz.cc b/fuzz/dfuzz.cc
index c926d61..29e6b57 100644
--- a/fuzz/dfuzz.cc
+++ b/fuzz/dfuzz.cc
@@ -23,20 +23,21 @@ using namespace lc3;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
- const int dt_list[] = { 7500, 10000 };
- const int sr_list[] = { 8000, 16000, 24000, 32000, 48000 };
+ const int dt_list[] = { 2500, 5000, 7500, 10000 };
+ const int sr_list[] = { 8000, 16000, 24000, 32000, 48000, 96000 };
FuzzedDataProvider fdp(data, size);
int dt_us = fdp.PickValueInArray(dt_list);
int sr_hz = fdp.PickValueInArray(sr_list);
int nchannels =fdp.PickValueInArray({1, 2});
+ bool hrmode = fdp.ConsumeBool();
int sr_pcm_hz = fdp.PickValueInArray(sr_list);
if (sr_pcm_hz < sr_hz)
sr_pcm_hz = 0;
- Decoder dec(dt_us, sr_hz, sr_pcm_hz, nchannels);
+ Decoder dec(dt_us, sr_hz, sr_pcm_hz, nchannels, hrmode);
int frame_size = fdp.ConsumeIntegralInRange(
LC3_MIN_FRAME_BYTES, LC3_MAX_FRAME_BYTES);
@@ -46,6 +47,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
PcmFormat::kS24In3Le, PcmFormat::kF32 });
int frame_samples = dec.GetFrameSamples();
+ if (frame_samples < 0)
+ return -1;
int sample_bytes =
fmt == PcmFormat::kS16 ? sizeof(int16_t) :
diff --git a/fuzz/efuzz.cc b/fuzz/efuzz.cc
index e79ef9c..be68b9c 100644
--- a/fuzz/efuzz.cc
+++ b/fuzz/efuzz.cc
@@ -70,7 +70,7 @@ int encode(Encoder &e, int frame_size, int nchannels,
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
- const int dt_list[] = { 7500, 10000 };
+ const int dt_list[] = { 2500, 5000, 7500, 10000 };
const int sr_list[] = { 8000, 16000, 24000, 32000, 48000 };
FuzzedDataProvider fdp(data, size);
@@ -78,12 +78,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
int dt_us = fdp.PickValueInArray(dt_list);
int sr_hz = fdp.PickValueInArray(sr_list);
int nchannels = fdp.PickValueInArray({1, 2});
+ bool hrmode = fdp.ConsumeBool();
int sr_pcm_hz = fdp.PickValueInArray(sr_list);
if (sr_pcm_hz < sr_hz)
sr_pcm_hz = 0;
- Encoder enc(dt_us, sr_hz, sr_pcm_hz, nchannels);
+ Encoder enc(dt_us, sr_hz, sr_pcm_hz, nchannels, hrmode);
PcmFormat fmt = fdp.PickValueInArray(
{ PcmFormat::kS16, PcmFormat::kS24,