|
|
|
@ -381,7 +381,8 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y, |
|
|
|
|
npal = *src++ + 1; |
|
|
|
|
if (src_end - src < npal * 3) |
|
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
|
memcpy(pal, src, npal * 3); src += npal * 3; |
|
|
|
|
memcpy(pal, src, npal * 3); |
|
|
|
|
src += npal * 3; |
|
|
|
|
if (sub_type != 2) { |
|
|
|
|
for (i = 0; i < npal; i++) { |
|
|
|
|
if (!memcmp(pal + i * 3, transp, 3)) { |
|
|
|
@ -393,7 +394,8 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y, |
|
|
|
|
|
|
|
|
|
if (src_end - src < 2) |
|
|
|
|
return 0; |
|
|
|
|
zsize = (src[0] << 8) | src[1]; src += 2; |
|
|
|
|
zsize = (src[0] << 8) | src[1]; |
|
|
|
|
src += 2; |
|
|
|
|
|
|
|
|
|
if (src_end - src < zsize + (sub_type != 2)) |
|
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
@ -558,16 +560,22 @@ static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c, |
|
|
|
|
int mask_bit = !!(bits & 0x80000000); |
|
|
|
|
switch (dst[0] * 2 + mask_bit) { |
|
|
|
|
case 0: |
|
|
|
|
dst[0] = 0xFF; dst[1] = 0x00; |
|
|
|
|
dst[2] = 0x00; dst[3] = 0x00; |
|
|
|
|
dst[0] = 0xFF; |
|
|
|
|
dst[1] = 0x00; |
|
|
|
|
dst[2] = 0x00; |
|
|
|
|
dst[3] = 0x00; |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
dst[0] = 0xFF; dst[1] = 0xFF; |
|
|
|
|
dst[2] = 0xFF; dst[3] = 0xFF; |
|
|
|
|
dst[0] = 0xFF; |
|
|
|
|
dst[1] = 0xFF; |
|
|
|
|
dst[2] = 0xFF; |
|
|
|
|
dst[3] = 0xFF; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
dst[0] = 0x00; dst[1] = 0x00; |
|
|
|
|
dst[2] = 0x00; dst[3] = 0x00; |
|
|
|
|
dst[0] = 0x00; |
|
|
|
|
dst[1] = 0x00; |
|
|
|
|
dst[2] = 0x00; |
|
|
|
|
dst[3] = 0x00; |
|
|
|
|
} |
|
|
|
|
dst += 4; |
|
|
|
|
bits <<= 1; |
|
|
|
@ -736,7 +744,7 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data, |
|
|
|
|
c->bpp = bytestream2_get_byte(&bc); |
|
|
|
|
if (c->bpp == 32) { |
|
|
|
|
if (bytestream2_get_bytes_left(&bc) < 16 || |
|
|
|
|
(chunk_size - 21) < 16 ) { |
|
|
|
|
(chunk_size - 21) < 16) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
|
"Display info: missing bitmasks!\n"); |
|
|
|
|
ret = AVERROR_INVALIDDATA; |
|
|
|
@ -848,15 +856,18 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return buf_size; |
|
|
|
|
|
|
|
|
|
header_fail: |
|
|
|
|
c->width = c->height = 0; |
|
|
|
|
c->tiles_x = c->tiles_y = 0; |
|
|
|
|
c->width = |
|
|
|
|
c->height = 0; |
|
|
|
|
c->tiles_x = |
|
|
|
|
c->tiles_y = 0; |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static av_cold int g2m_decode_init(AVCodecContext *avctx) |
|
|
|
|
{ |
|
|
|
|
G2MContext * const c = avctx->priv_data; |
|
|
|
|
G2MContext *const c = avctx->priv_data; |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
if ((ret = jpg_init(avctx, &c->jc)) != 0) { |
|
|
|
@ -872,7 +883,7 @@ static av_cold int g2m_decode_init(AVCodecContext *avctx) |
|
|
|
|
|
|
|
|
|
static av_cold int g2m_decode_end(AVCodecContext *avctx) |
|
|
|
|
{ |
|
|
|
|
G2MContext * const c = avctx->priv_data; |
|
|
|
|
G2MContext *const c = avctx->priv_data; |
|
|
|
|
|
|
|
|
|
jpg_free_context(&c->jc); |
|
|
|
|
|
|
|
|
|