src/media/audio/audio_core/mixer/test/mixer_bitwise_tests.cc
// Validate that we correctly mix stereo->mono, including rounding.
Validate that we correctly mix stereo->mono, including rounding.
Validate that we correctly mix stereo - > mono including rounding .
TEST(PassThru, StereoToMono_Round) {
  int16_t source[] = {-0x13,   0x2EF5,  0x7B,   -0x159, -0x3E8,  0x3ED,
                      -0x103B, -0x1B58, 0x7FFF, 0x7FFF, -0x8000, -0x8000};
  float accum[] = {-0x1234, 0x4321, -0x13579, 0xC0FF, -0xAAAA, 0x555};
  float expect[] = {0x01771000, -0x0006F000, 0x00002800, -0x015C9800, 0x07FFF000, -0x08000000};
  NormalizeInt28ToPipelineBitwidth(expect, std::size(expect));
  auto mixer = SelectMixer(fuchsia::media::AudioSampleFormat::SIGNED_16, 2, 48000, 1, 48000,
                           Resampler::SampleAndHold);
  DoMix(mixer.get(), source, accum, false, std::size(accum));
  EXPECT_THAT(accum, Pointwise(FloatEq(), expect));
  std::memset(accum, 0, std::size(accum) * sizeof(float));
  mixer = SelectMixer(fuchsia::media::AudioSampleFormat::SIGNED_16, 2, 48000, 1, 48000,
                      Resampler::LinearInterpolation);
  DoMix(mixer.get(), source, accum, false, std::size(accum));
  EXPECT_THAT(accum, Pointwise(FloatEq(), expect));
}
TEST ( PassThru , StereoToMono_Round ) { int16_t source [ ] = { -0x13 , 0x2EF5 , 0x7B , -0x159 , -0x3E8 , 0x3ED , -0x103B , -0x1B58 , 0x7FFF , 0x7FFF , -0x8000 , -0x8000 } ; float accum [ ] = { -0x1234 , 0x4321 , -0x13579 , 0xC0FF , -0xAAAA , 0x555 } ; float expect [ ] = { 0x01771000 , -0x0006F000 , 0x00002800 , -0x015C9800 , 0x07FFF000 , -0x08000000 } ; NormalizeInt28ToPipelineBitwidth ( expect , std :: size ( expect ) ) ; auto mixer = SelectMixer ( fuchsia :: media :: AudioSampleFormat :: SIGNED_16 , 2 , 48000 , 1 , 48000 , Resampler :: SampleAndHold ) ; DoMix ( mixer . get ( ) , source , accum , false , std :: size ( accum ) ) ; EXPECT_THAT ( accum , Pointwise ( FloatEq ( ) , expect ) ) ; std :: memset ( accum , 0 , std :: size ( accum ) * sizeof ( float ) ) ; mixer = SelectMixer ( fuchsia :: media :: AudioSampleFormat :: SIGNED_16 , 2 , 48000 , 1 , 48000 , Resampler :: LinearInterpolation ) ; DoMix ( mixer . get ( ) , source , accum , false , std :: size ( accum ) ) ; EXPECT_THAT ( accum , Pointwise ( FloatEq ( ) , expect ) ) ; }
Validate that we correctly mix stereo->mono, including rounding.
Validate that we correctly mix stereo - > mono including rounding .
// pairs: positive even, neg even, pos odd, neg odd, pos limit, neg limit // Will be overwritten // Now try with the other resampler