Commit 940b06ae authored by Reimar Döffinger's avatar Reimar Döffinger Committed by Carl Eugen Hoyos

kgv1dec: Simplify kega decoding by using memcpy instead of loops

Fixes decoding errors with icc 13.1
Signed-off-by: 's avatarCarl Eugen Hoyos <cehoyos@ag.or.at>
parent d9293648
...@@ -93,8 +93,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -93,8 +93,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
out[outcnt++] = code; // rgb555 pixel coded directly out[outcnt++] = code; // rgb555 pixel coded directly
} else { } else {
int count; int count;
int inp_off;
uint16_t *inp;
if ((code & 0x6000) == 0x6000) { if ((code & 0x6000) == 0x6000) {
// copy from previous frame // copy from previous frame
...@@ -112,7 +110,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -112,7 +110,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
start = (outcnt + offsets[oidx]) % maxcnt; start = (outcnt + offsets[oidx]) % maxcnt;
if (maxcnt - start < count) if (maxcnt - start < count || maxcnt - outcnt < count)
break; break;
if (!prev) { if (!prev) {
...@@ -121,8 +119,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -121,8 +119,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
break; break;
} }
inp = prev; memcpy(out + outcnt, prev + start, 2 * count);
inp_off = start;
} else { } else {
// copy from earlier in this frame // copy from earlier in this frame
int offset = (code & 0x1FFF) + 1; int offset = (code & 0x1FFF) + 1;
...@@ -137,19 +134,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -137,19 +134,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
count = 4 + *buf++; count = 4 + *buf++;
} }
if (outcnt < offset) if (outcnt < offset || maxcnt - outcnt < count)
break; break;
inp = out; av_memcpy_backptr((uint8_t *)out + 2 * outcnt, 2 * offset, 2 * count);
inp_off = outcnt - offset;
}
if (maxcnt - outcnt < count)
break;
for (i = inp_off; i < count + inp_off; i++) {
out[outcnt++] = inp[i];
} }
outcnt += count;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment