diff mbox

[FFmpeg-devel,4/6] avcodec/lagarith: Optimize FRAME_SOLID_RGBA

Message ID 20180813002423.10292-4-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Aug. 13, 2018, 12:24 a.m. UTC
Fixes: Timeout
Fixes: 9484/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LAGARITH_fuzzer-5707859156271104

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/lagarith.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Carl Eugen Hoyos Aug. 13, 2018, 6:11 p.m. UTC | #1
2018-08-13 2:24 GMT+02:00, Michael Niedermayer <michael@niedermayer.cc>:
> Fixes: Timeout
> Fixes:
> 9484/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LAGARITH_fuzzer-5707859156271104
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/lagarith.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c
> index 510a6ff2d6..b9a0649c31 100644
> --- a/libavcodec/lagarith.c
> +++ b/libavcodec/lagarith.c
> @@ -572,8 +572,14 @@ static int lag_decode_frame(AVCodecContext *avctx,
>
>          dst = p->data[0];
>          if (frametype == FRAME_SOLID_RGBA) {
> +            int w2 = avctx->width>>2;

qwidth? w2 is hard to read imo.

> +            uint64_t c = ((uint64_t)offset_gu << 32) | offset_gu;
>          for (j = 0; j < avctx->height; j++) {
> -            for (i = 0; i < avctx->width; i++)
> +            for (i = 0; i < w2; i++) {
> +                AV_WN64(dst + i * 16    , c);
> +                AV_WN64(dst + i * 16 + 8, c);
> +            }
> +            for (i = 4*w2; i < avctx->width; i++)

And please add (very) rough numbers to the commit message.

Thank you, Carl Eugen
Michael Niedermayer Aug. 19, 2018, 10:34 p.m. UTC | #2
On Mon, Aug 13, 2018 at 08:11:52PM +0200, Carl Eugen Hoyos wrote:
> 2018-08-13 2:24 GMT+02:00, Michael Niedermayer <michael@niedermayer.cc>:
> > Fixes: Timeout
> > Fixes:
> > 9484/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LAGARITH_fuzzer-5707859156271104
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/lagarith.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c
> > index 510a6ff2d6..b9a0649c31 100644
> > --- a/libavcodec/lagarith.c
> > +++ b/libavcodec/lagarith.c
> > @@ -572,8 +572,14 @@ static int lag_decode_frame(AVCodecContext *avctx,
> >
> >          dst = p->data[0];
> >          if (frametype == FRAME_SOLID_RGBA) {
> > +            int w2 = avctx->width>>2;
> 
> qwidth? w2 is hard to read imo.

changed

> 
> > +            uint64_t c = ((uint64_t)offset_gu << 32) | offset_gu;
> >          for (j = 0; j < avctx->height; j++) {
> > -            for (i = 0; i < avctx->width; i++)
> > +            for (i = 0; i < w2; i++) {
> > +                AV_WN64(dst + i * 16    , c);
> > +                AV_WN64(dst + i * 16 + 8, c);
> > +            }
> > +            for (i = 4*w2; i < avctx->width; i++)
> 
> And please add (very) rough numbers to the commit message.

will apply with benchmark details

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c
index 510a6ff2d6..b9a0649c31 100644
--- a/libavcodec/lagarith.c
+++ b/libavcodec/lagarith.c
@@ -572,8 +572,14 @@  static int lag_decode_frame(AVCodecContext *avctx,
 
         dst = p->data[0];
         if (frametype == FRAME_SOLID_RGBA) {
+            int w2 = avctx->width>>2;
+            uint64_t c = ((uint64_t)offset_gu << 32) | offset_gu;
         for (j = 0; j < avctx->height; j++) {
-            for (i = 0; i < avctx->width; i++)
+            for (i = 0; i < w2; i++) {
+                AV_WN64(dst + i * 16    , c);
+                AV_WN64(dst + i * 16 + 8, c);
+            }
+            for (i = 4*w2; i < avctx->width; i++)
                 AV_WN32(dst + i * 4, offset_gu);
             dst += p->linesize[0];
         }