[FFmpeg-devel] AC3 incomplete frame/invalid frame size

Phil Rutschman philr
Wed Oct 29 01:13:35 CET 2008


> I uploaded to ftp.mplayerhq.com/MPlayer/incoming/ a 19k file called
> "invalidframe-then-buzz.ac3" which decodes poorly in ffmpeg
SVN-r15735.
> The file is stereo at 192 kbps and consists of 25 AC3 syncframes.

Having investigated further, this appears to happen when the AC3 header
CRC mimics the syncword. I poked around in libavcodec/ac3_parser.c a bit
and added this instrumentation:

    err = ff_ac3_parse_header(&gbc, &hdr);

    if(err < 0) {
+       av_log(NULL, AV_LOG_DEBUG, "ff_ac3_parse_header: %d
[%016"PRIx64"]\n", err, state);	    
        return 0;
    }

    hdr_info->sample_rate = hdr.sample_rate;
    hdr_info->bit_rate = hdr.bit_rate;
    hdr_info->channels = hdr.channels;
    hdr_info->samples = AC3_FRAME_SIZE;

    *need_next_header = (hdr.frame_type != EAC3_FRAME_TYPE_AC3_CONVERT);
    *new_frame_start  = (hdr.frame_type != EAC3_FRAME_TYPE_DEPENDENT);

+   av_log(NULL, AV_LOG_DEBUG, "AC3 packet size: %d\n", hdr.frame_size);
    return hdr.frame_size;


This results in the following output when decoding
invalidframe-then-buzz.ac3:

ff_ac3_parse_header: -1 [000000000000000b]
ff_ac3_parse_header: -1 [0000000000000b77]
ff_ac3_parse_header: -1 [00000000000b770b]
ff_ac3_parse_header: -1 [000000000b770b77]
ff_ac3_parse_header: -1 [0000000b770b7714]
ff_ac3_parse_header: -1 [00000b770b771440]
AC3 packet size: 768
ff_ac3_parse_header: -1 [0b770b771440530b]
AC3 packet size: 698
ff_ac3_parse_header: -1 [0b771440530b7727]
ff_ac3_parse_header: -1 [771440530b772784]
ff_ac3_parse_header: -1 [1440530b77278449]
ff_ac3_parse_header: -1 [40530b772784499a]
ff_ac3_parse_header: -2 [530b772784499a87]


The first packet size reported is correct. The second appears to be the
result of misinterpreting the CRC as a syncword. I don't yet understand
why ac3_sync is being called after identifying the packet size.






More information about the ffmpeg-devel mailing list