Adding fuzzer for G711/PCM u/A decoders and fixing a fuzzer problem

Bug: chromium:1279775
Change-Id: I8cc3f5fe25b9e707e9d171251026bd5a8bad5da5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251844
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36036}
This commit is contained in:
Henrik Lundin
2022-02-16 16:03:47 +00:00
committed by WebRTC LUCI CQ
parent 153c9e5107
commit c4ed5f0b1a
3 changed files with 67 additions and 2 deletions

View File

@ -40,8 +40,14 @@ int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded,
int16_t* decoded,
SpeechType* speech_type) {
RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz);
// Adjust the encoded length down to ensure the same number of samples in each
// channel.
const size_t encoded_len_adjusted =
PacketDuration(encoded, encoded_len) *
Channels(); // 1 byte per sample per channel
int16_t temp_type = 1; // Default is speech.
size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type);
size_t ret =
WebRtcG711_DecodeU(encoded, encoded_len_adjusted, decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type);
return static_cast<int>(ret);
}
@ -75,8 +81,14 @@ int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded,
int16_t* decoded,
SpeechType* speech_type) {
RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz);
// Adjust the encoded length down to ensure the same number of samples in each
// channel.
const size_t encoded_len_adjusted =
PacketDuration(encoded, encoded_len) *
Channels(); // 1 byte per sample per channel
int16_t temp_type = 1; // Default is speech.
size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type);
size_t ret =
WebRtcG711_DecodeA(encoded, encoded_len_adjusted, decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type);
return static_cast<int>(ret);
}