avcodec/pictordec: avoid pointers in picmemset()

Improves overall speed by about 3%
Testcase: 14124/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICTOR_fuzzer-5633887734071296

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2019-04-13 01:17:12 +02:00
parent bcf9d2a172
commit 3ed360ea5c
1 changed files with 18 additions and 11 deletions

View File

@ -63,22 +63,25 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
uint8_t *d; uint8_t *d;
int shift = *plane * bits_per_plane; int shift = *plane * bits_per_plane;
unsigned mask = ((1U << bits_per_plane) - 1) << shift; unsigned mask = ((1U << bits_per_plane) - 1) << shift;
int xl = *x;
int yl = *y;
int planel = *plane;
value <<= shift; value <<= shift;
while (run > 0) { while (run > 0) {
int j; int j;
for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) { for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {
d = frame->data[0] + *y * frame->linesize[0]; d = frame->data[0] + yl * frame->linesize[0];
d[*x] |= (value >> j) & mask; d[xl] |= (value >> j) & mask;
*x += 1; xl += 1;
if (*x == s->width) { if (xl == s->width) {
*y -= 1; yl -= 1;
*x = 0; xl = 0;
if (*y < 0) { if (yl < 0) {
*y = s->height - 1; yl = s->height - 1;
*plane += 1; planel += 1;
if (*plane >= s->nb_planes) if (planel >= s->nb_planes)
return; goto end;
value <<= bits_per_plane; value <<= bits_per_plane;
mask <<= bits_per_plane; mask <<= bits_per_plane;
} }
@ -86,6 +89,10 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
} }
run--; run--;
} }
end:
*x = xl;
*y = yl;
*plane = planel;
} }
static const uint8_t cga_mode45_index[6][4] = { static const uint8_t cga_mode45_index[6][4] = {