[FFmpeg-devel,1/2] avcodec/ffv1dec_template: Optimize golomb run mode

Submitted by Michael Niedermayer on March 8, 2019, 4:38 p.m.

Details

Message ID 20190308163834.31692-1-michael@niedermayer.cc
State Accepted
Commit efe4aef90fd8d4259aed0a6ffe317b5be6557da9
Headers show

Commit Message

Michael Niedermayer March 8, 2019, 4:38 p.m.
Fixes: Timeout (34sec -> 12sec)
Fixes: 13398/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5664106709778432

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

Comments

Carl Eugen Hoyos March 8, 2019, 5:33 p.m.
2019-03-08 17:38 GMT+01:00, Michael Niedermayer <michael@niedermayer.cc>:
> Fixes: Timeout (34sec -> 12sec)

Am I correct that this is the speedup for an invalid input file?
Is there a measurable effect on valid files?

> Fixes:
> 13398/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5664106709778432
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/ffv1dec_template.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c
> index 25032feda0..1b7f6c4bf5 100644
> --- a/libavcodec/ffv1dec_template.c
> +++ b/libavcodec/ffv1dec_template.c
> @@ -86,6 +86,11 @@ static av_always_inline int
> RENAME(decode_line)(FFV1Context *s, int w,
>                          run_mode = 2;
>                      }
>                  }
> +                while (run_count > 1 && w-x > 1) {
> +                    sample[1][x] = RENAME(predict)(sample[1] + x, sample[0]
> + x);
> +                    x++;
> +                    run_count--;
> +                }

Carl Eugen
Michael Niedermayer March 8, 2019, 5:45 p.m.
On Fri, Mar 08, 2019 at 06:33:30PM +0100, Carl Eugen Hoyos wrote:
> 2019-03-08 17:38 GMT+01:00, Michael Niedermayer <michael@niedermayer.cc>:
> > Fixes: Timeout (34sec -> 12sec)
> 
> Am I correct that this is the speedup for an invalid input file?
> Is there a measurable effect on valid files?

This should speed up valid files

thx

[...]
Carl Eugen Hoyos March 8, 2019, 5:58 p.m.
2019-03-08 18:45 GMT+01:00, Michael Niedermayer <michael@niedermayer.cc>:
> On Fri, Mar 08, 2019 at 06:33:30PM +0100, Carl Eugen Hoyos wrote:
>> 2019-03-08 17:38 GMT+01:00, Michael Niedermayer <michael@niedermayer.cc>:
>> > Fixes: Timeout (34sec -> 12sec)
>>
>> Am I correct that this is the speedup for an invalid input file?
>> Is there a measurable effect on valid files?
>
> This should speed up valid files

Thank you!

Carl Eugen
Michael Niedermayer March 17, 2019, 10:37 a.m.
On Fri, Mar 08, 2019 at 05:38:33PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout (34sec -> 12sec)
> Fixes: 13398/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5664106709778432
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/ffv1dec_template.c | 5 +++++
>  1 file changed, 5 insertions(+)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c
index 25032feda0..1b7f6c4bf5 100644
--- a/libavcodec/ffv1dec_template.c
+++ b/libavcodec/ffv1dec_template.c
@@ -86,6 +86,11 @@  static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w,
                         run_mode = 2;
                     }
                 }
+                while (run_count > 1 && w-x > 1) {
+                    sample[1][x] = RENAME(predict)(sample[1] + x, sample[0] + x);
+                    x++;
+                    run_count--;
+                }
                 run_count--;
                 if (run_count < 0) {
                     run_mode  = 0;