Adding fuzzer for PCM16b decoder and fixing a fuzzer problem

Bug: chromium:1280852
Change-Id: I7f6c5de86ceee01156743c0389c59f875e53bb5f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251580
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36005}
This commit is contained in:
Henrik Lundin
2022-02-15 15:13:34 +00:00
committed by WebRTC LUCI CQ
parent e47493b3c0
commit ac341df436
3 changed files with 70 additions and 1 deletions

View File

@ -42,7 +42,12 @@ int AudioDecoderPcm16B::DecodeInternal(const uint8_t* encoded,
int16_t* decoded,
SpeechType* speech_type) {
RTC_DCHECK_EQ(sample_rate_hz_, sample_rate_hz);
size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded);
// 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) * 2 *
Channels(); // 2 bytes per sample per channel
size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len_adjusted, decoded);
*speech_type = ConvertSpeechType(1);
return static_cast<int>(ret);
}