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

Jason Vas Dias jason.vas.dias at synchronoss.com
Thu Jun 19 20:07:02 CEST 2014


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.

The complete section of code I'm concerned with is :
linavformat/mp3enc.c ,   line 127:
<quote>
    int bytes_needed, lsf;
    const char *vendor = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT;

    if (!s->pb->seekable || !mp3->write_xing)
        return 0;

    for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) {
        const uint16_t base_freq = avpriv_mpa_freq_tab[i];

        if      (codec->sample_rate == base_freq)     ver = 0x3; // MPEG 1
        else if (codec->sample_rate == base_freq / 2) ver = 0x2; // MPEG 2
        else if (codec->sample_rate == base_freq / 4) ver = 0x0; // MPEG 2.5
        else continue;

        srate_idx = i;
        break;
    }
    if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) {
        av_log(s, AV_LOG_WARNING, "Unsupported sample rate, not writing Xing header.\n");
        return -1;
    }

    switch (codec->channels) {
    case 1:  channels = MPA_MONO;                                          break;
    case 2:  channels = MPA_STEREO;                                        break;
    default: av_log(s, AV_LOG_WARNING, "Unsupported number of channels, "
                    "not writing Xing header.\n");
             return -1;
    }

    /* dummy MPEG audio header */
    header  =  0xffU                                 << 24; // sync
    header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16; // sync/audio-version/layer 3/no crc*/
    header |= (srate_idx << 2) << 8;
    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];
</quote>
^- ends at line #164 .

I checked out the GIT HEAD and did a diff of this file between n2.2.3 and HEAD - no differences are shown.

I'd really just like to understand what the INTENT of this lsf variable is here - 
should it be initialized to 0 or to mpah.lsf ?

Thanks & Regards,
Jason


On Thursday 19 June 2014 19:20:50 Michael Niedermayer wrote:
> On Thu, Jun 19, 2014 at 02:51:33PM +0100, Jason Vas Dias wrote:
> > Good day -
> > I am building ffmpeg, and fixing this compiler warning :
> > 
> > libavformat/mp3enc.c:164: warning: 'lsf' may be used uninitialized in this
> > function
> > 
> > The line in question and variable declaration is :
> > 
> > line 127:         int bytes_needed, lsf;
> 
> line 127 is
> int bytes_needed;
> 
> you are looking at a old version i assume
> 
> [...]



More information about the ffmpeg-devel mailing list