[FFmpeg-devel] FFmpeg at IBC

2024-07-14 Thread Thilo Borgmann via ffmpeg-devel

Hi,

FFmpeg will have a booth at the next IBC from September 13th to 16th 
2024 in Amsterdam [1]!


We received a corporate sponsorship for the booth, so there are no costs 
for the FFmpeg project to it (and no obligations, of course).


FFmpeg developers are welcome to join in and help man the booth with me!

Share with us your broken workflows, unfulfilled requirements, ideas for 
enhancements and after show drinks at W8.A23g!


-Thilo

[1] https://show.ibc.org/

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 1/4] avfilter/af_volumedetect.c: Move logdb function

2024-06-30 Thread Thilo Borgmann via ffmpeg-devel



On 29.06.24 21:54, Yigithan Yigit wrote:



On 29 Jun 2024, at 22:22, Rémi Denis-Courmont  wrote:

Le perjantaina 28. kesäkuuta 2024, 23.15.20 EEST Yigithan Yigit a écrit :

---
libavfilter/af_volumedetect.c | 20 ++--
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/libavfilter/af_volumedetect.c b/libavfilter/af_volumedetect.c
index 8b001d1cf2..327801a7f9 100644
--- a/libavfilter/af_volumedetect.c
+++ b/libavfilter/af_volumedetect.c
@@ -24,6 +24,8 @@
#include "avfilter.h"
#include "internal.h"
+#define MAX_DB 91
+
typedef struct VolDetectContext {
/**
 * Number of samples at each PCM value.
@@ -33,6 +35,14 @@ typedef struct VolDetectContext {
uint64_t histogram[0x10001];
} VolDetectContext;
+static inline double logdb(uint64_t v)
+{
+double d = v / (double)(0x8000 * 0x8000);


ldexp(v, -30) ?


That was the original code that already written. Should I change?


Not here. Keep the move patch as-is.

You can test if ldexp() is equal and if so, add another patch to the 
patchset changing the function to utilize ldexp().


-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v13 6/8] libavformat/webp: add WebP demuxer

2024-06-21 Thread Thilo Borgmann via ffmpeg-devel
From: Josef Zlomek 

Adds the demuxer of animated WebP files.
It supports non-animated, animated, truncated, and concatenated files.
Reading from a pipe (and other non-seekable inputs) is also supported.

The WebP demuxer splits the input stream into packets containing one frame.
It also marks the key frames properly.
The loop count is ignored by default (same behaviour as animated PNG and GIF),
it may be enabled by the option '-ignore_loop 0'.

The frame rate is set according to the frame delay in the ANMF chunk.
If the delay is too low, or the image is not animated, the default frame rate
is set to 10 fps, similarly to other WebP libraries and browsers.
The fate suite was updated accordingly.

Signed-off-by: Josef Zlomek 
---
 Changelog |   1 +
 doc/demuxers.texi |  28 ++
 libavformat/Makefile  |   1 +
 libavformat/allformats.c  |   1 +
 libavformat/webpdec.c | 384 ++
 tests/ref/fate/exif-image-webp|   4 +-
 tests/ref/fate/webp-rgb-lena-lossless |   2 +-
 tests/ref/fate/webp-rgb-lena-lossless-rgb24   |   2 +-
 tests/ref/fate/webp-rgb-lossless  |   2 +-
 .../fate/webp-rgb-lossless-palette-predictor  |   2 +-
 tests/ref/fate/webp-rgb-lossy-q80 |   2 +-
 tests/ref/fate/webp-rgba-lossless |   2 +-
 tests/ref/fate/webp-rgba-lossy-q80|   2 +-
 13 files changed, 424 insertions(+), 9 deletions(-)
 create mode 100644 libavformat/webpdec.c

diff --git a/Changelog b/Changelog
index de6eedfd68..22a6d16824 100644
--- a/Changelog
+++ b/Changelog
@@ -102,6 +102,7 @@ version 6.1:
   variable-fields elements within the same parent element
 - ffprobe -output_format option added as an alias of -of
 - animated WebP decoder
+- animated WebP demuxer
 
 
 version 6.0:
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 04293c4813..9c9d0fee17 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -1158,4 +1158,32 @@ this is set to 0, which means that a sensible value is 
chosen based on the
 input format.
 @end table
 
+@section webp
+
+Animated WebP demuxer.
+
+It accepts the following options:
+
+@table @option
+@item -min_delay @var{int}
+Set the minimum valid delay between frames in milliseconds.
+Range is 0 to 6. Default value is 10.
+
+@item -max_webp_delay @var{int}
+Set the maximum valid delay between frames in milliseconds.
+Range is 0 to 16777215. Default value is 16777215 (over four hours),
+the maximum value allowed by the specification.
+
+@item -default_delay @var{int}
+Set the default delay between frames in milliseconds.
+Range is 0 to 6. Default value is 100.
+
+@item -ignore_loop @var{bool}
+WebP files can contain information to loop a certain number of times
+(or infinitely). If @option{ignore_loop} is set to true, then the loop
+setting from the input will be ignored and looping will not occur.
+If set to false, then looping will occur and will cycle the number
+of times according to the WebP. Default value is true.
+@end table
+
 @c man end DEMUXERS
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 7ca68a7036..d86e98926d 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -628,6 +628,7 @@ OBJS-$(CONFIG_WEBM_MUXER)+= matroskaenc.o 
matroska.o \
 av1.o avlanguage.o
 OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER)  += webmdashenc.o
 OBJS-$(CONFIG_WEBM_CHUNK_MUXER)  += webm_chunk.o
+OBJS-$(CONFIG_WEBP_DEMUXER)  += webpdec.o
 OBJS-$(CONFIG_WEBP_MUXER)+= webpenc.o
 OBJS-$(CONFIG_WEBVTT_DEMUXER)+= webvttdec.o subtitles.o
 OBJS-$(CONFIG_WEBVTT_MUXER)  += webvttenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 305fa46532..23f6ef7f7d 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -511,6 +511,7 @@ extern const FFInputFormat  ff_webm_dash_manifest_demuxer;
 extern const FFOutputFormat ff_webm_dash_manifest_muxer;
 extern const FFOutputFormat ff_webm_chunk_muxer;
 extern const FFOutputFormat ff_webp_muxer;
+extern const FFInputFormat  ff_webp_demuxer;
 extern const FFInputFormat  ff_webvtt_demuxer;
 extern const FFOutputFormat ff_webvtt_muxer;
 extern const FFInputFormat  ff_wsaud_demuxer;
diff --git a/libavformat/webpdec.c b/libavformat/webpdec.c
new file mode 100644
index 00..446e181156
--- /dev/null
+++ b/libavformat/webpdec.c
@@ -0,0 +1,384 @@
+/*
+ * WebP demuxer
+ * Copyright (c) 2020 Pexeso Inc.
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; with

[FFmpeg-devel] [PATCH v13 7/8] fate: add test for animated WebP

2024-06-21 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

---
 tests/fate/image.mak   |   9 
 tests/ref/fate/webp-anim   |  22 
 tests/ref/fate/webp-chfmt1 |  23 
 tests/ref/fate/webp-chfmt2 | 106 +
 4 files changed, 160 insertions(+)
 create mode 100644 tests/ref/fate/webp-anim
 create mode 100644 tests/ref/fate/webp-chfmt1
 create mode 100644 tests/ref/fate/webp-chfmt2

diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 753936ec20..37dd0b83d9 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -566,6 +566,15 @@ fate-webp-rgb-lossy-q80: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/rgb_q80.webp
 FATE_WEBP += fate-webp-rgba-lossy-q80
 fate-webp-rgba-lossy-q80: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/rgba_q80.webp
 
+FATE_WEBP += fate-webp-anim
+fate-webp-anim: CMD = framecrc -i $(TARGET_SAMPLES)/webp/anim.webp
+
+FATE_WEBP += fate-webp-chfmt1
+fate-webp-chfmt1: CMD = framecrc -i $(TARGET_SAMPLES)/webp/anim_rgb_yuv.webp
+
+FATE_WEBP += fate-webp-chfmt2
+fate-webp-chfmt2: CMD = framecrc -i $(TARGET_SAMPLES)/webp/anim_yuv_rgb.webp
+
 FATE_WEBP-$(call DEMDEC, IMAGE2, WEBP) += $(FATE_WEBP)
 FATE_IMAGE_FRAMECRC += $(FATE_WEBP-yes)
 fate-webp: $(FATE_WEBP-yes)
diff --git a/tests/ref/fate/webp-anim b/tests/ref/fate/webp-anim
new file mode 100644
index 00..f0d3f1a88f
--- /dev/null
+++ b/tests/ref/fate/webp-anim
@@ -0,0 +1,22 @@
+#tb 0: 1/1000
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 100x70
+#sar 0: 0/1
+0,  0,  0,   80,28000, 0x2023ba6e
+0, 80, 80,   80,28000, 0x4292b778
+0,160,160,   80,28000, 0x1c972ef1
+0,240,240,   80,28000, 0xa98d8d04
+0,320,320,   80,28000, 0xd323b6af
+0,400,400,   80,28000, 0x508aba99
+0,480,480,   80,28000, 0x5c672dda
+0,560,560,   80,28000, 0xc8961ebb
+0,640,640, 1000,28000, 0x82460e1b
+0,   1640,   1640,   80,28000, 0x3debbfc9
+0,   1720,   1720,   80,28000, 0x427ab31f
+0,   1800,   1800,   80,28000, 0x6bbdec2e
+0,   1880,   1880,   80,28000, 0x5690b56b
+0,   1960,   1960,   80,28000, 0xb62963f3
+0,   2040,   2040,   80,28000, 0x68dd37b2
+0,   2120,   2120,   80,28000, 0x465c47d2
+0,   2200,   2200,1,28000, 0xa92033df
diff --git a/tests/ref/fate/webp-chfmt1 b/tests/ref/fate/webp-chfmt1
new file mode 100644
index 00..bdb0616353
--- /dev/null
+++ b/tests/ref/fate/webp-chfmt1
@@ -0,0 +1,23 @@
+#tb 0: 1/1000
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 488x488
+#sar 0: 0/1
+0,  0,  0,   80,   952576, 0x22e300c0
+0, 80, 80,   80,   952576, 0x4e7e9a01
+0,160,160,   80,   952576, 0x01b6a421
+0,240,240,   80,   952576, 0x26f09b88
+0,320,320,   80,   952576, 0xbb1404ac
+0,400,400,  480,   952576, 0x14368b56
+0,880,880,   80,   952576, 0x1843fad6
+0,960,960,   80,   952576, 0xc3c4bb73
+0,   1040,   1040,  160,   952576, 0x9d662364
+0,   1200,   1200,  160,   952576, 0xf8218a9a
+0,   1360,   1360,  160,   952576, 0x5828d888
+0,   1520,   1520,  560,   952576, 0x6a718e32
+0,   2080,   2080,   80,   952576, 0x95b7ff21
+0,   2160,   2160,   80,   952576, 0x84662ce1
+0,   2240,   2240,  720,   952576, 0x11974723
+0,   2960,   2960,   80,   952576, 0xd4a644ef
+0,   3040,   3040,   80,   952576, 0x3d29c6a8
+0,   3120,   3120,  720,   952576, 0x3d3a2d40
diff --git a/tests/ref/fate/webp-chfmt2 b/tests/ref/fate/webp-chfmt2
new file mode 100644
index 00..3d00544390
--- /dev/null
+++ b/tests/ref/fate/webp-chfmt2
@@ -0,0 +1,106 @@
+#tb 0: 1/1000
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 320x240
+#sar 0: 0/1
+0,  0,  0,   30,   192000, 0x41a50269
+0, 30, 30,   30,   192000, 0xb54a0286
+0, 60, 60,   30,   192000, 0x842c01ab
+0, 90, 90,   30,   192000, 0x19b0fd8f
+0,120,120,   30,   192000, 0x9eb9fb71
+0,150,150,   30,   192000, 0x1e11fb1d
+0,180,180,   30,   192000, 0x4e33fe49
+0,210,210,   30,   192000, 0x2e4fffa4
+0,240,240,   30,   192000, 0xfa74ff7f
+0,270,270,   30,   192000, 0x695ff5dd
+0,300,300,   30,   192000, 0xd263ff87
+0,330,330,   30,   192000, 0x8eb2f958
+0,360,360,   30,   192000, 0x2630f6dd
+0,390,390,   30,   192000, 0xf84af899
+0,420,420,   30

[FFmpeg-devel] [PATCH v13 8/8] avcodec/webp: export XMP metadata

2024-06-21 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

---
 libavcodec/webp.c | 42 --
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index bacf605ff2..c8be673060 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -38,8 +38,8 @@
  * @author Josef Zlomek, Pexeso Inc. 
  * Animation
  *
- * Unimplemented:
- *   - XMP metadata
+ * @author Thilo Borgmann 
+ * XMP metadata
  */
 
 #include "libavutil/common.h"
@@ -220,6 +220,7 @@ typedef struct WebPContext {
 int has_exif;   /* set after an EXIF chunk has been 
processed */
 int has_iccp;   /* set after an ICCP chunk has been 
processed */
 int duration;   /* frame duration in an animation */
+int has_xmp;/* set after an XMP chunk has been 
processed */
 int width;  /* image width */
 int height; /* image height */
 int vp8x_flags; /* global flags from VP8X chunk */
@@ -1469,6 +1470,7 @@ static int webp_decode_frame_common(AVCodecContext 
*avctx, uint8_t *data, int si
 // reset metadata bit for each packet
 s->has_exif  = 0;
 s->has_iccp  = 0;
+s->has_xmp   = 0;
 
 while (bytestream2_get_bytes_left(&gb) > 8) {
 char chunk_str[5] = { 0 };
@@ -1500,6 +1502,7 @@ static int webp_decode_frame_common(AVCodecContext 
*avctx, uint8_t *data, int si
 s->canvas_height = 0;
 s->has_exif  = 0;
 s->has_iccp  = 0;
+s->has_xmp   = 0;
 ff_progress_frame_unref(&s->canvas_frame);
 break;
 case MKTAG('V', 'P', '8', ' '):
@@ -1682,12 +1685,39 @@ exif_end:
 }
 s->vp8x_flags |= VP8X_FLAG_ANIMATION;
 break;
-case MKTAG('X', 'M', 'P', ' '):
-AV_WL32(chunk_str, chunk_type);
-av_log(avctx, AV_LOG_WARNING, "skipping unsupported chunk: %s\n",
-   chunk_str);
+case MKTAG('X', 'M', 'P', ' '): {
+GetByteContext xmp_gb;
+AVDictionary **xmp_metadata = NULL;
+uint8_t *buffer;
+int xmp_offset = bytestream2_tell(&gb);
+
+if (s->has_xmp) {
+av_log(avctx, AV_LOG_VERBOSE, "Ignoring extra XMP chunk\n");
+goto xmp_end;
+}
+if (!(s->vp8x_flags & VP8X_FLAG_XMP_METADATA))
+av_log(avctx, AV_LOG_WARNING,
+   "XMP chunk present, but XMP bit not set in the "
+   "VP8X header\n");
+
+// there are at least chunk_size bytes left to read
+buffer = av_malloc(chunk_size + 1);
+if (!buffer) {
+return AVERROR(ENOMEM);
+}
+
+s->has_xmp = 1;
+bytestream2_init(&xmp_gb, data + xmp_offset, size - xmp_offset);
+bytestream2_get_buffer(&xmp_gb, buffer, chunk_size);
+buffer[chunk_size] = '\0';
+
+xmp_metadata = (s->vp8x_flags & VP8X_FLAG_ANIMATION) ? 
&p->metadata : &s->frame->metadata;
+av_dict_set(xmp_metadata, "xmp", buffer, AV_DICT_DONT_STRDUP_VAL);
+
+xmp_end:
 bytestream2_skip(&gb, chunk_size);
 break;
+}
 default:
 AV_WL32(chunk_str, chunk_type);
 av_log(avctx, AV_LOG_VERBOSE, "skipping unknown chunk: %s\n",
-- 
2.39.3 (Apple Git-146)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v13 3/8] avcodec/bsf: Add awebp2webp bitstream filter

2024-06-21 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

Splits a packet containing a webp animations into
one non-compliant packet per frame of the animation.
Skips RIFF and WEBP chunks for those packets except
for the first. Copyies ICC, EXIF and XMP chunks first
into each of the packets except for the first.
---
 configure  |   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/bsf/Makefile|   1 +
 libavcodec/bsf/awebp2webp.c| 353 +
 4 files changed, 356 insertions(+)
 create mode 100644 libavcodec/bsf/awebp2webp.c

diff --git a/configure b/configure
index 3bca638459..1b6e56496f 100755
--- a/configure
+++ b/configure
@@ -3437,6 +3437,7 @@ aac_adtstoasc_bsf_select="adts_header mpeg4audio"
 av1_frame_merge_bsf_select="cbs_av1"
 av1_frame_split_bsf_select="cbs_av1"
 av1_metadata_bsf_select="cbs_av1"
+awebp2webp_bsf_select=""
 dts2pts_bsf_select="cbs_h264 h264parse"
 eac3_core_bsf_select="ac3_parser"
 evc_frame_merge_bsf_select="evcparse"
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 138246c50e..1f6471f4f3 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -28,6 +28,7 @@ extern const FFBitStreamFilter ff_aac_adtstoasc_bsf;
 extern const FFBitStreamFilter ff_av1_frame_merge_bsf;
 extern const FFBitStreamFilter ff_av1_frame_split_bsf;
 extern const FFBitStreamFilter ff_av1_metadata_bsf;
+extern const FFBitStreamFilter ff_awebp2webp_bsf;
 extern const FFBitStreamFilter ff_chomp_bsf;
 extern const FFBitStreamFilter ff_dump_extradata_bsf;
 extern const FFBitStreamFilter ff_dca_core_bsf;
diff --git a/libavcodec/bsf/Makefile b/libavcodec/bsf/Makefile
index fb70ad0c21..48c67dd210 100644
--- a/libavcodec/bsf/Makefile
+++ b/libavcodec/bsf/Makefile
@@ -5,6 +5,7 @@ OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += bsf/aac_adtstoasc.o
 OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= bsf/av1_frame_merge.o
 OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= bsf/av1_frame_split.o
 OBJS-$(CONFIG_AV1_METADATA_BSF)   += bsf/av1_metadata.o
+OBJS-$(CONFIG_AWEBP2WEBP_BSF) += bsf/awebp2webp.o
 OBJS-$(CONFIG_CHOMP_BSF)  += bsf/chomp.o
 OBJS-$(CONFIG_DCA_CORE_BSF)   += bsf/dca_core.o
 OBJS-$(CONFIG_DTS2PTS_BSF)+= bsf/dts2pts.o
diff --git a/libavcodec/bsf/awebp2webp.c b/libavcodec/bsf/awebp2webp.c
new file mode 100644
index 00..69a0156167
--- /dev/null
+++ b/libavcodec/bsf/awebp2webp.c
@@ -0,0 +1,353 @@
+/*
+ * Animated WebP into non-compliant WebP bitstream filter
+ * Copyright (c) 2024 Thilo Borgmann 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Animated WebP into non-compliant WebP bitstream filter
+ * Splits a packet containing a webp animations into
+ * one non-compliant packet per frame of the animation.
+ * Skips RIFF and WEBP chunks for those packets except
+ * for the first. Copyies ICC, EXIF and XMP chunks first
+ * into each of the packets except for the first.
+ * @author Thilo Borgmann 
+ */
+
+#include 
+#include 
+
+#include "codec_id.h"
+#include "bytestream.h"
+#include "libavutil/error.h"
+#include "libavutil/mem.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "packet.h"
+
+#define VP8X_FLAG_ANIMATION 0x02
+#define VP8X_FLAG_XMP_METADATA  0x04
+#define VP8X_FLAG_EXIF_METADATA 0x08
+#define VP8X_FLAG_ALPHA 0x10
+#define VP8X_FLAG_ICC   0x20
+
+typedef struct WEBPBSFContext {
+const AVClass *class;
+GetByteContext gb;
+
+AVPacket *last_pkt;
+uint8_t *last_iccp;
+uint8_t *last_exif;
+uint8_t *last_xmp;
+
+int iccp_size;
+int exif_size;
+int xmp_size;
+
+int add_iccp;
+int add_exif;
+int add_xmp;
+
+uint64_t last_pts;
+} WEBPBSFContext;
+
+static int save_chunk(WEBPBSFContext *ctx, uint8_t **buf, int *buf_size, 
uint32_t chunk_size)
+{
+if (*buf || !buf_size || !chunk_size)
+return 0;
+
+*buf = av_malloc(chunk_size + 8);
+if (!*buf)
+return AVERROR(ENOMEM);
+
+*buf_size = chunk_size + 8;
+
+byte

[FFmpeg-devel] [PATCH v13 5/8] avcodec/webp: make init_canvas_frame static

2024-06-21 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

---
 libavcodec/webp.c | 146 +++---
 1 file changed, 72 insertions(+), 74 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 146d5cb393..bacf605ff2 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1383,7 +1383,78 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, 
AVFrame *p,
 return ret;
 }
 
-int init_canvas_frame(WebPContext *s, int format, int key_frame);
+static int init_canvas_frame(WebPContext *s, int format, int key_frame)
+{
+AVFrame *canvas = s->canvas_frame.f;
+int height;
+int ret;
+
+// canvas is needed only for animation
+if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION))
+return 0;
+
+// avoid init for non-key frames whose format and size did not change
+if (!key_frame &&
+canvas &&
+canvas->width  == s->canvas_width &&
+canvas->height == s->canvas_height)
+return 0;
+
+// canvas changes within IPPP sequences will lose thread sync
+// because of the ThreadFrame reallocation and will wait forever
+// so if frame-threading is used, forbid canvas changes and unlock
+// previous frames
+if (!key_frame && canvas) {
+if (s->avctx->thread_count > 1) {
+av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged. Use -threads 1 to try decoding with best effort.\n");
+// unlock previous frames that have sent an _await() call
+ff_progress_frame_report(&s->canvas_frame, INT_MAX);
+return AVERROR_PATCHWELCOME;
+} else {
+// warn for damaged frames
+av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged.\n");
+}
+}
+
+s->avctx->pix_fmt = format;
+
+// VP8 decoder changed the width and height in AVCodecContext.
+// Change it back to the canvas size.
+ret = ff_set_dimensions(s->avctx, s->canvas_width, s->canvas_height);
+if (ret < 0)
+return ret;
+
+ff_progress_frame_unref(&s->canvas_frame);
+ret = ff_progress_frame_get_buffer(s->avctx, &s->canvas_frame, 
AV_GET_BUFFER_FLAG_REF);
+if (ret < 0)
+return ret;
+
+canvas = s->canvas_frame.f;
+canvas->format= format;
+canvas->duration  = s->duration;
+canvas->width = s->canvas_width;
+canvas->height= s->canvas_height;
+
+if (canvas->format == AV_PIX_FMT_ARGB) {
+height = canvas->height;
+memset(canvas->data[0], 0, height * canvas->linesize[0]);
+} else /* if (canvas->format == AV_PIX_FMT_YUVA420P) */ {
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(canvas->format);
+for (int comp = 0; comp < desc->nb_components; comp++) {
+int plane = desc->comp[comp].plane;
+
+if (comp == 1 || comp == 2)
+height = AV_CEIL_RSHIFT(canvas->height, desc->log2_chroma_h);
+else
+height = FFALIGN(canvas->height, 1 << desc->log2_chroma_h);
+
+memset(canvas->data[plane], s->transparent_yuva[plane],
+   height * canvas->linesize[plane]);
+}
+}
+
+return 0;
+}
 
 static int webp_decode_frame_common(AVCodecContext *avctx, uint8_t *data, int 
size,
 int *got_frame, int key_frame, AVFrame *p)
@@ -1629,79 +1700,6 @@ exif_end:
 return size;
 }
 
-int init_canvas_frame(WebPContext *s, int format, int key_frame)
-{
-AVFrame *canvas = s->canvas_frame.f;
-int height;
-int ret;
-
-// canvas is needed only for animation
-if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION))
-return 0;
-
-// avoid init for non-key frames whose format and size did not change
-if (!key_frame &&
-canvas &&
-canvas->width  == s->canvas_width &&
-canvas->height == s->canvas_height)
-return 0;
-
-// canvas changes within IPPP sequences will lose thread sync
-// because of the ThreadFrame reallocation and will wait forever
-// so if frame-threading is used, forbid canvas changes and unlock
-// previous frames
-if (!key_frame && canvas) {
-if (s->avctx->thread_count > 1) {
-av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged. Use -threads 1 to try decoding with best effort.\n");
-// unlock previous frames that have sent an _await() call
-ff_progress_frame_report(&s->canvas_frame, INT_MAX);
-return AVERROR_PATCHWELCOME;
-} else {
-// warn for damaged frames
-av_log(s->avctx, AV_LOG_WARNING, "Canvas chang

[FFmpeg-devel] [PATCH v13 4/8] libavcodec/webp: add support for animated WebP

2024-06-21 Thread Thilo Borgmann via ffmpeg-devel
From: Josef Zlomek 

Fixes: 4907

Adds support for decoding of animated WebP.

The WebP decoder adds the animation related features according to the specs:
https://developers.google.com/speed/webp/docs/riff_container#animation
The frames of the animation may be smaller than the image canvas.
Therefore, the frame is decoded to a temporary frame,
then it is blended into the canvas, the canvas is copied to the output frame,
and finally the frame is disposed from the canvas.

The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported.
The background color is specified only as BGRA in the WebP file
so it is converted to YUVA if YUV formats are output.

Signed-off-by: Josef Zlomek 
---
 Changelog   |   1 +
 libavcodec/codec_desc.c |   3 +-
 libavcodec/webp.c   | 897 +---
 3 files changed, 840 insertions(+), 61 deletions(-)

diff --git a/Changelog b/Changelog
index 06c00e981a..de6eedfd68 100644
--- a/Changelog
+++ b/Changelog
@@ -101,6 +101,7 @@ version 6.1:
 - ffprobe XML output schema changed to account for multiple
   variable-fields elements within the same parent element
 - ffprobe -output_format option added as an alias of -of
+- animated WebP decoder
 
 
 version 6.0:
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index a28ef68061..ec1dcc327a 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1259,8 +1259,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "webp",
 .long_name = NULL_IF_CONFIG_SMALL("WebP"),
-.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
- AV_CODEC_PROP_LOSSLESS,
+.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
 .mime_types= MT("image/webp"),
 },
 {
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index c52b9732b4..146d5cb393 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -35,13 +35,17 @@
  * Exif metadata
  * ICC profile
  *
+ * @author Josef Zlomek, Pexeso Inc. 
+ * Animation
+ *
  * Unimplemented:
- *   - Animation
  *   - XMP metadata
  */
 
+#include "libavutil/common.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/mem.h"
+#include "libavutil/colorspace.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
@@ -50,6 +54,7 @@
 #include "decode.h"
 #include "exif.h"
 #include "get_bits.h"
+#include "progressframe.h"
 #include "thread.h"
 #include "tiff_common.h"
 #include "vp8.h"
@@ -68,6 +73,14 @@
 #define NUM_SHORT_DISTANCES 120
 #define MAX_HUFFMAN_CODE_LENGTH 15
 
+#define ANMF_DISPOSAL_METHOD0x01
+#define ANMF_DISPOSAL_METHOD_UNCHANGED  0x00
+#define ANMF_DISPOSAL_METHOD_BACKGROUND 0x01
+
+#define ANMF_BLENDING_METHOD0x02
+#define ANMF_BLENDING_METHOD_ALPHA  0x00
+#define ANMF_BLENDING_METHOD_OVERWRITE  0x02
+
 static const uint16_t alphabet_sizes[HUFFMAN_CODES_PER_META_CODE] = {
 NUM_LITERAL_CODES + NUM_LENGTH_CODES,
 NUM_LITERAL_CODES, NUM_LITERAL_CODES, NUM_LITERAL_CODES,
@@ -192,6 +205,8 @@ typedef struct ImageContext {
 typedef struct WebPContext {
 VP8Context v;   /* VP8 Context used for lossy decoding 
*/
 GetBitContext gb;   /* bitstream reader for main image 
chunk */
+ProgressFrame canvas_frame; /* ThreadFrame for canvas */
+AVFrame *frame; /* AVFrame for decoded frame */
 AVFrame *alpha_frame;   /* AVFrame for alpha data decompressed 
from VP8L */
 AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
 AVCodecContext *avctx;  /* parent AVCodecContext */
@@ -204,9 +219,25 @@ typedef struct WebPContext {
 int alpha_data_size;/* alpha chunk data size */
 int has_exif;   /* set after an EXIF chunk has been 
processed */
 int has_iccp;   /* set after an ICCP chunk has been 
processed */
+int duration;   /* frame duration in an animation */
 int width;  /* image width */
 int height; /* image height */
-int lossless;   /* indicates lossless or lossy */
+int vp8x_flags; /* global flags from VP8X chunk */
+int canvas_width;   /* canvas width */
+int canvas_height;  /* canvas height */
+int anmf_flags; /* frame flags from ANMF chunk */
+int pos_x;  /* frame position X */
+int pos_y;  /* frame position Y */
+int prev_anmf_flags;/* previous frame flags from ANMF 
chunk */
+int prev_width; /* previous frame width */
+int prev_height;/* previous frame height */
+int prev_pos_x; /* previous frame po

[FFmpeg-devel] [PATCH v13 1/8] avcodec/webp: remove unused definitions

2024-06-21 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

---
 libavcodec/webp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 7c2a5f0111..af4ebcec27 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -60,8 +60,6 @@
 #define VP8X_FLAG_ALPHA 0x10
 #define VP8X_FLAG_ICC   0x20
 
-#define MAX_PALETTE_SIZE256
-#define MAX_CACHE_BITS  11
 #define NUM_CODE_LENGTH_CODES   19
 #define HUFFMAN_CODES_PER_META_CODE 5
 #define NUM_LITERAL_CODES   256
-- 
2.39.3 (Apple Git-146)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v13 2/8] avcodec/webp: separate VP8 decoding

2024-06-21 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

---
 libavcodec/webp.c | 50 +--
 1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index af4ebcec27..c52b9732b4 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -195,6 +195,7 @@ typedef struct WebPContext {
 AVFrame *alpha_frame;   /* AVFrame for alpha data decompressed 
from VP8L */
 AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
 AVCodecContext *avctx;  /* parent AVCodecContext */
+AVCodecContext *avctx_vp8;  /* wrapper context for VP8 decoder */
 int initialized;/* set once the VP8 context is 
initialized */
 int has_alpha;  /* has a separate alpha chunk */
 enum AlphaCompression alpha_compression; /* compression type for alpha 
chunk */
@@ -1299,12 +1300,13 @@ static int vp8_lossy_decode_frame(AVCodecContext 
*avctx, AVFrame *p,
 int ret;
 
 if (!s->initialized) {
-ff_vp8_decode_init(avctx);
+VP8Context *s_vp8 = s->avctx_vp8->priv_data;
+s_vp8->actually_webp = 1;
 s->initialized = 1;
-s->v.actually_webp = 1;
 }
 avctx->pix_fmt = s->has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P;
 s->lossless = 0;
+s->avctx_vp8->pix_fmt = avctx->pix_fmt;
 
 if (data_size > INT_MAX) {
 av_log(avctx, AV_LOG_ERROR, "unsupported chunk size\n");
@@ -1315,14 +1317,32 @@ static int vp8_lossy_decode_frame(AVCodecContext 
*avctx, AVFrame *p,
 s->pkt->data = data_start;
 s->pkt->size = data_size;
 
-ret = ff_vp8_decode_frame(avctx, p, got_frame, s->pkt);
-if (ret < 0)
+ret = avcodec_send_packet(s->avctx_vp8, s->pkt);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for 
decoding\n");
 return ret;
+}
 
-if (!*got_frame)
+ret = avcodec_receive_frame(s->avctx_vp8, p);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "VP8 decoding error: %s.\n", 
av_err2str(ret));
 return AVERROR_INVALIDDATA;
+}
+
+ret = ff_decode_frame_props(avctx, p);
+if (ret < 0) {
+return ret;
+}
+
+if (!p->private_ref) {
+ret = ff_attach_decode_data(p);
+if (ret < 0) {
+return ret;
+}
+}
 
-update_canvas_size(avctx, avctx->width, avctx->height);
+*got_frame = 1;
+update_canvas_size(avctx, s->avctx_vp8->width, s->avctx_vp8->height);
 
 if (s->has_alpha) {
 ret = vp8_lossy_decode_alpha(avctx, p, s->alpha_data,
@@ -1539,11 +1559,28 @@ exif_end:
 static av_cold int webp_decode_init(AVCodecContext *avctx)
 {
 WebPContext *s = avctx->priv_data;
+int ret;
+const AVCodec *codec;
 
 s->pkt = av_packet_alloc();
 if (!s->pkt)
 return AVERROR(ENOMEM);
 
+
+/* Prepare everything needed for VP8 decoding */
+codec = avcodec_find_decoder(AV_CODEC_ID_VP8);
+if (!codec)
+return AVERROR_BUG;
+s->avctx_vp8 = avcodec_alloc_context3(codec);
+if (!s->avctx_vp8)
+return AVERROR(ENOMEM);
+s->avctx_vp8->flags = avctx->flags;
+s->avctx_vp8->flags2 = avctx->flags2;
+s->avctx_vp8->pix_fmt = avctx->pix_fmt;
+ret = avcodec_open2(s->avctx_vp8, codec, NULL);
+if (ret < 0) {
+return ret;
+}
 return 0;
 }
 
@@ -1552,6 +1589,7 @@ static av_cold int webp_decode_close(AVCodecContext 
*avctx)
 WebPContext *s = avctx->priv_data;
 
 av_packet_free(&s->pkt);
+avcodec_free_context(&s->avctx_vp8);
 
 if (s->initialized)
 return ff_vp8_decode_free(avctx);
-- 
2.39.3 (Apple Git-146)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v13 0/8] [WIP] webp: add support for animated WebP decoding

2024-06-21 Thread Thilo Borgmann via ffmpeg-devel
Marked WIP because we'd want to introduce private bsf's first; review
welcome before that though

v13
Switched to new ProgressFrame API
Support for pixel format changes in animations
Propagate MIN_DELAY in case of invalid delay in animations
Added more tests for animations with pixel format changes

v12
VP8 decoder decoupled again
The whole animated sequence goes into one packet
The (currently public) bitstream filter splits animations up into 
non-conformant packets
Now with XMP metadata support (as string, like MOV)


Patch 5/8 is still there for making changes in lavc/webp reviewable but shall 
be stashed when pushing.

-Thilo

Josef Zlomek (2):
  libavcodec/webp: add support for animated WebP
  libavformat/webp: add WebP demuxer

Thilo Borgmann via ffmpeg-devel (6):
  avcodec/webp: remove unused definitions
  avcodec/webp: separate VP8 decoding
  avcodec/bsf: Add awebp2webp bitstream filter
  avcodec/webp: make init_canvas_frame static
  fate: add test for animated WebP
  avcodec/webp: export XMP metadata

 Changelog |   2 +
 configure |   1 +
 doc/demuxers.texi |  28 +
 libavcodec/bitstream_filters.c|   1 +
 libavcodec/bsf/Makefile   |   1 +
 libavcodec/bsf/awebp2webp.c   | 353 +++
 libavcodec/codec_desc.c   |   3 +-
 libavcodec/webp.c | 983 --
 libavformat/Makefile  |   1 +
 libavformat/allformats.c  |   1 +
 libavformat/webpdec.c | 384 +++
 tests/fate/image.mak  |   9 +
 tests/ref/fate/exif-image-webp|   4 +-
 tests/ref/fate/webp-anim  |  22 +
 tests/ref/fate/webp-chfmt1|  23 +
 tests/ref/fate/webp-chfmt2| 106 ++
 tests/ref/fate/webp-rgb-lena-lossless |   2 +-
 tests/ref/fate/webp-rgb-lena-lossless-rgb24   |   2 +-
 tests/ref/fate/webp-rgb-lossless  |   2 +-
 .../fate/webp-rgb-lossless-palette-predictor  |   2 +-
 tests/ref/fate/webp-rgb-lossy-q80 |   2 +-
 tests/ref/fate/webp-rgba-lossless |   2 +-
 tests/ref/fate/webp-rgba-lossy-q80|   2 +-
 23 files changed, 1855 insertions(+), 81 deletions(-)
 create mode 100644 libavcodec/bsf/awebp2webp.c
 create mode 100644 libavformat/webpdec.c
 create mode 100644 tests/ref/fate/webp-anim
 create mode 100644 tests/ref/fate/webp-chfmt1
 create mode 100644 tests/ref/fate/webp-chfmt2

-- 
2.39.3 (Apple Git-146)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2] avdevice/avfoundation: add external video devices

2024-06-18 Thread Thilo Borgmann via ffmpeg-devel

Am 09.06.24 um 21:51 schrieb Theo Fabi:

Video devices categorized by AVFoundation as
'AVCaptureDeviceTypeExternal(Unknown)' (like USB video streams) were not
recognized by libavdevice.

Signed-off-by: Theo Fabi 
---
  libavdevice/avfoundation.m | 3 +++
  1 file changed, 3 insertions(+)


Ok. Will push soon.

Thanks,
Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] New CC member: Steven Liu

2024-06-05 Thread Thilo Borgmann via ffmpeg-devel

Hi,

On 05.06.24 09:34, Marton Balint wrote:



On Tue, 4 Jun 2024, Ronald S. Bultje wrote:


Hi all,

Anton resigned from the CC [1], leaving an empty spot. The remaining
members of the CC agreed it would be best to fill the spot with the next
runner-up from the last CC Elections.
The last CC election results [2] had
Steven Liu as next runner-up, so we've asked him to fill Anton's spot for
the remainder of our term, and he accepted. Thanks & welcome, Steven!


I don't have a problem with this in practice, but the legitimacy of such 
an appointment is not rock solid. The CC itself probably should not 
decide on CC membership, as that comes from the GA.


Agreed. Though we see this the first time and the discussion some time 
ago did not raise much participation / interest.



Maybe we should always choose a spare member (as in the 6th winner), who 
can automatically jump in. And if more than 1 person resign, a new 
election can be held.


Sounds as a good possibility to me. We should determine our procedure of 
choice and put it into the docs.


-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [RFC] STF 2025

2024-06-02 Thread Thilo Borgmann via ffmpeg-devel

Am 02.06.24 um 22:14 schrieb Tomas Härdin:

sön 2024-06-02 klockan 20:01 +0200 skrev Michael Niedermayer:

Hi


On Sat, Jun 01, 2024 at 05:19:26PM +0200, Tomas Härdin wrote:

[...]


* Fund professional real live presence on multimedia / FOSS /
buisness related
   events.


Also reasonable. I could help man a booth at IBC or any other event
in
Europe


Iam strongly in favor of that! Though i have no idea about cost (for
IBC)
which probably requires someone to sponsor a booth if its not free.
Or any details. But i think its probably best if you mail thilo as he
was helping with FFmpeg presence on many european booths


Attending is free, so I expect booths cost quite a bit to make up the
costs. There's an inquiry form on the IBC website. Can't hurt to ask

Hotels aren't cheap as Rémi points out. Last time I attended IBC we had
to get a hotel in Harlem. Luckily I know some people in Amsterdam


We have a booth on IBC this year which again gets sponsored so no costs for 
FFmpeg.
Some details are still unclear which is why it's not yet announced.

@Thomas: Happy you want to attend, I'll keep you updated.

-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [RFC] STF 2025

2024-05-24 Thread Thilo Borgmann via ffmpeg-devel




On 24.05.24 11:56, Andrew Sayers wrote:

On Fri, May 17, 2024 at 03:49:58PM +0200, Michael Niedermayer wrote:

Hi all

Before this is forgotten again, better start some dicsussion too early than too 
late


This comment is inspired by the other subthread, but not directly in reply to 
it.
I'm replying to this post rather than get in the middle of all that...


Thanks :)



What happens if someone is hired to do a job that requires access to the ML,
then gets involved in a situation where there's talk of a ban?

If they're banned, does that translate to suspension without pay?  With pay?

Banning such a person would jeopardise future funding - if they aren't banned,
will people be concerned about the apparent conflict of interest?


Interesting and something we should think about.
I think the project's well-being should be the priority - meaning if we 
vote for a ban of someone that was trusted enough to get a contact from 
us in the first place, the ban should be executed - or any other measure 
the CC or GA sees fit. Giving a work contact to someone shall not make 
us dependent on that person to such an extent.




In a wider sense, hiring a single person to do a job we come to rely on (like
code review) gives the project a bus number of 1.  How would the STF react to
a proposal like "we plan to do XYZ in 2025, but if we don't get funding for
2026, we'll drop Z and spend the time on a transition plan instead"?


Speaking as an idealist, we should uphold our procedures independently 
of what another entity (except the applicable law) thinks about our 
decisions.


Realisticly speaking, we already got some feedback from STF about such 
potential break aways on our end. Though these are of course never good 
in any such business relation, these things do happen. So up to a 
certain extend, it won't remove us from the program. Problems arise if 
such things are getting frequent.


We also got another layer of protection vie the SPI linked in between.
If we sanction someone severely who is in current posession of a 
contract to do some FFmpeg work, we might stop funding that and give 
another contract to someone who can take over.


Not saying that this could work with any kind of work but can be an option.

That brings me to the idea that we need to check the contracts for 
potential fail-safe clauses for such extreme cases like these.


Thanks,
Thnilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [RFC] STF 2025

2024-05-24 Thread Thilo Borgmann via ffmpeg-devel

Am 22.05.24 um 14:27 schrieb Rémi Denis-Courmont:



Le 22 mai 2024 00:34:03 GMT+03:00, Thilo Borgmann via ffmpeg-devel 
 a écrit :

I hope you realize what you argue in favor of.


Yes. It's quoted above.

Are you claiming that *no* review is better than *some* review done in
*public* for all to see by a paid professional just because the person is
maybe biased?

First, even volunteers have their own biases. Any expert should have opinions
from their experience, and that by definition makes them "biased".

And second, you can't have it both ways. Either we want people to be paid for
review, and they will be answerable to their sponsor, or we want people to
continue to work on their free time.


I think that is what you don't understand.


You're not answering the question here. The current STF funding of 153k€ for 2 
years is roughly enough to pay for ONE full-time entry-level software engineer 
in Germany. Even if this were doubled with another similar round of funding 
next year, and even if that was to be reliably renewed year on year, and 
assuming that STF keeps an hands-off approach of not influencing the work, that 
will *not* be enough to pay all reviewers.

So is it better to have no reviews or reviews by skilled corporate employees?


Your one question above was: "Are you claiming that [...] because the person is 
maybe biased?"
And I answered about the biasing problem.




And "I hope you realise that you are arguing for" Intel, Loongson, etc.
employees to stop reviewing patches.


Syntax error. What exactly do you mean?


I fail to see a syntax error. You're saying that corporate employees should not review because 
"they [will] want to get [their]" or their colleagues' "stuff in" (your words).

Intel and Loongson are obvious current examples of companies whose employees are pushing and 
reviewing enablement patches for their commercial hardware. That is very definitely not 
"unbiased" nor "independent".


Unfortunately true, yet you argue to pay more companies to do reviews instead 
having reviews funded by unbiased means.



According to my assumptions: No, I value reviews of company employees in 
general which have been proven to be useful and unbiased e.g. in getting part 
of the community reviewing 'stuf' but not their 'own stuff'.


I never said that I wanted biased reviews. I said some reviews were better than 
none, in spite of the risk of bias.

So much for your grandstanding against my alleged not realising what I am 
advocating for, if you end up agreeing with me...


I think we don't agree. You would want to pay some comapny/companies to do 
review work while I'd want reviewers to be paid directly without a middle man 
and corporate bias.

-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [RFC] STF 2025

2024-05-21 Thread Thilo Borgmann via ffmpeg-devel



On 21.05.24 21:43, Rémi Denis-Courmont wrote:

Le tiistaina 21. toukokuuta 2024, 22.42.00 EEST Rémi Denis-Courmont a écrit :

And "I hope you realise that you are arguing for" Intel, Loongson, etc.
employees to stop reviewing patches.


P.S.: And FFlabs too, since it is a for-profit company.


Same remark as in the previous mail. I'm not sure how you mean that 
whole thing. Please elaborate / put in other words.


-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [RFC] STF 2025

2024-05-21 Thread Thilo Borgmann via ffmpeg-devel



On 21.05.24 21:42, Rémi Denis-Courmont wrote:

Le tiistaina 21. toukokuuta 2024, 21.43.44 EEST Thilo Borgmann via ffmpeg-devel
a écrit :

Same as above about that we should and STF would.
Especially since no corporate interest usually pays anyone for these
tasks


Sadly true, but...


(in case of reviews it might of course be considered a good thing).


I think some review is better than none. There may be conflict of
interests, but they are weighed by the risk of being caught abusing the
review process.

I hope you realize what you argue in favor of.


Yes. It's quoted above.

Are you claiming that *no* review is better than *some* review done in
*public* for all to see by a paid professional just because the person is
maybe biased?

First, even volunteers have their own biases. Any expert should have opinions
from their experience, and that by definition makes them "biased".

And second, you can't have it both ways. Either we want people to be paid for
review, and they will be answerable to their sponsor, or we want people to
continue to work on their free time.


I think that is what you don't understand.
An STF sponsorship for review would not introduce any bias in favor or 
against some patch or sth related.
A company sponsorship would as it would introduce a bias towards 'we 
want our stuff in'.

STF has no stuff they want to be reviewed on their behalf.
They are only in favor of stuff being reviewed.



STF is an agency of the German government, applying German government
policies. They certainly do seem to have their own biases, including on tech,
e.g.: https://www.theregister.com/2024/05/20/huawei_germany_ban/ to take just
the most recent example to come to mind.


No. Does not apply to any funding we might get.



Reviews need to be unbiased and independent.


Ideally so but that's the land of utopia.


Of course, we talk about what should be, don't we?



STF sponsoring reviews could be an excellent help towards this.


If STF is willing to sponsor reviews, that's welcome. But that would certainly
not be "independent".


It would. As STF would not send patches we'd be obliged to review.
They'd give us money just for the sake of review 'whatever comes our way'.



Corporate influence on the review process already happened in the past
and the chance of getting caught is almost zero.


So how do you that it happened if it does not get caught?


I assume you mean how I know that and the guilty ones did not get 
caught? Well they did. An answer in public I will give not.




And "I hope you realise that you are arguing for" Intel, Loongson, etc.
employees to stop reviewing patches.


Syntax error. What exactly do you mean?
According to my assumptions: No, I value reviews of company employees 
in general which have been proven to be useful and unbiased e.g. in 
getting part of the community reviewing 'stuf' but not their 'own stuff'.


-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [RFC] STF 2025

2024-05-21 Thread Thilo Borgmann via ffmpeg-devel



On 20.05.24 20:51, Rémi Denis-Courmont wrote:

Le sunnuntaina 19. toukokuuta 2024, 14.29.43 EEST Thilo Borgmann via ffmpeg-
devel a écrit :

[...]


* Fund administrative / maintainance work (one example is the mailman
upgrade that is needed>>
   with the next OS upgrade on one of our servers (this is not as trivial
   as one might expect). Another example here may be some git related
   tools if we find something that theres a broad consensus about.


I agree that this should be paid but I would expect that STF would not be
too keen on it, not that I'd know really.

We should absolutely pay for such activity and STF is very well willing
to fund such things.


Again, I don't know but that seems to stray from their stated goals. Also this
is most certainly not a full-time job, and it requires a very high level of
trust. In practice, what this really means is paying Michael.

It is more of a question whether STF is willing to pay for this, and whether a
reasonable task description with a reasonable average prorated workload and a
pay can be defined.


Again, I do know. "...STF is very well willing to fund such things." 
does not sound like an assumption to me.




And again, it is completely reasonable to be paid for that, and also for
code reviews and writing test cases (if we want to complete the menial
task list), but I am perplexed as to STF's stance on that.



Same as above about that we should and STF would.
Especially since no corporate interest usually pays anyone for these tasks


Sadly true, but...


(in case of reviews it might of course be considered a good thing).


I think some review is better than none. There may be conflict of interests,
but they are weighed by the risk of being caught abusing the review process.


I hope you realize what you argue in favor of. Reviews need to be 
unbiased and independent. STF sponsoring reviews could be an excellent 
help towards this.


Corporate influence on the review process already happened in the past 
and the chance of getting caught is almost zero.


About the rest, I think you already said that you don't find funding 
non-full-time positions useful in another thread - no need to reiterate 
that I don't agree with that nor with your assumptions that should lead 
to that.


-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v12 0/8] [WIP] webp: add support for animated WebP decoding

2024-05-21 Thread Thilo Borgmann via ffmpeg-devel

Hi,

[...]

Tests mostly work for me. There are a few images (that I reported
earlier) that give:


thanks for testing!



Canvas change detected. The output will be damaged. Use -threads 1
to try decoding with best effort.
They don't animate without that option and with it render incorrectly.


That issue yields from the canvas frame being the synchronization object
(ThreadFrame) - doing so prevents the canvas size changed mid-stream.
_Maybe_ this can be fixed switching the whole frame multithreading away
from ThreadFrame to sth else, not sure though and no experience with the
alternatives (AVExecutor?). Maybe Andreas can predict if it's
worth/valid to change that whole part of it? I'm not against putting
more effort into it to get it right.


I could fix 488x488.webp and have an almost identical output to libwebp.

488x488.webp features an ARGB canvas and has both, ARGB & YUVA420P 
p-frames.


Do you have more files with other variations of canvas & p-frames? If 
they at all exist... e.g. canvas YUV and p-frames RGB?


Pinged Meta as well for real-world samples. Will take some more days 
until I get feedback. Will then post the next iteration...


Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] Samples with invalid permissions

2024-05-20 Thread Thilo Borgmann via ffmpeg-devel




Hi,

There are a couple of files in samples.ffmpeg.org with invalid 
permissions, rsync is not able to read those:



/V-codecs/UCOD/noextradata/CLV1_tony.mov
/V-codecs/UCOD/noextradata/freddie2.mov
/V-codecs/UCOD/noextradata/pittc.mov
/V-codecs/UCOD/noextradata/smilla_cv.mov
/ffmpeg-bugs/trac/ticket4729/hap2_fuzz.mov
/ffmpeg-bugs/trac/ticket5406/crushed_1.snm
/ffmpeg-bugs/trac/ticket5407/512kbps.wv
/ffmpeg-bugs/trac/ticket5407/512kbps.wvc
/ffmpeg-bugs/trac/ticket5410/ela2.m4b
/ffmpeg-bugs/trac/ticket5410/intro_a.m4b
/ffmpeg-bugs/trac/ticket6102/error_reading_header_ticket_6102_first100.mp4 > 
/ffmpeg-bugs/trac/ticket6102/error_reading_header_ticket_6102_last100.mp4


the above are now free to read.



/ffmpeg-bugs/trac/ticket5925/non-work-spanned.zip
/ffmpeg-bugs/trac/ticket6400/tooshort.avi
/ffmpeg-bugs/trac/ticket6675/Cineform_Bottom_8_Pixel_Distort_1080_YUV.mov
/ffmpeg-bugs/trac/ticket6765/Canon-C200-Raw.CRM


These are in the size of GB's.
If someone really needs them, send us a mail according to
http://samples.ffmpeg.org/00-README

-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [RFC] STF 2025

2024-05-19 Thread Thilo Borgmann via ffmpeg-devel



[...]

* Fund administrative / maintainance work (one example is the mailman upgrade 
that is needed
  with the next OS upgrade on one of our servers (this is not as trivial as one 
might
  expect). Another example here may be some git related tools if we find 
something that
  theres a broad consensus about.


I agree that this should be paid but I would expect that STF would not be too 
keen on it, not that I'd know really.


We should absolutely pay for such activity and STF is very well willing 
to fund such things.




* Fund maintaince on the bug tracker, try to reproduce bugs, ask users to 
provide
  reproduceable cases, close bugs still unreproduceable, ...
  ATM we have over 2000 "new" bugs that are not even marked as open


This is a double-edged sword. If somebody gets paid to do that, then that is 
one more reason for others not to do it.

And again, it is completely reasonable to be paid for that, and also for code 
reviews and writing test cases (if we want to complete the menial task list), 
but I am perplexed as to STF's stance on that.


Same as above about that we should and STF would. Especially since no 
corporate interest usually pays anyone for these tasks (in case of 
reviews it might of course be considered a good thing).


The one problem to solve here AFAICT is we don't know exactly what 
quantity of bugs, reviewable code submissions and other maintenance work 
will come up in the next 12 months.
So it renders impossible to define in prior the workload, milestones and 
compensation per contributor interested as we did this year for 
well-defined tasks.


What we should consider IMO is defining the tasks (patch review, bug 
review & fix, FATE extensions, checkasm extensions, etc. as well such 
things for the administrative tasks from above) and defining a budget 
for these tasks.
Then, allow 'everyone interested' (aka git push access?) to claim a part 
of that budget every N-months, depending what the corresponding 
contributor actually did and can somehow be determined.


Regarding STF, this could visualize as one big milestone per task with a 
budget of X and this group of people working on it. How exactly the 
money distributes from there, depends on the actual work done afterwards.


However, there are many questions about the details for our side and 
probably on the STF side. We should however start with at least one of 
these tasks aiming for next year, trying to setup some process that 
would work for us and can then be aligned with what is possible with STF.




* Fund professional real live presence on multimedia / FOSS / buisness related
  events. we already refund individuals but i think we are lacking on the 
organizational
  side. We should also have on these events at least one person who can awnser 
developer/user
  questions and someone who can awnser buisness questions (on buisness related 
events).
  Also we need some eye catching things there, a big screen/projector that 
plays some
  real time filtered version from a camera. Or maybe have more people remotely 
be available
  from the FFmpeg team through real time streaming (as in, if someone wants to 
be on some event
  but cant physically go there, we could put a notebook on the table facing 
visitors showing
  something like a video chat. Also we need more cute girls on these events, 
everything i hear
  its 100% male geeks/hackers. Also a "24/7" realtime stream from any booth 
would be nice


This is not something that STF should pay for, AFAIU. This is something that 
professionals should pay out of their budget (or their employer's) for the 
business events, and SPI for cheap/community events, IMO.


I think we should fund all non-b2b appearances.
About b2b, I wouldn't like our donation based money to be spent. We had 
corporate sponsorship in the past not having to think about it and 
possibly will have that as well in the future. The companies are 
interested in seeing us there and some are willing to pay for that 
happening.
I think we could as well get dedicated STF money to cover such costs not 
being dependent on supportive companies and plan ahead better.


That is nothing that 'professionals' should pay out of their budget or 
should even be allowed to do as we talk about a presence for the 
open-source project, not some company's presence.


-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [RFC] STF 2025

2024-05-19 Thread Thilo Borgmann via ffmpeg-devel



On 17.05.24 16:43, Ronald S. Bultje wrote:

Hi,

On Fri, May 17, 2024 at 9:50 AM Michael Niedermayer 
wrote:


* Fund professional real live presence on multimedia / FOSS / buisness
related
   events. we already refund individuals but i think we are lacking on the
organizational
   side. We should also have on these events at least one person who can
awnser developer/user
   questions and someone who can awnser buisness questions (on buisness
related events).



Maybe not 100% the same thing, but ... As you say, there's several of us
(including me) that attend some of these events. In addition to sponsoring
more people to go, I'd be very excited to wear FFmpeg gear and at least
make the FFmpeg brand more visible. (Right now I wear videolan gear at most
events.) Make some nice-looking hoodies etc. that we'd like to wear and
find an efficient way to distribute them.


We have FFmpeg designs for T-Shirts and Hoodies.
From the last badge we ordered there are still plenty of T-Shirts.

I'd sent around a large badge vial mail all over the world some years 
ago and if there is enough demand I could do that again.


Also I could bring stuff to FOSDEM or other cons for distribution if I'd 
know the demand from developers.
We had occasionally some stuff with us to give away to users. However 
this is not very practical for anything where we'd need to hop into a 
plane for due to weight & space restrictions. Always having some swag to 
give away would produce costs for us.


-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] web: add a news entry about STF sponsorship

2024-05-16 Thread Thilo Borgmann via ffmpeg-devel



On 15.05.24 20:51, Thilo Borgmann via ffmpeg-devel wrote:



On 15.05.24 18:39, Rémi Denis-Courmont wrote:
Le tiistaina 14. toukokuuta 2024, 20.12.31 EEST Thilo Borgmann via 
ffmpeg-devel

a écrit :

---
This text including the link is also meant to be published via our socal
media.

  src/index | 8 
  1 file changed, 8 insertions(+)

diff --git a/src/index b/src/index
index d035ffa..83cc9bf 100644
--- a/src/index
+++ b/src/index
@@ -35,6 +35,14 @@
  News
    

+  May 13th, 2024, Sovereign Tech Fund
+  
+  The FFMPEG community is excited to announce that it has received
+  funding from the href="https://www.sovereigntechfund.de/";>Sovereign

Tech Fund
+  for the maintenance of the FFMPEG project. This funding
will help ensure that FFMPEG
+  continues bringing video efficiently and
securely to billions worldwide everyday.
+  


Lexical repeation is poor style, TBH:
"...funding from  Fund ... This funding..."



"The FFmpeg community is excited to announce that Germany's 
Sovereign Tech
Fund has become its first governmental sponsor. Their support will 
help

sustain the maintainance of the FFmpeg project, a critical open-source
software multimedia component essential to bringing audio and video to
billions around the world everyday."


I like it.

I'd want to post this text in an updated patch tomorrow morning, if 
there are no more remarks.


Pushed like that.

Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] web: add a news entry about STF sponsorship

2024-05-15 Thread Thilo Borgmann via ffmpeg-devel



On 15.05.24 18:39, Rémi Denis-Courmont wrote:

Le tiistaina 14. toukokuuta 2024, 20.12.31 EEST Thilo Borgmann via ffmpeg-devel
a écrit :

---
This text including the link is also meant to be published via our socal
media.

  src/index | 8 
  1 file changed, 8 insertions(+)

diff --git a/src/index b/src/index
index d035ffa..83cc9bf 100644
--- a/src/index
+++ b/src/index
@@ -35,6 +35,14 @@
  News


+  May 13th, 2024, Sovereign Tech Fund
+  
+  The FFMPEG community is excited to announce that it has received
+  funding from the https://www.sovereigntechfund.de/";>Sovereign
Tech Fund
+  for the maintenance of the FFMPEG project. This funding
will help ensure that FFMPEG
+  continues bringing video efficiently and
securely to billions worldwide everyday.
+  


Lexical repeation is poor style, TBH:
"...funding from  Fund ... This funding..."




"The FFmpeg community is excited to announce that Germany's Sovereign Tech
Fund has become its first governmental sponsor. Their support will help
sustain the maintainance of the FFmpeg project, a critical open-source
software multimedia component essential to bringing audio and video to
billions around the world everyday."


I like it.

I'd want to post this text in an updated patch tomorrow morning, if 
there are no more remarks.


Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] web: add a news entry about STF sponsorship

2024-05-14 Thread Thilo Borgmann via ffmpeg-devel

Am 14.05.24 um 19:14 schrieb J. Dekker:


Thilo Borgmann via ffmpeg-devel  writes:


---
This text including the link is also meant to be published via our socal media.

  src/index | 8 
  1 file changed, 8 insertions(+)

diff --git a/src/index b/src/index
index d035ffa..83cc9bf 100644
--- a/src/index
+++ b/src/index
@@ -35,6 +35,14 @@
  News

  
+  May 13th, 2024, Sovereign Tech Fund

+  
+  The FFMPEG community is excited to announce that it has received
+  funding from the https://www.sovereigntechfund.de/";>Sovereign Tech 
Fund
+  for the maintenance of the FFMPEG project. This funding will help ensure 
that FFMPEG
+  continues bringing video efficiently and securely to billions worldwide 
everyday.
+  
+
April 5th, 2024, FFmpeg 7.0 "Dijkstra"

A new major release, FFmpeg 7.0 
"Dijkstra",





Spelling of FFmpeg should be fixed, and needs a unique header id. Also
FFmpeg does more than 'bring video'.


Oh, missed the ID and spelling.
Propose something to extend 'bring video'.
 Thanks,
Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] web: add a news entry about STF sponsorship

2024-05-14 Thread Thilo Borgmann via ffmpeg-devel
---
This text including the link is also meant to be published via our socal media.

 src/index | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/index b/src/index
index d035ffa..83cc9bf 100644
--- a/src/index
+++ b/src/index
@@ -35,6 +35,14 @@
 News
   
 
+  May 13th, 2024, Sovereign Tech Fund
+  
+  The FFMPEG community is excited to announce that it has received
+  funding from the https://www.sovereigntechfund.de/";>Sovereign Tech 
Fund
+  for the maintenance of the FFMPEG project. This funding will help ensure 
that FFMPEG
+  continues bringing video efficiently and securely to billions worldwide 
everyday.
+  
+
   April 5th, 2024, FFmpeg 7.0 "Dijkstra"
   
   A new major release, FFmpeg 7.0 
"Dijkstra",
-- 
2.39.3 (Apple Git-146)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] GSoC 2024

2024-05-01 Thread Thilo Borgmann via ffmpeg-devel

Hi,


the application period for GSoC 2024 begins on Jan 22nd.

Everyone interested in mentoring a project in 2024, please add your idea(s) to 
[1].


we've been granted 7 slots this year!
All mentors received a mail already, work period begins May 27th.

There are pending patches from the students on the list, please help reviewing!

Thanks,
Thilo




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] FFmpeg table at NAB

2024-04-23 Thread Thilo Borgmann via ffmpeg-devel

Hi,


Thilo is calling Kieran, myself and presumably Derek and JB trolls.

This seems to be a pattern against anyone who disagrees with him.


please avoid top-posting on this list [1].

-Thilo

[1] https://ffmpeg.org/mailing-list-faq.html#What-is-top_002dposting_003f-1



Le 22 avril 2024 04:25:20 GMT+08:00, Thilo Borgmann via ffmpeg-devel 
 a écrit :

Hi,

On 21.04.24 10:47, Rémi Denis-Courmont wrote:

Hi,

I have been dragged privately into this issue so for the sake of transparency, 
I will just sum up my side here.


Le 17 avril 2024 07:21:18 GMT+08:00, Devin Heitmueller 
 a écrit :

Hello all,

I wasn't looking to start trouble, but I didn't see any discussion of
this on the mailing list so wanted to bring it to the developer
community's attention.

I attended the NAB conference and went by the "ffmpeg" booth on
Sunday.  What I found was a single table with the official ffmpeg
banner hanging right next to a banner for the GPAC project, and two
salespeople from GPAC handing out marketing literature and trying to
educate me on why I should use their framework for my next project.


Thilo did announce that some unidentified party would be payind for FFmpeg to 
hold a booth (this should be visible in the archives). Kieran raised legitimate 
if not concerning questions based on his prior experience at NAB.

I announced that "We reiceived an anonymous corporate sponsorship for the booth, so 
there are no costs for the FFmpeg project to it (and no obligations, of course)."

Kieran's reaction was raising concerns that he feels donors wouldn't want to 
see their SPI money spend on NAB [1][2] - ignoring that I'd just announced that 
there will be no donor's SPI money needed as there are no costs for FFmpeg.

Kieran's reaction further was claiming that no plan has been provided who will actually 
be present on the booth [1][2] - ignoring that I'd just announced that "Any FFmpeg 
developer is welcome to join in and man the booth with me".



Thilo did not answer, which is inexcusable, especially considering that there 
were several times that the questions were reiterated.

Ignoring what has been said, making statements raising the impression that 
something contradictory would be the truth is trolling me and deceiving the 
other readers. No reason at all to feed the trolls - no matter how often the 
trolling is repeated.



Thilo privately called Kieran a "troll" as the lame pretext for not answering 
the question (I can copy the CC privately if proof of this is needed).


And I just did publicly, for what I believe his reaction in the FFmpeg at NAB 2024 thread was and 
everyone can read to get their own impression in the archives. You think it's a lame pretext? The 
"questions" had been answered even before they were "raised" by Kieran.



In light of this, it seemed obvious that the FFmpeg booth would be a disaster, 
pretty much how Kieran had predicted.


In the light of... the costs being covered and me + any other volunteer manning 
the booth as announced or in the light of... the deceiving 'ignorance' in 
Kieran's statements?
_Even if_ the coverage of the complete funding and/or manning the booth would 
have been unanswered, how would that have 'obviusly' concluded the booth to 
become a disaster?
That conclusion itself appears not comprehensible.



So there you have it. On the bright side, FFmpeg was not footing the bill.


I fear FFmpeg has to pay quite a high bill for all the trolling bullshit going 
on about this NAB presence alone.



I think everybody can make their own conclusions without me speculating or 
opiniating further, so I will leave it at that.


I very much hope everyone is making up their own opinion.
Even you, who I think is not stupid, obviously was too easily made to takeover 
the 'payment is unclear', 'manning is unclear', 'will become a desaster' 
narrative here.



I'm not saying that GPAC shouldn't be able to have a table at the
conference, but it feels pretty misleading to have an "ffmpeg" booth
listed in the conference materials, with a table prominently
displaying the ffmpeg logo, with zero people from ffmpeg and people
pushing users to use an alternative framework that some might actually
considered to be a competitor to ffmpeg.


Agreed. Thanks for your testimony.

And here you are demonstrating again that it appears to be so much beloved 
behavior in our community to hop on the troll train and willingly ignore 
previous statement for the sake to troll on.
You love to ignore what I relied to Devin's mail where to the most important 
part, Devin's impression could be reasonably explained/voided to have been a 
wrong impression (misleading ffmpeg booth without any people from ffmpeg) that 
to my understanding after talking to him, doesn't bother him anymore.

You can think a

Re: [FFmpeg-devel] Fw: Your GSoC Org has 0 Contributors ranked - deadline is 1800 UTC April 24

2024-04-23 Thread Thilo Borgmann via ffmpeg-devel

Hi,


adding people who "want to mentor" to CC

thx

On Wed, Apr 24, 2024 at 01:50:31AM +0200, Michael Niedermayer wrote:

Hi all

I just got the mail below. I assume the other admins are going to rank them
before the deadline like they did last year. (but i can of course not assume
that because there is no time if that doesnt happen)
I have not followed GSoC last year or this year much ...

Either way, if you are a mentor and want your student to receive a slot
tell me privatly (with thilo and reynaldo in CC) ASAP how you would
rank your student. And i will rank him/her accordingly if i see noone
else starting to assign ranks


sorry for delay, just got home after NAB.
All proposals now ranked, all admins/mentors should be able to see that on the 
dashboard.

-Thilo




- Forwarded message from Stephanie Taylor  -

Date: Tue, 23 Apr 2024 15:55:36 -0700
From: Stephanie Taylor 
To: undisclosed-recipients: ;
Subject: Your GSoC Org has 0 Contributors ranked - deadline is 1800 UTC April 24

Hello GSoC Org Admin,


You are receiving this email because you are an Org Admin and your org
currently has 0 (zero) GSoC 2024 proposals ranked and thus have not
requested any GSoC contributors.

If your org would like to accept GSoC contributors this year, an Org Admin
must rank proposals before tomorrow, Wednesday April 24 at 1800 UTC.

Org Admins should verify they have Ranked all the proposals their Org
wishes to select for GSoC 2024 before the deadline this Wednesday, April 24
at 18:00 UTC. You must have proposals ranked with at least one assigned
mentor in order for Google Admins to consider your request. If your org
does not rank your requested proposals and assign mentors we will not be
able to grant you any GSoC 2024 contributors.

As of right now (2238 UTC), you have less than 20 hours to complete this
task. Please refer back to the email we sent you on Sunday, April 21st for
further instructions on this task or read that email in the GSoC 2024
Mentor and Org Admin email archive.
Not planning to accept any GSoC Contributors this year?

If your org does not plan to accept any GSoC Contributors for GSoC 2024
that is fine, please send a quick email to gsoc-supp...@google.com saying
as much so we know this was your intention and we won’t email you to ask
what happened.

Please contact us at gsoc-supp...@google.com with any questions.

Best,

Stephanie



Stephanie Taylor  |  Program Manager

Celebrating *20 years* of

*Google Summer of Code* in 2024!

g.co/gsoc  

- End forwarded message -

--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato





___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] FFmpeg table at NAB

2024-04-21 Thread Thilo Borgmann via ffmpeg-devel

Hi,

On 21.04.24 10:47, Rémi Denis-Courmont wrote:
> Hi,
>
> I have been dragged privately into this issue so for the sake of 
transparency, I will just sum up my side here.

>
>
> Le 17 avril 2024 07:21:18 GMT+08:00, Devin Heitmueller 
 a écrit :

>> Hello all,
>>
>> I wasn't looking to start trouble, but I didn't see any discussion of
>> this on the mailing list so wanted to bring it to the developer
>> community's attention.
>>
>> I attended the NAB conference and went by the "ffmpeg" booth on
>> Sunday.  What I found was a single table with the official ffmpeg
>> banner hanging right next to a banner for the GPAC project, and two
>> salespeople from GPAC handing out marketing literature and trying to
>> educate me on why I should use their framework for my next project.
>
> Thilo did announce that some unidentified party would be payind for 
FFmpeg to hold a booth (this should be visible in the archives). Kieran 
raised legitimate if not concerning questions based on his prior 
experience at NAB.
I announced that "We reiceived an anonymous corporate sponsorship for 
the booth, so there are no costs for the FFmpeg project to it (and no 
obligations, of course)."


Kieran's reaction was raising concerns that he feels donors wouldn't 
want to see their SPI money spend on NAB [1][2] - ignoring that I'd just 
announced that there will be no donor's SPI money needed as there are no 
costs for FFmpeg.


Kieran's reaction further was claiming that no plan has been provided 
who will actually be present on the booth [1][2] - ignoring that I'd 
just announced that "Any FFmpeg developer is welcome to join in and man 
the booth with me".



> Thilo did not answer, which is inexcusable, especially considering 
that there were several times that the questions were reiterated.
Ignoring what has been said, making statements raising the impression 
that something contradictory would be the truth is trolling me and 
deceiving the other readers. No reason at all to feed the trolls - no 
matter how often the trolling is repeated.



> Thilo privately called Kieran a "troll" as the lame pretext for not 
answering the question (I can copy the CC privately if proof of this is 
needed).


And I just did publicly, for what I believe his reaction in the FFmpeg 
at NAB 2024 thread was and everyone can read to get their own impression 
in the archives. You think it's a lame pretext? The "questions" had been 
answered even before they were "raised" by Kieran.



> In light of this, it seemed obvious that the FFmpeg booth would be a 
disaster, pretty much how Kieran had predicted.


In the light of... the costs being covered and me + any other volunteer 
manning the booth as announced or in the light of... the deceiving 
'ignorance' in Kieran's statements?
_Even if_ the coverage of the complete funding and/or manning the booth 
would have been unanswered, how would that have 'obviusly' concluded the 
booth to become a disaster?

That conclusion itself appears not comprehensible.


> So there you have it. On the bright side, FFmpeg was not footing the 
bill.


I fear FFmpeg has to pay quite a high bill for all the trolling bullshit 
going on about this NAB presence alone.



> I think everybody can make their own conclusions without me 
speculating or opiniating further, so I will leave it at that.


I very much hope everyone is making up their own opinion.
Even you, who I think is not stupid, obviously was too easily made to 
takeover the 'payment is unclear', 'manning is unclear', 'will become a 
desaster' narrative here.



>> I'm not saying that GPAC shouldn't be able to have a table at the
>> conference, but it feels pretty misleading to have an "ffmpeg" booth
>> listed in the conference materials, with a table prominently
>> displaying the ffmpeg logo, with zero people from ffmpeg and people
>> pushing users to use an alternative framework that some might actually
>> considered to be a competitor to ffmpeg.
>
> Agreed. Thanks for your testimony.
And here you are demonstrating again that it appears to be so much 
beloved behavior in our community to hop on the troll train and 
willingly ignore previous statement for the sake to troll on.
You love to ignore what I relied to Devin's mail where to the most 
important part, Devin's impression could be reasonably explained/voided 
to have been a wrong impression (misleading ffmpeg booth without any 
people from ffmpeg) that to my understanding after talking to him, 
doesn't bother him anymore.


You can think about GPAC what you want and if it is a good idea to share 
a booth with them.
My thoughts about it is that we should absorb them into FFmpeg instead 
of splitting resources and efforts. They know that and yet want to share 
a booth with us.
But since they are doing things like DRM we reject doing at FFmpeg, GPAC 
currently is a valid downstream project adding 'value' of some kind to 
their users beyond what FFmpeg can provide.
Not surprising, since we are a library and litera

Re: [FFmpeg-devel] [PATCH v12 0/8] [WIP] webp: add support for animated WebP decoding

2024-04-18 Thread Thilo Borgmann via ffmpeg-devel

Hi,

On 17.04.24 00:52, James Zern via ffmpeg-devel wrote:

On Wed, Apr 17, 2024 at 12:20 PM Thilo Borgmann via ffmpeg-devel
 wrote:


From: Thilo Borgmann 

Marked WIP because we'd want to introduce private bsf's first; review
welcome before that though
VP8 decoder decoupled again
The whole animated sequence goes into one packet
The (currently public) bitstream filter splits animations up into 
non-conformant packets
Now with XMP metadata support (as string, like MOV)



Tests mostly work for me. There are a few images (that I reported
earlier) that give:


thanks for testing!



   Canvas change detected. The output will be damaged. Use -threads 1
to try decoding with best effort.
They don't animate without that option and with it render incorrectly.


That issue yields from the canvas frame being the synchronization object 
(ThreadFrame) - doing so prevents the canvas size changed mid-stream. 
_Maybe_ this can be fixed switching the whole frame multithreading away 
from ThreadFrame to sth else, not sure though and no experience with the 
alternatives (AVExecutor?). Maybe Andreas can predict if it's 
worth/valid to change that whole part of it? I'm not against putting 
more effort into it to get it right.




A few other notes:
- should ffprobe report anything with files containing xmp?


It does, it is put into the frame metadata as a blob.
./ffprobe -show_frames 
will reveal it.



- 0 duration behaves differently than web browsers, which use the gif
behavior and set it to 10; as long as it's consistent in ffmpeg
between the two either is fine to me.


We are consistent to GIF in ffmpeg. Both do assume 100ms default delay.
Notice the defaults in their defines (ms for webp, fps for gif) in the 
demuxers:


#define WEBP_DEFAULT_DELAY   100
#define GIF_DEFAULT_DELAY   10




- The files in https://crbug.com/690848 don't exit cleanly from
ffplay, other corrupt files do; ffmpeg exits, so maybe it's a
non-issue.


ffplay always crashes after any file on osx for me. If ffmpeg terminates 
fine, it's a non-issue for that patchset. I'll however look into it once 
I can, I hear people saying their ffplay not always crashes...


Thanks!
-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] FFmpeg table at NAB

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel
Hi,

> Am 16.04.2024 um 16:21 schrieb Devin Heitmueller 
> :
> 
> Hello all,
> 
> I wasn't looking to start trouble, but I didn't see any discussion of
> this on the mailing list so wanted to bring it to the developer
> community's attention.
> 
> I attended the NAB conference and went by the "ffmpeg" booth on
> Sunday.  What I found was a single table with the official ffmpeg
> banner hanging right next to a banner for the GPAC project, and two
> salespeople from GPAC handing out marketing literature and trying to
> educate me on why I should use their framework for my next project.
> 
> I'm not saying that GPAC shouldn't be able to have a table at the
> conference, but it feels pretty misleading to have an "ffmpeg" booth
> listed in the conference materials, with a table prominently
> displaying the ffmpeg logo, with zero people from ffmpeg and people
> pushing users to use an alternative framework that some might actually
> considered to be a competitor to ffmpeg.

so I talked to the GPAC folks and Devin as well. The missing part of the 
information exchanged was apparently that there‘s nobody from FFmpeg here _at 
the moment_. 

Devin did circle around a bit for a while, never saw FFpeople in that time. 
Thing is that in the afternoons, Ramiro and me were out for lunch off-site, for 
around 90 minutes - plenty of time never to be seen by Devin. 

Additionally, not having followed the November announcement and subsequent 
posts too closely, lead to even more suspicion. 

So, Devin, as I told you earlier, thank you very much for your mail - in case 
that would have actually been some sort of misuse of our name, we’d totally 
want to 
become aware of. 

Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v12 3/8] avcodec/bsf: Add awebp2webp bitstream filter

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel

On 17.04.24 21:19, Thilo Borgmann via ffmpeg-devel wrote:

From: Thilo Borgmann via ffmpeg-devel 

Splits a packet containing a webp animations into
one non-compliant packet per frame of the animation.
Skips RIFF and WEBP chunks for those packets except
for the first. Copyies ICC, EXIF and XMP chunks first
into each of the packets except for the first.
---
  configure  |   1 +
  libavcodec/bitstream_filters.c |   1 +
  libavcodec/bsf/Makefile|   1 +
  libavcodec/bsf/awebp2webp.c| 350 +
  4 files changed, 353 insertions(+)
  create mode 100644 libavcodec/bsf/awebp2webp.c


build failed here. Updated patch attached.

Sorry,
ThiloFrom 536dfc772ac273b0d3607545b8aea7a26ba84ac1 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann via ffmpeg-devel 
Date: Thu, 28 Mar 2024 15:08:53 +0100
Subject: [PATCH v12 3/8] avcodec/bsf: Add awebp2webp bitstream filter

Splits a packet containing a webp animations into
one non-compliant packet per frame of the animation.
Skips RIFF and WEBP chunks for those packets except
for the first. Copyies ICC, EXIF and XMP chunks first
into each of the packets except for the first.
---
 configure  |   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/bsf/Makefile|   1 +
 libavcodec/bsf/awebp2webp.c| 351 +
 4 files changed, 354 insertions(+)
 create mode 100644 libavcodec/bsf/awebp2webp.c

diff --git a/configure b/configure
index 55f1fc354d..2d08bc1fd8 100755
--- a/configure
+++ b/configure
@@ -3425,6 +3425,7 @@ aac_adtstoasc_bsf_select="adts_header mpeg4audio"
 av1_frame_merge_bsf_select="cbs_av1"
 av1_frame_split_bsf_select="cbs_av1"
 av1_metadata_bsf_select="cbs_av1"
+awebp2webp_bsf_select=""
 dts2pts_bsf_select="cbs_h264 h264parse"
 eac3_core_bsf_select="ac3_parser"
 evc_frame_merge_bsf_select="evcparse"
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 12860c332b..af88283a8c 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -28,6 +28,7 @@ extern const FFBitStreamFilter ff_aac_adtstoasc_bsf;
 extern const FFBitStreamFilter ff_av1_frame_merge_bsf;
 extern const FFBitStreamFilter ff_av1_frame_split_bsf;
 extern const FFBitStreamFilter ff_av1_metadata_bsf;
+extern const FFBitStreamFilter ff_awebp2webp_bsf;
 extern const FFBitStreamFilter ff_chomp_bsf;
 extern const FFBitStreamFilter ff_dump_extradata_bsf;
 extern const FFBitStreamFilter ff_dca_core_bsf;
diff --git a/libavcodec/bsf/Makefile b/libavcodec/bsf/Makefile
index fb70ad0c21..48c67dd210 100644
--- a/libavcodec/bsf/Makefile
+++ b/libavcodec/bsf/Makefile
@@ -5,6 +5,7 @@ OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += bsf/aac_adtstoasc.o
 OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= bsf/av1_frame_merge.o
 OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= bsf/av1_frame_split.o
 OBJS-$(CONFIG_AV1_METADATA_BSF)   += bsf/av1_metadata.o
+OBJS-$(CONFIG_AWEBP2WEBP_BSF) += bsf/awebp2webp.o
 OBJS-$(CONFIG_CHOMP_BSF)  += bsf/chomp.o
 OBJS-$(CONFIG_DCA_CORE_BSF)   += bsf/dca_core.o
 OBJS-$(CONFIG_DTS2PTS_BSF)+= bsf/dts2pts.o
diff --git a/libavcodec/bsf/awebp2webp.c b/libavcodec/bsf/awebp2webp.c
new file mode 100644
index 00..7edacee48f
--- /dev/null
+++ b/libavcodec/bsf/awebp2webp.c
@@ -0,0 +1,351 @@
+/*
+ * Animated WebP into non-compliant WebP bitstream filter
+ * Copyright (c) 2024 Thilo Borgmann 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Animated WebP into non-compliant WebP bitstream filter
+ * Splits a packet containing a webp animations into
+ * one non-compliant packet per frame of the animation.
+ * Skips RIFF and WEBP chunks for those packets except
+ * for the first. Copyies ICC, EXIF and XMP chunks first
+ * into each of the packets except for the first.
+ * @author Thilo Borgmann 
+ */
+
+#include 
+#include 
+
+#include "codec_id.h"
+#include "bytestream.h"
+#include "libavutil/error.h"
+#include "libavutil/mem.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "packet.h"

Re: [FFmpeg-devel] [PATCH v11 4/8] libavcodec/webp: add support for animated WebP

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel



On 17.04.24 19:30, James Zern via ffmpeg-devel wrote:

On Thu, Mar 28, 2024 at 7:10 AM Thilo Borgmann via ffmpeg-devel
 wrote:


From: Josef Zlomek 

Fixes: 4907

Adds support for decoding of animated WebP.

The WebP decoder adds the animation related features according to the specs:
https://developers.google.com/speed/webp/docs/riff_container#animation
The frames of the animation may be smaller than the image canvas.
Therefore, the frame is decoded to a temporary frame,
then it is blended into the canvas, the canvas is copied to the output frame,
and finally the frame is disposed from the canvas.

The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported.
The background color is specified only as BGRA in the WebP file
so it is converted to YUVA if YUV formats are output.

Signed-off-by: Josef Zlomek 
---
  Changelog   |   1 +
  libavcodec/codec_desc.c |   3 +-
  libavcodec/version.h|   2 +-
  libavcodec/webp.c   | 710 
  4 files changed, 653 insertions(+), 63 deletions(-)



I'm late trying to test these. I think these need to be rebased.
version.h is easy enough to skip. I didn't look at the conflict in
webp.c.

error: patch failed: libavcodec/version.h:30
error: libavcodec/version.h: patch does not apply
error: patch failed: libavcodec/webp.c:35
error: libavcodec/webp.c: patch does not apply
Patch failed at 0004 libavcodec/webp: add support for animated WebP


just posted v12 which applies to master again, also tagged it WIP.

Thanks for having a look,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v12 8/8] avcodec/webp: export XMP metadata

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

---
 libavcodec/webp.c | 42 --
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 4a244c1b67..35851ef3da 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -38,8 +38,8 @@
  * @author Josef Zlomek, Pexeso Inc. 
  * Animation
  *
- * Unimplemented:
- *   - XMP metadata
+ * @author Thilo Borgmann 
+ * XMP metadata
  */
 
 #include "libavutil/imgutils.h"
@@ -217,6 +217,7 @@ typedef struct WebPContext {
 int alpha_data_size;/* alpha chunk data size */
 int has_exif;   /* set after an EXIF chunk has been 
processed */
 int has_iccp;   /* set after an ICCP chunk has been 
processed */
+int has_xmp;/* set after an XMP chunk has been 
processed */
 int width;  /* image width */
 int height; /* image height */
 int vp8x_flags; /* global flags from VP8X chunk */
@@ -1464,6 +1465,7 @@ static int webp_decode_frame_common(AVCodecContext 
*avctx, uint8_t *data, int si
 // reset metadata bit for each packet
 s->has_exif  = 0;
 s->has_iccp  = 0;
+s->has_xmp   = 0;
 
 while (bytestream2_get_bytes_left(&gb) > 8) {
 char chunk_str[5] = { 0 };
@@ -1495,6 +1497,7 @@ static int webp_decode_frame_common(AVCodecContext 
*avctx, uint8_t *data, int si
 s->canvas_height = 0;
 s->has_exif  = 0;
 s->has_iccp  = 0;
+s->has_xmp   = 0;
 ff_thread_release_ext_buffer(&s->canvas_frame);
 break;
 case MKTAG('V', 'P', '8', ' '):
@@ -1680,12 +1683,39 @@ exif_end:
 }
 s->vp8x_flags |= VP8X_FLAG_ANIMATION;
 break;
-case MKTAG('X', 'M', 'P', ' '):
-AV_WL32(chunk_str, chunk_type);
-av_log(avctx, AV_LOG_WARNING, "skipping unsupported chunk: %s\n",
-   chunk_str);
+case MKTAG('X', 'M', 'P', ' '): {
+GetByteContext xmp_gb;
+AVDictionary **xmp_metadata = NULL;
+uint8_t *buffer;
+int xmp_offset = bytestream2_tell(&gb);
+
+if (s->has_xmp) {
+av_log(avctx, AV_LOG_VERBOSE, "Ignoring extra XMP chunk\n");
+goto xmp_end;
+}
+if (!(s->vp8x_flags & VP8X_FLAG_XMP_METADATA))
+av_log(avctx, AV_LOG_WARNING,
+   "XMP chunk present, but XMP bit not set in the "
+   "VP8X header\n");
+
+// there are at least chunk_size bytes left to read
+buffer = av_malloc(chunk_size + 1);
+if (!buffer) {
+return AVERROR(ENOMEM);
+}
+
+s->has_xmp = 1;
+bytestream2_init(&xmp_gb, data + xmp_offset, size - xmp_offset);
+bytestream2_get_buffer(&xmp_gb, buffer, chunk_size);
+buffer[chunk_size] = '\0';
+
+xmp_metadata = (s->vp8x_flags & VP8X_FLAG_ANIMATION) ? 
&p->metadata : &s->frame->metadata;
+av_dict_set(xmp_metadata, "xmp", buffer, AV_DICT_DONT_STRDUP_VAL);
+
+xmp_end:
 bytestream2_skip(&gb, chunk_size);
 break;
+}
 default:
 AV_WL32(chunk_str, chunk_type);
 av_log(avctx, AV_LOG_VERBOSE, "skipping unknown chunk: %s\n",
-- 
2.43.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v12 7/8] fate: add test for animated WebP

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

---
 tests/fate/image.mak |  3 +++
 tests/ref/fate/webp-anim | 22 ++
 2 files changed, 25 insertions(+)
 create mode 100644 tests/ref/fate/webp-anim

diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 753936ec20..b6a4cd2ba3 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -566,6 +566,9 @@ fate-webp-rgb-lossy-q80: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/rgb_q80.webp
 FATE_WEBP += fate-webp-rgba-lossy-q80
 fate-webp-rgba-lossy-q80: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/rgba_q80.webp
 
+FATE_WEBP += fate-webp-anim
+fate-webp-anim: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/130227-100431-6817p.webp
+
 FATE_WEBP-$(call DEMDEC, IMAGE2, WEBP) += $(FATE_WEBP)
 FATE_IMAGE_FRAMECRC += $(FATE_WEBP-yes)
 fate-webp: $(FATE_WEBP-yes)
diff --git a/tests/ref/fate/webp-anim b/tests/ref/fate/webp-anim
new file mode 100644
index 00..f0d3f1a88f
--- /dev/null
+++ b/tests/ref/fate/webp-anim
@@ -0,0 +1,22 @@
+#tb 0: 1/1000
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 100x70
+#sar 0: 0/1
+0,  0,  0,   80,28000, 0x2023ba6e
+0, 80, 80,   80,28000, 0x4292b778
+0,160,160,   80,28000, 0x1c972ef1
+0,240,240,   80,28000, 0xa98d8d04
+0,320,320,   80,28000, 0xd323b6af
+0,400,400,   80,28000, 0x508aba99
+0,480,480,   80,28000, 0x5c672dda
+0,560,560,   80,28000, 0xc8961ebb
+0,640,640, 1000,28000, 0x82460e1b
+0,   1640,   1640,   80,28000, 0x3debbfc9
+0,   1720,   1720,   80,28000, 0x427ab31f
+0,   1800,   1800,   80,28000, 0x6bbdec2e
+0,   1880,   1880,   80,28000, 0x5690b56b
+0,   1960,   1960,   80,28000, 0xb62963f3
+0,   2040,   2040,   80,28000, 0x68dd37b2
+0,   2120,   2120,   80,28000, 0x465c47d2
+0,   2200,   2200,1,28000, 0xa92033df
-- 
2.43.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v12 6/8] libavformat/webp: add WebP demuxer

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel
From: Josef Zlomek 

Adds the demuxer of animated WebP files.
It supports non-animated, animated, truncated, and concatenated files.
Reading from a pipe (and other non-seekable inputs) is also supported.

The WebP demuxer splits the input stream into packets containing one frame.
It also marks the key frames properly.
The loop count is ignored by default (same behaviour as animated PNG and GIF),
it may be enabled by the option '-ignore_loop 0'.

The frame rate is set according to the frame delay in the ANMF chunk.
If the delay is too low, or the image is not animated, the default frame rate
is set to 10 fps, similarly to other WebP libraries and browsers.
The fate suite was updated accordingly.

Signed-off-by: Josef Zlomek 
---
 Changelog |   1 +
 doc/demuxers.texi |  28 ++
 libavformat/Makefile  |   1 +
 libavformat/allformats.c  |   1 +
 libavformat/version.h |   2 +-
 libavformat/webpdec.c | 383 ++
 tests/ref/fate/exif-image-webp|   4 +-
 tests/ref/fate/webp-rgb-lena-lossless |   2 +-
 tests/ref/fate/webp-rgb-lena-lossless-rgb24   |   2 +-
 tests/ref/fate/webp-rgb-lossless  |   2 +-
 .../fate/webp-rgb-lossless-palette-predictor  |   2 +-
 tests/ref/fate/webp-rgb-lossy-q80 |   2 +-
 tests/ref/fate/webp-rgba-lossless |   2 +-
 tests/ref/fate/webp-rgba-lossy-q80|   2 +-
 14 files changed, 424 insertions(+), 10 deletions(-)
 create mode 100644 libavformat/webpdec.c

diff --git a/Changelog b/Changelog
index 03ac047cea..698182aca3 100644
--- a/Changelog
+++ b/Changelog
@@ -94,6 +94,7 @@ version 6.1:
   variable-fields elements within the same parent element
 - ffprobe -output_format option added as an alias of -of
 - animated WebP decoder
+- animated WebP demuxer
 
 
 version 6.0:
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 04293c4813..9c9d0fee17 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -1158,4 +1158,32 @@ this is set to 0, which means that a sensible value is 
chosen based on the
 input format.
 @end table
 
+@section webp
+
+Animated WebP demuxer.
+
+It accepts the following options:
+
+@table @option
+@item -min_delay @var{int}
+Set the minimum valid delay between frames in milliseconds.
+Range is 0 to 6. Default value is 10.
+
+@item -max_webp_delay @var{int}
+Set the maximum valid delay between frames in milliseconds.
+Range is 0 to 16777215. Default value is 16777215 (over four hours),
+the maximum value allowed by the specification.
+
+@item -default_delay @var{int}
+Set the default delay between frames in milliseconds.
+Range is 0 to 6. Default value is 100.
+
+@item -ignore_loop @var{bool}
+WebP files can contain information to loop a certain number of times
+(or infinitely). If @option{ignore_loop} is set to true, then the loop
+setting from the input will be ignored and looping will not occur.
+If set to false, then looping will occur and will cycle the number
+of times according to the WebP. Default value is true.
+@end table
+
 @c man end DEMUXERS
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 8efe26b6df..6e7969846b 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -628,6 +628,7 @@ OBJS-$(CONFIG_WEBM_MUXER)+= matroskaenc.o 
matroska.o \
 av1.o avlanguage.o
 OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER)  += webmdashenc.o
 OBJS-$(CONFIG_WEBM_CHUNK_MUXER)  += webm_chunk.o
+OBJS-$(CONFIG_WEBP_DEMUXER)  += webpdec.o
 OBJS-$(CONFIG_WEBP_MUXER)+= webpenc.o
 OBJS-$(CONFIG_WEBVTT_DEMUXER)+= webvttdec.o subtitles.o
 OBJS-$(CONFIG_WEBVTT_MUXER)  += webvttenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 305fa46532..23f6ef7f7d 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -511,6 +511,7 @@ extern const FFInputFormat  ff_webm_dash_manifest_demuxer;
 extern const FFOutputFormat ff_webm_dash_manifest_muxer;
 extern const FFOutputFormat ff_webm_chunk_muxer;
 extern const FFOutputFormat ff_webp_muxer;
+extern const FFInputFormat  ff_webp_demuxer;
 extern const FFInputFormat  ff_webvtt_demuxer;
 extern const FFOutputFormat ff_webvtt_muxer;
 extern const FFInputFormat  ff_wsaud_demuxer;
diff --git a/libavformat/version.h b/libavformat/version.h
index 7ff1483912..ee91990360 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 #include "version_major.h"
 
 #define LIBAVFORMAT_VERSION_MINOR   3
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
diff --git a/libavformat/webpdec.c b/libavformat/webpdec.c
new file mode 100644
index 00..

[FFmpeg-devel] [PATCH v12 5/8] avcodec/webp: make init_canvas_frame static

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

---
 libavcodec/webp.c | 142 +++---
 1 file changed, 70 insertions(+), 72 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index f882c3e187..4a244c1b67 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1380,7 +1380,76 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, 
AVFrame *p,
 return ret;
 }
 
-int init_canvas_frame(WebPContext *s, int format, int key_frame);
+static int init_canvas_frame(WebPContext *s, int format, int key_frame)
+{
+AVFrame *canvas = s->canvas_frame.f;
+int height;
+int ret;
+
+// canvas is needed only for animation
+if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION))
+return 0;
+
+// avoid init for non-key frames whose format and size did not change
+if (!key_frame &&
+canvas->data[0] &&
+canvas->format == format &&
+canvas->width  == s->canvas_width &&
+canvas->height == s->canvas_height)
+return 0;
+
+// canvas changes within IPPP sequences will lose thread sync
+// because of the ThreadFrame reallocation and will wait forever
+// so if frame-threading is used, forbid canvas changes and unlock
+// previous frames
+if (!key_frame && canvas->data[0]) {
+if (s->avctx->thread_count > 1) {
+av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged. Use -threads 1 to try decoding with best effort.\n");
+// unlock previous frames that have sent an _await() call
+ff_thread_report_progress(&s->canvas_frame, INT_MAX, 0);
+return AVERROR_PATCHWELCOME;
+} else {
+// warn for damaged frames
+av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged.\n");
+}
+}
+
+s->avctx->pix_fmt = format;
+canvas->format= format;
+canvas->width = s->canvas_width;
+canvas->height= s->canvas_height;
+
+// VP8 decoder changed the width and height in AVCodecContext.
+// Change it back to the canvas size.
+ret = ff_set_dimensions(s->avctx, s->canvas_width, s->canvas_height);
+if (ret < 0)
+return ret;
+
+ff_thread_release_ext_buffer(&s->canvas_frame);
+ret = ff_thread_get_ext_buffer(s->avctx, &s->canvas_frame, 
AV_GET_BUFFER_FLAG_REF);
+if (ret < 0)
+return ret;
+
+if (canvas->format == AV_PIX_FMT_ARGB) {
+height = canvas->height;
+memset(canvas->data[0], 0, height * canvas->linesize[0]);
+} else /* if (canvas->format == AV_PIX_FMT_YUVA420P) */ {
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(canvas->format);
+for (int comp = 0; comp < desc->nb_components; comp++) {
+int plane = desc->comp[comp].plane;
+
+if (comp == 1 || comp == 2)
+height = AV_CEIL_RSHIFT(canvas->height, desc->log2_chroma_h);
+else
+height = FFALIGN(canvas->height, 1 << desc->log2_chroma_h);
+
+memset(canvas->data[plane], s->transparent_yuva[plane],
+   height * canvas->linesize[plane]);
+}
+}
+
+return 0;
+}
 
 static int webp_decode_frame_common(AVCodecContext *avctx, uint8_t *data, int 
size,
 int *got_frame, int key_frame, AVFrame *p)
@@ -1629,77 +1698,6 @@ exif_end:
 return size;
 }
 
-int init_canvas_frame(WebPContext *s, int format, int key_frame)
-{
-AVFrame *canvas = s->canvas_frame.f;
-int height;
-int ret;
-
-// canvas is needed only for animation
-if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION))
-return 0;
-
-// avoid init for non-key frames whose format and size did not change
-if (!key_frame &&
-canvas->data[0] &&
-canvas->format == format &&
-canvas->width  == s->canvas_width &&
-canvas->height == s->canvas_height)
-return 0;
-
-// canvas changes within IPPP sequences will loose thread sync
-// because of the ThreadFrame reallocation and will wait forever
-// so if frame-threading is used, forbid canvas changes and unlock
-// previous frames
-if (!key_frame && canvas->data[0]) {
-if (s->avctx->thread_count > 1) {
-av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged. Use -threads 1 to try decoding with best effort.\n");
-// unlock previous frames that have sent an _await() call
-ff_thread_report_progress(&s->canvas_frame, INT_MAX, 0);
-return AVERROR_PATCHWELCOME;
-} else {
-// warn for damaged fr

[FFmpeg-devel] [PATCH v12 4/8] libavcodec/webp: add support for animated WebP

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel
From: Josef Zlomek 

Fixes: 4907

Adds support for decoding of animated WebP.

The WebP decoder adds the animation related features according to the specs:
https://developers.google.com/speed/webp/docs/riff_container#animation
The frames of the animation may be smaller than the image canvas.
Therefore, the frame is decoded to a temporary frame,
then it is blended into the canvas, the canvas is copied to the output frame,
and finally the frame is disposed from the canvas.

The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported.
The background color is specified only as BGRA in the WebP file
so it is converted to YUVA if YUV formats are output.

Signed-off-by: Josef Zlomek 
---
 Changelog   |   1 +
 libavcodec/codec_desc.c |   3 +-
 libavcodec/version.h|   2 +-
 libavcodec/webp.c   | 710 
 4 files changed, 653 insertions(+), 63 deletions(-)

diff --git a/Changelog b/Changelog
index 5c8f505211..03ac047cea 100644
--- a/Changelog
+++ b/Changelog
@@ -93,6 +93,7 @@ version 6.1:
 - ffprobe XML output schema changed to account for multiple
   variable-fields elements within the same parent element
 - ffprobe -output_format option added as an alias of -of
+- animated WebP decoder
 
 
 version 6.0:
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 7dba61dc8b..2873f91479 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1259,8 +1259,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "webp",
 .long_name = NULL_IF_CONFIG_SMALL("WebP"),
-.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
- AV_CODEC_PROP_LOSSLESS,
+.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
 .mime_types= MT("image/webp"),
 },
 {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index f0958eee14..3d2de546b3 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 #include "version_major.h"
 
 #define LIBAVCODEC_VERSION_MINOR   5
-#define LIBAVCODEC_VERSION_MICRO 103
+#define LIBAVCODEC_VERSION_MICRO 104
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 3075321e86..f882c3e187 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -35,13 +35,16 @@
  * Exif metadata
  * ICC profile
  *
+ * @author Josef Zlomek, Pexeso Inc. 
+ * Animation
+ *
  * Unimplemented:
- *   - Animation
  *   - XMP metadata
  */
 
 #include "libavutil/imgutils.h"
 #include "libavutil/mem.h"
+#include "libavutil/colorspace.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
@@ -68,6 +71,14 @@
 #define NUM_SHORT_DISTANCES 120
 #define MAX_HUFFMAN_CODE_LENGTH 15
 
+#define ANMF_DISPOSAL_METHOD0x01
+#define ANMF_DISPOSAL_METHOD_UNCHANGED  0x00
+#define ANMF_DISPOSAL_METHOD_BACKGROUND 0x01
+
+#define ANMF_BLENDING_METHOD0x02
+#define ANMF_BLENDING_METHOD_ALPHA  0x00
+#define ANMF_BLENDING_METHOD_OVERWRITE  0x02
+
 static const uint16_t alphabet_sizes[HUFFMAN_CODES_PER_META_CODE] = {
 NUM_LITERAL_CODES + NUM_LENGTH_CODES,
 NUM_LITERAL_CODES, NUM_LITERAL_CODES, NUM_LITERAL_CODES,
@@ -192,6 +203,8 @@ typedef struct ImageContext {
 typedef struct WebPContext {
 VP8Context v;   /* VP8 Context used for lossy decoding 
*/
 GetBitContext gb;   /* bitstream reader for main image 
chunk */
+ThreadFrame canvas_frame;   /* ThreadFrame for canvas */
+AVFrame *frame; /* AVFrame for decoded frame */
 AVFrame *alpha_frame;   /* AVFrame for alpha data decompressed 
from VP8L */
 AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
 AVCodecContext *avctx;  /* parent AVCodecContext */
@@ -206,7 +219,22 @@ typedef struct WebPContext {
 int has_iccp;   /* set after an ICCP chunk has been 
processed */
 int width;  /* image width */
 int height; /* image height */
-int lossless;   /* indicates lossless or lossy */
+int vp8x_flags; /* global flags from VP8X chunk */
+int canvas_width;   /* canvas width */
+int canvas_height;  /* canvas height */
+int anmf_flags; /* frame flags from ANMF chunk */
+int pos_x;  /* frame position X */
+int pos_y;  /* frame position Y */
+int prev_anmf_flags;/* previous frame flags from ANMF 
chunk */
+int prev_width; /* previous frame width */
+int prev_height;/* previous frame height */
+int 

[FFmpeg-devel] [PATCH v12 3/8] avcodec/bsf: Add awebp2webp bitstream filter

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

Splits a packet containing a webp animations into
one non-compliant packet per frame of the animation.
Skips RIFF and WEBP chunks for those packets except
for the first. Copyies ICC, EXIF and XMP chunks first
into each of the packets except for the first.
---
 configure  |   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/bsf/Makefile|   1 +
 libavcodec/bsf/awebp2webp.c| 350 +
 4 files changed, 353 insertions(+)
 create mode 100644 libavcodec/bsf/awebp2webp.c

diff --git a/configure b/configure
index 55f1fc354d..2d08bc1fd8 100755
--- a/configure
+++ b/configure
@@ -3425,6 +3425,7 @@ aac_adtstoasc_bsf_select="adts_header mpeg4audio"
 av1_frame_merge_bsf_select="cbs_av1"
 av1_frame_split_bsf_select="cbs_av1"
 av1_metadata_bsf_select="cbs_av1"
+awebp2webp_bsf_select=""
 dts2pts_bsf_select="cbs_h264 h264parse"
 eac3_core_bsf_select="ac3_parser"
 evc_frame_merge_bsf_select="evcparse"
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 12860c332b..af88283a8c 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -28,6 +28,7 @@ extern const FFBitStreamFilter ff_aac_adtstoasc_bsf;
 extern const FFBitStreamFilter ff_av1_frame_merge_bsf;
 extern const FFBitStreamFilter ff_av1_frame_split_bsf;
 extern const FFBitStreamFilter ff_av1_metadata_bsf;
+extern const FFBitStreamFilter ff_awebp2webp_bsf;
 extern const FFBitStreamFilter ff_chomp_bsf;
 extern const FFBitStreamFilter ff_dump_extradata_bsf;
 extern const FFBitStreamFilter ff_dca_core_bsf;
diff --git a/libavcodec/bsf/Makefile b/libavcodec/bsf/Makefile
index fb70ad0c21..48c67dd210 100644
--- a/libavcodec/bsf/Makefile
+++ b/libavcodec/bsf/Makefile
@@ -5,6 +5,7 @@ OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += bsf/aac_adtstoasc.o
 OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= bsf/av1_frame_merge.o
 OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= bsf/av1_frame_split.o
 OBJS-$(CONFIG_AV1_METADATA_BSF)   += bsf/av1_metadata.o
+OBJS-$(CONFIG_AWEBP2WEBP_BSF) += bsf/awebp2webp.o
 OBJS-$(CONFIG_CHOMP_BSF)  += bsf/chomp.o
 OBJS-$(CONFIG_DCA_CORE_BSF)   += bsf/dca_core.o
 OBJS-$(CONFIG_DTS2PTS_BSF)+= bsf/dts2pts.o
diff --git a/libavcodec/bsf/awebp2webp.c b/libavcodec/bsf/awebp2webp.c
new file mode 100644
index 00..ebd123c667
--- /dev/null
+++ b/libavcodec/bsf/awebp2webp.c
@@ -0,0 +1,350 @@
+/*
+ * Animated WebP into non-compliant WebP bitstream filter
+ * Copyright (c) 2024 Thilo Borgmann 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Animated WebP into non-compliant WebP bitstream filter
+ * Splits a packet containing a webp animations into
+ * one non-compliant packet per frame of the animation.
+ * Skips RIFF and WEBP chunks for those packets except
+ * for the first. Copyies ICC, EXIF and XMP chunks first
+ * into each of the packets except for the first.
+ * @author Thilo Borgmann 
+ */
+
+#include 
+#include 
+
+#include "codec_id.h"
+#include "bytestream.h"
+#include "libavutil/error.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "packet.h"
+
+#define VP8X_FLAG_ANIMATION 0x02
+#define VP8X_FLAG_XMP_METADATA  0x04
+#define VP8X_FLAG_EXIF_METADATA 0x08
+#define VP8X_FLAG_ALPHA 0x10
+#define VP8X_FLAG_ICC   0x20
+
+typedef struct WEBPBSFContext {
+const AVClass *class;
+GetByteContext gb;
+
+AVPacket *last_pkt;
+uint8_t *last_iccp;
+uint8_t *last_exif;
+uint8_t *last_xmp;
+
+int iccp_size;
+int exif_size;
+int xmp_size;
+
+int add_iccp;
+int add_exif;
+int add_xmp;
+
+uint64_t last_pts;
+} WEBPBSFContext;
+
+static int save_chunk(WEBPBSFContext *ctx, uint8_t **buf, int *buf_size, 
uint32_t chunk_size)
+{
+if (*buf || !buf_size || !chunk_size)
+return 0;
+
+*buf = av_malloc(chunk_size + 8);
+if (!*buf)
+return AVERROR(ENOMEM);
+
+*buf_size = chunk_size + 8;
+
+bytestream2_seek(&ctx->gb, -8, SEEK

[FFmpeg-devel] [PATCH v12 2/8] avcodec/webp: separate VP8 decoding

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

---
 libavcodec/webp.c | 50 +--
 1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 3c153d78d1..3075321e86 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -195,6 +195,7 @@ typedef struct WebPContext {
 AVFrame *alpha_frame;   /* AVFrame for alpha data decompressed 
from VP8L */
 AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
 AVCodecContext *avctx;  /* parent AVCodecContext */
+AVCodecContext *avctx_vp8;  /* wrapper context for VP8 decoder */
 int initialized;/* set once the VP8 context is 
initialized */
 int has_alpha;  /* has a separate alpha chunk */
 enum AlphaCompression alpha_compression; /* compression type for alpha 
chunk */
@@ -1299,12 +1300,13 @@ static int vp8_lossy_decode_frame(AVCodecContext 
*avctx, AVFrame *p,
 int ret;
 
 if (!s->initialized) {
-ff_vp8_decode_init(avctx);
+VP8Context *s_vp8 = s->avctx_vp8->priv_data;
+s_vp8->actually_webp = 1;
 s->initialized = 1;
-s->v.actually_webp = 1;
 }
 avctx->pix_fmt = s->has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P;
 s->lossless = 0;
+s->avctx_vp8->pix_fmt = avctx->pix_fmt;
 
 if (data_size > INT_MAX) {
 av_log(avctx, AV_LOG_ERROR, "unsupported chunk size\n");
@@ -1315,14 +1317,32 @@ static int vp8_lossy_decode_frame(AVCodecContext 
*avctx, AVFrame *p,
 s->pkt->data = data_start;
 s->pkt->size = data_size;
 
-ret = ff_vp8_decode_frame(avctx, p, got_frame, s->pkt);
-if (ret < 0)
+ret = avcodec_send_packet(s->avctx_vp8, s->pkt);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for 
decoding\n");
 return ret;
+}
 
-if (!*got_frame)
+ret = avcodec_receive_frame(s->avctx_vp8, p);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "VP8 decoding error: %s.\n", 
av_err2str(ret));
 return AVERROR_INVALIDDATA;
+}
+
+ret = ff_decode_frame_props(avctx, p);
+if (ret < 0) {
+return ret;
+}
+
+if (!p->private_ref) {
+ret = ff_attach_decode_data(p);
+if (ret < 0) {
+return ret;
+}
+}
 
-update_canvas_size(avctx, avctx->width, avctx->height);
+*got_frame = 1;
+update_canvas_size(avctx, s->avctx_vp8->width, s->avctx_vp8->height);
 
 if (s->has_alpha) {
 ret = vp8_lossy_decode_alpha(avctx, p, s->alpha_data,
@@ -1539,11 +1559,28 @@ exif_end:
 static av_cold int webp_decode_init(AVCodecContext *avctx)
 {
 WebPContext *s = avctx->priv_data;
+int ret;
+const AVCodec *codec;
 
 s->pkt = av_packet_alloc();
 if (!s->pkt)
 return AVERROR(ENOMEM);
 
+
+/* Prepare everything needed for VP8 decoding */
+codec = avcodec_find_decoder(AV_CODEC_ID_VP8);
+if (!codec)
+return AVERROR_BUG;
+s->avctx_vp8 = avcodec_alloc_context3(codec);
+if (!s->avctx_vp8)
+return AVERROR(ENOMEM);
+s->avctx_vp8->flags = avctx->flags;
+s->avctx_vp8->flags2 = avctx->flags2;
+s->avctx_vp8->pix_fmt = avctx->pix_fmt;
+ret = avcodec_open2(s->avctx_vp8, codec, NULL);
+if (ret < 0) {
+return ret;
+}
 return 0;
 }
 
@@ -1552,6 +1589,7 @@ static av_cold int webp_decode_close(AVCodecContext 
*avctx)
 WebPContext *s = avctx->priv_data;
 
 av_packet_free(&s->pkt);
+avcodec_free_context(&s->avctx_vp8);
 
 if (s->initialized)
 return ff_vp8_decode_free(avctx);
-- 
2.43.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v12 1/8] avcodec/webp: remove unused definitions

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann via ffmpeg-devel 

---
 libavcodec/webp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index dbcc5e73eb..3c153d78d1 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -60,8 +60,6 @@
 #define VP8X_FLAG_ALPHA 0x10
 #define VP8X_FLAG_ICC   0x20
 
-#define MAX_PALETTE_SIZE256
-#define MAX_CACHE_BITS  11
 #define NUM_CODE_LENGTH_CODES   19
 #define HUFFMAN_CODES_PER_META_CODE 5
 #define NUM_LITERAL_CODES   256
-- 
2.43.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v12 0/8] [WIP] webp: add support for animated WebP decoding

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann 

Marked WIP because we'd want to introduce private bsf's first; review
welcome before that though
VP8 decoder decoupled again
The whole animated sequence goes into one packet
The (currently public) bitstream filter splits animations up into 
non-conformant packets
Now with XMP metadata support (as string, like MOV)


Patch 5/8 is still there for making changes in lavc/webp reviewable but shall 
be stashed when pushing.

-Thilo

Josef Zlomek (2):
  libavcodec/webp: add support for animated WebP
  libavformat/webp: add WebP demuxer

Thilo Borgmann via ffmpeg-devel (6):
  avcodec/webp: remove unused definitions
  avcodec/webp: separate VP8 decoding
  avcodec/bsf: Add awebp2webp bitstream filter
  avcodec/webp: make init_canvas_frame static
  fate: add test for animated WebP
  avcodec/webp: export XMP metadata

 Changelog |   2 +
 configure |   1 +
 doc/demuxers.texi |  28 +
 libavcodec/bitstream_filters.c|   1 +
 libavcodec/bsf/Makefile   |   1 +
 libavcodec/bsf/awebp2webp.c   | 350 
 libavcodec/codec_desc.c   |   3 +-
 libavcodec/version.h  |   2 +-
 libavcodec/webp.c | 796 --
 libavformat/Makefile  |   1 +
 libavformat/allformats.c  |   1 +
 libavformat/version.h |   2 +-
 libavformat/webpdec.c | 383 +
 tests/fate/image.mak  |   3 +
 tests/ref/fate/exif-image-webp|   4 +-
 tests/ref/fate/webp-anim  |  22 +
 tests/ref/fate/webp-rgb-lena-lossless |   2 +-
 tests/ref/fate/webp-rgb-lena-lossless-rgb24   |   2 +-
 tests/ref/fate/webp-rgb-lossless  |   2 +-
 .../fate/webp-rgb-lossless-palette-predictor  |   2 +-
 tests/ref/fate/webp-rgb-lossy-q80 |   2 +-
 tests/ref/fate/webp-rgba-lossless |   2 +-
 tests/ref/fate/webp-rgba-lossy-q80|   2 +-
 23 files changed, 1530 insertions(+), 84 deletions(-)
 create mode 100644 libavcodec/bsf/awebp2webp.c
 create mode 100644 libavformat/webpdec.c
 create mode 100644 tests/ref/fate/webp-anim

-- 
2.43.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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avdevice/avfoundation: fix macOS/iOS/tvOS SDK conditional checks

2024-04-17 Thread Thilo Borgmann via ffmpeg-devel

Hi,

On 17.04.24 17:12, Marvin Scholz wrote:

This fixes the checks to properly use runtime feature detection and
check the SDK version (*_MAX_ALLOWED) instead of the targeted version
for the relevant APIs.

The target is still checked (*_MIN_REQUIRED) to avoid using deprecated
methods when targeting new enough versions.
---
  libavdevice/avfoundation.m | 164 ++---
  1 file changed, 116 insertions(+), 48 deletions(-)


this is probably the extension to what we started at FOSDEM, right?

LGTM if tested. Please apply, I can't in the next couple of days.

Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] Sovereign Tech Fund

2024-04-12 Thread Thilo Borgmann via ffmpeg-devel

Hi all,


We are offered to apply for a sponsorship of FFmpeg by the Sovereign Tech Fund 
(STF).

Please read the following to get a better understanding what STF is about:
(In short it is about maintenance and sustainability, not features)
https://www.sovereigntechfund.de/programs/applications

As some probably already know, Thilo has worked with STF to work out
many details of this. SPI will handle the financials for FFmpeg.
Everyone willing to benefit from this sponsorship must not be a US sanctioned
entity or in a US sanctioned country. And must sign a contractor agreement
and simplified SoW with SPI.
"A SOW purpose is to protect the contracted from doing a
work and not getting paid, and to protect the contractor from paying for a
work which wasn't wanted"

At this point, what we need is a list of Projects so we can submit an 
application to STF
at or before 12th Feb. (at the 14th they have a meeting and will review our 
submission)


our application has been fully accepted, covering all the project 
proposals as listed in [1].


We were asked to align our public / social media announcement with STF 
which happens after the contracts are finalized, presumably end of 
April. Once these are done and set, I'll post a patch for a news entry 
which we can also put into the social media channels we have.


Cheers,
Thilo

[1] http://trac.ffmpeg.org/wiki/SponsoringPrograms/STF/2024#STFApplication
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v11 3/8] avcodec/bsf: Add awebp2webp bitstream filter

2024-03-29 Thread Thilo Borgmann via ffmpeg-devel

Am 28.03.24 um 19:11 schrieb Stefano Sabatini:

On date Thursday 2024-03-28 15:08:53 +0100, ffmpeg-devel Mailing List wrote:

Splits a packet containing a webp animations into
one non-compliant packet per frame of the animation.
Skips RIFF and WEBP chunks for those packets except
for the first. Copyies ICC, EXIF and XMP chunks first
into each of the packets except for the first.
---
  configure  |   1 +
  libavcodec/bitstream_filters.c |   1 +
  libavcodec/bsf/Makefile|   1 +
  libavcodec/bsf/awebp2webp.c| 350 +
  4 files changed, 353 insertions(+)
  create mode 100644 libavcodec/bsf/awebp2webp.c


missing doc/bitstreams.texi update?

also you might mention in the Changelog, assuming this might be
directly used by users


Yes, adding docs next iteration. Also micro bump for a new bsf? (I'll never get 
the rules of bumping...)

It's yet a normal filter, Andreas wanted this to be non-public in the end, 
requiring some additional changes before.

-Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 6/8] libavformat/webp: add WebP demuxer

2024-03-28 Thread Thilo Borgmann via ffmpeg-devel
From: Josef Zlomek 

Adds the demuxer of animated WebP files.
It supports non-animated, animated, truncated, and concatenated files.
Reading from a pipe (and other non-seekable inputs) is also supported.

The WebP demuxer splits the input stream into packets containing one frame.
It also marks the key frames properly.
The loop count is ignored by default (same behaviour as animated PNG and GIF),
it may be enabled by the option '-ignore_loop 0'.

The frame rate is set according to the frame delay in the ANMF chunk.
If the delay is too low, or the image is not animated, the default frame rate
is set to 10 fps, similarly to other WebP libraries and browsers.
The fate suite was updated accordingly.

Signed-off-by: Josef Zlomek 
---
 Changelog |   1 +
 doc/demuxers.texi |  28 ++
 libavformat/Makefile  |   1 +
 libavformat/allformats.c  |   1 +
 libavformat/version.h |   2 +-
 libavformat/webpdec.c | 383 ++
 tests/ref/fate/exif-image-webp|   4 +-
 tests/ref/fate/webp-rgb-lena-lossless |   2 +-
 tests/ref/fate/webp-rgb-lena-lossless-rgb24   |   2 +-
 tests/ref/fate/webp-rgb-lossless  |   2 +-
 .../fate/webp-rgb-lossless-palette-predictor  |   2 +-
 tests/ref/fate/webp-rgb-lossy-q80 |   2 +-
 tests/ref/fate/webp-rgba-lossless |   2 +-
 tests/ref/fate/webp-rgba-lossy-q80|   2 +-
 14 files changed, 424 insertions(+), 10 deletions(-)
 create mode 100644 libavformat/webpdec.c

diff --git a/Changelog b/Changelog
index bafa56dc2a..d91e9df577 100644
--- a/Changelog
+++ b/Changelog
@@ -78,6 +78,7 @@ version 6.1:
   variable-fields elements within the same parent element
 - ffprobe -output_format option added as an alias of -of
 - animated WebP decoder
+- animated WebP demuxer
 
 
 version 6.0:
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index b70f3a38d7..64c9c8c215 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -1128,4 +1128,32 @@ this is set to 0, which means that a sensible value is 
chosen based on the
 input format.
 @end table
 
+@section webp
+
+Animated WebP demuxer.
+
+It accepts the following options:
+
+@table @option
+@item -min_delay @var{int}
+Set the minimum valid delay between frames in milliseconds.
+Range is 0 to 6. Default value is 10.
+
+@item -max_webp_delay @var{int}
+Set the maximum valid delay between frames in milliseconds.
+Range is 0 to 16777215. Default value is 16777215 (over four hours),
+the maximum value allowed by the specification.
+
+@item -default_delay @var{int}
+Set the default delay between frames in milliseconds.
+Range is 0 to 6. Default value is 100.
+
+@item -ignore_loop @var{bool}
+WebP files can contain information to loop a certain number of times
+(or infinitely). If @option{ignore_loop} is set to true, then the loop
+setting from the input will be ignored and looping will not occur.
+If set to false, then looping will occur and will cycle the number
+of times according to the WebP. Default value is true.
+@end table
+
 @c man end DEMUXERS
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 44aa485029..cede2920e5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -625,6 +625,7 @@ OBJS-$(CONFIG_WEBM_MUXER)+= matroskaenc.o 
matroska.o \
 av1.o avlanguage.o
 OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER)  += webmdashenc.o
 OBJS-$(CONFIG_WEBM_CHUNK_MUXER)  += webm_chunk.o
+OBJS-$(CONFIG_WEBP_DEMUXER)  += webpdec.o
 OBJS-$(CONFIG_WEBP_MUXER)+= webpenc.o
 OBJS-$(CONFIG_WEBVTT_DEMUXER)+= webvttdec.o subtitles.o
 OBJS-$(CONFIG_WEBVTT_MUXER)  += webvttenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 9df42bb87a..c1febf0b04 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -508,6 +508,7 @@ extern const FFInputFormat  ff_webm_dash_manifest_demuxer;
 extern const FFOutputFormat ff_webm_dash_manifest_muxer;
 extern const FFOutputFormat ff_webm_chunk_muxer;
 extern const FFOutputFormat ff_webp_muxer;
+extern const FFInputFormat  ff_webp_demuxer;
 extern const FFInputFormat  ff_webvtt_demuxer;
 extern const FFOutputFormat ff_webvtt_muxer;
 extern const FFInputFormat  ff_wsaud_demuxer;
diff --git a/libavformat/version.h b/libavformat/version.h
index 904e7f06aa..21042d998f 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 #include "version_major.h"
 
 #define LIBAVFORMAT_VERSION_MINOR   2
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
diff --git a/libavformat/webpdec.c b/libavformat/webpdec.c
new file mode 100644
index 00..

[FFmpeg-devel] [PATCH v11 8/8] avcodec/webp: export XMP metadata

2024-03-28 Thread Thilo Borgmann via ffmpeg-devel
---
 libavcodec/webp.c | 42 --
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 832ede52fc..b9feaa5bf0 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -38,8 +38,8 @@
  * @author Josef Zlomek, Pexeso Inc. 
  * Animation
  *
- * Unimplemented:
- *   - XMP metadata
+ * @author Thilo Borgmann 
+ * XMP metadata
  */
 
 #include "libavutil/imgutils.h"
@@ -216,6 +216,7 @@ typedef struct WebPContext {
 int alpha_data_size;/* alpha chunk data size */
 int has_exif;   /* set after an EXIF chunk has been 
processed */
 int has_iccp;   /* set after an ICCP chunk has been 
processed */
+int has_xmp;/* set after an XMP chunk has been 
processed */
 int width;  /* image width */
 int height; /* image height */
 int vp8x_flags; /* global flags from VP8X chunk */
@@ -1463,6 +1464,7 @@ static int webp_decode_frame_common(AVCodecContext 
*avctx, uint8_t *data, int si
 // reset metadata bit for each packet
 s->has_exif  = 0;
 s->has_iccp  = 0;
+s->has_xmp   = 0;
 
 while (bytestream2_get_bytes_left(&gb) > 8) {
 char chunk_str[5] = { 0 };
@@ -1494,6 +1496,7 @@ static int webp_decode_frame_common(AVCodecContext 
*avctx, uint8_t *data, int si
 s->canvas_height = 0;
 s->has_exif  = 0;
 s->has_iccp  = 0;
+s->has_xmp   = 0;
 ff_thread_release_ext_buffer(&s->canvas_frame);
 break;
 case MKTAG('V', 'P', '8', ' '):
@@ -1679,12 +1682,39 @@ exif_end:
 }
 s->vp8x_flags |= VP8X_FLAG_ANIMATION;
 break;
-case MKTAG('X', 'M', 'P', ' '):
-AV_WL32(chunk_str, chunk_type);
-av_log(avctx, AV_LOG_WARNING, "skipping unsupported chunk: %s\n",
-   chunk_str);
+case MKTAG('X', 'M', 'P', ' '): {
+GetByteContext xmp_gb;
+AVDictionary **xmp_metadata = NULL;
+uint8_t *buffer;
+int xmp_offset = bytestream2_tell(&gb);
+
+if (s->has_xmp) {
+av_log(avctx, AV_LOG_VERBOSE, "Ignoring extra XMP chunk\n");
+goto xmp_end;
+}
+if (!(s->vp8x_flags & VP8X_FLAG_XMP_METADATA))
+av_log(avctx, AV_LOG_WARNING,
+   "XMP chunk present, but XMP bit not set in the "
+   "VP8X header\n");
+
+// there are at least chunk_size bytes left to read
+buffer = av_malloc(chunk_size + 1);
+if (!buffer) {
+return AVERROR(ENOMEM);
+}
+
+s->has_xmp = 1;
+bytestream2_init(&xmp_gb, data + xmp_offset, size - xmp_offset);
+bytestream2_get_buffer(&xmp_gb, buffer, chunk_size);
+buffer[chunk_size] = '\0';
+
+xmp_metadata = (s->vp8x_flags & VP8X_FLAG_ANIMATION) ? 
&p->metadata : &s->frame->metadata;
+av_dict_set(xmp_metadata, "xmp", buffer, AV_DICT_DONT_STRDUP_VAL);
+
+xmp_end:
 bytestream2_skip(&gb, chunk_size);
 break;
+}
 default:
 AV_WL32(chunk_str, chunk_type);
 av_log(avctx, AV_LOG_VERBOSE, "skipping unknown chunk: %s\n",
-- 
2.39.3 (Apple Git-146)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 4/8] libavcodec/webp: add support for animated WebP

2024-03-28 Thread Thilo Borgmann via ffmpeg-devel
From: Josef Zlomek 

Fixes: 4907

Adds support for decoding of animated WebP.

The WebP decoder adds the animation related features according to the specs:
https://developers.google.com/speed/webp/docs/riff_container#animation
The frames of the animation may be smaller than the image canvas.
Therefore, the frame is decoded to a temporary frame,
then it is blended into the canvas, the canvas is copied to the output frame,
and finally the frame is disposed from the canvas.

The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported.
The background color is specified only as BGRA in the WebP file
so it is converted to YUVA if YUV formats are output.

Signed-off-by: Josef Zlomek 
---
 Changelog   |   1 +
 libavcodec/codec_desc.c |   3 +-
 libavcodec/version.h|   2 +-
 libavcodec/webp.c   | 710 
 4 files changed, 653 insertions(+), 63 deletions(-)

diff --git a/Changelog b/Changelog
index e83a00e35c..bafa56dc2a 100644
--- a/Changelog
+++ b/Changelog
@@ -77,6 +77,7 @@ version 6.1:
 - ffprobe XML output schema changed to account for multiple
   variable-fields elements within the same parent element
 - ffprobe -output_format option added as an alias of -of
+- animated WebP decoder
 
 
 version 6.0:
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 3bab86db62..b017acbc74 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1259,8 +1259,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "webp",
 .long_name = NULL_IF_CONFIG_SMALL("WebP"),
-.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
- AV_CODEC_PROP_LOSSLESS,
+.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
 .mime_types= MT("image/webp"),
 },
 {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 06631ffa8c..789d9047c2 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 #include "version_major.h"
 
 #define LIBAVCODEC_VERSION_MINOR   4
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index d6af48585e..293bb485de 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -35,12 +35,15 @@
  * Exif metadata
  * ICC profile
  *
+ * @author Josef Zlomek, Pexeso Inc. 
+ * Animation
+ *
  * Unimplemented:
- *   - Animation
  *   - XMP metadata
  */
 
 #include "libavutil/imgutils.h"
+#include "libavutil/colorspace.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
@@ -67,6 +70,14 @@
 #define NUM_SHORT_DISTANCES 120
 #define MAX_HUFFMAN_CODE_LENGTH 15
 
+#define ANMF_DISPOSAL_METHOD0x01
+#define ANMF_DISPOSAL_METHOD_UNCHANGED  0x00
+#define ANMF_DISPOSAL_METHOD_BACKGROUND 0x01
+
+#define ANMF_BLENDING_METHOD0x02
+#define ANMF_BLENDING_METHOD_ALPHA  0x00
+#define ANMF_BLENDING_METHOD_OVERWRITE  0x02
+
 static const uint16_t alphabet_sizes[HUFFMAN_CODES_PER_META_CODE] = {
 NUM_LITERAL_CODES + NUM_LENGTH_CODES,
 NUM_LITERAL_CODES, NUM_LITERAL_CODES, NUM_LITERAL_CODES,
@@ -191,6 +202,8 @@ typedef struct ImageContext {
 typedef struct WebPContext {
 VP8Context v;   /* VP8 Context used for lossy decoding 
*/
 GetBitContext gb;   /* bitstream reader for main image 
chunk */
+ThreadFrame canvas_frame;   /* ThreadFrame for canvas */
+AVFrame *frame; /* AVFrame for decoded frame */
 AVFrame *alpha_frame;   /* AVFrame for alpha data decompressed 
from VP8L */
 AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
 AVCodecContext *avctx;  /* parent AVCodecContext */
@@ -205,7 +218,22 @@ typedef struct WebPContext {
 int has_iccp;   /* set after an ICCP chunk has been 
processed */
 int width;  /* image width */
 int height; /* image height */
-int lossless;   /* indicates lossless or lossy */
+int vp8x_flags; /* global flags from VP8X chunk */
+int canvas_width;   /* canvas width */
+int canvas_height;  /* canvas height */
+int anmf_flags; /* frame flags from ANMF chunk */
+int pos_x;  /* frame position X */
+int pos_y;  /* frame position Y */
+int prev_anmf_flags;/* previous frame flags from ANMF 
chunk */
+int prev_width; /* previous frame width */
+int prev_height;/* previous frame height */
+int prev_pos_x; 

[FFmpeg-devel] [PATCH v11 5/8] avcodec/webp: make init_canvas_frame static

2024-03-28 Thread Thilo Borgmann via ffmpeg-devel
---
 libavcodec/webp.c | 142 +++---
 1 file changed, 70 insertions(+), 72 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 293bb485de..832ede52fc 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1379,7 +1379,76 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, 
AVFrame *p,
 return ret;
 }
 
-int init_canvas_frame(WebPContext *s, int format, int key_frame);
+static int init_canvas_frame(WebPContext *s, int format, int key_frame)
+{
+AVFrame *canvas = s->canvas_frame.f;
+int height;
+int ret;
+
+// canvas is needed only for animation
+if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION))
+return 0;
+
+// avoid init for non-key frames whose format and size did not change
+if (!key_frame &&
+canvas->data[0] &&
+canvas->format == format &&
+canvas->width  == s->canvas_width &&
+canvas->height == s->canvas_height)
+return 0;
+
+// canvas changes within IPPP sequences will lose thread sync
+// because of the ThreadFrame reallocation and will wait forever
+// so if frame-threading is used, forbid canvas changes and unlock
+// previous frames
+if (!key_frame && canvas->data[0]) {
+if (s->avctx->thread_count > 1) {
+av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged. Use -threads 1 to try decoding with best effort.\n");
+// unlock previous frames that have sent an _await() call
+ff_thread_report_progress(&s->canvas_frame, INT_MAX, 0);
+return AVERROR_PATCHWELCOME;
+} else {
+// warn for damaged frames
+av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged.\n");
+}
+}
+
+s->avctx->pix_fmt = format;
+canvas->format= format;
+canvas->width = s->canvas_width;
+canvas->height= s->canvas_height;
+
+// VP8 decoder changed the width and height in AVCodecContext.
+// Change it back to the canvas size.
+ret = ff_set_dimensions(s->avctx, s->canvas_width, s->canvas_height);
+if (ret < 0)
+return ret;
+
+ff_thread_release_ext_buffer(&s->canvas_frame);
+ret = ff_thread_get_ext_buffer(s->avctx, &s->canvas_frame, 
AV_GET_BUFFER_FLAG_REF);
+if (ret < 0)
+return ret;
+
+if (canvas->format == AV_PIX_FMT_ARGB) {
+height = canvas->height;
+memset(canvas->data[0], 0, height * canvas->linesize[0]);
+} else /* if (canvas->format == AV_PIX_FMT_YUVA420P) */ {
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(canvas->format);
+for (int comp = 0; comp < desc->nb_components; comp++) {
+int plane = desc->comp[comp].plane;
+
+if (comp == 1 || comp == 2)
+height = AV_CEIL_RSHIFT(canvas->height, desc->log2_chroma_h);
+else
+height = FFALIGN(canvas->height, 1 << desc->log2_chroma_h);
+
+memset(canvas->data[plane], s->transparent_yuva[plane],
+   height * canvas->linesize[plane]);
+}
+}
+
+return 0;
+}
 
 static int webp_decode_frame_common(AVCodecContext *avctx, uint8_t *data, int 
size,
 int *got_frame, int key_frame, AVFrame *p)
@@ -1628,77 +1697,6 @@ exif_end:
 return size;
 }
 
-int init_canvas_frame(WebPContext *s, int format, int key_frame)
-{
-AVFrame *canvas = s->canvas_frame.f;
-int height;
-int ret;
-
-// canvas is needed only for animation
-if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION))
-return 0;
-
-// avoid init for non-key frames whose format and size did not change
-if (!key_frame &&
-canvas->data[0] &&
-canvas->format == format &&
-canvas->width  == s->canvas_width &&
-canvas->height == s->canvas_height)
-return 0;
-
-// canvas changes within IPPP sequences will loose thread sync
-// because of the ThreadFrame reallocation and will wait forever
-// so if frame-threading is used, forbid canvas changes and unlock
-// previous frames
-if (!key_frame && canvas->data[0]) {
-if (s->avctx->thread_count > 1) {
-av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged. Use -threads 1 to try decoding with best effort.\n");
-// unlock previous frames that have sent an _await() call
-ff_thread_report_progress(&s->canvas_frame, INT_MAX, 0);
-return AVERROR_PATCHWELCOME;
-} else {
-// warn for damaged frames
-av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged.\n");
-}
-}
-
-s->avctx->pix_fmt = format;
-canvas->format= format;
-canvas->width = s->canvas_width;
-canvas->height= s->canvas_height;
-
-// VP8 decoder changed the width and height in AVCodecContext.
-// Ch

[FFmpeg-devel] [PATCH v11 3/8] avcodec/bsf: Add awebp2webp bitstream filter

2024-03-28 Thread Thilo Borgmann via ffmpeg-devel
Splits a packet containing a webp animations into
one non-compliant packet per frame of the animation.
Skips RIFF and WEBP chunks for those packets except
for the first. Copyies ICC, EXIF and XMP chunks first
into each of the packets except for the first.
---
 configure  |   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/bsf/Makefile|   1 +
 libavcodec/bsf/awebp2webp.c| 350 +
 4 files changed, 353 insertions(+)
 create mode 100644 libavcodec/bsf/awebp2webp.c

diff --git a/configure b/configure
index 2d46ef0b9c..91813a41cd 100755
--- a/configure
+++ b/configure
@@ -3418,6 +3418,7 @@ aac_adtstoasc_bsf_select="adts_header mpeg4audio"
 av1_frame_merge_bsf_select="cbs_av1"
 av1_frame_split_bsf_select="cbs_av1"
 av1_metadata_bsf_select="cbs_av1"
+awebp2webp_bsf_select=""
 dts2pts_bsf_select="cbs_h264 h264parse"
 eac3_core_bsf_select="ac3_parser"
 evc_frame_merge_bsf_select="evcparse"
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 12860c332b..af88283a8c 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -28,6 +28,7 @@ extern const FFBitStreamFilter ff_aac_adtstoasc_bsf;
 extern const FFBitStreamFilter ff_av1_frame_merge_bsf;
 extern const FFBitStreamFilter ff_av1_frame_split_bsf;
 extern const FFBitStreamFilter ff_av1_metadata_bsf;
+extern const FFBitStreamFilter ff_awebp2webp_bsf;
 extern const FFBitStreamFilter ff_chomp_bsf;
 extern const FFBitStreamFilter ff_dump_extradata_bsf;
 extern const FFBitStreamFilter ff_dca_core_bsf;
diff --git a/libavcodec/bsf/Makefile b/libavcodec/bsf/Makefile
index fb70ad0c21..48c67dd210 100644
--- a/libavcodec/bsf/Makefile
+++ b/libavcodec/bsf/Makefile
@@ -5,6 +5,7 @@ OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += bsf/aac_adtstoasc.o
 OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= bsf/av1_frame_merge.o
 OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= bsf/av1_frame_split.o
 OBJS-$(CONFIG_AV1_METADATA_BSF)   += bsf/av1_metadata.o
+OBJS-$(CONFIG_AWEBP2WEBP_BSF) += bsf/awebp2webp.o
 OBJS-$(CONFIG_CHOMP_BSF)  += bsf/chomp.o
 OBJS-$(CONFIG_DCA_CORE_BSF)   += bsf/dca_core.o
 OBJS-$(CONFIG_DTS2PTS_BSF)+= bsf/dts2pts.o
diff --git a/libavcodec/bsf/awebp2webp.c b/libavcodec/bsf/awebp2webp.c
new file mode 100644
index 00..ebd123c667
--- /dev/null
+++ b/libavcodec/bsf/awebp2webp.c
@@ -0,0 +1,350 @@
+/*
+ * Animated WebP into non-compliant WebP bitstream filter
+ * Copyright (c) 2024 Thilo Borgmann 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Animated WebP into non-compliant WebP bitstream filter
+ * Splits a packet containing a webp animations into
+ * one non-compliant packet per frame of the animation.
+ * Skips RIFF and WEBP chunks for those packets except
+ * for the first. Copyies ICC, EXIF and XMP chunks first
+ * into each of the packets except for the first.
+ * @author Thilo Borgmann 
+ */
+
+#include 
+#include 
+
+#include "codec_id.h"
+#include "bytestream.h"
+#include "libavutil/error.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "packet.h"
+
+#define VP8X_FLAG_ANIMATION 0x02
+#define VP8X_FLAG_XMP_METADATA  0x04
+#define VP8X_FLAG_EXIF_METADATA 0x08
+#define VP8X_FLAG_ALPHA 0x10
+#define VP8X_FLAG_ICC   0x20
+
+typedef struct WEBPBSFContext {
+const AVClass *class;
+GetByteContext gb;
+
+AVPacket *last_pkt;
+uint8_t *last_iccp;
+uint8_t *last_exif;
+uint8_t *last_xmp;
+
+int iccp_size;
+int exif_size;
+int xmp_size;
+
+int add_iccp;
+int add_exif;
+int add_xmp;
+
+uint64_t last_pts;
+} WEBPBSFContext;
+
+static int save_chunk(WEBPBSFContext *ctx, uint8_t **buf, int *buf_size, 
uint32_t chunk_size)
+{
+if (*buf || !buf_size || !chunk_size)
+return 0;
+
+*buf = av_malloc(chunk_size + 8);
+if (!*buf)
+return AVERROR(ENOMEM);
+
+*buf_size = chunk_size + 8;
+
+bytestream2_seek(&ctx->gb, -8, SEEK_CUR);
+bytestream2_get_buffer(&am

[FFmpeg-devel] [PATCH v11 2/8] avcodec/webp: separate VP8 decoding

2024-03-28 Thread Thilo Borgmann via ffmpeg-devel
---
 libavcodec/webp.c | 50 +--
 1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 2301699e5a..d6af48585e 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -194,6 +194,7 @@ typedef struct WebPContext {
 AVFrame *alpha_frame;   /* AVFrame for alpha data decompressed 
from VP8L */
 AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
 AVCodecContext *avctx;  /* parent AVCodecContext */
+AVCodecContext *avctx_vp8;  /* wrapper context for VP8 decoder */
 int initialized;/* set once the VP8 context is 
initialized */
 int has_alpha;  /* has a separate alpha chunk */
 enum AlphaCompression alpha_compression; /* compression type for alpha 
chunk */
@@ -1298,12 +1299,13 @@ static int vp8_lossy_decode_frame(AVCodecContext 
*avctx, AVFrame *p,
 int ret;
 
 if (!s->initialized) {
-ff_vp8_decode_init(avctx);
+VP8Context *s_vp8 = s->avctx_vp8->priv_data;
+s_vp8->actually_webp = 1;
 s->initialized = 1;
-s->v.actually_webp = 1;
 }
 avctx->pix_fmt = s->has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P;
 s->lossless = 0;
+s->avctx_vp8->pix_fmt = avctx->pix_fmt;
 
 if (data_size > INT_MAX) {
 av_log(avctx, AV_LOG_ERROR, "unsupported chunk size\n");
@@ -1314,14 +1316,32 @@ static int vp8_lossy_decode_frame(AVCodecContext 
*avctx, AVFrame *p,
 s->pkt->data = data_start;
 s->pkt->size = data_size;
 
-ret = ff_vp8_decode_frame(avctx, p, got_frame, s->pkt);
-if (ret < 0)
+ret = avcodec_send_packet(s->avctx_vp8, s->pkt);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for 
decoding\n");
 return ret;
+}
 
-if (!*got_frame)
+ret = avcodec_receive_frame(s->avctx_vp8, p);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "VP8 decoding error: %s.\n", 
av_err2str(ret));
 return AVERROR_INVALIDDATA;
+}
+
+ret = ff_decode_frame_props(avctx, p);
+if (ret < 0) {
+return ret;
+}
+
+if (!p->private_ref) {
+ret = ff_attach_decode_data(p);
+if (ret < 0) {
+return ret;
+}
+}
 
-update_canvas_size(avctx, avctx->width, avctx->height);
+*got_frame = 1;
+update_canvas_size(avctx, s->avctx_vp8->width, s->avctx_vp8->height);
 
 if (s->has_alpha) {
 ret = vp8_lossy_decode_alpha(avctx, p, s->alpha_data,
@@ -1538,11 +1558,28 @@ exif_end:
 static av_cold int webp_decode_init(AVCodecContext *avctx)
 {
 WebPContext *s = avctx->priv_data;
+int ret;
+const AVCodec *codec;
 
 s->pkt = av_packet_alloc();
 if (!s->pkt)
 return AVERROR(ENOMEM);
 
+
+/* Prepare everything needed for VP8 decoding */
+codec = avcodec_find_decoder(AV_CODEC_ID_VP8);
+if (!codec)
+return AVERROR_BUG;
+s->avctx_vp8 = avcodec_alloc_context3(codec);
+if (!s->avctx_vp8)
+return AVERROR(ENOMEM);
+s->avctx_vp8->flags = avctx->flags;
+s->avctx_vp8->flags2 = avctx->flags2;
+s->avctx_vp8->pix_fmt = avctx->pix_fmt;
+ret = avcodec_open2(s->avctx_vp8, codec, NULL);
+if (ret < 0) {
+return ret;
+}
 return 0;
 }
 
@@ -1551,6 +1588,7 @@ static av_cold int webp_decode_close(AVCodecContext 
*avctx)
 WebPContext *s = avctx->priv_data;
 
 av_packet_free(&s->pkt);
+avcodec_free_context(&s->avctx_vp8);
 
 if (s->initialized)
 return ff_vp8_decode_free(avctx);
-- 
2.39.3 (Apple Git-146)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 7/8] fate: add test for animated WebP

2024-03-28 Thread Thilo Borgmann via ffmpeg-devel
---
 tests/fate/image.mak |  3 +++
 tests/ref/fate/webp-anim | 22 ++
 2 files changed, 25 insertions(+)
 create mode 100644 tests/ref/fate/webp-anim

diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 7c0e0fec08..4620d65b3f 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -566,6 +566,9 @@ fate-webp-rgb-lossy-q80: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/rgb_q80.webp
 FATE_WEBP += fate-webp-rgba-lossy-q80
 fate-webp-rgba-lossy-q80: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/rgba_q80.webp
 
+FATE_WEBP += fate-webp-anim
+fate-webp-anim: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/130227-100431-6817p.webp
+
 FATE_WEBP-$(call DEMDEC, IMAGE2, WEBP) += $(FATE_WEBP)
 FATE_IMAGE_FRAMECRC += $(FATE_WEBP-yes)
 fate-webp: $(FATE_WEBP-yes)
diff --git a/tests/ref/fate/webp-anim b/tests/ref/fate/webp-anim
new file mode 100644
index 00..f0d3f1a88f
--- /dev/null
+++ b/tests/ref/fate/webp-anim
@@ -0,0 +1,22 @@
+#tb 0: 1/1000
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 100x70
+#sar 0: 0/1
+0,  0,  0,   80,28000, 0x2023ba6e
+0, 80, 80,   80,28000, 0x4292b778
+0,160,160,   80,28000, 0x1c972ef1
+0,240,240,   80,28000, 0xa98d8d04
+0,320,320,   80,28000, 0xd323b6af
+0,400,400,   80,28000, 0x508aba99
+0,480,480,   80,28000, 0x5c672dda
+0,560,560,   80,28000, 0xc8961ebb
+0,640,640, 1000,28000, 0x82460e1b
+0,   1640,   1640,   80,28000, 0x3debbfc9
+0,   1720,   1720,   80,28000, 0x427ab31f
+0,   1800,   1800,   80,28000, 0x6bbdec2e
+0,   1880,   1880,   80,28000, 0x5690b56b
+0,   1960,   1960,   80,28000, 0xb62963f3
+0,   2040,   2040,   80,28000, 0x68dd37b2
+0,   2120,   2120,   80,28000, 0x465c47d2
+0,   2200,   2200,1,28000, 0xa92033df
-- 
2.39.3 (Apple Git-146)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 0/8] webp: add support for animated WebP decoding

2024-03-28 Thread Thilo Borgmann via ffmpeg-devel
VP8 decoder decoupled again
The whole animated sequence goes into one packet
The (currently public) bitstream filter splits animations up into 
non-conformant packets
Now with XMP metadata support (as string, like MOV)


Patch 5/8 is still there for making changes in lavc/webp reviewable but shall 
be stashed when pushing.

-Thilo

Josef Zlomek (2):
  libavcodec/webp: add support for animated WebP
  libavformat/webp: add WebP demuxer

Thilo Borgmann (6):
  avcodec/webp: remove unused definitions
  avcodec/webp: separate VP8 decoding
  avcodec/bsf: Add awebp2webp bitstream filter
  avcodec/webp: make init_canvas_frame static
  fate: add test for animated WebP
  avcodec/webp: export XMP metadata

 Changelog |   2 +
 configure |   1 +
 doc/demuxers.texi |  28 +
 libavcodec/bitstream_filters.c|   1 +
 libavcodec/bsf/Makefile   |   1 +
 libavcodec/bsf/awebp2webp.c   | 350 
 libavcodec/codec_desc.c   |   3 +-
 libavcodec/version.h  |   2 +-
 libavcodec/webp.c | 796 --
 libavformat/Makefile  |   1 +
 libavformat/allformats.c  |   1 +
 libavformat/version.h |   2 +-
 libavformat/webpdec.c | 383 +
 tests/fate/image.mak  |   3 +
 tests/ref/fate/exif-image-webp|   4 +-
 tests/ref/fate/webp-anim  |  22 +
 tests/ref/fate/webp-rgb-lena-lossless |   2 +-
 tests/ref/fate/webp-rgb-lena-lossless-rgb24   |   2 +-
 tests/ref/fate/webp-rgb-lossless  |   2 +-
 .../fate/webp-rgb-lossless-palette-predictor  |   2 +-
 tests/ref/fate/webp-rgb-lossy-q80 |   2 +-
 tests/ref/fate/webp-rgba-lossless |   2 +-
 tests/ref/fate/webp-rgba-lossy-q80|   2 +-
 23 files changed, 1530 insertions(+), 84 deletions(-)
 create mode 100644 libavcodec/bsf/awebp2webp.c
 create mode 100644 libavformat/webpdec.c
 create mode 100644 tests/ref/fate/webp-anim

-- 
2.39.3 (Apple Git-146)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 1/8] avcodec/webp: remove unused definitions

2024-03-28 Thread Thilo Borgmann via ffmpeg-devel
---
 libavcodec/webp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 9308ea2b69..2301699e5a 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -59,8 +59,6 @@
 #define VP8X_FLAG_ALPHA 0x10
 #define VP8X_FLAG_ICC   0x20
 
-#define MAX_PALETTE_SIZE256
-#define MAX_CACHE_BITS  11
 #define NUM_CODE_LENGTH_CODES   19
 #define HUFFMAN_CODES_PER_META_CODE 5
 #define NUM_LITERAL_CODES   256
-- 
2.39.3 (Apple Git-146)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v10 2/5] libavcodec/webp: add support for animated WebP

2024-02-26 Thread Thilo Borgmann via ffmpeg-devel

Hi,

Am 19.02.24 um 17:50 schrieb Andreas Rheinhardt:

Thilo Borgmann via ffmpeg-devel:

From: Josef Zlomek 

Fixes: 4907

Adds support for decoding of animated WebP.

The WebP decoder adds the animation related features according to the specs:
https://developers.google.com/speed/webp/docs/riff_container#animation
The frames of the animation may be smaller than the image canvas.
Therefore, the frame is decoded to a temporary frame,
then it is blended into the canvas, the canvas is copied to the output frame,
and finally the frame is disposed from the canvas.

The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported.
The background color is specified only as BGRA in the WebP file
so it is converted to YUVA if YUV formats are output.

Signed-off-by: Josef Zlomek 
---
  Changelog   |   1 +
  libavcodec/codec_desc.c |   3 +-
  libavcodec/version.h|   2 +-
  libavcodec/webp.c   | 704 +---
  4 files changed, 654 insertions(+), 56 deletions(-)




+static int webp_decode_frame(AVCodecContext *avctx, AVFrame *p,
+ int *got_frame, AVPacket *avpkt)
+{
+WebPContext *s = avctx->priv_data;
+AVFrame *canvas = s->canvas_frame.f;
+int ret;
+int key_frame = avpkt->flags & AV_PKT_FLAG_KEY;
+
+*got_frame   = 0;
+
+if (key_frame) {
+// The canvas is passed from one thread to another in a sequence
+// starting with a key frame followed by non-key frames.
+// The key frame reports progress 1,
+// the N-th non-key frame awaits progress N = s->await_progress
+// and reports progress N + 1.
+s->await_progress = 0;
+}
+
+// reset the frame params
+s->anmf_flags = 0;
+s->width  = 0;
+s->height = 0;
+s->pos_x  = 0;
+s->pos_y  = 0;
+s->has_alpha  = 0;
+
+ret = webp_decode_frame_common(avctx, avpkt->data, avpkt->size, got_frame, 
key_frame);
+if (ret < 0)
+goto end;
+
+if (s->vp8x_flags & VP8X_FLAG_ANIMATION) {
+// VP8 decoder might have changed the width and height of the frame
+AVFrame *frame  = s->frame;
+ret = av_frame_copy_props(canvas, frame);
+if (ret < 0)
+return ret;
+
+ret = ff_set_dimensions(s->avctx, canvas->width, canvas->height);
+if (ret < 0)
+return ret;
+
+s->avctx->pix_fmt = canvas->format;
+}
+
+ff_thread_finish_setup(s->avctx);





1. Up until now, when decoding a series of stand-alone WebP pictures,
the multiple decoder instances don't wait for each other (because the
WebP decoder had no update_thread_context callback). You added such a
callback and now you are calling it after the main picture has already
been decoded, effectively serializing everything. You can test this for
yourself: Create lots of files via ffmpeg -i  -c:v libwebp -f
webp%d.webp and decode them (don't use -stream_loop on a single input
picture, as this will flush the decoder after every single picture, so
that everything is always serialized).
2. To fix this, ff_thread_finish_setup() needs to be called as soon as
possible. This means that you have to abandon the approach of letting
the inner VP8 decoder set the frame dimensions and then overwriting them
again in the WebP decoder.


so I tried to move the ff_thread_finish_setup() call and avoid updating the 
AVCodecContext after decoding.

With the integrated decoder like here, ff_vp8_decode_frame() writes into the 
AVCodecContext while decoding, so ff_thread_finish_setup() can only be called 
afterwards -> quasi sequentially. I do see decoding speed for many files at 
once dropping from 100x to 16x compared to master.

With the decoder decoupled, I can actually move ff_thread_finish_setup() before 
send_packet() (in contrast to v9) -> next thread can start before decoding the 
frame.
I don't see a penalty with that way on decoding many files at once compared to 
master, as expected.

Is that reason enough to actually decouple the vp8 decoder?


Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v10 2/5] libavcodec/webp: add support for animated WebP

2024-02-26 Thread Thilo Borgmann via ffmpeg-devel

Am 19.02.24 um 19:01 schrieb Andreas Rheinhardt:

James Almer:

On 2/19/2024 1:50 PM, Andreas Rheinhardt wrote:

a) Use the receive frame callback for this decoder. This will
necessitate changes to pthread_frame.c (which currently can't handle
receive_frame decoders)


There's a patch for this that i think Anton wrote and then Timo
improved. It was posted sometime ago.


Notice that the BSF I have in mind would not be a public BSF, but a
private one (given that the output of the BSF would be spec-incompliant
due to the wrong ordering it should not be public), i.e. one not
accessible via av_bsf_get_by_name() or av_bsf_iterate().


How do you propose to do this? And would you be willing to write the
framework for it?
It certainly sounds useful, as existing bsfs like vp9_superframe_split
already generate spec non-compliant packets, and they ideally should not
be publicly available.


The way I envision is by using a const FFBitStreamFilter* instead of the
name of the bsf in FFCodec.bsfs. (Of course, one can keep the
open-by-string method (which also works for filterchains as long as they
only use static arguments), too; it is also possible (by currently
unneeded) to add bsfs during init with non-static arguments (based upon
codec options etc.).)
I'd be willing to write the code for this.


If that is useful for other codecs as well, let's do that.
Generating one packet per animation containing all frames+meta should be easy 
enough in the demuxer.

What do you expect the bsf to do exactly?
IIUC generate packets with one frame + meta for all frames in the animation 
from the big packet coming from the demuxer?

Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] GSoC 2024

2024-02-22 Thread Thilo Borgmann via ffmpeg-devel

Am 22.02.24 um 18:49 schrieb Matthias Dressel:

On 22.02.24 18:38, Thilo Borgmann via ffmpeg-devel wrote:

Am 02.01.24 um 22:47 schrieb Thilo Borgmann via ffmpeg-devel:

Hi,

the application period for GSoC 2024 begins on Jan 22nd.

Everyone interested in mentoring a project in 2024, please add your idea(s) to 
[1].



[1] https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2024


we've been selected to participate again in GSoC 2024!

https://summerofcode.withgoogle.com/programs/2024/organizations/ffmpeg
links to the 2023 trac page.


No more!

Thanks,
Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] GSoC 2024

2024-02-22 Thread Thilo Borgmann via ffmpeg-devel

Am 02.01.24 um 22:47 schrieb Thilo Borgmann via ffmpeg-devel:

Hi,

the application period for GSoC 2024 begins on Jan 22nd.

Everyone interested in mentoring a project in 2024, please add your idea(s) to 
[1].



[1] https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2024


we've been selected to participate again in GSoC 2024!

Find all orgs at [2].

Cheers,
Thilo

[2] https://summerofcode.withgoogle.com/programs/2024/organizations

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] .mailmap: update my mailmap entry

2024-02-06 Thread Thilo Borgmann via ffmpeg-devel

Am 05.02.24 um 21:02 schrieb Cosmin Stejerean via ffmpeg-devel:

From: Cosmin Stejerean 

---
  .mailmap | 1 +
  1 file changed, 1 insertion(+)

diff --git a/.mailmap b/.mailmap
index 7546cf0caf..cbe6b3ff99 100644
--- a/.mailmap
+++ b/.mailmap
@@ -22,3 +22,4 @@ rcombs  
   
   
   
+Cosmin Stejerean  Cosmin Stejerean via ffmpeg-devel 



Tested & pushed.

-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v10 3/5] avcodec/webp: make init_canvas_frame static

2024-02-05 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann 

---
 libavcodec/webp.c | 142 +++---
 1 file changed, 70 insertions(+), 72 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 4119ae679d..0931112546 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1358,7 +1358,76 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, 
AVFrame *p,
 return ret;
 }
 
-int init_canvas_frame(WebPContext *s, int format, int key_frame);
+static int init_canvas_frame(WebPContext *s, int format, int key_frame)
+{
+AVFrame *canvas = s->canvas_frame.f;
+int height;
+int ret;
+
+// canvas is needed only for animation
+if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION))
+return 0;
+
+// avoid init for non-key frames whose format and size did not change
+if (!key_frame &&
+canvas->data[0] &&
+canvas->format == format &&
+canvas->width  == s->canvas_width &&
+canvas->height == s->canvas_height)
+return 0;
+
+// canvas changes within IPPP sequences will lose thread sync
+// because of the ThreadFrame reallocation and will wait forever
+// so if frame-threading is used, forbid canvas changes and unlock
+// previous frames
+if (!key_frame && canvas->data[0]) {
+if (s->avctx->thread_count > 1) {
+av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged. Use -threads 1 to try decoding with best effort.\n");
+// unlock previous frames that have sent an _await() call
+ff_thread_report_progress(&s->canvas_frame, INT_MAX, 0);
+return AVERROR_PATCHWELCOME;
+} else {
+// warn for damaged frames
+av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged.\n");
+}
+}
+
+s->avctx->pix_fmt = format;
+canvas->format= format;
+canvas->width = s->canvas_width;
+canvas->height= s->canvas_height;
+
+// VP8 decoder changed the width and height in AVCodecContext.
+// Change it back to the canvas size.
+ret = ff_set_dimensions(s->avctx, s->canvas_width, s->canvas_height);
+if (ret < 0)
+return ret;
+
+ff_thread_release_ext_buffer(&s->canvas_frame);
+ret = ff_thread_get_ext_buffer(s->avctx, &s->canvas_frame, 
AV_GET_BUFFER_FLAG_REF);
+if (ret < 0)
+return ret;
+
+if (canvas->format == AV_PIX_FMT_ARGB) {
+height = canvas->height;
+memset(canvas->data[0], 0, height * canvas->linesize[0]);
+} else /* if (canvas->format == AV_PIX_FMT_YUVA420P) */ {
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(canvas->format);
+for (int comp = 0; comp < desc->nb_components; comp++) {
+int plane = desc->comp[comp].plane;
+
+if (comp == 1 || comp == 2)
+height = AV_CEIL_RSHIFT(canvas->height, desc->log2_chroma_h);
+else
+height = FFALIGN(canvas->height, 1 << desc->log2_chroma_h);
+
+memset(canvas->data[plane], s->transparent_yuva[plane],
+   height * canvas->linesize[plane]);
+}
+}
+
+return 0;
+}
 
 static int webp_decode_frame_common(AVCodecContext *avctx, uint8_t *data, int 
size,
 int *got_frame, int key_frame)
@@ -1597,77 +1666,6 @@ exif_end:
 return size;
 }
 
-int init_canvas_frame(WebPContext *s, int format, int key_frame)
-{
-AVFrame *canvas = s->canvas_frame.f;
-int height;
-int ret;
-
-// canvas is needed only for animation
-if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION))
-return 0;
-
-// avoid init for non-key frames whose format and size did not change
-if (!key_frame &&
-canvas->data[0] &&
-canvas->format == format &&
-canvas->width  == s->canvas_width &&
-canvas->height == s->canvas_height)
-return 0;
-
-// canvas changes within IPPP sequences will loose thread sync
-// because of the ThreadFrame reallocation and will wait forever
-// so if frame-threading is used, forbid canvas changes and unlock
-// previous frames
-if (!key_frame && canvas->data[0]) {
-if (s->avctx->thread_count > 1) {
-av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged. Use -threads 1 to try decoding with best effort.\n");
-// unlock previous frames that have sent an _await() call
-ff_thread_report_progress(&s->canvas_frame, INT_MAX, 0);
-return AVERROR_PATCHWELCOME;
-} else {
-// warn for damaged frames
-av_log(s-&g

[FFmpeg-devel] [PATCH v10 5/5] fate: add test for animated WebP

2024-02-05 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann 

---
 tests/fate/image.mak |  3 +++
 tests/ref/fate/webp-anim | 22 ++
 2 files changed, 25 insertions(+)
 create mode 100644 tests/ref/fate/webp-anim

diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 400199c28a..2e0d1e8e3f 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -567,6 +567,9 @@ fate-webp-rgb-lossy-q80: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/rgb_q80.webp
 FATE_WEBP += fate-webp-rgba-lossy-q80
 fate-webp-rgba-lossy-q80: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/rgba_q80.webp
 
+FATE_WEBP += fate-webp-anim
+fate-webp-anim: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/130227-100431-6817p.webp
+
 FATE_WEBP-$(call DEMDEC, IMAGE2, WEBP) += $(FATE_WEBP)
 FATE_IMAGE_FRAMECRC += $(FATE_WEBP-yes)
 fate-webp: $(FATE_WEBP-yes)
diff --git a/tests/ref/fate/webp-anim b/tests/ref/fate/webp-anim
new file mode 100644
index 00..fe7a53a235
--- /dev/null
+++ b/tests/ref/fate/webp-anim
@@ -0,0 +1,22 @@
+#tb 0: 2/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 100x70
+#sar 0: 0/1
+0,  0,  0,1,28000, 0x2023ba6e
+0,  1,  1,1,28000, 0x4292b778
+0,  2,  2,1,28000, 0x9772a187
+0,  3,  3,1,28000, 0x9599bb3b
+0,  4,  4,1,28000, 0xa1d6b949
+0,  5,  5,1,28000, 0x153bb9fc
+0,  6,  6,1,28000, 0x6ba8d83b
+0,  7,  7,1,28000, 0xed2a4316
+0,  8,  8,   12,28000, 0xe7994c44
+0, 21, 21,1,28000, 0x15ec2f76
+0, 22, 22,1,28000, 0x96522a6b
+0, 23, 23,1,28000, 0xbbae1e30
+0, 24, 24,1,28000, 0xa2baab83
+0, 25, 25,1,28000, 0x09f1aba0
+0, 26, 26,1,28000, 0x09f1aba0
+0, 27, 27,1,28000, 0xe761bbc0
+0, 28, 28,  125,28000, 0xe761bbc0
-- 
2.39.3 (Apple Git-145)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v10 4/5] libavformat/webp: add WebP demuxer

2024-02-05 Thread Thilo Borgmann via ffmpeg-devel
From: Josef Zlomek 

Adds the demuxer of animated WebP files.
It supports non-animated, animated, truncated, and concatenated files.
Reading from a pipe (and other non-seekable inputs) is also supported.

The WebP demuxer splits the input stream into packets containing one frame.
It also marks the key frames properly.
The loop count is ignored by default (same behaviour as animated PNG and GIF),
it may be enabled by the option '-ignore_loop 0'.

The frame rate is set according to the frame delay in the ANMF chunk.
If the delay is too low, or the image is not animated, the default frame rate
is set to 10 fps, similarly to other WebP libraries and browsers.
The fate suite was updated accordingly.

Signed-off-by: Josef Zlomek 
---
 Changelog   |   1 +
 doc/demuxers.texi   |  28 ++
 libavformat/Makefile|   1 +
 libavformat/allformats.c|   1 +
 libavformat/version.h   |   2 +-
 libavformat/webpdec.c   | 383 
 tests/ref/fate/exif-image-webp  |   8 +-
 tests/ref/fate/webp-rgb-lena-lossless   |   2 +-
 tests/ref/fate/webp-rgb-lena-lossless-rgb24 |   2 +-
 tests/ref/fate/webp-rgb-lossless|   2 +-
 tests/ref/fate/webp-rgb-lossy-q80   |   2 +-
 tests/ref/fate/webp-rgba-lossless   |   2 +-
 tests/ref/fate/webp-rgba-lossy-q80  |   2 +-
 13 files changed, 425 insertions(+), 11 deletions(-)
 create mode 100644 libavformat/webpdec.c

diff --git a/Changelog b/Changelog
index 87f4dbdef4..cbf15f028a 100644
--- a/Changelog
+++ b/Changelog
@@ -63,6 +63,7 @@ version 6.1:
   variable-fields elements within the same parent element
 - ffprobe -output_format option added as an alias of -of
 - animated WebP decoder
+- animated WebP demuxer
 
 
 version 6.0:
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index e4c5b560a6..fcb9f9ee3c 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -943,4 +943,32 @@ which in turn, acts as a ceiling for the size of scripts 
that can be read.
 Default is 1 MiB.
 @end table
 
+@section webp
+
+Animated WebP demuxer.
+
+It accepts the following options:
+
+@table @option
+@item -min_delay @var{int}
+Set the minimum valid delay between frames in milliseconds.
+Range is 0 to 6. Default value is 10.
+
+@item -max_webp_delay @var{int}
+Set the maximum valid delay between frames in milliseconds.
+Range is 0 to 16777215. Default value is 16777215 (over four hours),
+the maximum value allowed by the specification.
+
+@item -default_delay @var{int}
+Set the default delay between frames in milliseconds.
+Range is 0 to 6. Default value is 100.
+
+@item -ignore_loop @var{bool}
+WebP files can contain information to loop a certain number of times
+(or infinitely). If @option{ignore_loop} is set to true, then the loop
+setting from the input will be ignored and looping will not occur.
+If set to false, then looping will occur and will cycle the number
+of times according to the WebP. Default value is true.
+@end table
+
 @c man end DEMUXERS
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 05b9b8a115..78ed0977c6 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -622,6 +622,7 @@ OBJS-$(CONFIG_WEBM_MUXER)+= matroskaenc.o 
matroska.o \
 av1.o avlanguage.o
 OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER)  += webmdashenc.o
 OBJS-$(CONFIG_WEBM_CHUNK_MUXER)  += webm_chunk.o
+OBJS-$(CONFIG_WEBP_DEMUXER)  += webpdec.o
 OBJS-$(CONFIG_WEBP_MUXER)+= webpenc.o
 OBJS-$(CONFIG_WEBVTT_DEMUXER)+= webvttdec.o subtitles.o
 OBJS-$(CONFIG_WEBVTT_MUXER)  += webvttenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index b04b43cab3..c6a2308591 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -506,6 +506,7 @@ extern const AVInputFormat  ff_webm_dash_manifest_demuxer;
 extern const FFOutputFormat ff_webm_dash_manifest_muxer;
 extern const FFOutputFormat ff_webm_chunk_muxer;
 extern const FFOutputFormat ff_webp_muxer;
+extern const AVInputFormat  ff_webp_demuxer;
 extern const AVInputFormat  ff_webvtt_demuxer;
 extern const FFOutputFormat ff_webvtt_muxer;
 extern const AVInputFormat  ff_wsaud_demuxer;
diff --git a/libavformat/version.h b/libavformat/version.h
index de9cc8e31d..f4a26c2870 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 #include "version_major.h"
 
 #define LIBAVFORMAT_VERSION_MINOR  20
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
diff --git a/libavformat/webpdec.c b/libavformat/webpdec.c
new file mode 100644
index 00..73c55ee585
--- /dev/null
+++ b/libavformat/webpdec.c
@@ -0,0 +1,383 @@
+/*
+ *

[FFmpeg-devel] [PATCH v10 2/5] libavcodec/webp: add support for animated WebP

2024-02-05 Thread Thilo Borgmann via ffmpeg-devel
From: Josef Zlomek 

Fixes: 4907

Adds support for decoding of animated WebP.

The WebP decoder adds the animation related features according to the specs:
https://developers.google.com/speed/webp/docs/riff_container#animation
The frames of the animation may be smaller than the image canvas.
Therefore, the frame is decoded to a temporary frame,
then it is blended into the canvas, the canvas is copied to the output frame,
and finally the frame is disposed from the canvas.

The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported.
The background color is specified only as BGRA in the WebP file
so it is converted to YUVA if YUV formats are output.

Signed-off-by: Josef Zlomek 
---
 Changelog   |   1 +
 libavcodec/codec_desc.c |   3 +-
 libavcodec/version.h|   2 +-
 libavcodec/webp.c   | 704 +---
 4 files changed, 654 insertions(+), 56 deletions(-)

diff --git a/Changelog b/Changelog
index c5fb21d198..87f4dbdef4 100644
--- a/Changelog
+++ b/Changelog
@@ -62,6 +62,7 @@ version 6.1:
 - ffprobe XML output schema changed to account for multiple
   variable-fields elements within the same parent element
 - ffprobe -output_format option added as an alias of -of
+- animated WebP decoder
 
 
 version 6.0:
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 033344304c..0f72769093 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1259,8 +1259,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "webp",
 .long_name = NULL_IF_CONFIG_SMALL("WebP"),
-.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
- AV_CODEC_PROP_LOSSLESS,
+.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
 .mime_types= MT("image/webp"),
 },
 {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index f2f14eaed1..ecdbc51c74 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 #include "version_major.h"
 
 #define LIBAVCODEC_VERSION_MINOR  39
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 4fd107aa0c..4119ae679d 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -35,12 +35,15 @@
  * Exif metadata
  * ICC profile
  *
+ * @author Josef Zlomek, Pexeso Inc. 
+ * Animation
+ *
  * Unimplemented:
- *   - Animation
  *   - XMP metadata
  */
 
 #include "libavutil/imgutils.h"
+#include "libavutil/colorspace.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
@@ -67,6 +70,14 @@
 #define NUM_SHORT_DISTANCES 120
 #define MAX_HUFFMAN_CODE_LENGTH 15
 
+#define ANMF_DISPOSAL_METHOD0x01
+#define ANMF_DISPOSAL_METHOD_UNCHANGED  0x00
+#define ANMF_DISPOSAL_METHOD_BACKGROUND 0x01
+
+#define ANMF_BLENDING_METHOD0x02
+#define ANMF_BLENDING_METHOD_ALPHA  0x00
+#define ANMF_BLENDING_METHOD_OVERWRITE  0x02
+
 static const uint16_t alphabet_sizes[HUFFMAN_CODES_PER_META_CODE] = {
 NUM_LITERAL_CODES + NUM_LENGTH_CODES,
 NUM_LITERAL_CODES, NUM_LITERAL_CODES, NUM_LITERAL_CODES,
@@ -191,6 +202,8 @@ typedef struct ImageContext {
 typedef struct WebPContext {
 VP8Context v;   /* VP8 Context used for lossy decoding 
*/
 GetBitContext gb;   /* bitstream reader for main image 
chunk */
+ThreadFrame canvas_frame;   /* ThreadFrame for canvas */
+AVFrame *frame; /* AVFrame for decoded frame */
 AVFrame *alpha_frame;   /* AVFrame for alpha data decompressed 
from VP8L */
 AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
 AVCodecContext *avctx;  /* parent AVCodecContext */
@@ -204,7 +217,22 @@ typedef struct WebPContext {
 int has_iccp;   /* set after an ICCP chunk has been 
processed */
 int width;  /* image width */
 int height; /* image height */
-int lossless;   /* indicates lossless or lossy */
+int vp8x_flags; /* global flags from VP8X chunk */
+int canvas_width;   /* canvas width */
+int canvas_height;  /* canvas height */
+int anmf_flags; /* frame flags from ANMF chunk */
+int pos_x;  /* frame position X */
+int pos_y;  /* frame position Y */
+int prev_anmf_flags;/* previous frame flags from ANMF 
chunk */
+int prev_width; /* previous frame width */
+int prev_height;/* previous frame height */
+int prev_pos_x; 

[FFmpeg-devel] [PATCH v10 1/5] avcodec/webp: remove unused definitions

2024-02-05 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann 

---
 libavcodec/webp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 54b3fde6dc..4fd107aa0c 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -59,8 +59,6 @@
 #define VP8X_FLAG_ALPHA 0x10
 #define VP8X_FLAG_ICC   0x20
 
-#define MAX_PALETTE_SIZE256
-#define MAX_CACHE_BITS  11
 #define NUM_CODE_LENGTH_CODES   19
 #define HUFFMAN_CODES_PER_META_CODE 5
 #define NUM_LITERAL_CODES   256
-- 
2.39.3 (Apple Git-145)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v10 0/5] webp: add support for animated WebP decoding

2024-02-05 Thread Thilo Borgmann via ffmpeg-devel
From: Thilo Borgmann 

Still images fixed, includes FATE tests, VP8 decoder not decoupled, fixed more 
asserts, fixed ffprobe regression, removed unnecessary parser changes, put the 
whole animated sequence into one packet.

Patch 4/6 is still there for making changes in lavc/webp reviewable but shall 
be stashed when pushing.

-Thilo


Josef Zlomek (2):
  libavcodec/webp: add support for animated WebP
  libavformat/webp: add WebP demuxer

Thilo Borgmann (3):
  avcodec/webp: remove unused definitions
  avcodec/webp: make init_canvas_frame static
  fate: add test for animated WebP

 Changelog   |   2 +
 doc/demuxers.texi   |  28 +
 libavcodec/codec_desc.c |   3 +-
 libavcodec/version.h|   2 +-
 libavcodec/webp.c   | 698 ++--
 libavformat/Makefile|   1 +
 libavformat/allformats.c|   1 +
 libavformat/version.h   |   2 +-
 libavformat/webpdec.c   | 383 +++
 tests/fate/image.mak|   3 +
 tests/ref/fate/exif-image-webp  |   8 +-
 tests/ref/fate/webp-anim|  22 +
 tests/ref/fate/webp-rgb-lena-lossless   |   2 +-
 tests/ref/fate/webp-rgb-lena-lossless-rgb24 |   2 +-
 tests/ref/fate/webp-rgb-lossless|   2 +-
 tests/ref/fate/webp-rgb-lossy-q80   |   2 +-
 tests/ref/fate/webp-rgba-lossless   |   2 +-
 tests/ref/fate/webp-rgba-lossy-q80  |   2 +-
 18 files changed, 1099 insertions(+), 66 deletions(-)
 create mode 100644 libavformat/webpdec.c
 create mode 100644 tests/ref/fate/webp-anim

-- 
2.39.3 (Apple Git-145)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v9 2/6] avcodec/webp: separate VP8 decoding

2024-02-04 Thread Thilo Borgmann via ffmpeg-devel



On 03.02.24 14:53, Andreas Rheinhardt wrote:

Thilo Borgmann via ffmpeg-devel:

Am 28.01.24 um 11:29 schrieb Anton Khirnov:

Quoting Thilo Borgmann via ffmpeg-devel (2024-01-25 16:39:19)

Am 25.01.24 um 11:04 schrieb Anton Khirnov:

Quoting Thilo Borgmann via ffmpeg-devel (2023-12-31 13:30:14)

---
    libavcodec/webp.c | 50
+--
    1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 4fd107aa0c..58a20b73da 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -194,6 +194,7 @@ typedef struct WebPContext {
    AVFrame *alpha_frame;   /* AVFrame for alpha
data decompressed from VP8L */
    AVPacket *pkt;  /* AVPacket to be passed
to the underlying VP8 decoder */
    AVCodecContext *avctx;  /* parent AVCodecContext */
+    AVCodecContext *avctx_vp8;  /* wrapper context for VP8
decoder */


Nested codec contexts are in general highly undesirable and should be
avoided whenever possible.


AFAICT we do it that way in the other codecs as well (cri, ftr, imm5,
tdsc, tiff). So what do you suggest to do to avoid having it nested?


Integrating the two decoders directly, as is done now.

With nesting it is very tricky to handle all the corner cases properly,
especially passing through all the options to the innner decoder, like
direct rendering, other user callbacks, etc. It should only be done as a
last resort and there should be a strong argument to do it this way.


IIUC that was what the patch still did some some versions ago.
It brought us the data races in animated files, decoupling the decoder
solving the issue.



If one keeps the codecs integrated, then one needs at the very least
change the check for whether to call ff_thread_finish_setup() as I did:
https://ffmpeg.org/pipermail/ffmpeg-devel/2024-January/320490.html
This will not be enough: E.g. changing the dimensions in VP8 code and
then reverting that change in WebP (as has been done in the earlier
version of your patch which made me propose that these decoders should
be separated) will have to be avoided.


I've a version of the animated webp decoder with coupled vp8 decoder 
doing that size change and tsan is happy for me.


I had the impression ff_thread_finish_setup() blew it in the past which 
is now avoided - am I wrong? Once your patches landed I'll post v10 and 
we can check that again.


-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/3] avcodec/vp8: Enforce key-frame only for WebP

2024-02-04 Thread Thilo Borgmann via ffmpeg-devel




On 03.02.24 14:57, Andreas Rheinhardt wrote:

Andreas Rheinhardt:

VP8-in-WebP only uses key frame encoding (see [1]), yet this
is currently not enforced. This commit does so in order to
make output reproducible with frame-threading as the VP8 decoder's
update_thread_context is not called at all when using decoding
VP8-in-WebP (as this is unnecessary for key frame-only streams).

[1]: https://developers.google.com/speed/webp/docs/riff_container

Signed-off-by: Andreas Rheinhardt 
---
  libavcodec/vp8.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 83c60adeb0..7972775a1c 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -2665,7 +2665,11 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame 
*rframe, int *got_frame,
  if (ret < 0)
  goto err;
  
-if (s->actually_webp) {

+if (!is_vp7 && s->actually_webp) {
+// VP8 in WebP is supposed to be intra-only. Enforce this here
+// to ensure that output is reproducible with frame-threading.
+if (!s->keyframe)
+return AVERROR_INVALIDDATA;
  // avctx->pix_fmt already set in caller.
  } else if (!is_vp7 && s->pix_fmt == AV_PIX_FMT_NONE) {
  s->pix_fmt = get_pixel_format(s);


Will apply this patchset tomorrow unless there are objections.


Works as expected for me for a coupled version of the animated webp 
decoder which can follow-up.


Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/2] fate/video: add DXV3 HQ tests

2024-02-01 Thread Thilo Borgmann via ffmpeg-devel

Am 30.01.24 um 22:57 schrieb Connor Worley:

OK, attached are some significantly smaller HQ samples that produce the
same coverage.

5b11c393dda223b5dd198ad2f2576fe2  fate-suite/dxv/dxv3-hqna.mov
3af30eaba2b6ec68a0f5b2c136f4dab6  fate-suite/dxv/dxv3-hqwa.mov


5b11c393dda223b5dd198ad2f2576fe2  download/dxv3-hqna.mov
3af30eaba2b6ec68a0f5b2c136f4dab6  download/dxv3-hqwa.mov

Uploaded.

Thanks,
Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] GSoC 2024

2024-01-30 Thread Thilo Borgmann via ffmpeg-devel

Am 02.01.24 um 23:14 schrieb Thilo Borgmann via ffmpeg-devel:

Am 02.01.24 um 22:47 schrieb Thilo Borgmann via ffmpeg-devel:

Hi,

the application period for GSoC 2024 begins on Jan 22nd.

Everyone interested in mentoring a project in 2024, please add your idea(s) to 
[1].

The application deadline is February 6th, I will aim for sending an application 
Jan 1st.


Aiming for Feb 1st, obviously 0:-)


Reminder, add your GSoC project ideas soon if you want to do one.
Going to submit the application soon!

-Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/2] fate/video: add DXV3 HQ tests

2024-01-30 Thread Thilo Borgmann via ffmpeg-devel

Am 30.01.24 um 21:53 schrieb Connor Worley:

In that case, it is probably worth replacing the existing "normal quality"
samples as they're even larger.
dxv3-nqwa.mov does not adequately exercise the code fixed in
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20240130062626.98273-1-connorbwor...@gmail.com/
I'm not sure what the process for removing samples from fate-suite is.



The new ones are around 75K, not too big IMO.

Can the new samples cover the same use-cases like the old ones as well?
If we don't loose the old coverage, I can delete the unnecessary ones.

-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v9 2/6] avcodec/webp: separate VP8 decoding

2024-01-30 Thread Thilo Borgmann via ffmpeg-devel

Am 28.01.24 um 11:29 schrieb Anton Khirnov:

Quoting Thilo Borgmann via ffmpeg-devel (2024-01-25 16:39:19)

Am 25.01.24 um 11:04 schrieb Anton Khirnov:

Quoting Thilo Borgmann via ffmpeg-devel (2023-12-31 13:30:14)

---
   libavcodec/webp.c | 50 +--
   1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 4fd107aa0c..58a20b73da 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -194,6 +194,7 @@ typedef struct WebPContext {
   AVFrame *alpha_frame;   /* AVFrame for alpha data 
decompressed from VP8L */
   AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
   AVCodecContext *avctx;  /* parent AVCodecContext */
+AVCodecContext *avctx_vp8;  /* wrapper context for VP8 decoder */


Nested codec contexts are in general highly undesirable and should be
avoided whenever possible.


AFAICT we do it that way in the other codecs as well (cri, ftr, imm5,
tdsc, tiff). So what do you suggest to do to avoid having it nested?


Integrating the two decoders directly, as is done now.

With nesting it is very tricky to handle all the corner cases properly,
especially passing through all the options to the innner decoder, like
direct rendering, other user callbacks, etc. It should only be done as a
last resort and there should be a strong argument to do it this way.


IIUC that was what the patch still did some some versions ago.
It brought us the data races in animated files, decoupling the decoder solving 
the issue.

-Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v9 2/6] avcodec/webp: separate VP8 decoding

2024-01-25 Thread Thilo Borgmann via ffmpeg-devel

Am 25.01.24 um 11:04 schrieb Anton Khirnov:

Quoting Thilo Borgmann via ffmpeg-devel (2023-12-31 13:30:14)

---
  libavcodec/webp.c | 50 +--
  1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 4fd107aa0c..58a20b73da 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -194,6 +194,7 @@ typedef struct WebPContext {
  AVFrame *alpha_frame;   /* AVFrame for alpha data 
decompressed from VP8L */
  AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
  AVCodecContext *avctx;  /* parent AVCodecContext */
+AVCodecContext *avctx_vp8;  /* wrapper context for VP8 decoder */


Nested codec contexts are in general highly undesirable and should be
avoided whenever possible.


AFAICT we do it that way in the other codecs as well (cri, ftr, imm5, tdsc, 
tiff). So what do you suggest to do to avoid having it nested?

-Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] Revert "doc/faq: replace non-breaking spaces (0xA0) with normal space"

2024-01-07 Thread Thilo Borgmann via ffmpeg-devel

Am 07.01.24 um 13:12 schrieb Stefano Sabatini:

On date Saturday 2024-01-06 15:49:56 -0600, Marth64 wrote:

This reverts commit 6442d1ddd62160e96c686c30648b6111e3e0c264.

A valid point was made, that the non-breaking space will cause this text
to render better by ensuring the unit never seperates from the number.


I'm not convinced the non-breaking space was a good idea in the first
place, the fact that there is a single instance in the whole
documentation confirms this.

In fact even if the unit and value are not on the same line we don't
miss much in terms of readability.

On the other hand it is very hard to edit such non-printable
characters, and you can bet what as much as you can that most
contributors will not get it right or consistent.


I think we could use @tie{} instead of an invisible 0xA0 wherever we want 
non-breaking spaces.
Even if we seem not to care much about these in the docs.

-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v3 1/2] avfilter: Add fsync filter

2024-01-07 Thread Thilo Borgmann via ffmpeg-devel

Am 06.01.24 um 18:39 schrieb James Almer:

On 12/16/2023 5:13 AM, Thilo Borgmann via ffmpeg-devel wrote:

---
  Changelog    |   1 +
  MAINTAINERS  |   1 +
  configure    |   2 +
  doc/filters.texi |  33 +
  libavfilter/Makefile |   1 +
  libavfilter/allfilters.c |   1 +
  libavfilter/version.h    |   2 +-
  libavfilter/vf_fsync.c   | 286 +++
  8 files changed, 326 insertions(+), 1 deletion(-)
  create mode 100644 libavfilter/vf_fsync.c


[...]


+static int activate(AVFilterContext *ctx)
+{
+    FsyncContext *s   = ctx->priv;
+    AVFilterLink *inlink  = ctx->inputs[0];
+    AVFilterLink *outlink = ctx->outputs[0];
+
+    int ret, line_count;
+    AVFrame *frame;
+
+    FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
+
+    buf_skip_eol(s);
+    line_count = buf_get_line_count(s);
+    if (line_count < 0) {
+    line_count = buf_reload(s);
+    if (line_count < 0)
+    return line_count;
+    line_count = buf_get_line_count(s);
+    if (line_count < 0)
+    return line_count;
+    }
+
+    if (avio_feof(s->avio_ctx) && buf_get_zero(s) < 3) {
+    av_log(ctx, AV_LOG_DEBUG, "End of file. To zero = %i\n", 
buf_get_zero(s));
+    goto end;
+    }
+
+    if (s->last_frame) {
+    ret = av_sscanf(s->cur, "%"PRId64" %"PRId64" %d/%d", &s->ptsi, &s->pts, 
&s->tb_num, &s->tb_den);
+    if (ret != 4) {
+    av_log(ctx, AV_LOG_ERROR, "Unexpected format found (%i / 4).\n", 
ret);
+    ff_outlink_set_status(outlink, AVERROR_INVALIDDATA, 
AV_NOPTS_VALUE);
+    return AVERROR_INVALIDDATA;
+    }
+
+    av_log(ctx, AV_LOG_DEBUG, "frame %lli ", s->last_frame->pts);
+
+    if (s->last_frame->pts >= s->ptsi) {
+    av_log(ctx, AV_LOG_DEBUG, ">= %lli: DUP LAST with pts = %lli\n", 
s->ptsi, s->pts);
+
+    // clone frame
+    frame = av_frame_clone(s->last_frame);
+    if (!frame) {
+    ff_outlink_set_status(outlink, AVERROR(ENOMEM), 
AV_NOPTS_VALUE);
+    return AVERROR(ENOMEM);
+    }
+
+    // set output pts and timebase
+    frame->pts = s->pts;
+    frame->time_base = av_make_q((int)s->tb_num, (int)s->tb_den);
+
+    // advance cur to eol, skip over eol in the next call
+    s->cur += line_count;
+
+    // call again
+    if (ff_inoutlink_check_flow(inlink, outlink))
+    ff_filter_set_ready(ctx, 100);
+
+    // filter frame
+    return ff_filter_frame(outlink, frame);
+    } else if (s->last_frame->pts < s->ptsi) {
+    av_log(ctx, AV_LOG_DEBUG, "<  %lli: DROP\n", s->ptsi);
+    av_frame_free(&s->last_frame);
+
+    // call again
+    if (ff_inoutlink_check_flow(inlink, outlink))
+    ff_filter_set_ready(ctx, 100);
+
+    return 0;
+    }
+    }
+
+end:
+    ret = ff_inlink_consume_frame(inlink, &s->last_frame);


There's a leak in this filter, and i suspect it's here. If s->last_frame is not 
NULL, the pointer will be rewritten and the frame will leak.

http://fate.ffmpeg.org/history.cgi?slot=x86_64-archlinux-gcc-valgrind-no-undef


Indeed - fixed & pushed.

Thanks,
Thilo


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v3 1/2] avfilter: Add fsync filter

2024-01-05 Thread Thilo Borgmann via ffmpeg-devel

Am 31.12.23 um 13:31 schrieb Thilo Borgmann via ffmpeg-devel:

Am 18.12.23 um 12:02 schrieb Thilo Borgmann via ffmpeg-devel:

Am 17.12.23 um 23:51 schrieb Michael Niedermayer:

On Sat, Dec 16, 2023 at 09:13:21AM +0100, Thilo Borgmann via ffmpeg-devel wrote:
[...]


+// get number of bytes from cur to '\0'
+static int buf_get_zero(FsyncContext *ctx)


maybe doxygen syntax would make sense for comments descrining functions
its not public api but still maybe


Better still. Done.



+{
+    return av_strnlen(ctx->cur, ctx->end - ctx->cur);
+}
+

[...]

+    if (s->last_frame) {
+    ret = av_sscanf(s->cur, "%"PRId64" %"PRId64" %d/%d", &s->ptsi, &s->pts, 
&s->tb_num, &s->tb_den);
+    if (ret != 4) {
+    av_log(ctx, AV_LOG_ERROR, "Unexpected format found (%i / 4).\n", 
ret);
+    ff_outlink_set_status(outlink, AVERROR_INVALIDDATA, 
AV_NOPTS_VALUE);
+    return AVERROR_INVALIDDATA;
+    }
+
+    av_log(ctx, AV_LOG_DEBUG, "frame %lli ", s->last_frame->pts);


warning: format ‘%lli’ expects argument of type ‘long long int’, but argument 4 
has type ‘int64_t {aka long int}’ [-Wformat=]

"%"PRIi64 / "%"PRId64 / "%"PRIu64 / "%"PRIx64


"%"PRId64 it shall be here and for the other DEBUG logs.

All done locally, I'd appreciate if someone could test this on Windows, I'm 
curious about line endings in the map file...


Will push this soon if there are no further comments.


Pushed.

Thanks,
Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v3] GSoC 2023: Add Audio Overlay Filter

2024-01-03 Thread Thilo Borgmann via ffmpeg-devel

Am 03.01.24 um 11:45 schrieb Gyan Doshi:



On 2024-01-03 03:46 pm, Thilo Borgmann via ffmpeg-devel wrote:

Am 03.01.24 um 11:10 schrieb Gyan Doshi:



On 2024-01-03 02:28 pm, Thilo Borgmann via ffmpeg-devel wrote:

Am 01.12.23 um 12:37 schrieb Paul B Mahol:

On Fri, Dec 1, 2023 at 12:24 PM Gyan Doshi  wrote:




On 2023-09-25 11:35 pm, Paul B Mahol wrote:

On 9/11/23, Harshit Karwal  wrote:

1. Replaced ring buffer ADT with AVAudioFifo from libavutil/audio_fifo.h
2. Fixed potential freeing of uninitialised pointers in uninit
3. Minor changes like removing unused headers

Will apply with more fixes soon.


Ping. Looks to be a useful filter.



After documentation general fixes are in master.


Ping again.
What documentation fixes we were waiting for here?


All the missing entries for (de)muxers, (de/en)coders ..etc.


I don't really understand. Missing (de)muxer & (de/en)coders docs are blocking 
this filter? Do I miss a connection?
Is there some discussion regarding that on the list somewhere?


I was in the process of doc completion a few years ago when the pandemic hit, 
and I lost track of that. He made integrating
this filter conditional on me resuming that effort. I intend to do so but can't 
commit to a firm timeline.


It would be nice if you would resume on that or post the status quo you already 
have which is still an enhancement.
It is not a reason for blocking a new filter coming in.



Of course, if Paul isn't coming back, someone else will have to push anyway.


I pinged Paul about it, let's see if he's still interested.

In any way, I asked Harshit to add some tests to this filter to make it more 
complete.
Once that is done, and Paul has no more interest in it, we should proceed with 
this.

Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v3] GSoC 2023: Add Audio Overlay Filter

2024-01-03 Thread Thilo Borgmann via ffmpeg-devel

Am 03.01.24 um 11:10 schrieb Gyan Doshi:



On 2024-01-03 02:28 pm, Thilo Borgmann via ffmpeg-devel wrote:

Am 01.12.23 um 12:37 schrieb Paul B Mahol:

On Fri, Dec 1, 2023 at 12:24 PM Gyan Doshi  wrote:




On 2023-09-25 11:35 pm, Paul B Mahol wrote:

On 9/11/23, Harshit Karwal  wrote:

1. Replaced ring buffer ADT with AVAudioFifo from libavutil/audio_fifo.h
2. Fixed potential freeing of uninitialised pointers in uninit
3. Minor changes like removing unused headers

Will apply with more fixes soon.


Ping. Looks to be a useful filter.



After documentation general fixes are in master.


Ping again.
What documentation fixes we were waiting for here?


All the missing entries for (de)muxers, (de/en)coders ..etc.


I don't really understand. Missing (de)muxer & (de/en)coders docs are blocking 
this filter? Do I miss a connection?
Is there some discussion regarding that on the list somewhere?

Thanks,
Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v3] GSoC 2023: Add Audio Overlay Filter

2024-01-03 Thread Thilo Borgmann via ffmpeg-devel

Am 01.12.23 um 12:37 schrieb Paul B Mahol:

On Fri, Dec 1, 2023 at 12:24 PM Gyan Doshi  wrote:




On 2023-09-25 11:35 pm, Paul B Mahol wrote:

On 9/11/23, Harshit Karwal  wrote:

1. Replaced ring buffer ADT with AVAudioFifo from libavutil/audio_fifo.h
2. Fixed potential freeing of uninitialised pointers in uninit
3. Minor changes like removing unused headers

Will apply with more fixes soon.


Ping. Looks to be a useful filter.



After documentation general fixes are in master.


Ping again.
What documentation fixes we were waiting for here?

-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] GSoC 2024

2024-01-02 Thread Thilo Borgmann via ffmpeg-devel

Am 02.01.24 um 22:47 schrieb Thilo Borgmann via ffmpeg-devel:

Hi,

the application period for GSoC 2024 begins on Jan 22nd.

Everyone interested in mentoring a project in 2024, please add your idea(s) to 
[1].

The application deadline is February 6th, I will aim for sending an application 
Jan 1st.


Aiming for Feb 1st, obviously 0:-)

-Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] GSoC 2024

2024-01-02 Thread Thilo Borgmann via ffmpeg-devel

Hi,

the application period for GSoC 2024 begins on Jan 22nd.

Everyone interested in mentoring a project in 2024, please add your idea(s) to 
[1].

The application deadline is February 6th, I will aim for sending an application 
Jan 1st.

Thanks,
Thilo

[1] https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2024
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v9 5/6] libavformat/webp: add WebP demuxer

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel

Am 31.12.23 um 13:59 schrieb Tomas Härdin:

sön 2023-12-31 klockan 13:30 +0100 skrev Thilo Borgmann via ffmpeg-
devel:

From: Josef Zlomek 

Adds the demuxer of animated WebP files.
It supports non-animated, animated, truncated, and concatenated
files.
Reading from a pipe (and other non-seekable inputs) is also
supported.

The WebP demuxer splits the input stream into packets containing one
frame.
It also marks the key frames properly.
The loop count is ignored by default (same behaviour as animated PNG
and GIF),
it may be enabled by the option '-ignore_loop 0'.


Should format duration not also be set accordingly? I don't see
anything setting it at all, only packet duration


Locally done to set AVStream->duration and ->avg_frame_rate the same way as GIF 
does.

Thanks,
Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v9 3/6] libavcodec/webp: add support for animated WebP

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel


Am 31.12.23 um 13:56 schrieb Tomas Härdin:

+for (int y = 0; y < height; y++) {
+const uint8_t *src1 = src1_data[0] + y * src1_linesize[0];
+const uint8_t *src2 = src2_data[0] + (y + pos_y) *
src2_linesize[0] + pos_x * src2_step[0];
+uint8_t   *dest = dest_data[0] + (y + pos_y) *
dest_linesize[0] + pos_x * sizeof(uint32_t);
+for (int x = 0; x < width; x++) {
+int src1_alpha = src1[0];
+int src2_alpha = src2[0];
+
+if (src1_alpha == 255) {
+memcpy(dest, src1, sizeof(uint32_t));
+} else if (src1_alpha + src2_alpha == 0) {
+memset(dest, 0, sizeof(uint32_t));
+} else {
+int tmp_alpha = src2_alpha - ROUNDED_DIV(src1_alpha
* src2_alpha, 255);
+int blend_alpha = src1_alpha + tmp_alpha;
+
+dest[0] = blend_alpha;
+dest[1] = ROUNDED_DIV(src1[1] * src1_alpha + src2[1]
* tmp_alpha, blend_alpha);
+dest[2] = ROUNDED_DIV(src1[2] * src1_alpha + src2[2]
* tmp_alpha, blend_alpha);
+dest[3] = ROUNDED_DIV(src1[3] * src1_alpha + src2[3]
* tmp_alpha, blend_alpha);
+}


Is branching and a bunch of function calls (which I hope get optimized
out) really faster than just always doing the blending?


If I trust my START_TIMER/STOP_TIMER interpretation, I'd say so:

With branches:
253315 UNITS in blend_alpha_yuva, 128 runs,  0 skips

Always blending:
351104 UNITS in blend_alpha_yuva, 128 runs,  0 skips




It mgiht also be worthwhile to check 8 bytes at a time against
UINT64_MAX and 0. That doesn't need to hold up this patch though. Same
with the YUVA version.


+static int blend_frame_into_canvas(WebPContext *s)
+{
+AVFrame *canvas = s->canvas_frame.f;
+AVFrame *frame  = s->frame;
+int width, height;
+int pos_x, pos_y;
+
+if ((s->anmf_flags & ANMF_BLENDING_METHOD) ==
ANMF_BLENDING_METHOD_OVERWRITE
+|| frame->format == AV_PIX_FMT_YUV420P) {
+// do not blend, overwrite
+
+if (canvas->format == AV_PIX_FMT_ARGB) {
+width  = s->width;
+height = s->height;
+pos_x  = s->pos_x;
+pos_y  = s->pos_y;
+
+for (int y = 0; y < height; y++) {
+const uint32_t *src = (uint32_t *) (frame->data[0] +
y * frame->linesize[0]);
+uint32_t *dst = (uint32_t *) (canvas->data[0] + (y +
pos_y) * canvas->linesize[0]) + pos_x;
+memcpy(dst, src, width * sizeof(uint32_t));
+}


This could be reduced to a single memcpy() when linesizes are equal.
Same for the other memcpy()s


Its a subimage copied into a canvas (see pos_x and pos_y).
Has to be copied line-by-line.

Same for the other loops.

-Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v3 1/2] avfilter: Add fsync filter

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel

Am 18.12.23 um 12:02 schrieb Thilo Borgmann via ffmpeg-devel:

Am 17.12.23 um 23:51 schrieb Michael Niedermayer:

On Sat, Dec 16, 2023 at 09:13:21AM +0100, Thilo Borgmann via ffmpeg-devel wrote:
[...]


+// get number of bytes from cur to '\0'
+static int buf_get_zero(FsyncContext *ctx)


maybe doxygen syntax would make sense for comments descrining functions
its not public api but still maybe


Better still. Done.



+{
+    return av_strnlen(ctx->cur, ctx->end - ctx->cur);
+}
+

[...]

+    if (s->last_frame) {
+    ret = av_sscanf(s->cur, "%"PRId64" %"PRId64" %d/%d", &s->ptsi, &s->pts, 
&s->tb_num, &s->tb_den);
+    if (ret != 4) {
+    av_log(ctx, AV_LOG_ERROR, "Unexpected format found (%i / 4).\n", 
ret);
+    ff_outlink_set_status(outlink, AVERROR_INVALIDDATA, 
AV_NOPTS_VALUE);
+    return AVERROR_INVALIDDATA;
+    }
+
+    av_log(ctx, AV_LOG_DEBUG, "frame %lli ", s->last_frame->pts);


warning: format ‘%lli’ expects argument of type ‘long long int’, but argument 4 
has type ‘int64_t {aka long int}’ [-Wformat=]

"%"PRIi64 / "%"PRId64 / "%"PRIu64 / "%"PRIx64


"%"PRId64 it shall be here and for the other DEBUG logs.

All done locally, I'd appreciate if someone could test this on Windows, I'm 
curious about line endings in the map file...


Will push this soon if there are no further comments.

-Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v9 5/6] libavformat/webp: add WebP demuxer

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel
From: Josef Zlomek 

Adds the demuxer of animated WebP files.
It supports non-animated, animated, truncated, and concatenated files.
Reading from a pipe (and other non-seekable inputs) is also supported.

The WebP demuxer splits the input stream into packets containing one frame.
It also marks the key frames properly.
The loop count is ignored by default (same behaviour as animated PNG and GIF),
it may be enabled by the option '-ignore_loop 0'.

The frame rate is set according to the frame delay in the ANMF chunk.
If the delay is too low, or the image is not animated, the default frame rate
is set to 10 fps, similarly to other WebP libraries and browsers.
The fate suite was updated accordingly.

Signed-off-by: Josef Zlomek 
---
 Changelog   |   1 +
 doc/demuxers.texi   |  28 ++
 libavformat/Makefile|   1 +
 libavformat/allformats.c|   1 +
 libavformat/version.h   |   2 +-
 libavformat/webpdec.c   | 383 
 tests/ref/fate/exif-image-webp  |   8 +-
 tests/ref/fate/webp-rgb-lena-lossless   |   2 +-
 tests/ref/fate/webp-rgb-lena-lossless-rgb24 |   2 +-
 tests/ref/fate/webp-rgb-lossless|   2 +-
 tests/ref/fate/webp-rgb-lossy-q80   |   2 +-
 tests/ref/fate/webp-rgba-lossless   |   2 +-
 tests/ref/fate/webp-rgba-lossy-q80  |   2 +-
 13 files changed, 425 insertions(+), 11 deletions(-)
 create mode 100644 libavformat/webpdec.c

diff --git a/Changelog b/Changelog
index 58ed906f86..0a15cbd4f8 100644
--- a/Changelog
+++ b/Changelog
@@ -52,6 +52,7 @@ version 6.1:
   variable-fields elements within the same parent element
 - ffprobe -output_format option added as an alias of -of
 - animated WebP decoder
+- animated WebP demuxer
 
 
 version 6.0:
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index e4c5b560a6..fcb9f9ee3c 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -943,4 +943,32 @@ which in turn, acts as a ceiling for the size of scripts 
that can be read.
 Default is 1 MiB.
 @end table
 
+@section webp
+
+Animated WebP demuxer.
+
+It accepts the following options:
+
+@table @option
+@item -min_delay @var{int}
+Set the minimum valid delay between frames in milliseconds.
+Range is 0 to 6. Default value is 10.
+
+@item -max_webp_delay @var{int}
+Set the maximum valid delay between frames in milliseconds.
+Range is 0 to 16777215. Default value is 16777215 (over four hours),
+the maximum value allowed by the specification.
+
+@item -default_delay @var{int}
+Set the default delay between frames in milliseconds.
+Range is 0 to 6. Default value is 100.
+
+@item -ignore_loop @var{bool}
+WebP files can contain information to loop a certain number of times
+(or infinitely). If @option{ignore_loop} is set to true, then the loop
+setting from the input will be ignored and looping will not occur.
+If set to false, then looping will occur and will cycle the number
+of times according to the WebP. Default value is true.
+@end table
+
 @c man end DEMUXERS
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 581e378d95..29d78eba3f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -621,6 +621,7 @@ OBJS-$(CONFIG_WEBM_MUXER)+= matroskaenc.o 
matroska.o \
 av1.o avlanguage.o
 OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER)  += webmdashenc.o
 OBJS-$(CONFIG_WEBM_CHUNK_MUXER)  += webm_chunk.o
+OBJS-$(CONFIG_WEBP_DEMUXER)  += webpdec.o
 OBJS-$(CONFIG_WEBP_MUXER)+= webpenc.o
 OBJS-$(CONFIG_WEBVTT_DEMUXER)+= webvttdec.o subtitles.o
 OBJS-$(CONFIG_WEBVTT_MUXER)  += webvttenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index ce6be5f04d..621d9b0383 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -505,6 +505,7 @@ extern const AVInputFormat  ff_webm_dash_manifest_demuxer;
 extern const FFOutputFormat ff_webm_dash_manifest_muxer;
 extern const FFOutputFormat ff_webm_chunk_muxer;
 extern const FFOutputFormat ff_webp_muxer;
+extern const AVInputFormat  ff_webp_demuxer;
 extern const AVInputFormat  ff_webvtt_demuxer;
 extern const FFOutputFormat ff_webvtt_muxer;
 extern const AVInputFormat  ff_wsaud_demuxer;
diff --git a/libavformat/version.h b/libavformat/version.h
index de9cc8e31d..f4a26c2870 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 #include "version_major.h"
 
 #define LIBAVFORMAT_VERSION_MINOR  20
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
diff --git a/libavformat/webpdec.c b/libavformat/webpdec.c
new file mode 100644
index 00..73c55ee585
--- /dev/null
+++ b/libavformat/webpdec.c
@@ -0,0 +1,383 @@
+/*
+ *

[FFmpeg-devel] [PATCH v9 6/6] fate: add test for animated WebP

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel
---
 tests/fate/image.mak |  3 +++
 tests/ref/fate/webp-anim | 22 ++
 2 files changed, 25 insertions(+)
 create mode 100644 tests/ref/fate/webp-anim

diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 400199c28a..2e0d1e8e3f 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -567,6 +567,9 @@ fate-webp-rgb-lossy-q80: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/rgb_q80.webp
 FATE_WEBP += fate-webp-rgba-lossy-q80
 fate-webp-rgba-lossy-q80: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/rgba_q80.webp
 
+FATE_WEBP += fate-webp-anim
+fate-webp-anim: CMD = framecrc -i 
$(TARGET_SAMPLES)/webp/130227-100431-6817p.webp
+
 FATE_WEBP-$(call DEMDEC, IMAGE2, WEBP) += $(FATE_WEBP)
 FATE_IMAGE_FRAMECRC += $(FATE_WEBP-yes)
 fate-webp: $(FATE_WEBP-yes)
diff --git a/tests/ref/fate/webp-anim b/tests/ref/fate/webp-anim
new file mode 100644
index 00..fe7a53a235
--- /dev/null
+++ b/tests/ref/fate/webp-anim
@@ -0,0 +1,22 @@
+#tb 0: 2/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 100x70
+#sar 0: 0/1
+0,  0,  0,1,28000, 0x2023ba6e
+0,  1,  1,1,28000, 0x4292b778
+0,  2,  2,1,28000, 0x9772a187
+0,  3,  3,1,28000, 0x9599bb3b
+0,  4,  4,1,28000, 0xa1d6b949
+0,  5,  5,1,28000, 0x153bb9fc
+0,  6,  6,1,28000, 0x6ba8d83b
+0,  7,  7,1,28000, 0xed2a4316
+0,  8,  8,   12,28000, 0xe7994c44
+0, 21, 21,1,28000, 0x15ec2f76
+0, 22, 22,1,28000, 0x96522a6b
+0, 23, 23,1,28000, 0xbbae1e30
+0, 24, 24,1,28000, 0xa2baab83
+0, 25, 25,1,28000, 0x09f1aba0
+0, 26, 26,1,28000, 0x09f1aba0
+0, 27, 27,1,28000, 0xe761bbc0
+0, 28, 28,  125,28000, 0xe761bbc0
-- 
2.37.1 (Apple Git-137.1)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v9 2/6] avcodec/webp: separate VP8 decoding

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel
---
 libavcodec/webp.c | 50 +--
 1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 4fd107aa0c..58a20b73da 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -194,6 +194,7 @@ typedef struct WebPContext {
 AVFrame *alpha_frame;   /* AVFrame for alpha data decompressed 
from VP8L */
 AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
 AVCodecContext *avctx;  /* parent AVCodecContext */
+AVCodecContext *avctx_vp8;  /* wrapper context for VP8 decoder */
 int initialized;/* set once the VP8 context is 
initialized */
 int has_alpha;  /* has a separate alpha chunk */
 enum AlphaCompression alpha_compression; /* compression type for alpha 
chunk */
@@ -1298,12 +1299,13 @@ static int vp8_lossy_decode_frame(AVCodecContext 
*avctx, AVFrame *p,
 int ret;
 
 if (!s->initialized) {
-ff_vp8_decode_init(avctx);
+VP8Context *s_vp8 = s->avctx_vp8->priv_data;
+s_vp8->actually_webp = 1;
 s->initialized = 1;
-s->v.actually_webp = 1;
 }
 avctx->pix_fmt = s->has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P;
 s->lossless = 0;
+s->avctx_vp8->pix_fmt = avctx->pix_fmt;
 
 if (data_size > INT_MAX) {
 av_log(avctx, AV_LOG_ERROR, "unsupported chunk size\n");
@@ -1314,14 +1316,32 @@ static int vp8_lossy_decode_frame(AVCodecContext 
*avctx, AVFrame *p,
 s->pkt->data = data_start;
 s->pkt->size = data_size;
 
-ret = ff_vp8_decode_frame(avctx, p, got_frame, s->pkt);
-if (ret < 0)
+ret = avcodec_send_packet(s->avctx_vp8, s->pkt);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for 
decoding\n");
 return ret;
+}
 
-if (!*got_frame)
+ret = avcodec_receive_frame(s->avctx_vp8, p);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "VP8 decoding error: %s.\n", 
av_err2str(ret));
 return AVERROR_INVALIDDATA;
+}
+
+ret = ff_decode_frame_props(avctx, p);
+if (ret < 0) {
+return ret;
+}
+
+if (!p->private_ref) {
+ret = ff_attach_decode_data(p);
+if (ret < 0) {
+return ret;
+}
+}
 
-update_canvas_size(avctx, avctx->width, avctx->height);
+*got_frame = 1;
+update_canvas_size(avctx, s->avctx_vp8->width, s->avctx_vp8->height);
 
 if (s->has_alpha) {
 ret = vp8_lossy_decode_alpha(avctx, p, s->alpha_data,
@@ -1533,11 +1553,28 @@ exif_end:
 static av_cold int webp_decode_init(AVCodecContext *avctx)
 {
 WebPContext *s = avctx->priv_data;
+int ret;
+const AVCodec *codec;
 
 s->pkt = av_packet_alloc();
 if (!s->pkt)
 return AVERROR(ENOMEM);
 
+
+/* Prepare everything needed for VP8 decoding */
+codec = avcodec_find_decoder(AV_CODEC_ID_VP8);
+if (!codec)
+return AVERROR_BUG;
+s->avctx_vp8 = avcodec_alloc_context3(codec);
+if (!s->avctx_vp8)
+return AVERROR(ENOMEM);
+s->avctx_vp8->flags = avctx->flags;
+s->avctx_vp8->flags2 = avctx->flags2;
+s->avctx_vp8->pix_fmt = avctx->pix_fmt;
+ret = avcodec_open2(s->avctx_vp8, codec, NULL);
+if (ret < 0) {
+return ret;
+}
 return 0;
 }
 
@@ -1546,6 +1583,7 @@ static av_cold int webp_decode_close(AVCodecContext 
*avctx)
 WebPContext *s = avctx->priv_data;
 
 av_packet_free(&s->pkt);
+avcodec_free_context(&s->avctx_vp8);
 
 if (s->initialized)
 return ff_vp8_decode_free(avctx);
-- 
2.37.1 (Apple Git-137.1)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v9 4/6] avcodec/webp: make init_canvas_frame static

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel
---
 libavcodec/webp.c | 142 +++---
 1 file changed, 70 insertions(+), 72 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 4f989b8f0a..a2e6e199a7 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1378,7 +1378,76 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, 
AVFrame *p,
 return ret;
 }
 
-int init_canvas_frame(WebPContext *s, int format, int key_frame);
+static int init_canvas_frame(WebPContext *s, int format, int key_frame)
+{
+AVFrame *canvas = s->canvas_frame.f;
+int height;
+int ret;
+
+// canvas is needed only for animation
+if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION))
+return 0;
+
+// avoid init for non-key frames whose format and size did not change
+if (!key_frame &&
+canvas->data[0] &&
+canvas->format == format &&
+canvas->width  == s->canvas_width &&
+canvas->height == s->canvas_height)
+return 0;
+
+// canvas changes within IPPP sequences will lose thread sync
+// because of the ThreadFrame reallocation and will wait forever
+// so if frame-threading is used, forbid canvas changes and unlock
+// previous frames
+if (!key_frame && canvas->data[0]) {
+if (s->avctx->thread_count > 1) {
+av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged. Use -threads 1 to try decoding with best effort.\n");
+// unlock previous frames that have sent an _await() call
+ff_thread_report_progress(&s->canvas_frame, INT_MAX, 0);
+return AVERROR_PATCHWELCOME;
+} else {
+// warn for damaged frames
+av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged.\n");
+}
+}
+
+s->avctx->pix_fmt = format;
+canvas->format= format;
+canvas->width = s->canvas_width;
+canvas->height= s->canvas_height;
+
+// VP8 decoder changed the width and height in AVCodecContext.
+// Change it back to the canvas size.
+ret = ff_set_dimensions(s->avctx, s->canvas_width, s->canvas_height);
+if (ret < 0)
+return ret;
+
+ff_thread_release_ext_buffer(&s->canvas_frame);
+ret = ff_thread_get_ext_buffer(s->avctx, &s->canvas_frame, 
AV_GET_BUFFER_FLAG_REF);
+if (ret < 0)
+return ret;
+
+if (canvas->format == AV_PIX_FMT_ARGB) {
+height = canvas->height;
+memset(canvas->data[0], 0, height * canvas->linesize[0]);
+} else /* if (canvas->format == AV_PIX_FMT_YUVA420P) */ {
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(canvas->format);
+for (int comp = 0; comp < desc->nb_components; comp++) {
+int plane = desc->comp[comp].plane;
+
+if (comp == 1 || comp == 2)
+height = AV_CEIL_RSHIFT(canvas->height, desc->log2_chroma_h);
+else
+height = FFALIGN(canvas->height, 1 << desc->log2_chroma_h);
+
+memset(canvas->data[plane], s->transparent_yuva[plane],
+   height * canvas->linesize[plane]);
+}
+}
+
+return 0;
+}
 
 static int webp_decode_frame_common(AVCodecContext *avctx, uint8_t *data, int 
size,
 int *got_frame, int key_frame)
@@ -1617,77 +1686,6 @@ exif_end:
 return size;
 }
 
-int init_canvas_frame(WebPContext *s, int format, int key_frame)
-{
-AVFrame *canvas = s->canvas_frame.f;
-int height;
-int ret;
-
-// canvas is needed only for animation
-if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION))
-return 0;
-
-// avoid init for non-key frames whose format and size did not change
-if (!key_frame &&
-canvas->data[0] &&
-canvas->format == format &&
-canvas->width  == s->canvas_width &&
-canvas->height == s->canvas_height)
-return 0;
-
-// canvas changes within IPPP sequences will loose thread sync
-// because of the ThreadFrame reallocation and will wait forever
-// so if frame-threading is used, forbid canvas changes and unlock
-// previous frames
-if (!key_frame && canvas->data[0]) {
-if (s->avctx->thread_count > 1) {
-av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged. Use -threads 1 to try decoding with best effort.\n");
-// unlock previous frames that have sent an _await() call
-ff_thread_report_progress(&s->canvas_frame, INT_MAX, 0);
-return AVERROR_PATCHWELCOME;
-} else {
-// warn for damaged frames
-av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The 
output will be damaged.\n");
-}
-}
-
-s->avctx->pix_fmt = format;
-canvas->format= format;
-canvas->width = s->canvas_width;
-canvas->height= s->canvas_height;
-
-// VP8 decoder changed the width and height in AVCodecContext.
-// Change it back

[FFmpeg-devel] [PATCH v9 3/6] libavcodec/webp: add support for animated WebP

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel
From: Josef Zlomek 

Fixes: 4907

Adds support for decoding of animated WebP.

The WebP decoder adds the animation related features according to the specs:
https://developers.google.com/speed/webp/docs/riff_container#animation
The frames of the animation may be smaller than the image canvas.
Therefore, the frame is decoded to a temporary frame,
then it is blended into the canvas, the canvas is copied to the output frame,
and finally the frame is disposed from the canvas.

The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported.
The background color is specified only as BGRA in the WebP file
so it is converted to YUVA if YUV formats are output.

Signed-off-by: Josef Zlomek 
---
 Changelog   |   1 +
 libavcodec/codec_desc.c |   3 +-
 libavcodec/version.h|   2 +-
 libavcodec/webp.c   | 704 
 4 files changed, 652 insertions(+), 58 deletions(-)

diff --git a/Changelog b/Changelog
index a638c03250..58ed906f86 100644
--- a/Changelog
+++ b/Changelog
@@ -51,6 +51,7 @@ version 6.1:
 - ffprobe XML output schema changed to account for multiple
   variable-fields elements within the same parent element
 - ffprobe -output_format option added as an alias of -of
+- animated WebP decoder
 
 
 version 6.0:
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 033344304c..0f72769093 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1259,8 +1259,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "webp",
 .long_name = NULL_IF_CONFIG_SMALL("WebP"),
-.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
- AV_CODEC_PROP_LOSSLESS,
+.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
 .mime_types= MT("image/webp"),
 },
 {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 34b059a8a9..381b278e81 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 #include "version_major.h"
 
 #define LIBAVCODEC_VERSION_MINOR  36
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 58a20b73da..4f989b8f0a 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -35,12 +35,15 @@
  * Exif metadata
  * ICC profile
  *
+ * @author Josef Zlomek, Pexeso Inc. 
+ * Animation
+ *
  * Unimplemented:
- *   - Animation
  *   - XMP metadata
  */
 
 #include "libavutil/imgutils.h"
+#include "libavutil/colorspace.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
@@ -67,6 +70,14 @@
 #define NUM_SHORT_DISTANCES 120
 #define MAX_HUFFMAN_CODE_LENGTH 15
 
+#define ANMF_DISPOSAL_METHOD0x01
+#define ANMF_DISPOSAL_METHOD_UNCHANGED  0x00
+#define ANMF_DISPOSAL_METHOD_BACKGROUND 0x01
+
+#define ANMF_BLENDING_METHOD0x02
+#define ANMF_BLENDING_METHOD_ALPHA  0x00
+#define ANMF_BLENDING_METHOD_OVERWRITE  0x02
+
 static const uint16_t alphabet_sizes[HUFFMAN_CODES_PER_META_CODE] = {
 NUM_LITERAL_CODES + NUM_LENGTH_CODES,
 NUM_LITERAL_CODES, NUM_LITERAL_CODES, NUM_LITERAL_CODES,
@@ -191,6 +202,8 @@ typedef struct ImageContext {
 typedef struct WebPContext {
 VP8Context v;   /* VP8 Context used for lossy decoding 
*/
 GetBitContext gb;   /* bitstream reader for main image 
chunk */
+ThreadFrame canvas_frame;   /* ThreadFrame for canvas */
+AVFrame *frame; /* AVFrame for decoded frame */
 AVFrame *alpha_frame;   /* AVFrame for alpha data decompressed 
from VP8L */
 AVPacket *pkt;  /* AVPacket to be passed to the 
underlying VP8 decoder */
 AVCodecContext *avctx;  /* parent AVCodecContext */
@@ -205,7 +218,22 @@ typedef struct WebPContext {
 int has_iccp;   /* set after an ICCP chunk has been 
processed */
 int width;  /* image width */
 int height; /* image height */
-int lossless;   /* indicates lossless or lossy */
+int vp8x_flags; /* global flags from VP8X chunk */
+int canvas_width;   /* canvas width */
+int canvas_height;  /* canvas height */
+int anmf_flags; /* frame flags from ANMF chunk */
+int pos_x;  /* frame position X */
+int pos_y;  /* frame position Y */
+int prev_anmf_flags;/* previous frame flags from ANMF 
chunk */
+int prev_width; /* previous frame width */
+int prev_height;/* previous frame height */
+int prev_pos_x; 

[FFmpeg-devel] [PATCH v9 1/6] avcodec/webp: remove unused definitions

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel
---
 libavcodec/webp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 54b3fde6dc..4fd107aa0c 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -59,8 +59,6 @@
 #define VP8X_FLAG_ALPHA 0x10
 #define VP8X_FLAG_ICC   0x20
 
-#define MAX_PALETTE_SIZE256
-#define MAX_CACHE_BITS  11
 #define NUM_CODE_LENGTH_CODES   19
 #define HUFFMAN_CODES_PER_META_CODE 5
 #define NUM_LITERAL_CODES   256
-- 
2.37.1 (Apple Git-137.1)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v9 0/6] webp: add support for animated WebP decoding

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel
Still images fixed, includes FATE tests, VP8 decoder decoupled so there are no 
more data races, fixed more asserts, fixed ffprobe regression, removed 
unnecessary parser changes, put the whole animated sequence into one packet.

Patch 4/6 is still there for making changes in lavc/webp reviewable but shall 
be stashed when pushing.

-Thilo


Josef Zlomek (2):
  libavcodec/webp: add support for animated WebP
  libavformat/webp: add WebP demuxer

Thilo Borgmann (4):
  avcodec/webp: remove unused definitions
  avcodec/webp: separate VP8 decoding
  avcodec/webp: make init_canvas_frame static
  fate: add test for animated WebP

 Changelog   |   2 +
 doc/demuxers.texi   |  28 +
 libavcodec/codec_desc.c |   3 +-
 libavcodec/version.h|   2 +-
 libavcodec/webp.c   | 748 ++--
 libavformat/Makefile|   1 +
 libavformat/allformats.c|   1 +
 libavformat/version.h   |   2 +-
 libavformat/webpdec.c   | 383 ++
 tests/fate/image.mak|   3 +
 tests/ref/fate/exif-image-webp  |   8 +-
 tests/ref/fate/webp-anim|  22 +
 tests/ref/fate/webp-rgb-lena-lossless   |   2 +-
 tests/ref/fate/webp-rgb-lena-lossless-rgb24 |   2 +-
 tests/ref/fate/webp-rgb-lossless|   2 +-
 tests/ref/fate/webp-rgb-lossy-q80   |   2 +-
 tests/ref/fate/webp-rgba-lossless   |   2 +-
 tests/ref/fate/webp-rgba-lossy-q80  |   2 +-
 18 files changed, 1141 insertions(+), 74 deletions(-)
 create mode 100644 libavformat/webpdec.c
 create mode 100644 tests/ref/fate/webp-anim

-- 
2.37.1 (Apple Git-137.1)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v8 2/5] libavcodec/webp: add support for animated WebP decoding

2023-12-31 Thread Thilo Borgmann via ffmpeg-devel

Am 21.12.23 um 23:18 schrieb Andreas Rheinhardt:

Thilo Borgmann via ffmpeg-devel:

From: Josef Zlomek 

Fixes: 4907

Adds support for decoding of animated WebP.

The WebP decoder adds the animation related features according to the specs:
https://developers.google.com/speed/webp/docs/riff_container#animation
The frames of the animation may be smaller than the image canvas.
Therefore, the frame is decoded to a temporary frame,
then it is blended into the canvas, the canvas is copied to the output frame,
and finally the frame is disposed from the canvas.

The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported.
The background color is specified only as BGRA in the WebP file
so it is converted to YUVA if YUV formats are output.

Signed-off-by: Josef Zlomek 
---
  Changelog   |   1 +
  libavcodec/codec_desc.c |   3 +-
  libavcodec/version.h|   2 +-
  libavcodec/webp.c   | 754 
  4 files changed, 696 insertions(+), 64 deletions(-)

@@ -1298,12 +1326,12 @@ static int vp8_lossy_decode_frame(AVCodecContext 
*avctx, AVFrame *p,
  int ret;
  
  if (!s->initialized) {

-ff_vp8_decode_init(avctx);
+VP8Context *s_vp8 = s->avctx_vp8->priv_data;
+s_vp8->actually_webp = 1;
  s->initialized = 1;
-s->v.actually_webp = 1;
  }
  avctx->pix_fmt = s->has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P;
-s->lossless = 0;
+s->avctx_vp8->pix_fmt = avctx->pix_fmt;
  


Separating webp.c from vp8.c should be done in commit of its own. And
you did not really separate them, because you are overwriting internals
of the VP8 decoder.


Sending v9 with a separate commit for this.
actually_webp and pix_fmt need to be set since 9f00fa5, or we won't get the 
alpha channel allocated (and segfault on fate-webp-rgba-lossy-q80)
See https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/vp8.c#L2668-L2677

Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v8 0/5] webp: add support for animated WebP decoding

2023-12-21 Thread Thilo Borgmann via ffmpeg-devel

Am 15.12.23 um 20:59 schrieb Thilo Borgmann via ffmpeg-devel:

Still images fixed, includes FATE tests, VP8 decoder decoupled so there are no 
more data races, fixed more asserts, fixed ffprobe regression, removed 
unnecessary parser changes, put the whole animated sequence into one packet.

Patch 3/5 is still there for making changes in lavc/webp reviewable but shall 
be stashed when pushing.

-Thilo


Josef Zlomek (2):
   libavcodec/webp: add support for animated WebP decoding
   libavformat/webp: add WebP demuxer

Thilo Borgmann (3):
   avcodec/webp: remove unused definitions
   avcodec/webp: make init_canvas_frame static
   fate: add test for animated WebP

  Changelog   |   2 +
  doc/demuxers.texi   |  28 +
  libavcodec/codec_desc.c |   3 +-
  libavcodec/version.h|   2 +-
  libavcodec/webp.c   | 748 ++--
  libavformat/Makefile|   1 +
  libavformat/allformats.c|   1 +
  libavformat/version.h   |   2 +-
  libavformat/webpdec.c   | 383 ++
  tests/fate/image.mak|   3 +
  tests/ref/fate/exif-image-webp  |   8 +-
  tests/ref/fate/webp-anim|  22 +
  tests/ref/fate/webp-rgb-lena-lossless   |   2 +-
  tests/ref/fate/webp-rgb-lena-lossless-rgb24 |   2 +-
  tests/ref/fate/webp-rgb-lossless|   2 +-
  tests/ref/fate/webp-rgb-lossy-q80   |   2 +-
  tests/ref/fate/webp-rgba-lossless   |   2 +-
  tests/ref/fate/webp-rgba-lossy-q80  |   2 +-
  18 files changed, 1141 insertions(+), 74 deletions(-)
  create mode 100644 libavformat/webpdec.c
  create mode 100644 tests/ref/fate/webp-anim


Ping.

-Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v3 1/2] avfilter: Add fsync filter

2023-12-18 Thread Thilo Borgmann via ffmpeg-devel

Am 18.12.23 um 02:04 schrieb Stefano Sabatini:

On date Saturday 2023-12-16 09:13:21 +0100, ffmpeg-devel Mailing List wrote:

---
  Changelog|   1 +
  MAINTAINERS  |   1 +
  configure|   2 +
  doc/filters.texi |  33 +
  libavfilter/Makefile |   1 +
  libavfilter/allfilters.c |   1 +
  libavfilter/version.h|   2 +-
  libavfilter/vf_fsync.c   | 286 +++
  8 files changed, 326 insertions(+), 1 deletion(-)
  create mode 100644 libavfilter/vf_fsync.c

[...]
@@ -14681,6 +14681,39 @@ option may cause flicker since the B-Frames have often 
larger QP. Default is
  
  @end table
  
+@anchor{fsync}

+@section fsync
+
+Synchronize video frames with an external mapping from a file.
+
+For each input PTS given in the map file it either drops or creates as many 
frames as necessary to recreate the sequence of output frames given in the map 
file.
+
+This filter is useful to recreate the output frames of a framerate conversion 
by the @ref{fps} filter, recorded into a map file using the ffmpeg option 
@code{-stats_mux_pre}, and do further processing to the corresponding frames 
e.g. quality comparison.


wrap around 80 chars, here and below


All wrapped locally, except in the examples where it would mangle the HTML 
output.

Thanks,
Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v3 1/2] avfilter: Add fsync filter

2023-12-18 Thread Thilo Borgmann via ffmpeg-devel

Am 17.12.23 um 23:51 schrieb Michael Niedermayer:

On Sat, Dec 16, 2023 at 09:13:21AM +0100, Thilo Borgmann via ffmpeg-devel wrote:
[...]


+// get number of bytes from cur to '\0'
+static int buf_get_zero(FsyncContext *ctx)


maybe doxygen syntax would make sense for comments descrining functions
its not public api but still maybe


Better still. Done.



+{
+return av_strnlen(ctx->cur, ctx->end - ctx->cur);
+}
+

[...]

+if (s->last_frame) {
+ret = av_sscanf(s->cur, "%"PRId64" %"PRId64" %d/%d", &s->ptsi, &s->pts, 
&s->tb_num, &s->tb_den);
+if (ret != 4) {
+av_log(ctx, AV_LOG_ERROR, "Unexpected format found (%i / 4).\n", 
ret);
+ff_outlink_set_status(outlink, AVERROR_INVALIDDATA, 
AV_NOPTS_VALUE);
+return AVERROR_INVALIDDATA;
+}
+
+av_log(ctx, AV_LOG_DEBUG, "frame %lli ", s->last_frame->pts);


warning: format ‘%lli’ expects argument of type ‘long long int’, but argument 4 
has type ‘int64_t {aka long int}’ [-Wformat=]

"%"PRIi64 / "%"PRId64 / "%"PRIu64 / "%"PRIx64


"%"PRId64 it shall be here and for the other DEBUG logs.

All done locally, I'd appreciate if someone could test this on Windows, I'm 
curious about line endings in the map file...

Thanks,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v3 2/2] fate: Add fsync filter tests

2023-12-16 Thread Thilo Borgmann via ffmpeg-devel
---
 tests/Makefile   |  6 +++-
 tests/fate/filter-video.mak  |  6 
 tests/maps/fsync-down|  7 
 tests/maps/fsync-up  | 57 +
 tests/ref/fate/filter-fsync-down | 12 +++
 tests/ref/fate/filter-fsync-up   | 62 
 6 files changed, 149 insertions(+), 1 deletion(-)
 create mode 100644 tests/maps/fsync-down
 create mode 100644 tests/maps/fsync-up
 create mode 100644 tests/ref/fate/filter-fsync-down
 create mode 100644 tests/ref/fate/filter-fsync-up

diff --git a/tests/Makefile b/tests/Makefile
index 444c09b3de..c7892a9313 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -23,7 +23,7 @@ FFMPEG=ffmpeg$(PROGSSUF)$(EXESUF)
 $(AREF): CMP=
 
 APITESTSDIR := tests/api
-FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs 
tests/data/lavf tests/data/lavf-fate tests/data/pixfmt tests/vsynth1 
$(APITESTSDIR)
+FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs 
tests/data/maps tests/data/lavf tests/data/lavf-fate tests/data/pixfmt 
tests/vsynth1 $(APITESTSDIR)
 OUTDIRS += $(FATE_OUTDIRS)
 
 $(VREF): tests/videogen$(HOSTEXESUF) | tests/vsynth1
@@ -66,6 +66,10 @@ tests/data/filtergraphs/%: TAG = COPY
 tests/data/filtergraphs/%: $(SRC_PATH)/tests/filtergraphs/% | 
tests/data/filtergraphs
$(M)cp $< $@
 
+tests/data/maps/%: TAG = COPY
+tests/data/maps/%: $(SRC_PATH)/tests/maps/% | tests/data/maps
+   $(M)cp $< $@
+
 RUNNING_FATE := $(filter check fate%,$(filter-out fate-rsync,$(MAKECMDGOALS)))
 
 # Check sanity of dependencies when running FATE tests.
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index b57ef88c9b..072169ac7e 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -395,6 +395,12 @@ FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, FPS SCALE, MOV, 
QTRLE) += fate-filter-f
 fate-filter-fps-cfr: CMD = framecrc -auto_conversion_filters -i 
$(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -r 30 -fps_mode 
cfr -pix_fmt yuv420p
 fate-filter-fps: CMD = framecrc -auto_conversion_filters -i 
$(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -vf fps=30 
-pix_fmt yuv420p
 
+FATE_FILTER_SAMPLES-$(call FILTERFRAMECRC, TESTSRC2 FSYNC, FILE_PROTOCOL) += 
fate-filter-fsync-up fate-filter-fsync-down
+fate-filter-fsync-up: tests/data/maps/fsync-up
+fate-filter-fsync-up: CMD = framecrc -lavfi 
testsrc2=r=25:d=1,fsync=f=tests/data/maps/fsync-up
+fate-filter-fsync-down: tests/data/maps/fsync-down
+fate-filter-fsync-down: CMD = framecrc -lavfi 
testsrc2=r=25:d=1,fsync=f=tests/data/maps/fsync-down
+
 FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE := $(addprefix 
fate-filter-alphaextract_alphamerge_, rgb yuv)
 FATE_FILTER_VSYNTH_PGMYUV-$(call ALLYES, SCALE_FILTER FORMAT_FILTER 
SPLIT_FILTER ALPHAEXTRACT_FILTER ALPHAMERGE_FILTER) += 
$(FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE)
 $(FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE): fate-filter-alphaextract_alphamerge_%: 
tests/data/filtergraphs/alphamerge_alphaextract_%
diff --git a/tests/maps/fsync-down b/tests/maps/fsync-down
new file mode 100644
index 00..107761ecbe
--- /dev/null
+++ b/tests/maps/fsync-down
@@ -0,0 +1,7 @@
+1 0 1/7
+5 1 1/7
+8 2 1/7
+12 3 1/7
+16 4 1/7
+19 5 1/7
+23 6 1/7
diff --git a/tests/maps/fsync-up b/tests/maps/fsync-up
new file mode 100644
index 00..c37a1fae14
--- /dev/null
+++ b/tests/maps/fsync-up
@@ -0,0 +1,57 @@
+0 0 1/57
+0 1 1/57
+1 2 1/57
+1 3 1/57
+1 4 1/57
+2 5 1/57
+2 6 1/57
+3 7 1/57
+3 8 1/57
+4 9 1/57
+4 10 1/57
+5 11 1/57
+5 12 1/57
+5 13 1/57
+6 14 1/57
+6 15 1/57
+7 16 1/57
+7 17 1/57
+8 18 1/57
+8 19 1/57
+8 20 1/57
+9 21 1/57
+9 22 1/57
+10 23 1/57
+10 24 1/57
+11 25 1/57
+11 26 1/57
+12 27 1/57
+12 28 1/57
+12 29 1/57
+13 30 1/57
+13 31 1/57
+14 32 1/57
+14 33 1/57
+15 34 1/57
+15 35 1/57
+16 36 1/57
+16 37 1/57
+16 38 1/57
+17 39 1/57
+17 40 1/57
+18 41 1/57
+18 42 1/57
+19 43 1/57
+19 44 1/57
+19 45 1/57
+20 46 1/57
+20 47 1/57
+21 48 1/57
+21 49 1/57
+22 50 1/57
+22 51 1/57
+23 52 1/57
+23 53 1/57
+23 54 1/57
+24 55 1/57
+24 56 1/57
diff --git a/tests/ref/fate/filter-fsync-down b/tests/ref/fate/filter-fsync-down
new file mode 100644
index 00..d3f04060ad
--- /dev/null
+++ b/tests/ref/fate/filter-fsync-down
@@ -0,0 +1,12 @@
+#tb 0: 1/7
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 320x240
+#sar 0: 1/1
+0,  0,  0,1,   115200, 0x7ed43658
+0,  1,  1,1,   115200, 0x5418f45b
+0,  2,  2,1,   115200, 0x9872fad9
+0,  3,  3,1,   115200, 0x4dbbf2e0
+0,  4,  4,1,   115200, 0xcce711f5
+0,  5,  5,1,   115200, 0xaa341025
+0,  6,  6,1,   115200, 0xb41eeaac
diff --git a/tests/ref/fate/filter-fsync-up b/tests/ref/fate/filter-fsync-up
new file mode 100644
index 00..ea7f7efe2d
--- /dev/null
+++ b/tests/ref/fate/filter-fsync-up
@@ -0,0 +1,62 @@
+#tb 0: 1/57
+#medi

[FFmpeg-devel] [PATCH v3 1/2] avfilter: Add fsync filter

2023-12-16 Thread Thilo Borgmann via ffmpeg-devel
---
 Changelog|   1 +
 MAINTAINERS  |   1 +
 configure|   2 +
 doc/filters.texi |  33 +
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 libavfilter/vf_fsync.c   | 286 +++
 8 files changed, 326 insertions(+), 1 deletion(-)
 create mode 100644 libavfilter/vf_fsync.c

diff --git a/Changelog b/Changelog
index 67ef92eb02..a25278d227 100644
--- a/Changelog
+++ b/Changelog
@@ -9,6 +9,7 @@ version :
 - aap filter
 - demuxing, decoding, filtering, encoding, and muxing in the
   ffmpeg CLI now all run in parallel
+- fsync filter
 
 version 6.1:
 - libaribcaption decoder
diff --git a/MAINTAINERS b/MAINTAINERS
index 39b37ee0c5..4257fcad98 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -343,6 +343,7 @@ Filters:
   vf_delogo.c   Jean Delvare (CC )
   vf_drawbox.c/drawgrid Andrey Utkin
   vf_extractplanes.cPaul B Mahol
+  vf_fsync.cThilo Borgmann
   vf_histogram.cPaul B Mahol
   vf_hqx.c  Clément Bœsch
   vf_idet.c Pascal Massimino
diff --git a/configure b/configure
index 7d2ee66000..2328c96dde 100755
--- a/configure
+++ b/configure
@@ -3745,6 +3745,7 @@ frei0r_deps_any="libdl LoadLibrary"
 frei0r_filter_deps="frei0r"
 frei0r_src_filter_deps="frei0r"
 fspp_filter_deps="gpl"
+fsync_filter_deps="avformat"
 gblur_vulkan_filter_deps="vulkan spirv_compiler"
 hflip_vulkan_filter_deps="vulkan spirv_compiler"
 histeq_filter_deps="gpl"
@@ -7647,6 +7648,7 @@ enabled cover_rect_filter   && prepend avfilter_deps 
"avformat avcodec"
 enabled ebur128_filter && enabled swresample && prepend avfilter_deps 
"swresample"
 enabled elbg_filter && prepend avfilter_deps "avcodec"
 enabled find_rect_filter&& prepend avfilter_deps "avformat avcodec"
+enabled fsync_filter&& prepend avfilter_deps "avformat"
 enabled mcdeint_filter  && prepend avfilter_deps "avcodec"
 enabled movie_filter&& prepend avfilter_deps "avformat avcodec"
 enabled pan_filter  && prepend avfilter_deps "swresample"
diff --git a/doc/filters.texi b/doc/filters.texi
index 6d00ba2c3f..9f19cba9df 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14681,6 +14681,39 @@ option may cause flicker since the B-Frames have often 
larger QP. Default is
 
 @end table
 
+@anchor{fsync}
+@section fsync
+
+Synchronize video frames with an external mapping from a file.
+
+For each input PTS given in the map file it either drops or creates as many 
frames as necessary to recreate the sequence of output frames given in the map 
file.
+
+This filter is useful to recreate the output frames of a framerate conversion 
by the @ref{fps} filter, recorded into a map file using the ffmpeg option 
@code{-stats_mux_pre}, and do further processing to the corresponding frames 
e.g. quality comparison.
+
+Each line of the map file must contain three items per input frame, the input 
PTS (decimal), the output PTS (decimal) and the output TIMEBASE 
(decimal/decimal), seperated by a space.
+This file format corresponds to the output of 
@code{-stats_mux_pre_fmt="@{ptsi@} @{pts@} @{tb@}"}.
+
+The filter assumes the map file is sorted by increasing input PTS.
+
+The filter accepts the following options:
+@table @option
+
+@item file, f
+The filename of the map file to be used.
+@end table
+
+Example:
+@example
+# Convert a video to 25 fps and record a MAP_FILE file with the default format 
of this filter
+ffmpeg -i INPUT -vf fps=fps=25 -stats_mux_pre MAP_FILE -stats_mux_pre_fmt 
"@{ptsi@} @{pts@} @{tb@}" OUTPUT
+
+# Sort MAP_FILE by increasing input PTS
+sort -n MAP_FILE
+
+# Use INPUT, OUTPUT and the MAP_FILE from above to compare the corresponding 
frames in INPUT and OUTPUT via SSIM
+ffmpeg -i INPUT -i OUTPUT -filter_complex 
'[0:v]fsync=file=MAP_FILE[ref];[1:v][ref]ssim' -f null -
+@end example
+
 @section gblur
 
 Apply Gaussian blur filter.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 63725f91b4..612616dfb4 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -323,6 +323,7 @@ OBJS-$(CONFIG_FREEZEDETECT_FILTER)   += 
vf_freezedetect.o
 OBJS-$(CONFIG_FREEZEFRAMES_FILTER)   += vf_freezeframes.o
 OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o
 OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o qp_table.o
+OBJS-$(CONFIG_FSYNC_FILTER)  += vf_fsync.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 OBJS-$(CONFIG_GBLUR_VULKAN_FILTER)   += vf_gblur_vulkan.o vulkan.o 
vulkan_filter.o
 OBJS-$(CONFIG_GEQ_

[FFmpeg-devel] [PATCH v3 0/2] avfilter: Add fsync filter

2023-12-16 Thread Thilo Borgmann via ffmpeg-devel
Synchronize video frames with an external mapping from a file.
Follows up on the idea in 
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2023-January/305986.html 
implemented as a filter.

Not storing the frame map in a probably huge string but buffering
piece-wise. Using a fixed format string. Passthrough for all pixel
formats.

Thilo Borgmann (2):
  avfilter: Add fsync filter
  fate: Add fsync filter tests

 Changelog|   1 +
 MAINTAINERS  |   1 +
 configure|   2 +
 doc/filters.texi |  33 
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 libavfilter/vf_fsync.c   | 286 +++
 tests/Makefile   |   6 +-
 tests/fate/filter-video.mak  |   6 +
 tests/maps/fsync-down|   7 +
 tests/maps/fsync-up  |  57 ++
 tests/ref/fate/filter-fsync-down |  12 ++
 tests/ref/fate/filter-fsync-up   |  62 +++
 14 files changed, 475 insertions(+), 2 deletions(-)
 create mode 100644 libavfilter/vf_fsync.c
 create mode 100644 tests/maps/fsync-down
 create mode 100644 tests/maps/fsync-up
 create mode 100644 tests/ref/fate/filter-fsync-down
 create mode 100644 tests/ref/fate/filter-fsync-up

-- 
2.37.1 (Apple Git-137.1)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/2] avfilter: Add fsync filter

2023-12-16 Thread Thilo Borgmann via ffmpeg-devel

Am 15.12.23 um 15:17 schrieb Andreas Rheinhardt:

Thilo Borgmann via ffmpeg-devel:

---
  Changelog|   1 +
  MAINTAINERS  |   1 +
  doc/filters.texi |  33 +
  libavfilter/Makefile |   1 +
  libavfilter/allfilters.c |   1 +
  libavfilter/version.h|   2 +-
  libavfilter/vf_fsync.c   | 304 +++
  7 files changed, 342 insertions(+), 1 deletion(-)
  create mode 100644 libavfilter/vf_fsync.c

[...]
+// fills the buffer from cur to end, add \0 at EOF
+static int buf_fill(FsyncContext *ctx)
+{
+int ret;
+int num = ctx->end - ctx->cur;
+
+ret = avio_read(ctx->avio_ctx, ctx->cur, num);
+if (ret < 0)
+return ret;
+if (ret < num) {
+*(ctx->cur + ret) = '\0';
+}
+
+return ret;
+}
+
+// copies cur to end to the beginning and fills the rest
+static int buf_reload(FsyncContext *ctx)
+{
+int i, ret;
+int num = ctx->end - ctx->cur;
+
+for (i = 0; i < num; i++) {
+ctx->buf[i] = *ctx->cur++;
+}
+
+ctx->cur = ctx->buf + i;
+ret = buf_fill(ctx);
+if (ret < 0)
+return ret;
+ctx->cur = ctx->buf;


I wonder whether you should not just use avio_read_to_bprint() for all
of this.


I tested a bit. It appears good for filling the buffer with one function call, 
getting the stuff out for scanf appears not as well as when and how to refill 
the buffer. Comparing a bit to f_metadata where this is used, the necessary 
function get bigger and more complex than this easily.
Maybe its just I didn't use it often enough, but this char* handling appears 
easier and less complex to me.
So if you don't insist I'd leave it that way.


+
+return ret;
+}
+
+// skip from cur over eol
+static void buf_skip_eol(FsyncContext *ctx)
+{
+char *i;
+for (i = ctx->cur; i < ctx->end; i++) {
+if (*i != '\n')// && *i != '\r')
+break;
+}
+ctx->cur = i;
+}
+
+// get number of bytes from cur until eol
+static int buf_get_line_count(FsyncContext *ctx)
+{
+int ret = 0;
+char *i;
+for (i = ctx->cur; i < ctx->end; i++, ret++) {
+if (*i == '\0' || *i == '\n')
+return ret;


If you unconditionally added a single \0 to the end of the buffer, you
could use strchr() here.


I'd need two strchr() calls, for \0 and \n, plus the interpretation of the 
resulting pointers.
Where \0 would always be found at the end of the buffer which needs another if 
to see if its what I need or do need to load more data.



[...]
+
+static av_cold void fsync_uninit(AVFilterContext *ctx)
+{
+FsyncContext *s = ctx->priv;
+
+avio_close(s->avio_ctx);


avio_closep()


+av_freep(&s->buf);
+av_frame_unref(s->last_frame);


I expect that this needs to be changed to av_frame_free(). Anyway, you
should run your tests via valgrind/asan.


Asan is fine both ways, so I assume it wouldn't catch it?
Changed to av_frame_free anyways.

There appears no Valgrind nor msan to be available for OSX.
'leaks' also even complains it cannot really do its job:

"Can't examine target process's malloc zone asan_0x10c134950, so memory 
analysis will be incomplete or incorrect.
Reason: for security, cannot load non-system library 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib

Process 49784 is not debuggable. Due to security restrictions, leaks can only show 
or save contents of readonly memory of restricted processes."

Am I out of options on OSX? Seems like the first real drawback when on a mac...


Fixed all the other things for v3.

-Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


  1   2   3   4   5   6   7   8   9   10   >