diff options
author | Jose Da Silva <digital@joescat.com> | 2021-01-31 19:50:49 -0800 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2021-02-03 16:03:15 +0100 |
commit | b6bc981d257565d77d8d14d233cf9b461e63c280 (patch) | |
tree | 30a6330d6ae2ed6d178212b3312d6d016850b0c8 | |
parent | b4ad669a425c9ec169e059bacd378f525cf53e9c (diff) | |
download | ffmpeg-b6bc981d257565d77d8d14d233cf9b461e63c280.tar.gz |
avcodec/xbmenc: substitute end instead of recalculating end
Minor speed increase, end is calculated before entering parse_str_int(),
so let's take advantage of the value and avoid recalculating twice more.
This also allows parse_str_int() to work with file size larger than int.
Signed-off-by: Joe Da Silva <digital@joescat.com>
-rw-r--r-- | libavcodec/xbmdec.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c index d19bdaee23..2ce70204cf 100644 --- a/libavcodec/xbmdec.c +++ b/libavcodec/xbmdec.c @@ -37,10 +37,8 @@ static int convert(uint8_t x) return x; } -static int parse_str_int(const uint8_t *p, int len, const uint8_t *key) +static int parse_str_int(const uint8_t *p, const uint8_t *end, const uint8_t *key) { - const uint8_t *end = p + len; - for(; p<end - strlen(key); p++) { if (!memcmp(p, key, strlen(key))) break; @@ -72,8 +70,8 @@ static int xbm_decode_frame(AVCodecContext *avctx, void *data, avctx->pix_fmt = AV_PIX_FMT_MONOWHITE; end = avpkt->data + avpkt->size; - width = parse_str_int(avpkt->data, avpkt->size, "_width"); - height = parse_str_int(avpkt->data, avpkt->size, "_height"); + width = parse_str_int(avpkt->data, end, "_width"); + height = parse_str_int(avpkt->data, end, "_height"); if ((ret = ff_set_dimensions(avctx, width, height)) < 0) return ret; |