Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(742)

Unified Diff: media/filters/audio_decoder_unittest.cc

Issue 1260193005: Fix incorrect opus seek preroll and flaky pre-skip removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test cases. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/audio_decoder_unittest.cc
diff --git a/media/filters/audio_decoder_unittest.cc b/media/filters/audio_decoder_unittest.cc
index d428107519542b38db5e31283d6bd255b9012e51..3be1ee8b7e23bd66022679607cde143408fee6a3 100644
--- a/media/filters/audio_decoder_unittest.cc
+++ b/media/filters/audio_decoder_unittest.cc
@@ -64,6 +64,8 @@ std::ostream& operator<<(std::ostream& os, const DecoderTestData& data) {
// discard metadata in favor of setting DiscardPadding on the DecoderBuffer.
// Allows better testing of AudioDiscardHelper usage.
static void SetDiscardPadding(AVPacket* packet,
+ bool first_packet,
+ const AVStream* stream,
const scoped_refptr<DecoderBuffer> buffer,
double samples_per_second) {
// Discard negative timestamps.
@@ -79,15 +81,20 @@ static void SetDiscardPadding(AVPacket* packet,
}
// If the timestamp is positive, try to use FFmpeg's discard data.
+ int skip_samples = 0;
int skip_samples_size = 0;
const uint32* skip_samples_ptr =
reinterpret_cast<const uint32*>(av_packet_get_side_data(
packet, AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
- if (skip_samples_size < 4)
+ if (skip_samples_size >= 4)
+ skip_samples = base::ByteSwapToLE32(*skip_samples_ptr);
+ else if (first_packet && stream->codec->delay)
+ skip_samples = stream->codec->delay;
+ else
return;
+
buffer->set_discard_padding(std::make_pair(
- base::TimeDelta::FromSecondsD(base::ByteSwapToLE32(*skip_samples_ptr) /
- samples_per_second),
+ base::TimeDelta::FromSecondsD(skip_samples / samples_per_second),
base::TimeDelta()));
}
@@ -188,10 +195,9 @@ class AudioDecoderTest : public testing::TestWithParam<DecoderTestData> {
if (packet.flags & AV_PKT_FLAG_KEY)
buffer->set_is_key_frame(true);
- // Don't set discard padding for Opus, it already has discard behavior set
- // based on the codec delay in the AudioDecoderConfig.
- if (GetParam().decoder_type == FFMPEG)
- SetDiscardPadding(&packet, buffer, GetParam().samples_per_second);
+ SetDiscardPadding(&packet, buffer->timestamp() == start_timestamp_,
+ reader_->GetAVStreamForTesting(), buffer,
+ GetParam().samples_per_second);
// DecodeBuffer() shouldn't need the original packet since it uses the copy.
av_free_packet(&packet);

Powered by Google App Engine
This is Rietveld 408576698