[FFmpeg-devel] [PATCH v2] webp: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
Alex Xu (Hello71)
alex_y_xu at yahoo.ca
Tue Dec 7 19:54:39 EET 2021
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 | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index d5a81fd527..e425bce3ff 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;
@@ -1339,7 +1342,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVFrame * const p = data;
WebPContext *s = avctx->priv_data;
GetByteContext gb;
- int ret;
+ int ret, got_frame_chunk = 0;
uint32_t chunk_type, chunk_size;
int vp8x_flags = 0;
@@ -1392,6 +1395,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
chunk_size);
if (ret < 0)
return ret;
+ got_frame_chunk = 1;
}
bytestream2_skip(&gb, chunk_size);
break;
@@ -1403,6 +1407,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (ret < 0)
return ret;
avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
+ got_frame_chunk = 1;
}
bytestream2_skip(&gb, chunk_size);
break;
@@ -1524,7 +1529,7 @@ exif_end:
}
}
- if (!*got_frame) {
+ if (!got_frame_chunk) {
av_log(avctx, AV_LOG_ERROR, "image data not found\n");
return AVERROR_INVALIDDATA;
}
@@ -1565,5 +1570,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,
};
--
2.34.1
More information about the ffmpeg-devel
mailing list