diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-12-24 16:13:06 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-12-24 16:20:07 +0100 |
commit | 7681b8e9a922b9c1b45d95e2585b716a1caed360 (patch) | |
tree | abcd015f2c160784cae4ccef96abff2bc3b32601 /libavcodec/xan.c | |
parent | 9dbedf331eca9903230368f28716f29e7375450a (diff) | |
parent | 0a9132b84c0590500bb3d6b358219323805993fc (diff) | |
download | ffmpeg-7681b8e9a922b9c1b45d95e2585b716a1caed360.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
wnv1: cosmetics, reformat
xan: remove a trivially true if().
ansi: do not depend on get_buffer() initializing the frame.
zerocodec: remove an unused variable.
zmbv: remove some pointless comments and empty lines
Conflicts:
libavcodec/xan.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/xan.c')
-rw-r--r-- | libavcodec/xan.c | 105 |
1 files changed, 52 insertions, 53 deletions
diff --git a/libavcodec/xan.c b/libavcodec/xan.c index 2aa420e508..899c1f1d22 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -518,66 +518,65 @@ static int xan_decode_frame(AVCodecContext *avctx, const uint8_t *buf = avpkt->data; int ret, buf_size = avpkt->size; XanContext *s = avctx->priv_data; - - if (avctx->codec->id == AV_CODEC_ID_XAN_WC3) { - const uint8_t *buf_end = buf + buf_size; - int tag = 0; - while (buf_end - buf > 8 && tag != VGA__TAG) { - unsigned *tmpptr; - uint32_t new_pal; - int size; - int i; - tag = bytestream_get_le32(&buf); - size = bytestream_get_be32(&buf); - if(size < 0) { - av_log(avctx, AV_LOG_ERROR, "Invalid tag size %d\n", size); + const uint8_t *buf_end = buf + buf_size; + int tag = 0; + + while (buf_end - buf > 8 && tag != VGA__TAG) { + unsigned *tmpptr; + uint32_t new_pal; + int size; + int i; + tag = bytestream_get_le32(&buf); + size = bytestream_get_be32(&buf); + if(size < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid tag size %d\n", size); + return AVERROR_INVALIDDATA; + } + size = FFMIN(size, buf_end - buf); + switch (tag) { + case PALT_TAG: + if (size < PALETTE_SIZE) return AVERROR_INVALIDDATA; - } - size = FFMIN(size, buf_end - buf); - switch (tag) { - case PALT_TAG: - if (size < PALETTE_SIZE) - return AVERROR_INVALIDDATA; - if (s->palettes_count >= PALETTES_MAX) - return AVERROR_INVALIDDATA; - tmpptr = av_realloc(s->palettes, - (s->palettes_count + 1) * AVPALETTE_SIZE); - if (!tmpptr) - return AVERROR(ENOMEM); - s->palettes = tmpptr; - tmpptr += s->palettes_count * AVPALETTE_COUNT; - for (i = 0; i < PALETTE_COUNT; i++) { + if (s->palettes_count >= PALETTES_MAX) + return AVERROR_INVALIDDATA; + tmpptr = av_realloc(s->palettes, + (s->palettes_count + 1) * AVPALETTE_SIZE); + if (!tmpptr) + return AVERROR(ENOMEM); + s->palettes = tmpptr; + tmpptr += s->palettes_count * AVPALETTE_COUNT; + for (i = 0; i < PALETTE_COUNT; i++) { #if RUNTIME_GAMMA - int r = gamma_corr(*buf++); - int g = gamma_corr(*buf++); - int b = gamma_corr(*buf++); + int r = gamma_corr(*buf++); + int g = gamma_corr(*buf++); + int b = gamma_corr(*buf++); #else - int r = gamma_lookup[*buf++]; - int g = gamma_lookup[*buf++]; - int b = gamma_lookup[*buf++]; + int r = gamma_lookup[*buf++]; + int g = gamma_lookup[*buf++]; + int b = gamma_lookup[*buf++]; #endif - *tmpptr++ = (0xFFU << 24) | (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; + *tmpptr++ = (0xFFU << 24) | (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; } - buf_size = buf_end - buf; } + buf_size = buf_end - buf; + if (s->palettes_count <= 0) { av_log(s->avctx, AV_LOG_ERROR, "No palette found\n"); return AVERROR_INVALIDDATA; |