diff options
author | Paul B Mahol <onemda@gmail.com> | 2023-02-14 09:46:46 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2023-02-14 22:29:33 +0100 |
commit | b5534b94df7f9f5b3b5cd2bbc5eec98a360d2f96 (patch) | |
tree | 57e3359fe1a2e6f8e76dd170b1eeff4779bc609b | |
parent | 02ddfeadbee52c1ad8c023a93594a8cb957e11db (diff) | |
download | ffmpeg-b5534b94df7f9f5b3b5cd2bbc5eec98a360d2f96.tar.gz |
avcodec/rka: fix lossy mode decoding
-rw-r--r-- | libavcodec/rka.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libavcodec/rka.c b/libavcodec/rka.c index f479942832..7b3ba771a6 100644 --- a/libavcodec/rka.c +++ b/libavcodec/rka.c @@ -161,9 +161,9 @@ static av_cold int rka_decode_init(AVCodecContext *avctx) if ((avctx->extradata[15] & 4) != 0) cmode = -cmode; - s->ch[0].cmode = s->ch[1].cmode = cmode; - s->ch[0].cmode2 = -s->ch[0].cmode; - s->ch[1].cmode2 = -s->ch[1].cmode; + s->ch[0].cmode = s->ch[1].cmode = cmode < 0 ? 2 : cmode; + s->ch[0].cmode2 = cmode < 0 ? FFABS(cmode) : 0; + s->ch[1].cmode2 = cmode < 0 ? FFABS(cmode) : 0; av_log(avctx, AV_LOG_DEBUG, "cmode: %d\n", cmode); return 0; @@ -662,7 +662,9 @@ static int mdl64_decode(ACoder *ac, Model64 *ctx, int *dst) return 0; } -static const uint8_t tab[] = { 0, 3, 3, 2, 2, 1, 1, 1, 1 }; +static const uint8_t tab[16] = { + 0, 3, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 +}; static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, unsigned size) { @@ -729,7 +731,7 @@ static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, uns } ctx->buf0[off] = ctx->buf1[off] + ctx->buf0[off + -1]; } else { - val = val * (1 << ctx->cmode & 0x1f); + val <<= ctx->cmode; sum += ctx->buf0[off + -1] + val; switch (s->bps) { case 16: sum = av_clip_int16(sum); break; |