[FFmpeg-devel] avcodec/scpr: Use av_memcpy_backptr() in type 17 and 33

Submitted by Michael Niedermayer on July 30, 2019, 12:10 a.m.

Details

Message ID 20190730001056.9110-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer July 30, 2019, 12:10 a.m.
This makes the changed code-path faster.

Change not tested except with the fuzzer testcase as I found no other testcase.

Improves: Timeout (136sec -> 74sec)
Improves: 16040/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5705876062601216

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
---
 libavcodec/scpr.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Paul B Mahol July 30, 2019, 7:19 a.m.
On Tue, Jul 30, 2019 at 2:12 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> This makes the changed code-path faster.
>
> Change not tested except with the fuzzer testcase as I found no other
> testcase.
>

You can test this easily be encoding solid color frame(s).


> Improves: Timeout (136sec -> 74sec)
> Improves:
> 16040/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5705876062601216
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> ---
>  libavcodec/scpr.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c
> index 317950dafb..778b064841 100644
> --- a/libavcodec/scpr.c
> +++ b/libavcodec/scpr.c
> @@ -548,9 +548,8 @@ static int decode_frame(AVCodecContext *avctx, void
> *data, int *got_frame,
>              clr = bytestream2_get_le24(gb);
>          }
>          for (y = 0; y < avctx->height; y++) {
> -            for (x = 0; x < avctx->width; x++) {
> -                dst[x] = clr;
> -            }
> +            dst[0] = clr;
> +            av_memcpy_backptr(dst+1, 4, 4*avctx->width - 4);
>              dst += s->current_frame->linesize[0] / 4;
>          }
>      } else if (type == 0 || type == 1) {
> --
> 2.22.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer July 30, 2019, 7:21 p.m.
On Tue, Jul 30, 2019 at 09:19:58AM +0200, Paul B Mahol wrote:
> On Tue, Jul 30, 2019 at 2:12 AM Michael Niedermayer <michael@niedermayer.cc>
> wrote:
> 
> > This makes the changed code-path faster.
> >
> > Change not tested except with the fuzzer testcase as I found no other
> > testcase.
> >
> 
> You can test this easily be encoding solid color frame(s).

on linux ?

The only thing i see is windows software. I havnt really done anything
on windows for quite a while and i suspect using wine wouldnt be easier
either.

Thought someone has this setup already and could generate a testfile
trivially.
But if not ill add this to my todo

Thanks

[...]
Paul B Mahol Aug. 11, 2019, 10:56 a.m.
lgtm

On Tue, Jul 30, 2019 at 2:12 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> This makes the changed code-path faster.
>
> Change not tested except with the fuzzer testcase as I found no other
> testcase.
>
> Improves: Timeout (136sec -> 74sec)
> Improves:
> 16040/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5705876062601216
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> ---
>  libavcodec/scpr.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c
> index 317950dafb..778b064841 100644
> --- a/libavcodec/scpr.c
> +++ b/libavcodec/scpr.c
> @@ -548,9 +548,8 @@ static int decode_frame(AVCodecContext *avctx, void
> *data, int *got_frame,
>              clr = bytestream2_get_le24(gb);
>          }
>          for (y = 0; y < avctx->height; y++) {
> -            for (x = 0; x < avctx->width; x++) {
> -                dst[x] = clr;
> -            }
> +            dst[0] = clr;
> +            av_memcpy_backptr(dst+1, 4, 4*avctx->width - 4);
>              dst += s->current_frame->linesize[0] / 4;
>          }
>      } else if (type == 0 || type == 1) {
> --
> 2.22.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Aug. 11, 2019, 3:26 p.m.
On Sun, Aug 11, 2019 at 12:56:53PM +0200, Paul B Mahol wrote:
> lgtm

will apply

thanks

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c
index 317950dafb..778b064841 100644
--- a/libavcodec/scpr.c
+++ b/libavcodec/scpr.c
@@ -548,9 +548,8 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
             clr = bytestream2_get_le24(gb);
         }
         for (y = 0; y < avctx->height; y++) {
-            for (x = 0; x < avctx->width; x++) {
-                dst[x] = clr;
-            }
+            dst[0] = clr;
+            av_memcpy_backptr(dst+1, 4, 4*avctx->width - 4);
             dst += s->current_frame->linesize[0] / 4;
         }
     } else if (type == 0 || type == 1) {