Comment 48 for bug 602934

Revision history for this message
In , Leland-audacityteam (leland-audacityteam) wrote :

I have FINALLY figured out, at least for me, why the m4a files would import as
mono when the above patch was NOT applied. It basically boils to me being an
idiot.

When I was originally testing the patch, I'd realized that the QuickTime
importer was doing the import, so I reversed the order of these fellas in
Import.cpp, forcing the FFmpeg importer to be used instead:

   #if defined(USE_FFMPEG)
   GetFFmpegImportPlugin(mImportPluginList, mUnusableImportPluginList);
   #endif
   #ifdef USE_QUICKTIME
   GetQTImportPlugin(mImportPluginList, mUnusableImportPluginList);
   #endif

So, when the patch was applied, all imports would go through the FFmpeg
importer and if it was configured to use faad, then the imported audio would be
in stereo. If the patch wasn't applied then the imports would be mono since
the QuickTime importer was doing it. But, forgetting that I had done this, I
thought there was some other heinous problem lurking somewhere in the way
Audacity was using FFmpeg.

Putting the importer order back the way it was, made Audacity act the same
whether the patch was applied or not.

With that explained away, I can now say with certainty why the m4as are
importing as stereo instead of mono. It has everything to do with the faad
library.

I found the bit of code in libfaad that is causing the files to be imported as
mono. It's really quite concrete. In faad-2.7/libfaad/mp4.c, you'll find this
block:

#if (defined(PS_DEC) || defined(DRM_PS))
    /* check if we have a mono file */
    if (mp4ASC->channelsConfiguration == 1)
    {
        /* upMatrix to 2 channels for implicit signalling of PS */
        mp4ASC->channelsConfiguration = 2;
    }
#endif

And this bit of code defined faad-2.7/libfaad/common.h:

#define SBR_DEC
//#define SBR_LOW_POWER
#define PS_DEC

#ifdef SBR_LOW_POWER
#undef PS_DEC
#endif

Notice that PS_DEC will ALWAYS be defined since SBR_LOW_POWER has been
commented. That means that the channel count will always be changed to 2 if
the file only has 1 channel. So, unless measures were taken to defeat this
code, all applications using libfaad either directly or via ffmpeg, will always
import mono m4a files as stereo.

I'm now convinced that the patch works as it should and has not caused any
unexplained behavior over the previous 0.5x support.

So, if everyone is also satisfied, I'd like to go ahead and commit it and move
on to the detection simplification.

Now, getting back to the order of the FFmpeg and QuickTime importers...

I'd like to leave it with FFmpeg first and then QuickTime. That way Audacity
will behave the same on Windows, Linux, and OSX. If QuickTime comes first,
then there may be the same kind of confusion that I experienced among the
general populace. This would mean a change in behavior and the possibility
that FFmpeg would take responsibility for importing a file when the QuickTime
importer may be a better selection.

However, with the extended import/export option in preferences, the user would
be able to override the order if desired, so there's no loss of functionality.

What say ye?