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

Unified Diff: media/formats/mpeg/adts_stream_parser.cc

Issue 2378443002: Fix MSE ADTS parsing on Android. (Closed)
Patch Set: Address comments. Created 4 years, 3 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/mpeg/adts_stream_parser.h ('k') | media/formats/mpeg/mpeg1_audio_stream_parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/formats/mpeg/adts_stream_parser.cc
diff --git a/media/formats/mpeg/adts_stream_parser.cc b/media/formats/mpeg/adts_stream_parser.cc
index c6543047f94aa9f9edbe2757da357940bb03469c..6aa8782ab51102807a4992ee7ad1696665a0de05 100644
--- a/media/formats/mpeg/adts_stream_parser.cc
+++ b/media/formats/mpeg/adts_stream_parser.cc
@@ -6,7 +6,9 @@
#include <stddef.h>
+#include "build/build_config.h"
#include "media/base/media_log.h"
+#include "media/formats/mp4/aac.h"
#include "media/formats/mpeg/adts_constants.h"
namespace media {
@@ -24,12 +26,12 @@ int ADTSStreamParser::ParseFrameHeader(const uint8_t* data,
int* sample_rate,
ChannelLayout* channel_layout,
int* sample_count,
- bool* metadata_frame) const {
+ bool* metadata_frame,
+ std::vector<uint8_t>* extra_data) const {
DCHECK(data);
DCHECK_GE(size, 0);
- DCHECK(frame_size);
- if (size < 8)
+ if (size < kADTSHeaderMinSize)
return 0;
BitReader reader(data, size);
@@ -95,6 +97,23 @@ int ADTSStreamParser::ParseFrameHeader(const uint8_t* data,
if (metadata_frame)
*metadata_frame = false;
+ if (extra_data) {
+ // See mp4::AAC::Parse() for details. We don't need to worry about writing
+ // extensions since we can't have extended ADTS by this point (it's
+ // explicitly rejected as invalid above).
+ DCHECK_NE(sample_rate_index, 15u);
+
+ // The following code is written according to ISO 14496 Part 3 Table 1.13 -
+ // Syntax of AudioSpecificConfig.
+ const uint16_t esds = (((((profile + 1) << 4) + sample_rate_index) << 4) +
+ channel_layout_index)
+ << 3;
+ extra_data->push_back(esds >> 8);
+ extra_data->push_back(esds & 0xFF);
+ if (media_log())
+ DCHECK(mp4::AAC().Parse(*extra_data, media_log()));
+ }
+
return bytes_read;
}
« no previous file with comments | « media/formats/mpeg/adts_stream_parser.h ('k') | media/formats/mpeg/mpeg1_audio_stream_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698