|
|
@ -38,29 +38,6 @@ typedef enum { |
|
|
|
MASK_LASSO |
|
|
|
MASK_LASSO |
|
|
|
} mask_type; |
|
|
|
} mask_type; |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Gets the actual raw image data after video properties which |
|
|
|
|
|
|
|
* contains the raw image data beyond the IFF extra context. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param avpkt the AVPacket where to extract raw image data from |
|
|
|
|
|
|
|
* @return pointer to raw image data |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
static av_always_inline uint8_t *get_image_data(const AVPacket *const avpkt) { |
|
|
|
|
|
|
|
return avpkt->data + AV_RB16(avpkt->data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Gets the size of raw image data beyond the IFF extra context. |
|
|
|
|
|
|
|
* Please note that any value < 2 of either IFF extra context |
|
|
|
|
|
|
|
* or raw image data is considered as an illegal packet. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param avpkt the AVPacket where to extract image data size from |
|
|
|
|
|
|
|
* @return size of raw image data in bytes |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
static av_always_inline int get_image_size(const AVPacket *const avpkt) { |
|
|
|
|
|
|
|
return avpkt->size - AV_RB16(avpkt->data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct { |
|
|
|
typedef struct { |
|
|
|
AVFrame frame; |
|
|
|
AVFrame frame; |
|
|
|
int planesize; |
|
|
|
int planesize; |
|
|
@ -202,14 +179,16 @@ static int extract_header(AVCodecContext *const avctx, |
|
|
|
int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); |
|
|
|
int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); |
|
|
|
|
|
|
|
|
|
|
|
if (avpkt) { |
|
|
|
if (avpkt) { |
|
|
|
|
|
|
|
int image_size; |
|
|
|
if (avpkt->size < 2) |
|
|
|
if (avpkt->size < 2) |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
|
|
|
|
image_size = avpkt->size - AV_RB16(avpkt->data); |
|
|
|
buf = avpkt->data; |
|
|
|
buf = avpkt->data; |
|
|
|
buf_size = bytestream_get_be16(&buf); |
|
|
|
buf_size = bytestream_get_be16(&buf); |
|
|
|
if (buf_size <= 1 || get_image_size(avpkt) <= 1) { |
|
|
|
if (buf_size <= 1 || image_size <= 1) { |
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
"Invalid image size received: %u -> image data offset: %d\n", |
|
|
|
"Invalid image size received: %u -> image data offset: %d\n", |
|
|
|
buf_size, get_image_size(avpkt)); |
|
|
|
buf_size, image_size); |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -439,8 +418,8 @@ static int decode_frame_ilbm(AVCodecContext *avctx, |
|
|
|
AVPacket *avpkt) |
|
|
|
AVPacket *avpkt) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IffContext *s = avctx->priv_data; |
|
|
|
IffContext *s = avctx->priv_data; |
|
|
|
const uint8_t *buf = avpkt->size >= 2 ? get_image_data(avpkt) : NULL; |
|
|
|
const uint8_t *buf = avpkt->size >= 2 ? avpkt->data + AV_RB16(avpkt->data) : NULL; |
|
|
|
const int buf_size = avpkt->size >= 2 ? get_image_size(avpkt) : 0; |
|
|
|
const int buf_size = avpkt->size >= 2 ? avpkt->size - AV_RB16(avpkt->data) : 0; |
|
|
|
const uint8_t *buf_end = buf+buf_size; |
|
|
|
const uint8_t *buf_end = buf+buf_size; |
|
|
|
int y, plane, res; |
|
|
|
int y, plane, res; |
|
|
|
|
|
|
|
|
|
|
@ -516,8 +495,8 @@ static int decode_frame_byterun1(AVCodecContext *avctx, |
|
|
|
AVPacket *avpkt) |
|
|
|
AVPacket *avpkt) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IffContext *s = avctx->priv_data; |
|
|
|
IffContext *s = avctx->priv_data; |
|
|
|
const uint8_t *buf = avpkt->size >= 2 ? get_image_data(avpkt) : NULL; |
|
|
|
const uint8_t *buf = avpkt->size >= 2 ? avpkt->data + AV_RB16(avpkt->data) : NULL; |
|
|
|
const int buf_size = avpkt->size >= 2 ? get_image_size(avpkt) : 0; |
|
|
|
const int buf_size = avpkt->size >= 2 ? avpkt->size - AV_RB16(avpkt->data) : 0; |
|
|
|
const uint8_t *buf_end = buf+buf_size; |
|
|
|
const uint8_t *buf_end = buf+buf_size; |
|
|
|
int y, plane, res; |
|
|
|
int y, plane, res; |
|
|
|
|
|
|
|
|
|
|
|