Hi, All.
I'm using libavcodec to decode APE files, and one of them starting like this:
4D 41 43 20  96 0F 00 00  34 00 00 00
( this file has been verified by mac )
and the function in libavcodec/apedec.c:
static av_cold int ape_decode_init(AVCodecContext * avctx)
{
// ...
    s->avctx             = avctx;
    s->channels          = avctx->channels;
    s->fileversion       = AV_RL16(avctx->extradata);
    s->compression_level = AV_RL16(avctx->extradata + 2);
    s->flags             = AV_RL16(avctx->extradata + 4);

    av_log(avctx, AV_LOG_DEBUG, "Compression Level: %d - Flags: %d\n",
s->compression_level, s->flags);
    if (s->compression_level % 1000 || s->compression_level >
COMPRESSION_LEVEL_INSANE) {
        av_log(avctx, AV_LOG_ERROR, "Incorrect compression level
%d\n", s->compression_level);
        return -1;
    }
    s->fset = s->compression_level / 1000 - 1;
    for (i = 0; i < APE_FILTER_LEVELS; i++) {
        if (!ape_filter_orders[s->fset][i])
            break;
        s->filterbuf[i] = av_malloc((ape_filter_orders[s->fset][i] * 3
+ HISTORY_SIZE) * 4);
    }
// ...
}

The file version( 96 0F ) is 3990, which is correct.
But the compression level( 00 00 ) is 0, so s->fset will be -1,
and ape_filter_orders[s->fset] will be ... ?

Notice that 0 can pass test
(s->compression_level % 1000 || s->compression_level >
COMPRESSION_LEVEL_INSANE),
but it is not regular compress level. ( Is it? )

I don't know why my program won't crash at run time,
but this compression level seems cause wrong offset
when decoding.
If 0 is not a regular value, should this codec guess a right value, or
just log an error?

Thanks.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to