njh / twolame

MPEG Audio Layer 2 (MP2) encoder
http://www.twolame.org/
GNU Lesser General Public License v2.1
59 stars 34 forks source link

Swap bytes, when? #45

Closed eblanca closed 6 years ago

eblanca commented 7 years ago

In frontend.c I see endian-ness care is taken for some difficult audio sources. Now, is this needed when dealing with input samples coming from libsndfile? Or is this just needed in case of raw sample sources? I think the latter case is true (after all, if the frontend calls libsndfile services is because we trust them), so this special handling should be only done as part of raw input routines... What do you think about this?

njh commented 7 years ago

Within libtwolame, 16-bit integers are all host native endian (ie x86 is little-endian and PPC is big-endian).

So endian conversion is only needed when loading input files. libsndfile will deal with the endianess for us. So you are right, conversion is should only needed for raw files.

It is possible there are also other edge-cases, where you need to correct a malformed file.

eblanca commented 7 years ago

Can you provide (link to) such a corrupted/malformed file? I would like to run some tests on it.

eblanca commented 7 years ago

I was able to read (and encode) a raw file using libsndfile, via audioin_sndfile.c. This could mean twolame does not need the audioin_raw.c module anymore, as the audioin_sndfile.c can do anything the former did. Can a patch for this be relevant/interesting ?

njh commented 6 years ago

Pull Request #71 addresses this.

njh commented 6 years ago

71 has been (manually) merged into master.