History

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.

Jose Da Silva committed 5 years ago

Commit b6bc9811 parent b4ad6691 file · +3 −5Browse files

Unified · Split

libavcodec/xbmdec.c+3−5
@@ -37,10 +37,8 @@ static int convert(uint8_t x) · 36 unmodified lines
37 return x;37 return x;
38}38}
39 39
40static int parse_str_int(const uint8_t *p, int len, const uint8_t *key)40static int parse_str_int(const uint8_t *p, const uint8_t *end, const uint8_t *key)
41{41{
42 const uint8_t *end = p + len;
43
44 for(; p<end - strlen(key); p++) {42 for(; p<end - strlen(key); p++) {
45 if (!memcmp(p, key, strlen(key)))43 if (!memcmp(p, key, strlen(key)))
46 break;44 break;
@@ -72,8 +70,8 @@ static int xbm_decode_frame(AVCodecContext *avctx, void *data, · 25 unmodified lines
72 avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;70 avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
73 end = avpkt->data + avpkt->size;71 end = avpkt->data + avpkt->size;
74 72
75 width = parse_str_int(avpkt->data, avpkt->size, "_width");73 width = parse_str_int(avpkt->data, end, "_width");
76 height = parse_str_int(avpkt->data, avpkt->size, "_height");74 height = parse_str_int(avpkt->data, end, "_height");
77 75
78 if ((ret = ff_set_dimensions(avctx, width, height)) < 0)76 if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
79 return ret;77 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t