Re: [FFmpeg-devel] [PATCH 4/4] lavc/vulkan: add SPIR-V compilation support

2024-10-04 Thread Martin Storsjö

On Fri, 4 Oct 2024, Lynne via ffmpeg-devel wrote:


On 04/10/2024 12:01, epira...@gmail.com wrote:

On 4 Oct 2024, at 11:31, Lynne via ffmpeg-devel wrote:


This is the same as with libavfilter.

We will need SPIR-V compilation for at least three different things,
like the VC-2 encoder and decoder, AV1 film grain synthesis for
hardware with no support for it, and possibly other codecs.
---
  libavcodec/Makefile |  4 
  libavcodec/vulkan_glslang.c | 19 +++
  libavcodec/vulkan_shaderc.c | 19 +++
  3 files changed, 42 insertions(+)
  create mode 100644 libavcodec/vulkan_glslang.c
  create mode 100644 libavcodec/vulkan_shaderc.c

diff --git a/libavcodec/vulkan_shaderc.c b/libavcodec/vulkan_shaderc.c
new file mode 100644
index 00..9f60bf4dfd
--- /dev/null
+++ b/libavcodec/vulkan_shaderc.c
@@ -0,0 +1,19 @@
+/*
+ * 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/vulkan_shaderc.c"


Wouldn’t this cause duplicate symbol issues with for example 
ff_vk_shaderc_init

being in both libavfilter and libavcodec?


No. For completely identical objects like we have here, the linker 
deduplicates while linking.


Not quite...

A linker doesn't deduplicate things wrt static libraries; it's the other 
way around. With a static library, the linker only pulls in specifically 
the object files that are needed to fulfill some missing symbol. As long 
as both objects provide the exact same set of symbols, there's no 
collision and no issue with duplicates.


If you have two objects that provide a differing set of symbols, you may 
end up pulling in both object files, and you have such a conflict.


If a static library is linked with flags like --wholearchive, forcing the 
linker to pull in all object files (as if they were specified directly on 
the linker command line), you'd also hit the same conflict. (Not that we 
usually do this, though.)


This is how vulkan.c is also handled across libavutil, libavfilter and 
libavcodec. We also handle something else in the same way, but I don't 
remember what.


I'm not sure about these cases, but we have a slightly similar thing with 
e.g. log2_tab.c, which contains an ff_ prefixed symbol; for static-only 
builds, we only provide the object file in libavutil, as it will be 
accessible to other libraries from there. For shared library builds, we 
include the object in the other shared libraries, so that the symbols 
(which aren't visible/exported across shared libraries) won't need to be 
accessed across shared libraries.


// Martin
___
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] vulkan: move SPIR-V compilation code to libavutil

2024-10-04 Thread Lynne via ffmpeg-devel
The code is not currently used by libavutil, its just where our
common Vulkan code is.
Since SPIR-V compilation will be needed by lavc, move it, rather
than having lavc including lavfi.
---
 libavfilter/Makefile  |   2 -
 libavfilter/vf_avgblur_vulkan.c   |   2 +-
 libavfilter/vf_blend_vulkan.c |   2 +-
 libavfilter/vf_bwdif_vulkan.c |   2 +-
 libavfilter/vf_chromaber_vulkan.c |   2 +-
 libavfilter/vf_flip_vulkan.c  |   2 +-
 libavfilter/vf_gblur_vulkan.c |   2 +-
 libavfilter/vf_nlmeans_vulkan.c   |   2 +-
 libavfilter/vf_overlay_vulkan.c   |   2 +-
 libavfilter/vf_scale_vulkan.c |   2 +-
 libavfilter/vf_transpose_vulkan.c |   2 +-
 libavfilter/vf_xfade_vulkan.c |   2 +-
 libavfilter/vsrc_testsrc_vulkan.c |   2 +-
 libavfilter/vulkan_glslang.c  | 291 +---
 libavfilter/vulkan_shaderc.c  | 127 +
 libavutil/vulkan_glslang.c| 308 ++
 libavutil/vulkan_shaderc.c| 144 ++
 {libavfilter => libavutil}/vulkan_spirv.h |   2 +-
 18 files changed, 467 insertions(+), 431 deletions(-)
 create mode 100644 libavutil/vulkan_glslang.c
 create mode 100644 libavutil/vulkan_shaderc.c
 rename {libavfilter => libavutil}/vulkan_spirv.h (98%)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 9253e362fc..7d8391f132 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -663,8 +663,6 @@ SKIPHEADERS-$(CONFIG_QSVVPP) += qsvvpp.h 
stack_internal.h
 SKIPHEADERS-$(CONFIG_OPENCL) += opencl.h
 SKIPHEADERS-$(CONFIG_VAAPI)  += vaapi_vpp.h stack_internal.h
 SKIPHEADERS-$(CONFIG_VULKAN) += vulkan_filter.h
-SKIPHEADERS-$(CONFIG_LIBSHADERC) += vulkan_spirv.h
-SKIPHEADERS-$(CONFIG_LIBGLSLANG) += vulkan_spirv.h
 
 TOOLS = graph2dot
 TESTPROGS = drawutils filtfmts formats integral
diff --git a/libavfilter/vf_avgblur_vulkan.c b/libavfilter/vf_avgblur_vulkan.c
index 9214ebcc0f..36f00a7a74 100644
--- a/libavfilter/vf_avgblur_vulkan.c
+++ b/libavfilter/vf_avgblur_vulkan.c
@@ -19,9 +19,9 @@
  */
 
 #include "libavutil/random_seed.h"
+#include "libavutil/vulkan_spirv.h"
 #include "libavutil/opt.h"
 #include "vulkan_filter.h"
-#include "vulkan_spirv.h"
 
 #include "filters.h"
 #include "video.h"
diff --git a/libavfilter/vf_blend_vulkan.c b/libavfilter/vf_blend_vulkan.c
index 406b087503..a2834353e7 100644
--- a/libavfilter/vf_blend_vulkan.c
+++ b/libavfilter/vf_blend_vulkan.c
@@ -22,9 +22,9 @@
  */
 
 #include "libavutil/random_seed.h"
+#include "libavutil/vulkan_spirv.h"
 #include "libavutil/opt.h"
 #include "vulkan_filter.h"
-#include "vulkan_spirv.h"
 
 #include "filters.h"
 #include "framesync.h"
diff --git a/libavfilter/vf_bwdif_vulkan.c b/libavfilter/vf_bwdif_vulkan.c
index 2ea9512fcb..0d6f1dc39e 100644
--- a/libavfilter/vf_bwdif_vulkan.c
+++ b/libavfilter/vf_bwdif_vulkan.c
@@ -22,8 +22,8 @@
 
 #include "libavutil/random_seed.h"
 #include "libavutil/opt.h"
+#include "libavutil/vulkan_spirv.h"
 #include "vulkan_filter.h"
-#include "vulkan_spirv.h"
 #include "yadif.h"
 #include "filters.h"
 
diff --git a/libavfilter/vf_chromaber_vulkan.c 
b/libavfilter/vf_chromaber_vulkan.c
index 8a62e514fa..e677261259 100644
--- a/libavfilter/vf_chromaber_vulkan.c
+++ b/libavfilter/vf_chromaber_vulkan.c
@@ -20,8 +20,8 @@
 
 #include "libavutil/random_seed.h"
 #include "libavutil/opt.h"
+#include "libavutil/vulkan_spirv.h"
 #include "vulkan_filter.h"
-#include "vulkan_spirv.h"
 
 #include "filters.h"
 #include "video.h"
diff --git a/libavfilter/vf_flip_vulkan.c b/libavfilter/vf_flip_vulkan.c
index 3e0a7ebc85..396f85da9b 100644
--- a/libavfilter/vf_flip_vulkan.c
+++ b/libavfilter/vf_flip_vulkan.c
@@ -21,8 +21,8 @@
 
 #include "libavutil/random_seed.h"
 #include "libavutil/opt.h"
+#include "libavutil/vulkan_spirv.h"
 #include "vulkan_filter.h"
-#include "vulkan_spirv.h"
 
 #include "filters.h"
 #include "video.h"
diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c
index 9632a084e4..110f19e555 100644
--- a/libavfilter/vf_gblur_vulkan.c
+++ b/libavfilter/vf_gblur_vulkan.c
@@ -22,8 +22,8 @@
 #include "libavutil/mem.h"
 #include "libavutil/random_seed.h"
 #include "libavutil/opt.h"
+#include "libavutil/vulkan_spirv.h"
 #include "vulkan_filter.h"
-#include "vulkan_spirv.h"
 
 #include "filters.h"
 #include "video.h"
diff --git a/libavfilter/vf_nlmeans_vulkan.c b/libavfilter/vf_nlmeans_vulkan.c
index 39460dc194..1c729a2e7a 100644
--- a/libavfilter/vf_nlmeans_vulkan.c
+++ b/libavfilter/vf_nlmeans_vulkan.c
@@ -20,9 +20,9 @@
 
 #include "libavutil/mem.h"
 #include "libavutil/random_seed.h"
+#include "libavutil/vulkan_spirv.h"
 #include "libavutil/opt.h"
 #include "vulkan_filter.h"
-#include "vulkan_spirv.h"
 
 #include "filters.h"
 #include "video.h"
diff --git a/libavfilter/vf_overlay_vulkan.c b/libav

[FFmpeg-devel] [PATCH 4/4] lavc/vulkan: add SPIR-V compilation support

2024-10-04 Thread Lynne via ffmpeg-devel
This is the same as with libavfilter.

We will need SPIR-V compilation for at least three different things,
like the VC-2 encoder and decoder, AV1 film grain synthesis for
hardware with no support for it, and possibly other codecs.
---
 libavcodec/Makefile |  4 
 libavcodec/vulkan_glslang.c | 19 +++
 libavcodec/vulkan_shaderc.c | 19 +++
 3 files changed, 42 insertions(+)
 create mode 100644 libavcodec/vulkan_glslang.c
 create mode 100644 libavcodec/vulkan_shaderc.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a253a9b160..7147ed0360 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1257,6 +1257,10 @@ OBJS-$(HAVE_THREADS)   += pthread.o 
pthread_slice.o pthread_fram
 
 OBJS-$(CONFIG_FRAME_THREAD_ENCODER)+= frame_thread_encoder.o
 
+# vulkan libs
+OBJS-$(CONFIG_LIBGLSLANG)  += vulkan_glslang.o
+OBJS-$(CONFIG_LIBSHADERC)  += vulkan_shaderc.o
+
 # Windows resource file
 SHLIBOBJS-$(HAVE_GNU_WINDRES)   += avcodecres.o
 
diff --git a/libavcodec/vulkan_glslang.c b/libavcodec/vulkan_glslang.c
new file mode 100644
index 00..9aa41567a3
--- /dev/null
+++ b/libavcodec/vulkan_glslang.c
@@ -0,0 +1,19 @@
+/*
+ * 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/vulkan_glslang.c"
diff --git a/libavcodec/vulkan_shaderc.c b/libavcodec/vulkan_shaderc.c
new file mode 100644
index 00..9f60bf4dfd
--- /dev/null
+++ b/libavcodec/vulkan_shaderc.c
@@ -0,0 +1,19 @@
+/*
+ * 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/vulkan_shaderc.c"
-- 
2.45.2.753.g447d99e1c3b
___
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] lavfi/vulkan: remove redundant header

2024-10-04 Thread Lynne via ffmpeg-devel
---
 libavfilter/Makefile|  2 +-
 libavfilter/vulkan.h| 24 
 libavfilter/vulkan_filter.h |  2 +-
 libavfilter/vulkan_spirv.h  |  1 -
 4 files changed, 2 insertions(+), 27 deletions(-)
 delete mode 100644 libavfilter/vulkan.h

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index a56c8e8b79..9253e362fc 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -662,7 +662,7 @@ SKIPHEADERS-$(CONFIG_LIBVIDSTAB) += 
vidstabutils.h
 SKIPHEADERS-$(CONFIG_QSVVPP) += qsvvpp.h stack_internal.h
 SKIPHEADERS-$(CONFIG_OPENCL) += opencl.h
 SKIPHEADERS-$(CONFIG_VAAPI)  += vaapi_vpp.h stack_internal.h
-SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_filter.h
+SKIPHEADERS-$(CONFIG_VULKAN) += vulkan_filter.h
 SKIPHEADERS-$(CONFIG_LIBSHADERC) += vulkan_spirv.h
 SKIPHEADERS-$(CONFIG_LIBGLSLANG) += vulkan_spirv.h
 
diff --git a/libavfilter/vulkan.h b/libavfilter/vulkan.h
deleted file mode 100644
index 928b2e21c3..00
--- a/libavfilter/vulkan.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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
- */
-
-#ifndef AVFILTER_VULKAN_H
-#define AVFILTER_VULKAN_H
-
-#include "libavutil/vulkan.h"
-
-#endif /* AVFILTER_VULKAN_H */
diff --git a/libavfilter/vulkan_filter.h b/libavfilter/vulkan_filter.h
index 9f1297e0d2..6ed9c4de39 100644
--- a/libavfilter/vulkan_filter.h
+++ b/libavfilter/vulkan_filter.h
@@ -23,7 +23,7 @@
 
 #include "avfilter.h"
 
-#include "vulkan.h"
+#include "libavutil/vulkan.h"
 
 /**
  * General lavfi IO functions
diff --git a/libavfilter/vulkan_spirv.h b/libavfilter/vulkan_spirv.h
index d008804ab2..b0349b6b54 100644
--- a/libavfilter/vulkan_spirv.h
+++ b/libavfilter/vulkan_spirv.h
@@ -21,7 +21,6 @@
 
 #include "libavutil/vulkan.h"
 
-#include "vulkan.h"
 #include "config.h"
 
 typedef struct FFVkSPIRVCompiler {
-- 
2.45.2.753.g447d99e1c3b
___
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] lavc/vulkan: remove redundant header

2024-10-04 Thread Lynne via ffmpeg-devel
---
 libavcodec/Makefile   |  2 +-
 libavcodec/vulkan.h   | 24 
 libavcodec/vulkan_video.h |  2 +-
 3 files changed, 2 insertions(+), 26 deletions(-)
 delete mode 100644 libavcodec/vulkan.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5aed2fff28..a253a9b160 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1290,7 +1290,7 @@ SKIPHEADERS-$(CONFIG_QSVENC)   += qsvenc.h
 SKIPHEADERS-$(CONFIG_VAAPI)+= vaapi_decode.h vaapi_hevc.h 
vaapi_encode.h
 SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h
 SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h
-SKIPHEADERS-$(CONFIG_VULKAN)   += vulkan.h vulkan_video.h 
vulkan_encode.h vulkan_decode.h
+SKIPHEADERS-$(CONFIG_VULKAN)   += vulkan_video.h vulkan_encode.h 
vulkan_decode.h
 SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h 
v4l2_m2m.h
 SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h
 
diff --git a/libavcodec/vulkan.h b/libavcodec/vulkan.h
deleted file mode 100644
index b15efd4add..00
--- a/libavcodec/vulkan.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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
- */
-
-#ifndef AVCODEC_VULKAN_H
-#define AVCODEC_VULKAN_H
-
-#include "libavutil/vulkan.h"
-
-#endif /* AVCODEC_VULKAN_H */
diff --git a/libavcodec/vulkan_video.h b/libavcodec/vulkan_video.h
index c205f7b88f..1ec5f419ed 100644
--- a/libavcodec/vulkan_video.h
+++ b/libavcodec/vulkan_video.h
@@ -20,7 +20,7 @@
 #define AVCODEC_VULKAN_VIDEO_H
 
 #include "avcodec.h"
-#include "vulkan.h"
+#include "libavutil/vulkan.h"
 
 #include 
 
-- 
2.45.2.753.g447d99e1c3b
___
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] vulkan_encode: do not align DPB buffer size

2024-10-04 Thread Lynne via ffmpeg-devel
Per subsection B stroke 165 of Chapter 56,
drivers are required to do the aligning, not users.
---
 libavcodec/vulkan_encode.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/vulkan_encode.c b/libavcodec/vulkan_encode.c
index 6d1743c7d7..9ad02e8c52 100644
--- a/libavcodec/vulkan_encode.c
+++ b/libavcodec/vulkan_encode.c
@@ -220,8 +220,7 @@ static int vulkan_encode_issue(AVCodecContext *avctx,
 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
 .pNext = NULL,
 .codedOffset = { 0 },
-.codedExtent = (VkExtent2D){ ctx->base.surface_width,
- ctx->base.surface_height },
+.codedExtent = (VkExtent2D){ avctx->width, avctx->height },
 .baseArrayLayer = ctx->common.layered_dpb ? slot_index : 0,
 .imageViewBinding = vp->dpb.view,
 };
@@ -565,8 +564,8 @@ static int vulkan_encode_create_dpb(AVCodecContext *avctx, 
FFVulkanEncodeContext
 
 base_ctx->recon_frames->format= AV_PIX_FMT_VULKAN;
 base_ctx->recon_frames->sw_format = dpb_format;
-base_ctx->recon_frames->width = base_ctx->surface_width;
-base_ctx->recon_frames->height= base_ctx->surface_height;
+base_ctx->recon_frames->width = avctx->width;
+base_ctx->recon_frames->height= avctx->height;
 
 hwfc->format[0]= ctx->pic_format;
 hwfc->create_pnext = &ctx->profile_list;
@@ -915,9 +914,9 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, 
FFVulkanEncodeContext *
 
 /* Setup width/height alignment */
 base_ctx->surface_width = avctx->coded_width =
-FFALIGN(avctx->width, ctx->caps.pictureAccessGranularity.width);
+FFALIGN(avctx->width, 
ctx->enc_caps.encodeInputPictureGranularity.width);
 base_ctx->surface_height = avctx->coded_height =
-FFALIGN(avctx->height, ctx->caps.pictureAccessGranularity.height);
+FFALIGN(avctx->height, 
ctx->enc_caps.encodeInputPictureGranularity.height);
 
 /* Setup slice width/height */
 base_ctx->slice_block_width = 
ctx->enc_caps.encodeInputPictureGranularity.width;
-- 
2.45.2.753.g447d99e1c3b
___
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 - Uncompressed MP4

2024-10-04 Thread Devon Sookhoo
I appreciate your feedback. Doing the decoder side first is a good
suggestion, I certainly want to start with whichever is easier. I
originally started with the encoder simply because of the limited number of
existing test files. However, I believe that GPAC is able to generate some.

I thought the option  "-c:v rawvideo"  was the way to go because it's used
to generate an uncompressed avi file:
$ ffmpeg -i input.mp4  -c:v rawvideo  out.avi

Is this an exception? If "-c:v rawvideo" isn't typically used to generate
uncompressed files, then what is?

On Fri, Oct 4, 2024 at 8:14 AM martin schitter  wrote:

>
>
> On 04.10.24 15:11, Devon Sookhoo wrote:
> > You're correct that I'm primarily interested in uncompressed data and not
> > raw bayer sensor data.
>
> Yes -- it was more a rather extreme example to remind, that this file
> format isn't as simple and limited as many old and simple AV packaging
> solutions for uncompressed pixel data. This opens interesting new
> applications, but it also comes with lots of complex management and
> configuration demands.
>
> > However, it seems like the  "-c:v rawvideo"  option
> > is the convention in other formats to generate uncompressed video data.
>
> No -- I think, in the context of ffmpeg "rawvideo" is just used for
> io-data streams, files and pipes, which are not packed in any mediating
> container format. In this case you just get a "raw" stream of bytes
> without any information about the used format.
>
> ISO/IEC 23001-17:2024 stands for the strict opposite: a way to precisely
> describe lots of possible variants of utilized image data pixel format
> and bit-packaging options.
>
> > I'm
> > just trying to follow the pattern and reuse what is already there. If
> there
> > is a better option, then please suggest one.
>
> Perhaps you should start by implementing the decoder side first.
> That's at least the strategy, that I've chosen in case of
> DNxUncompressed to reduce complexity and concentrate on those aspects,
> which are essential for exchange with existing end user software resp.
> already existing implementations of this file format.
>
> On the decoder side you also do not need any configuration options,
> because everything is already defined by the given input file, but it
> will nevertheless give you a vague orientation, what's really relevant
> for your own encoding design resp. some insight, which subset of the
> specification is actually used by others and required for compatibility
> and real world data exchange.
>
> > If ISO/IEC 23001-17:2024 requires its own .c file, then perhaps that
> > filename should use the term "uncompressed" instead of "raw". For
> example,
> > mpeg_unc_enc.c
>
> Yes -- although it's "uncompressed" and it's processing not much more
> than just trivial bit and byte juggling of unmodified pixel data, you
> will still have to implement specific codecs and package parsers for
> this particular file format to support the actual embedding within the
> surrounding containers.
>
> martin
>
> ___
> 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 3/4] avcodec/vvdec: refact, ff_vvc_deblock_bs use CodingUnit/TransformUnit instead of fc->tabs

2024-10-04 Thread Nuo Mi
perf result for:
"perf record -F 99 ./ffmpeg_g -i  Tango2_3840x2160_60_10_420_27_LD.266 -f null 
-"

before: 5.24%
1.87%  ffmpeg_g  [.] vvc_deblock_bs_chroma
1.72%  ffmpeg_g  [.] ff_vvc_deblock_bs
1.65%  ffmpeg_g  [.] vvc_deblock_bs_luma

after: 3.48%
1.84%  ffmpeg_g  [.] vvc_deblock_bs_chroma
1.64%  ffmpeg_g  [.] ff_vvc_deblock_bs + vvc_deblock_bs_luma(inlined)
---
 libavcodec/vvc/ctu.c|  2 +
 libavcodec/vvc/ctu.h|  3 ++
 libavcodec/vvc/filter.c | 90 +
 3 files changed, 42 insertions(+), 53 deletions(-)

diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
index 8210ab520f..e49976c66b 100644
--- a/libavcodec/vvc/ctu.c
+++ b/libavcodec/vvc/ctu.c
@@ -241,6 +241,7 @@ static TransformUnit* add_tu(VVCFrameContext *fc, 
CodingUnit *cu, const int x0,
 tu->height = tu_height;
 tu->joint_cbcr_residual_flag = 0;
 memset(tu->coded_flag, 0, sizeof(tu->coded_flag));
+tu->avail[LUMA] = tu->avail[CHROMA] = 0;
 tu->nb_tbs = 0;
 
 return tu;
@@ -267,6 +268,7 @@ static TransformBlock* add_tb(TransformUnit *tu, 
VVCLocalContext *lc,
 tb->ts = 0;
 tb->coeffs = lc->coeffs;
 lc->coeffs += tb_width * tb_height;
+tu->avail[!!c_idx] = true;
 return tb;
 }
 
diff --git a/libavcodec/vvc/ctu.h b/libavcodec/vvc/ctu.h
index eab4612561..c5533c1ad0 100644
--- a/libavcodec/vvc/ctu.h
+++ b/libavcodec/vvc/ctu.h
@@ -23,6 +23,8 @@
 #ifndef AVCODEC_VVC_CTU_H
 #define AVCODEC_VVC_CTU_H
 
+#include 
+
 #include "libavcodec/cabac.h"
 #include "libavutil/mem_internal.h"
 
@@ -172,6 +174,7 @@ typedef struct TransformUnit {
 int y0;
 int width;
 int height;
+bool avail[CHROMA + 1]; // contains 
luma/chroma block
 
 uint8_t joint_cbcr_residual_flag;   ///< 
tu_joint_cbcr_residual_flag
 
diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 9a45a735e0..a7f102bc64 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -451,15 +451,15 @@ static int boundary_strength(const VVCLocalContext *lc, 
const MvField *curr, con
 
 //part of 8.8.3.3 Derivation process of transform block boundary
 static void derive_max_filter_length_luma(const VVCFrameContext *fc, const int 
qx, const int qy,
-  const int is_intra, const int 
has_subblock, const int vertical, uint8_t *max_len_p, uint8_t *max_len_q)
+const int size_q, const int has_subblock, const int vertical, uint8_t 
*max_len_p, uint8_t *max_len_q)
 {
 const int px =  vertical ? qx - 1 : qx;
 const int py = !vertical ? qy - 1 : qy;
 const uint8_t *tb_size = vertical ? fc->tab.tb_width[LUMA] : 
fc->tab.tb_height[LUMA];
 const int size_p = tb_size[(py >> MIN_TU_LOG2) * fc->ps.pps->min_tu_width 
+ (px >> MIN_TU_LOG2)];
-const int size_q = tb_size[(qy >> MIN_TU_LOG2) * fc->ps.pps->min_tu_width 
+ (qx >> MIN_TU_LOG2)];
 const int min_cb_log2 = fc->ps.sps->min_cb_log2_size_y;
 const int off_p = (py >> min_cb_log2) * fc->ps.pps->min_cb_width + (px >> 
min_cb_log2);
+
 if (size_p <= 4 || size_q <= 4) {
 *max_len_p = *max_len_q = 1;
 } else {
@@ -525,7 +525,7 @@ static void vvc_deblock_subblock_bs(const VVCLocalContext 
*lc,
 }
 
 static av_always_inline int deblock_bs(const VVCLocalContext *lc,
-const int x_p, const int y_p, const int x_q, const int y_q,
+const int x_p, const int y_p, const int x_q, const int y_q, const 
CodingUnit *cu, const TransformUnit *tu,
 const RefPicList *rpl_p, const int c_idx, const int off_to_cb, const 
uint8_t has_sub_block)
 {
 const VVCFrameContext *fc  = lc->fc;
@@ -542,12 +542,10 @@ static av_always_inline int deblock_bs(const 
VVCLocalContext *lc,
 const MvField *mvf_q   = &tab_mvf[pu_q];
 const uint8_t chroma   = !!c_idx;
 const int tu_p = (y_p >> log2_min_tu_size) * min_tu_width  + 
(x_p >>  log2_min_tu_size);
-const int tu_q = (y_q >> log2_min_tu_size) * min_tu_width  + 
(x_q >>  log2_min_tu_size);
 const int cb_p = (y_p >> log2_min_cb_size) * min_cb_width  + 
(x_p >>  log2_min_cb_size);
-const int cb_q = (y_q >> log2_min_cb_size) * min_cb_width  + 
(x_q >>  log2_min_cb_size);
-const uint8_t pcmf = fc->tab.pcmf[chroma][cb_p] && 
fc->tab.pcmf[chroma][cb_q];
-const uint8_t intra= fc->tab.cpm[chroma][cb_p] == MODE_INTRA || 
fc->tab.cpm[chroma][cb_q] == MODE_INTRA;
-const uint8_t same_mode= fc->tab.cpm[chroma][cb_p] == 
fc->tab.cpm[chroma][cb_q];
+const uint8_t pcmf = fc->tab.pcmf[chroma][cb_p] && 
cu->bdpcm_flag[chroma];
+const uint8_t intra= fc->tab.cpm[chroma][cb_p] == MODE_INTRA || 
cu->pred_mode == MODE_INTRA;
+const uint8_t same_mode= fc->tab.cpm[chroma][cb_p] == cu->pred_mode;
 
 if (pcmf)
 return 0;
@@ -557,12 +555,12 @@ static av_always_inline int deblock_bs(const 
VVCLocalContext *lc,
 
 if (chroma) {
 return fc->tab.tu_cod

Re: [FFmpeg-devel] [PATCH] av1dec: Don't crash if decoding of some frames have failed

2024-10-04 Thread Martin Storsjö

On Wed, 2 Oct 2024, Martin Storsjö wrote:


If decoding with hwaccel, but decoding fails, these pointers
are null at this point.
---
libavcodec/av1dec.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 6a9de07d16..bc4ef63e68 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -281,6 +281,8 @@ static void skip_mode_params(AV1DecContext *s)
forward_idx  = -1;
backward_idx = -1;
for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+if (!s->ref[header->ref_frame_idx[i]].raw_frame_header)
+return;
ref_hint = 
s->ref[header->ref_frame_idx[i]].raw_frame_header->order_hint;
dist = get_relative_dist(seq, ref_hint, header->order_hint);
if (dist < 0) {
--
2.39.5 (Apple Git-154)


OK'd by James on irc, will push later.

// Martin
___
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/2] doc/ffmpeg.texi: add a diagram for the loopback decoder example

2024-10-04 Thread Anton Khirnov
---
 doc/ffmpeg.texi | 32 
 1 file changed, 32 insertions(+)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index e17c17bcd7..1ccc48bbad 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -526,6 +526,38 @@ reads an input video and
 
 @end itemize
 
+Such a transcoding pipeline can be represented with the following diagram:
+@verbatim
+┌──┬───┐
+│ demuxer  │   │   ┌─┐┌─┐
┌┐
+╞══╡ video stream  │   │  video  ││  video  ││ null 
muxer │
+│   INPUT  │   ├──⮞│ decoder ├──┬⮞│ encoder 
├─┬─⮞│(discards its input)│
+│  │   │   └─┘  │ │(libx264)│ │  
└┘
+└──┴───┘│ └─┘ │
+ ╭───⮜──╯   ┌─┐   │
+ │  │loopback │   │
+ │ ╭─⮜──┤ decoder ├⮜──╯
+ │ │└─┘
+ │ │
+ │ │
+ │ │  ┌───┐
+ │ │  │complex filtergraph│
+ │ │  ╞═══╡
+ │ │  │  ┌─┐  │
+ ╰─╫─⮞├─⮞│   hstack├─⮞├╮
+   ╰─⮞├─⮞│ │  ││
+  │  └─┘  ││
+  └───┘│
+   │
+┌──┬───┐  ┌─┐  │
+│ muxer│   │  │  video  │  │
+╞══╡ video stream  │⮜─┤ encoder ├───⮜──╯
+│  OUTPUT  │   │  │ (ffv1)  │
+│  │   │  └─┘
+└──┴───┘
+@end verbatim
+
+
 @c man end DETAILED DESCRIPTION
 
 @anchor{Stream selection}
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 1/2] doc/ffmpeg: rewrite the detailed description chapter

2024-10-04 Thread Anton Khirnov
Split it into sections that describe in detail
* the components of the transcoding pipeline
* the main features it handles, in order of complexity
* streamcopy
* transcoding
* filtering

Replace the current confusing/misleading diagrams with new ones that
actually reflect the program components and data flow between them.
---
 doc/ffmpeg.texi | 491 +---
 1 file changed, 378 insertions(+), 113 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index de140067ae..e17c17bcd7 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -87,140 +87,405 @@ The format option may be needed for raw input files.
 @chapter Detailed description
 @c man begin DETAILED DESCRIPTION
 
-The transcoding process in @command{ffmpeg} for each output can be described by
-the following diagram:
+@command{ffmpeg} builds a transcoding pipeline out of the components listed
+below. The program's operation then consists of input data chunks flowing from
+the sources down the pipes towards the sinks, while being transformed by the
+components they encounter along the way.
 
+The following kinds of components are available:
+@itemize
+@item
+@emph{Demuxers} (short for "demultiplexers") read an input source in order to
+extract
+
+@itemize
+@item
+global properties such as metadata or chapters;
+@item
+list of input elementary streams and their properties
+@end itemize
+
+One demuxer instance is created for each @option{-i} option, and sends encoded
+@emph{packets} to @emph{decoders} or @emph{muxers}.
+
+In other literature, demuxers are sometimes called @emph{splitters}, because
+their main function is splitting a file into elementary streams (though some
+files only contain one elementary stream).
+
+A schematic representation of a demuxer looks like this:
 @verbatim
- ___  __
-|   ||  |
-| input |  demuxer   | encoded data |   decoder
-| file  | -> | packets  | -+
-|___||__|  |
-   v
-   _
-  | |
-  | decoded |
-  | frames  |
-  |_|
-  __   |
-||   |  |  |
-| output | < | encoded data | <+
-| file   |   muxer   | packets  |   encoder
-||   |__|
-
-
+┌──┬───┐
+│ demuxer  │   │ packets for stream 0
+╞══╡ elementary stream 0   ├──⮞
+│  │   │
+│  global  ├───┤
+│properties│   │ packets for stream 1
+│   and│ elementary stream 1   ├──⮞
+│ metadata │   │
+│  ├───┤
+│  │   │
+│  │ ...   │
+│  │   │
+│  ├───┤
+│  │   │ packets for stream N
+│  │ elementary stream N   ├──⮞
+│  │   │
+└──┴───┘
+ ⯅
+ │
+ │ read from file, network stream,
+ │ grabbing device, etc.
+ │
 @end verbatim
 
-@command{ffmpeg} calls the libavformat library (containing demuxers) to read
-input files and get packets containing encoded data from them. When there are
-multiple input files, @command{ffmpeg} tries to keep them synchronized by
-tracking lowest timestamp on any active input stream.
+@item
+@emph{Decoders} receive encoded (compressed) @emph{packets} for an audio, 
video,
+or subtitle elementary stream, and decode them into raw @emph{frames} (arrays 
of
+pixels for video, PCM for audio). A decoder is typically associated with (and
+receives its input from) an elementary stream in a @emph{demuxer}, but 
sometimes
+may also exist on its own (see @ref{Loopback decoders}).
+
+A schematic representation of a decoder looks like this:
+@verbatim
+  ┌─┐
+ packets  │ │ raw frames
+─⮞│ decoder ├⮞
+  │ │
+  └─┘
+@end verbatim
+
+@item
+@emph{Filtergraphs} process and transform raw audio or video @emph{frames}. A
+filtergraph consists of one or more individual @emph{filters} linked into a
+graph. Filtergraphs come in two flavors - @emph{simple} and @emph{complex},
+configured with the @option{-filter} and @option{-filter_complex} options,
+respectively.
+
+A simple filtergraph is associated with an @emph{output elementary stream}; it
+receives the input to be filtered from a @emph{decoder} and sends filtered
+output to that output stream's @emph{encoder}.
+
+A simple video filtergraph that performs deinterlacing (using the @code{yadif}
+dein

Re: [FFmpeg-devel] RFC - Uncompressed MP4

2024-10-04 Thread martin schitter




On 04.10.24 15:11, Devon Sookhoo wrote:

You're correct that I'm primarily interested in uncompressed data and not
raw bayer sensor data. 


Yes -- it was more a rather extreme example to remind, that this file 
format isn't as simple and limited as many old and simple AV packaging 
solutions for uncompressed pixel data. This opens interesting new 
applications, but it also comes with lots of complex management and 
configuration demands.



However, it seems like the  "-c:v rawvideo"  option
is the convention in other formats to generate uncompressed video data. 


No -- I think, in the context of ffmpeg "rawvideo" is just used for 
io-data streams, files and pipes, which are not packed in any mediating 
container format. In this case you just get a "raw" stream of bytes 
without any information about the used format.


ISO/IEC 23001-17:2024 stands for the strict opposite: a way to precisely 
describe lots of possible variants of utilized image data pixel format 
and bit-packaging options.



I'm
just trying to follow the pattern and reuse what is already there. If there
is a better option, then please suggest one.


Perhaps you should start by implementing the decoder side first.
That's at least the strategy, that I've chosen in case of 
DNxUncompressed to reduce complexity and concentrate on those aspects, 
which are essential for exchange with existing end user software resp. 
already existing implementations of this file format.


On the decoder side you also do not need any configuration options, 
because everything is already defined by the given input file, but it 
will nevertheless give you a vague orientation, what's really relevant 
for your own encoding design resp. some insight, which subset of the 
specification is actually used by others and required for compatibility 
and real world data exchange.



If ISO/IEC 23001-17:2024 requires its own .c file, then perhaps that
filename should use the term "uncompressed" instead of "raw". For example,
mpeg_unc_enc.c


Yes -- although it's "uncompressed" and it's processing not much more 
than just trivial bit and byte juggling of unmodified pixel data, you 
will still have to implement specific codecs and package parsers for 
this particular file format to support the actual embedding within the 
surrounding containers.


martin

___
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 02/20] lavfi/vf_boxblur: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_boxblur.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c
index 27cf57a7c1..d684dee99d 100644
--- a/libavfilter/vf_boxblur.c
+++ b/libavfilter/vf_boxblur.c
@@ -55,7 +55,9 @@ static av_cold void uninit(AVFilterContext *ctx)
 av_freep(&s->temp[1]);
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 AVFilterFormats *formats = NULL;
 int fmt, ret;
@@ -69,7 +71,7 @@ static int query_formats(AVFilterContext *ctx)
 return ret;
 }
 
-return ff_set_common_formats(ctx, formats);
+return ff_set_common_formats2(ctx, cfg_in, cfg_out, formats);
 }
 
 static int config_input(AVFilterLink *inlink)
@@ -303,6 +305,6 @@ const AVFilter ff_vf_boxblur = {
 .uninit= uninit,
 FILTER_INPUTS(avfilter_vf_boxblur_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 01/20] lavfi/vf_alphamerge: switch to query_func2()

2024-10-04 Thread Anton Khirnov
Simplify the implementation by using the fact that ff_set_common_*()
will ignore those links on which the formats have already been set.
---
 libavfilter/vf_alphamerge.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_alphamerge.c b/libavfilter/vf_alphamerge.c
index 2abb7e5583..c732f29367 100644
--- a/libavfilter/vf_alphamerge.c
+++ b/libavfilter/vf_alphamerge.c
@@ -96,7 +96,9 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 static const enum AVPixelFormat main_fmts[] = {
 AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P,
@@ -105,15 +107,18 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_NONE
 };
 static const enum AVPixelFormat alpha_fmts[] = { AV_PIX_FMT_GRAY8, 
AV_PIX_FMT_NONE };
-AVFilterFormats *main_formats = ff_make_format_list(main_fmts);
 int ret;
 
-if ((ret = ff_formats_ref(main_formats, &ctx->inputs[0]->outcfg.formats)) 
< 0 ||
-(ret = ff_formats_ref(main_formats, &ctx->outputs[0]->incfg.formats)) 
< 0)
-return ret;
+ret = ff_formats_ref(ff_make_format_list(alpha_fmts),
+ &cfg_in[1]->formats);
+if (ret < 0)
+return ret;
 
-return ff_formats_ref(ff_make_format_list(alpha_fmts),
-  &ctx->inputs[1]->outcfg.formats);
+ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, main_fmts);
+if (ret < 0)
+return ret;
+
+return 0;
 }
 
 static int config_input_main(AVFilterLink *inlink)
@@ -203,7 +208,7 @@ const AVFilter ff_vf_alphamerge = {
 .init   = init,
 FILTER_INPUTS(alphamerge_inputs),
 FILTER_OUTPUTS(alphamerge_outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .uninit = uninit,
 .activate   = activate,
 .flags  = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 13/20] lavfi/vf_fade: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_fade.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index fb04c7ce32..39f16b0b3a 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -101,7 +101,9 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 const FadeContext *s = ctx->priv;
 static const enum AVPixelFormat pix_fmts[] = {
@@ -162,7 +164,7 @@ static int query_formats(AVFilterContext *ctx)
 else
 pixel_fmts = pix_fmts_rgb;
 }
-return ff_set_common_formats_from_list(ctx, pixel_fmts);
+return ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, pixel_fmts);
 }
 
 const static enum AVPixelFormat studio_level_pix_fmts[] = {
@@ -566,7 +568,7 @@ const AVFilter ff_vf_fade = {
 .priv_class= &fade_class,
 FILTER_INPUTS(avfilter_vf_fade_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags = AVFILTER_FLAG_SLICE_THREADS |
  AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 10/20] lavfi/vf_drawtext: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_drawtext.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 4c55a01155..2b0a21a4b4 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1077,9 +1077,12 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+return ff_set_common_formats2(ctx, cfg_in, cfg_out,
+  ff_draw_supported_pixel_formats(0));
 }
 
 static int glyph_enu_border_free(void *opaque, void *elem)
@@ -1915,7 +1918,7 @@ const AVFilter ff_vf_drawtext = {
 .uninit= uninit,
 FILTER_INPUTS(avfilter_vf_drawtext_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .process_command = command,
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 16/20] lavfi/vf_fieldmatch: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_fieldmatch.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_fieldmatch.c b/libavfilter/vf_fieldmatch.c
index 9198c894f9..c3ff909b1b 100644
--- a/libavfilter/vf_fieldmatch.c
+++ b/libavfilter/vf_fieldmatch.c
@@ -908,9 +908,11 @@ static int activate(AVFilterContext *ctx)
 }
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-FieldMatchContext *fm = ctx->priv;
+const FieldMatchContext *fm = ctx->priv;
 
 static const enum AVPixelFormat pix_fmts[] = {
 AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV420P,
@@ -939,17 +941,17 @@ static int query_formats(AVFilterContext *ctx)
 if (!fmts_list)
 return AVERROR(ENOMEM);
 if (!fm->ppsrc) {
-return ff_set_common_formats(ctx, fmts_list);
+return ff_set_common_formats2(ctx, cfg_in, cfg_out, fmts_list);
 }
 
-if ((ret = ff_formats_ref(fmts_list, 
&ctx->inputs[INPUT_MAIN]->outcfg.formats)) < 0)
+if ((ret = ff_formats_ref(fmts_list, &cfg_in[INPUT_MAIN]->formats)) < 0)
 return ret;
 fmts_list = ff_make_format_list(unproc_pix_fmts);
 if (!fmts_list)
 return AVERROR(ENOMEM);
-if ((ret = ff_formats_ref(fmts_list, &ctx->outputs[0]->incfg.formats)) < 0)
+if ((ret = ff_formats_ref(fmts_list, &cfg_out[0]->formats)) < 0)
 return ret;
-if ((ret = ff_formats_ref(fmts_list, 
&ctx->inputs[INPUT_CLEANSRC]->outcfg.formats)) < 0)
+if ((ret = ff_formats_ref(fmts_list, &cfg_in[INPUT_CLEANSRC]->formats)) < 
0)
 return ret;
 return 0;
 }
@@ -1080,7 +1082,7 @@ const AVFilter ff_vf_fieldmatch = {
 .uninit = fieldmatch_uninit,
 .inputs = NULL,
 FILTER_OUTPUTS(fieldmatch_outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .priv_class = &fieldmatch_class,
 .flags  = AVFILTER_FLAG_DYNAMIC_INPUTS,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 04/20] lavfi/vf_colorspace: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_colorspace.c | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 344dcd5f9e..62055aa1bf 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -830,7 +830,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 return ff_filter_frame(outlink, out);
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 static const enum AVPixelFormat pix_fmts[] = {
 AV_PIX_FMT_YUV420P,   AV_PIX_FMT_YUV422P,   AV_PIX_FMT_YUV444P,
@@ -840,32 +842,34 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_NONE
 };
 int res;
-ColorSpaceContext *s = ctx->priv;
-AVFilterLink *outlink = ctx->outputs[0];
-AVFilterFormats *formats = ff_make_format_list(pix_fmts);
+const ColorSpaceContext *s = ctx->priv;
+AVFilterFormats *formats;
 
-res = ff_formats_ref(ff_make_formats_list_singleton(s->out_csp), 
&outlink->incfg.color_spaces);
+res = ff_formats_ref(ff_make_formats_list_singleton(s->out_csp), 
&cfg_out[0]->color_spaces);
 if (res < 0)
 return res;
 if (s->user_rng != AVCOL_RANGE_UNSPECIFIED) {
-res = ff_formats_ref(ff_make_formats_list_singleton(s->user_rng), 
&outlink->incfg.color_ranges);
+res = ff_formats_ref(ff_make_formats_list_singleton(s->user_rng), 
&cfg_out[0]->color_ranges);
 if (res < 0)
 return res;
 }
 
+formats = ff_make_format_list(pix_fmts);
 if (!formats)
 return AVERROR(ENOMEM);
 if (s->user_format == AV_PIX_FMT_NONE)
-return ff_set_common_formats(ctx, formats);
-res = ff_formats_ref(formats, &ctx->inputs[0]->outcfg.formats);
+return ff_set_common_formats2(ctx, cfg_in, cfg_out, formats);
+
+res = ff_formats_ref(formats, &cfg_in[0]->formats);
 if (res < 0)
 return res;
+
 formats = NULL;
 res = ff_add_format(&formats, s->user_format);
 if (res < 0)
 return res;
 
-return ff_formats_ref(formats, &outlink->incfg.formats);
+return ff_formats_ref(formats, &cfg_out[0]->formats);
 }
 
 static int config_props(AVFilterLink *outlink)
@@ -1035,6 +1039,6 @@ const AVFilter ff_vf_colorspace = {
 .priv_class  = &colorspace_class,
 FILTER_INPUTS(inputs),
 FILTER_OUTPUTS(outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags   = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | 
AVFILTER_FLAG_SLICE_THREADS,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 06/20] lavfi/vf_crop: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_crop.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
index 4742732b63..f3cbc83b8b 100644
--- a/libavfilter/vf_crop.c
+++ b/libavfilter/vf_crop.c
@@ -95,11 +95,14 @@ typedef struct CropContext {
 double var_values[VAR_VARS_NB];
 } CropContext;
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 int reject_flags = AV_PIX_FMT_FLAG_BITSTREAM | FF_PIX_FMT_FLAG_SW_FLAT_SUB;
 
-return ff_set_common_formats(ctx, ff_formats_pixdesc_filter(0, 
reject_flags));
+return ff_set_common_formats2(ctx, cfg_in, cfg_out,
+  ff_formats_pixdesc_filter(0, reject_flags));
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
@@ -405,6 +408,6 @@ const AVFilter ff_vf_crop = {
 .uninit  = uninit,
 FILTER_INPUTS(avfilter_vf_crop_inputs),
 FILTER_OUTPUTS(avfilter_vf_crop_outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .process_command = process_command,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 03/20] lavfi/vf_ciescope: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_ciescope.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_ciescope.c b/libavfilter/vf_ciescope.c
index 260ca26187..8ca47aaafd 100644
--- a/libavfilter/vf_ciescope.c
+++ b/libavfilter/vf_ciescope.c
@@ -139,14 +139,16 @@ static const enum AVPixelFormat out_pix_fmts[] = {
 AV_PIX_FMT_NONE
 };
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 int ret;
 
-if ((ret = ff_formats_ref(ff_make_format_list(in_pix_fmts), 
&ctx->inputs[0]->outcfg.formats)) < 0)
+if ((ret = ff_formats_ref(ff_make_format_list(in_pix_fmts), 
&cfg_in[0]->formats)) < 0)
 return ret;
 
-if ((ret = ff_formats_ref(ff_make_format_list(out_pix_fmts), 
&ctx->outputs[0]->incfg.formats)) < 0)
+if ((ret = ff_formats_ref(ff_make_format_list(out_pix_fmts), 
&cfg_out[0]->formats)) < 0)
 return ret;
 
 return 0;
@@ -1559,5 +1561,5 @@ const AVFilter ff_vf_ciescope = {
 .uninit= uninit,
 FILTER_INPUTS(inputs),
 FILTER_OUTPUTS(outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 11/20] lavfi/vf_edgedetect: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_edgedetect.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_edgedetect.c b/libavfilter/vf_edgedetect.c
index 32339a0d8b..1077095fd3 100644
--- a/libavfilter/vf_edgedetect.c
+++ b/libavfilter/vf_edgedetect.c
@@ -97,7 +97,9 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 const EdgeDetectContext *edgedetect = ctx->priv;
 static const enum AVPixelFormat wires_pix_fmts[] = {AV_PIX_FMT_GRAY8, 
AV_PIX_FMT_NONE};
@@ -114,7 +116,7 @@ static int query_formats(AVFilterContext *ctx)
 } else {
 av_assert0(0);
 }
-return ff_set_common_formats_from_list(ctx, pix_fmts);
+return ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, pix_fmts);
 }
 
 static int config_props(AVFilterLink *inlink)
@@ -258,7 +260,7 @@ const AVFilter ff_vf_edgedetect = {
 .uninit= uninit,
 FILTER_INPUTS(edgedetect_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .priv_class= &edgedetect_class,
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 18/20] lavfi/vf_format: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_format.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c
index da39625fec..9dbb174c42 100644
--- a/libavfilter/vf_format.c
+++ b/libavfilter/vf_format.c
@@ -149,14 +149,16 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 FormatContext *s = ctx->priv;
 int ret;
 
-if (s->formats  && (ret = ff_set_common_formats(ctx,  s->formats)) 
< 0 ||
-s->color_spaces && (ret = ff_set_common_color_spaces(ctx, 
s->color_spaces)) < 0 ||
-s->color_ranges && (ret = ff_set_common_color_ranges(ctx, 
s->color_ranges)) < 0)
+if (s->formats  && (ret = ff_set_common_formats2 (ctx, cfg_in, 
cfg_out, s->formats)) < 0 ||
+s->color_spaces && (ret = ff_set_common_color_spaces2(ctx, cfg_in, 
cfg_out, s->color_spaces)) < 0 ||
+s->color_ranges && (ret = ff_set_common_color_ranges2(ctx, cfg_in, 
cfg_out, s->color_ranges)) < 0)
 return ret;
 
 return 0;
@@ -197,7 +199,7 @@ const AVFilter ff_vf_format = {
 FILTER_INPUTS(inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
 
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 };
 #endif /* CONFIG_FORMAT_FILTER */
 
@@ -217,6 +219,6 @@ const AVFilter ff_vf_noformat = {
 FILTER_INPUTS(inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
 
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 };
 #endif /* CONFIG_NOFORMAT_FILTER */
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 07/20] lavfi/vf_datascope: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_datascope.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_datascope.c b/libavfilter/vf_datascope.c
index 7b4cb52ee8..a4f6c69bfd 100644
--- a/libavfilter/vf_datascope.c
+++ b/libavfilter/vf_datascope.c
@@ -77,9 +77,12 @@ static const AVOption datascope_options[] = {
 
 AVFILTER_DEFINE_CLASS(datascope);
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+return ff_set_common_formats2(ctx, cfg_in, cfg_out,
+  ff_draw_supported_pixel_formats(0));
 }
 
 static void draw_text(FFDrawContext *draw, AVFrame *frame, FFDrawColor *color,
@@ -455,7 +458,7 @@ const AVFilter ff_vf_datascope = {
 .priv_class= &datascope_class,
 FILTER_INPUTS(inputs),
 FILTER_OUTPUTS(outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags = AVFILTER_FLAG_SLICE_THREADS,
 .process_command = process_command,
 };
@@ -735,7 +738,7 @@ const AVFilter ff_vf_pixscope = {
 .priv_class= &pixscope_class,
 FILTER_INPUTS(pixscope_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 .process_command = pixscope_process_command,
 };
@@ -1134,7 +1137,7 @@ const AVFilter ff_vf_oscilloscope = {
 .uninit= oscilloscope_uninit,
 FILTER_INPUTS(oscilloscope_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 .process_command = oscilloscope_process_command,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 20/20] lavfi/vf_geq: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_geq.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_geq.c b/libavfilter/vf_geq.c
index bb95f45e2e..3f5f3796ba 100644
--- a/libavfilter/vf_geq.c
+++ b/libavfilter/vf_geq.c
@@ -336,9 +336,11 @@ end:
 return ret;
 }
 
-static int geq_query_formats(AVFilterContext *ctx)
+static int geq_query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-GEQContext *geq = ctx->priv;
+const GEQContext *geq = ctx->priv;
 static const enum AVPixelFormat yuv_pix_fmts[] = {
 AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV420P,
 AV_PIX_FMT_YUV411P,  AV_PIX_FMT_YUV410P,  AV_PIX_FMT_YUV440P,
@@ -371,7 +373,7 @@ static int geq_query_formats(AVFilterContext *ctx)
 };
 const enum AVPixelFormat *pix_fmts = geq->is_rgb ? rgb_pix_fmts : 
yuv_pix_fmts;
 
-return ff_set_common_formats_from_list(ctx, pix_fmts);
+return ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, pix_fmts);
 }
 
 static int geq_config_props(AVFilterLink *inlink)
@@ -532,7 +534,7 @@ const AVFilter ff_vf_geq = {
 .uninit= geq_uninit,
 FILTER_INPUTS(geq_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(geq_query_formats),
+FILTER_QUERY_FUNC2(geq_query_formats),
 .priv_class= &geq_class,
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | 
AVFILTER_FLAG_SLICE_THREADS,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 12/20] lavfi/vf_elbg: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_elbg.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_elbg.c b/libavfilter/vf_elbg.c
index 453147ca33..5eb5ffed2f 100644
--- a/libavfilter/vf_elbg.c
+++ b/libavfilter/vf_elbg.c
@@ -85,9 +85,11 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-ELBGFilterContext *const elbg = ctx->priv;
+const ELBGFilterContext *const elbg = ctx->priv;
 int ret;
 
 static const enum AVPixelFormat pix_fmts[] = {
@@ -96,14 +98,14 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_NONE
 };
 if (!elbg->pal8) {
-return ff_set_common_formats_from_list(ctx, pix_fmts);
+return ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, 
pix_fmts);
 } else {
 static const enum AVPixelFormat pal8_fmt[] = {
 AV_PIX_FMT_PAL8,
 AV_PIX_FMT_NONE
 };
-if ((ret = ff_formats_ref(ff_make_format_list(pix_fmts), 
&ctx->inputs[0]->outcfg.formats)) < 0 ||
-(ret = ff_formats_ref(ff_make_format_list(pal8_fmt), 
&ctx->outputs[0]->incfg.formats)) < 0)
+if ((ret = ff_formats_ref(ff_make_format_list(pix_fmts), 
&cfg_in[0]->formats)) < 0 ||
+(ret = ff_formats_ref(ff_make_format_list(pal8_fmt), 
&cfg_out[0]->formats)) < 0)
 return ret;
 }
 return 0;
@@ -264,5 +266,5 @@ const AVFilter ff_vf_elbg = {
 .uninit= uninit,
 FILTER_INPUTS(elbg_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 17/20] lavfi/vf_fieldorder: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_fieldorder.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index 46b7f4bb30..5b0c723e8d 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -38,7 +38,9 @@ typedef struct FieldOrderContext {
 int  line_size[4]; ///< bytes of pixel data per line for each plane
 } FieldOrderContext;
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 const AVPixFmtDescriptor *desc = NULL;
 AVFilterFormats  *formats;
@@ -56,7 +58,7 @@ static int query_formats(AVFilterContext *ctx)
 (ret = ff_add_format(&formats, pix_fmt)) < 0)
 return ret;
 }
-return ff_set_common_formats(ctx, formats);
+return ff_set_common_formats2(ctx, cfg_in, cfg_out, formats);
 }
 
 static int config_input(AVFilterLink *inlink)
@@ -183,6 +185,6 @@ const AVFilter ff_vf_fieldorder = {
 .priv_class= &fieldorder_class,
 FILTER_INPUTS(avfilter_vf_fieldorder_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 14/20] lavfi/vf_feedback: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_feedback.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_feedback.c b/libavfilter/vf_feedback.c
index ddc53cad27..0b701ed9ea 100644
--- a/libavfilter/vf_feedback.c
+++ b/libavfilter/vf_feedback.c
@@ -106,11 +106,14 @@ static int config_output(AVFilterLink *outlink)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-return ff_set_common_formats(ctx, ff_formats_pixdesc_filter(0, 
AV_PIX_FMT_FLAG_BITSTREAM |
-   
AV_PIX_FMT_FLAG_HWACCEL |
-   
AV_PIX_FMT_FLAG_PAL));
+return ff_set_common_formats2(ctx, cfg_in, cfg_out,
+  ff_formats_pixdesc_filter(0, 
AV_PIX_FMT_FLAG_BITSTREAM |
+   
AV_PIX_FMT_FLAG_HWACCEL |
+   
AV_PIX_FMT_FLAG_PAL));
 }
 
 static int activate(AVFilterContext *ctx)
@@ -332,7 +335,7 @@ const AVFilter ff_vf_feedback = {
 .uninit  = uninit,
 FILTER_INPUTS(inputs),
 FILTER_OUTPUTS(outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags   = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
 .process_command = ff_filter_process_command,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 05/20] lavfi/vf_copy: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_copy.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_copy.c b/libavfilter/vf_copy.c
index 8158414dcf..87cb9e9bd2 100644
--- a/libavfilter/vf_copy.c
+++ b/libavfilter/vf_copy.c
@@ -28,9 +28,12 @@
 #include "formats.h"
 #include "video.h"
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-return ff_set_common_formats(ctx, ff_formats_pixdesc_filter(0, 
AV_PIX_FMT_FLAG_HWACCEL));
+return ff_set_common_formats2(ctx, cfg_in, cfg_out,
+  ff_formats_pixdesc_filter(0, 
AV_PIX_FMT_FLAG_HWACCEL));
 }
 
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
@@ -72,5 +75,5 @@ const AVFilter ff_vf_copy = {
 .flags   = AVFILTER_FLAG_METADATA_ONLY,
 FILTER_INPUTS(avfilter_vf_copy_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 08/20] lavfi/vf_deband: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_deband.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_deband.c b/libavfilter/vf_deband.c
index 31b864b760..4ba22c85a0 100644
--- a/libavfilter/vf_deband.c
+++ b/libavfilter/vf_deband.c
@@ -71,9 +71,11 @@ static const AVOption deband_options[] = {
 
 AVFILTER_DEFINE_CLASS(deband);
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
-DebandContext *s = ctx->priv;
+const DebandContext *s = ctx->priv;
 
 static const enum AVPixelFormat pix_fmts[] = {
 AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10,
@@ -110,7 +112,8 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_NONE
 };
 
-return ff_set_common_formats_from_list(ctx, s->coupling ? cpix_fmts : 
pix_fmts);
+return ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out,
+s->coupling ? cpix_fmts : 
pix_fmts);
 }
 
 static float frand(int x, int y)
@@ -468,7 +471,7 @@ const AVFilter ff_vf_deband = {
 .uninit= uninit,
 FILTER_INPUTS(avfilter_vf_deband_inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | 
AVFILTER_FLAG_SLICE_THREADS,
 .process_command = process_command,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 09/20] lavfi/vf_detelecine: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_detelecine.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_detelecine.c b/libavfilter/vf_detelecine.c
index 8eae7107c2..cc69194a19 100644
--- a/libavfilter/vf_detelecine.c
+++ b/libavfilter/vf_detelecine.c
@@ -122,13 +122,16 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 int reject_flags = AV_PIX_FMT_FLAG_BITSTREAM |
AV_PIX_FMT_FLAG_PAL   |
AV_PIX_FMT_FLAG_HWACCEL;
 
-return ff_set_common_formats(ctx, ff_formats_pixdesc_filter(0, 
reject_flags));
+return ff_set_common_formats2(ctx, cfg_in, cfg_out,
+  ff_formats_pixdesc_filter(0, reject_flags));
 }
 
 static int config_input(AVFilterLink *inlink)
@@ -377,5 +380,5 @@ const AVFilter ff_vf_detelecine = {
 .uninit= uninit,
 FILTER_INPUTS(detelecine_inputs),
 FILTER_OUTPUTS(detelecine_outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 15/20] lavfi/vf_fieldhint: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_fieldhint.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_fieldhint.c b/libavfilter/vf_fieldhint.c
index 92e3c5c8b9..d1f05562c2 100644
--- a/libavfilter/vf_fieldhint.c
+++ b/libavfilter/vf_fieldhint.c
@@ -85,13 +85,16 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
 {
 int reject_flags = AV_PIX_FMT_FLAG_BITSTREAM |
AV_PIX_FMT_FLAG_HWACCEL   |
AV_PIX_FMT_FLAG_PAL;
 
-return ff_set_common_formats(ctx, ff_formats_pixdesc_filter(0, 
reject_flags));
+return ff_set_common_formats2(ctx, cfg_in, cfg_out,
+  ff_formats_pixdesc_filter(0, reject_flags));
 }
 
 static int config_input(AVFilterLink *inlink)
@@ -329,5 +332,5 @@ const AVFilter ff_vf_fieldhint = {
 .uninit= uninit,
 FILTER_INPUTS(inputs),
 FILTER_OUTPUTS(outputs),
-FILTER_QUERY_FUNC(query_formats),
+FILTER_QUERY_FUNC2(query_formats),
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 19/20] lavfi/vf_hwmap: switch to query_func2()

2024-10-04 Thread Anton Khirnov
---
 libavfilter/vf_hwmap.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c
index e999605eb1..f32a566b74 100644
--- a/libavfilter/vf_hwmap.c
+++ b/libavfilter/vf_hwmap.c
@@ -37,14 +37,16 @@ typedef struct HWMapContext {
 intreverse;
 } HWMapContext;
 
-static int hwmap_query_formats(AVFilterContext *avctx)
+static int hwmap_query_formats(const AVFilterContext *avctx,
+   AVFilterFormatsConfig **cfg_in,
+   AVFilterFormatsConfig **cfg_out)
 {
 int ret;
 
 if ((ret = ff_formats_ref(ff_all_formats(AVMEDIA_TYPE_VIDEO),
-  &avctx->inputs[0]->outcfg.formats)) < 0 ||
+  &cfg_in[0]->formats)) < 0 ||
 (ret = ff_formats_ref(ff_all_formats(AVMEDIA_TYPE_VIDEO),
-  &avctx->outputs[0]->incfg.formats)) < 0)
+  &cfg_out[0]->formats)) < 0)
 return ret;
 
 return 0;
@@ -428,7 +430,7 @@ const AVFilter ff_vf_hwmap = {
 .priv_class = &hwmap_class,
 FILTER_INPUTS(hwmap_inputs),
 FILTER_OUTPUTS(hwmap_outputs),
-FILTER_QUERY_FUNC(hwmap_query_formats),
+FILTER_QUERY_FUNC2(hwmap_query_formats),
 .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
 .flags  = AVFILTER_FLAG_HWDEVICE,
 };
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 1/1] avfilter/framesync: fix forward EOF pts

2024-10-04 Thread Nicolas Gaullier
Note1: when the EOF pts is not accurate enough, the last frame
can be dropped by vf_fps with default rounding.

Note2: vf_scale use framesync since e82a3997cdd6c0894869b33ba42430ac3,
so this is a very commonplace scenario.

For example:
./ffprobe -f lavfi testsrc=d=1,scale,fps -of flat \
  -count_frames -show_entries stream=nb_read_frames

Before:
streams.stream.0.nb_read_frames="24"

After:
streams.stream.0.nb_read_frames="25"
---
 libavfilter/framesync.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c
index 8e06e0e700..0d5779f830 100644
--- a/libavfilter/framesync.c
+++ b/libavfilter/framesync.c
@@ -103,14 +103,14 @@ int ff_framesync_init(FFFrameSync *fs, AVFilterContext 
*parent, unsigned nb_in)
 return 0;
 }
 
-static void framesync_eof(FFFrameSync *fs)
+static void framesync_eof(FFFrameSync *fs, int64_t pts)
 {
 fs->eof = 1;
 fs->frame_ready = 0;
-ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE);
+ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, pts);
 }
 
-static void framesync_sync_level_update(FFFrameSync *fs)
+static void framesync_sync_level_update(FFFrameSync *fs, int64_t eof_pts)
 {
 unsigned i, level = 0;
 
@@ -131,7 +131,7 @@ static void framesync_sync_level_update(FFFrameSync *fs)
 if (level)
 fs->sync_level = level;
 else
-framesync_eof(fs);
+framesync_eof(fs, eof_pts);
 }
 
 int ff_framesync_configure(FFFrameSync *fs)
@@ -179,7 +179,7 @@ int ff_framesync_configure(FFFrameSync *fs)
 for (i = 0; i < fs->nb_in; i++)
 fs->in[i].pts = fs->in[i].pts_next = AV_NOPTS_VALUE;
 fs->sync_level = UINT_MAX;
-framesync_sync_level_update(fs);
+framesync_sync_level_update(fs, AV_NOPTS_VALUE);
 
 return 0;
 }
@@ -200,7 +200,7 @@ static int framesync_advance(FFFrameSync *fs)
 if (fs->in[i].have_next && fs->in[i].pts_next < pts)
 pts = fs->in[i].pts_next;
 if (pts == INT64_MAX) {
-framesync_eof(fs);
+framesync_eof(fs, AV_NOPTS_VALUE);
 break;
 }
 for (i = 0; i < fs->nb_in; i++) {
@@ -222,7 +222,7 @@ static int framesync_advance(FFFrameSync *fs)
 fs->frame_ready = 1;
 if (fs->in[i].state == STATE_EOF &&
 fs->in[i].after == EXT_STOP)
-framesync_eof(fs);
+framesync_eof(fs, AV_NOPTS_VALUE);
 }
 }
 if (fs->frame_ready)
@@ -255,15 +255,14 @@ static void framesync_inject_frame(FFFrameSync *fs, 
unsigned in, AVFrame *frame)
 fs->in[in].have_next  = 1;
 }
 
-static void framesync_inject_status(FFFrameSync *fs, unsigned in, int status, 
int64_t pts)
+static void framesync_inject_status(FFFrameSync *fs, unsigned in, int status, 
int64_t eof_pts)
 {
 av_assert0(!fs->in[in].have_next);
-pts = fs->in[in].state != STATE_RUN || fs->in[in].after == EXT_INFINITY
-? INT64_MAX : framesync_pts_extrapolate(fs, in, fs->in[in].pts);
 fs->in[in].sync = 0;
-framesync_sync_level_update(fs);
+framesync_sync_level_update(fs, status == AVERROR_EOF ? eof_pts : 
AV_NOPTS_VALUE);
 fs->in[in].frame_next = NULL;
-fs->in[in].pts_next   = pts;
+fs->in[in].pts_next   = fs->in[in].state != STATE_RUN || fs->in[in].after 
== EXT_INFINITY
+? INT64_MAX : framesync_pts_extrapolate(fs, in, 
fs->in[in].pts);
 fs->in[in].have_next  = 1;
 }
 
-- 
2.30.2

___
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 0/1] avfilter/framesync: fix forward EOF pts

2024-10-04 Thread Nicolas Gaullier
Pinging again...
post rebased to current master, issue still present and fixed with the patch.

Nicolas Gaullier (1):
  avfilter/framesync: fix forward EOF pts

 libavfilter/framesync.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

-- 
2.30.2

___
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 - Uncompressed MP4

2024-10-04 Thread Devon Sookhoo
You're correct that I'm primarily interested in uncompressed data and not
raw bayer sensor data. However, it seems like the  "-c:v rawvideo"  option
is the convention in other formats to generate uncompressed video data. I'm
just trying to follow the pattern and reuse what is already there. If there
is a better option, then please suggest one.

If ISO/IEC 23001-17:2024 requires its own .c file, then perhaps that
filename should use the term "uncompressed" instead of "raw". For example,
mpeg_unc_enc.c




On Fri, Oct 4, 2024 at 5:54 AM martin schitter  wrote:

>
>
> On 04.10.24 01:33, Devon Sookhoo wrote:
> > Once completed, I envision the following command to work:
> >
> > $ ffmpeg  -i input.mp4  -c:v rawvideo  output.mp4
>
> Why do you choose the term "raw" instead of uncompressed?
>
> Using this format for "raw" bayer CFA data is just one possible
> application of ISO/IEC 23001-17:2024. But it would need a rather
> uncommon setup in this case. Implementing all these necessary pixel
> format related configuration options, which are nearly indispensable for
> useful encoding, and supporting at least an acceptable subset of all the
> possible variants declared by this standard will be the real challenge
> of your project.
>
> martin
> ___
> 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] configure: Enable -Wno-implicit-const-int-float-conversion if available

2024-10-04 Thread Martin Storsjö

On Wed, 2 Oct 2024, Martin Storsjö wrote:


This silences a lot of compile warnings (around 160 instances at least), when
compiling with Clang.

These warnings look like this:

   libavformat/http.c:176:133: warning: implicit conversion from 'long long' to 
'double' changes value from 9223372036854775807 to 9223372036854775808 
[-Wimplicit-const-int-float-conversion]
 176 | { "end_offset", "try to limit the request to bytes preceding this 
offset", OFFSET(end_off), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, D },
 | ~
   ^
---
configure | 1 +
1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index dc1b9b2bea..2b0ba07771 100755
--- a/configure
+++ b/configure
@@ -7459,6 +7459,7 @@ check_disable_warning -Wno-pointer-sign
check_disable_warning -Wno-unused-const-variable
check_disable_warning -Wno-bool-operation
check_disable_warning -Wno-char-subscripts
+check_disable_warning -Wno-implicit-const-int-float-conversion

check_disable_warning_headers(){
warning_flag=-W${1#-Wno-}
--
2.39.5 (Apple Git-154)


I'll push this one soon as well, if there's no good ideas (with a 
volunteered implementation) to get around the actual issue that the 
compiler warns about.


// Martin
___
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_xpsnr: remove duplicated DSP infranstructure

2024-10-04 Thread James Almer
Fully reuse the existing one from vf_psnr, instead of halfways.

Signed-off-by: James Almer 
---
 libavfilter/Makefile|  4 +--
 libavfilter/psnr.c  | 64 +
 libavfilter/psnr.h  |  1 +
 libavfilter/vf_psnr.c   | 29 +--
 libavfilter/vf_xpsnr.c  | 28 ---
 libavfilter/x86/Makefile|  3 +-
 libavfilter/x86/vf_xpsnr_init.c | 43 --
 libavfilter/xpsnr.h |  5 +--
 8 files changed, 77 insertions(+), 100 deletions(-)
 create mode 100644 libavfilter/psnr.c
 delete mode 100644 libavfilter/x86/vf_xpsnr_init.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index a56c8e8b79..a3a63d326e 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -437,7 +437,7 @@ OBJS-$(CONFIG_PREWITT_OPENCL_FILTER) += 
vf_convolution_opencl.o opencl.o
 OBJS-$(CONFIG_PROCAMP_VAAPI_FILTER)  += vf_procamp_vaapi.o vaapi_vpp.o
 OBJS-$(CONFIG_PROGRAM_OPENCL_FILTER) += vf_program_opencl.o opencl.o 
framesync.o
 OBJS-$(CONFIG_PSEUDOCOLOR_FILTER)+= vf_pseudocolor.o
-OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o framesync.o
+OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o framesync.o psnr.o
 OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o
 OBJS-$(CONFIG_QP_FILTER) += vf_qp.o
 OBJS-$(CONFIG_QUIRC_FILTER)  += vf_quirc.o
@@ -566,7 +566,7 @@ OBJS-$(CONFIG_XFADE_FILTER)  += vf_xfade.o
 OBJS-$(CONFIG_XFADE_OPENCL_FILTER)   += vf_xfade_opencl.o opencl.o 
opencl/xfade.o
 OBJS-$(CONFIG_XFADE_VULKAN_FILTER)   += vf_xfade_vulkan.o vulkan.o 
vulkan_filter.o
 OBJS-$(CONFIG_XMEDIAN_FILTER)+= vf_xmedian.o framesync.o
-OBJS-$(CONFIG_XPSNR_FILTER)  += vf_xpsnr.o framesync.o
+OBJS-$(CONFIG_XPSNR_FILTER)  += vf_xpsnr.o framesync.o psnr.o
 OBJS-$(CONFIG_XSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o yadif_common.o
 OBJS-$(CONFIG_YADIF_CUDA_FILTER) += vf_yadif_cuda.o 
vf_yadif_cuda.ptx.o \
diff --git a/libavfilter/psnr.c b/libavfilter/psnr.c
new file mode 100644
index 00..a6b7f5969c
--- /dev/null
+++ b/libavfilter/psnr.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2015 Ronald S. Bultje 
+ *
+ * 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 "config.h"
+
+#include 
+#include 
+
+#include "psnr.h"
+
+static uint64_t sse_line_8bit(const uint8_t *main_line,  const uint8_t 
*ref_line, int outw)
+{
+int j;
+unsigned m2 = 0;
+
+for (j = 0; j < outw; j++) {
+unsigned error = main_line[j] - ref_line[j];
+
+m2 += error * error;
+}
+
+return m2;
+}
+
+static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t 
*_ref_line, int outw)
+{
+int j;
+uint64_t m2 = 0;
+const uint16_t *main_line = (const uint16_t *) _main_line;
+const uint16_t *ref_line = (const uint16_t *) _ref_line;
+
+for (j = 0; j < outw; j++) {
+unsigned error = main_line[j] - ref_line[j];
+
+m2 += error * error;
+}
+
+return m2;
+}
+
+void ff_psnr_init(PSNRDSPContext *dsp, int bpp)
+{
+dsp->sse_line = bpp > 8 ? sse_line_16bit : sse_line_8bit;
+#if ARCH_X86
+ff_psnr_init_x86(dsp, bpp);
+#endif
+}
diff --git a/libavfilter/psnr.h b/libavfilter/psnr.h
index bbc4541135..2664aa5255 100644
--- a/libavfilter/psnr.h
+++ b/libavfilter/psnr.h
@@ -28,6 +28,7 @@ typedef struct PSNRDSPContext {
 uint64_t (*sse_line)(const uint8_t *buf, const uint8_t *ref, int w);
 } PSNRDSPContext;
 
+void ff_psnr_init(PSNRDSPContext *dsp, int bpp);
 void ff_psnr_init_x86(PSNRDSPContext *dsp, int bpp);
 
 #endif /* AVFILTER_PSNR_H */
diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 4a5db5df23..1e8f24fc52 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -82,30 +82,6 @@ static inline double get_psnr(double mse, uint64_t 
nb_frames, int max)
 return 10.0 * log10(pow_2(max) / (mse / nb_frames));
 }
 
-static uint64_t sse_line_8bit(const uint8_t *main_line,  const uint8_t 
*ref_line, int outw)
-{
-int j;
-unsigned m2 = 0;
-
-for (j = 0; j < outw; j++)
-  

[FFmpeg-devel] [PATCH 2/4] avcodec/vvcdec: misc, move pcmf from min_tu_tl_init to min_cb_nz_tl_init

2024-10-04 Thread Nuo Mi
pcmf are cu level flags
---
 libavcodec/vvc/ctu.c| 8 +---
 libavcodec/vvc/dec.c| 4 +---
 libavcodec/vvc/filter.c | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
index b33ad576cf..8210ab520f 100644
--- a/libavcodec/vvc/ctu.c
+++ b/libavcodec/vvc/ctu.c
@@ -1240,16 +1240,18 @@ static void set_cu_tabs(const VVCLocalContext *lc, 
const CodingUnit *cu)
 
 set_cb_tab(lc, fc->tab.mmi, pu->mi.motion_model_idc);
 set_cb_tab(lc, fc->tab.msf, pu->merge_subblock_flag);
-if (cu->tree_type != DUAL_TREE_CHROMA)
+if (cu->tree_type != DUAL_TREE_CHROMA) {
 set_cb_tab(lc, fc->tab.skip, cu->skip_flag);
+set_cb_tab(lc, fc->tab.pcmf[LUMA], cu->bdpcm_flag[LUMA]);
+}
+if (cu->tree_type != DUAL_TREE_LUMA)
+set_cb_tab(lc, fc->tab.pcmf[CHROMA], cu->bdpcm_flag[CHROMA]);
 
 while (tu) {
   for (int j = 0; j < tu->nb_tbs; j++) {
 const TransformBlock *tb = tu->tbs + j;
 if (tb->c_idx != LUMA)
 set_qp_c_tab(lc, tu, tb);
-if (tb->c_idx != CR && cu->bdpcm_flag[tb->c_idx])
-set_tb_tab(fc->tab.pcmf[tb->c_idx], 1, fc, tb);
 }
 tu = tu->next;
 }
diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index edf2607f50..13ca752eec 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -150,6 +150,7 @@ static void min_cb_nz_tl_init(TabList *l, VVCFrameContext 
*fc)
 TL_ADD(cb_height[i], pic_size_in_min_cb);
 TL_ADD(cp_mv[i], pic_size_in_min_cb * MAX_CONTROL_POINTS);
 TL_ADD(cpm[i],   pic_size_in_min_cb);
+TL_ADD(pcmf[i],  pic_size_in_min_cb);
 }
 // For luma, qp can only change at the CU level, so the qp tab size is 
related to the CU.
 TL_ADD(qp[LUMA], pic_size_in_min_cb);
@@ -189,9 +190,6 @@ static void min_tu_tl_init(TabList *l, VVCFrameContext *fc)
 
 TL_ADD(tu_joint_cbcr_residual_flag, pic_size_in_min_tu);
 
-for (int i = LUMA; i <= CHROMA; i++)
-TL_ADD(pcmf[i], pic_size_in_min_tu);
-
 for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS; i++) {
 TL_ADD(tu_coded_flag[i], pic_size_in_min_tu);
 
diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 707fc24203..9a45a735e0 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -543,9 +543,9 @@ static av_always_inline int deblock_bs(const 
VVCLocalContext *lc,
 const uint8_t chroma   = !!c_idx;
 const int tu_p = (y_p >> log2_min_tu_size) * min_tu_width  + 
(x_p >>  log2_min_tu_size);
 const int tu_q = (y_q >> log2_min_tu_size) * min_tu_width  + 
(x_q >>  log2_min_tu_size);
-const uint8_t pcmf = fc->tab.pcmf[chroma][tu_p] && 
fc->tab.pcmf[chroma][tu_q];
 const int cb_p = (y_p >> log2_min_cb_size) * min_cb_width  + 
(x_p >>  log2_min_cb_size);
 const int cb_q = (y_q >> log2_min_cb_size) * min_cb_width  + 
(x_q >>  log2_min_cb_size);
+const uint8_t pcmf = fc->tab.pcmf[chroma][cb_p] && 
fc->tab.pcmf[chroma][cb_q];
 const uint8_t intra= fc->tab.cpm[chroma][cb_p] == MODE_INTRA || 
fc->tab.cpm[chroma][cb_q] == MODE_INTRA;
 const uint8_t same_mode= fc->tab.cpm[chroma][cb_p] == 
fc->tab.cpm[chroma][cb_q];
 
-- 
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 4/4] avcodec/vvcdec: remove unused tb_pos_x0 and tb_pos_y0

2024-10-04 Thread Nuo Mi
This change will save approximately 531 MB for an 8K clip when processed with 
16 threads.
The calculation is as follows:
7680 * 4320 * sizeof(int) * 2 * 2 * 16 / (4 * 4).
---
 libavcodec/vvc/ctu.c | 10 +++---
 libavcodec/vvc/dec.c |  2 --
 libavcodec/vvc/dec.h |  2 --
 3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
index e49976c66b..1e06119cfd 100644
--- a/libavcodec/vvc/ctu.c
+++ b/libavcodec/vvc/ctu.c
@@ -38,7 +38,7 @@ typedef enum VVCModeType {
 MODE_TYPE_INTRA,
 } VVCModeType;
 
-static void set_tb_pos(const VVCFrameContext *fc, const TransformBlock *tb)
+static void set_tb_size(const VVCFrameContext *fc, const TransformBlock *tb)
 {
 const int x_tb  = tb->x0 >> MIN_TU_LOG2;
 const int y_tb  = tb->y0 >> MIN_TU_LOG2;
@@ -50,10 +50,6 @@ static void set_tb_pos(const VVCFrameContext *fc, const 
TransformBlock *tb)
 
 for (int y = y_tb; y < end; y++) {
 const int off = y * fc->ps.pps->min_tu_width + x_tb;
-for (int i = 0; i < width; i++) {
-fc->tab.tb_pos_x0[is_chroma][off + i] = tb->x0;
-fc->tab.tb_pos_y0[is_chroma][off + i] = tb->y0;
-}
 memset(fc->tab.tb_width [is_chroma] + off, tb->tb_width,  width);
 memset(fc->tab.tb_height[is_chroma] + off, tb->tb_height, width);
 }
@@ -397,7 +393,7 @@ static int hls_transform_unit(VVCLocalContext *lc, int x0, 
int y0,int tu_width,
 set_tb_tab(fc->tab.tu_coded_flag[tb->c_idx], 
tu->coded_flag[tb->c_idx], fc, tb);
 }
 if (tb->c_idx != CR)
-set_tb_pos(fc, tb);
+set_tb_size(fc, tb);
 if (tb->c_idx == CB)
 set_tb_tab(fc->tab.tu_joint_cbcr_residual_flag, 
tu->joint_cbcr_residual_flag, fc, tb);
 }
@@ -514,7 +510,7 @@ static int skipped_transform_tree(VVCLocalContext *lc, int 
x0, int y0,int tu_wid
 for (int i = c_start; i < c_end; i++) {
 TransformBlock *tb = add_tb(tu, lc, x0, y0, tu_width >> 
sps->hshift[i], tu_height >> sps->vshift[i], i);
 if (i != CR)
-set_tb_pos(fc, tb);
+set_tb_size(fc, tb);
 }
 }
 
diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 13ca752eec..9b7afe4c38 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -207,8 +207,6 @@ static void min_tu_nz_tl_init(TabList *l, VVCFrameContext 
*fc)
 tl_init(l, 0, changed);
 
 for (int i = LUMA; i <= CHROMA; i++) {
-TL_ADD(tb_pos_x0[i], pic_size_in_min_tu);
-TL_ADD(tb_pos_y0[i], pic_size_in_min_tu);
 TL_ADD(tb_width[i],  pic_size_in_min_tu);
 TL_ADD(tb_height[i], pic_size_in_min_tu);
 }
diff --git a/libavcodec/vvc/dec.h b/libavcodec/vvc/dec.h
index 159c60942b..7254b515fd 100644
--- a/libavcodec/vvc/dec.h
+++ b/libavcodec/vvc/dec.h
@@ -172,8 +172,6 @@ typedef struct VVCFrameContext {
 
 uint8_t *tu_coded_flag[VVC_MAX_SAMPLE_ARRAYS];  ///< 
tu_y_coded_flag[][],  tu_cb_coded_flag[][],  tu_cr_coded_flag[][]
 uint8_t *tu_joint_cbcr_residual_flag;   ///< 
tu_joint_cbcr_residual_flag[][]
-int *tb_pos_x0[2];
-int *tb_pos_y0[2];
 uint8_t *tb_width[2];
 uint8_t *tb_height[2];
 uint8_t *pcmf[2];
-- 
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 1/4] avcodec/vvcdec: refact out deblock boundary strength stage

2024-10-04 Thread Nuo Mi
The deblock boundary strength stage utilizes ~5% of CPU resources for 8K clips.
It's worth considering it as a standalone stage. This stage has been relocated
to follow the parser process, allowing us to reuse CUs and TUs before releasing 
them.
---
 libavcodec/vvc/filter.c | 27 +++
 libavcodec/vvc/filter.h |  9 +
 libavcodec/vvc/thread.c | 24 +---
 3 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 25bef45eed..707fc24203 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -678,12 +678,14 @@ static void vvc_deblock_bs_chroma(const VVCLocalContext 
*lc,
 typedef void (*deblock_bs_fn)(const VVCLocalContext *lc, const int x0, const 
int y0,
 const int width, const int height, const int rs, const int vertical);
 
-static void vvc_deblock_bs(const VVCLocalContext *lc, const int x0, const int 
y0, const int rs, const int vertical)
+void ff_vvc_deblock_bs(VVCLocalContext *lc, const int rx, const int ry, const 
int rs)
 {
 const VVCFrameContext *fc  = lc->fc;
 const VVCSPS *sps  = fc->ps.sps;
 const VVCPPS *pps  = fc->ps.pps;
 const int ctb_size = sps->ctb_size_y;
+const int x0   = rx << sps->ctb_log2_size_y;
+const int y0   = ry << sps->ctb_log2_size_y;
 const int x_end= FFMIN(x0 + ctb_size, pps->width) >> 
MIN_TU_LOG2;
 const int y_end= FFMIN(y0 + ctb_size, pps->height) >> 
MIN_TU_LOG2;
 const int has_chroma   = !!sps->r->sps_chroma_format_idc;
@@ -691,15 +693,18 @@ static void vvc_deblock_bs(const VVCLocalContext *lc, 
const int x0, const int y0
 vvc_deblock_bs_luma, vvc_deblock_bs_chroma
 };
 
-for (int is_chroma = 0; is_chroma <= has_chroma; is_chroma++) {
-const int hs = sps->hshift[is_chroma];
-const int vs = sps->vshift[is_chroma];
-for (int y = y0 >> MIN_TU_LOG2; y < y_end; y++) {
-for (int x = x0 >> MIN_TU_LOG2; x < x_end; x++) {
-const int off = y * fc->ps.pps->min_tu_width + x;
-if ((fc->tab.tb_pos_x0[is_chroma][off] >> MIN_TU_LOG2) == x && 
(fc->tab.tb_pos_y0[is_chroma][off] >> MIN_TU_LOG2) == y) {
-deblock_bs[is_chroma](lc, x << MIN_TU_LOG2, y << 
MIN_TU_LOG2,
-fc->tab.tb_width[is_chroma][off] << hs, 
fc->tab.tb_height[is_chroma][off] << vs, rs, vertical);
+ff_vvc_decode_neighbour(lc, x0, y0, rx, ry, rs);
+for (int vertical = 0; vertical <= 1; vertical++) {
+for (int is_chroma = 0; is_chroma <= has_chroma; is_chroma++) {
+const int hs = sps->hshift[is_chroma];
+const int vs = sps->vshift[is_chroma];
+for (int y = y0 >> MIN_TU_LOG2; y < y_end; y++) {
+for (int x = x0 >> MIN_TU_LOG2; x < x_end; x++) {
+const int off = y * fc->ps.pps->min_tu_width + x;
+if ((fc->tab.tb_pos_x0[is_chroma][off] >> MIN_TU_LOG2) == 
x && (fc->tab.tb_pos_y0[is_chroma][off] >> MIN_TU_LOG2) == y) {
+deblock_bs[is_chroma](lc, x << MIN_TU_LOG2, y << 
MIN_TU_LOG2,
+fc->tab.tb_width[is_chroma][off] << hs, 
fc->tab.tb_height[is_chroma][off] << vs, rs, vertical);
+}
 }
 }
 }
@@ -795,8 +800,6 @@ static void vvc_deblock(const VVCLocalContext *lc, int x0, 
int y0, const int rs,
 const uint8_t no_p[4]  = { 0 };
 const uint8_t no_q[4]  = { 0 } ;
 
-vvc_deblock_bs(lc, x0, y0, rs, vertical);
-
 if (!vertical) {
 FFSWAP(int, x_end, y_end);
 FFSWAP(int, x0, y0);
diff --git a/libavcodec/vvc/filter.h b/libavcodec/vvc/filter.h
index 03cc74e071..29abbd98ce 100644
--- a/libavcodec/vvc/filter.h
+++ b/libavcodec/vvc/filter.h
@@ -33,6 +33,15 @@
  */
 void ff_vvc_lmcs_filter(const VVCLocalContext *lc, const int x0, const int y0);
 
+/**
+ * derive boundary strength for the CTU
+ * @param lc local context for CTU
+ * @param rx raster x position for the CTU
+ * @param ry raster y position for the CTU
+ * @param rs raster position for the CTU
+ */
+void ff_vvc_deblock_bs(VVCLocalContext *lc, const int rx, const int ry, const 
int rs);
+
 /**
  * vertical deblock filter for the CTU
  * @param lc local context for CTU
diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
index d75784e242..82c00dd4c9 100644
--- a/libavcodec/vvc/thread.c
+++ b/libavcodec/vvc/thread.c
@@ -42,6 +42,7 @@ typedef struct ProgressListener {
 typedef enum VVCTaskStage {
 VVC_TASK_STAGE_INIT,// for CTU(0, 0) only
 VVC_TASK_STAGE_PARSE,
+VVC_TASK_STAGE_DEBLOCK_BS,
 VVC_TASK_STAGE_INTER,
 VVC_TASK_STAGE_RECON,
 VVC_TASK_STAGE_LMCS,
@@ -111,6 +112,7 @@ static void add_task(VVCContext *s, VVCTask *t)
 const int priorities[] = {
 0,  // VVC_TASK_STAGE_INIT,
 0,  //

Re: [FFmpeg-devel] [PATCH] libavcodec: x86: Remove an explicit include of config.asm

2024-10-04 Thread Martin Storsjö

On Wed, 2 Oct 2024, Martin Storsjö wrote:


This file is never included explicitly anywhere else, it's only
included implicitly by passing -Pconfig.asm on the command line.
---
libavcodec/x86/celt_pvq_search.asm | 1 -
1 file changed, 1 deletion(-)

diff --git a/libavcodec/x86/celt_pvq_search.asm 
b/libavcodec/x86/celt_pvq_search.asm
index e9bff02650..3c6974d370 100644
--- a/libavcodec/x86/celt_pvq_search.asm
+++ b/libavcodec/x86/celt_pvq_search.asm
@@ -20,7 +20,6 @@
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;**

-%include "config.asm"
%include "libavutil/x86/x86util.asm"

%ifdef __NASM_VER__
--
2.39.5 (Apple Git-154)


Will push soon, as this is kinda trivial.

// Martin
___
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/mediacodecenc: Extract configOBUs from AV1CodecConfigurationRecord

2024-10-04 Thread Martin Storsjö

On Sat, 5 Oct 2024, Zhao Zhili wrote:


From: Zhao Zhili 

MediaCodec can generate AV1CodecConfigurationRecord, which shouldn't
be put into packet->data. Skip four bytes and extract configOBUs
if it exist.
---
I did some test on Pixel 8 Pro. AV1 hardware encoding works with a lot
of bugs:

1. It's broken for width non-aligned to 16. For width 1080 and pixel
format YUV420P, MediaCodec use 1080 as stride. For pixel format NV12,
MediaCodec use 1088 as stride. There is no API to get the stride info.
AMEDIAFORMAT_KEY_STRIDE doesn't work. And set stride to MediaCodec has
no effect from my test, at least on that device. We know the buffer
size provided by MediaCodec, but we still cannot get stride by
buf_size / height:

 1) For YUV420P, buf_size = 1080 * height
 2) For NV12, buf_size = 1080 + 1088 * (height - 1). Yes, buf_size doesn't
count last line's padding :(


Isn't this pretty much the case for the encoders for other codecs as well 
- there aren't really any compat guarantees for how they behave for widths 
that aren't a multiple of 16? At least back when there when Android added 
CTS tests to guarantee some sort of cross device consistent behaviour, 
they only tested/mandated the behviour for a couple resolutions, that all 
were even multiples of 16.


I guess the difference here is whether it's possible to do cropping in the 
same way as via the h264_metadata/hevc_metadata BSFs?


// Martin

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

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


[FFmpeg-devel] [PATCH v10 3/6] libavcodec/dnxuc_parser: DNxUncompressed essence parser

2024-10-04 Thread Martin Schitter
---
 libavcodec/Makefile   |   1 +
 libavcodec/dnxuc_parser.c | 124 ++
 libavcodec/parsers.c  |   1 +
 3 files changed, 126 insertions(+)
 create mode 100644 libavcodec/dnxuc_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4eed81e..81fc0a1 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1194,6 +1194,7 @@ OBJS-$(CONFIG_DCA_PARSER)  += dca_parser.o 
dca_exss.o dca.o \
   dca_sample_rate_tab.o
 OBJS-$(CONFIG_DIRAC_PARSER)+= dirac_parser.o
 OBJS-$(CONFIG_DNXHD_PARSER)+= dnxhd_parser.o dnxhddata.o
+OBJS-$(CONFIG_DNXUC_PARSER)+= dnxuc_parser.o
 OBJS-$(CONFIG_DOLBY_E_PARSER)  += dolby_e_parser.o dolby_e_parse.o
 OBJS-$(CONFIG_DPX_PARSER)  += dpx_parser.o
 OBJS-$(CONFIG_DVAUDIO_PARSER)  += dvaudio_parser.o
diff --git a/libavcodec/dnxuc_parser.c b/libavcodec/dnxuc_parser.c
new file mode 100644
index 000..55d5763
--- /dev/null
+++ b/libavcodec/dnxuc_parser.c
@@ -0,0 +1,124 @@
+/*
+ * Avid DNxUncomressed / SMPTE RDD 50 parser
+ * Copyright (c) 2024 Martin Schitter
+ *
+ * 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
+ */
+
+/*
+ This parser for DNxUncompressed video data is mostly based on
+ reverse engineering of output generated by DaVinci Resolve 19
+ but was later also checked against the SMPTE RDD 50 specification.
+
+ Limitations: Multiple image planes are not supported.
+*/
+
+#include "avcodec.h"
+#include "libavutil/intreadwrite.h"
+
+typedef struct DNxUcParseContext {
+uint32_t fourcc_tag;
+uint32_t width;
+uint32_t height;
+uint32_t nr_bytes;
+} DNxUcParseContext;
+
+/*
+DNxUncompressed frame data comes wrapped in nested boxes of metadata
+(box structure: len + fourcc marker + data):
+
+[0-4]   len of outer essence unit box (typically 37 bytes of header + frame 
data)
+[4-7]   fourcc 'pack'
+
+[8-11]  len of "signal info box" (always 21)
+[12-15] fourcc 'sinf'
+[16-19] frame width / line packing size
+[20-23] frame hight / nr of lines
+[24-27] fourcc pixel format indicator
+[28]frame_layout (0: progressive, 1: interlaced)
+
+[29-32] len of "signal data box" (nr of frame data bytes + 8)
+[33-36] fourcc 'sdat'
+[37-..] frame data
+
+A sequence of 'signal info'+'signal data' box pairs wrapped in
+'icmp'(=image component) boxes can be utilized to compose more
+complex multi plane images.
+This feature is only partially supported in the present implementation.
+We never pick more than the first pair of info and image data enclosed
+in this way.
+*/
+
+static int dnxuc_parse(AVCodecParserContext *s,
+AVCodecContext *avctx,
+const uint8_t **poutbuf, int *poutbuf_size,
+const uint8_t *buf, int buf_size)
+{
+char fourcc_buf[5];
+const int HEADER_SIZE = 37;
+int icmp_offset = 0;
+
+DNxUcParseContext *pc;
+pc = (DNxUcParseContext *) s->priv_data;
+
+if (!buf_size) {
+return 0;
+}
+if (buf_size > 16 && MKTAG('i','c','m','p') == AV_RL32(buf+12)){
+icmp_offset += 8;
+}
+if ( buf_size < 37 + icmp_offset /* check metadata structure expectations 
*/
+|| MKTAG('p','a','c','k') != AV_RL32(buf+4+icmp_offset)
+|| MKTAG('s','i','n','f') != AV_RL32(buf+12+icmp_offset)
+|| MKTAG('s','d','a','t') != AV_RL32(buf+33+icmp_offset)){
+av_log(avctx, AV_LOG_ERROR, "can't read DNxUncompressed 
metadata.\n");
+*poutbuf_size = 0;
+return buf_size;
+}
+
+pc->fourcc_tag = AV_RL32(buf+24+icmp_offset);
+pc->width = AV_RL32(buf+16+icmp_offset);
+pc->height = AV_RL32(buf+20+icmp_offset);
+pc->nr_bytes = AV_RL32(buf+29+icmp_offset) - 8;
+
+if (!avctx->codec_tag) {
+av_fourcc_make_string(fourcc_buf, pc->fourcc_tag);
+av_log(avctx, AV_LOG_INFO, "dnxuc_parser: '%s' %dx%d %dbpp %d\n",
+fourcc_buf,
+pc->width, pc->height,
+(pc->nr_bytes*8)/(pc->width*pc->height),
+pc->nr_bytes);
+avctx->codec_tag = pc->fourcc_tag;
+}
+
+if (pc->nr_bytes > buf_size - HEADER_SIZE + icmp_offset){
+av_log(avctx, AV_LOG_ERROR, "Insufficient size of image essence 
da

[FFmpeg-devel] [PATCH v10 2/6] libavformat/mxf: Add ULs for DNxUncompressed

2024-10-04 Thread Martin Schitter
---
 libavformat/mxf.c| 1 +
 libavformat/mxfdec.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libavformat/mxf.c b/libavformat/mxf.c
index a73e40e..b6c1f17 100644
--- a/libavformat/mxf.c
+++ b/libavformat/mxf.c
@@ -61,6 +61,7 @@ const MXFCodecUL ff_mxf_codec_uls[] = {
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x71,0x00,0x00,0x00 
}, 13,  AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x03,0x02,0x00,0x00 
}, 14,  AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0E,0x04,0x02,0x01,0x02,0x04,0x01,0x00 
}, 16,  AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD Legacy Avid Media Composer 
MXF */
+{ { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x02,0x02,0x03,0x07,0x01,0x00 
}, 14,  AV_CODEC_ID_DNXUC }, /* DNxUncompressed/SMPTE RDD 50 */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 
}, 14,   AV_CODEC_ID_H264 }, /* H.264/MPEG-4 AVC Intra */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x31,0x11,0x01 
}, 14,   AV_CODEC_ID_H264 }, /* H.264/MPEG-4 AVC SPS/PPS in-band */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x02,0x01 
}, 16,   AV_CODEC_ID_V210 }, /* V210 */
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 1b53a97..e5f5908 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1617,6 +1617,7 @@ static const MXFCodecUL 
mxf_picture_essence_container_uls[] = {
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c,0x01,0x00 
}, 14,   AV_CODEC_ID_JPEG2000, NULL, 14, J2KWrap },
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x10,0x60,0x01 
}, 14,   AV_CODEC_ID_H264, NULL, 15 }, /* H.264 */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x11,0x01,0x00 
}, 14,  AV_CODEC_ID_DNXHD, NULL, 14 }, /* VC-3 */
+{ { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x1e,0x01,0x00 
}, 14,  AV_CODEC_ID_DNXUC, NULL, 14 }, /* DNxUncompressed / SMPTE RDD 50 */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x12,0x01,0x00 
}, 14,AV_CODEC_ID_VC1, NULL, 14 }, /* VC-1 */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x14,0x01,0x00 
}, 14,   AV_CODEC_ID_TIFF, NULL, 14 }, /* TIFF */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x15,0x01,0x00 
}, 14,  AV_CODEC_ID_DIRAC, NULL, 14 }, /* VC-2 */
-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH v10 0/6] DNxUncompressed decoder

2024-10-04 Thread Martin Schitter
v10 of this patch set utilizes AV_WL16 macros instead of memcpy to get
byte swapping support as pointed out by michael niedermayers review.

Martin

Martin Schitter (6):
  libavcodec/: Add ID and desc for DNxUncompressed
  libavformat/mxf: Add ULs for DNxUncompressed
  libavcodec/dnxuc_parser: DNxUncompressed essence parser
  libavcodec/dnxucdec: DNxUncompressed decoder
  doc: DNxUncompressed Changelog and doc entries
  tests: Fate sample tests for DNxUncompressed

 Changelog   |   2 +
 doc/general_contents.texi   |   1 +
 libavcodec/Makefile |   2 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/codec_desc.c |   7 +
 libavcodec/codec_id.h   |   1 +
 libavcodec/dnxuc_parser.c   | 124 +
 libavcodec/dnxucdec.c   | 385 
 libavcodec/parsers.c|   1 +
 libavcodec/version.c|   2 +-
 libavformat/mxf.c   |   1 +
 libavformat/mxfdec.c|   1 +
 tests/Makefile  |   1 +
 tests/fate/dnxuc.mak|  40 +++
 tests/ref/fate/dnxuc-cb-rgb-10  |   8 +
 tests/ref/fate/dnxuc-cb-rgb-12  |   8 +
 tests/ref/fate/dnxuc-cb-rgb-8   |   8 +
 tests/ref/fate/dnxuc-cb-rgb-float   |   8 +
 tests/ref/fate/dnxuc-cb-rgb-half|   8 +
 tests/ref/fate/dnxuc-cb-yuv422-10   |   8 +
 tests/ref/fate/dnxuc-cb-yuv422-12   |   8 +
 tests/ref/fate/dnxuc-cb-yuv422-8|   8 +
 tests/ref/fate/dnxuc-ramp-rgb-10|   8 +
 tests/ref/fate/dnxuc-ramp-rgb-12|   8 +
 tests/ref/fate/dnxuc-ramp-rgb-8 |   8 +
 tests/ref/fate/dnxuc-ramp-rgb-float |   8 +
 tests/ref/fate/dnxuc-ramp-rgb-half  |   8 +
 tests/ref/fate/dnxuc-ramp-yuv422-10 |   8 +
 tests/ref/fate/dnxuc-ramp-yuv422-12 |   8 +
 tests/ref/fate/dnxuc-ramp-yuv422-8  |   8 +
 30 files changed, 696 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/dnxuc_parser.c
 create mode 100644 libavcodec/dnxucdec.c
 create mode 100644 tests/fate/dnxuc.mak
 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-10
 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-12
 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-8
 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-float
 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-half
 create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-10
 create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-12
 create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-8
 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-10
 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-12
 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-8
 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-float
 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-half
 create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-10
 create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-12
 create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-8

-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH v10 1/6] libavcodec/: Add ID and desc for DNxUncompressed

2024-10-04 Thread Martin Schitter
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 libavcodec/version.c| 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 03dea57..2452a7b 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1959,6 +1959,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("LEAD MCMP"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_DNXUC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "dnxuc",
+.long_name = NULL_IF_CONFIG_SMALL("DNxUncompressed / SMPTE RDD 50"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 0a8d3be..0abd036 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -322,6 +322,7 @@ enum AVCodecID {
 AV_CODEC_ID_RTV1,
 AV_CODEC_ID_VMIX,
 AV_CODEC_ID_LEAD,
+AV_CODEC_ID_DNXUC,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/version.c b/libavcodec/version.c
index 27f9432..03dd95e 100644
--- a/libavcodec/version.c
+++ b/libavcodec/version.c
@@ -31,7 +31,7 @@ const char av_codec_ffversion[] = "FFmpeg version " 
FFMPEG_VERSION;
 
 unsigned avcodec_version(void)
 {
-static_assert(AV_CODEC_ID_LEAD ==   269 &&
+static_assert(AV_CODEC_ID_DNXUC==   270 &&
   AV_CODEC_ID_PCM_SGA  == 65572 &&
   AV_CODEC_ID_ADPCM_XMD== 69683 &&
   AV_CODEC_ID_CBD2_DPCM== 81928 &&
-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH v10 4/6] libavcodec/dnxucdec: DNxUncompressed decoder

2024-10-04 Thread Martin Schitter
---
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/dnxucdec.c  | 385 +
 3 files changed, 387 insertions(+)
 create mode 100644 libavcodec/dnxucdec.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 81fc0a1..251b826 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -327,6 +327,7 @@ OBJS-$(CONFIG_DFPWM_DECODER)   += dfpwmdec.o
 OBJS-$(CONFIG_DFPWM_ENCODER)   += dfpwmenc.o
 OBJS-$(CONFIG_DNXHD_DECODER)   += dnxhddec.o dnxhddata.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += dnxhdenc.o dnxhddata.o
+OBJS-$(CONFIG_DNXUC_DECODER)   += dnxucdec.o
 OBJS-$(CONFIG_DOLBY_E_DECODER) += dolby_e.o dolby_e_parse.o kbdwin.o
 OBJS-$(CONFIG_DPX_DECODER) += dpx.o
 OBJS-$(CONFIG_DPX_ENCODER) += dpxenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index aa0fc47..d6ab5f0 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -93,6 +93,7 @@ extern const FFCodec ff_dfa_decoder;
 extern const FFCodec ff_dirac_decoder;
 extern const FFCodec ff_dnxhd_encoder;
 extern const FFCodec ff_dnxhd_decoder;
+extern const FFCodec ff_dnxuc_decoder;
 extern const FFCodec ff_dpx_encoder;
 extern const FFCodec ff_dpx_decoder;
 extern const FFCodec ff_dsicinvideo_decoder;
diff --git a/libavcodec/dnxucdec.c b/libavcodec/dnxucdec.c
new file mode 100644
index 000..f28e935
--- /dev/null
+++ b/libavcodec/dnxucdec.c
@@ -0,0 +1,385 @@
+/*
+ * Avid DNxUncomressed / SMPTE RDD 50 decoder
+ * Copyright (c) 2024 Martin Schitter
+ *
+ * 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
+ */
+
+/*
+ This decoder for DNxUncompressed video data is mostly based on
+ reverse engineering of output generated by DaVinci Resolve 19
+ but was later also checked against the SMPTE RDD 50 specification.
+
+ Not all DNxUncompressed pixel format variants are supported,
+ but at least an elementary base set is already usable:
+
+  - YUV 4:2:2 8/10/12bit
+  - RGB 8/10/12bit/half/float
+
+*/
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "decode.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/intreadwrite.h"
+#include "thread.h"
+
+static int pass_though(AVCodecContext *avctx, AVFrame *frame, const AVPacket 
*avpkt)
+{
+/* there is no need to copy as the data already match
+ * a known pixel format */
+
+frame->buf[0] = av_buffer_ref(avpkt->buf);
+
+if (!frame->buf[0]) {
+return AVERROR(ENOMEM);
+}
+
+return av_image_fill_arrays(frame->data, frame->linesize, avpkt->data,
+   avctx->pix_fmt, avctx->width, avctx->height, 1);
+}
+
+static int float2planes(AVCodecContext *avctx, AVFrame *frame, const AVPacket 
*pkt)
+{
+int lw;
+const size_t sof = 4;
+
+lw = frame->width;
+
+for(int y = 0; y < frame->height; y++){
+for(int x = 0; x < frame->width; x++){
+memcpy(&frame->data[2][sof*(lw*y + x)], &pkt->data[sof* 3*(lw*y + 
x)], sof);
+memcpy(&frame->data[0][sof*(lw*y + x)], &pkt->data[sof*(3*(lw*y + 
x) + 1)], sof);
+memcpy(&frame->data[1][sof*(lw*y + x)], &pkt->data[sof*(3*(lw*y + 
x) + 2)], sof);
+}
+}
+return pkt->size;
+}
+
+static int half_add_alpha(AVCodecContext *avctx, AVFrame *frame, const 
AVPacket *pkt)
+{
+/* ffmpeg doesn't provide RGB half bit depth without alpha channel right 
now
+ * we simply add an opaque alpha layer as workaround */
+
+int lw;
+const size_t soh = 2;
+const uint16_t opaque = 0x3c00;
+
+lw = frame->width;
+
+for(int y = 0; y < frame->height; y++){
+for(int x = 0; x < frame->width; x++){
+memcpy(&frame->data[0][soh*4*(lw*y + x)], &pkt->data[soh*3*(lw*y + 
x)], soh*3);
+memcpy(&frame->data[0][soh*(4*(lw*y + x) + 3)], &opaque, soh);
+}
+}
+return pkt->size;
+}
+
+/* DNxUncompressed utilizes a very dense bitpack representation of 10bit and 
12bit pixel data.
+
+Lines of Image data, which look like in their ordinary 8bit counterpart, 
contain the most
+significant upper bits of the pixel data. These sections alternate with 
shorter segments in
+which the complementary least significant bits of information get packed in a 
gapless sequenc

[FFmpeg-devel] [PATCH v10 6/6] tests: Fate sample tests for DNxUncompressed

2024-10-04 Thread Martin Schitter
---
 tests/Makefile  |  1 +
 tests/fate/dnxuc.mak| 40 +
 tests/ref/fate/dnxuc-cb-rgb-10  |  8 ++
 tests/ref/fate/dnxuc-cb-rgb-12  |  8 ++
 tests/ref/fate/dnxuc-cb-rgb-8   |  8 ++
 tests/ref/fate/dnxuc-cb-rgb-float   |  8 ++
 tests/ref/fate/dnxuc-cb-rgb-half|  8 ++
 tests/ref/fate/dnxuc-cb-yuv422-10   |  8 ++
 tests/ref/fate/dnxuc-cb-yuv422-12   |  8 ++
 tests/ref/fate/dnxuc-cb-yuv422-8|  8 ++
 tests/ref/fate/dnxuc-ramp-rgb-10|  8 ++
 tests/ref/fate/dnxuc-ramp-rgb-12|  8 ++
 tests/ref/fate/dnxuc-ramp-rgb-8 |  8 ++
 tests/ref/fate/dnxuc-ramp-rgb-float |  8 ++
 tests/ref/fate/dnxuc-ramp-rgb-half  |  8 ++
 tests/ref/fate/dnxuc-ramp-yuv422-10 |  8 ++
 tests/ref/fate/dnxuc-ramp-yuv422-12 |  8 ++
 tests/ref/fate/dnxuc-ramp-yuv422-8  |  8 ++
 18 files changed, 169 insertions(+)
 create mode 100644 tests/fate/dnxuc.mak
 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-10
 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-12
 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-8
 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-float
 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-half
 create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-10
 create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-12
 create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-8
 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-10
 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-12
 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-8
 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-float
 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-half
 create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-10
 create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-12
 create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-8

diff --git a/tests/Makefile b/tests/Makefile
index 9b70145..e073915 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -172,6 +172,7 @@ include $(SRC_PATH)/tests/fate/dca.mak
 include $(SRC_PATH)/tests/fate/demux.mak
 include $(SRC_PATH)/tests/fate/dfa.mak
 include $(SRC_PATH)/tests/fate/dnxhd.mak
+include $(SRC_PATH)/tests/fate/dnxuc.mak
 include $(SRC_PATH)/tests/fate/dpcm.mak
 include $(SRC_PATH)/tests/fate/dvvideo.mak
 include $(SRC_PATH)/tests/fate/ea.mak
diff --git a/tests/fate/dnxuc.mak b/tests/fate/dnxuc.mak
new file mode 100644
index 000..80ff0e9
--- /dev/null
+++ b/tests/fate/dnxuc.mak
@@ -0,0 +1,40 @@
+FATE_DNXUC_CB = fate-dnxuc-cb-rgb-8 \
+fate-dnxuc-cb-rgb-10 \
+fate-dnxuc-cb-rgb-12 \
+fate-dnxuc-cb-rgb-half \
+fate-dnxuc-cb-rgb-float \
+fate-dnxuc-cb-yuv422-8 \
+fate-dnxuc-cb-yuv422-10 \
+fate-dnxuc-cb-yuv422-12
+
+FATE_DNXUC_RAMP =   fate-dnxuc-ramp-rgb-8 \
+fate-dnxuc-ramp-rgb-10 \
+fate-dnxuc-ramp-rgb-12 \
+fate-dnxuc-ramp-rgb-half \
+fate-dnxuc-ramp-rgb-float \
+fate-dnxuc-ramp-yuv422-8 \
+fate-dnxuc-ramp-yuv422-10 \
+fate-dnxuc-ramp-yuv422-12
+
+FATE_DNXUC-$(call FRAMECRC, MXF, DNXUC) += $(FATE_DNXUC_CB) $(FATE_DNXUC_RAMP)
+
+FATE_SAMPLES_FFMPEG += $(FATE_DNXUC-yes)
+fate-dnxuc: $(FATE_DNXUC-yes)
+
+fate-dnxuc-cb-rgb-8: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/cb_rgb_8.mxf
+fate-dnxuc-cb-rgb-10: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/cb_rgb_10.mxf
+fate-dnxuc-cb-rgb-12: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/cb_rgb_12.mxf
+fate-dnxuc-cb-rgb-half: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/cb_rgb_half.mxf
+fate-dnxuc-cb-rgb-float: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/cb_rgb_float.mxf
+fate-dnxuc-cb-yuv422-8: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/cb_yuv422_8.mxf
+fate-dnxuc-cb-yuv422-10: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/cb_yuv422_10.mxf
+fate-dnxuc-cb-yuv422-12: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/cb_yuv422_12.mxf
+
+fate-dnxuc-ramp-rgb-8: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/ramp_rgb_8.mxf
+fate-dnxuc-ramp-rgb-10: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/ramp_rgb_10.mxf
+fate-dnxuc-ramp-rgb-12: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/ramp_rgb_12.mxf
+fate-dnxuc-ramp-rgb-half: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/ramp_rgb_half.mxf
+fate-dnxuc-ramp-rgb-float: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/ramp_rgb_float.mxf
+fate-dnxuc-ramp-yuv422-8: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/ramp_yuv422_8.mxf
+fate-dnxuc-ramp-yuv422-10: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/ramp_yuv422_10.mxf
+fate-dnxuc-ramp-yuv422-12: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/dnxuc/ramp_yuv422_12.mxf
diff --git a/tests/ref/fate/dnxu

[FFmpeg-devel] [PATCH v10 5/6] doc: DNxUncompressed Changelog and doc entries

2024-10-04 Thread Martin Schitter
---
 Changelog | 2 ++
 doc/general_contents.texi | 1 +
 2 files changed, 3 insertions(+)

diff --git a/Changelog b/Changelog
index b82b948..41632ba 100644
--- a/Changelog
+++ b/Changelog
@@ -2,6 +2,8 @@ Entries are sorted chronologically from oldest to youngest 
within each release,
 releases are sorted from youngest to oldest.
 
 version :
+- DNxUncompressed (SMPTE RDD 50) decoder
+
 
 version 7.1:
 - Raw Captions with Time (RCWT) closed caption demuxer
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 5980ac6..76e1d34 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -632,6 +632,7 @@ library:
 @item raw DFPWM @tab X @tab X
 @item raw Dirac @tab X @tab X
 @item raw DNxHD @tab X @tab X
+@item raw DNxUncompressed   @tab   @tab X
 @item raw DTS   @tab X @tab X
 @item raw DTS-HD@tab   @tab X
 @item raw E-AC-3@tab X @tab X
-- 
2.45.2

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

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


Re: [FFmpeg-devel] [PATCH v9 4/6] libavcodec/dnxucdec: DNxUncompressed decoder

2024-10-04 Thread martin schitter




On 03.10.24 20:44, Michael Niedermayer wrote:

On Mon, Sep 23, 2024 at 11:16:45AM +0200, Martin Schitter wrote:
[...]


+static av_cold int dnxuc_decode_init(AVCodecContext *avctx)
+{
+return 0;
+}


unneeded


done in v10.



+memcpy(&frame->data[2][2*(y*lw + x)], &r, 2);
+memcpy(&frame->data[0][2*(y*lw + x)], &g, 2);
+memcpy(&frame->data[1][2*(y*lw + x)], &b, 2);


this probably should be AV_WL16() or something like that


changed in all similar places.

thanks for your review!

martin
___
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 - Uncompressed MP4

2024-10-04 Thread martin schitter




On 04.10.24 18:10, Devon Sookhoo wrote:

I thought the option  "-c:v rawvideo"  was the way to go because it's used
to generate an uncompressed avi file:
$ ffmpeg -i input.mp4  -c:v rawvideo  out.avi


For the older simpler file formats, where only a rather small set of 
supported image format configurations were available, this kind of 
handling may indeed have worked sufficient. But even under this rather 
limited circumstances, you always had to take care of the actually used 
pixel format and very often set/correct/enforce it explicitly.


In principle you could adapt such a combination of -c:v rawvideo and 
-pix_fmt for this kind of mp4 content as well, but I doubt that it will 
work satisfactorily in practice. The range of possible configuration 
variants is huge and not all of them correspond in a strict one-to-one 
relation already defined ffmpeg pixel formats.


A more format specific video codec specifier (= -c:v ...) and suitable 
options for all the format specific export configuration parameters 
looks much more useful to me -- but I may be wrong.


martin
___
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/mfenc: add support for AV1 MF encoders

2024-10-04 Thread Martin Storsjö

On Fri, 4 Oct 2024, Dash Santosh wrote:


From 77c708805c52302861650cf770f6c32a33590e90 Mon Sep 17 00:00:00 2001
From: Min Chen 
Date: Fri, 4 Oct 2024 23:04:04 +0530
Subject: [PATCH] avcodec/mfenc: add support for AV1 MF encoders
X-Unsent: 1
To: ffmpeg-devel@ffmpeg.org

Signed-off-by: Dash Santosh 
---
configure  | 1 +
libavcodec/allcodecs.c | 1 +
libavcodec/mf_utils.c  | 2 ++
libavcodec/mfenc.c | 1 +
4 files changed, 5 insertions(+)

diff --git a/configure b/configure
index 0247ea08d6..63bc53cc27 100755
--- a/configure
+++ b/configure
@@ -3347,6 +3347,7 @@ av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS"
av1_mediacodec_decoder_deps="mediacodec"
av1_mediacodec_encoder_deps="mediacodec"
av1_mediacodec_encoder_select="extract_extradata_bsf"
+av1_mf_encoder_deps="mediafoundation"
av1_nvenc_encoder_deps="nvenc NV_ENC_PIC_PARAMS_AV1"
av1_nvenc_encoder_select="atsc_a53"
av1_qsv_decoder_select="qsvdec"
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index aa0fc47647..f5317616b7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -838,6 +838,7 @@ extern const FFCodec ff_av1_nvenc_encoder;
extern const FFCodec ff_av1_qsv_decoder;
extern const FFCodec ff_av1_qsv_encoder;
extern const FFCodec ff_av1_amf_encoder;
+extern const FFCodec ff_av1_mf_encoder;
extern const FFCodec ff_av1_vaapi_encoder;
extern const FFCodec ff_libopenh264_encoder;
extern const FFCodec ff_libopenh264_decoder;
diff --git a/libavcodec/mf_utils.c b/libavcodec/mf_utils.c
index 48e3a63efc..f740a6090b 100644
--- a/libavcodec/mf_utils.c
+++ b/libavcodec/mf_utils.c
@@ -240,6 +240,7 @@ static struct GUID_Entry guid_names[] = {
GUID_ENTRY(MFMediaType_Video),
GUID_ENTRY(MFAudioFormat_PCM),
GUID_ENTRY(MFAudioFormat_Float),
+GUID_ENTRY(MFVideoFormat_AV1),
GUID_ENTRY(MFVideoFormat_H264),
GUID_ENTRY(MFVideoFormat_H264_ES),
GUID_ENTRY(ff_MFVideoFormat_HEVC),
@@ -507,6 +508,7 @@ void ff_media_type_dump(void *log, IMFMediaType *type)
const CLSID *ff_codec_to_mf_subtype(enum AVCodecID codec)
{
switch (codec) {
+case AV_CODEC_ID_AV1:   return &MFVideoFormat_AV1;
case AV_CODEC_ID_H264:  return &MFVideoFormat_H264;
case AV_CODEC_ID_HEVC:  return &ff_MFVideoFormat_HEVC;


Doing this like this would break compilation with any earlier SDK, that 
doesn't contain a declaration of MFVideoFormat_AV1. See how we've provided 
a local definition of MFVideoFormat_HEVC in the form of 
ff_MFVideoFormat_HEVC, to work around this issue.


// Martin

___
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] avcodec/mediacodecenc: Extract configOBUs from AV1CodecConfigurationRecord

2024-10-04 Thread Zhao Zhili
From: Zhao Zhili 

MediaCodec can generate AV1CodecConfigurationRecord, which shouldn't
be put into packet->data. Skip four bytes and extract configOBUs
if it exist.
---
I did some test on Pixel 8 Pro. AV1 hardware encoding works with a lot
of bugs:

1. It's broken for width non-aligned to 16. For width 1080 and pixel
format YUV420P, MediaCodec use 1080 as stride. For pixel format NV12,
MediaCodec use 1088 as stride. There is no API to get the stride info.
AMEDIAFORMAT_KEY_STRIDE doesn't work. And set stride to MediaCodec has
no effect from my test, at least on that device. We know the buffer
size provided by MediaCodec, but we still cannot get stride by
buf_size / height:

  1) For YUV420P, buf_size = 1080 * height
  2) For NV12, buf_size = 1080 + 1088 * (height - 1). Yes, buf_size doesn't
count last line's padding :(

2. After flush (which means reset for MediaCodec), it doesn't reset GOP
info, so it output a few non-key frames before generate a key frame.
This breaks what I did for AV_CODEC_FLAG_GLOBAL_HEADER: send a dummy
frame, send EOF, get packet and extract extra data, then reset
MediaCodec state by AMediaCodec_flush.

 libavcodec/mediacodecenc.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index e76ea81236..3880ea2fe9 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -429,6 +429,16 @@ static int mediacodec_receive(AVCodecContext *avctx, 
AVPacket *pkt)
 }
 
 if (out_info.flags & ff_AMediaCodec_getBufferFlagCodecConfig(codec)) {
+if (avctx->codec_id == AV_CODEC_ID_AV1) {
+// Skip AV1CodecConfigurationRecord without configOBUs
+if (out_info.size <= 4) {
+ff_AMediaCodec_releaseOutputBuffer(codec, index, false);
+return mediacodec_receive(avctx, pkt);
+}
+out_info.size -= 4;
+out_info.offset += 4;
+}
+
 ret = av_reallocp(&s->extradata, out_info.size);
 if (ret)
 goto bailout;
-- 
2.46.0

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/mediacodecenc: Extract configOBUs from AV1CodecConfigurationRecord

2024-10-04 Thread Zhao Zhili


> On Oct 5, 2024, at 02:15, James Almer  wrote:
> 
> On 10/4/2024 2:54 PM, Zhao Zhili wrote:
>> From: Zhao Zhili 
>> MediaCodec can generate AV1CodecConfigurationRecord, which shouldn't
>> be put into packet->data. Skip four bytes and extract configOBUs
>> if it exist.
> 
> But why are you removing them from extradata if you only want to prevent them 
> to make it to a packet?
> You could instead make sure they are not dumped into the packet in the 
> memcpy(pkt->data... below this chunk.

s->extradata is a temporary buffer, not avctx->extradata. I don’t know how to 
make
it useful with the whole AV1CodecConfigurationRecord. 
AV_CODEC_FLAG_GLOBAL_HEADER
is handled by extract_extradata bsf within MediaCodec wrapper, which is more 
reliable
than depends on OS to output extradata directly. From my test, the device output
AV1CodecConfigurationRecord with zero configOBUs.

> 
>> ---
>> I did some test on Pixel 8 Pro. AV1 hardware encoding works with a lot
>> of bugs:
>> 1. It's broken for width non-aligned to 16. For width 1080 and pixel
>> format YUV420P, MediaCodec use 1080 as stride. For pixel format NV12,
>> MediaCodec use 1088 as stride. There is no API to get the stride info.
>> AMEDIAFORMAT_KEY_STRIDE doesn't work. And set stride to MediaCodec has
>> no effect from my test, at least on that device. We know the buffer
>> size provided by MediaCodec, but we still cannot get stride by
>> buf_size / height:
>>   1) For YUV420P, buf_size = 1080 * height
>>   2) For NV12, buf_size = 1080 + 1088 * (height - 1). Yes, buf_size doesn't
>> count last line's padding :(
>> 2. After flush (which means reset for MediaCodec), it doesn't reset GOP
>> info, so it output a few non-key frames before generate a key frame.
>> This breaks what I did for AV_CODEC_FLAG_GLOBAL_HEADER: send a dummy
>> frame, send EOF, get packet and extract extra data, then reset
>> MediaCodec state by AMediaCodec_flush.
>>  libavcodec/mediacodecenc.c | 10 ++
>>  1 file changed, 10 insertions(+)
>> diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
>> index e76ea81236..3880ea2fe9 100644
>> --- a/libavcodec/mediacodecenc.c
>> +++ b/libavcodec/mediacodecenc.c
>> @@ -429,6 +429,16 @@ static int mediacodec_receive(AVCodecContext *avctx, 
>> AVPacket *pkt)
>>  }
>>if (out_info.flags & ff_AMediaCodec_getBufferFlagCodecConfig(codec)) {
>> +if (avctx->codec_id == AV_CODEC_ID_AV1) {
>> +// Skip AV1CodecConfigurationRecord without configOBUs
>> +if (out_info.size <= 4) {
>> +ff_AMediaCodec_releaseOutputBuffer(codec, index, false);
>> +return mediacodec_receive(avctx, pkt);
>> +}
>> +out_info.size -= 4;
>> +out_info.offset += 4;
>> +}
>> +
>>  ret = av_reallocp(&s->extradata, out_info.size);
>>  if (ret)
>>  goto bailout;
> 
> ___
> 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] avcodec/mediacodecenc: Extract configOBUs from AV1CodecConfigurationRecord

2024-10-04 Thread Zhao Zhili


> On Oct 5, 2024, at 05:01, Martin Storsjö  wrote:
> 
> On Sat, 5 Oct 2024, Zhao Zhili wrote:
> 
>> From: Zhao Zhili 
>> 
>> MediaCodec can generate AV1CodecConfigurationRecord, which shouldn't
>> be put into packet->data. Skip four bytes and extract configOBUs
>> if it exist.
>> ---
>> I did some test on Pixel 8 Pro. AV1 hardware encoding works with a lot
>> of bugs:
>> 
>> 1. It's broken for width non-aligned to 16. For width 1080 and pixel
>> format YUV420P, MediaCodec use 1080 as stride. For pixel format NV12,
>> MediaCodec use 1088 as stride. There is no API to get the stride info.
>> AMEDIAFORMAT_KEY_STRIDE doesn't work. And set stride to MediaCodec has
>> no effect from my test, at least on that device. We know the buffer
>> size provided by MediaCodec, but we still cannot get stride by
>> buf_size / height:
>> 
>> 1) For YUV420P, buf_size = 1080 * height
>> 2) For NV12, buf_size = 1080 + 1088 * (height - 1). Yes, buf_size doesn't
>> count last line's padding :(
> 
> Isn't this pretty much the case for the encoders for other codecs as well - 
> there aren't really any compat guarantees for how they behave for widths that 
> aren't a multiple of 16? At least back when there when Android added CTS 
> tests to guarantee some sort of cross device consistent behaviour, they only 
> tested/mandated the behviour for a couple resolutions, that all were even 
> multiples of 16.

> 
> I guess the difference here is whether it's possible to do cropping in the 
> same way as via the h264_metadata/hevc_metadata BSFs?

All codecs have the same issue for dst buffer stride. Yes we can workaround it 
for H.264/H.265 with
h264_metadata/hevc_metadata BSFs. I think we should do the same for AV1.

Even without dst buffer stride issue, some devices still have align requirement 
on video size. For
example, when send frame to encoder via Surface/ANativeWindow, there is no 
explicit memcpy and
OS handles alignment of the underlying buffer. A 1080x1920 video turn into 
1072x1920 after encoding
with MediaTek device (not with FFmpeg MediaCodec wrapper but call MediaCodec 
API directly in App).
Take care of alignment/crop within our wrapper rather than leave it to OS 
implementation resolved these
mess.

> 
> // Martin
> 
> ___
> 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] avcodec/libx265: unbreak build for X265_BUILD >= 213

2024-10-04 Thread Gyan Doshi
Earlier, x265 made an API change to support alpha and
other multiple layer pictures. We added guards to accommodate
that in 1f801dfdb5

They have now reverted that API change in
https://bitbucket.org/multicoreware/x265_git/commits/78e5b703b1

Updated our wrapper guards to unbreak build again.
---
 libavcodec/libx265.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 513f473307..63cc497f83 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -661,7 +661,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 {
 libx265Context *ctx = avctx->priv_data;
 x265_picture x265pic;
-#if X265_BUILD >= 210
+#if (X265_BUILD >= 210) && (X265_BUILD < 213)
 x265_picture x265pic_layers_out[MAX_SCALABLE_LAYERS];
 x265_picture* x265pic_lyrptr_out[MAX_SCALABLE_LAYERS];
 #else
@@ -805,7 +805,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 #endif
 }
 
-#if X265_BUILD >= 210
+#if (X265_BUILD >= 210) && (X265_BUILD < 213)
 for (i = 0; i < MAX_SCALABLE_LAYERS; i++)
 x265pic_lyrptr_out[i] = &x265pic_layers_out[i];
 
@@ -844,7 +844,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 pkt->flags |= AV_PKT_FLAG_KEY;
 }
 
-#if X265_BUILD >= 210
+#if (X265_BUILD >= 210) && (X265_BUILD < 213)
 x265pic_out = x265pic_lyrptr_out[0];
 #else
 x265pic_out = &x265pic_solo_out;
-- 
2.46.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 4/4] lavc/vulkan: add SPIR-V compilation support

2024-10-04 Thread Lynne via ffmpeg-devel

On 04/10/2024 12:01, epira...@gmail.com wrote:

On 4 Oct 2024, at 11:31, Lynne via ffmpeg-devel wrote:


This is the same as with libavfilter.

We will need SPIR-V compilation for at least three different things,
like the VC-2 encoder and decoder, AV1 film grain synthesis for
hardware with no support for it, and possibly other codecs.
---
  libavcodec/Makefile |  4 
  libavcodec/vulkan_glslang.c | 19 +++
  libavcodec/vulkan_shaderc.c | 19 +++
  3 files changed, 42 insertions(+)
  create mode 100644 libavcodec/vulkan_glslang.c
  create mode 100644 libavcodec/vulkan_shaderc.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a253a9b160..7147ed0360 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1257,6 +1257,10 @@ OBJS-$(HAVE_THREADS)   += pthread.o 
pthread_slice.o pthread_fram

  OBJS-$(CONFIG_FRAME_THREAD_ENCODER)+= frame_thread_encoder.o

+# vulkan libs
+OBJS-$(CONFIG_LIBGLSLANG)  += vulkan_glslang.o
+OBJS-$(CONFIG_LIBSHADERC)  += vulkan_shaderc.o
+
  # Windows resource file
  SHLIBOBJS-$(HAVE_GNU_WINDRES)   += avcodecres.o

diff --git a/libavcodec/vulkan_glslang.c b/libavcodec/vulkan_glslang.c
new file mode 100644
index 00..9aa41567a3
--- /dev/null
+++ b/libavcodec/vulkan_glslang.c
@@ -0,0 +1,19 @@
+/*
+ * 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/vulkan_glslang.c"
diff --git a/libavcodec/vulkan_shaderc.c b/libavcodec/vulkan_shaderc.c
new file mode 100644
index 00..9f60bf4dfd
--- /dev/null
+++ b/libavcodec/vulkan_shaderc.c
@@ -0,0 +1,19 @@
+/*
+ * 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/vulkan_shaderc.c"


Wouldn’t this cause duplicate symbol issues with for example ff_vk_shaderc_init
being in both libavfilter and libavcodec?


No. For completely identical objects like we have here, the linker 
deduplicates while linking.
This is how vulkan.c is also handled across libavutil, libavfilter and 
libavcodec. We also handle something else in the same way, but I don't 
remember what.


OpenPGP_0xA2FEA5F03F034464.asc
Description: OpenPGP public key


OpenPGP_signature.asc
Description: OpenPGP digital 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] arm: Consistently use proper interworking function returns

2024-10-04 Thread Martin Storsjö
Use "bx lr", or "pop {lr}", which do proper mode switching
between thumb and arm modes. A plain "mov pc, lr" does not switch
from thumb mode to arm mode (while in arm mode, it does switch
mode for a thumb caller).

This is normally not an issue, as CONFIG_THUMB only is enabled if
the C compiler defaults to thumb; but stick to patterns that can
do mode switching if needed, for consistency.
---
 libswresample/arm/resample.S  | 8 
 libswscale/arm/hscale.S   | 3 +--
 libswscale/arm/output.S   | 3 +--
 libswscale/arm/yuv2rgb_neon.S | 3 +--
 4 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/libswresample/arm/resample.S b/libswresample/arm/resample.S
index 3ce7623246..791f4cc016 100644
--- a/libswresample/arm/resample.S
+++ b/libswresample/arm/resample.S
@@ -30,7 +30,7 @@ function ff_resample_common_apply_filter_x4_float_neon, 
export=1
 vpadd.f32   d0, d0, d1 @ pair 
adding of the 4x32-bit accumulated values
 vpadd.f32   d0, d0, d0 @ pair 
adding of the 4x32-bit accumulator values
 vst1.32 {d0[0]}, [r0]  @ write 
accumulator
-mov pc, lr
+bx  lr
 endfunc
 
 function ff_resample_common_apply_filter_x8_float_neon, export=1
@@ -46,7 +46,7 @@ function ff_resample_common_apply_filter_x8_float_neon, 
export=1
 vpadd.f32   d0, d0, d1 @ pair 
adding of the 4x32-bit accumulated values
 vpadd.f32   d0, d0, d0 @ pair 
adding of the 4x32-bit accumulator values
 vst1.32 {d0[0]}, [r0]  @ write 
accumulator
-mov pc, lr
+bx  lr
 endfunc
 
 function ff_resample_common_apply_filter_x4_s16_neon, export=1
@@ -59,7 +59,7 @@ function ff_resample_common_apply_filter_x4_s16_neon, export=1
 vpadd.s32   d0, d0, d1 @ pair 
adding of the 4x32-bit accumulated values
 vpadd.s32   d0, d0, d0 @ pair 
adding of the 4x32-bit accumulator values
 vst1.32 {d0[0]}, [r0]  @ write 
accumulator
-mov pc, lr
+bx  lr
 endfunc
 
 function ff_resample_common_apply_filter_x8_s16_neon, export=1
@@ -73,5 +73,5 @@ function ff_resample_common_apply_filter_x8_s16_neon, export=1
 vpadd.s32   d0, d0, d1 @ pair 
adding of the 4x32-bit accumulated values
 vpadd.s32   d0, d0, d0 @ pair 
adding of the 4x32-bit accumulator values
 vst1.32 {d0[0]}, [r0]  @ write 
accumulator
-mov pc, lr
+bx  lr
 endfunc
diff --git a/libswscale/arm/hscale.S b/libswscale/arm/hscale.S
index dd4d453957..5c3551a0f1 100644
--- a/libswscale/arm/hscale.S
+++ b/libswscale/arm/hscale.S
@@ -65,6 +65,5 @@ function ff_hscale_8_to_15_neon, export=1
 subsr2, #2 @ dstW 
-= 2
 bgt 1b @ loop 
until end of line
 vpop{q4-q7}
-pop {r4-r12, lr}
-mov pc, lr
+pop {r4-r12, pc}
 endfunc
diff --git a/libswscale/arm/output.S b/libswscale/arm/output.S
index 70846dee1f..5f10585f81 100644
--- a/libswscale/arm/output.S
+++ b/libswscale/arm/output.S
@@ -73,6 +73,5 @@ function ff_yuv2planeX_8_neon, export=1
 subsr4, r4, #8 @ dstW 
-= 8
 bgt 2b @ loop 
until width is consumed
 vpop{q4-q7}
-pop {r4-r12, lr}
-mov pc, lr
+pop {r4-r12, pc}
 endfunc
diff --git a/libswscale/arm/yuv2rgb_neon.S b/libswscale/arm/yuv2rgb_neon.S
index 474465427d..6777d625f9 100644
--- a/libswscale/arm/yuv2rgb_neon.S
+++ b/libswscale/arm/yuv2rgb_neon.S
@@ -262,8 +262,7 @@ function ff_\ifmt\()_to_\ofmt\()_neon, export=1
 increment_and_test_\ifmt
 bgt 1b
 vpop{q4-q7}
-pop {r4-r12, lr}
-mov pc, lr
+pop {r4-r12, pc}
 endfunc
 .endm
 
-- 
2.39.5 (Apple Git-154)

___
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] checkasm: lls: Use relative tolerances rather than absolute ones

2024-10-04 Thread Martin Storsjö
Depending on the magnitude of the output values, the potential
errors can be larger.

This fixes errors in the lls tests on x86_32 for some seeds,
observed with GCC 11 (on Ubuntu 22.04, with the distro compiler,
with -m32).
---
 tests/checkasm/lls.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/tests/checkasm/lls.c b/tests/checkasm/lls.c
index 1e0b56974c..4251032e02 100644
--- a/tests/checkasm/lls.c
+++ b/tests/checkasm/lls.c
@@ -46,28 +46,32 @@ static void test_update(LLSModel *lls, const double *var)
 call_new(lls, var);
 
 for (size_t i = 0; i < lls->indep_count; i++)
-for (size_t j = i; j < lls->indep_count; j++)
+for (size_t j = i; j < lls->indep_count; j++) {
+double eps = FFMAX(2 * DBL_EPSILON * fabs(refcovar[i][j]),
+   8 * DBL_EPSILON);
 if (!double_near_abs_eps(refcovar[i][j], lls->covariance[i][j],
- 8 * DBL_EPSILON)) {
+ eps)) {
 fprintf(stderr, "%zu, %zu: %- .12f - %- .12f = % .12g\n", i, j,
 refcovar[i][j], lls->covariance[i][j],
 refcovar[i][j] - lls->covariance[i][j]);
 fail();
 }
+}
 
 bench_new(lls, var);
 }
 
-#define EPS 0.2
 static void test_evaluate(LLSModel *lls, const double *param, int order)
 {
-double refprod, newprod;
+double refprod, newprod, eps;
 declare_func_float(double, LLSModel *, const double *, int);
 
 refprod = call_ref(lls, param, order);
 newprod = call_new(lls, param, order);
 
-if (!double_near_abs_eps(refprod, newprod, EPS)) {
+eps = FFMAX(2 * DBL_EPSILON * fabs(refprod), 0.2);
+
+if (!double_near_abs_eps(refprod, newprod, eps)) {
 fprintf(stderr, "%- .12f - %- .12f = % .12g\n",
 refprod, newprod, refprod - newprod);
 fail();
-- 
2.39.5 (Apple Git-154)

___
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 4/4] lavc/vulkan: add SPIR-V compilation support

2024-10-04 Thread epirat07
On 4 Oct 2024, at 11:31, Lynne via ffmpeg-devel wrote:

> This is the same as with libavfilter.
>
> We will need SPIR-V compilation for at least three different things,
> like the VC-2 encoder and decoder, AV1 film grain synthesis for
> hardware with no support for it, and possibly other codecs.
> ---
>  libavcodec/Makefile |  4 
>  libavcodec/vulkan_glslang.c | 19 +++
>  libavcodec/vulkan_shaderc.c | 19 +++
>  3 files changed, 42 insertions(+)
>  create mode 100644 libavcodec/vulkan_glslang.c
>  create mode 100644 libavcodec/vulkan_shaderc.c
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index a253a9b160..7147ed0360 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1257,6 +1257,10 @@ OBJS-$(HAVE_THREADS)   += pthread.o 
> pthread_slice.o pthread_fram
>
>  OBJS-$(CONFIG_FRAME_THREAD_ENCODER)+= frame_thread_encoder.o
>
> +# vulkan libs
> +OBJS-$(CONFIG_LIBGLSLANG)  += vulkan_glslang.o
> +OBJS-$(CONFIG_LIBSHADERC)  += vulkan_shaderc.o
> +
>  # Windows resource file
>  SHLIBOBJS-$(HAVE_GNU_WINDRES)   += avcodecres.o
>
> diff --git a/libavcodec/vulkan_glslang.c b/libavcodec/vulkan_glslang.c
> new file mode 100644
> index 00..9aa41567a3
> --- /dev/null
> +++ b/libavcodec/vulkan_glslang.c
> @@ -0,0 +1,19 @@
> +/*
> + * 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/vulkan_glslang.c"
> diff --git a/libavcodec/vulkan_shaderc.c b/libavcodec/vulkan_shaderc.c
> new file mode 100644
> index 00..9f60bf4dfd
> --- /dev/null
> +++ b/libavcodec/vulkan_shaderc.c
> @@ -0,0 +1,19 @@
> +/*
> + * 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/vulkan_shaderc.c"

Wouldn’t this cause duplicate symbol issues with for example ff_vk_shaderc_init
being in both libavfilter and libavcodec?

> -- 
> 2.45.2.753.g447d99e1c3b
> ___
> 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 v3] avformat/hlsenc: Respect `omit_endlist` flag in subtitle playlists

2024-10-04 Thread Steven Liu
Jonathan Baecker  于2024年10月1日周二 07:56写道:
>
> This modification applies Steven's suggestion.
>
> Original description was:
> Ensure that when the `-hls_flags omit_endlist` option is set,
> the `#EXT-X-ENDLIST` tag is also omitted from the `stream_vtt.m3u8`
> subtitle playlist. This maintains consistency with the behavior
> in other playlists when `omit_endlist` is specified.
> ---
>  libavformat/hlsenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 571d6b2752..c258fc812d 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1676,7 +1676,7 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
>  }
>  }
>
> -if (last)
> +if (last && !(hls->flags & HLS_OMIT_ENDLIST))
>  ff_hls_write_end_list(hls->sub_m3u8_out);
>
>  }
> --
> 2.46.2
>
> ___
> 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".


lgtm

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

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


Re: [FFmpeg-devel] [PATCH v3] avformat/hlsenc: Respect `append_list` flag in subtitle

2024-10-04 Thread Steven Liu
Jonathan Baecker  于2024年10月1日周二 03:51写道:
>
> Apply Stevens suggestion.
>
> Original description:
> Ensure that when the `-hls_flags append_list` option is set,
> that *.vtt files in stream_vtt.m3u8 are correctly updated.
> This fixes https://trac.ffmpeg.org/ticket/11208
> ---
>  libavformat/hlsenc.c | 30 ++
>  1 file changed, 30 insertions(+)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 571d6b2752..8d4322796d 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1202,6 +1202,22 @@ static int hls_append_segment(struct AVFormatContext 
> *s, HLSContext *hls,
>  return 0;
>  }
>
> +static int extract_segment_number(const char *filename) {
> +const char *dot = strrchr(filename, '.');
> +const char *num_start = dot - 1;
> +
> +while (num_start > filename && *num_start >= '0' && *num_start <= '9') {
> +num_start--;
> +}
> +
> +num_start++;
> +
> +if (num_start == dot)
> +return -1;
> +
> +return atoi(num_start);
> +}
> +
>  static int parse_playlist(AVFormatContext *s, const char *url, VariantStream 
> *vs)
>  {
>  HLSContext *hls = s->priv_data;
> @@ -1295,6 +1311,20 @@ static int parse_playlist(AVFormatContext *s, const 
> char *url, VariantStream *vs
>  goto fail;
>  }
>  ff_format_set_url(vs->avf, new_file);
> +
> +if (vs->has_subtitle) {
> +int vtt_index = extract_segment_number(line);
> +const char *vtt_basename = av_basename(vs->vtt_basename);
> +int len = strlen(vtt_basename) + 11;
> +char *vtt_file = av_mallocz(len);
> +if (!vtt_file) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
> +snprintf(vtt_file, len, vtt_basename, vtt_index);
> +ff_format_set_url(vs->vtt_avf, vtt_file);
> +}
> +
>  is_segment = 0;
>  new_start_pos = avio_tell(vs->avf->pb);
>  vs->size = new_start_pos - vs->start_pos;
> --
> 2.46.2
>
> ___
> 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".

LGTM
Will apply after 48 hours if no more comments.


Thanks
Steven
___
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] libavformat/hlsplaylist: add subtitle_varname for naming subtitle streams

2024-10-04 Thread Steven Liu
Jonathan Baecker  于2024年9月29日周日 05:56写道:
>
> If 'sname:*' is set in the var_stream_map variable, use it as
> the NAME attribute for subtitles. This improves the naming of
> subtitle streams in HTML players, providing clearer and more
> descriptive labels for users.
> ---
>  doc/muxers.texi   | 5 +++--
>  libavformat/hlsenc.c  | 7 ++-
>  libavformat/hlsplaylist.c | 9 +++--
>  libavformat/hlsplaylist.h | 2 +-
>  4 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index ce93ba1488..04b7f20b7e 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -2436,13 +2436,14 @@ ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 
> 1000k \
>  @item
>  Create a single variant stream. Add the @code{#EXT-X-MEDIA} tag with
>  @code{TYPE=SUBTITLES} in the master playlist with webvtt subtitle group name
> -'subtitle'. Make sure the input file has one text subtitle stream at least.
> +'subtitle' and optional subtitle name, e.g. 'English'. Make sure the input
> +file has one text subtitle stream at least.
>  @example
>  ffmpeg -y -i input_with_subtitle.mkv \
>   -b:v:0 5250k -c:v h264 -pix_fmt yuv420p -profile:v main -level 4.1 \
>   -b:a:0 256k \
>   -c:s webvtt -c:a mp2 -ar 48000 -ac 2 -map 0:v -map 0:a:0 -map 0:s:0 \
> - -f hls -var_stream_map "v:0,a:0,s:0,sgroup:subtitle" \
> + -f hls -var_stream_map "v:0,a:0,s:0,sgroup:subtitle,sname:English" \
>   -master_pl_name master.m3u8 -t 300 -hls_time 10 -hls_init_time 4 
> -hls_list_size \
>   10 -master_pl_publish_rate 10 -hls_flags \
>   delete_segments+discont_start+split_by_time ./tmp/video.m3u8
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 1e932b7b0e..7b2145f5bf 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -189,6 +189,7 @@ typedef struct VariantStream {
>  const char *sgroup;   /* subtitle group name */
>  const char *ccgroup;  /* closed caption group name */
>  const char *varname;  /* variant name */
> +const char *subtitle_varname;  /* subtitle variant name */
>  } VariantStream;
>
>  typedef struct ClosedCaptionsStream {
> @@ -1533,7 +1534,8 @@ static int create_master_playlist(AVFormatContext *s,
>  break;
>  }
>
> -ff_hls_write_subtitle_rendition(hls->m3u8_out, sgroup, 
> vtt_m3u8_rel_name, vs->language, i, hls->has_default_key ? vs->is_default : 
> 1);
> +ff_hls_write_subtitle_rendition(hls->m3u8_out, sgroup, 
> vtt_m3u8_rel_name, vs->language,
> +vs->subtitle_varname, i, hls->has_default_key ? 
> vs->is_default : 1);
>  }
>
>  if (!hls->has_default_key || !hls->has_video_m3u8) {
> @@ -2107,6 +2109,9 @@ static int 
> parse_variant_stream_mapstring(AVFormatContext *s)
>  } else if (av_strstart(keyval, "name:", &val)) {
>  vs->varname  = val;
>  continue;
> +} else if (av_strstart(keyval, "sname:", &val)) {
> +vs->subtitle_varname  = val;
> +continue;
>  } else if (av_strstart(keyval, "agroup:", &val)) {
>  vs->agroup   = val;
>  continue;
> diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c
> index f8a6977702..17b93a5ef1 100644
> --- a/libavformat/hlsplaylist.c
> +++ b/libavformat/hlsplaylist.c
> @@ -57,13 +57,18 @@ void ff_hls_write_audio_rendition(AVIOContext *out, const 
> char *agroup,
>
>  void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup,
>   const char *filename, const char 
> *language,
> - int name_id, int is_default)
> + const char *sname, int name_id, int 
> is_default)
>  {
>  if (!out || !filename)
>  return;
>
>  avio_printf(out, "#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"%s\"", sgroup);
> -avio_printf(out, ",NAME=\"subtitle_%d\",DEFAULT=%s,", name_id, 
> is_default ? "YES" : "NO");
> +if (sname) {
> +avio_printf(out, ",NAME=\"%s\",", sname);
> +} else {
> +avio_printf(out, ",NAME=\"subtitle_%d\",", name_id);
> +}
> +avio_printf(out, "DEFAULT=%s,", is_default ? "YES" : "NO");
>  if (language) {
>  avio_printf(out, "LANGUAGE=\"%s\",", language);
>  }
> diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
> index d7aa44d8dc..ec44e5a0ae 100644
> --- a/libavformat/hlsplaylist.h
> +++ b/libavformat/hlsplaylist.h
> @@ -41,7 +41,7 @@ void ff_hls_write_audio_rendition(AVIOContext *out, const 
> char *agroup,
>int name_id, int is_default, int 
> nb_channels);
>  void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup,
>   const char *filename, const char 
> *language,
> - int name_id, int is_default);
> + const char *sname, int name_id

Re: [FFmpeg-devel] [PATCH v3 1/3] avcodec: make a local copy of executor

2024-10-04 Thread Nuo Mi
>
>>
>> Should probably use a different namespace for this header, to ensure it
>> doesn't conflict with the lavu one. So just prefix everything with FF
>> instead of AV.
>>
> Sure. It is fixed by v4.
>
v4 applied.
___
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] libavutil/vulkan: Prevent crash on shaders with no descriptors

2024-10-04 Thread IndecisiveTurtle
 Needed to prevent crashes on vc2 vulkan encoder patch
---
 libavutil/vulkan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 44552e97b8..cd617496dc 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -2022,7 +2022,7 @@ static inline FFVulkanShaderData 
*get_shd_data(FFVkExecContext *e,
 for (int i = 0; i < e->parent->nb_reg_shd; i++)
 if (e->parent->reg_shd[i].shd == shd)
 return &e->parent->reg_shd[i];
-av_assert0(0);
+return NULL;
 }
 
 static inline void update_set_descriptor(FFVulkanContext *s, FFVkExecContext 
*e,
@@ -2239,7 +2239,7 @@ void ff_vk_exec_bind_shader(FFVulkanContext *s, 
FFVkExecContext *e,
 vk->CmdBindPipeline(e->buf, shd->bind_point, shd->pipeline);
 }
 
-if (sd->nb_descriptor_sets) {
+if (sd && sd->nb_descriptor_sets) {
 if (s->extensions & FF_VK_EXT_DESCRIPTOR_BUFFER) {
 for (int i = 0; i < sd->nb_descriptor_sets; i++)
 offsets[i] = shd->desc_set[i].singular ? 0 : 
shd->desc_set[i].aligned_size*e->idx;
-- 
2.46.2

___
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] avcodec/mfenc: add support for AV1 MF encoders

2024-10-04 Thread Dash Santosh
>From 77c708805c52302861650cf770f6c32a33590e90 Mon Sep 17 00:00:00 2001
From: Min Chen 
Date: Fri, 4 Oct 2024 23:04:04 +0530
Subject: [PATCH] avcodec/mfenc: add support for AV1 MF encoders
X-Unsent: 1
To: ffmpeg-devel@ffmpeg.org

Signed-off-by: Dash Santosh 
---
 configure  | 1 +
 libavcodec/allcodecs.c | 1 +
 libavcodec/mf_utils.c  | 2 ++
 libavcodec/mfenc.c | 1 +
 4 files changed, 5 insertions(+)

diff --git a/configure b/configure
index 0247ea08d6..63bc53cc27 100755
--- a/configure
+++ b/configure
@@ -3347,6 +3347,7 @@ av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS"
 av1_mediacodec_decoder_deps="mediacodec"
 av1_mediacodec_encoder_deps="mediacodec"
 av1_mediacodec_encoder_select="extract_extradata_bsf"
+av1_mf_encoder_deps="mediafoundation"
 av1_nvenc_encoder_deps="nvenc NV_ENC_PIC_PARAMS_AV1"
 av1_nvenc_encoder_select="atsc_a53"
 av1_qsv_decoder_select="qsvdec"
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index aa0fc47647..f5317616b7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -838,6 +838,7 @@ extern const FFCodec ff_av1_nvenc_encoder;
 extern const FFCodec ff_av1_qsv_decoder;
 extern const FFCodec ff_av1_qsv_encoder;
 extern const FFCodec ff_av1_amf_encoder;
+extern const FFCodec ff_av1_mf_encoder;
 extern const FFCodec ff_av1_vaapi_encoder;
 extern const FFCodec ff_libopenh264_encoder;
 extern const FFCodec ff_libopenh264_decoder;
diff --git a/libavcodec/mf_utils.c b/libavcodec/mf_utils.c
index 48e3a63efc..f740a6090b 100644
--- a/libavcodec/mf_utils.c
+++ b/libavcodec/mf_utils.c
@@ -240,6 +240,7 @@ static struct GUID_Entry guid_names[] = {
 GUID_ENTRY(MFMediaType_Video),
 GUID_ENTRY(MFAudioFormat_PCM),
 GUID_ENTRY(MFAudioFormat_Float),
+GUID_ENTRY(MFVideoFormat_AV1),
 GUID_ENTRY(MFVideoFormat_H264),
 GUID_ENTRY(MFVideoFormat_H264_ES),
 GUID_ENTRY(ff_MFVideoFormat_HEVC),
@@ -507,6 +508,7 @@ void ff_media_type_dump(void *log, IMFMediaType *type)
 const CLSID *ff_codec_to_mf_subtype(enum AVCodecID codec)
 {
 switch (codec) {
+case AV_CODEC_ID_AV1:   return &MFVideoFormat_AV1;
 case AV_CODEC_ID_H264:  return &MFVideoFormat_H264;
 case AV_CODEC_ID_HEVC:  return &ff_MFVideoFormat_HEVC;
 case AV_CODEC_ID_AC3:   return &MFAudioFormat_Dolby_AC3;
diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index b8f8a25f43..c062d87f11 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -1315,3 +1315,4 @@ static const FFCodecDefault defaults[] = {

 MF_ENCODER(VIDEO, h264,H264, venc_opts, VFMTS, VCAPS, defaults);
 MF_ENCODER(VIDEO, hevc,HEVC, venc_opts, VFMTS, VCAPS, defaults);
+MF_ENCODER(VIDEO, av1, AV1,  venc_opts, VFMTS, VCAPS, defaults);
-- 
2.43.0.windows.1


-- 

* *
  



   

*Dash Santosh*

*Research Engineer, Video Engineering*

Mobile: +91 78679 43737

IndiQube Echo Point, Avinashi Road

Coimbatore - 641 014
--- Begin Message ---
Signed-off-by: Dash Santosh 
---
 configure  | 1 +
 libavcodec/allcodecs.c | 1 +
 libavcodec/mf_utils.c  | 2 ++
 libavcodec/mfenc.c | 1 +
 4 files changed, 5 insertions(+)

diff --git a/configure b/configure
index 0247ea08d6..63bc53cc27 100755
--- a/configure
+++ b/configure
@@ -3347,6 +3347,7 @@ av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS"
 av1_mediacodec_decoder_deps="mediacodec"
 av1_mediacodec_encoder_deps="mediacodec"
 av1_mediacodec_encoder_select="extract_extradata_bsf"
+av1_mf_encoder_deps="mediafoundation"
 av1_nvenc_encoder_deps="nvenc NV_ENC_PIC_PARAMS_AV1"
 av1_nvenc_encoder_select="atsc_a53"
 av1_qsv_decoder_select="qsvdec"
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index aa0fc47647..f5317616b7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -838,6 +838,7 @@ extern const FFCodec ff_av1_nvenc_encoder;
 extern const FFCodec ff_av1_qsv_decoder;
 extern const FFCodec ff_av1_qsv_encoder;
 extern const FFCodec ff_av1_amf_encoder;
+extern const FFCodec ff_av1_mf_encoder;
 extern const FFCodec ff_av1_vaapi_encoder;
 extern const FFCodec ff_libopenh264_encoder;
 extern const FFCodec ff_libopenh264_decoder;
diff --git a/libavcodec/mf_utils.c b/libavcodec/mf_utils.c
index 48e3a63efc..f740a6090b 100644
--- a/libavcodec/mf_utils.c
+++ b/libavcodec/mf_utils.c
@@ -240,6 +240,7 @@ static struct GUID_Entry guid_names[] = {
 GUID_ENTRY(MFMediaType_Video),
 GUID_ENTRY(MFAudioFormat_PCM),
 GUID_ENTRY(MFAudioFormat_Float),
+GUID_ENTRY(MFVideoFormat_AV1),
 GUID_ENTRY(MFVideoFormat_H264),
 GUID_ENTRY(MFVideoFormat_H264_ES),
 GUID_ENTRY(ff_MFVideoFormat_HEVC),
@@ -507,6 +508,7 @@ void ff_media_type_dump(void *log, IMFMediaType *type)
 const CLSID *ff

Re: [FFmpeg-devel] [PATCH] avcodec/mediacodecenc: Extract configOBUs from AV1CodecConfigurationRecord

2024-10-04 Thread James Almer

On 10/4/2024 2:54 PM, Zhao Zhili wrote:

From: Zhao Zhili 

MediaCodec can generate AV1CodecConfigurationRecord, which shouldn't
be put into packet->data. Skip four bytes and extract configOBUs
if it exist.


But why are you removing them from extradata if you only want to prevent 
them to make it to a packet?
You could instead make sure they are not dumped into the packet in the 
memcpy(pkt->data... below this chunk.



---
I did some test on Pixel 8 Pro. AV1 hardware encoding works with a lot
of bugs:

1. It's broken for width non-aligned to 16. For width 1080 and pixel
format YUV420P, MediaCodec use 1080 as stride. For pixel format NV12,
MediaCodec use 1088 as stride. There is no API to get the stride info.
AMEDIAFORMAT_KEY_STRIDE doesn't work. And set stride to MediaCodec has
no effect from my test, at least on that device. We know the buffer
size provided by MediaCodec, but we still cannot get stride by
buf_size / height:

   1) For YUV420P, buf_size = 1080 * height
   2) For NV12, buf_size = 1080 + 1088 * (height - 1). Yes, buf_size doesn't
count last line's padding :(

2. After flush (which means reset for MediaCodec), it doesn't reset GOP
info, so it output a few non-key frames before generate a key frame.
This breaks what I did for AV_CODEC_FLAG_GLOBAL_HEADER: send a dummy
frame, send EOF, get packet and extract extra data, then reset
MediaCodec state by AMediaCodec_flush.

  libavcodec/mediacodecenc.c | 10 ++
  1 file changed, 10 insertions(+)

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index e76ea81236..3880ea2fe9 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -429,6 +429,16 @@ static int mediacodec_receive(AVCodecContext *avctx, 
AVPacket *pkt)
  }
  
  if (out_info.flags & ff_AMediaCodec_getBufferFlagCodecConfig(codec)) {

+if (avctx->codec_id == AV_CODEC_ID_AV1) {
+// Skip AV1CodecConfigurationRecord without configOBUs
+if (out_info.size <= 4) {
+ff_AMediaCodec_releaseOutputBuffer(codec, index, false);
+return mediacodec_receive(avctx, pkt);
+}
+out_info.size -= 4;
+out_info.offset += 4;
+}
+
  ret = av_reallocp(&s->extradata, out_info.size);
  if (ret)
  goto bailout;




OpenPGP_signature.asc
Description: OpenPGP digital 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".