Patches item #3458942, was opened at 2011-12-13 02:41
Message generated for change (Settings changed) made by uklauer
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=310706&aid=3458942&group_id=10706

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Paul Kelly (paulk7)
Assigned to: Nobody/Anonymous (nobody)
Summary: Patch for MP2 write support using Twolame

Initial Comment:
Hi,
Currently sox supports MP2 for reading (using libmad) but not for writing. This 
can be quite confusing as it doesn't complain when given an output file with an 
.mp2 extension, but silently writes an MP3 file instead.

The attached patch is an attempt to add MP2 write support to sox using the 
Twolame library (LGPL). I considered adding MP2 as a separate format handler, 
but seeing so much of the code is shared with MP3 (including all the decoding 
code) it seemed better to modify the MP3 format handler to also support MP2 
writing.

A few points that might be important:

1. I tried to follow all the logic for supporting dynamic loading of the 
library and to do it the same way as done for liblame and libmad. I haven't 
been in a position to thoroughly test this on all platforms, but it works fine 
on Linux as far as I can see.

2. My code decides to write an MP2 rather than an MP3 file if the character '2' 
occurs in the filetype. This works for me but I'm not sure if it's robust in 
all circumstances. However the worst outcome could be that it silently writes 
an MP3 file, which is the same as the current behaviour, so perhaps not a huge 
problem.

3. Related to his, if a user attempts to write an MP2 file and Twolame support 
hasn't been compiled in, sox will now refuse and issue an error message rather 
than continuing and silently writing an MP3 file. This is arguably an 
improvement on the current behaviour. But of course it could be changed back if 
required.

4. The desired bitrate is set from the compression factor in the same way as 
for MP3 output. The Twolame API seems to indicate that it supports variable 
bitrate, but there are lots of reports of this not working and no players being 
able to play the files, so I thought it better to disable variable bitrate 
support to avoid reports of broken files.

5. Twolame does not have a variable quality parameter, so the fractional part 
of the compression factor is ignored (for MP3 this is used to set the quality). 
It does have two quality-related functions, twolame_get_quick_mode() and 
twolame_set_quick_count(), but defining a mapping between a numeric quality 
parameter and an appropriate combination of these functions just seemed like 
too much of a subjective judgement to attempt, so I just leave Twolame to use 
its default quality.

6. Since MP2/MP3 audio has a finite range of samplerates that it supports, it 
surprised me that they weren't specified when the format handler was 
initialised. So I added this in. This is obviously not necessary for the MP2 
support and could be removed if not desired.

I hope this patch can be considered for inclusion into the sox source, and I'm 
happy to respond to comments/feedback and prepare a revised version if 
necessary.

Best regards

Paul Kelly


----------------------------------------------------------------------

Comment By: Paul Kelly (paulk7)
Date: 2012-01-09 05:07

Message:
Updated patch to (a) fix bug whereby HAVE_TWOLAME was being checked before
before it had been defined, and (b) patch against current version of
src/mp3.c.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=310706&aid=3458942&group_id=10706

------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, 
is your hub for all things parallel software development, from weekly thought 
leadership blogs to news, videos, case studies, tutorials, tech docs, 
whitepapers, evaluation guides, and opinion stories. Check out the most 
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

Reply via email to