diff mbox series

[FFmpeg-devel] webp: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM

Message ID 1637868305.ykqhar2ukx.none@localhost
State New
Headers show
Series [FFmpeg-devel] webp: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Alex Xu (Hello71) Nov. 25, 2021, 7:45 p.m. UTC
Roughly doubles webp performance for common applications (ffmpeg,
ffprobe, mpv) due to speeding up avformat_find_stream_info.

Lossy needs no patches since vp8.c already implements skip_frame.
Lossless needs hook to understand skip_frame. Also the "image data not
found" message is fixed, which was already broken with manual
-skip_frame but would now be exposed in default operation.
---
 libavcodec/webp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer Nov. 26, 2021, 6:59 p.m. UTC | #1
On Thu, Nov 25, 2021 at 02:45:26PM -0500, Alex Xu (Hello71) wrote:
> Roughly doubles webp performance for common applications (ffmpeg,
> ffprobe, mpv) due to speeding up avformat_find_stream_info.
> 
> Lossy needs no patches since vp8.c already implements skip_frame.
> Lossless needs hook to understand skip_frame. Also the "image data not
> found" message is fixed, which was already broken with manual
> -skip_frame but would now be exposed in default operation.
> ---
>  libavcodec/webp.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/webp.c b/libavcodec/webp.c
> index d5a81fd527..f24aa979ac 100644
> --- a/libavcodec/webp.c
> +++ b/libavcodec/webp.c
> @@ -1126,6 +1126,9 @@ static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p,
>          h = s->height;
>      }
>  
> +    if (avctx->skip_frame == AVDISCARD_ALL)
> +        return data_size;
> +
>      /* parse transformations */
>      s->nb_transforms = 0;
>      s->reduced_width = s->width;
> @@ -1524,7 +1527,7 @@ exif_end:
>          }
>      }
>  
> -    if (!*got_frame) {
> +    if (!*got_frame && avctx->skip_frame < 0) {
>          av_log(avctx, AV_LOG_ERROR, "image data not found\n");
>          return AVERROR_INVALIDDATA;
>      }

there are more possibilities than AVDISCARD_ALL and NONE
maybe iam missing something but this would probably not show this
error for them even when the error occured

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index d5a81fd527..f24aa979ac 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1126,6 +1126,9 @@  static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p,
         h = s->height;
     }
 
+    if (avctx->skip_frame == AVDISCARD_ALL)
+        return data_size;
+
     /* parse transformations */
     s->nb_transforms = 0;
     s->reduced_width = s->width;
@@ -1524,7 +1527,7 @@  exif_end:
         }
     }
 
-    if (!*got_frame) {
+    if (!*got_frame && avctx->skip_frame < 0) {
         av_log(avctx, AV_LOG_ERROR, "image data not found\n");
         return AVERROR_INVALIDDATA;
     }
@@ -1565,5 +1568,5 @@  const AVCodec ff_webp_decoder = {
     .decode         = webp_decode_frame,
     .close          = webp_decode_close,
     .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 };