You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-11 14:30:22 +02:00
xan: remove a trivially true if().
This function used to be shared with the xxan decoder, but that is not true anymore.
This commit is contained in:
@ -499,62 +499,61 @@ static int xan_decode_frame(AVCodecContext *avctx,
|
|||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int ret, buf_size = avpkt->size;
|
int ret, buf_size = avpkt->size;
|
||||||
XanContext *s = avctx->priv_data;
|
XanContext *s = avctx->priv_data;
|
||||||
|
const uint8_t *buf_end = buf + buf_size;
|
||||||
|
int tag = 0;
|
||||||
|
|
||||||
if (avctx->codec->id == AV_CODEC_ID_XAN_WC3) {
|
while (buf_end - buf > 8 && tag != VGA__TAG) {
|
||||||
const uint8_t *buf_end = buf + buf_size;
|
unsigned *tmpptr;
|
||||||
int tag = 0;
|
uint32_t new_pal;
|
||||||
while (buf_end - buf > 8 && tag != VGA__TAG) {
|
int size;
|
||||||
unsigned *tmpptr;
|
int i;
|
||||||
uint32_t new_pal;
|
tag = bytestream_get_le32(&buf);
|
||||||
int size;
|
size = bytestream_get_be32(&buf);
|
||||||
int i;
|
size = FFMIN(size, buf_end - buf);
|
||||||
tag = bytestream_get_le32(&buf);
|
switch (tag) {
|
||||||
size = bytestream_get_be32(&buf);
|
case PALT_TAG:
|
||||||
size = FFMIN(size, buf_end - buf);
|
if (size < PALETTE_SIZE)
|
||||||
switch (tag) {
|
return AVERROR_INVALIDDATA;
|
||||||
case PALT_TAG:
|
if (s->palettes_count >= PALETTES_MAX)
|
||||||
if (size < PALETTE_SIZE)
|
return AVERROR_INVALIDDATA;
|
||||||
return AVERROR_INVALIDDATA;
|
tmpptr = av_realloc(s->palettes,
|
||||||
if (s->palettes_count >= PALETTES_MAX)
|
(s->palettes_count + 1) * AVPALETTE_SIZE);
|
||||||
return AVERROR_INVALIDDATA;
|
if (!tmpptr)
|
||||||
tmpptr = av_realloc(s->palettes,
|
return AVERROR(ENOMEM);
|
||||||
(s->palettes_count + 1) * AVPALETTE_SIZE);
|
s->palettes = tmpptr;
|
||||||
if (!tmpptr)
|
tmpptr += s->palettes_count * AVPALETTE_COUNT;
|
||||||
return AVERROR(ENOMEM);
|
for (i = 0; i < PALETTE_COUNT; i++) {
|
||||||
s->palettes = tmpptr;
|
|
||||||
tmpptr += s->palettes_count * AVPALETTE_COUNT;
|
|
||||||
for (i = 0; i < PALETTE_COUNT; i++) {
|
|
||||||
#if RUNTIME_GAMMA
|
#if RUNTIME_GAMMA
|
||||||
int r = gamma_corr(*buf++);
|
int r = gamma_corr(*buf++);
|
||||||
int g = gamma_corr(*buf++);
|
int g = gamma_corr(*buf++);
|
||||||
int b = gamma_corr(*buf++);
|
int b = gamma_corr(*buf++);
|
||||||
#else
|
#else
|
||||||
int r = gamma_lookup[*buf++];
|
int r = gamma_lookup[*buf++];
|
||||||
int g = gamma_lookup[*buf++];
|
int g = gamma_lookup[*buf++];
|
||||||
int b = gamma_lookup[*buf++];
|
int b = gamma_lookup[*buf++];
|
||||||
#endif
|
#endif
|
||||||
*tmpptr++ = (r << 16) | (g << 8) | b;
|
*tmpptr++ = (r << 16) | (g << 8) | b;
|
||||||
}
|
|
||||||
s->palettes_count++;
|
|
||||||
break;
|
|
||||||
case SHOT_TAG:
|
|
||||||
if (size < 4)
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
new_pal = bytestream_get_le32(&buf);
|
|
||||||
if (new_pal < s->palettes_count) {
|
|
||||||
s->cur_palette = new_pal;
|
|
||||||
} else
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid palette selected\n");
|
|
||||||
break;
|
|
||||||
case VGA__TAG:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
buf += size;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
s->palettes_count++;
|
||||||
|
break;
|
||||||
|
case SHOT_TAG:
|
||||||
|
if (size < 4)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
new_pal = bytestream_get_le32(&buf);
|
||||||
|
if (new_pal < s->palettes_count) {
|
||||||
|
s->cur_palette = new_pal;
|
||||||
|
} else
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Invalid palette selected\n");
|
||||||
|
break;
|
||||||
|
case VGA__TAG:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
buf += size;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
buf_size = buf_end - buf;
|
|
||||||
}
|
}
|
||||||
|
buf_size = buf_end - buf;
|
||||||
|
|
||||||
if (s->palettes_count <= 0) {
|
if (s->palettes_count <= 0) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "No palette found\n");
|
av_log(s->avctx, AV_LOG_ERROR, "No palette found\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
Reference in New Issue
Block a user