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

Unified Diff: media/mojo/common/media_type_converters.cc

Issue 2572573007: Use passthrough decoder for (E)AC3 formats (Closed)
Patch Set: Sanity checks Created 3 years, 7 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
« no previous file with comments | « media/formats/ac3/ac3_util_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/common/media_type_converters.cc
diff --git a/media/mojo/common/media_type_converters.cc b/media/mojo/common/media_type_converters.cc
index 50dd25fd4d34b2f7730aa7907d2f07255f4d2242..0a415d96adb3977d179d8a2136bcbfad9fc7691a 100644
--- a/media/mojo/common/media_type_converters.cc
+++ b/media/mojo/common/media_type_converters.cc
@@ -311,6 +311,23 @@ TypeConverter<scoped_refptr<media::AudioBuffer>, media::mojom::AudioBufferPtr>::
if (input->end_of_stream)
return media::AudioBuffer::CreateEOSBuffer();
+ if (input->frame_count <= 0 ||
+ static_cast<size_t>(input->sample_format) > media::kSampleFormatMax ||
+ static_cast<size_t>(input->channel_layout) > media::CHANNEL_LAYOUT_MAX ||
+ ChannelLayoutToChannelCount(input->channel_layout) !=
+ input->channel_count) {
+ LOG(ERROR) << "Receive an invalid audio buffer, replace it with EOS.";
+ return media::AudioBuffer::CreateEOSBuffer();
+ }
+
+ if (IsBitstream(input->sample_format)) {
+ uint8_t* data = input->data.data();
+ return media::AudioBuffer::CopyBitstreamFrom(
+ input->sample_format, input->channel_layout, input->channel_count,
+ input->sample_rate, input->frame_count, &data, input->data.size(),
+ input->timestamp);
+ }
+
// Setup channel pointers. AudioBuffer::CopyFrom() will only use the first
// one in the case of interleaved data.
std::vector<const uint8_t*> channel_ptrs(input->channel_count, nullptr);
« no previous file with comments | « media/formats/ac3/ac3_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698