Chromium Code Reviews| Index: media/base/audio_discard_helper_unittest.cc |
| diff --git a/media/base/audio_discard_helper_unittest.cc b/media/base/audio_discard_helper_unittest.cc |
| index 1ea0cc6f81657f2d63fcd0f59396448e86c35c65..3156c9a83930c4808808e917811a524be422b9a7 100644 |
| --- a/media/base/audio_discard_helper_unittest.cc |
| +++ b/media/base/audio_discard_helper_unittest.cc |
| @@ -329,9 +329,14 @@ TEST(AudioDiscardHelperTest, InitialDiscardAndDiscardPaddingAndDecoderDelay) { |
| ASSERT_FALSE(discard_helper.ProcessBuffers(encoded_buffer, decoded_buffer)); |
| ASSERT_TRUE(discard_helper.initialized()); |
| - // Processing another buffer (with the same discard padding) should discard |
| - // the back half of the buffer since kDecoderDelay is half a buffer. |
| + // Processing another buffer should discard the back half of the buffer since |
| + // kDecoderDelay is half a buffer. The end padding should not be discarded |
| + // until another buffer is processed. kDuration / 4 is chosen for the end |
| + // discard since it will force the end discard to start after position zero |
| + // within the next decoded buffer. |
|
acolwell GONE FROM CHROMIUM
2014/07/24 19:22:14
I'm confused by this comment. Wasn't the decoder d
DaleCurtis
2014/07/24 19:58:59
Decoder delay is forever. Remember it's not inclu
DaleCurtis
2014/07/29 01:35:09
Per our offline conversation I've added diagrams e
|
| encoded_buffer->set_timestamp(kTimestamp + kDuration); |
| + encoded_buffer->set_discard_padding( |
| + std::make_pair(kDuration / 2, kDuration / 4)); |
| decoded_buffer = CreateDecodedBuffer(kTestFrames); |
| ASSERT_FLOAT_EQ(0.0f, ExtractDecodedData(decoded_buffer, 0)); |
| ASSERT_NEAR(kDecoderDelay * kDataStep, |
| @@ -344,6 +349,37 @@ TEST(AudioDiscardHelperTest, InitialDiscardAndDiscardPaddingAndDecoderDelay) { |
| // Verify it was actually the latter half of the buffer that was removed. |
| ASSERT_FLOAT_EQ(0.0f, ExtractDecodedData(decoded_buffer, 0)); |
| + |
| + // Verify the end discard padding is carried over to the next buffer. Use |
| + // kDuration / 2 so that the next buffer has its start entirely discarded. |
| + encoded_buffer->set_timestamp(kTimestamp + kDuration); |
|
acolwell GONE FROM CHROMIUM
2014/07/24 19:22:14
Shouldn't you be using + 2 * kDuration here so it
DaleCurtis
2014/07/29 01:35:09
Done.
|
| + encoded_buffer->set_discard_padding( |
| + std::make_pair(base::TimeDelta(), kDuration / 2)); |
| + decoded_buffer = CreateDecodedBuffer(kTestFrames); |
| + ASSERT_TRUE(discard_helper.ProcessBuffers(encoded_buffer, decoded_buffer)); |
| + EXPECT_EQ(kTimestamp + kDuration / 2, decoded_buffer->timestamp()); |
| + EXPECT_EQ(3 * kDuration / 4, decoded_buffer->duration()); |
| + EXPECT_EQ(3 * kTestFrames / 4, decoded_buffer->frame_count()); |
| + |
| + // Verify it was actually the second quarter of the buffer that was removed. |
| + const int kDiscardFrames = kTestFrames / 4; |
| + ASSERT_FLOAT_EQ(0.0f, ExtractDecodedData(decoded_buffer, 0)); |
| + ASSERT_FLOAT_EQ( |
| + kDiscardFrames * 2 * kDataStep, |
| + ExtractDecodedData(decoded_buffer, kDecoderDelay - kDiscardFrames)); |
| + |
| + // One last test to ensure carryover discard from the start works. |
| + encoded_buffer->set_timestamp(kTimestamp + kDuration * 2); |
|
acolwell GONE FROM CHROMIUM
2014/07/24 19:22:14
Shouldn't this be *3?
DaleCurtis
2014/07/29 01:35:09
Done.
|
| + encoded_buffer->set_discard_padding(DecoderBuffer::DiscardPadding()); |
| + decoded_buffer = CreateDecodedBuffer(kTestFrames); |
| + ASSERT_FLOAT_EQ(0.0f, ExtractDecodedData(decoded_buffer, 0)); |
| + ASSERT_TRUE(discard_helper.ProcessBuffers(encoded_buffer, decoded_buffer)); |
| + EXPECT_EQ(kTimestamp + kDuration / 2 + 3 * kDuration / 4, |
| + decoded_buffer->timestamp()); |
| + EXPECT_EQ(kDuration / 2, decoded_buffer->duration()); |
| + EXPECT_EQ(kTestFrames / 2, decoded_buffer->frame_count()); |
| + ASSERT_FLOAT_EQ(kTestFrames / 2 * kDataStep, |
| + ExtractDecodedData(decoded_buffer, 0)); |
| } |
| TEST(AudioDiscardHelperTest, DelayedDiscardInitialDiscardAndDiscardPadding) { |