[FFmpeg-devel] intent of 'lsf' variable in libavformat/mp3enc.c mp3_write_xing() ?

Michael Niedermayer michaelni at gmx.at
Fri Jun 20 15:02:49 CEST 2014


On Fri, Jun 20, 2014 at 09:47:21AM +0100, Jason Vas Dias wrote:
> On Thursday 19 June 2014 21:23:07 Michael Niedermayer wrote:
> > Hi
> > 
> > On Thu, Jun 19, 2014 at 07:07:02PM +0100, Jason Vas Dias wrote:
> > > Thanks for responding, Michael -
> > > Actually, I checked out the GIT HEAD, then checked out the latest 'stable'
> > > tag 'n2.2.3'. Sorry, my original mail should have mentioned the version I
> > > was trying to build.
> > it seems we forgot backporting the bugfix for this
> > 
> > Fixed in release/2.2
> > 
> > thanks
> > 
> > [...]
> 
> Hi Michael -
>   
>    But what was the fix for this ? How should 'lsf' be initialized - is '0' OK ?

please see git log:

commit f378636d90af664e162f75c295167078e3a97360
Author: Michael Niedermayer <michaelni at gmx.at>
Date:   Sun Apr 13 20:03:24 2014 +0200

    avformat/mp3enc: drop redundant and uninitialized variable

    Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
    (cherry picked from commit eccec203978e53f897a3c6105d011bbdff2a978b)

    Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 0eecdb7..9c9bd5e 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -124,7 +124,7 @@ static int mp3_write_xing(AVFormatContext *s)
     int best_bitrate_error = INT_MAX;
     int xing_offset;
     int ver = 0;
-    int bytes_needed, lsf;
+    int bytes_needed;
     const char *vendor = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT;

     if (!s->pb->seekable || !mp3->write_xing)
@@ -161,7 +161,7 @@ static int mp3_write_xing(AVFormatContext *s)
     header |= channels << 6;

     for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
-        int bit_rate = 1000 * avpriv_mpa_bitrate_tab[lsf][3 - 1][bitrate_idx];
+        int bit_rate = 1000 * avpriv_mpa_bitrate_tab[ver != 3][3 - 1][bitrate_idx];
         int error    = FFABS(bit_rate - codec->bit_rate);

         if (error < best_bitrate_error) {



> 
>    I've attached a patch against the files with the 'n2.2.3' tag to fix all the other 

please provide patches against git master, if there are issues
remaining in master.

to fix issues in release/2.2, limit your changes to backports from the
fixes from git master.
This ensures that all fixes have been tested before they are
backported
If you dont know how to find which commits fixed a warning, just ask
iam sure people can provide tips on this
also you might want to subscribe to the mailing list, to see replies


also dont just set variables to 0 without understanding the problem
thats worse than leaving the warning. If your goal is to hide
warnings, its best to disable them with the appropriate compiler flags
if you want to fix warnings theres no way around reading and
understanding the code that produced the warning. I suspect though
most warnings is just the compiler being silly
also there is av_uninit() to hide cases where the compiler incorrectly
thinks a variable is used uninitialized

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140620/67e8b446/attachment.asc>


More information about the ffmpeg-devel mailing list