Package: libfaad-dev Version: 2.7-8 Severity: normal I'm not sure if this an issue which affects Debian itself. As it affects FAAD2 users and the development seems (the original homepage is orphaned) to be continued within a Debian Git repo, I post it here.
FAAD2 provides the ability to init the decoder with the help of an AudioSpecificConfig bit sequence (see also ISO/IEC 14496-3) via NeAACDecInit2. That function also returns the "output" sample rate of the AAC stream. When the AAC stream has the SBR extension (therefore: the core sample rate is the half of the output sample rate), this can be signalled implicitely. In this case the AudioSpecificConfig signals e.g. 24 kHz. FAAD2 treats streams with sample rates of 24 kHz (or lower) automatically as having the SBR extension (see the end of AudioSpecificConfigFromBitfile in /libfaad/mp4.c) and the double of the core sample rate is returned as output sample rate. Unfortunately, this does not work on systems where the char data type is unsigned (e.g. Raspbian Jessie). In this case, the variable mp4ASC->sbr_present_flag in the mentioned function AudioSpecificConfigFromBitfile does not get initialized to -1. Therefore the sample rate returned by NeAACDecInit2 is not doubled and still refers to the core sample rate instead of the output sample rate. The problem affects the installed version (see below) as well as the latest Git version from git://anonscm.debian.org/pkg-multimedia/faad2.git One way to fix this is to make the struct variable sbr_present_flag signed. Another way is to enforce signed char by compiling FAAD2 with -fsigned-char. I attach a short example in C which reproduces the problem. It prints out the expected vs. the returned sample rate. -- System Information: Distributor ID: Raspbian Description: Raspbian GNU/Linux 8.0 (jessie) Release: 8.0 Codename: jessie Architecture: armv7l Kernel: Linux 4.4.21-v7+ (SMP w/4 CPU cores) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages libfaad-dev depends on: ii libfaad2 2.7-8 libfaad-dev recommends no packages. libfaad-dev suggests no packages. -- no debconf information
// compile with: // gcc -o faad2_test faad2_test.c -lfaad #include <stdio.h> #include <stdint.h> #include <neaacdec.h> int main() { NeAACDecHandle handle = NeAACDecOpen(); if(!handle) { fprintf(stderr, "Error while NeAACDecOpen\n"); return 1; } /* AudioSpecificConfig structure (see also ISO/IEC 14496-3) * * 00010 = AudioObjectType 2 (AAC LC) * xxxx = (core) sample rate index * xxxx = (core) channel config * 100 = GASpecificConfig with 960 transform (used for DAB+; does not matter here) * * SBR extension: implicit signaling used - libfaad2 automatically assumes SBR on sample rates <= 24 kHz */ int core_sr_index = 0b0110; // 24 kHz int core_ch_config = 0b0010; // L/R uint8_t asc[2]; asc[0] = 0b00010 << 3 | core_sr_index >> 1; asc[1] = (core_sr_index & 0x01) << 7 | core_ch_config << 3 | 0b100; // init decoder unsigned long output_sr; unsigned char output_ch; long int init_result = NeAACDecInit2(handle, asc, sizeof(asc), &output_sr, &output_ch); if(init_result != 0) { fprintf(stderr, "Error while NeAACDecInit2\n"); NeAACDecClose(handle); return 1; } printf("The output sample rate is: %ld (expected: 48000)\n", output_sr); NeAACDecClose(handle); return 0; }