[FFmpeg-devel] [PATCH v14 4/4] avformat/image2: add Jpeg XL as image2 format

2022-04-11 Thread Leo Izen
This commit adds support to libavformat for muxing
and demuxing Jpeg XL images as image2 streams.
---
 MAINTAINERS|   1 +
 libavformat/Makefile   |   1 +
 libavformat/allformats.c   |   1 +
 libavformat/img2.c |   1 +
 libavformat/img2dec.c  |  18 ++
 libavformat/img2enc.c  |   6 +-
 libavformat/jpegxl_probe.c | 393 +
 libavformat/jpegxl_probe.h |  32 +++
 libavformat/mov.c  |   1 +
 9 files changed, 451 insertions(+), 3 deletions(-)
 create mode 100644 libavformat/jpegxl_probe.c
 create mode 100644 libavformat/jpegxl_probe.h

diff --git a/MAINTAINERS b/MAINTAINERS
index faea84ebf1..46723972dc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -439,6 +439,7 @@ Muxers/Demuxers:
   ipmovie.c Mike Melanson
   ircam*Paul B Mahol
   iss.c Stefan Gehrer
+  jpegxl_probe.*Leo Izen
   jvdec.c   Peter Ross
   kvag.cZane van Iperen
   libmodplug.c  Clément Bœsch
diff --git a/libavformat/Makefile b/libavformat/Makefile
index d7182d6bd8..beecdf5a66 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -272,6 +272,7 @@ OBJS-$(CONFIG_IMAGE_GIF_PIPE_DEMUXER) += img2dec.o 
img2.o
 OBJS-$(CONFIG_IMAGE_J2K_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_JPEG_PIPE_DEMUXER)+= img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER)  += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_JPEGXL_PIPE_DEMUXER)  += img2dec.o img2.o jpegxl_probe.o
 OBJS-$(CONFIG_IMAGE_PAM_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_PBM_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_PCX_PIPE_DEMUXER) += img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 7c1d0ac38f..63876c468f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -510,6 +510,7 @@ extern const AVInputFormat  ff_image_gif_pipe_demuxer;
 extern const AVInputFormat  ff_image_j2k_pipe_demuxer;
 extern const AVInputFormat  ff_image_jpeg_pipe_demuxer;
 extern const AVInputFormat  ff_image_jpegls_pipe_demuxer;
+extern const AVInputFormat  ff_image_jpegxl_pipe_demuxer;
 extern const AVInputFormat  ff_image_pam_pipe_demuxer;
 extern const AVInputFormat  ff_image_pbm_pipe_demuxer;
 extern const AVInputFormat  ff_image_pcx_pipe_demuxer;
diff --git a/libavformat/img2.c b/libavformat/img2.c
index fe2ca7bfff..566ef873ca 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -88,6 +88,7 @@ const IdStrMap ff_img_tags[] = {
 { AV_CODEC_ID_GEM,"ximg" },
 { AV_CODEC_ID_GEM,"timg" },
 { AV_CODEC_ID_VBN,"vbn"  },
+{ AV_CODEC_ID_JPEGXL, "jxl"  },
 { AV_CODEC_ID_NONE,   NULL   }
 };
 
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 551b9d508e..627bb67212 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -36,6 +36,7 @@
 #include "avio_internal.h"
 #include "internal.h"
 #include "img2.h"
+#include "jpegxl_probe.h"
 #include "libavcodec/mjpeg.h"
 #include "libavcodec/vbn.h"
 #include "libavcodec/xwd.h"
@@ -837,6 +838,22 @@ static int jpegls_probe(const AVProbeData *p)
 return 0;
 }
 
+static int jpegxl_probe(const AVProbeData *p)
+{
+const uint8_t *b = p->buf;
+
+/* ISOBMFF-based container */
+/* 0x4a584c20 == "JXL " */
+if (AV_RL64(b) == FF_JPEGXL_CONTAINER_SIGNATURE_LE)
+return AVPROBE_SCORE_EXTENSION + 1;
+/* Raw codestreams all start with 0xff0a */
+if (AV_RL16(b) != FF_JPEGXL_CODESTREAM_SIGNATURE_LE)
+return 0;
+if (ff_jpegxl_verify_codestream_header(p->buf, p->buf_size) >= 0)
+return AVPROBE_SCORE_MAX - 2;
+return 0;
+}
+
 static int pcx_probe(const AVProbeData *p)
 {
 const uint8_t *b = p->buf;
@@ -1176,6 +1193,7 @@ IMAGEAUTO_DEMUXER(gif,   GIF)
 IMAGEAUTO_DEMUXER_EXT(j2k,   JPEG2000, J2K)
 IMAGEAUTO_DEMUXER_EXT(jpeg,  MJPEG, JPEG)
 IMAGEAUTO_DEMUXER(jpegls,JPEGLS)
+IMAGEAUTO_DEMUXER(jpegxl,JPEGXL)
 IMAGEAUTO_DEMUXER(pam,   PAM)
 IMAGEAUTO_DEMUXER(pbm,   PBM)
 IMAGEAUTO_DEMUXER(pcx,   PCX)
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index ae351963d9..5ed97bb833 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -263,9 +263,9 @@ static const AVClass img2mux_class = {
 const AVOutputFormat ff_image2_muxer = {
 .name   = "image2",
 .long_name  = NULL_IF_CONFIG_SMALL("image2 sequence"),
-.extensions = 
"bmp,dpx,exr,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,png,"
-  
"ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,im24,"
-  "sunras,vbn,xbm,xface,pix,y",
+.extensions = 
"bmp,dpx,exr,jls,jpeg,jpg,jxl,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,"
+  
"png,ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,"
+

[FFmpeg-devel] [PATCH v14 3/4] avcodec/libjxl: add Jpeg XL encoding via libjxl

2022-04-11 Thread Leo Izen
This commit adds encoding support to libavcodec
for Jpeg XL images via the external library libjxl.
---
 configure  |   3 +-
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libjxlenc.c | 382 +
 4 files changed, 386 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libjxlenc.c

diff --git a/configure b/configure
index c36d5dbc8b..76bd8857db 100755
--- a/configure
+++ b/configure
@@ -240,7 +240,7 @@ External library support:
   --enable-libiec61883 enable iec61883 via libiec61883 [no]
   --enable-libilbc enable iLBC de/encoding via libilbc [no]
   --enable-libjack enable JACK audio sound server [no]
-  --enable-libjxl  enable JPEG XL decoding via libjxl [no]
+  --enable-libjxl  enable JPEG XL de/encoding via libjxl [no]
   --enable-libklvanc   enable Kernel Labs VANC processing [no]
   --enable-libkvazaar  enable HEVC encoding via libkvazaar [no]
   --enable-liblensfun  enable lensfun lens correction [no]
@@ -3334,6 +3334,7 @@ libgsm_ms_encoder_deps="libgsm"
 libilbc_decoder_deps="libilbc"
 libilbc_encoder_deps="libilbc"
 libjxl_decoder_deps="libjxl libjxl_threads"
+libjxl_encoder_deps="libjxl libjxl_threads"
 libkvazaar_encoder_deps="libkvazaar"
 libmodplug_demuxer_deps="libmodplug"
 libmp3lame_encoder_deps="libmp3lame"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8fc3b3cc5f..a8cb606186 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1062,6 +1062,7 @@ OBJS-$(CONFIG_LIBGSM_MS_ENCODER)  += libgsmenc.o
 OBJS-$(CONFIG_LIBILBC_DECODER)+= libilbc.o
 OBJS-$(CONFIG_LIBILBC_ENCODER)+= libilbc.o
 OBJS-$(CONFIG_LIBJXL_DECODER) += libjxldec.o libjxl.o
+OBJS-$(CONFIG_LIBJXL_ENCODER) += libjxlenc.o libjxl.o
 OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o
 OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o
 OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER)  += libopencore-amr.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 07f5bafd27..c47133aa18 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -752,6 +752,7 @@ extern const FFCodec ff_libgsm_ms_decoder;
 extern const FFCodec ff_libilbc_encoder;
 extern const FFCodec ff_libilbc_decoder;
 extern const FFCodec ff_libjxl_decoder;
+extern const FFCodec ff_libjxl_encoder;
 extern const FFCodec ff_libmp3lame_encoder;
 extern const FFCodec ff_libopencore_amrnb_encoder;
 extern const FFCodec ff_libopencore_amrnb_decoder;
diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
new file mode 100644
index 00..a20de91661
--- /dev/null
+++ b/libavcodec/libjxlenc.c
@@ -0,0 +1,382 @@
+/*
+ * JPEG XL encoding support via libjxl
+ * Copyright (c) 2021 Leo Izen 
+ *
+ * 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
+ * JPEG XL encoder using libjxl
+ */
+
+#include 
+
+#include "libavutil/avutil.h"
+#include "libavutil/error.h"
+#include "libavutil/frame.h"
+#include "libavutil/libm.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/pixfmt.h"
+#include "libavutil/version.h"
+
+#include "avcodec.h"
+#include "encode.h"
+#include "codec_internal.h"
+
+#include 
+#include 
+#include "libjxl.h"
+
+typedef struct LibJxlEncodeContext {
+AVClass *class;
+void *runner;
+JxlEncoder *encoder;
+JxlEncoderFrameSettings *options;
+int effort;
+float distance;
+int modular;
+uint8_t *buffer;
+size_t buffer_size;
+} LibJxlEncodeContext;
+
+/**
+ * Map a quality setting for -qscale roughly from libjpeg
+ * quality numbers to libjxl's butteraugli distance for
+ * photographic content.
+ *
+ * Setting distance explicitly is preferred, but this will
+ * allow qscale to be used as a fallback.
+ *
+ * This function is continuous and injective on [0, 100] which
+ * makes it monotonic.
+ *
+ * @param  quality 0.0 to 100.0 quality setting, libjpeg quality
+ * @return Butteraugli distance between 0.0 and 15.0
+ */
+static float quality_to_distance(float quality)
+{
+if (quality >= 100.0)
+return 0.0;
+else if (quality >= 90.0)
+return (100.0 - quality) * 0.10;
+else if (quality >= 30.0)
+return 

[FFmpeg-devel] [PATCH v14 2/4] avcodec/libjxl: add Jpeg XL decoding via libjxl

2022-04-11 Thread Leo Izen
This commit adds decoding support to libavcodec
for Jpeg XL images via the external library libjxl.
---
 MAINTAINERS   |   1 +
 configure |   5 +
 doc/general_contents.texi |   7 +
 libavcodec/Makefile   |   1 +
 libavcodec/allcodecs.c|   1 +
 libavcodec/libjxl.c   |  70 ++
 libavcodec/libjxl.h   |  48 +++
 libavcodec/libjxldec.c| 274 ++
 8 files changed, 407 insertions(+)
 create mode 100644 libavcodec/libjxl.c
 create mode 100644 libavcodec/libjxl.h
 create mode 100644 libavcodec/libjxldec.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 859a5005d4..faea84ebf1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -194,6 +194,7 @@ Codecs:
   libcodec2.c   Tomas Härdin
   libdirac* David Conrad
   libdavs2.cHuiwen Ren
+  libjxl*.c, libjxl.h   Leo Izen
   libgsm.c  Michel Bardiaux
   libkvazaar.c  Arttu Ylä-Outinen
   libopenh264enc.c  Martin Storsjo, Linjie Fu
diff --git a/configure b/configure
index 9c8965852b..c36d5dbc8b 100755
--- a/configure
+++ b/configure
@@ -240,6 +240,7 @@ External library support:
   --enable-libiec61883 enable iec61883 via libiec61883 [no]
   --enable-libilbc enable iLBC de/encoding via libilbc [no]
   --enable-libjack enable JACK audio sound server [no]
+  --enable-libjxl  enable JPEG XL decoding via libjxl [no]
   --enable-libklvanc   enable Kernel Labs VANC processing [no]
   --enable-libkvazaar  enable HEVC encoding via libkvazaar [no]
   --enable-liblensfun  enable lensfun lens correction [no]
@@ -1833,6 +1834,7 @@ EXTERNAL_LIBRARY_LIST="
 libiec61883
 libilbc
 libjack
+libjxl
 libklvanc
 libkvazaar
 libmodplug
@@ -3331,6 +,7 @@ libgsm_ms_decoder_deps="libgsm"
 libgsm_ms_encoder_deps="libgsm"
 libilbc_decoder_deps="libilbc"
 libilbc_encoder_deps="libilbc"
+libjxl_decoder_deps="libjxl libjxl_threads"
 libkvazaar_encoder_deps="libkvazaar"
 libmodplug_demuxer_deps="libmodplug"
 libmp3lame_encoder_deps="libmp3lame"
@@ -6543,6 +6546,8 @@ enabled libgsm&& { for gsm_hdr in "gsm.h" 
"gsm/gsm.h"; do
check_lib libgsm "${gsm_hdr}" gsm_create 
-lgsm && break;
done || die "ERROR: libgsm not found"; }
 enabled libilbc   && require libilbc ilbc.h WebRtcIlbcfix_InitDecode 
-lilbc $pthreads_extralibs
+enabled libjxl&& require_pkg_config libjxl "libjxl >= 0.7.0" 
jxl/decode.h JxlDecoderVersion &&
+ require_pkg_config libjxl_threads "libjxl_threads 
>= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner
 enabled libklvanc && require libklvanc libklvanc/vanc.h 
klvanc_context_create -lklvanc
 enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= 0.8.1" 
kvazaar.h kvz_api_get
 enabled liblensfun&& require_pkg_config liblensfun lensfun lensfun.h 
lf_db_new
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 238568f2bb..93a90a5e52 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -171,6 +171,13 @@ Go to @url{https://github.com/TimothyGu/libilbc} and 
follow the instructions for
 installing the library. Then pass @code{--enable-libilbc} to configure to
 enable it.
 
+@section libjxl
+
+JPEG XL is an image format intended to fully replace legacy JPEG for an 
extended
+period of life. See @url{https://jpegxl.info/} for more information, and see
+@url{https://github.com/libjxl/libjxl} for the library source. You can pass
+@code{--enable-libjxl} to configure in order enable the libjxl wrapper.
+
 @section libvpx
 
 FFmpeg can make use of the libvpx library for VP8/VP9 decoding and encoding.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 90f46035d9..8fc3b3cc5f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1061,6 +1061,7 @@ OBJS-$(CONFIG_LIBGSM_MS_DECODER)  += libgsmdec.o
 OBJS-$(CONFIG_LIBGSM_MS_ENCODER)  += libgsmenc.o
 OBJS-$(CONFIG_LIBILBC_DECODER)+= libilbc.o
 OBJS-$(CONFIG_LIBILBC_ENCODER)+= libilbc.o
+OBJS-$(CONFIG_LIBJXL_DECODER) += libjxldec.o libjxl.o
 OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o
 OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o
 OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER)  += libopencore-amr.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 585918da93..07f5bafd27 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -751,6 +751,7 @@ extern const FFCodec ff_libgsm_ms_encoder;
 extern const FFCodec ff_libgsm_ms_decoder;
 extern const FFCodec ff_libilbc_encoder;
 extern const FFCodec ff_libilbc_decoder;
+extern const FFCodec ff_libjxl_decoder;
 extern const FFCodec ff_libmp3lame_encoder;
 extern const FFCodec 

[FFmpeg-devel] [PATCH v14 1/4] avcodec/jpegxl: add Jpeg XL image codec

2022-04-11 Thread Leo Izen
This commit adds support to libavcodec to read
encoded Jpeg XL images. Jpeg XL is intended to be an
extended-life replacement to legacy mjpeg.
---
 MAINTAINERS | 1 +
 libavcodec/codec_desc.c | 9 +
 libavcodec/codec_id.h   | 1 +
 3 files changed, 11 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8c71605339..859a5005d4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -618,6 +618,7 @@ Haihao Xiang (haihao) 1F0C 31E8 B4FE F7A4 4DC1 DC99 
E0F5 76D4 76FC 437F
 Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368
 James Almer   7751 2E8C FD94 A169 57E6 9A7A 1463 01AD 7376 59E0
 Jean Delvare  7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A
+Leo Izen (thebombzen) B6FD 3CFC 7ACF 83FC 9137 6945 5A71 C331 FD2F A19A
 Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
 Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464
 Michael Niedermayer   9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index c08854cc93..e7f0f6a8d4 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1870,6 +1870,15 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Vizrt Binary Image"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_JPEGXL,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "jpegxl",
+.long_name = NULL_IF_CONFIG_SMALL("JPEG XL"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
+ AV_CODEC_PROP_LOSSLESS,
+.mime_types= MT("image/jxl"),
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 43c72ce8e4..8b317fa121 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -309,6 +309,7 @@ enum AVCodecID {
 AV_CODEC_ID_SGA_VIDEO,
 AV_CODEC_ID_GEM,
 AV_CODEC_ID_VBN,
+AV_CODEC_ID_JPEGXL,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
-- 
2.35.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 v14 0/4] Jpeg XL Patch Set

2022-04-11 Thread Leo Izen
Changes:
v14:
 - Make changes requested by Anton from v13
  -- make encoder return refcounted packet
  -- use av_realloc for realloc loop
  -- use -1 as default instead of -0.0
 - Remove unnecessary JXL_DEC_FRAME subscribe event from decoder
 - Update FFCodec declarations to use the new macros, rebase onto master
v13:
 - Make changes requested by Anton and Andreas from v12
v12:
 - Remove the parser in order to avoid avpriv in the ABI
 - Add a lightweight version of it to avformat to help the prober
 - Remove the FATE test for the parser which no longer exists


Leo Izen (4):
  avcodec/jpegxl: add Jpeg XL image codec
  avcodec/libjxl: add Jpeg XL decoding via libjxl
  avcodec/libjxl: add Jpeg XL encoding via libjxl
  avformat/image2: add Jpeg XL as image2 format

 MAINTAINERS|   3 +
 configure  |   6 +
 doc/general_contents.texi  |   7 +
 libavcodec/Makefile|   2 +
 libavcodec/allcodecs.c |   2 +
 libavcodec/codec_desc.c|   9 +
 libavcodec/codec_id.h  |   1 +
 libavcodec/libjxl.c|  70 +++
 libavcodec/libjxl.h|  48 +
 libavcodec/libjxldec.c | 274 ++
 libavcodec/libjxlenc.c | 382 +++
 libavformat/Makefile   |   1 +
 libavformat/allformats.c   |   1 +
 libavformat/img2.c |   1 +
 libavformat/img2dec.c  |  18 ++
 libavformat/img2enc.c  |   6 +-
 libavformat/jpegxl_probe.c | 393 +
 libavformat/jpegxl_probe.h |  32 +++
 libavformat/mov.c  |   1 +
 19 files changed, 1254 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/libjxl.c
 create mode 100644 libavcodec/libjxl.h
 create mode 100644 libavcodec/libjxldec.c
 create mode 100644 libavcodec/libjxlenc.c
 create mode 100644 libavformat/jpegxl_probe.c
 create mode 100644 libavformat/jpegxl_probe.h

-- 
2.35.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 4/4] fate/oma: Use REMUX where appropriate

2022-04-11 Thread Andreas Rheinhardt
Simplifies the checks.

Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/oma.mak | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/tests/fate/oma.mak b/tests/fate/oma.mak
index a088feff21..7e2020b7d0 100644
--- a/tests/fate/oma.mak
+++ b/tests/fate/oma.mak
@@ -8,14 +8,8 @@ fate-oma-atrac3p-remux: CMD = transcode oma 
$(TARGET_SAMPLES)/atrac3p/at3p_sampl
 FATE_OMA_REMUX-$(CONFIG_WAV_DEMUXER) += fate-oma-atrac3-remux
 fate-oma-atrac3-remux: CMD = transcode wav 
$(TARGET_SAMPLES)/atrac3/mc_sich_at3_132_small.wav oma "-c copy" "-c copy -t 
0.1"
 
-FATE_OMA_FFMPEG-$(call ALLYES, FILE_PROTOCOL OMA_MUXER\
-   OMA_DEMUXER FRAMECRC_MUXER \
-   PIPE_PROTOCOL) \
-   += $(FATE_OMA_REMUX-yes)
-FATE_OMA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL OMA_MUXER\
-   OMA_DEMUXER FRAMECRC_MUXER \
-   PIPE_PROTOCOL) \
-   += $(FATE_OMA_REMUX_FFPROBE-yes)
+FATE_OMA_FFMPEG-$(call REMUX, OMA) += $(FATE_OMA_REMUX-yes)
+FATE_OMA_FFMPEG_FFPROBE-$(call REMUX, OMA) += $(FATE_OMA_REMUX_FFPROBE-yes)
 FATE_SAMPLES_FFMPEG += $(FATE_OMA_FFMPEG-yes)
 FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_OMA_FFMPEG_FFPROBE-yes)
 fate-oma: $(FATE_OMA_FFMPEG-yes) $(FATE_OMA_FFMPEG_FFPROBE-yes)
-- 
2.32.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 3/4] fate/subtitles: Use REMUX where appropriate

2022-04-11 Thread Andreas Rheinhardt
It also adds the missing depenencies on the file and pipe protocols
and the framecrc muxer.

Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/subtitles.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/fate/subtitles.mak b/tests/fate/subtitles.mak
index 8375cf2898..bc464edce6 100644
--- a/tests/fate/subtitles.mak
+++ b/tests/fate/subtitles.mak
@@ -22,7 +22,7 @@ fate-binsub-mksenc: CMD = md5pipe -i 
$(TARGET_SAMPLES)/sub/1ededcbd7b.ass -c cop
 FATE_SUBTITLES_ASS-$(call DEMDEC, JACOSUB, JACOSUB) += fate-sub-jacosub
 fate-sub-jacosub: CMD = fmtstdout ass -i 
$(TARGET_SAMPLES)/sub/JACOsub_capability_tester.jss
 
-FATE_SUBTITLES-$(call DEMMUX, JACOSUB, JACOSUB) += fate-sub-jacosub-remux
+FATE_SUBTITLES-$(call REMUX, JACOSUB) += fate-sub-jacosub-remux
 fate-sub-jacosub-remux: CMD = transcode jacosub 
$(TARGET_SAMPLES)/sub/JACOsub_capability_tester.jss jacosub "-map 0 -c copy" 
"-map 0 -c copy"
 fate-sub-jacosub-remux: CMP = diff
 
-- 
2.32.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 2/4] fate/image: Use TRANSCODE where appropriate

2022-04-11 Thread Andreas Rheinhardt
This also adds previously forgotten requirements. E.g. fate-jpg-icc
actually depends on the png decoder, so that it should not be run
when e.g. zlib is disabled, yet it happens, see
http://fate.ffmpeg.org/report.cgi?time=20220411182746=x86_64-archlinux-gcc-disablezlib

Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/image.mak | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 70be281411..63076f8ded 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -337,7 +337,7 @@ fate-jpg-12bpp: CMD = framecrc -idct simple -i 
$(TARGET_SAMPLES)/jpg/12bpp.jpg -
 FATE_JPG += fate-jpg-jfif
 fate-jpg-jfif: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/jpg/20242.jpg
 
-FATE_JPG_TRANSCODE-$(call ENCDEC, MJPEG, IMAGE2) += fate-jpg-icc
+FATE_JPG_TRANSCODE-$(call TRANSCODE, MJPEG, MJPEG IMAGE_JPEG_PIPE, 
IMAGE_PNG_PIPE_DEMUXER PNG_DECODER SCALE_FILTER) += fate-jpg-icc
 fate-jpg-icc: CMD = transcode png_pipe 
$(TARGET_SAMPLES)/png1/lena-int_rgb24.png mjpeg "-vf scale" "" "" "-show_frames"
 
 FATE_JPG-$(call DEMDEC, IMAGE2, MJPEG) += $(FATE_JPG)
@@ -389,7 +389,7 @@ FATE_PNG_PROBE += fate-png-side-data
 fate-png-side-data: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_frames \
 -i $(TARGET_SAMPLES)/png1/lena-int_rgb24.png
 
-FATE_PNG_TRANSCODE-$(call ENCDEC, PNG, IMAGE2) += fate-png-icc
+FATE_PNG_TRANSCODE-$(call TRANSCODE, PNG, IMAGE2 IMAGE_PNG_PIPE) += 
fate-png-icc
 fate-png-icc: CMD = transcode png_pipe 
$(TARGET_SAMPLES)/png1/lena-int_rgb24.png image2 "-c png" "" "" "-show_frames"
 
 FATE_PNG-$(call DEMDEC, IMAGE2, PNG) += $(FATE_PNG)
-- 
2.32.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 1/4] tests/Makefile: Add auxiliary functions for transcode and stream_remux

2022-04-11 Thread Andreas Rheinhardt
Tests using the transcode and stream_remux functions have some common
requirements (namely the file and pipe protocols as well as the framecrc
muxer) and also other commonalities: The create a file and read it
immediately afterwards, so that they typically rely on a corresponding
muxer+demuxer pair which typically shares the same name; for transcode
(if it does not use stream copy) the same is true for encoders and
decoders. This means that using special Makefile-functions instead
of the general ALLYES is worthwhile. This commit adds such functions.

These functions allow to add arbitrary CONFIG-checks on top of the
aforementioned ones in order to satisfy special needs (for e.g. parsers,
filters) that several intended users have.

Signed-off-by: Andreas Rheinhardt 
---
 tests/Makefile | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/tests/Makefile b/tests/Makefile
index e3b41a4f7b..5e4da2c42f 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -74,6 +74,16 @@ ENCDEC2 = $(call ALLYES, $(firstword $(1))_ENCODER 
$(lastword $(1))_DECODER  \
  $(firstword $(2))_ENCODER $(lastword $(2))_DECODER  \
  $(firstword $(3))_MUXER   $(lastword $(3))_DEMUXER)
 
+# RAWVIDEO_ENCODER and PCM_S16LE_ENCODER corresponds to the default codecs
+# for framecrc. These requirements are not always necessary.
+TRANSCODE = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword $(1))_DECODER \
+   $(firstword $(2))_MUXER   $(lastword $(2))_DEMUXER \
+   $(3) FILE_PROTOCOL PIPE_PROTOCOL RAWVIDEO_ENCODER  \
+   PCM_S16LE_ENCODER FRAMECRC_MUXER)
+
+REMUX = $(call ALLYES, $(firstword $(1))_MUXER $(lastword $(1))_DEMUXER \
+   $(2) FILE_PROTOCOL PIPE_PROTOCOL FRAMECRC_MUXER)
+
 DEMDEC  = $(call ALLYES, $(1)_DEMUXER $(2:%=%_DECODER))
 ENCMUX  = $(call ALLYES, $(1:%=%_ENCODER) $(2)_MUXER)
 
-- 
2.32.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 4/4] avcodec/mjpegenc: Don't unnecessarily grow buffer

2022-04-11 Thread Andreas Rheinhardt
The size of the ICC chunk has already been accounted for when
the packet's buffer was initially set in ff_mpv_encode_picture()
and the header (including the ICC chunk) has already been written
at this point.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mjpegenc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 1e9b97535a..8cada8366c 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -131,7 +131,6 @@ static void mjpeg_encode_picture_frame(MpegEncContext *s)
 }
 
 bytes_needed = (total_bits + 7) / 8;
-ff_mjpeg_add_icc_profile_size(s->avctx, s->picture->f, _needed);
 ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
 
 for (int i = 0; i < m->huff_ncode; i++) {
-- 
2.32.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 3/4] avcodec/mpegvideo_enc: Remove always-true check

2022-04-11 Thread Andreas Rheinhardt
It is a remnant of the old way for user-supplied buffers;
it is always-true since 93016f5d1d280f9cb7856883af287fa66affc04c.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo_enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 434bbb3a68..c9d8c48026 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1683,7 +1683,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket 
*pkt,
 
 /* output? */
 if (s->new_picture->data[0]) {
-int growing_buffer = context_count == 1 && !pkt->data && 
!s->data_partitioning;
+int growing_buffer = context_count == 1 && !s->data_partitioning;
 size_t pkt_size = 1 + s->mb_width * s->mb_height *
   (growing_buffer ? 64 : (MAX_MB_BYTES + 100));
 if (CONFIG_MJPEG_ENCODER && avctx->codec_id == AV_CODEC_ID_MJPEG) {
-- 
2.32.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 2/4] avcodec/mpegvideo_enc: Fix unnecessary linear growth of buffer

2022-04-11 Thread Andreas Rheinhardt
If one encodes MJPEG with a single slice and uses input with
AV_FRAME_DATA_ICC_PROFILE side data, the current allocation code
in ff_mpv_encode_picture() will always increase the size of the
temporary buffer used for allocating packets by the size needed
for to write the ICC chunk even when the current buffer is actually
large enough. This commit fixes this.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo_enc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 4a5e5a5059..434bbb3a68 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1684,9 +1684,8 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket 
*pkt,
 /* output? */
 if (s->new_picture->data[0]) {
 int growing_buffer = context_count == 1 && !pkt->data && 
!s->data_partitioning;
-size_t pkt_size = growing_buffer ? 
FFMAX(s->mb_width*s->mb_height*64+1, avctx->internal->byte_buffer_size) - 
AV_INPUT_BUFFER_PADDING_SIZE
-  :
-  
s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+1;
+size_t pkt_size = 1 + s->mb_width * s->mb_height *
+  (growing_buffer ? 64 : (MAX_MB_BYTES + 100));
 if (CONFIG_MJPEG_ENCODER && avctx->codec_id == AV_CODEC_ID_MJPEG) {
 ret = ff_mjpeg_add_icc_profile_size(avctx, s->new_picture, 
_size);
 if (ret < 0)
@@ -1694,6 +1693,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket 
*pkt,
 }
 if ((ret = ff_alloc_packet(avctx, pkt, pkt_size)) < 0)
 return ret;
+pkt->size = avctx->internal->byte_buffer_size - 
AV_INPUT_BUFFER_PADDING_SIZE;
 if (s->mb_info) {
 s->mb_info_ptr = av_packet_new_side_data(pkt,
  AV_PKT_DATA_H263_MB_INFO,
-- 
2.32.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 1/4] avcodec/mpegvideo_enc: Ignore ICC profile size when not MJPEG

2022-04-11 Thread Andreas Rheinhardt
MJPEG is the only mpegvideo-based encoder making use of it.
Fixes linking failures in case mpegvideo_enc.c is compiled
with AMV, LJPEG and MJPEG encoders disabled.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo_enc.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 40bcf09c0b..4a5e5a5059 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1687,8 +1687,11 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, 
AVPacket *pkt,
 size_t pkt_size = growing_buffer ? 
FFMAX(s->mb_width*s->mb_height*64+1, avctx->internal->byte_buffer_size) - 
AV_INPUT_BUFFER_PADDING_SIZE
   :
   
s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+1;
-if ((ret = ff_mjpeg_add_icc_profile_size(avctx, s->new_picture, 
_size)) < 0)
-return ret;
+if (CONFIG_MJPEG_ENCODER && avctx->codec_id == AV_CODEC_ID_MJPEG) {
+ret = ff_mjpeg_add_icc_profile_size(avctx, s->new_picture, 
_size);
+if (ret < 0)
+return ret;
+}
 if ((ret = ff_alloc_packet(avctx, pkt, pkt_size)) < 0)
 return ret;
 if (s->mb_info) {
-- 
2.32.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 2/4] avformat/genh: Check sample rate

2022-04-11 Thread Michael Niedermayer
Fixes: signed integer overflow: -2515507630940093440 * 4 cannot be represented 
in type 'long'
Fixes: 
46318/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-5009637474172928

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/genh.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/genh.c b/libavformat/genh.c
index b1c20718f6..a25d4d625a 100644
--- a/libavformat/genh.c
+++ b/libavformat/genh.c
@@ -67,6 +67,9 @@ static int genh_read_header(AVFormatContext *s)
 return AVERROR_INVALIDDATA;
 st->codecpar->block_align = align * st->codecpar->ch_layout.nb_channels;
 st->codecpar->sample_rate = avio_rl32(s->pb);
+if (st->codecpar->sample_rate < 0)
+return AVERROR_INVALIDDATA;
+
 avio_skip(s->pb, 4);
 st->duration = avio_rl32(s->pb);
 
-- 
2.17.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 3/4] avfilter/video: Add ff_default_get_video_buffer2() to set specific alignment

2022-04-11 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavfilter/video.c | 8 ++--
 libavfilter/video.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavfilter/video.c b/libavfilter/video.c
index b2f0cdf88a..e9eb110ff4 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -38,13 +38,12 @@ AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int 
w, int h)
 return ff_get_video_buffer(link->dst->outputs[0], w, h);
 }
 
-AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
+AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int 
align)
 {
 AVFrame *frame = NULL;
 int pool_width = 0;
 int pool_height = 0;
 int pool_align = 0;
-int align = av_cpu_max_align();
 enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
 
 if (link->hw_frames_ctx &&
@@ -94,6 +93,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int 
w, int h)
 return frame;
 }
 
+AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
+{
+return ff_default_get_video_buffer2(link, w, h, av_cpu_max_align());
+}
+
 AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int h)
 {
 AVFrame *ret = NULL;
diff --git a/libavfilter/video.h b/libavfilter/video.h
index f448e4ada4..f37bab9d03 100644
--- a/libavfilter/video.h
+++ b/libavfilter/video.h
@@ -24,6 +24,7 @@
 #include "avfilter.h"
 
 AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h);
+AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int 
align);
 AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h);
 
 /**
-- 
2.17.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 4/4] avfilter/vf_frei0r: Copy to frame allocated according to frei0r requirements

2022-04-11 Thread Michael Niedermayer
Fixes: issues with non trivial linesize

Signed-off-by: Michael Niedermayer 
---
 libavfilter/vf_frei0r.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 9cd0098e73..f11ae6e55c 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -353,14 +353,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 Frei0rContext *s = inlink->dst->priv;
 AVFilterLink *outlink = inlink->dst->outputs[0];
-AVFrame *out;
+AVFrame *out = ff_default_get_video_buffer2(outlink, outlink->w, 
outlink->h, 16);
+if (!out)
+goto fail;
 
-out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-if (!out) {
+av_frame_copy_props(out, in);
+
+if (in->linesize[0] != out->linesize[0]) {
+AVFrame *in2 = ff_default_get_video_buffer2(outlink, outlink->w, 
outlink->h, 16);
+if (!in2)
+goto fail;
+av_frame_copy(in2, in);
 av_frame_free();
-return AVERROR(ENOMEM);
+in = in2;
 }
-av_frame_copy_props(out, in);
 
 s->update(s->instance, in->pts * av_q2d(inlink->time_base) * 1000,
(const uint32_t *)in->data[0],
@@ -369,6 +375,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 av_frame_free();
 
 return ff_filter_frame(outlink, out);
+fail:
+av_frame_free();
+av_frame_free();
+return AVERROR(ENOMEM);
 }
 
 static int process_command(AVFilterContext *ctx, const char *cmd, const char 
*args,
@@ -465,7 +475,7 @@ static int source_config_props(AVFilterLink *outlink)
 static int source_request_frame(AVFilterLink *outlink)
 {
 Frei0rContext *s = outlink->src->priv;
-AVFrame *frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+AVFrame *frame = ff_default_get_video_buffer2(outlink, outlink->w, 
outlink->h, 16);
 
 if (!frame)
 return AVERROR(ENOMEM);
-- 
2.17.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 1/4] avformat/demux: Use unsigned to check duration vs duration_text

2022-04-11 Thread Michael Niedermayer
Fixes: signed integer overflow: 9223371898743775808 - -13811100 cannot be 
represented in type 'long'
Fixes: 
46245/clusterfuzz-testcase-minimized-ffmpeg_dem_OGG_fuzzer-5075129786302464

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/demux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index ef189d9d8e..ad7b5dbf83 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1612,7 +1612,7 @@ static void update_stream_timings(AVFormatContext *ic)
 else if (end_time < end_time_text)
 av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream 
endtime %f\n", end_time_text / (float)AV_TIME_BASE);
 
- if (duration == INT64_MIN || (duration < duration_text && duration_text - 
duration < AV_TIME_BASE))
+ if (duration == INT64_MIN || (duration < duration_text && 
(uint64_t)duration_text - duration < AV_TIME_BASE))
  duration = duration_text;
  else if (duration < duration_text)
  av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream 
duration %f\n", duration_text / (float)AV_TIME_BASE);
-- 
2.17.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] avfilter/alimiter: Add "flush_buffer" option to flush the remaining valid data to the output

2022-04-11 Thread Wang Cao
On Sat, Apr 9, 2022 at 5:35 AM Paul B Mahol  wrote:

> On Fri, Apr 8, 2022 at 10:41 PM Wang Cao  >
> wrote:
>
> > On Fri, Apr 8, 2022 at 11:40 AM Paul B Mahol  wrote:
> >
> > > On Thu, Apr 7, 2022 at 11:56 PM Wang Cao <
> > wangcao-at-google@ffmpeg.org
> > > >
> > > wrote:
> > >
> > > > On Thu, Apr 7, 2022 at 12:44 AM Paul B Mahol 
> wrote:
> > > >
> > > > > On Wed, Apr 6, 2022 at 1:49 PM Paul B Mahol 
> > wrote:
> > > > >
> > > > > >
> > > > > >
> > > > > > On Tue, Apr 5, 2022 at 8:57 PM Wang Cao <
> > > > > wangcao-at-google@ffmpeg.org>
> > > > > > wrote:
> > > > > >
> > > > > >> On Mon, Apr 4, 2022 at 3:28 PM Marton Balint 
> > wrote:
> > > > > >>
> > > > > >> >
> > > > > >> >
> > > > > >> > On Mon, 4 Apr 2022, Paul B Mahol wrote:
> > > > > >> >
> > > > > >> > > On Sun, Mar 27, 2022 at 11:41 PM Marton Balint <
> c...@passwd.hu
> > >
> > > > > wrote:
> > > > > >> > >
> > > > > >> > >>
> > > > > >> > >>
> > > > > >> > >> On Sat, 26 Mar 2022, Wang Cao wrote:
> > > > > >> > >>
> > > > > >> > >>> The change in the commit will add some samples to the end
> of
> > > the
> > > > > >> audio
> > > > > >> > >>> stream. The intention is to add a "zero_delay" option
> > > eventually
> > > > > to
> > > > > >> not
> > > > > >> > >>> have the delay in the begining the output from alimiter
> due
> > to
> > > > > >> > >>> lookahead.
> > > > > >> > >>
> > > > > >> > >> I was very much suprised to see that the alimiter filter
> > > actually
> > > > > >> delays
> > > > > >> > >> the audio - as in extra samples are inserted in the
> beginning
> > > and
> > > > > >> some
> > > > > >> > >> samples are cut in the end. This trashes A-V sync, so it
> is a
> > > bug
> > > > > >> IMHO.
> > > > > >> > >>
> > > > > >> > >> So unless somebody has some valid usecase for the legacy
> way
> > of
> > > > > >> > operation
> > > > > >> > >> I'd just simply change it to be "zero delay" without any
> > > > additional
> > > > > >> user
> > > > > >> > >> option, in a single patch.
> > > > > >> > >>
> > > > > >> > >
> > > > > >> > >
> > > > > >> > > This is done by this patch in very complicated way and also
> it
> > > > > really
> > > > > >> > > should be optional.
> > > > > >> >
> > > > > >> > But why does it make sense to keep the current (IMHO buggy)
> > > > > operational
> > > > > >> > mode which adds silence in the beginning and trims the end? I
> > > > > understand
> > > > > >> > that the original implementation worked like this, but
> > libavfilter
> > > > has
> > > > > >> > packet timestamps and N:M filtering so there is absolutely no
> > > reason
> > > > > to
> > > > > >> > use an 1:1 implementation and live with its limitations.
> > > > > >> >
> > > > > >> Hello Paul and Marton, thank you so much for taking time to
> review
> > > my
> > > > > >> patch.
> > > > > >> I totally understand that my patch may seem a little bit
> > complicated
> > > > > but I
> > > > > >> can
> > > > > >> show with a FATE test that if we set the alimiter to behave as a
> > > > > >> passthrough filter,
> > > > > >> the output frames will be the same from "framecrc" with my
> patch.
> > > The
> > > > > >> existing
> > > > > >> behavior will not work for all gapless audio processing.
> > > > > >>
> > > > > >> The complete patch to fix this issue is at
> > > > > >>
> > > > > >>
> > > > >
> > > >
> > >
> >
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220330210314.2055201-1-wang...@google.com/
> > > > > >>
> > > > > >> Regarding Paul's concern, I personally don't have any preference
> > > > whether
> > > > > >> to
> > > > > >> put
> > > > > >> the patch as an extra option or not. With respect to the
> > > > implementation,
> > > > > >> the patch
> > > > > >> is the best I can think of by preserving as much information as
> > > > possible
> > > > > >> from input
> > > > > >> frames. I also understand it may break concept that
> "filter_frame"
> > > > > outputs
> > > > > >> one frame
> > > > > >> at a time. For alimiter with my patch, depending on the size of
> > the
> > > > > >> lookahead buffer,
> > > > > >> it may take a few frames before one output frame can be
> generated.
> > > > This
> > > > > is
> > > > > >> inevitable
> > > > > >> to compensate for the delay of the lookahead buffer.
> > > > > >>
> > > > > >> Thanks again for reviewing my patch and I'm looking forward to
> > > hearing
> > > > > >> from
> > > > > >> you :)
> > > > > >>
> > > > > >
> > > > > > Better than (because its no more 1 frame X nb_samples in, 1
> frame X
> > > > > > nb_samples out) to replace .filter_frame/.request_frame with
> > > .activate
> > > > > > logic.
> > > > > >
> > > > > > And make this output delay compensation filtering optional.
> > > > > >
> > > > > > In this process make sure that output PTS frame timestamps are
> > > > unchanged
> > > > > > from input one, by keeping reference of needed frames in filter
> > > queue.
> > > > > >
> > > > > > Look how speechnorm/dynaudnorm does it.
> > > > > >
> > > > >
> > > > >
> > > > > Alternatively, use current 

Re: [FFmpeg-devel] [RFC] Switching ffmpeg.c to a threaded architecture

2022-04-11 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Paul
> B Mahol
> Sent: Monday, April 11, 2022 10:52 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [RFC] Switching ffmpeg.c to a threaded
> architecture
> 
> On Mon, Apr 11, 2022 at 10:10 PM Soft Works 
> wrote:
> 
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Anton Khirnov
> > > Sent: Monday, April 11, 2022 10:29 AM
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [RFC] Switching ffmpeg.c to a threaded
> > > architecture
> > >
> > > Quoting Soft Works (2022-04-08 17:27:10)
> > > > > Furthermore, remember that this is just the first step. There
> will
> > > be
> > > > > further patchsets converting the other components. I intend to
> > > > > upstream
> > > > > them gradually one after the other. Your suggestion would
> require
> > > me
> > > > > to
> > > > > instead write the whole thing at once, fighting rebase
> conflicts
> > > all
> > > > > the
> > > > > way, and then submit it as a giant utterly unreviewable
> patchset.
> > > >
> > > > That's not what I meant, but anyway it's not worth discussing
> when
> > > > it's a minority opinion.
> > > >
> > > > Just a practical question instead for planning purposes:
> > > >
> > > > Which timeframe do you expect for the whole process?
> > > > When do you plan to start
> > >
> > > If you mean "start pushing the patches", then I intend to do that
> as
> > > they are reviewed and approved. I hope to send the upstreamable
> > > version
> > > of this set this week, if nobody has strong objectsions then I
> might
> > > push it after vacation, i.e. late April/early May.
> > >
> > > > and for how long do you think it will take until all further
> > > patchsets
> > > > will be submitted/applied?
> > >
> > > This is very hard to estimate accurately. A pessimistic guess
> assuming
> > > I
> > > get stuck on every stupid thing would be end of this year, but I
> hope
> > > for things to go much faster.
> >
> > Thanks for the reply. I'm asking because I need to decide about the
> > way I'm going to proceed with the subtitle filtering patchset.
> >
> > I think I will have to keep and continue this in private during this
> > procedure as I don't have the resources to regularly adapt and sync
> > from my (5.0 based) working branch back to the master branch.
> >
> >
> That is big waste of resource when not implementing thing properly.

>From my point of view, somebody who has never given any detailed 
reviews, didn't state what exactly(!) he would consider to be "improper"
and never made any suggestion how the implementation would need to 
be changed to become "proper" - doesn't have the right to make such
claims.

softworkz



___
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] avformat/mov: fix timecode with high frame rate content

2022-04-11 Thread Marton Balint




On Mon, 11 Apr 2022, Anton Khirnov wrote:


Quoting Marton Balint (2022-04-10 20:11:59)

60 fps content have "Number of Frames" set to 30 in the tmcd atom, but the
frame duration / timescale reflects the original video frame rate.

Therefore we multiply the frame count with the quotient of the rounded timecode
frame rate and the "Number of Frames" per second to get a frame count in the 
original
(higher) frame rate.

Note that the frames part in the timecode will be in high frame rate which will
make the timecode different to e.g. MediaInfo which seems to show the 30 fps
timecode even for 120 fps content.

Regression since 428b4aacb1a91a267650de644519882a5f700388.

Fixes ticket #9710.
Fixes ticket #9492.


Sounds like there should be a test for this.


The smallest file I managed to find which is affected by this is
mov/canon_6d/mvi_9114.mov, but that is still 12 MB, therefore probably not
fit for addition to fate-samples.

With our muxer, the issue is not reproducible, so remuxing is not an
option.

Regards,
Marton
___
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] Switching ffmpeg.c to a threaded architecture

2022-04-11 Thread Paul B Mahol
On Mon, Apr 11, 2022 at 10:10 PM Soft Works  wrote:

>
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Anton Khirnov
> > Sent: Monday, April 11, 2022 10:29 AM
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [RFC] Switching ffmpeg.c to a threaded
> > architecture
> >
> > Quoting Soft Works (2022-04-08 17:27:10)
> > > > Furthermore, remember that this is just the first step. There will
> > be
> > > > further patchsets converting the other components. I intend to
> > > > upstream
> > > > them gradually one after the other. Your suggestion would require
> > me
> > > > to
> > > > instead write the whole thing at once, fighting rebase conflicts
> > all
> > > > the
> > > > way, and then submit it as a giant utterly unreviewable patchset.
> > >
> > > That's not what I meant, but anyway it's not worth discussing when
> > > it's a minority opinion.
> > >
> > > Just a practical question instead for planning purposes:
> > >
> > > Which timeframe do you expect for the whole process?
> > > When do you plan to start
> >
> > If you mean "start pushing the patches", then I intend to do that as
> > they are reviewed and approved. I hope to send the upstreamable
> > version
> > of this set this week, if nobody has strong objectsions then I might
> > push it after vacation, i.e. late April/early May.
> >
> > > and for how long do you think it will take until all further
> > patchsets
> > > will be submitted/applied?
> >
> > This is very hard to estimate accurately. A pessimistic guess assuming
> > I
> > get stuck on every stupid thing would be end of this year, but I hope
> > for things to go much faster.
>
> Thanks for the reply. I'm asking because I need to decide about the
> way I'm going to proceed with the subtitle filtering patchset.
>
> I think I will have to keep and continue this in private during this
> procedure as I don't have the resources to regularly adapt and sync
> from my (5.0 based) working branch back to the master branch.
>
>
That is big waste of resource when not implementing thing properly.


> Thanks,
> softworkz
>
>
>
>
>
> ___
> 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] [PATCH] avfilter/vf_frei0r: Copy to frame allocated according to frei0r requirements

2022-04-11 Thread Michael Niedermayer
On Mon, Apr 11, 2022 at 03:01:57PM -0300, James Almer wrote:
> 
> 
> On 4/11/2022 10:31 AM, Michael Niedermayer wrote:
> > Fixes: issues with non trivial linesize
> > 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >   libavfilter/vf_frei0r.c | 40 
> >   1 file changed, 32 insertions(+), 8 deletions(-)
> > 
> > diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
> > index 9cd0098e73..c9b698897f 100644
> > --- a/libavfilter/vf_frei0r.c
> > +++ b/libavfilter/vf_frei0r.c
> > @@ -349,18 +349,41 @@ static int query_formats(AVFilterContext *ctx)
> >   return ff_set_common_formats(ctx, formats);
> >   }
> > +static AVFrame *getframe(AVFilterLink *link)
> > +{
> > +int ret;
> > +AVFrame *frame = av_frame_alloc();
> > +if (!frame)
> > +return NULL;
> > +
> > +frame->width  = link->w;
> > +frame->height = link->h;
> > +frame->format = link->format;
> > +ret = av_frame_get_buffer(frame, 16);
> 
> Maybe ff_get_video_buffer can be updated to accept an align argument which
> would be used instead of av_cpu_max_align() when not 0, so we don't lose the
> benefits of the frame pool it provides?

We need a specific alignment and specific linesize.
ff_get_video_buffer() is forwarded to the next filter so a change to it
feels moderately messy. Each filter using it would have to deal with
specific linesize and alignment requirements. Thats for one odd filter
What can be done is to work with ff_default_get_video_buffer() maybe
and never use the next filters one.
Ill send a patch doing that if it pases tests

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2



signature.asc
Description: PGP signature
___
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] Switching ffmpeg.c to a threaded architecture

2022-04-11 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Anton Khirnov
> Sent: Monday, April 11, 2022 10:29 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [RFC] Switching ffmpeg.c to a threaded
> architecture
> 
> Quoting Soft Works (2022-04-08 17:27:10)
> > > Furthermore, remember that this is just the first step. There will
> be
> > > further patchsets converting the other components. I intend to
> > > upstream
> > > them gradually one after the other. Your suggestion would require
> me
> > > to
> > > instead write the whole thing at once, fighting rebase conflicts
> all
> > > the
> > > way, and then submit it as a giant utterly unreviewable patchset.
> >
> > That's not what I meant, but anyway it's not worth discussing when
> > it's a minority opinion.
> >
> > Just a practical question instead for planning purposes:
> >
> > Which timeframe do you expect for the whole process?
> > When do you plan to start
> 
> If you mean "start pushing the patches", then I intend to do that as
> they are reviewed and approved. I hope to send the upstreamable
> version
> of this set this week, if nobody has strong objectsions then I might
> push it after vacation, i.e. late April/early May.
> 
> > and for how long do you think it will take until all further
> patchsets
> > will be submitted/applied?
> 
> This is very hard to estimate accurately. A pessimistic guess assuming
> I
> get stuck on every stupid thing would be end of this year, but I hope
> for things to go much faster.

Thanks for the reply. I'm asking because I need to decide about the 
way I'm going to proceed with the subtitle filtering patchset.

I think I will have to keep and continue this in private during this
procedure as I don't have the resources to regularly adapt and sync 
from my (5.0 based) working branch back to the master branch.

Thanks,
softworkz





___
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] avfilter/vf_frei0r: Copy to frame allocated according to frei0r requirements

2022-04-11 Thread Michael Niedermayer
On Mon, Apr 11, 2022 at 07:34:40PM +0200, Paul B Mahol wrote:
> On Mon, Apr 11, 2022 at 3:32 PM Michael Niedermayer 
> wrote:
> 
> > Fixes: issues with non trivial linesize
> >
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavfilter/vf_frei0r.c | 40 
> >  1 file changed, 32 insertions(+), 8 deletions(-)
> >
> > diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
> > index 9cd0098e73..c9b698897f 100644
> > --- a/libavfilter/vf_frei0r.c
> > +++ b/libavfilter/vf_frei0r.c
> > @@ -349,18 +349,41 @@ static int query_formats(AVFilterContext *ctx)
> >  return ff_set_common_formats(ctx, formats);
> >  }
> >
> > +static AVFrame *getframe(AVFilterLink *link)
> > +{
> > +int ret;
> > +AVFrame *frame = av_frame_alloc();
> > +if (!frame)
> > +return NULL;
> > +
> > +frame->width  = link->w;
> > +frame->height = link->h;
> > +frame->format = link->format;
> > +ret = av_frame_get_buffer(frame, 16);
> > +if (ret < 0)
> > +av_frame_free();
> > +
> > +return frame;
> > +}
> > +
> >  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
> >  {
> >  Frei0rContext *s = inlink->dst->priv;
> >  AVFilterLink *outlink = inlink->dst->outputs[0];
> > -AVFrame *out;
> > +AVFrame *out = getframe(outlink);
> > +if (!out)
> > +goto fail;
> >
> > -out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
> > -if (!out) {
> > +av_frame_copy_props(out, in);
> > +
> > +if (in->linesize[0] != out->linesize[0]) {
> > +AVFrame *in2 = getframe(outlink);
> > +if (!in2)
> > +goto fail;
> > +av_frame_copy(in2, in);
> >  av_frame_free();
> > -return AVERROR(ENOMEM);
> > +in = in2;
> >  }
> > -av_frame_copy_props(out, in);
> >
> >  s->update(s->instance, in->pts * av_q2d(inlink->time_base) * 1000,
> > (const uint32_t *)in->data[0],
> > @@ -369,6 +392,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> > *in)
> >  av_frame_free();
> >
> >  return ff_filter_frame(outlink, out);
> > +fail:
> > +av_frame_free();
> > +av_frame_free();
> > +return AVERROR(ENOMEM);
> >  }
> >
> >  static int process_command(AVFilterContext *ctx, const char *cmd, const
> > char *args,
> > @@ -473,9 +500,6 @@ static int source_request_frame(AVFilterLink *outlink)
> >  frame->sample_aspect_ratio = (AVRational) {1, 1};
> >  frame->pts = s->pts++;
> >
> > -s->update(s->instance, av_rescale_q(frame->pts, s->time_base,
> > (AVRational){1,1000}),
> > -   NULL, (uint32_t *)frame->data[0]);
> >
> >
> Why this is removed?

i did miss that frei0r_src exists


> 
> That handle frei0r source filters.

I ll send a better patch

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


signature.asc
Description: PGP signature
___
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] warning about configuration mismatch between ff* binaries and libraries

2022-04-11 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Anton Khirnov
> Sent: Monday, April 11, 2022 9:47 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] warning about configuration mismatch
> between ff* binaries and libraries
> 
> Quoting zhilizhao(赵志立) (2022-04-11 05:15:59)
> >
> >
> > > On Apr 11, 2022, at 5:31 AM, Dominik 'Rathann' Mierzejewski
>  wrote:
> > >
> > > Dear Developers!
> > > I'm curious about the warning about configuration mismatch between
> ff*
> > > binaries and the libraries introduced in:
> > >
> > >
> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/9120e2cd3fadfa60269e94
> f97fc8107974c586fc
> > >
> > > At Fedora, we're interested in having two builds: one built with
> limited
> > > set of codecs[1] that is legally distributable in the US (since
> Red Hat,
> > > Fedora sponsor is a US-based company) and another, with a more
> complete
> > > set of codecs[2] distributed by RPM Fusion. The builds are
> intended to
> > > be drop-in replacements. We'd like to be able to distribute just
> one set
> > > of ff* binaries and only have two different interchangeable builds
> of
> > > libraries.
> > >
> > > The idea is to have the builds differ by enabled codecs only and
> have
> > > the rest of the configuration the same (even if it's not the case
> > > today).
> > >
> > > So, does that warning still make sense today? Will something break
> > > if we swap the libraries but keep the binary on user systems?
> >
> > That’s exactly an example of why the warning is useful. Otherwise
> user can
> > be confused why some codecs are missing while banner says they are
> enabled
> > by configure. So yes, the warning still make sense.
> 
> I would prefer to not show all that noise in the banner, which would
> also resolve the confusion. Build information should be reduced to
> loglevel verbose IMO.

I agree and I would suggest reconsidering James' earlier patch for this.

softworkz
___
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] lavc/snow: only allocate mconly_picture for decoding

2022-04-11 Thread Michael Niedermayer
On Mon, Apr 11, 2022 at 10:49:34AM +0200, Anton Khirnov wrote:
> It is not used in the encoder.
> ---
> Does this fix the crash?
> ---
>  libavcodec/snow.c | 12 
>  1 file changed, 8 insertions(+), 4 deletions(-)

This patch alone works fine

i havnt tested it in conjunction with other patches as i slightly 
lost track but 1-3 + this seem not to build or i did something stupid

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"I am not trying to be anyone's saviour, I'm trying to think about the
 future and not be sad" - Elon Musk



signature.asc
Description: PGP signature
___
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] avfilter: add Audio Video Sync Test filter

2022-04-11 Thread Paul B Mahol
On Sat, Apr 9, 2022 at 9:21 PM Paul B Mahol  wrote:

>
> will apply soon
>


Forgot to apply, will apply in next 24h.
___
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] avfilter/vf_frei0r: Copy to frame allocated according to frei0r requirements

2022-04-11 Thread James Almer




On 4/11/2022 10:31 AM, Michael Niedermayer wrote:

Fixes: issues with non trivial linesize

Signed-off-by: Michael Niedermayer 
---
  libavfilter/vf_frei0r.c | 40 
  1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 9cd0098e73..c9b698897f 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -349,18 +349,41 @@ static int query_formats(AVFilterContext *ctx)
  return ff_set_common_formats(ctx, formats);
  }
  
+static AVFrame *getframe(AVFilterLink *link)

+{
+int ret;
+AVFrame *frame = av_frame_alloc();
+if (!frame)
+return NULL;
+
+frame->width  = link->w;
+frame->height = link->h;
+frame->format = link->format;
+ret = av_frame_get_buffer(frame, 16);


Maybe ff_get_video_buffer can be updated to accept an align argument 
which would be used instead of av_cpu_max_align() when not 0, so we 
don't lose the benefits of the frame pool it provides?



+if (ret < 0)
+av_frame_free();
+
+return frame;
+}
+
  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
  {
  Frei0rContext *s = inlink->dst->priv;
  AVFilterLink *outlink = inlink->dst->outputs[0];
-AVFrame *out;
+AVFrame *out = getframe(outlink);
+if (!out)
+goto fail;
  
-out = ff_get_video_buffer(outlink, outlink->w, outlink->h);

-if (!out) {
+av_frame_copy_props(out, in);
+
+if (in->linesize[0] != out->linesize[0]) {
+AVFrame *in2 = getframe(outlink);
+if (!in2)
+goto fail;
+av_frame_copy(in2, in);
  av_frame_free();
-return AVERROR(ENOMEM);
+in = in2;
  }
-av_frame_copy_props(out, in);
  
  s->update(s->instance, in->pts * av_q2d(inlink->time_base) * 1000,

 (const uint32_t *)in->data[0],
@@ -369,6 +392,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
  av_frame_free();
  
  return ff_filter_frame(outlink, out);

+fail:
+av_frame_free();
+av_frame_free();
+return AVERROR(ENOMEM);
  }
  
  static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,

@@ -473,9 +500,6 @@ static int source_request_frame(AVFilterLink *outlink)
  frame->sample_aspect_ratio = (AVRational) {1, 1};
  frame->pts = s->pts++;
  
-s->update(s->instance, av_rescale_q(frame->pts, s->time_base, (AVRational){1,1000}),

-   NULL, (uint32_t *)frame->data[0]);
-
  return ff_filter_frame(outlink, frame);
  }
  

___
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] avcodec/pcm_rechunk_bsf: unref packet before putting a new one in

2022-04-11 Thread Andreas Rheinhardt
James Almer:
> 
> 
> On 4/10/2022 11:14 AM, Michael Niedermayer wrote:
>> On Sat, Apr 09, 2022 at 08:56:05PM +0200, Marton Balint wrote:
>>>
>>>
>>> On Wed, 30 Mar 2022, Michael Niedermayer wrote:
>>>
 On Tue, Mar 29, 2022 at 06:33:06PM -0300, James Almer wrote:
> On 3/29/2022 6:24 PM, Michael Niedermayer wrote:
>> Fixes: memleak
>> Fixes:
>> 45982/clusterfuzz-testcase-minimized-ffmpeg_BSF_PCM_RECHUNK_fuzzer-5562089618407424
>>
>>
>> Found-by: continuous fuzzing process
>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> Signed-off-by: Michael Niedermayer 
>> ---
>>    libavcodec/pcm_rechunk_bsf.c | 1 +
>>    1 file changed, 1 insertion(+)
>>
>> diff --git a/libavcodec/pcm_rechunk_bsf.c
>> b/libavcodec/pcm_rechunk_bsf.c
>> index 108d9e90b9..3f43934fe9 100644
>> --- a/libavcodec/pcm_rechunk_bsf.c
>> +++ b/libavcodec/pcm_rechunk_bsf.c
>> @@ -153,6 +153,7 @@ static int rechunk_filter(AVBSFContext *ctx,
>> AVPacket *pkt)
>>    }
>>    }
>> +    av_packet_unref(s->in_pkt);
>
> This looks to me like it revealed a bug in the code above, which is
> meant to
> ensure s->in_pkt will be blank at this point. It should be fixed there
> instead.

 IIRC the problem was a input packet with size 0
 the code seems to assume 0 meaning no packet
>>>
>>> Is that valid here? The docs says that the encoders can generate 0 sized
>>> packets if there is side data in them. However - the PCM rechunk BSF
>>> using
>>> PCM packets - I am not sure this is intentional here.
>>
>> where exactly is this written ?
>>
>>
>>>
>>> So overall it looks to me that the PCM rechunk BSF should reject 0 sized
>>> packets with AVERROR_INVALIDDATA, and the encoder or demuxer which
>>> produces
>>> the 0 sized packets should be fixed.
>>
>> There is no encoder or demuxer. There is just the fuzzer which excercies
>> the whole space of allowed parameters of the BSFs
>> and either such zero packets are valid or they are not.
>> if not, then a check could be added to av_bsf_send_packet() that feels a
>> bit broad though.
>>
>> i can add a check to pcm_rechunk_bsf but it feels a bit odd if these are
>> valid and just not supposed to come out of the encoders
>>
>> do you see some problem with these packets ?
>> that makes it better to just reject them ?
>>
>> (error you enountered a packet which makes no difference seems a bit odd
>>   in its own too. That probably should only be a warning)
>>   thx
>>
>> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
>> index 42cc1b5ab0..ae16112285 100644
>> --- a/libavcodec/bsf.c
>> +++ b/libavcodec/bsf.c
>> @@ -212,6 +212,11 @@ int av_bsf_send_packet(AVBSFContext *ctx,
>> AVPacket *pkt)
>>   return 0;
>>   }
>>   +    if (pkt->size == 0 && pkt->side_data_elems == 0) {
>> +    av_log(ctx, AV_LOG_ERROR, "Zero packet is not allowed.\n");
>> +    return AVERROR(EINVAL);
>> +    }
> 
> To make this behave like avcodec_send_packet(), it should instead be
> 
> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> index 42cc1b5ab0..01ed9db258 100644
> --- a/libavcodec/bsf.c
> +++ b/libavcodec/bsf.c
> @@ -205,6 +205,9 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket
> *pkt)
>  FFBSFContext *const bsfi = ffbsfcontext(ctx);
>  int ret;
> 
> +    if (pkt && !pkt->size && pkt->data)
> +    return AVERROR(EINVAL);
> +
>  if (!pkt || IS_EMPTY(pkt)) {
>  if (pkt)
>  av_packet_unref(pkt);

1. None of your patches would actually fix the memleak: Packets with
data == NULL, size == 0 and side_data_elems != 0 would still slip
through and cause leaks (of the side data).
2. I don't see why the behaviour of avcodec_send_packet should be the
model to emulate here. (E.g. av_packet_make_refcounted* creates packets
with size == 0 and data set (pointing to a buffer of size
AV_INPUT_BUFFER_PADDING_SIZE) when the packet has no data.)
3. avcodec_send_packet ignores its own documentation: Packets with data
== NULL, size == 0, but side_data_elems != 0 are not considered
eof/flush packets. The reason for this is that avcodec_send_packet
offloads the flushing-decision to the underlying BSF and the BSF API has
slightly different semantics.
IMO we should only accept NULL packets/frames as flush packets as this
is the only thing that is always guaranteed to be an intentional flush
packet; any more additions to AVPacket might otherwise force us to
redefine what a flush packet is.
4. The behaviour of avcodec_send_packet has a weird consequence: Say you
get new extradata via an out-of-band mechanism and want to send it to
the decoder via packet side-data. Given that it is an out-of-band
mechanism you don't have an ordinary packet yet to attach it, so you
simply send it via a packet with size 0. But given that packets with
data == NULL and size == 0 are documented to be flush packets (they
aren't in practice) and flushing is not intended 

Re: [FFmpeg-devel] [PATCH] avfilter/vf_frei0r: Copy to frame allocated according to frei0r requirements

2022-04-11 Thread Paul B Mahol
On Mon, Apr 11, 2022 at 3:32 PM Michael Niedermayer 
wrote:

> Fixes: issues with non trivial linesize
>
> Signed-off-by: Michael Niedermayer 
> ---
>  libavfilter/vf_frei0r.c | 40 
>  1 file changed, 32 insertions(+), 8 deletions(-)
>
> diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
> index 9cd0098e73..c9b698897f 100644
> --- a/libavfilter/vf_frei0r.c
> +++ b/libavfilter/vf_frei0r.c
> @@ -349,18 +349,41 @@ static int query_formats(AVFilterContext *ctx)
>  return ff_set_common_formats(ctx, formats);
>  }
>
> +static AVFrame *getframe(AVFilterLink *link)
> +{
> +int ret;
> +AVFrame *frame = av_frame_alloc();
> +if (!frame)
> +return NULL;
> +
> +frame->width  = link->w;
> +frame->height = link->h;
> +frame->format = link->format;
> +ret = av_frame_get_buffer(frame, 16);
> +if (ret < 0)
> +av_frame_free();
> +
> +return frame;
> +}
> +
>  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>  {
>  Frei0rContext *s = inlink->dst->priv;
>  AVFilterLink *outlink = inlink->dst->outputs[0];
> -AVFrame *out;
> +AVFrame *out = getframe(outlink);
> +if (!out)
> +goto fail;
>
> -out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
> -if (!out) {
> +av_frame_copy_props(out, in);
> +
> +if (in->linesize[0] != out->linesize[0]) {
> +AVFrame *in2 = getframe(outlink);
> +if (!in2)
> +goto fail;
> +av_frame_copy(in2, in);
>  av_frame_free();
> -return AVERROR(ENOMEM);
> +in = in2;
>  }
> -av_frame_copy_props(out, in);
>
>  s->update(s->instance, in->pts * av_q2d(inlink->time_base) * 1000,
> (const uint32_t *)in->data[0],
> @@ -369,6 +392,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *in)
>  av_frame_free();
>
>  return ff_filter_frame(outlink, out);
> +fail:
> +av_frame_free();
> +av_frame_free();
> +return AVERROR(ENOMEM);
>  }
>
>  static int process_command(AVFilterContext *ctx, const char *cmd, const
> char *args,
> @@ -473,9 +500,6 @@ static int source_request_frame(AVFilterLink *outlink)
>  frame->sample_aspect_ratio = (AVRational) {1, 1};
>  frame->pts = s->pts++;
>
> -s->update(s->instance, av_rescale_q(frame->pts, s->time_base,
> (AVRational){1,1000}),
> -   NULL, (uint32_t *)frame->data[0]);
>
>
Why this is removed?

That handle frei0r source filters.


>  return ff_filter_frame(outlink, frame);
>  }
>
> --
> 2.17.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 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] avfilter: add feedback video filter

2022-04-11 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi  |  38 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_feedback.c | 312 ++
 4 files changed, 352 insertions(+)
 create mode 100644 libavfilter/vf_feedback.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 0300a4e2e3..de2b674ba2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12214,6 +12214,44 @@ fade=t=in:st=5.5:d=0.5
 
 @end itemize
 
+@section feedback
+Apply feedback video filter.
+
+This filter pass cropped input frames to 2nd output.
+From there it can be filtered with other video filters.
+After filter receives frame from 2nd input, that frame
+is combined on top of original frame from 1st input and passed
+to 1st output.
+
+The typical usage is filter only part of frame.
+
+The filter accepts the following options:
+@table @option
+@item x
+@item y
+Set the top left crop position.
+
+@item w
+@item h
+Set the crop size.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Blur only top left rectangular part of video frame size 100x100 with gblur 
filter.
+@example
+[in][blurin]feedback=x=0:y=0:w=100:h=100[out][blurout];[blurout]gblur=8[blurin]
+@end example
+
+@item
+Draw black box on top left part of video frame of size 100x100 with drawbox 
filter.
+@example
+[in][blurin]feedback=x=0:y=0:w=100:h=100[out][blurout];[blurout]drawbox=x=0:y=0:w=100:h=100:t=100[blurin]
+@end example
+@end itemize
+
 @section fftdnoiz
 Denoise frames using 3D FFT (frequency domain filtering).
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index d69bd59bb6..bdfdfdc04a 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -279,6 +279,7 @@ OBJS-$(CONFIG_ESTDIF_FILTER) += vf_estdif.o
 OBJS-$(CONFIG_EXPOSURE_FILTER)   += vf_exposure.o
 OBJS-$(CONFIG_EXTRACTPLANES_FILTER)  += vf_extractplanes.o
 OBJS-$(CONFIG_FADE_FILTER)   += vf_fade.o
+OBJS-$(CONFIG_FEEDBACK_FILTER)   += vf_feedback.o
 OBJS-$(CONFIG_FFTDNOIZ_FILTER)   += vf_fftdnoiz.o
 OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o
 OBJS-$(CONFIG_FIELD_FILTER)  += vf_field.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index abd1fe2367..44fac46521 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -261,6 +261,7 @@ extern const AVFilter ff_vf_estdif;
 extern const AVFilter ff_vf_exposure;
 extern const AVFilter ff_vf_extractplanes;
 extern const AVFilter ff_vf_fade;
+extern const AVFilter ff_vf_feedback;
 extern const AVFilter ff_vf_fftdnoiz;
 extern const AVFilter ff_vf_fftfilt;
 extern const AVFilter ff_vf_field;
diff --git a/libavfilter/vf_feedback.c b/libavfilter/vf_feedback.c
new file mode 100644
index 00..268aff0ebd
--- /dev/null
+++ b/libavfilter/vf_feedback.c
@@ -0,0 +1,312 @@
+/*
+ * 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
+ * feedback video filter
+ */
+
+#include "libavutil/fifo.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "libavutil/internal.h"
+#include "avfilter.h"
+#include "filters.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct FeedbackContext {
+const AVClass *class;
+
+int x, y;
+int w, h;
+
+int max_step[4];
+int hsub, vsub;
+
+AVFrame *feed;
+
+AVFifo *fifo;
+} FeedbackContext;
+
+static void adjust_pos(AVFilterContext *ctx, FeedbackContext *s)
+{
+if (s->x + s->w > ctx->inputs[0]->w)
+s->x = ctx->inputs[0]->w - s->w;
+if (s->y + s->h > ctx->inputs[0]->h)
+s->y = ctx->inputs[0]->h - s->h;
+}
+
+static void adjust_parameters(AVFilterContext *ctx, FeedbackContext *s)
+{
+if (s->x >= ctx->inputs[0]->w)
+s->x = 0;
+if (s->y >= ctx->inputs[0]->h)
+s->y = 0;
+
+if (s->w <= 0)
+s->w = ctx->inputs[0]->w - s->x;
+if (s->h <= 0)
+s->h = ctx->inputs[0]->h - s->y;
+
+if (s->w > ctx->inputs[0]->w)
+s->w = ctx->inputs[0]->w;
+if (s->h > ctx->inputs[0]->h)
+s->h = ctx->inputs[0]->h;
+
+adjust_pos(ctx, s);
+}
+
+static int config_input(AVFilterLink *inlink)
+{
+AVFilterContext *ctx = inlink->dst;
+const AVPixFmtDescriptor 

Re: [FFmpeg-devel] [PATCH] avcodec/pcm_rechunk_bsf: unref packet before putting a new one in

2022-04-11 Thread Michael Niedermayer
On Sun, Apr 10, 2022 at 11:46:24AM -0300, James Almer wrote:
> 
> 
> On 4/10/2022 11:14 AM, Michael Niedermayer wrote:
> > On Sat, Apr 09, 2022 at 08:56:05PM +0200, Marton Balint wrote:
> > > 
> > > 
> > > On Wed, 30 Mar 2022, Michael Niedermayer wrote:
> > > 
> > > > On Tue, Mar 29, 2022 at 06:33:06PM -0300, James Almer wrote:
> > > > > On 3/29/2022 6:24 PM, Michael Niedermayer wrote:
> > > > > > Fixes: memleak
> > > > > > Fixes: 
> > > > > > 45982/clusterfuzz-testcase-minimized-ffmpeg_BSF_PCM_RECHUNK_fuzzer-5562089618407424
> > > > > > 
> > > > > > Found-by: continuous fuzzing process 
> > > > > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > > > > Signed-off-by: Michael Niedermayer 
> > > > > > ---
> > > > > >libavcodec/pcm_rechunk_bsf.c | 1 +
> > > > > >1 file changed, 1 insertion(+)
> > > > > > 
> > > > > > diff --git a/libavcodec/pcm_rechunk_bsf.c 
> > > > > > b/libavcodec/pcm_rechunk_bsf.c
> > > > > > index 108d9e90b9..3f43934fe9 100644
> > > > > > --- a/libavcodec/pcm_rechunk_bsf.c
> > > > > > +++ b/libavcodec/pcm_rechunk_bsf.c
> > > > > > @@ -153,6 +153,7 @@ static int rechunk_filter(AVBSFContext *ctx, 
> > > > > > AVPacket *pkt)
> > > > > >}
> > > > > >}
> > > > > > +av_packet_unref(s->in_pkt);
> > > > > 
> > > > > This looks to me like it revealed a bug in the code above, which is 
> > > > > meant to
> > > > > ensure s->in_pkt will be blank at this point. It should be fixed there
> > > > > instead.
> > > > 
> > > > IIRC the problem was a input packet with size 0
> > > > the code seems to assume 0 meaning no packet
> > > 
> > > Is that valid here? The docs says that the encoders can generate 0 sized
> > > packets if there is side data in them. However - the PCM rechunk BSF using
> > > PCM packets - I am not sure this is intentional here.
> > 
> > where exactly is this written ?
> > 
> > 
> > > 
> > > So overall it looks to me that the PCM rechunk BSF should reject 0 sized
> > > packets with AVERROR_INVALIDDATA, and the encoder or demuxer which 
> > > produces
> > > the 0 sized packets should be fixed.
> > 
> > There is no encoder or demuxer. There is just the fuzzer which excercies
> > the whole space of allowed parameters of the BSFs
> > and either such zero packets are valid or they are not.
> > if not, then a check could be added to av_bsf_send_packet() that feels a
> > bit broad though.
> > 
> > i can add a check to pcm_rechunk_bsf but it feels a bit odd if these are
> > valid and just not supposed to come out of the encoders
> > 
> > do you see some problem with these packets ?
> > that makes it better to just reject them ?
> > 
> > (error you enountered a packet which makes no difference seems a bit odd
> >   in its own too. That probably should only be a warning)
> > thx
> > 
> > diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> > index 42cc1b5ab0..ae16112285 100644
> > --- a/libavcodec/bsf.c
> > +++ b/libavcodec/bsf.c
> > @@ -212,6 +212,11 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket 
> > *pkt)
> >   return 0;
> >   }
> > +if (pkt->size == 0 && pkt->side_data_elems == 0) {
> > +av_log(ctx, AV_LOG_ERROR, "Zero packet is not allowed.\n");
> > +return AVERROR(EINVAL);
> > +}
> 
> To make this behave like avcodec_send_packet(), it should instead be

if we reject these allready then it should be fine for bsfs too
will apply your suggestion with you as author after testing

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2



signature.asc
Description: PGP signature
___
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] avfilter: add feedback video filter

2022-04-11 Thread Andreas Rheinhardt
Paul B Mahol:
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi  |  32 
>  libavfilter/Makefile  |   1 +
>  libavfilter/allfilters.c  |   1 +
>  libavfilter/vf_feedback.c | 306 ++
>  4 files changed, 340 insertions(+)
>  create mode 100644 libavfilter/vf_feedback.c
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index ac49092743..612497d865 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -12214,6 +12214,38 @@ fade=t=in:st=5.5:d=0.5
>  
>  @end itemize
>  
> +@section feedback
> +Apply feedback video filter.
> +
> +This filter pass cropped input frames to 2nd output.
> +From there it can be filtered with other video filters.
> +After filter receives frame from 2nd input, that frame
> +is combined on top of original frame from 1st input and passed
> +to 1st output.
> +
> +The typical usage is filter only part of frame.
> +
> +The filter accepts the following options:
> +@table @option
> +@item x
> +@item y
> +Set the top left crop position.
> +
> +@item w
> +@item h
> +Set the crop size.
> +@end table
> +
> +@subsection Examples
> +
> +@itemize
> +@item
> +Blur only top left rectangular part of size 100x100 of frame with gblur 
> filter.
> +@example
> +[in][blurin]feedback=x=0:y=0:w=100:h=100[out][blurout];[blurout]gblur[blurin]
> +@end example
> +@end itemize
> +
>  @section fftdnoiz
>  Denoise frames using 3D FFT (frequency domain filtering).
>  
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index d69bd59bb6..bdfdfdc04a 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -279,6 +279,7 @@ OBJS-$(CONFIG_ESTDIF_FILTER) += 
> vf_estdif.o
>  OBJS-$(CONFIG_EXPOSURE_FILTER)   += vf_exposure.o
>  OBJS-$(CONFIG_EXTRACTPLANES_FILTER)  += vf_extractplanes.o
>  OBJS-$(CONFIG_FADE_FILTER)   += vf_fade.o
> +OBJS-$(CONFIG_FEEDBACK_FILTER)   += vf_feedback.o
>  OBJS-$(CONFIG_FFTDNOIZ_FILTER)   += vf_fftdnoiz.o
>  OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o
>  OBJS-$(CONFIG_FIELD_FILTER)  += vf_field.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index abd1fe2367..44fac46521 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -261,6 +261,7 @@ extern const AVFilter ff_vf_estdif;
>  extern const AVFilter ff_vf_exposure;
>  extern const AVFilter ff_vf_extractplanes;
>  extern const AVFilter ff_vf_fade;
> +extern const AVFilter ff_vf_feedback;
>  extern const AVFilter ff_vf_fftdnoiz;
>  extern const AVFilter ff_vf_fftfilt;
>  extern const AVFilter ff_vf_field;
> diff --git a/libavfilter/vf_feedback.c b/libavfilter/vf_feedback.c
> new file mode 100644
> index 00..cf6ef7ef0c
> --- /dev/null
> +++ b/libavfilter/vf_feedback.c
> @@ -0,0 +1,306 @@
> +/*
> + * 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
> + * feedback video filter
> + */
> +
> +#include "libavutil/avstring.h"

?

> +#include "libavutil/fifo.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/internal.h"
> +#include "avfilter.h"
> +#include "filters.h"
> +#include "internal.h"
> +#include "video.h"
> +
> +typedef struct FeedbackContext {
> +const AVClass *class;
> +
> +int x, y;
> +int w, h;
> +
> +int max_step[4];
> +int hsub, vsub;
> +
> +AVFrame *feed;
> +
> +AVFifo *fifo;
> +} FeedbackContext;
> +
> +static void adjust_pos(AVFilterContext *ctx, FeedbackContext *s)
> +{
> +if (s->x + s->w > ctx->inputs[0]->w)
> +s->x = ctx->inputs[0]->w - s->w;
> +if (s->y + s->h > ctx->inputs[0]->h)
> +s->y = ctx->inputs[0]->h - s->h;
> +}
> +
> +static void adjust_parameters(AVFilterContext *ctx, FeedbackContext *s)
> +{
> +if (s->x >= ctx->inputs[0]->w)
> +s->x = 0;
> +if (s->y >= ctx->inputs[0]->h)
> +s->y = 0;
> +
> +if (s->w <= 0)
> +s->w = ctx->inputs[0]->w - s->x;
> +if (s->h <= 0)
> +s->h = ctx->inputs[0]->h - s->y;
> +
> +if (s->w > ctx->inputs[0]->w)
> +s->w = ctx->inputs[0]->w;
> +if (s->h > ctx->inputs[0]->h)
> +s->h = ctx->inputs[0]->h;
> +
> +adjust_pos(ctx, 

Re: [FFmpeg-devel] [PATCH] lavc/encode: drop EncodeSimpleContext

2022-04-11 Thread James Almer

On 4/11/2022 5:39 AM, Anton Khirnov wrote:

It has only a single member.
---
  libavcodec/avcodec.c  |  4 ++--
  libavcodec/encode.c   |  7 +++
  libavcodec/internal.h | 12 +++-
  3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index c7daa385e7..e0f38ac42a 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -432,7 +432,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
  while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0)
  av_packet_unref(avci->last_pkt_props);
  
-av_frame_unref(avci->es.in_frame);

+av_frame_unref(avci->in_frame);
  av_packet_unref(avci->in_pkt);
  
  if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)

@@ -498,7 +498,7 @@ av_cold int avcodec_close(AVCodecContext *avctx)
  av_packet_free(>last_pkt_props);
  
  av_packet_free(>in_pkt);

-av_frame_free(>es.in_frame);
+av_frame_free(>in_frame);
  
  av_buffer_unref(>pool);
  
diff --git a/libavcodec/encode.c b/libavcodec/encode.c

index 837ffaa40d..8b0d4443cd 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -175,8 +175,7 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame 
*frame)
  static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
  {
  AVCodecInternal   *avci = avctx->internal;
-EncodeSimpleContext *es = >es;
-AVFrame  *frame = es->in_frame;
+AVFrame  *frame = avci->in_frame;
  const FFCodec *const codec = ffcodec(avctx->codec);
  int got_packet;
  int ret;
@@ -565,8 +564,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
  avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY;
  
  if (ffcodec(avctx->codec)->encode2) {

-avci->es.in_frame = av_frame_alloc();
-if (!avci->es.in_frame)
+avci->in_frame = av_frame_alloc();
+if (!avci->in_frame)
  return AVERROR(ENOMEM);
  }
  
diff --git a/libavcodec/internal.h b/libavcodec/internal.h

index f9d08fcb60..2fa56d3a59 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -47,10 +47,6 @@
  #   define STRIDE_ALIGN 8
  #endif
  
-typedef struct EncodeSimpleContext {

-AVFrame *in_frame;
-} EncodeSimpleContext;
-
  typedef struct AVCodecInternal {
  /**
   * When using frame-threaded decoding, this field is set for the first
@@ -101,7 +97,13 @@ typedef struct AVCodecInternal {
  
  void *frame_thread_encoder;
  
-EncodeSimpleContext es;

+/**
+ * The input frame is stored here for encoders implementing the simple
+ * encode API.
+ *
+ * Not allocated in other cases.
+ */
+AVFrame *in_frame;
  
  /**

   * If this is set, then FFCodec->close (if existing) needs to be called


LGTM.
___
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] avfilter/vf_drawbox: remove redefinition of DrawBoxContext typedef

2022-04-11 Thread Andreas Rheinhardt
James Almer:
> Old GCC and Clang apparently don't like it.
> 
> Signed-off-by: James Almer 
> ---
> Untested since i don't have old compilers.
> 
> See
> 
> http://fate.ffmpeg.org/report.cgi?time=20220409194302=x86_64-netbsd-clang-noopt
> http://fate.ffmpeg.org/report.cgi?time=20220409194413=x86_64-netbsd-gcc34
> http://fate.ffmpeg.org/report.cgi?time=20220409200245=x86_64-openbsd5.6-gcc4.2-conf2
> http://fate.ffmpeg.org/report.cgi?time=20220409040143=armel5tej-qemu-debian-gcc4.4
> 
> Clang 3 even says "redefinition of typedef 'DrawBoxContext' is invalid in C", 
> but newer
> Clang compiles it fine.
> 

Before C11, typedefs were subject to the one-definition-rule, so that
redefining them was forbidden. C11 allowed it.

>  libavfilter/vf_drawbox.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c
> index a4fe0b8abd..65bd039d65 100644
> --- a/libavfilter/vf_drawbox.c
> +++ b/libavfilter/vf_drawbox.c
> @@ -73,9 +73,9 @@ enum var_name {
>  VARS_NB
>  };
>  
> -typedef struct DrawBoxContext DrawBoxContext;
> +struct DrawBoxContext;
>  
> -typedef int (*PixelBelongsToRegion)(DrawBoxContext *s, int x, int y);
> +typedef int (*PixelBelongsToRegion)(struct DrawBoxContext *s, int x, int y);
>  
>  typedef struct DrawBoxContext {
>  const AVClass *class;
> @@ -96,7 +96,7 @@ typedef struct DrawBoxContext {
>  int step;
>  enum AVFrameSideDataType box_source;
>  
> -void (*draw_region)(AVFrame *frame, DrawBoxContext *ctx, int left, int 
> top, int right, int down,
> +void (*draw_region)(AVFrame *frame, struct DrawBoxContext *ctx, int 
> left, int top, int right, int down,
>  PixelBelongsToRegion pixel_belongs_to_region);
>  } DrawBoxContext;
>  

___
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 1/1] librtmp: use AVBPrint instead of char *

2022-04-11 Thread Tristan Matthews
This avoids having to do one pass to calculate the full length to allocate
followed by a second pass to actually append values.
---
 libavformat/librtmp.c | 123 +++---
 1 file changed, 32 insertions(+), 91 deletions(-)

diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index 43013e46e0..7b379e48ee 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -25,6 +25,7 @@
  */
 
 #include "libavutil/avstring.h"
+#include "libavutil/bprint.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 #include "avformat.h"
@@ -50,7 +51,6 @@ typedef struct LibRTMPContext {
 char *pageurl;
 char *client_buffer_time;
 int live;
-char *temp_filename;
 int buffer_size;
 } LibRTMPContext;
 
@@ -76,7 +76,6 @@ static int rtmp_close(URLContext *s)
 RTMP *r = >rtmp;
 
 RTMP_Close(r);
-av_freep(>temp_filename);
 return 0;
 }
 
@@ -94,11 +93,11 @@ static int rtmp_close(URLContext *s)
  */
 static int rtmp_open(URLContext *s, const char *uri, int flags)
 {
+AVBPrint filename;
 LibRTMPContext *ctx = s->priv_data;
 RTMP *r = >rtmp;
 int rc = 0, level;
-char *filename = s->filename;
-int len = strlen(s->filename) + 1;
+av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
 
 switch (av_log_get_level()) {
 default:
@@ -112,118 +111,58 @@ static int rtmp_open(URLContext *s, const char *uri, int 
flags)
 RTMP_LogSetLevel(level);
 RTMP_LogSetCallback(rtmp_log);
 
-if (ctx->app)  len += strlen(ctx->app)  + sizeof(" app=");
-if (ctx->tcurl)len += strlen(ctx->tcurl)+ sizeof(" tcUrl=");
-if (ctx->pageurl)  len += strlen(ctx->pageurl)  + sizeof(" pageUrl=");
-if (ctx->flashver) len += strlen(ctx->flashver) + sizeof(" flashver=");
-
+av_bprintf(, "%s", s->filename);
+if (ctx->app)
+av_bprintf(, " app=%s", ctx->app);
+if (ctx->tcurl)
+av_bprintf(, " tcUrl=%s", ctx->tcurl);
+if (ctx->pageurl)
+av_bprintf(, " pageUrl=%s", ctx->pageurl);
+if (ctx->swfurl)
+av_bprintf(, " swfUrl=%s", ctx->swfurl);
+if (ctx->flashver)
+av_bprintf(, " flashVer=%s", ctx->flashver);
 if (ctx->conn) {
 char *sep, *p = ctx->conn;
-int options = 0;
-
 while (p) {
-options++;
+av_bprintf(,  " conn=");
 p += strspn(p, " ");
 if (!*p)
 break;
 sep = strchr(p, ' ');
+if (sep)
+*sep = '\0';
+av_bprintf(, "%s", p);
+
 if (sep)
 p = sep + 1;
 else
 break;
 }
-len += options * sizeof(" conn=");
-len += strlen(ctx->conn);
 }
-
 if (ctx->playpath)
-len += strlen(ctx->playpath) + sizeof(" playpath=");
+av_bprintf(, " playpath=%s", ctx->playpath);
 if (ctx->live)
-len += sizeof(" live=1");
+av_bprintf(, " live=1");
 if (ctx->subscribe)
-len += strlen(ctx->subscribe) + sizeof(" subscribe=");
-
+av_bprintf(, " subscribe=%s", ctx->subscribe);
 if (ctx->client_buffer_time)
-len += strlen(ctx->client_buffer_time) + sizeof(" buffer=");
-
+av_bprintf(, " buffer=%s", ctx->client_buffer_time);
 if (ctx->swfurl || ctx->swfverify) {
-len += sizeof(" swfUrl=");
-
 if (ctx->swfverify)
-len += strlen(ctx->swfverify) + sizeof(" swfVfy=1");
+av_bprintf(, " swfUrl=%s swfVfy=1", ctx->swfverify);
 else
-len += strlen(ctx->swfurl);
+av_bprintf(, " swfUrl=%s", ctx->swfurl);
 }
 
-if (!(ctx->temp_filename = filename = av_malloc(len)))
+if (!av_bprint_is_complete()) {
+av_bprint_finalize(, NULL);
 return AVERROR(ENOMEM);
-
-av_strlcpy(filename, s->filename, len);
-if (ctx->app) {
-av_strlcat(filename, " app=", len);
-av_strlcat(filename, ctx->app, len);
-}
-if (ctx->tcurl) {
-av_strlcat(filename, " tcUrl=", len);
-av_strlcat(filename, ctx->tcurl, len);
-}
-if (ctx->pageurl) {
-av_strlcat(filename, " pageUrl=", len);
-av_strlcat(filename, ctx->pageurl, len);
-}
-if (ctx->swfurl) {
-av_strlcat(filename, " swfUrl=", len);
-av_strlcat(filename, ctx->swfurl, len);
-}
-if (ctx->flashver) {
-av_strlcat(filename, " flashVer=", len);
-av_strlcat(filename, ctx->flashver, len);
-}
-if (ctx->conn) {
-char *sep, *p = ctx->conn;
-while (p) {
-av_strlcat(filename, " conn=", len);
-p += strspn(p, " ");
-if (!*p)
-break;
-sep = strchr(p, ' ');
-if (sep)
-*sep = '\0';
-av_strlcat(filename, p, len);
-
-if (sep)
-p = sep + 1;
-else
-break;
-}
-}
-if (ctx->playpath) {
-

Re: [FFmpeg-devel] [PATCH 1/1] librtmp: make flashVer case consistent

2022-04-11 Thread Tristan Matthews
On Sat, Apr 9, 2022 at 2:45 PM Marton Balint  wrote:

>
>
> On Wed, 6 Apr 2022, Tristan Matthews wrote:
>
> > This is basically a cosmetic change (no functional difference).
> >
> > ---
> > libavformat/librtmp.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
> > index 43013e46e0..b23adb9593 100644
> > --- a/libavformat/librtmp.c
> > +++ b/libavformat/librtmp.c
> > @@ -115,7 +115,7 @@ static int rtmp_open(URLContext *s, const char *uri,
> int flags)
> > if (ctx->app)  len += strlen(ctx->app)  + sizeof(" app=");
> > if (ctx->tcurl)len += strlen(ctx->tcurl)+ sizeof(" tcUrl=");
> > if (ctx->pageurl)  len += strlen(ctx->pageurl)  + sizeof("
> pageUrl=");
> > -if (ctx->flashver) len += strlen(ctx->flashver) + sizeof("
> flashver=");
> > +if (ctx->flashver) len += strlen(ctx->flashver) + sizeof("
> flashVer=");
>
> Actually this whole rtmp_open function should be reworked to use an
> AVBPrint buffer to generate the rtmp URL. The way it works now -
> calculating the length first then creating the actual sting - is
> very ugly.
>
>
Oh yeah good call, I will follow up with that instead.
___
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 5/5] lavfi: add vf_iccdetect for parsing ICC profiles

2022-04-11 Thread Niklas Haas
From: Niklas Haas 

This filter is designed to parse embedded ICC profiles and attempt
extracting colorspace tags from them, updating the AVFrame metadata
accordingly.

This is intentionally made a separate filter, rather than being part of
libavcodec itself, so that it's an opt-in behavior for the time being.
This also gives the user more flexibility to e.g. first attach an ICC
profile and then also set the colorspace tags from it.

This makes #9673 possible, though not automatic.

Signed-off-by: Niklas Haas 
---
 configure  |   1 +
 doc/filters.texi   |  14 
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/vf_iccdetect.c | 141 +
 5 files changed, 158 insertions(+)
 create mode 100644 libavfilter/vf_iccdetect.c

diff --git a/configure b/configure
index d64ccf7181..c1e2c53b7f 100755
--- a/configure
+++ b/configure
@@ -3659,6 +3659,7 @@ gblur_vulkan_filter_deps="vulkan spirv_compiler"
 hflip_vulkan_filter_deps="vulkan spirv_compiler"
 histeq_filter_deps="gpl"
 hqdn3d_filter_deps="gpl"
+iccdetect_filter_deps="lcms2"
 iccgen_filter_deps="lcms2"
 interlace_filter_deps="gpl"
 kerndeint_filter_deps="gpl"
diff --git a/doc/filters.texi b/doc/filters.texi
index 9673858355..67054458f9 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14304,6 +14304,20 @@ By default value is 0.
 
 The @code{hysteresis} filter also supports the @ref{framesync} options.
 
+@section iccdetect
+
+Detect the colorspace  from an embedded ICC profile (if present), and update
+the frame's tags accordingly.
+
+This filter accepts the following options:
+
+@table @option
+@item force
+If true, the frame's existing colorspace tags will always be overridden by
+values detected from an ICC profile. Otherwise, they will only be assigned if
+they contain @code{unknown}. Enabled by default.
+@end table
+
 @section iccgen
 
 Generate ICC profiles and attach them to frames.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 8ffc53d751..e82b0b373a 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -320,6 +320,7 @@ OBJS-$(CONFIG_HWMAP_FILTER)  += vf_hwmap.o
 OBJS-$(CONFIG_HWUPLOAD_CUDA_FILTER)  += vf_hwupload_cuda.o
 OBJS-$(CONFIG_HWUPLOAD_FILTER)   += vf_hwupload.o
 OBJS-$(CONFIG_HYSTERESIS_FILTER) += vf_hysteresis.o framesync.o
+OBJS-$(CONFIG_ICCDETECT_FILTER)  += vf_iccdetect.o fflcms2.o 
colorspace.o
 OBJS-$(CONFIG_ICCGEN_FILTER) += vf_iccgen.o fflcms2.o 
colorspace.o
 OBJS-$(CONFIG_IDENTITY_FILTER)   += vf_identity.o
 OBJS-$(CONFIG_IDET_FILTER)   += vf_idet.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index d43f4b45b1..37661d26f9 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -303,6 +303,7 @@ extern const AVFilter ff_vf_hwmap;
 extern const AVFilter ff_vf_hwupload;
 extern const AVFilter ff_vf_hwupload_cuda;
 extern const AVFilter ff_vf_hysteresis;
+extern const AVFilter ff_vf_iccdetect;
 extern const AVFilter ff_vf_iccgen;
 extern const AVFilter ff_vf_identity;
 extern const AVFilter ff_vf_idet;
diff --git a/libavfilter/vf_iccdetect.c b/libavfilter/vf_iccdetect.c
new file mode 100644
index 00..8850857ad2
--- /dev/null
+++ b/libavfilter/vf_iccdetect.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2022 Niklas Haas
+ * 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
+ * filter for generating ICC profiles
+ */
+
+#include 
+
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+
+#include "avfilter.h"
+#include "fflcms2.h"
+#include "internal.h"
+
+typedef struct IccDetectContext {
+const AVClass *class;
+FFIccContext icc;
+int force;
+/* (cached) detected ICC profile values */
+AVBufferRef *profile;
+enum AVColorPrimaries profile_prim;
+enum AVColorTransferCharacteristic profile_trc;
+} IccDetectContext;
+
+#define OFFSET(x) offsetof(IccDetectContext, x)
+#define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption iccdetect_options[] = {
+{ "force", "overwrite existing tags", OFFSET(force), AV_OPT_TYPE_BOOL, 
{.i64=1}, 0, 1, VF },
+{ NULL }
+};
+

[FFmpeg-devel] [PATCH 4/5] lavfi: add vf_iccgen for generating ICC profiles

2022-04-11 Thread Niklas Haas
From: Niklas Haas 

This filter is designed to specifically cover the task of generating ICC
profiles (and attaching them to output frames) on demand. Other tasks,
such as ICC profile loading/stripping, or ICC profile application, are
better left to separate filters (or included into e.g. vf_setparams).

Signed-off-by: Niklas Haas 
---
 configure|   1 +
 doc/filters.texi |  21 +
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_iccgen.c  | 179 +++
 5 files changed, 203 insertions(+)
 create mode 100644 libavfilter/vf_iccgen.c

diff --git a/configure b/configure
index 1a9c3dcd3c..d64ccf7181 100755
--- a/configure
+++ b/configure
@@ -3659,6 +3659,7 @@ gblur_vulkan_filter_deps="vulkan spirv_compiler"
 hflip_vulkan_filter_deps="vulkan spirv_compiler"
 histeq_filter_deps="gpl"
 hqdn3d_filter_deps="gpl"
+iccgen_filter_deps="lcms2"
 interlace_filter_deps="gpl"
 kerndeint_filter_deps="gpl"
 ladspa_filter_deps="ladspa libdl"
diff --git a/doc/filters.texi b/doc/filters.texi
index 4e9b0e0111..9673858355 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14304,6 +14304,27 @@ By default value is 0.
 
 The @code{hysteresis} filter also supports the @ref{framesync} options.
 
+@section iccgen
+
+Generate ICC profiles and attach them to frames.
+
+This filter accepts the following options:
+
+@table @option
+@item color_primaries
+@item color_trc
+Configure the colorspace that the ICC profile will be generated for. The
+default value of @code{auto} infers the value from the input frame's metadata,
+defaulting to BT.709/sRGB as appropriate.
+
+See the @ref{setparams} filter for a list of possible values, but note that
+@code{unknown} are not valid values for this filter.
+
+@item force
+If true, an ICC profile will be generated even if it would overwrite an
+already existing ICC profile. Disabled by default.
+@end table
+
 @section identity
 
 Obtain the identity score between two input videos.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index c4c946a988..8ffc53d751 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -320,6 +320,7 @@ OBJS-$(CONFIG_HWMAP_FILTER)  += vf_hwmap.o
 OBJS-$(CONFIG_HWUPLOAD_CUDA_FILTER)  += vf_hwupload_cuda.o
 OBJS-$(CONFIG_HWUPLOAD_FILTER)   += vf_hwupload.o
 OBJS-$(CONFIG_HYSTERESIS_FILTER) += vf_hysteresis.o framesync.o
+OBJS-$(CONFIG_ICCGEN_FILTER) += vf_iccgen.o fflcms2.o 
colorspace.o
 OBJS-$(CONFIG_IDENTITY_FILTER)   += vf_identity.o
 OBJS-$(CONFIG_IDET_FILTER)   += vf_idet.o
 OBJS-$(CONFIG_IL_FILTER) += vf_il.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9fbaaacf47..d43f4b45b1 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -303,6 +303,7 @@ extern const AVFilter ff_vf_hwmap;
 extern const AVFilter ff_vf_hwupload;
 extern const AVFilter ff_vf_hwupload_cuda;
 extern const AVFilter ff_vf_hysteresis;
+extern const AVFilter ff_vf_iccgen;
 extern const AVFilter ff_vf_identity;
 extern const AVFilter ff_vf_idet;
 extern const AVFilter ff_vf_il;
diff --git a/libavfilter/vf_iccgen.c b/libavfilter/vf_iccgen.c
new file mode 100644
index 00..afc924e291
--- /dev/null
+++ b/libavfilter/vf_iccgen.c
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2022 Niklas Haas
+ * 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
+ * filter for generating ICC profiles
+ */
+
+#include 
+
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+
+#include "avfilter.h"
+#include "fflcms2.h"
+#include "internal.h"
+
+typedef struct IccGenContext {
+const AVClass *class;
+FFIccContext icc;
+/* options */
+int color_prim;
+int color_trc;
+int force;
+/* (cached) generated ICC profile */
+cmsHPROFILE profile;
+int profile_prim;
+int profile_trc;
+} IccGenContext;
+
+#define OFFSET(x) offsetof(IccGenContext, x)
+#define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption iccgen_options[] = {
+{"color_primaries", "select color primaries", OFFSET(color_prim), 
AV_OPT_TYPE_INT, {.i64=0}, 0, AVCOL_PRI_NB-1, VF, "color_primaries"},
+

[FFmpeg-devel] [PATCH 3/5] lavfi: add ICC profile support via lcms2

2022-04-11 Thread Niklas Haas
From: Niklas Haas 

This introduces an optional dependency on lcms2 into FFmpeg. lcms2 is a
widely used library for ICC profile handling, which apart from being
used in almost all major image processing programs and video players,
has also been deployed in browsers. As such, it's both widely available
and well-tested.

Add a few helpers to cover our major use cases. This commit merely
introduces the helpers (and configure check), even though nothing uses
them yet.

It's worth pointing out that the reason the cmsToneCurves for each
AVCOL_TRC are cached inside the context, is because constructing a
cmsToneCurve requires evaluating the curve at 4096 (by default) grid
points and constructing a LUT. So, we ideally only want to do this once
per curve. This matters for e.g. ff_icc_profile_detect_transfer, which
essentially compares a profile against all of these generated LUTs.
Re-generating the LUTs for every iteration would be unnecessarily
wasteful.

The same consideration does not apply to e.g. cmsCreate*Profile, which
is a very lightweight operation just involving struct allocation and
setting a few pointers.

The cutoff value of 0.01 was determined by experimentation. The lowest
"false positive" delta I saw in practice was 0.13, and the largest
"false negative" delta was 0.0008. So a value of 0.01 sits comfortaby
almost exactly in the middle.

Signed-off-by: Niklas Haas 
---
 configure |   3 +
 libavfilter/fflcms2.c | 311 ++
 libavfilter/fflcms2.h |  87 
 3 files changed, 401 insertions(+)
 create mode 100644 libavfilter/fflcms2.c
 create mode 100644 libavfilter/fflcms2.h

diff --git a/configure b/configure
index 9c8965852b..1a9c3dcd3c 100755
--- a/configure
+++ b/configure
@@ -215,6 +215,7 @@ External library support:
   --disable-iconv  disable iconv [autodetect]
   --enable-jni enable JNI support [no]
   --enable-ladspa  enable LADSPA audio filtering [no]
+  --enable-lcms2   enable ICC profile support via LittleCMS 2 [no]
   --enable-libaom  enable AV1 video encoding/decoding via libaom [no]
   --enable-libaribb24  enable ARIB text and caption decoding via 
libaribb24 [no]
   --enable-libass  enable libass subtitles rendering,
@@ -1813,6 +1814,7 @@ EXTERNAL_LIBRARY_LIST="
 gnutls
 jni
 ladspa
+lcms2
 libaom
 libass
 libbluray
@@ -6504,6 +6506,7 @@ enabled gmp   && require gmp gmp.h mpz_export 
-lgmp
 enabled gnutls&& require_pkg_config gnutls gnutls gnutls/gnutls.h 
gnutls_global_init
 enabled jni   && { [ $target_os = "android" ] && check_headers 
jni.h && enabled pthreads || die "ERROR: jni not found"; }
 enabled ladspa&& require_headers "ladspa.h dlfcn.h"
+enabled lcms2 && require_pkg_config lcms2 "lcms2 >= 2.13" lcms2.h 
cmsCreateContext
 enabled libaom&& require_pkg_config libaom "aom >= 1.0.0" 
aom/aom_codec.h aom_codec_version
 enabled libaribb24&& { check_pkg_config libaribb24 "aribb24 > 1.0.3" 
"aribb24/aribb24.h" arib_instance_new ||
{ enabled gpl && require_pkg_config libaribb24 
aribb24 "aribb24/aribb24.h" arib_instance_new; } ||
diff --git a/libavfilter/fflcms2.c b/libavfilter/fflcms2.c
new file mode 100644
index 00..afde5d87a8
--- /dev/null
+++ b/libavfilter/fflcms2.c
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) 2022 Niklas Haas
+ * 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
+ */
+
+#include "libavutil/color_utils.h"
+
+#include "fflcms2.h"
+
+static void log_cb(cmsContext ctx, cmsUInt32Number error, const char *str)
+{
+FFIccContext *s = cmsGetContextUserData(ctx);
+av_log(s->avctx, AV_LOG_ERROR, "lcms2: [%"PRIu32"] %s\n", error, str);
+}
+
+int ff_icc_context_init(FFIccContext *s, void *avctx)
+{
+memset(s, 0, sizeof(*s));
+s->avctx = avctx;
+s->ctx = cmsCreateContext(NULL, s);
+if (!s->ctx)
+return AVERROR(ENOMEM);
+
+cmsSetLogErrorHandlerTHR(s->ctx, log_cb);
+return 0;
+}
+
+void ff_icc_context_uninit(FFIccContext *s)
+{
+for (int i = 0; i < FF_ARRAY_ELEMS(s->curves); i++)
+cmsFreeToneCurve(s->curves[i]);
+cmsDeleteContext(s->ctx);
+memset(s, 0, sizeof(*s));

[FFmpeg-devel] [PATCH 2/5] lavfi: add ff_detect_color_primaries helper

2022-04-11 Thread Niklas Haas
From: Niklas Haas 

Related to #9673, this helper exists to facilitate "guessing" the right
primary tags from a given set of raw primary coefficients.

The cutoff value of 0.001 was chosen by experimentation. The smallest
"false negative" delta observed in practice was 0.023329, while the
largest "false positive" delta was 0.00016. So, a value of 0.001 sits
comfortably in the middle.

Signed-off-by: Niklas Haas 
---
 libavfilter/colorspace.c | 25 +
 libavfilter/colorspace.h |  3 +++
 2 files changed, 28 insertions(+)

diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c
index 25e99f4759..8d7b882375 100644
--- a/libavfilter/colorspace.c
+++ b/libavfilter/colorspace.c
@@ -170,6 +170,31 @@ const struct ColorPrimaries *ff_get_color_primaries(enum 
AVColorPrimaries prm)
 return p;
 }
 
+enum AVColorPrimaries ff_detect_color_primaries(const struct ColorPrimaries 
*prm)
+{
+double delta;
+
+for (enum AVColorPrimaries p = 0; p < AVCOL_PRI_NB; p++) {
+const struct ColorPrimaries *ref = _primaries[p];
+if (!ref->prim.xr)
+continue;
+
+delta = fabs(prm->prim.xr - ref->prim.xr) +
+fabs(prm->prim.yr - ref->prim.yr) +
+fabs(prm->prim.yg - ref->prim.yg) +
+fabs(prm->prim.yg - ref->prim.yg) +
+fabs(prm->prim.yb - ref->prim.yb) +
+fabs(prm->prim.yb - ref->prim.yb) +
+fabs(prm->wp.xw - ref->wp.xw) +
+fabs(prm->wp.yw - ref->wp.yw);
+
+if (delta < 0.001)
+return p;
+}
+
+return AVCOL_PRI_UNSPECIFIED;
+}
+
 void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
double rgb2yuv[3][3])
 {
diff --git a/libavfilter/colorspace.h b/libavfilter/colorspace.h
index fc415fed05..6959133a49 100644
--- a/libavfilter/colorspace.h
+++ b/libavfilter/colorspace.h
@@ -49,6 +49,9 @@ void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients 
*coeffs,
const struct WhitepointCoefficients *wp,
double rgb2xyz[3][3]);
 
+/* Returns AVCOL_PRI_UNSPECIFIED if no clear match can be identified */
+enum AVColorPrimaries ff_detect_color_primaries(const struct ColorPrimaries 
*prm);
+
 const struct ColorPrimaries *ff_get_color_primaries(enum AVColorPrimaries prm);
 const struct LumaCoefficients *ff_get_luma_coefficients(enum AVColorSpace csp);
 void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
-- 
2.35.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 1/5] lavfi: generalize colorspace coefficent helpers

2022-04-11 Thread Niklas Haas
From: Niklas Haas 

These are needed beyond just vf_colorspace, so give them a new home in
colorspace.h.

In addition to moving code around, also merge the white point and
primary coefficients into a single struct to slightly increase the
convenience and shrink the size of the new API by avoiding the need
to introduce an extra function just to look up the white point as well.
The only place the distinction matters is in a single enum comparison,
which can just as well be a single memcpy - the difference is
negligible.

Signed-off-by: Niklas Haas 
---
 libavfilter/colorspace.c| 32 +
 libavfilter/colorspace.h|  6 
 libavfilter/vf_colorspace.c | 70 ++---
 3 files changed, 49 insertions(+), 59 deletions(-)

diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c
index 19616e4f12..25e99f4759 100644
--- a/libavfilter/colorspace.c
+++ b/libavfilter/colorspace.c
@@ -138,6 +138,38 @@ const struct LumaCoefficients 
*ff_get_luma_coefficients(enum AVColorSpace csp)
 return coeffs;
 }
 
+#define WP_D65 { 0.3127, 0.3290 }
+#define WP_C   { 0.3100, 0.3160 }
+#define WP_DCI { 0.3140, 0.3510 }
+#define WP_E   { 1/3.0f, 1/3.0f }
+
+static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB] = {
+[AVCOL_PRI_BT709] = { WP_D65, { 0.640, 0.330, 0.300, 0.600, 0.150, 
0.060 } },
+[AVCOL_PRI_BT470M]= { WP_C,   { 0.670, 0.330, 0.210, 0.710, 0.140, 
0.080 } },
+[AVCOL_PRI_BT470BG]   = { WP_D65, { 0.640, 0.330, 0.290, 0.600, 0.150, 
0.060 } },
+[AVCOL_PRI_SMPTE170M] = { WP_D65, { 0.630, 0.340, 0.310, 0.595, 0.155, 
0.070 } },
+[AVCOL_PRI_SMPTE240M] = { WP_D65, { 0.630, 0.340, 0.310, 0.595, 0.155, 
0.070 } },
+[AVCOL_PRI_SMPTE428]  = { WP_E,   { 0.735, 0.265, 0.274, 0.718, 0.167, 
0.009 } },
+[AVCOL_PRI_SMPTE431]  = { WP_DCI, { 0.680, 0.320, 0.265, 0.690, 0.150, 
0.060 } },
+[AVCOL_PRI_SMPTE432]  = { WP_D65, { 0.680, 0.320, 0.265, 0.690, 0.150, 
0.060 } },
+[AVCOL_PRI_FILM]  = { WP_C,   { 0.681, 0.319, 0.243, 0.692, 0.145, 
0.049 } },
+[AVCOL_PRI_BT2020]= { WP_D65, { 0.708, 0.292, 0.170, 0.797, 0.131, 
0.046 } },
+[AVCOL_PRI_JEDEC_P22] = { WP_D65, { 0.630, 0.340, 0.295, 0.605, 0.155, 
0.077 } },
+};
+
+const struct ColorPrimaries *ff_get_color_primaries(enum AVColorPrimaries prm)
+{
+const struct ColorPrimaries *p;
+
+if (prm >= AVCOL_PRI_NB)
+return NULL;
+p = _primaries[prm];
+if (!p->prim.xr)
+return NULL;
+
+return p;
+}
+
 void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
double rgb2yuv[3][3])
 {
diff --git a/libavfilter/colorspace.h b/libavfilter/colorspace.h
index a4c5078d5f..fc415fed05 100644
--- a/libavfilter/colorspace.h
+++ b/libavfilter/colorspace.h
@@ -37,6 +37,11 @@ struct WhitepointCoefficients {
 double xw, yw;
 };
 
+struct ColorPrimaries {
+struct WhitepointCoefficients wp;
+struct PrimaryCoefficients prim;
+};
+
 void ff_matrix_invert_3x3(const double in[3][3], double out[3][3]);
 void ff_matrix_mul_3x3(double dst[3][3],
const double src1[3][3], const double src2[3][3]);
@@ -44,6 +49,7 @@ void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients 
*coeffs,
const struct WhitepointCoefficients *wp,
double rgb2xyz[3][3]);
 
+const struct ColorPrimaries *ff_get_color_primaries(enum AVColorPrimaries prm);
 const struct LumaCoefficients *ff_get_luma_coefficients(enum AVColorSpace csp);
 void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
double rgb2yuv[3][3]);
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 0bd8e2b0cf..3c8b3b20eb 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -55,14 +55,6 @@ enum Colorspace {
 CS_NB,
 };
 
-enum Whitepoint {
-WP_D65,
-WP_C,
-WP_DCI,
-WP_E,
-WP_NB,
-};
-
 enum WhitepointAdaptation {
 WP_ADAPT_BRADFORD,
 WP_ADAPT_VON_KRIES,
@@ -110,11 +102,6 @@ static const enum AVColorSpace default_csp[CS_NB + 1] = {
 [CS_NB]  = AVCOL_SPC_UNSPECIFIED,
 };
 
-struct ColorPrimaries {
-enum Whitepoint wp;
-struct PrimaryCoefficients coeff;
-};
-
 struct TransferCharacteristics {
 double alpha, beta, gamma, delta;
 };
@@ -201,40 +188,6 @@ static const struct TransferCharacteristics *
 return coeffs;
 }
 
-static const struct WhitepointCoefficients whitepoint_coefficients[WP_NB] = {
-[WP_D65] = { 0.3127, 0.3290 },
-[WP_C]   = { 0.3100, 0.3160 },
-[WP_DCI] = { 0.3140, 0.3510 },
-[WP_E]   = { 1/3.0f, 1/3.0f },
-};
-
-static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB] = {
-[AVCOL_PRI_BT709] = { WP_D65, { 0.640, 0.330, 0.300, 0.600, 0.150, 
0.060 } },
-[AVCOL_PRI_BT470M]= { WP_C,   { 0.670, 0.330, 0.210, 0.710, 0.140, 
0.080 } },
-[AVCOL_PRI_BT470BG]   = { WP_D65, { 0.640, 0.330, 0.290, 0.600, 0.150, 
0.060 } 

Re: [FFmpeg-devel] [PATCH v8 2/2] avcodec/mjpegenc: support writing ICC profiles

2022-04-11 Thread Niklas Haas
Merged as e254af31549ce6b4964936b3fe2124c3a18e69f8

On Sun, 10 Apr 2022 22:47:21 +0200 Niklas Haas  wrote:
> Merging this tomorrow if there's no further feedback.
> 
> On Tue, 05 Apr 2022 13:31:35 +0200 Niklas Haas  wrote:
> > From: Niklas Haas 
> > 
> > This is mostly straightforward. The major complication is that, as a
> > result of the 16-bit chunk size limitation, ICC profiles may need to be
> > split up into multiple chunks.
> > 
> > We also need to make sure to allocate enough extra space in the packet
> > to fit the ICC profile, so modify both mpegvideo_enc.c and ljpegenc.c to
> > take into account this extra overhead, failing cleanly if necessary.
> > 
> > Also add a FATE transcode test to ensure that the ICC profile gets
> > written (and read) correctly. Note that this ICC profile is smaller than
> > 64 kB, so this doesn't test the APP2 chunk re-arranging code at all.
> > 
> > Signed-off-by: Niklas Haas 
> > ---
> >  libavcodec/ljpegenc.c|  6 ++--
> >  libavcodec/mjpegenc.c|  3 +-
> >  libavcodec/mjpegenc_common.c | 68 ++--
> >  libavcodec/mjpegenc_common.h |  4 ++-
> >  libavcodec/mpegvideo_enc.c   |  4 ++-
> >  tests/fate/image.mak |  6 +++-
> >  tests/ref/fate/jpg-icc   | 42 ++
> >  7 files changed, 124 insertions(+), 9 deletions(-)
> >  create mode 100644 tests/ref/fate/jpg-icc
> > 
> > diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
> > index 1af4475b75..522898eb73 100644
> > --- a/libavcodec/ljpegenc.c
> > +++ b/libavcodec/ljpegenc.c
> > @@ -220,7 +220,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, 
> > AVPacket *pkt,
> >  const int height = avctx->height;
> >  const int mb_width  = (width  + s->hsample[0] - 1) / s->hsample[0];
> >  const int mb_height = (height + s->vsample[0] - 1) / s->vsample[0];
> > -int max_pkt_size = AV_INPUT_BUFFER_MIN_SIZE;
> > +size_t max_pkt_size = AV_INPUT_BUFFER_MIN_SIZE;
> >  int ret, header_bits;
> >  
> >  if(avctx->pix_fmt == AV_PIX_FMT_BGR0
> > @@ -233,12 +233,14 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, 
> > AVPacket *pkt,
> >  * s->hsample[0] * s->vsample[0];
> >  }
> >  
> > +if ((ret = ff_mjpeg_add_icc_profile_size(avctx, pict, _pkt_size)) 
> > < 0)
> > +return ret;
> >  if ((ret = ff_alloc_packet(avctx, pkt, max_pkt_size)) < 0)
> >  return ret;
> >  
> >  init_put_bits(, pkt->data, pkt->size);
> >  
> > -ff_mjpeg_encode_picture_header(avctx, , NULL, >scantable,
> > +ff_mjpeg_encode_picture_header(avctx, , pict, NULL, >scantable,
> > s->pred, s->matrix, s->matrix, 0);
> >  
> >  header_bits = put_bits_count();
> > diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
> > index 6ea113afb2..54ded08282 100644
> > --- a/libavcodec/mjpegenc.c
> > +++ b/libavcodec/mjpegenc.c
> > @@ -80,7 +80,7 @@ static av_cold void init_uni_ac_vlc(const uint8_t 
> > huff_size_ac[256],
> >  
> >  static void mjpeg_encode_picture_header(MpegEncContext *s)
> >  {
> > -ff_mjpeg_encode_picture_header(s->avctx, >pb, s->mjpeg_ctx,
> > +ff_mjpeg_encode_picture_header(s->avctx, >pb, s->picture->f, 
> > s->mjpeg_ctx,
> > >intra_scantable, 0,
> > s->intra_matrix, s->chroma_intra_matrix,
> > s->slice_context_count > 1);
> > @@ -131,6 +131,7 @@ static void mjpeg_encode_picture_frame(MpegEncContext 
> > *s)
> >  }
> >  
> >  bytes_needed = (total_bits + 7) / 8;
> > +ff_mjpeg_add_icc_profile_size(s->avctx, s->picture->f, _needed);
> >  ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
> >  
> >  for (int i = 0; i < m->huff_ncode; i++) {
> > diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
> > index 4143a372bb..98c464fc62 100644
> > --- a/libavcodec/mjpegenc_common.c
> > +++ b/libavcodec/mjpegenc_common.c
> > @@ -131,8 +131,41 @@ static void jpeg_table_header(AVCodecContext *avctx, 
> > PutBitContext *p,
> >  AV_WB16(ptr, size);
> >  }
> >  
> > -static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)
> > +enum {
> > +ICC_HDR_SIZE= 16, /* ICC_PROFILE\0 tag + 4 bytes */
> > +ICC_CHUNK_SIZE  = UINT16_MAX - ICC_HDR_SIZE,
> > +ICC_MAX_CHUNKS  = UINT8_MAX,
> > +};
> > +
> > +int ff_mjpeg_add_icc_profile_size(AVCodecContext *avctx, const AVFrame 
> > *frame,
> > +  size_t *max_pkt_size)
> >  {
> > +const AVFrameSideData *sd;
> > +size_t new_pkt_size;
> > +int nb_chunks;
> > +sd = av_frame_get_side_data(frame, AV_FRAME_DATA_ICC_PROFILE);
> > +if (!sd || !sd->size)
> > +return 0;
> > +
> > +if (sd->size > ICC_MAX_CHUNKS * ICC_CHUNK_SIZE) {
> > +av_log(avctx, AV_LOG_ERROR, "Cannot store %"SIZE_SPECIFIER" byte 
> > ICC "
> > +   "profile: too large for JPEG\n",

Re: [FFmpeg-devel] [PATCH v13 1/1] avformat: Add IPFS protocol support.

2022-04-11 Thread Mark Gaiser
On Sun, Apr 10, 2022 at 4:41 PM Michael Niedermayer 
wrote:

> On Wed, Apr 06, 2022 at 02:00:56PM +0200, Mark Gaiser wrote:
> [...]
>
> > +if (stat_ret < 0) {
>
> > +av_log(h, AV_LOG_INFO, "Unable to find IPFS folder. We
> tried:\n");
> > +av_log(h, AV_LOG_INFO, "- $IPFS_PATH, which was empty.\n");
> > +av_log(h, AV_LOG_INFO, "- $HOME/.ipfs (full uri: %s) which
> doesn't exist.\n", ipfs_full_data_folder);
>
> The 3 av_log() can also be combined
>
> If nothing else is found then ill change that myself and apply in a day or
> 2
>

That would be awesome!! I'm looking forward to that very much.

>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Awnsering whenever a program halts or runs forever is
> On a turing machine, in general impossible (turings halting problem).
> On any real computer, always possible as a real computer has a finite
> number
> of states N, and will either halt in less than N cycles or never halt.
> ___
> 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] [PATCH v2] avformat/mpegts: set data broadcast streams as such

2022-04-11 Thread Jan Ekström
On Mon, Apr 11, 2022 at 1:50 PM Jan Ekström  wrote:
>
> From: Jan Ekström 
>
> Additionally, they should not be probed, as this is essentially
> various types of binary data.
>
> Signed-off-by: Jan Ekström 

Changes from v1:
- checking the length of descriptor to at least be 3 bytes before
reading them with getX(). The only error these functions can throw is
INVALIDDATA in case of the buffer not being large enough so this
should make sure that these reads cannot fail (VS checking each
separately for < 0).
- switching data type to the type returned by getX (int).

Jan
___
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] avfilter/vf_frei0r: Copy to frame allocated according to frei0r requirements

2022-04-11 Thread Michael Niedermayer
Fixes: issues with non trivial linesize

Signed-off-by: Michael Niedermayer 
---
 libavfilter/vf_frei0r.c | 40 
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 9cd0098e73..c9b698897f 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -349,18 +349,41 @@ static int query_formats(AVFilterContext *ctx)
 return ff_set_common_formats(ctx, formats);
 }
 
+static AVFrame *getframe(AVFilterLink *link)
+{
+int ret;
+AVFrame *frame = av_frame_alloc();
+if (!frame)
+return NULL;
+
+frame->width  = link->w;
+frame->height = link->h;
+frame->format = link->format;
+ret = av_frame_get_buffer(frame, 16);
+if (ret < 0)
+av_frame_free();
+
+return frame;
+}
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 Frei0rContext *s = inlink->dst->priv;
 AVFilterLink *outlink = inlink->dst->outputs[0];
-AVFrame *out;
+AVFrame *out = getframe(outlink);
+if (!out)
+goto fail;
 
-out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-if (!out) {
+av_frame_copy_props(out, in);
+
+if (in->linesize[0] != out->linesize[0]) {
+AVFrame *in2 = getframe(outlink);
+if (!in2)
+goto fail;
+av_frame_copy(in2, in);
 av_frame_free();
-return AVERROR(ENOMEM);
+in = in2;
 }
-av_frame_copy_props(out, in);
 
 s->update(s->instance, in->pts * av_q2d(inlink->time_base) * 1000,
(const uint32_t *)in->data[0],
@@ -369,6 +392,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 av_frame_free();
 
 return ff_filter_frame(outlink, out);
+fail:
+av_frame_free();
+av_frame_free();
+return AVERROR(ENOMEM);
 }
 
 static int process_command(AVFilterContext *ctx, const char *cmd, const char 
*args,
@@ -473,9 +500,6 @@ static int source_request_frame(AVFilterLink *outlink)
 frame->sample_aspect_ratio = (AVRational) {1, 1};
 frame->pts = s->pts++;
 
-s->update(s->instance, av_rescale_q(frame->pts, s->time_base, 
(AVRational){1,1000}),
-   NULL, (uint32_t *)frame->data[0]);
-
 return ff_filter_frame(outlink, frame);
 }
 
-- 
2.17.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 v13 3/4] avcodec/libjxl: add Jpeg XL encoding via libjxl

2022-04-11 Thread Anton Khirnov
Quoting Hendrik Leppkes (2022-04-09 17:44:45)
> > >
> > > Also, pointers from av_malloc() cannot be passed to av_realloc(). You
> > > need to allocate it with av_realloc() in the first place.
> >
> > Is this documented? afaik realloc() can be used with malloc'd pointers.
> > It will, i assume, also realloc it the first time you call it even if
> > you request the exact same amount of memory malloc already allocated.
> > But in any case it's hardly a problem if he can just use av_realloc the
> > first time.
> 
> realloc can work with malloc, but thats not guaranteed with every form
> of aligned memory allocator.
> 
> That said, I don't think any platform where this is currently a
> problem is known, and we likely have this issue in a few areas of the
> code.
> The documentation of this limitation was removed in 2016
> (21f70940ae106bfffa07e73057cdb4b5e81a767a)

I remember this used to be an issue in the past. If it isn't anymore
then disregard my comment.

-- 
Anton Khirnov
___
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 v13 3/4] avcodec/libjxl: add Jpeg XL encoding via libjxl

2022-04-11 Thread Anton Khirnov
Quoting Leo Izen (2022-04-11 13:16:21)
> 
> On 4/9/22 09:17, Anton Khirnov wrote:
> > Quoting Leo Izen (2022-04-05 18:55:03)
> >> +
> >> +/* check for negative zero, our default */
> >> +if (1.0f / ctx->distance == 1.0f / -0.0f) {
> > IIRC division by zero is UB. Why not make the default -1.0 and then just
> > check whether the number is negative?
> >
> The legal range is between 0 and 15, so if I set the default to -1, it 
> whines that the value is invalid. Should I just set the legal range to 
> -1 to 15 then and assume negative is unset?

Yes, that's what I would do.

-- 
Anton Khirnov
___
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 v13 3/4] avcodec/libjxl: add Jpeg XL encoding via libjxl

2022-04-11 Thread Leo Izen



On 4/9/22 09:17, Anton Khirnov wrote:

Quoting Leo Izen (2022-04-05 18:55:03)

+
+/* check for negative zero, our default */
+if (1.0f / ctx->distance == 1.0f / -0.0f) {

IIRC division by zero is UB. Why not make the default -1.0 and then just
check whether the number is negative?

The legal range is between 0 and 15, so if I set the default to -1, it 
whines that the value is invalid. Should I just set the legal range to 
-1 to 15 then and assume negative is unset?


-Leo Izen (thebombzen)


___
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] warning about configuration mismatch between ff* binaries and libraries

2022-04-11 Thread Nicolas George
Anton Khirnov (12022-04-11):
> I would prefer to not show all that noise in the banner, which would
> also resolve the confusion. Build information should be reduced to
> loglevel verbose IMO.

The people who do actual support on the users mailing-list and tracker
do not want that.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
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 v2] avformat/mpegts: set data broadcast streams as such

2022-04-11 Thread Jan Ekström
From: Jan Ekström 

Additionally, they should not be probed, as this is essentially
various types of binary data.

Signed-off-by: Jan Ekström 
---
 libavformat/mpegts.c| 53 +
 tests/fate/mpegts.mak   |  3 ++
 tests/ref/fate/mpegts-probe-sdt-data-stream | 14 ++
 3 files changed, 70 insertions(+)
 create mode 100644 tests/ref/fate/mpegts-probe-sdt-data-stream

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 49f7735123..d41f7fc8bd 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2516,6 +2516,13 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 }
 }
 p = desc_list_end;
+
+if (!ts->pkt && (stream_type >= 0x80 && stream_type <= 0xFF) &&
+st->codecpar->codec_id == AV_CODEC_ID_NONE)
+// if we are reading headers, and still have a user private stream
+// with no proper codec set, do not stop reading at PMT. Data
+// streams are marked within SDT.
+ts->stop_parse = 0;
 }
 
 if (!ts->pids[pcr_pid])
@@ -2699,6 +2706,7 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 if (val < 0)
 return;
 for (;;) {
+struct Program *program = NULL;
 sid = get16(, p_end);
 if (sid < 0)
 break;
@@ -2712,6 +2720,15 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 desc_list_end  = p + desc_list_len;
 if (desc_list_end > p_end)
 break;
+
+program = get_program(ts, sid);
+
+if (!ts->pkt && program && program->pmt_found)
+// if during header reading we have already received a PMT for
+// this program and now have received an SDT for it, stop further
+// reading at this point.
+ts->stop_parse = 2;
+
 for (;;) {
 desc_tag = get8(, desc_list_end);
 if (desc_tag < 0)
@@ -2744,6 +2761,42 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 av_free(name);
 av_free(provider_name);
 break;
+case 0x64: /* ETSI data broadcast descriptor; EN 300 468 6.2.11 */
+if (desc_len < 3)
+// length of the always available header part, up to and
+// including the component_tag field.
+break;
+
+{
+AVStream *st  = NULL;
+FFStream *sti = NULL;
+
+int data_broadcast_id = get16(, desc_end); // TS 101 162
+int component_tag = get8(, desc_end);
+if (!component_tag)
+// no stream mapping according to component_tag
+break;
+
+av_log(ts->stream, AV_LOG_TRACE,
+   "data broadcast id: %d, component tag: %d\n",
+   data_broadcast_id, component_tag);
+
+if (!program)
+break;
+
+st = find_matching_stream(ts, 0, sid, component_tag + 1, 0,
+  program);
+if (!st)
+break;
+
+sti = ffstream(st);
+
+st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+st->codecpar->codec_id   = AV_CODEC_ID_BIN_DATA;
+sti->request_probe = sti->need_parsing = 0;
+sti->need_context_update = 1;
+break;
+}
 default:
 break;
 }
diff --git a/tests/fate/mpegts.mak b/tests/fate/mpegts.mak
index bbcbfc47b2..ae21ee87d0 100644
--- a/tests/fate/mpegts.mak
+++ b/tests/fate/mpegts.mak
@@ -19,6 +19,9 @@ FATE_MPEGTS_PROBE-$(call DEMDEC, MPEGTS) += 
fate-mpegts-probe-pmt-merge
 fate-mpegts-probe-pmt-merge: SRC = $(TARGET_SAMPLES)/mpegts/pmtchange.ts
 fate-mpegts-probe-pmt-merge: CMD = run $(PROBE_CODEC_NAME_COMMAND) 
-merge_pmt_versions 1 -i "$(SRC)"
 
+FATE_MPEGTS_PROBE-$(call DEMDEC, MPEGTS, MP2) += 
fate-mpegts-probe-sdt-data-stream
+fate-mpegts-probe-sdt-data-stream: SRC = 
$(TARGET_SAMPLES)/mpegts/mpegts_sdt_data_stream.ts
+fate-mpegts-probe-sdt-data-stream: CMD = run $(PROBE_CODEC_NAME_COMMAND) -i 
"$(SRC)"
 
 FATE_SAMPLES_FFPROBE += $(FATE_MPEGTS_PROBE-yes)
 
diff --git a/tests/ref/fate/mpegts-probe-sdt-data-stream 
b/tests/ref/fate/mpegts-probe-sdt-data-stream
new file mode 100644
index 00..0b8e90962f
--- /dev/null
+++ b/tests/ref/fate/mpegts-probe-sdt-data-stream
@@ -0,0 +1,14 @@
+[PROGRAM]
+[STREAM]
+codec_name=mp2
+[/STREAM]
+[STREAM]
+codec_name=bin_data
+[/STREAM]
+[/PROGRAM]
+[STREAM]
+codec_name=mp2
+[/STREAM]
+[STREAM]
+codec_name=bin_data
+[/STREAM]
-- 
2.35.1


Re: [FFmpeg-devel] Hook for trailing whitespace

2022-04-11 Thread Gyan Doshi




On 2022-04-11 03:49 pm, Gyan Doshi wrote:


I was just prevented from pushing this patch[1] because of a trailing 
whitespace in a .texi file. This seems to be a new git hook as it 
wasn't in place before April 1.


Doc files should be excluded from whitespace checks as they may be 
required for formatting.


Looks like the hook is applied to ALL hunks in a patch if ANY hunk 
touches a source unit.

Can someone fine-tune the hook?

Regards,
Gyan

___
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] Hook for trailing whitespace

2022-04-11 Thread Gyan Doshi



I was just prevented from pushing this patch[1] because of a trailing 
whitespace in a .texi file. This seems to be a new git hook as it wasn't 
in place before April 1.


Doc files should be excluded from whitespace checks as they may be 
required for formatting.


Regards,
Gyan

[1]: 
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220410060622.1734-1-ffm...@gyani.pro/

___
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] lavc/encode: drop EncodeSimpleContext

2022-04-11 Thread Paul B Mahol
lgtm
___
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 v4] examples/decode_video: flush parser to fix missing frame

2022-04-11 Thread zhilizhao(赵志立)
Ping. The same kind of issue like `doc/examples/transcode_aac: Don't ignore 
last encoded frame.

https://patchwork.ffmpeg.org/project/ffmpeg/patch/8fd28808-07f8-9458-b032-8792c67a3...@gmail.com/

> On Jul 14, 2021, at 11:02 AM, Zhao Zhili  wrote:
> 
> ---
> v4: break when error occured in fread, fix infinite loop introduced by v3
> v3: check EOF by "eof = !data_size && feof(f);"
> 
> doc/examples/decode_video.c | 12 
> 1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/examples/decode_video.c b/doc/examples/decode_video.c
> index 18ee90a6c0..7238e38103 100644
> --- a/doc/examples/decode_video.c
> +++ b/doc/examples/decode_video.c
> @@ -92,6 +92,7 @@ int main(int argc, char **argv)
> uint8_t *data;
> size_t   data_size;
> int ret;
> +int eof;
> AVPacket *pkt;
> 
> if (argc <= 2) {
> @@ -150,15 +151,16 @@ int main(int argc, char **argv)
> exit(1);
> }
> 
> -while (!feof(f)) {
> +do {
> /* read raw data from the input file */
> data_size = fread(inbuf, 1, INBUF_SIZE, f);
> -if (!data_size)
> +if (ferror(f))
> break;
> +eof = !data_size;
> 
> /* use the parser to split the data into frames */
> data = inbuf;
> -while (data_size > 0) {
> +while (data_size > 0 || eof) {
> ret = av_parser_parse2(parser, c, >data, >size,
>data, data_size, AV_NOPTS_VALUE, 
> AV_NOPTS_VALUE, 0);
> if (ret < 0) {
> @@ -170,8 +172,10 @@ int main(int argc, char **argv)
> 
> if (pkt->size)
> decode(c, frame, pkt, outfilename);
> +else if (eof)
> +break;
> }
> -}
> +} while (!eof);
> 
> /* flush the decoder */
> decode(c, frame, NULL, outfilename);
> -- 
> 2.31.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 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] lavc/encode: add an encoder-specific get_buffer() variant

2022-04-11 Thread Anton Khirnov
Several encoders (roqvideo, svq1, snow, and the mpegvideo family)
currently call ff_get_buffer(). However this function is written
assuming it is called by a decoder. Though nothing has been obviously
broken by this until now, this may change in the future.

To avoid potential future issues, introduce a simple encode-specific
wrapper around avcodec_default_get_buffer2() and enforce its use in
encoders.
---
 libavcodec/decode.c  |  2 ++
 libavcodec/encode.c  | 34 ++
 libavcodec/encode.h  |  5 +
 libavcodec/mpegpicture.c | 16 +---
 libavcodec/roqvideoenc.c |  4 ++--
 libavcodec/snow.c|  8 ++--
 libavcodec/svq1enc.c |  4 ++--
 7 files changed, 60 insertions(+), 13 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index fffad5f700..3733e6d4b8 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1405,6 +1405,8 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, 
int flags)
 int override_dimensions = 1;
 int ret;
 
+av_assert0(av_codec_is_decoder(avctx->codec));
+
 if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
 if ((unsigned)avctx->width > INT_MAX - STRIDE_ALIGN ||
 (ret = av_image_check_size2(FFALIGN(avctx->width, STRIDE_ALIGN), 
avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || 
avctx->pix_fmt<0) {
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 8b0d4443cd..adeb28f0d3 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -571,3 +571,37 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 return 0;
 }
+
+int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
+{
+int ret;
+
+switch (avctx->codec->type) {
+case AVMEDIA_TYPE_VIDEO:
+frame->format = avctx->pix_fmt;
+if (frame->width <= 0 || frame->height <= 0) {
+frame->width  = FFMAX(avctx->width,  avctx->coded_width);
+frame->height = FFMAX(avctx->height, avctx->coded_height);
+}
+
+break;
+case AVMEDIA_TYPE_AUDIO:
+frame->sample_rate = avctx->sample_rate;
+frame->format  = avctx->sample_fmt;
+if (!frame->ch_layout.nb_channels) {
+ret = av_channel_layout_copy(>ch_layout, >ch_layout);
+if (ret < 0)
+return ret;
+}
+break;
+}
+
+ret = avcodec_default_get_buffer2(avctx, frame, 0);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+av_frame_unref(frame);
+return ret;
+}
+
+return 0;
+}
diff --git a/libavcodec/encode.h b/libavcodec/encode.h
index 97b3acf9df..b2536bf0f3 100644
--- a/libavcodec/encode.h
+++ b/libavcodec/encode.h
@@ -44,6 +44,11 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame 
*frame);
  */
 int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, 
int flags);
 
+/**
+ * Allocate buffers for a frame. Encoder equivalent to ff_get_buffer().
+ */
+int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame);
+
 /**
  * Check AVPacket size and allocate data.
  *
diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 681ccc2b82..aaa1df0bd8 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -26,6 +26,7 @@
 #include "libavutil/imgutils.h"
 
 #include "avcodec.h"
+#include "encode.h"
 #include "motion_est.h"
 #include "mpegpicture.h"
 #include "mpegutils.h"
@@ -123,14 +124,15 @@ static int alloc_frame_buffer(AVCodecContext *avctx,  
Picture *pic,
 int r, ret;
 
 pic->tf.f = pic->f;
-if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE &&
-avctx->codec_id != AV_CODEC_ID_VC1IMAGE  &&
-avctx->codec_id != AV_CODEC_ID_MSS2) {
-if (edges_needed) {
-pic->f->width  = avctx->width  + 2 * EDGE_WIDTH;
-pic->f->height = avctx->height + 2 * EDGE_WIDTH;
-}
 
+if (edges_needed) {
+pic->f->width  = avctx->width  + 2 * EDGE_WIDTH;
+pic->f->height = avctx->height + 2 * EDGE_WIDTH;
+
+r = ff_encode_alloc_frame(avctx, pic->f);
+} else if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE &&
+   avctx->codec_id != AV_CODEC_ID_VC1IMAGE  &&
+   avctx->codec_id != AV_CODEC_ID_MSS2) {
 r = ff_thread_get_ext_buffer(avctx, >tf,
  pic->reference ? AV_GET_BUFFER_FLAG_REF : 
0);
 } else {
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index ef7861088d..95db514140 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -1081,8 +1081,8 @@ static int roq_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 if (enc->first_frame) {
 /* Alloc memory for the reconstruction data (we must know the stride
  for that) */
-if ((ret = ff_get_buffer(avctx, roq->current_frame, 0)) < 0 ||
-(ret = ff_get_buffer(avctx, roq->last_frame,0)) < 0)
+if ((ret = ff_encode_alloc_frame(avctx, 

[FFmpeg-devel] [PATCH] lavc/encode: drop EncodeSimpleContext

2022-04-11 Thread Anton Khirnov
It has only a single member.
---
 libavcodec/avcodec.c  |  4 ++--
 libavcodec/encode.c   |  7 +++
 libavcodec/internal.h | 12 +++-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index c7daa385e7..e0f38ac42a 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -432,7 +432,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0)
 av_packet_unref(avci->last_pkt_props);
 
-av_frame_unref(avci->es.in_frame);
+av_frame_unref(avci->in_frame);
 av_packet_unref(avci->in_pkt);
 
 if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
@@ -498,7 +498,7 @@ av_cold int avcodec_close(AVCodecContext *avctx)
 av_packet_free(>last_pkt_props);
 
 av_packet_free(>in_pkt);
-av_frame_free(>es.in_frame);
+av_frame_free(>in_frame);
 
 av_buffer_unref(>pool);
 
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 837ffaa40d..8b0d4443cd 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -175,8 +175,7 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame 
*frame)
 static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
 {
 AVCodecInternal   *avci = avctx->internal;
-EncodeSimpleContext *es = >es;
-AVFrame  *frame = es->in_frame;
+AVFrame  *frame = avci->in_frame;
 const FFCodec *const codec = ffcodec(avctx->codec);
 int got_packet;
 int ret;
@@ -565,8 +564,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY;
 
 if (ffcodec(avctx->codec)->encode2) {
-avci->es.in_frame = av_frame_alloc();
-if (!avci->es.in_frame)
+avci->in_frame = av_frame_alloc();
+if (!avci->in_frame)
 return AVERROR(ENOMEM);
 }
 
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index f9d08fcb60..2fa56d3a59 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -47,10 +47,6 @@
 #   define STRIDE_ALIGN 8
 #endif
 
-typedef struct EncodeSimpleContext {
-AVFrame *in_frame;
-} EncodeSimpleContext;
-
 typedef struct AVCodecInternal {
 /**
  * When using frame-threaded decoding, this field is set for the first
@@ -101,7 +97,13 @@ typedef struct AVCodecInternal {
 
 void *frame_thread_encoder;
 
-EncodeSimpleContext es;
+/**
+ * The input frame is stored here for encoders implementing the simple
+ * encode API.
+ *
+ * Not allocated in other cases.
+ */
+AVFrame *in_frame;
 
 /**
  * If this is set, then FFCodec->close (if existing) needs to be called
-- 
2.34.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] lavc/snow: only allocate mconly_picture for decoding

2022-04-11 Thread Anton Khirnov
It is not used in the encoder.
---
Does this fix the crash?
---
 libavcodec/snow.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index 0a500695ce..97b0448dbf 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -513,16 +513,20 @@ int ff_snow_common_init_after_header(AVCodecContext 
*avctx) {
 int ret, emu_buf_size;
 
 if(!s->scratchbuf) {
-if ((ret = ff_get_buffer(s->avctx, s->mconly_picture,
- AV_GET_BUFFER_FLAG_REF)) < 0)
-return ret;
+if (av_codec_is_decoder(avctx->codec)) {
+if ((ret = ff_get_buffer(s->avctx, s->mconly_picture,
+ AV_GET_BUFFER_FLAG_REF)) < 0)
+return ret;
+}
+
 emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 
2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1);
 if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf,  
FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) ||
 !FF_ALLOCZ_TYPED_ARRAY(s->emu_edge_buffer, emu_buf_size))
 return AVERROR(ENOMEM);
 }
 
-if(s->mconly_picture->format != avctx->pix_fmt) {
+if (av_codec_is_decoder(avctx->codec) &&
+s->mconly_picture->format != avctx->pix_fmt) {
 av_log(avctx, AV_LOG_ERROR, "pixel format changed\n");
 return AVERROR_INVALIDDATA;
 }
-- 
2.34.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] [RFC] Switching ffmpeg.c to a threaded architecture

2022-04-11 Thread Anton Khirnov
Quoting Soft Works (2022-04-08 17:27:10)
> > Furthermore, remember that this is just the first step. There will be
> > further patchsets converting the other components. I intend to
> > upstream
> > them gradually one after the other. Your suggestion would require me
> > to
> > instead write the whole thing at once, fighting rebase conflicts all
> > the
> > way, and then submit it as a giant utterly unreviewable patchset. 
> 
> That's not what I meant, but anyway it's not worth discussing when
> it's a minority opinion.
> 
> Just a practical question instead for planning purposes:
> 
> Which timeframe do you expect for the whole process? 
> When do you plan to start

If you mean "start pushing the patches", then I intend to do that as
they are reviewed and approved. I hope to send the upstreamable version
of this set this week, if nobody has strong objectsions then I might
push it after vacation, i.e. late April/early May.

> and for how long do you think it will take until all further patchsets
> will be submitted/applied?

This is very hard to estimate accurately. A pessimistic guess assuming I
get stuck on every stupid thing would be end of this year, but I hope
for things to go much faster.

-- 
Anton Khirnov
___
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] avfilter: add feedback video filter

2022-04-11 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi  |  32 
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_feedback.c | 306 ++
 4 files changed, 340 insertions(+)
 create mode 100644 libavfilter/vf_feedback.c

diff --git a/doc/filters.texi b/doc/filters.texi
index ac49092743..612497d865 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12214,6 +12214,38 @@ fade=t=in:st=5.5:d=0.5
 
 @end itemize
 
+@section feedback
+Apply feedback video filter.
+
+This filter pass cropped input frames to 2nd output.
+From there it can be filtered with other video filters.
+After filter receives frame from 2nd input, that frame
+is combined on top of original frame from 1st input and passed
+to 1st output.
+
+The typical usage is filter only part of frame.
+
+The filter accepts the following options:
+@table @option
+@item x
+@item y
+Set the top left crop position.
+
+@item w
+@item h
+Set the crop size.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Blur only top left rectangular part of size 100x100 of frame with gblur filter.
+@example
+[in][blurin]feedback=x=0:y=0:w=100:h=100[out][blurout];[blurout]gblur[blurin]
+@end example
+@end itemize
+
 @section fftdnoiz
 Denoise frames using 3D FFT (frequency domain filtering).
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index d69bd59bb6..bdfdfdc04a 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -279,6 +279,7 @@ OBJS-$(CONFIG_ESTDIF_FILTER) += vf_estdif.o
 OBJS-$(CONFIG_EXPOSURE_FILTER)   += vf_exposure.o
 OBJS-$(CONFIG_EXTRACTPLANES_FILTER)  += vf_extractplanes.o
 OBJS-$(CONFIG_FADE_FILTER)   += vf_fade.o
+OBJS-$(CONFIG_FEEDBACK_FILTER)   += vf_feedback.o
 OBJS-$(CONFIG_FFTDNOIZ_FILTER)   += vf_fftdnoiz.o
 OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o
 OBJS-$(CONFIG_FIELD_FILTER)  += vf_field.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index abd1fe2367..44fac46521 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -261,6 +261,7 @@ extern const AVFilter ff_vf_estdif;
 extern const AVFilter ff_vf_exposure;
 extern const AVFilter ff_vf_extractplanes;
 extern const AVFilter ff_vf_fade;
+extern const AVFilter ff_vf_feedback;
 extern const AVFilter ff_vf_fftdnoiz;
 extern const AVFilter ff_vf_fftfilt;
 extern const AVFilter ff_vf_field;
diff --git a/libavfilter/vf_feedback.c b/libavfilter/vf_feedback.c
new file mode 100644
index 00..cf6ef7ef0c
--- /dev/null
+++ b/libavfilter/vf_feedback.c
@@ -0,0 +1,306 @@
+/*
+ * 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
+ * feedback video filter
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/fifo.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "libavutil/internal.h"
+#include "avfilter.h"
+#include "filters.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct FeedbackContext {
+const AVClass *class;
+
+int x, y;
+int w, h;
+
+int max_step[4];
+int hsub, vsub;
+
+AVFrame *feed;
+
+AVFifo *fifo;
+} FeedbackContext;
+
+static void adjust_pos(AVFilterContext *ctx, FeedbackContext *s)
+{
+if (s->x + s->w > ctx->inputs[0]->w)
+s->x = ctx->inputs[0]->w - s->w;
+if (s->y + s->h > ctx->inputs[0]->h)
+s->y = ctx->inputs[0]->h - s->h;
+}
+
+static void adjust_parameters(AVFilterContext *ctx, FeedbackContext *s)
+{
+if (s->x >= ctx->inputs[0]->w)
+s->x = 0;
+if (s->y >= ctx->inputs[0]->h)
+s->y = 0;
+
+if (s->w <= 0)
+s->w = ctx->inputs[0]->w - s->x;
+if (s->h <= 0)
+s->h = ctx->inputs[0]->h - s->y;
+
+if (s->w > ctx->inputs[0]->w)
+s->w = ctx->inputs[0]->w;
+if (s->h > ctx->inputs[0]->h)
+s->h = ctx->inputs[0]->h;
+
+adjust_pos(ctx, s);
+}
+
+static int config_input(AVFilterLink *inlink)
+{
+AVFilterContext *ctx = inlink->dst;
+const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
+FeedbackContext *s = ctx->priv;
+
+s->hsub = pix_desc->log2_chroma_w;
+s->vsub = pix_desc->log2_chroma_h;
+
+

Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: fix timecode with high frame rate content

2022-04-11 Thread Anton Khirnov
Quoting Marton Balint (2022-04-10 20:11:59)
> 60 fps content have "Number of Frames" set to 30 in the tmcd atom, but the
> frame duration / timescale reflects the original video frame rate.
> 
> Therefore we multiply the frame count with the quotient of the rounded 
> timecode
> frame rate and the "Number of Frames" per second to get a frame count in the 
> original
> (higher) frame rate.
> 
> Note that the frames part in the timecode will be in high frame rate which 
> will
> make the timecode different to e.g. MediaInfo which seems to show the 30 fps
> timecode even for 120 fps content.
> 
> Regression since 428b4aacb1a91a267650de644519882a5f700388.
> 
> Fixes ticket #9710.
> Fixes ticket #9492.

Sounds like there should be a test for this.

-- 
Anton Khirnov
___
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] warning about configuration mismatch between ff* binaries and libraries

2022-04-11 Thread Anton Khirnov
Quoting zhilizhao(赵志立) (2022-04-11 05:15:59)
> 
> 
> > On Apr 11, 2022, at 5:31 AM, Dominik 'Rathann' Mierzejewski 
> >  wrote:
> > 
> > Dear Developers!
> > I'm curious about the warning about configuration mismatch between ff*
> > binaries and the libraries introduced in:
> > 
> > https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/9120e2cd3fadfa60269e94f97fc8107974c586fc
> > 
> > At Fedora, we're interested in having two builds: one built with limited
> > set of codecs[1] that is legally distributable in the US (since Red Hat,
> > Fedora sponsor is a US-based company) and another, with a more complete
> > set of codecs[2] distributed by RPM Fusion. The builds are intended to
> > be drop-in replacements. We'd like to be able to distribute just one set
> > of ff* binaries and only have two different interchangeable builds of
> > libraries.
> > 
> > The idea is to have the builds differ by enabled codecs only and have
> > the rest of the configuration the same (even if it's not the case
> > today).
> > 
> > So, does that warning still make sense today? Will something break
> > if we swap the libraries but keep the binary on user systems?
> 
> That’s exactly an example of why the warning is useful. Otherwise user can
> be confused why some codecs are missing while banner says they are enabled
> by configure. So yes, the warning still make sense.

I would prefer to not show all that noise in the banner, which would
also resolve the confusion. Build information should be reduced to
loglevel verbose IMO.

I would also be in favor of removing the mismatch warning. Different
builds are supposed to be ABI-compatible, so mismatching configuration
is not a cause for a warning.

-- 
Anton Khirnov
___
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/2] doc/examples/transcode_aac: Don't ignore last encoded frame

2022-04-11 Thread Gyan Doshi




On 2022-04-11 12:16 pm, Paul B Mahol wrote:

On Tue, Mar 22, 2022 at 6:47 PM Andreas Unterweger 
wrote:


The last encoded frame is now fetched on EOF. It was previously left in
the encoder and caused a "1 frame left in queue" warning.

Signed-off-by: Andreas Unterweger 
---
   doc/examples/transcode_aac.c | 22 +++---
   1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index 9102e55f16..c9b93f6439 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -377,6 +377,8 @@ static int decode_audio_frame(AVFrame *frame,
   if (error < 0)
   return error;

+*data_present = 0;
+*finished = 0;
   /* Read one audio frame from the input file into a temporary packet.
*/
   if ((error = av_read_frame(input_format_context, input_packet)) < 0)
{
   /* If we are at the end of the file, flush the decoder below. */
@@ -555,7 +557,7 @@ static int read_decode_convert_and_store(AVAudioFifo
*fifo,
   AVFrame *input_frame = NULL;
   /* Temporary storage for the converted input samples. */
   uint8_t **converted_input_samples = NULL;
-int data_present = 0;
+int data_present;
   int ret = AVERROR_EXIT;

   /* Initialize temporary storage for one input frame. */
@@ -675,18 +677,17 @@ static int encode_audio_frame(AVFrame *frame,
   frame->pts = pts;
   pts += frame->nb_samples;
   }
-
+
+*data_present = 0;
   /* Send the audio frame stored in the temporary packet to the
encoder.
* The output audio stream encoder is used to do this. */
   error = avcodec_send_frame(output_codec_context, frame);
-/* The encoder signals that it has nothing more to encode. */
-if (error == AVERROR_EOF) {
-error = 0;
-goto cleanup;
-} else if (error < 0) {
-fprintf(stderr, "Could not send packet for encoding (error
'%s')\n",
-av_err2str(error));
-goto cleanup;
+/* Check for errors, but proceed with fetching encoded samples if the
+ *  encoder signals that it has nothing more to encode. */
+if (error < 0 && error != AVERROR_EOF) {
+  fprintf(stderr, "Could not send packet for encoding (error '%s')\n",
+  av_err2str(error));
+  goto cleanup;
   }

   /* Receive one encoded frame from the encoder. */
@@ -857,7 +858,6 @@ int main(int argc, char **argv)
   int data_written;
   /* Flush the encoder as it may have delayed frames. */
   do {
-data_written = 0;
   if (encode_audio_frame(NULL, output_format_context,
  output_codec_context,
_written))
   goto cleanup;
--
2.30.2



LGTM. can someone apply this?


Patch does not apply. May need to be manually rebased.

Regards,
Gyan

___
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] warning about configuration mismatch between ff* binaries and libraries

2022-04-11 Thread Dominik 'Rathann' Mierzejewski
On Monday, 11 April 2022 at 05:15, "zhilizhao(赵志立)" wrote:
> > On Apr 11, 2022, at 5:31 AM, Dominik 'Rathann' Mierzejewski
> >  wrote:
> > 
> > Dear Developers!
> > I'm curious about the warning about configuration mismatch between
> > ff* binaries and the libraries introduced in:
> > 
> > https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/9120e2cd3fadfa60269e94f97fc8107974c586fc
> > 
[...]
> > The idea is to have the builds differ by enabled codecs only and
> > have the rest of the configuration the same (even if it's not the
> > case today).
> > 
> > So, does that warning still make sense today? Will something break
> > if we swap the libraries but keep the binary on user systems?
> 
> That’s exactly an example of why the warning is useful. Otherwise user
> can be confused why some codecs are missing while banner says they are
> enabled by configure. So yes, the warning still make sense.

Granted.

> For the second question, I guess it may miss a few features depending
> on the configuration. Try `grep CONFIG_ -r fftools/` and test.

Thanks for the tip.

Regards,
Dominik
-- 
Fedora   https://getfedora.org  |  RPM Fusion  http://rpmfusion.org
There should be a science of discontent. People need hard times and
oppression to develop psychic muscles.
-- from "Collected Sayings of Muad'Dib" by the Princess Irulan
___
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/2] doc/examples/transcode_aac: Don't ignore last encoded frame

2022-04-11 Thread Paul B Mahol
On Tue, Mar 22, 2022 at 6:47 PM Andreas Unterweger 
wrote:

> The last encoded frame is now fetched on EOF. It was previously left in
> the encoder and caused a "1 frame left in queue" warning.
>
> Signed-off-by: Andreas Unterweger 
> ---
>   doc/examples/transcode_aac.c | 22 +++---
>   1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
> index 9102e55f16..c9b93f6439 100644
> --- a/doc/examples/transcode_aac.c
> +++ b/doc/examples/transcode_aac.c
> @@ -377,6 +377,8 @@ static int decode_audio_frame(AVFrame *frame,
>   if (error < 0)
>   return error;
>
> +*data_present = 0;
> +*finished = 0;
>   /* Read one audio frame from the input file into a temporary packet.
> */
>   if ((error = av_read_frame(input_format_context, input_packet)) < 0)
> {
>   /* If we are at the end of the file, flush the decoder below. */
> @@ -555,7 +557,7 @@ static int read_decode_convert_and_store(AVAudioFifo
> *fifo,
>   AVFrame *input_frame = NULL;
>   /* Temporary storage for the converted input samples. */
>   uint8_t **converted_input_samples = NULL;
> -int data_present = 0;
> +int data_present;
>   int ret = AVERROR_EXIT;
>
>   /* Initialize temporary storage for one input frame. */
> @@ -675,18 +677,17 @@ static int encode_audio_frame(AVFrame *frame,
>   frame->pts = pts;
>   pts += frame->nb_samples;
>   }
> -
> +
> +*data_present = 0;
>   /* Send the audio frame stored in the temporary packet to the
> encoder.
>* The output audio stream encoder is used to do this. */
>   error = avcodec_send_frame(output_codec_context, frame);
> -/* The encoder signals that it has nothing more to encode. */
> -if (error == AVERROR_EOF) {
> -error = 0;
> -goto cleanup;
> -} else if (error < 0) {
> -fprintf(stderr, "Could not send packet for encoding (error
> '%s')\n",
> -av_err2str(error));
> -goto cleanup;
> +/* Check for errors, but proceed with fetching encoded samples if the
> + *  encoder signals that it has nothing more to encode. */
> +if (error < 0 && error != AVERROR_EOF) {
> +  fprintf(stderr, "Could not send packet for encoding (error '%s')\n",
> +  av_err2str(error));
> +  goto cleanup;
>   }
>
>   /* Receive one encoded frame from the encoder. */
> @@ -857,7 +858,6 @@ int main(int argc, char **argv)
>   int data_written;
>   /* Flush the encoder as it may have delayed frames. */
>   do {
> -data_written = 0;
>   if (encode_audio_frame(NULL, output_format_context,
>  output_codec_context,
> _written))
>   goto cleanup;
> --
> 2.30.2
>
>
LGTM. can someone apply this?


> ___
> 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".