diff options
author | Paul B Mahol <onemda@gmail.com> | 2018-12-10 21:38:08 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2018-12-10 21:38:08 +0100 |
commit | 03beac5b97e8fd77c5fef6123183dc00f5d3c7fd (patch) | |
tree | 5abf284fe5e80419310caa966cc1f2e74c6600a8 /libavcodec/xpmdec.c | |
parent | 00502370f6bef3f40de2685a4d2ee2c1ec960da8 (diff) | |
download | ffmpeg-03beac5b97e8fd77c5fef6123183dc00f5d3c7fd.tar.gz |
avcodec/xpmdec: define constants
Diffstat (limited to 'libavcodec/xpmdec.c')
-rw-r--r-- | libavcodec/xpmdec.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index acde9e768d..43dd9bc7e7 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -26,6 +26,10 @@ #include "avcodec.h" #include "internal.h" +#define MIN_ELEMENT ' ' +#define MAX_ELEMENT 0xfe +#define NB_ELEMENTS (MAX_ELEMENT - MIN_ELEMENT + 1) + typedef struct XPMContext { uint32_t *pixels; int pixels_size; @@ -290,10 +294,10 @@ static int ascii2index(const uint8_t *cpixel, int cpp) int n = 0, m = 1, i; for (i = 0; i < cpp; i++) { - if (*p < ' ' || *p > 0xfe) + if (*p < MIN_ELEMENT || *p > MAX_ELEMENT) return AVERROR_INVALIDDATA; - n += (*p++ - ' ') * m; - m *= 223; + n += (*p++ - MIN_ELEMENT) * m; + m *= NB_ELEMENTS; } return n; } @@ -346,7 +350,7 @@ static int xpm_decode_frame(AVCodecContext *avctx, void *data, size = 1; for (i = 0; i < cpp; i++) - size *= 223; + size *= NB_ELEMENTS; if (ncolors <= 0 || ncolors > size) { av_log(avctx, AV_LOG_ERROR, "invalid number of colors: %d\n", ncolors); |