OLD | NEW |
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/filters/ffmpeg_aac_bitstream_converter.h" | 5 #include "media/filters/ffmpeg_aac_bitstream_converter.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/ffmpeg/ffmpeg_common.h" | 8 #include "media/ffmpeg/ffmpeg_common.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 // Creates an ADTS header and stores in |hdr| | 14 // Creates an ADTS header and stores in |hdr| |
15 // Assumes |hdr| points to an array of length |kAdtsHeaderSize| | 15 // Assumes |hdr| points to an array of length |kAdtsHeaderSize| |
16 // Returns false if parameter values are for an unsupported configuration. | 16 // Returns false if parameter values are for an unsupported configuration. |
17 bool GenerateAdtsHeader( | 17 bool GenerateAdtsHeader(int codec, |
18 int codec, int layer, int audio_profile, int sample_rate_index, | 18 int layer, |
19 int private_stream, int channel_configuration, int originality, int home, | 19 int audio_profile, |
20 int copyrighted_stream, int copyright_start, int frame_length, | 20 int sample_rate_index, |
21 int buffer_fullness, int number_of_frames_minus_one, uint8* hdr) { | 21 int private_stream, |
| 22 int channel_configuration, |
| 23 int originality, |
| 24 int home, |
| 25 int copyrighted_stream, |
| 26 int copyright_start, |
| 27 int frame_length, |
| 28 int buffer_fullness, |
| 29 int number_of_frames_minus_one, |
| 30 uint8_t* hdr) { |
22 DCHECK_EQ(codec, AV_CODEC_ID_AAC); | 31 DCHECK_EQ(codec, AV_CODEC_ID_AAC); |
23 | 32 |
24 memset(reinterpret_cast<void *>(hdr), 0, | 33 memset(reinterpret_cast<void *>(hdr), 0, |
25 FFmpegAACBitstreamConverter::kAdtsHeaderSize); | 34 FFmpegAACBitstreamConverter::kAdtsHeaderSize); |
26 // Ref: http://wiki.multimedia.cx/index.php?title=ADTS | 35 // Ref: http://wiki.multimedia.cx/index.php?title=ADTS |
27 // ADTS header structure is the following | 36 // ADTS header structure is the following |
28 // AAAAAAAA AAAABCCD EEFFFFGH HHIJKLMM MMMMMMMM MMMOOOOO OOOOOOPP | 37 // AAAAAAAA AAAABCCD EEFFFFGH HHIJKLMM MMMMMMMM MMMOOOOO OOOOOOPP |
29 // | 38 // |
30 // A Syncword 0xFFF, all bits must be 1 | 39 // A Syncword 0xFFF, all bits must be 1 |
31 // B MPEG Version: 0 for MPEG-4, 1 for MPEG-2 | 40 // B MPEG Version: 0 for MPEG-4, 1 for MPEG-2 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 av_packet_copy_props(&dest_packet, packet); | 239 av_packet_copy_props(&dest_packet, packet); |
231 | 240 |
232 // Release the old packet. | 241 // Release the old packet. |
233 av_packet_unref(packet); | 242 av_packet_unref(packet); |
234 *packet = dest_packet; // Finally, replace the values in the input packet. | 243 *packet = dest_packet; // Finally, replace the values in the input packet. |
235 | 244 |
236 return true; | 245 return true; |
237 } | 246 } |
238 | 247 |
239 } // namespace media | 248 } // namespace media |
OLD | NEW |