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

Side by Side Diff: media/formats/mp4/mp4_stream_parser.cc

Issue 812643005: Re-add AC3/EAC3 audio demuxing support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code cleanup Created 5 years, 11 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
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 "media/formats/mp4/mp4_stream_parser.h" 5 #include "media/formats/mp4/mp4_stream_parser.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 RCHECK(!samp_descr.audio_entries.empty()); 208 RCHECK(!samp_descr.audio_entries.empty());
209 209
210 // It is not uncommon to find otherwise-valid files with incorrect sample 210 // It is not uncommon to find otherwise-valid files with incorrect sample
211 // description indices, so we fail gracefully in that case. 211 // description indices, so we fail gracefully in that case.
212 if (desc_idx >= samp_descr.audio_entries.size()) 212 if (desc_idx >= samp_descr.audio_entries.size())
213 desc_idx = 0; 213 desc_idx = 0;
214 const AudioSampleEntry& entry = samp_descr.audio_entries[desc_idx]; 214 const AudioSampleEntry& entry = samp_descr.audio_entries[desc_idx];
215 const AAC& aac = entry.esds.aac; 215 const AAC& aac = entry.esds.aac;
216 216
217 if (!(entry.format == FOURCC_MP4A || 217 if (!(entry.format == FOURCC_MP4A ||
218 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
219 entry.format == FOURCC_A52 ||
220 entry.format == FOURCC_A52b ||
221 entry.format == FOURCC_AC3 ||
222 entry.format == FOURCC_AC_3 ||
223 entry.format == FOURCC_EAC3 ||
224 #endif
218 (entry.format == FOURCC_ENCA && 225 (entry.format == FOURCC_ENCA &&
219 entry.sinf.format.format == FOURCC_MP4A))) { 226 entry.sinf.format.format == FOURCC_MP4A))) {
220 MEDIA_LOG(log_cb_) << "Unsupported audio format 0x" 227 MEDIA_LOG(log_cb_) << "Unsupported audio format 0x"
221 << std::hex << entry.format << " in stsd box."; 228 << std::hex << entry.format << " in stsd box.";
222 return false; 229 return false;
223 } 230 }
224 231
225 uint8 audio_type = entry.esds.object_type; 232 uint8 audio_type = entry.esds.object_type;
233 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
234 if (audio_type == kForbidden &&
235 (entry.format == FOURCC_EAC3 || entry.format == FOURCC_A52b)) {
236 audio_type = kEAC3;
237 }
238 if (audio_type == kForbidden &&
239 (entry.format == FOURCC_A52 || entry.format == FOURCC_AC3 ||
240 entry.format == FOURCC_AC_3)) {
241 audio_type = kAC3;
242 }
243 #endif
226 DVLOG(1) << "audio_type " << std::hex << static_cast<int>(audio_type); 244 DVLOG(1) << "audio_type " << std::hex << static_cast<int>(audio_type);
227 if (audio_object_types_.find(audio_type) == audio_object_types_.end()) { 245 if (audio_object_types_.find(audio_type) == audio_object_types_.end()) {
228 MEDIA_LOG(log_cb_) << "audio object type 0x" << std::hex << audio_type 246 MEDIA_LOG(log_cb_) << "audio object type 0x" << std::hex << audio_type
229 << " does not match what is specified in the" 247 << " does not match what is specified in the"
230 << " mimetype."; 248 << " mimetype.";
231 return false; 249 return false;
232 } 250 }
233 251
234 AudioCodec codec = kUnknownAudioCodec; 252 AudioCodec codec = kUnknownAudioCodec;
235 ChannelLayout channel_layout = CHANNEL_LAYOUT_NONE; 253 ChannelLayout channel_layout = CHANNEL_LAYOUT_NONE;
236 int sample_per_second = 0; 254 int sample_per_second = 0;
237 std::vector<uint8> extra_data; 255 std::vector<uint8> extra_data;
238 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3 or 256 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3 or
239 // supported MPEG2 AAC varients. 257 // supported MPEG2 AAC varients.
240 if (ESDescriptor::IsAAC(audio_type)) { 258 if (ESDescriptor::IsAAC(audio_type)) {
241 codec = kCodecAAC; 259 codec = kCodecAAC;
242 channel_layout = aac.GetChannelLayout(has_sbr_); 260 channel_layout = aac.GetChannelLayout(has_sbr_);
243 sample_per_second = aac.GetOutputSamplesPerSecond(has_sbr_); 261 sample_per_second = aac.GetOutputSamplesPerSecond(has_sbr_);
244 #if defined(OS_ANDROID) 262 #if defined(OS_ANDROID)
245 extra_data = aac.codec_specific_data(); 263 extra_data = aac.codec_specific_data();
246 #endif 264 #endif
265 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
266 } else if (audio_type == kAC3) {
267 codec = kCodecAC3;
268 channel_layout = GuessChannelLayout(entry.channelcount);
269 sample_per_second = entry.samplerate;
270 } else if (audio_type == kEAC3) {
271 codec = kCodecEAC3;
272 channel_layout = GuessChannelLayout(entry.channelcount);
273 sample_per_second = entry.samplerate;
274 #endif
247 } else { 275 } else {
248 MEDIA_LOG(log_cb_) << "Unsupported audio object type 0x" << std::hex 276 MEDIA_LOG(log_cb_) << "Unsupported audio object type 0x" << std::hex
249 << audio_type << " in esds."; 277 << audio_type << " in esds.";
250 return false; 278 return false;
251 } 279 }
252 280
253 SampleFormat sample_format; 281 SampleFormat sample_format;
254 if (entry.samplesize == 8) { 282 if (entry.samplesize == 8) {
255 sample_format = kSampleFormatU8; 283 sample_format = kSampleFormatU8;
256 } else if (entry.samplesize == 16) { 284 } else if (entry.samplesize == 16) {
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 runs.AdvanceSample(); 654 runs.AdvanceSample();
627 } 655 }
628 runs.AdvanceRun(); 656 runs.AdvanceRun();
629 } 657 }
630 658
631 return true; 659 return true;
632 } 660 }
633 661
634 } // namespace mp4 662 } // namespace mp4
635 } // namespace media 663 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698