Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be18a381 authored by Brian Delwiche's avatar Brian Delwiche Committed by Android (Google) Code Review
Browse files

Merge "[conflict] Merge "Add bounds checks in btif_avrcp_audio_track.cc" into...

Merge "[conflict] Merge "Add bounds checks in btif_avrcp_audio_track.cc" into tm-dev am: 0b68bd68 am: 52d169b1" into udc-dev-plus-aosp
parents ffeb0156 e9b41ff0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ static size_t transcodeQ15ToFloat(uint8_t* buffer, size_t length,
  size_t sampleSize = sampleSizeFor(trackHolder);
  size_t i = 0;
  const float scaledGain = trackHolder->gain * kScaleQ15ToFloat;
  for (; i <= length / sampleSize; i++) {
  for (; i < std::min(trackHolder->bufferLength, length / sampleSize); i++) {
    trackHolder->buffer[i] = ((int16_t*)buffer)[i] * scaledGain;
  }
  return i * sampleSize;
@@ -232,7 +232,7 @@ static size_t transcodeQ23ToFloat(uint8_t* buffer, size_t length,
  size_t sampleSize = sampleSizeFor(trackHolder);
  size_t i = 0;
  const float scaledGain = trackHolder->gain * kScaleQ23ToFloat;
  for (; i <= length / sampleSize; i++) {
  for (; i < std::min(trackHolder->bufferLength, length / sampleSize); i++) {
    size_t offset = i * sampleSize;
    int32_t sample = *((int32_t*)(buffer + offset - 1)) & 0x00FFFFFF;
    trackHolder->buffer[i] = sample * scaledGain;
@@ -245,7 +245,7 @@ static size_t transcodeQ31ToFloat(uint8_t* buffer, size_t length,
  size_t sampleSize = sampleSizeFor(trackHolder);
  size_t i = 0;
  const float scaledGain = trackHolder->gain * kScaleQ31ToFloat;
  for (; i <= length / sampleSize; i++) {
  for (; i < std::min(trackHolder->bufferLength, length / sampleSize); i++) {
    trackHolder->buffer[i] = ((int32_t*)buffer)[i] * scaledGain;
  }
  return i * sampleSize;
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ TEST_F(BtifAvrcpAudioTrackTest,
  for (size_t index = 0; index < bufferLength; ++index) {
    data[index] = index;
  }
  BtifAvrcpAudioTrackWriteData(trackHolder, data, bufferLength - 1);
  BtifAvrcpAudioTrackWriteData(trackHolder, data, bufferLength);
  const int16_t* dataInt = (int16_t*)data;
  for (size_t index = 0; index < bufferLength / sampleSize; ++index) {
    const float expected = dataInt[index] * scaleQ15ToFloat * gainValue;