mirror of https://git.ffmpeg.org/ffmpeg.git
Use uint8_t instead of uint16_t pointer in kega decoder.
This change allows to remove a few casts and avoids a potential pointer aliasing violation.
This commit is contained in:
parent
940b06aeb8
commit
96d2e4d61a
|
@ -50,7 +50,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||||
const uint8_t *buf_end = buf + avpkt->size;
|
const uint8_t *buf_end = buf + avpkt->size;
|
||||||
KgvContext * const c = avctx->priv_data;
|
KgvContext * const c = avctx->priv_data;
|
||||||
int offsets[8];
|
int offsets[8];
|
||||||
uint16_t *out, *prev;
|
uint8_t *out, *prev;
|
||||||
int outcnt = 0, maxcnt;
|
int outcnt = 0, maxcnt;
|
||||||
int w, h, i, res;
|
int w, h, i, res;
|
||||||
|
|
||||||
|
@ -75,9 +75,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||||
c->cur.reference = 3;
|
c->cur.reference = 3;
|
||||||
if ((res = ff_get_buffer(avctx, &c->cur)) < 0)
|
if ((res = ff_get_buffer(avctx, &c->cur)) < 0)
|
||||||
return res;
|
return res;
|
||||||
out = (uint16_t *) c->cur.data[0];
|
out = c->cur.data[0];
|
||||||
if (c->prev.data[0]) {
|
if (c->prev.data[0]) {
|
||||||
prev = (uint16_t *) c->prev.data[0];
|
prev = c->prev.data[0];
|
||||||
} else {
|
} else {
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||||
buf += 2;
|
buf += 2;
|
||||||
|
|
||||||
if (!(code & 0x8000)) {
|
if (!(code & 0x8000)) {
|
||||||
out[outcnt++] = code; // rgb555 pixel coded directly
|
AV_WN16A(&out[2 * outcnt], code); // rgb555 pixel coded directly
|
||||||
|
outcnt++;
|
||||||
} else {
|
} else {
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
|
@ -119,7 +120,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(out + outcnt, prev + start, 2 * count);
|
memcpy(out + 2 * outcnt, prev + 2 * start, 2 * count);
|
||||||
} 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,7 +138,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||||
if (outcnt < offset || maxcnt - outcnt < count)
|
if (outcnt < offset || maxcnt - outcnt < count)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
av_memcpy_backptr((uint8_t *)out + 2 * outcnt, 2 * offset, 2 * count);
|
av_memcpy_backptr(out + 2 * outcnt, 2 * offset, 2 * count);
|
||||||
}
|
}
|
||||||
outcnt += count;
|
outcnt += count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue