You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-16 22:42:38 +02:00
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>
This commit is contained in:
committed by
Paul B Mahol
parent
b4ad669a42
commit
b6bc981d25
@ -37,10 +37,8 @@ static int convert(uint8_t x)
|
|||||||
return 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++) {
|
for(; p<end - strlen(key); p++) {
|
||||||
if (!memcmp(p, key, strlen(key)))
|
if (!memcmp(p, key, strlen(key)))
|
||||||
break;
|
break;
|
||||||
@ -72,8 +70,8 @@ static int xbm_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
|
avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
|
||||||
end = avpkt->data + avpkt->size;
|
end = avpkt->data + avpkt->size;
|
||||||
|
|
||||||
width = parse_str_int(avpkt->data, avpkt->size, "_width");
|
width = parse_str_int(avpkt->data, end, "_width");
|
||||||
height = parse_str_int(avpkt->data, avpkt->size, "_height");
|
height = parse_str_int(avpkt->data, end, "_height");
|
||||||
|
|
||||||
if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
|
if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user