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

Side by Side Diff: media/filters/audio_decoder_unittest.cc

Issue 1904213003: Convert //media/filters from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove include Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « media/filters/audio_decoder_selector_unittest.cc ('k') | media/filters/audio_file_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 EXPECT_FALSE(pending_decode_); 289 EXPECT_FALSE(pending_decode_);
290 pending_reset_ = false; 290 pending_reset_ = false;
291 } 291 }
292 292
293 // Generates an MD5 hash of the audio signal. Should not be used for checks 293 // Generates an MD5 hash of the audio signal. Should not be used for checks
294 // across platforms as audio varies slightly across platforms. 294 // across platforms as audio varies slightly across platforms.
295 std::string GetDecodedAudioMD5(size_t i) { 295 std::string GetDecodedAudioMD5(size_t i) {
296 CHECK_LT(i, decoded_audio_.size()); 296 CHECK_LT(i, decoded_audio_.size());
297 const scoped_refptr<AudioBuffer>& buffer = decoded_audio_[i]; 297 const scoped_refptr<AudioBuffer>& buffer = decoded_audio_[i];
298 298
299 scoped_ptr<AudioBus> output = 299 std::unique_ptr<AudioBus> output =
300 AudioBus::Create(buffer->channel_count(), buffer->frame_count()); 300 AudioBus::Create(buffer->channel_count(), buffer->frame_count());
301 buffer->ReadFrames(buffer->frame_count(), 0, 0, output.get()); 301 buffer->ReadFrames(buffer->frame_count(), 0, 0, output.get());
302 302
303 base::MD5Context context; 303 base::MD5Context context;
304 base::MD5Init(&context); 304 base::MD5Init(&context);
305 for (int ch = 0; ch < output->channels(); ++ch) { 305 for (int ch = 0; ch < output->channels(); ++ch) {
306 base::MD5Update( 306 base::MD5Update(
307 &context, 307 &context,
308 base::StringPiece(reinterpret_cast<char*>(output->channel(ch)), 308 base::StringPiece(reinterpret_cast<char*>(output->channel(ch)),
309 output->frames() * sizeof(*output->channel(ch)))); 309 output->frames() * sizeof(*output->channel(ch))));
(...skipping 21 matching lines...) Expand all
331 331
332 const DecodedBufferExpectations& sample_info = GetParam().expectations[i]; 332 const DecodedBufferExpectations& sample_info = GetParam().expectations[i];
333 333
334 // Android MediaCodec returns wrong timestamps (shifted one frame forward) 334 // Android MediaCodec returns wrong timestamps (shifted one frame forward)
335 // for AAC before Android L. Ignore sample_info.timestamp in this situation. 335 // for AAC before Android L. Ignore sample_info.timestamp in this situation.
336 if (!SkipBufferTimestampCheck()) 336 if (!SkipBufferTimestampCheck())
337 EXPECT_EQ(sample_info.timestamp, buffer->timestamp().InMicroseconds()); 337 EXPECT_EQ(sample_info.timestamp, buffer->timestamp().InMicroseconds());
338 EXPECT_EQ(sample_info.duration, buffer->duration().InMicroseconds()); 338 EXPECT_EQ(sample_info.duration, buffer->duration().InMicroseconds());
339 EXPECT_FALSE(buffer->end_of_stream()); 339 EXPECT_FALSE(buffer->end_of_stream());
340 340
341 scoped_ptr<AudioBus> output = 341 std::unique_ptr<AudioBus> output =
342 AudioBus::Create(buffer->channel_count(), buffer->frame_count()); 342 AudioBus::Create(buffer->channel_count(), buffer->frame_count());
343 buffer->ReadFrames(buffer->frame_count(), 0, 0, output.get()); 343 buffer->ReadFrames(buffer->frame_count(), 0, 0, output.get());
344 344
345 // Generate a lossy hash of the audio used for comparison across platforms. 345 // Generate a lossy hash of the audio used for comparison across platforms.
346 AudioHash audio_hash; 346 AudioHash audio_hash;
347 audio_hash.Update(output.get(), output->frames()); 347 audio_hash.Update(output.get(), output->frames());
348 EXPECT_TRUE(audio_hash.IsEquivalent(sample_info.hash, 0.02)) 348 EXPECT_TRUE(audio_hash.IsEquivalent(sample_info.hash, 0.02))
349 << "Audio hashes differ. Expected: " << sample_info.hash 349 << "Audio hashes differ. Expected: " << sample_info.hash
350 << " Actual: " << audio_hash.ToString(); 350 << " Actual: " << audio_hash.ToString();
351 351
(...skipping 10 matching lines...) Expand all
362 size_t decoded_audio_size() const { return decoded_audio_.size(); } 362 size_t decoded_audio_size() const { return decoded_audio_.size(); }
363 base::TimeDelta start_timestamp() const { return start_timestamp_; } 363 base::TimeDelta start_timestamp() const { return start_timestamp_; }
364 const scoped_refptr<AudioBuffer>& decoded_audio(size_t i) { 364 const scoped_refptr<AudioBuffer>& decoded_audio(size_t i) {
365 return decoded_audio_[i]; 365 return decoded_audio_[i];
366 } 366 }
367 DecodeStatus last_decode_status() const { return last_decode_status_; } 367 DecodeStatus last_decode_status() const { return last_decode_status_; }
368 368
369 private: 369 private:
370 base::MessageLoop message_loop_; 370 base::MessageLoop message_loop_;
371 scoped_refptr<DecoderBuffer> data_; 371 scoped_refptr<DecoderBuffer> data_;
372 scoped_ptr<InMemoryUrlProtocol> protocol_; 372 std::unique_ptr<InMemoryUrlProtocol> protocol_;
373 scoped_ptr<AudioFileReader> reader_; 373 std::unique_ptr<AudioFileReader> reader_;
374 374
375 scoped_ptr<AudioDecoder> decoder_; 375 std::unique_ptr<AudioDecoder> decoder_;
376 bool pending_decode_; 376 bool pending_decode_;
377 bool pending_reset_; 377 bool pending_reset_;
378 DecodeStatus last_decode_status_; 378 DecodeStatus last_decode_status_;
379 379
380 std::deque<scoped_refptr<AudioBuffer> > decoded_audio_; 380 std::deque<scoped_refptr<AudioBuffer> > decoded_audio_;
381 base::TimeDelta start_timestamp_; 381 base::TimeDelta start_timestamp_;
382 382
383 DISALLOW_COPY_AND_ASSIGN(AudioDecoderTest); 383 DISALLOW_COPY_AND_ASSIGN(AudioDecoderTest);
384 }; 384 };
385 385
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 }; 618 };
619 619
620 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest, 620 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest,
621 AudioDecoderTest, 621 AudioDecoderTest,
622 testing::ValuesIn(kFFmpegTests)); 622 testing::ValuesIn(kFFmpegTests));
623 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest, 623 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest,
624 FFmpegAudioDecoderBehavioralTest, 624 FFmpegAudioDecoderBehavioralTest,
625 testing::ValuesIn(kFFmpegBehavioralTest)); 625 testing::ValuesIn(kFFmpegBehavioralTest));
626 626
627 } // namespace media 627 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/audio_decoder_selector_unittest.cc ('k') | media/filters/audio_file_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698