mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
Support for generic AAC that is neither "normal" nor "SBR" (e.g. parametric stereo or other extensions that are not translatable into the various A_AAC/MPEG* CodecIDs).
This commit is contained in:
parent
1615eb84a4
commit
0128479143
@ -222,7 +222,7 @@ parse_aac_data(unsigned char *data,
|
||||
if (size == 5) {
|
||||
output_sample_rate = aac_sampling_freq[(data[4] & 0x7f) >> 3];
|
||||
sbr = true;
|
||||
} else if (sample_rate < 44100) {
|
||||
} else if (sample_rate <= 24000) {
|
||||
output_sample_rate = 2 * sample_rate;
|
||||
sbr = true;
|
||||
} else
|
||||
|
@ -27,6 +27,7 @@
|
||||
#define MKV_A_AAC_4SSR "A_AAC/MPEG4/SSR"
|
||||
#define MKV_A_AAC_4LTP "A_AAC/MPEG4/LTP"
|
||||
#define MKV_A_AAC_4SBR "A_AAC/MPEG4/LC/SBR"
|
||||
#define MKV_A_AAC "A_AAC"
|
||||
#define MKV_A_AC3 "A_AC3"
|
||||
#define MKV_A_DTS "A_DTS"
|
||||
#define MKV_A_MP3 "A_MPEG/L3"
|
||||
|
@ -443,8 +443,7 @@ kax_reader_c::verify_tracks() {
|
||||
c = (unsigned char *)t->private_data;
|
||||
if (c[0] != 2) {
|
||||
if (verbose)
|
||||
mxwarn(PFX "Vorbis track does not "
|
||||
"contain valid headers.\n");
|
||||
mxwarn(PFX "Vorbis track does not contain valid headers.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -458,8 +457,7 @@ kax_reader_c::verify_tracks() {
|
||||
}
|
||||
if (offset >= (t->private_size - 1)) {
|
||||
if (verbose)
|
||||
mxwarn(PFX "Vorbis track does not "
|
||||
"contain valid headers.\n");
|
||||
mxwarn(PFX "Vorbis track does not contain valid headers.\n");
|
||||
continue;
|
||||
}
|
||||
length += c[offset];
|
||||
@ -497,8 +495,15 @@ kax_reader_c::verify_tracks() {
|
||||
(t->codec_id == MKV_A_AAC_2SBR) ||
|
||||
(t->codec_id == MKV_A_AAC_4SBR))
|
||||
t->a_formattag = FOURCC('M', 'P', '4', 'A');
|
||||
else if (starts_with(t->codec_id, MKV_A_REAL_COOK,
|
||||
strlen("A_REAL/")))
|
||||
else if (t->codec_id == MKV_A_AAC) {
|
||||
if ((t->private_data == NULL) || (t->private_size < 2)) {
|
||||
mxwarn(PFX "The AAC track number %u is missing its private "
|
||||
"data. Ignoring this track.\n", t->tnum);
|
||||
continue;
|
||||
}
|
||||
t->a_formattag = FOURCC('M', 'P', '4', 'A');
|
||||
} else if (starts_with(t->codec_id, MKV_A_REAL_COOK,
|
||||
strlen("A_REAL/")))
|
||||
t->a_formattag = FOURCC('r', 'e', 'a', 'l');
|
||||
else if (t->codec_id == MKV_A_FLAC) {
|
||||
#if defined(HAVE_FLAC_FORMAT_H)
|
||||
@ -1651,7 +1656,19 @@ kax_reader_c::create_packetizer(int64_t tid) {
|
||||
id = 0;
|
||||
profile = 0;
|
||||
if (t->a_formattag == FOURCC('M', 'P', '4', 'A')) {
|
||||
if (!parse_aac_codec_id(string(t->codec_id), id, profile))
|
||||
int channels, sfreq, osfreq;
|
||||
bool sbr;
|
||||
|
||||
if (t->codec_id == MKV_A_AAC) {
|
||||
id = AAC_ID_MPEG4;
|
||||
if (!parse_aac_data((unsigned char *)t->private_data,
|
||||
t->private_size, profile, channels, sfreq,
|
||||
osfreq, sbr))
|
||||
mxerror(FMT_TID "Malformed AAC codec initialization data "
|
||||
"found.\n", ti->fname.c_str(), (int64_t)t->tnum);
|
||||
if (sbr)
|
||||
profile = AAC_PROFILE_SBR;
|
||||
} else if (!parse_aac_codec_id(string(t->codec_id), id, profile))
|
||||
mxerror(FMT_TID "Malformed codec id '%s'.\n", ti->fname.c_str(),
|
||||
(int64_t)t->tnum, t->codec_id.c_str());
|
||||
} else {
|
||||
|
@ -1208,8 +1208,7 @@ qtmp4_reader_c::create_packetizer(int64_t tid) {
|
||||
int profile, sample_rate, channels, output_sample_rate;
|
||||
bool sbraac;
|
||||
|
||||
if ((dmx->esds.decoder_config_len == 2) ||
|
||||
(dmx->esds.decoder_config_len == 5)) {
|
||||
if (dmx->esds.decoder_config_len >= 2) {
|
||||
parse_aac_data(dmx->esds.decoder_config,
|
||||
dmx->esds.decoder_config_len, profile, channels,
|
||||
sample_rate, output_sample_rate, sbraac);
|
||||
@ -1218,6 +1217,8 @@ qtmp4_reader_c::create_packetizer(int64_t tid) {
|
||||
channels, output_sample_rate, (int)sbraac);
|
||||
if (sbraac)
|
||||
profile = AAC_PROFILE_SBR;
|
||||
ti->private_data = dmx->esds.decoder_config;
|
||||
ti->private_size = dmx->esds.decoder_config_len;
|
||||
dmx->ptzr =
|
||||
add_packetizer(new aac_packetizer_c(this, AAC_ID_MPEG4, profile,
|
||||
sample_rate, channels, ti,
|
||||
@ -1227,6 +1228,8 @@ qtmp4_reader_c::create_packetizer(int64_t tid) {
|
||||
set_audio_output_sampling_freq(output_sample_rate);
|
||||
mxinfo(FMT_TID "Using the AAC output module.\n", ti->fname.c_str(),
|
||||
(int64_t)dmx->id);
|
||||
ti->private_data = NULL;
|
||||
ti->private_size = 0;
|
||||
|
||||
} else
|
||||
mxerror(FMT_TID "AAC found, but decoder config data has length %u."
|
||||
|
@ -126,7 +126,10 @@ aac_packetizer_c::get_aac_packet(unsigned long *header,
|
||||
|
||||
void
|
||||
aac_packetizer_c::set_headers() {
|
||||
if (id == AAC_ID_MPEG4) {
|
||||
if ((ti->private_size > 0) && (ti->private_size != 2) &&
|
||||
(ti->private_size != 5))
|
||||
set_codec_id(MKV_A_AAC);
|
||||
else if (id == AAC_ID_MPEG4) {
|
||||
if (profile == AAC_PROFILE_MAIN)
|
||||
set_codec_id(MKV_A_AAC_4MAIN);
|
||||
else if (profile == AAC_PROFILE_LC)
|
||||
@ -154,6 +157,9 @@ aac_packetizer_c::set_headers() {
|
||||
set_audio_sampling_freq((float)samples_per_sec);
|
||||
set_audio_channels(channels);
|
||||
|
||||
if ((ti->private_data != NULL) && (ti->private_size > 0))
|
||||
set_codec_private(ti->private_data, ti->private_size);
|
||||
|
||||
generic_packetizer_c::set_headers();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user