Opened 13 years ago

Closed 13 years ago

#441 closed defect (fixed)

MPEG audio decoder prints "incorrect frame size" error for valid code

Reported by: Chris Rankin Owned by:
Priority: normal Component: avcodec
Version: 0.7.3 Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description

Decoding an MP3 audio stream (CODEC_ID_MP3) using libavcodec and libavutil is creating lots of messages like these:

[mp3 @ 0xad218660] incorrect frame size
[mp3 @ 0xad218660] incorrect frame size
[mp3 @ 0xad218660] incorrect frame size
[mp3 @ 0xad218660] incorrect frame size
[mp3 @ 0xad218660] incorrect frame size

However, the audio is playing fine, so there can't really be an error here. The application is funnelling an audio stream into avcodec_decode_audio3(), and is just expecting the function to consume as many bytes as it needs each time:

In simplified form:

uint8_t *buffer_offset = buffer;

while (buffer_size > 0) {

    av_init_packet(&avpkt);
    avpkt.data = buffer_offset;
    avpkt.size = buffer_size;

    bytes_consumed = avcoded_decode_audio3(context, output_buffer, &output_size, &avpkt);
    if (bytes_consumed < 0) {
        // Error handling
        return;
    }

    /* Send decoded output to device */

    buffer_size -= bytes_consumed;
    buffer_offset += bytes_consumed;
}

The spurious error message is coming from decode_frame() in libavcodec/mpegaudiodec.c: line 1977

    }else if(s->frame_size < buf_size){
        av_log(avctx, AV_LOG_ERROR, "incorrect frame size\n");
        buf_size= s->frame_size;
    }

At very worst, this should only be AV_LOG_WARNING because it's internally correctable and doesn't affect normal operation. But I would actually argue that this message could be removed completely instead, because (to be blunt) who cares if the input buffer is too big, so long as the entire frame is present and we return the correct number of bytes consumed to the caller? This message is just noise.

Attachments (1)

SITH.mov (1.2 MB ) - added by Chris Rankin 13 years ago.
Sample file that generates lots of "incorrect frame size" errors in xine

Download all attachments as: .zip

Change History (6)

comment:1 by Carl Eugen Hoyos, 13 years ago

Status: newopen

Please test current git head and please provide complete, uncut output of ffmpeg -i file.mp3 out.wav (or similar) and attach a sample.

comment:2 by Chris Rankin, 13 years ago

Eh? I'm raising a bug against libavcodec, not ffmpeg. Isn't libavcodec supposed to be linkable against other applications? And as for git-head:

http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/mpegaudiodec.c;h=56a48ce71bd8b6c05a65866545b5be3ee289bbb4;hb=HEAD

The superfluous error message is still clearly visible at line 1812:

1808     if(s->frame_size<=0 || s->frame_size > buf_size){
1809         av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
1810         return -1;
1811     }else if(s->frame_size < buf_size){
1812         av_log(avctx, AV_LOG_ERROR, "incorrect frame size\n");
1813         buf_size= s->frame_size;
1814     }

comment:3 by Carl Eugen Hoyos, 13 years ago

Is the problem not reproducible with ffmpeg (the application)? Then you are right, you should report it for the library. If the problem is (also) reproducible with ffmpeg, it will be easier to reproduce the problem (and easier to test a possible solution) if you do not report it for libavcodec, but ffmpeg. In this case, please provide complete, uncut output (and a test-case).
In any case, problems that are reproducible with current git head should not be reported for old versions of FFmpeg.

If you already know how to solve your problem, I suggest to send a patch to ffmpeg-devel.

by Chris Rankin, 13 years ago

Attachment: SITH.mov added

Sample file that generates lots of "incorrect frame size" errors in xine

comment:4 by Chris Rankin, 13 years ago

Note: xine will probably not use the FFmpeg audio decoder by default, and its default decoder provides working audio without this "spam" problem. So the issue is purely with FFmpeg.

comment:5 by Michael Niedermayer, 13 years ago

Analyzed by developer: set
Resolution: fixed
Status: openclosed

Fix commited, will be pushed soon

Note: See TracTickets for help on using tickets.