Message ID | 20190802234957.11098-4-michael@niedermayer.cc |
---|---|
State | Accepted |
Commit | cd460f4da04c05d6ba93ccbbe294e948768f0937 |
Headers | show |
lör 2019-08-03 klockan 01:49 +0200 skrev Michael Niedermayer: > - uint32_t x, y, src_x, src_y; > + uint32_t x, y, src_y; > + int width = hnm->width; > > for (y = 0; y < hnm->height; y++) { > + uint8_t *dst = hnm->processed + y * width; > + const uint8_t *src = hnm->current; > src_y = y - (y % 2); > - src_x = src_y * hnm->width + (y % 2); > - for (x = 0; x < hnm->width; x++) { > - hnm->processed[(y * hnm->width) + x] = hnm- > >current[src_x]; > - src_x += 2; > + src += src_y * width + (y % 2); > + for (x = 0; x < width; x++) { > + dst[x] = *src; > + src += 2; Looks OK. Maybe telling the compiler that src and dst don't alias would be worthwhile? /Tomas
On Sat, Aug 03, 2019 at 04:07:22PM +0200, Tomas Härdin wrote: > lör 2019-08-03 klockan 01:49 +0200 skrev Michael Niedermayer: > > - uint32_t x, y, src_x, src_y; > > + uint32_t x, y, src_y; > > + int width = hnm->width; > > > > for (y = 0; y < hnm->height; y++) { > > + uint8_t *dst = hnm->processed + y * width; > > + const uint8_t *src = hnm->current; > > src_y = y - (y % 2); > > - src_x = src_y * hnm->width + (y % 2); > > - for (x = 0; x < hnm->width; x++) { > > - hnm->processed[(y * hnm->width) + x] = hnm- > > >current[src_x]; > > - src_x += 2; > > + src += src_y * width + (y % 2); > > + for (x = 0; x < width; x++) { > > + dst[x] = *src; > > + src += 2; > > Looks OK. Maybe telling the compiler that src and dst don't alias would > be worthwhile? will apply (as discussed later without restrict as it doesnt help) thx [...]
diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c index 9e1ac49ddc..68d0baef6d 100644 --- a/libavcodec/hnm4video.c +++ b/libavcodec/hnm4video.c @@ -117,14 +117,17 @@ static void unpack_intraframe(AVCodecContext *avctx, uint8_t *src, static void postprocess_current_frame(AVCodecContext *avctx) { Hnm4VideoContext *hnm = avctx->priv_data; - uint32_t x, y, src_x, src_y; + uint32_t x, y, src_y; + int width = hnm->width; for (y = 0; y < hnm->height; y++) { + uint8_t *dst = hnm->processed + y * width; + const uint8_t *src = hnm->current; src_y = y - (y % 2); - src_x = src_y * hnm->width + (y % 2); - for (x = 0; x < hnm->width; x++) { - hnm->processed[(y * hnm->width) + x] = hnm->current[src_x]; - src_x += 2; + src += src_y * width + (y % 2); + for (x = 0; x < width; x++) { + dst[x] = *src; + src += 2; } } }
Improves: Timeout (220sec -> 108sec) Improves: 15570/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HNM4_VIDEO_fuzzer-5085482213441536 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavcodec/hnm4video.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)