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

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/xbmdec.c+3−5
@@ -37,10 +37,8 @@ static int convert(uint8_t x) · 36 unmodified lines
3737 return x;
3838 }
3939
40−static int parse_str_int(const uint8_t *p, int len, const uint8_t *key)
40+static int parse_str_int(const uint8_t *p, const uint8_t *end, const uint8_t *key)
4141 {
42− const uint8_t *end = p + len;
43−
4442 for(; p<end - strlen(key); p++) {
4543 if (!memcmp(p, key, strlen(key)))
4644 break;
@@ -72,8 +70,8 @@ static int xbm_decode_frame(AVCodecContext *avctx, void *data, · 25 unmodified lines
7270 avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
7371 end = avpkt->data + avpkt->size;
7472
75− width = parse_str_int(avpkt->data, avpkt->size, "_width");
76− height = parse_str_int(avpkt->data, avpkt->size, "_height");
73+ width = parse_str_int(avpkt->data, end, "_width");
74+ height = parse_str_int(avpkt->data, end, "_height");
7775
7876 if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
7977 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