diff --git a/src/spek-audio.cc b/src/spek-audio.cc index e519b9c..f1daebb 100644 --- a/src/spek-audio.cc +++ b/src/spek-audio.cc @@ -134,9 +134,12 @@ std::unique_ptr Audio::open(const std::string& file_name) bits_per_sample = codec_context->bits_per_raw_sample; if (!bits_per_sample) { // APE uses bpcs, FLAC uses bprs. - // TODO: old comment, verify bits_per_sample = codec_context->bits_per_coded_sample; } + if (codec_context->codec_id == AV_CODEC_ID_AAC) { + // AAC decoder sets both bps and bitrate. + bits_per_sample = 0; + } if (bits_per_sample) { bit_rate = 0; } diff --git a/tests/samples/2ch-44100Hz-q100.m4a b/tests/samples/2ch-44100Hz-q100.m4a new file mode 100644 index 0000000..deae3a1 Binary files /dev/null and b/tests/samples/2ch-44100Hz-q100.m4a differ diff --git a/tests/test-audio-info.cc b/tests/test-audio-info.cc index aa55852..196c26b 100644 --- a/tests/test-audio-info.cc +++ b/tests/test-audio-info.cc @@ -50,6 +50,7 @@ static void test_file(const std::string& name, const FileInfo& info) void test_audio_info() { const double MP3_T = 5.0 * 1152 / 44100; // 5 frames * duration per mp3 frame + const double M4A_T = (10240 + 628) / 2.0 / 44100; std::map files = { {"1ch-96000Hz-24bps.flac", {"FLAC", 0, 96000, 24, 1, 0.1}}, @@ -63,6 +64,7 @@ void test_audio_info() {"2ch-44100Hz-320cbr.mp3", {"MP3", 320000, 44100, 0, 2, MP3_T}}, {"2ch-44100Hz-V0.mp3", {"MP3", 201329, 44100, 0, 2, MP3_T}}, {"2ch-44100Hz-V2.mp3", {"MP3", 150124, 44100, 0, 2, MP3_T}}, + {"2ch-44100Hz-q100.m4a", {"AAC", 159649, 44100, 0, 2, M4A_T}}, {"2ch-44100Hz-q5.ogg", {"Vorbis", 160000, 44100, 0, 2, 0.1}}, }; for (const auto& item : files) { diff --git a/tests/test-audio-read.cc b/tests/test-audio-read.cc index 503515c..c63257c 100644 --- a/tests/test-audio-read.cc +++ b/tests/test-audio-read.cc @@ -58,6 +58,7 @@ void test_audio_read() {"2ch-44100Hz-320cbr.mp3", 2 * 1152 * 4 + 94}, {"2ch-44100Hz-V0.mp3", 2 * 1152 * 4 + 94}, {"2ch-44100Hz-V2.mp3", 2 * 1152 * 4 + 94}, + {"2ch-44100Hz-q100.m4a", 10240}, {"2ch-44100Hz-q5.ogg", 2 * 1024 * 4 + 1152}, }; for (const auto& item : files) {