[FFmpeg-cvslog] avcodec/rka: fix lossy mode decoding

Paul B Mahol git at videolan.org
Tue Feb 14 23:30:26 EET 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Feb 14 09:46:46 2023 +0100| [b5534b94df7f9f5b3b5cd2bbc5eec98a360d2f96] | committer: Paul B Mahol

avcodec/rka: fix lossy mode decoding

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b5534b94df7f9f5b3b5cd2bbc5eec98a360d2f96
---

 libavcodec/rka.c | 12 +++++++-----
 1 file 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;



More information about the ffmpeg-cvslog mailing list