[FFmpeg-cvslog] vc2enc: zero padding of the coefficient buffer

2019-12-17 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Dec 17 14:56:33 2019 
+| [377a095dc37222a373fba00579145e77629a5e81] | committer: Lynne

vc2enc: zero padding of the coefficient buffer

Wavelet types with large amounts of overreading/writing like 9_7 would
write into the padding at high wavelet depths, which would remain and be
read by the next frame's transform and quickly cause artifacts to appear
for subsequent frames.
This fix affects all frames encoded with a non-power-of-two width, with
the artifacts varying between non-observable to very noticeable,
depending on encoder settings, so reencoding is advisable.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=377a095dc37222a373fba00579145e77629a5e81
---

 libavcodec/vc2enc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index d0101e01e4..ba5a03e4ec 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -867,6 +867,7 @@ static int dwt_plane(AVCodecContext *avctx, void *arg)
 for (x = 0; x < p->width; x++) {
 buf[x] = pix[x] - s->diff_offset;
 }
+memset(&buf[x], 0, (p->coef_stride - p->width)*sizeof(dwtcoef));
 buf += p->coef_stride;
 pix += pix_stride;
 }
@@ -876,6 +877,7 @@ static int dwt_plane(AVCodecContext *avctx, void *arg)
 for (x = 0; x < p->width; x++) {
 buf[x] = pix[x] - s->diff_offset;
 }
+memset(&buf[x], 0, (p->coef_stride - p->width)*sizeof(dwtcoef));
 buf += p->coef_stride;
 pix += pix_stride;
 }

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

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

[FFmpeg-cvslog] tiffdec: support embedded ICC profiles

2020-01-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Fri Jan 10 21:55:19 2020 
+| [9e01f171f3b7d408f93ec0409d8f9be1d8b291d8] | committer: Lynne

tiffdec: support embedded ICC profiles

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e01f171f3b7d408f93ec0409d8f9be1d8b291d8
---

 libavcodec/tiff.c | 18 ++
 libavcodec/tiff.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 636614aa28..e8357114de 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1218,6 +1218,8 @@ static void set_sar(TiffContext *s, unsigned tag, 
unsigned num, unsigned den)
 
 static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
 {
+AVFrameSideData *sd;
+GetByteContext gb_temp;
 unsigned tag, type, count, off, value = 0, value2 = 1; // value2 is a 
denominator so init. to 1
 int i, start;
 int pos;
@@ -1643,6 +1645,22 @@ static int tiff_decode_tag(TiffContext *s, AVFrame 
*frame)
 }
 }
 break;
+case TIFF_ICC_PROFILE:
+if (type != TIFF_UNDEFINED)
+return AVERROR_INVALIDDATA;
+
+gb_temp = s->gb;
+bytestream2_seek(&gb_temp, SEEK_SET, off);
+
+if (bytestream2_get_bytes_left(&gb_temp) < count)
+return AVERROR_INVALIDDATA;
+
+sd = av_frame_new_side_data(frame, AV_FRAME_DATA_ICC_PROFILE, count);
+if (!sd)
+return AVERROR(ENOMEM);
+
+bytestream2_get_bufferu(&gb_temp, sd->data, count);
+break;
 case TIFF_ARTIST:
 ADD_METADATA(count, "artist", NULL);
 break;
diff --git a/libavcodec/tiff.h b/libavcodec/tiff.h
index 2184c2c829..c07a5d4fa9 100644
--- a/libavcodec/tiff.h
+++ b/libavcodec/tiff.h
@@ -92,6 +92,7 @@ enum TiffTags {
 TIFF_MODEL_TIEPOINT = 0x8482,
 TIFF_MODEL_PIXEL_SCALE  = 0x830E,
 TIFF_MODEL_TRANSFORMATION= 0x8480,
+TIFF_ICC_PROFILE= 0x8773,
 TIFF_GEO_KEY_DIRECTORY  = 0x87AF,
 TIFF_GEO_DOUBLE_PARAMS  = 0x87B0,
 TIFF_GEO_ASCII_PARAMS   = 0x87B1,

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

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

[FFmpeg-cvslog] lavfi: add Vulkan filtering framework

2020-02-04 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Oct 27 14:44:00 2019 
+| [6fca61bbc917678b3e517be4f6594ce52a16a93c] | committer: Lynne

lavfi: add Vulkan filtering framework

This commit adds a Vulkan filtering infrastructure for libavfilter.
It attempts to abstract as much as possible of the Vulkan API from filters.

The way the hwcontext and the framework are designed permits for parallel,
non-CPU-blocking filtering throughout, with the exception of up/downloading
and mapping.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6fca61bbc917678b3e517be4f6594ce52a16a93c
---

 configure   |   13 +-
 libavfilter/Makefile|2 +
 libavfilter/glslang.cpp |  243 ++
 libavfilter/glslang.h   |   52 ++
 libavfilter/vulkan.c| 1236 +++
 libavfilter/vulkan.h|  323 +
 6 files changed, 1864 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index ad3894f77c..d4c0e31f56 100755
--- a/configure
+++ b/configure
@@ -236,6 +236,7 @@ External library support:
   --enable-libfontconfig   enable libfontconfig, useful for drawtext filter 
[no]
   --enable-libfreetype enable libfreetype, needed for drawtext filter [no]
   --enable-libfribidi  enable libfribidi, improves drawtext filter [no]
+  --enable-libglslang  enable GLSL->SPIRV compilation via libglslang [no]
   --enable-libgme  enable Game Music Emu via libgme [no]
   --enable-libgsm  enable GSM de/encoding via libgsm [no]
   --enable-libiec61883 enable iec61883 via libiec61883 [no]
@@ -1550,11 +1551,11 @@ require_cc(){
 }
 
 require_cpp(){
-name="$1"
-headers="$2"
-classes="$3"
-shift 3
-check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
+log require_cpp "$@"
+name_version="$1"
+name="${1%% *}"
+shift
+check_lib_cpp "$name" "$@" || die "ERROR: $name_version not found"
 }
 
 require_headers(){
@@ -1771,6 +1772,7 @@ EXTERNAL_LIBRARY_LIST="
 libfontconfig
 libfreetype
 libfribidi
+libglslang
 libgme
 libgsm
 libiec61883
@@ -6261,6 +6263,7 @@ enabled fontconfig&& enable libfontconfig
 enabled libfontconfig && require_pkg_config libfontconfig fontconfig 
"fontconfig/fontconfig.h" FcInit
 enabled libfreetype   && require_pkg_config libfreetype freetype2 
"ft2build.h FT_FREETYPE_H" FT_Init_FreeType
 enabled libfribidi&& require_pkg_config libfribidi fribidi fribidi.h 
fribidi_version_info
+enabled libglslang&& require_cpp libglslang 
glslang/SPIRV/GlslangToSpv.h "glslang::TIntermediate*" -lglslang -lOSDependent 
-lHLSL -lOGLCompiler -lSPVRemapper -lSPIRV -lSPIRV-Tools -lSPIRV-Tools-opt 
-lpthread -lstdc++
 enabled libgme&& { check_pkg_config libgme libgme gme/gme.h 
gme_new_emu ||
require libgme gme/gme.h gme_new_emu -lgme 
-lstdc++; }
 enabled libgsm&& { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ead47c2855..d49b8bcefa 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -510,6 +510,8 @@ SKIPHEADERS-$(CONFIG_QSVVPP) += qsvvpp.h
 SKIPHEADERS-$(CONFIG_OPENCL) += opencl.h
 SKIPHEADERS-$(CONFIG_VAAPI)  += vaapi_vpp.h
 
+OBJS-$(CONFIG_LIBGLSLANG)+= glslang.o
+
 TOOLS = graph2dot
 TESTPROGS = drawutils filtfmts formats integral
 
diff --git a/libavfilter/glslang.cpp b/libavfilter/glslang.cpp
new file mode 100644
index 00..497df6e245
--- /dev/null
+++ b/libavfilter/glslang.cpp
@@ -0,0 +1,243 @@
+/*
+ * 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 
+
+extern "C" {
+#include "libavutil/mem.h"
+#include "libavutil/avassert.h"
+}
+
+#include 
+#include 
+#include 
+#include 
+
+#include "glslang.h"
+
+using namespace glslang;
+
+static pthread_mutex_t glslang_mutex = PTHREAD_MUTEX_INITIALIZER;
+static int glslang_refcount

[FFmpeg-cvslog] lavfi: add an avgblur_vulkan filter

2020-02-04 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Oct 27 14:47:18 2019 
+| [a2db7343e02fe4c78c6d301550849a0634f0ac38] | committer: Lynne

lavfi: add an avgblur_vulkan filter

This commit adds a fast avgblur Vulkan filter.
This will reset Intel GPUs on Linux due to a known, two-year-old driver bug
(!834 on mesa's gitlab).

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a2db7343e02fe4c78c6d301550849a0634f0ac38
---

 configure   |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_avgblur_vulkan.c | 406 
 4 files changed, 409 insertions(+)

diff --git a/configure b/configure
index efb62ed354..293754feaa 100755
--- a/configure
+++ b/configure
@@ -3461,6 +3461,7 @@ ass_filter_deps="libass"
 atempo_filter_deps="avcodec"
 atempo_filter_select="rdft"
 avgblur_opencl_filter_deps="opencl"
+avgblur_vulkan_filter_deps="vulkan libglslang"
 azmq_filter_deps="libzmq"
 blackframe_filter_deps="gpl"
 bm3d_filter_deps="avcodec"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 217ba2217a..e3e2f615e1 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -163,6 +163,7 @@ OBJS-$(CONFIG_ATADENOISE_FILTER) += 
vf_atadenoise.o
 OBJS-$(CONFIG_AVGBLUR_FILTER)+= vf_avgblur.o
 OBJS-$(CONFIG_AVGBLUR_OPENCL_FILTER) += vf_avgblur_opencl.o opencl.o \
 opencl/avgblur.o boxblur.o
+OBJS-$(CONFIG_AVGBLUR_VULKAN_FILTER) += vf_avgblur_vulkan.o vulkan.o
 OBJS-$(CONFIG_BBOX_FILTER)   += bbox.o vf_bbox.o
 OBJS-$(CONFIG_BENCH_FILTER)  += f_bench.o
 OBJS-$(CONFIG_BILATERAL_FILTER)  += vf_bilateral.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 747d65a5b0..4acafdd269 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -154,6 +154,7 @@ extern AVFilter ff_vf_ass;
 extern AVFilter ff_vf_atadenoise;
 extern AVFilter ff_vf_avgblur;
 extern AVFilter ff_vf_avgblur_opencl;
+extern AVFilter ff_vf_avgblur_vulkan;
 extern AVFilter ff_vf_bbox;
 extern AVFilter ff_vf_bench;
 extern AVFilter ff_vf_bilateral;
diff --git a/libavfilter/vf_avgblur_vulkan.c b/libavfilter/vf_avgblur_vulkan.c
new file mode 100644
index 00..105d753f73
--- /dev/null
+++ b/libavfilter/vf_avgblur_vulkan.c
@@ -0,0 +1,406 @@
+/*
+ * 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/opt.h"
+#include "vulkan.h"
+#include "internal.h"
+
+#define CGS 32
+
+typedef struct AvgBlurVulkanContext {
+VulkanFilterContext vkctx;
+
+int initialized;
+FFVkExecContext *exec;
+VulkanPipeline *pl_hor;
+VulkanPipeline *pl_ver;
+
+/* Shader updators, must be in the main filter struct */
+VkDescriptorImageInfo input_images[3];
+VkDescriptorImageInfo tmp_images[3];
+VkDescriptorImageInfo output_images[3];
+
+int size_x;
+int size_y;
+int planes;
+} AvgBlurVulkanContext;
+
+static const char blur_kernel[] = {
+C(0, shared vec4 cache[DIR(gl_WorkGroupSize) + FILTER_RADIUS*2 + 1];   
)
+C(0,   
)
+C(0, void distort(const ivec2 pos, const int idx)  
)
+C(0, { 
)
+C(1, const uint cp = DIR(gl_LocalInvocationID) + FILTER_RADIUS;
)
+C(0,   
)
+C(1, cache[cp] = texture(input_img[idx], pos); 
)
+C(0,   
)
+C(1, const ivec2 loc_l = pos - INC(FILTER_RADIUS); 
)
+C(1, cache[cp - FILTER_RADIUS] = texture(input_img[idx], loc_l);   
)
+C(0,   
)
+C(1, const ivec2 loc_h = pos + INC(DIR(gl_WorkGroupSize)); 
)
+C(1, cache[cp + DIR(gl_WorkGroupSize)] = texture(inpu

[FFmpeg-cvslog] lavfi: add an overlay_vulkan filter

2020-02-04 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Oct 27 14:46:16 2019 
+| [7bb443137c656857449d56d1212d09a7018819b0] | committer: Lynne

lavfi: add an overlay_vulkan filter

This commit adds a basic, non-converting overlay filter for Vulkan.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7bb443137c656857449d56d1212d09a7018819b0
---

 configure   |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_overlay_vulkan.c | 463 
 4 files changed, 466 insertions(+)

diff --git a/configure b/configure
index 2dbf4728f8..efb62ed354 100755
--- a/configure
+++ b/configure
@@ -3531,6 +3531,7 @@ openclsrc_filter_deps="opencl"
 overlay_opencl_filter_deps="opencl"
 overlay_qsv_filter_deps="libmfx"
 overlay_qsv_filter_select="qsvvpp"
+overlay_vulkan_filter_deps="vulkan libglslang"
 owdenoise_filter_deps="gpl"
 pan_filter_deps="swresample"
 perspective_filter_deps="gpl"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ed3155670e..217ba2217a 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -323,6 +323,7 @@ OBJS-$(CONFIG_OVERLAY_FILTER)+= 
vf_overlay.o framesync.o
 OBJS-$(CONFIG_OVERLAY_OPENCL_FILTER) += vf_overlay_opencl.o opencl.o \
 opencl/overlay.o framesync.o
 OBJS-$(CONFIG_OVERLAY_QSV_FILTER)+= vf_overlay_qsv.o framesync.o
+OBJS-$(CONFIG_OVERLAY_VULKAN_FILTER) += vf_overlay_vulkan.o vulkan.o
 OBJS-$(CONFIG_OWDENOISE_FILTER)  += vf_owdenoise.o
 OBJS-$(CONFIG_PAD_FILTER)+= vf_pad.o
 OBJS-$(CONFIG_PALETTEGEN_FILTER) += vf_palettegen.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 25e607b359..747d65a5b0 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -307,6 +307,7 @@ extern AVFilter ff_vf_oscilloscope;
 extern AVFilter ff_vf_overlay;
 extern AVFilter ff_vf_overlay_opencl;
 extern AVFilter ff_vf_overlay_qsv;
+extern AVFilter ff_vf_overlay_vulkan;
 extern AVFilter ff_vf_owdenoise;
 extern AVFilter ff_vf_pad;
 extern AVFilter ff_vf_palettegen;
diff --git a/libavfilter/vf_overlay_vulkan.c b/libavfilter/vf_overlay_vulkan.c
new file mode 100644
index 00..7cedcc6e88
--- /dev/null
+++ b/libavfilter/vf_overlay_vulkan.c
@@ -0,0 +1,463 @@
+/*
+ * 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/opt.h"
+#include "vulkan.h"
+#include "internal.h"
+#include "framesync.h"
+
+#define CGROUPS (int [3]){ 32, 32, 1 }
+
+typedef struct OverlayVulkanContext {
+VulkanFilterContext vkctx;
+
+int initialized;
+VulkanPipeline *pl;
+FFVkExecContext *exec;
+FFFrameSync fs;
+FFVkBuffer params_buf;
+
+/* Shader updators, must be in the main filter struct */
+VkDescriptorImageInfo main_images[3];
+VkDescriptorImageInfo overlay_images[3];
+VkDescriptorImageInfo output_images[3];
+VkDescriptorBufferInfo params_desc;
+
+int overlay_x;
+int overlay_y;
+int overlay_w;
+int overlay_h;
+} OverlayVulkanContext;
+
+static const char overlay_noalpha[] = {
+C(0, void overlay_noalpha(int i, ivec2 pos)
)
+C(0, { 
)
+C(1, if ((o_offset[i].x <= pos.x) && (o_offset[i].y <= pos.y) &&
+ (pos.x < (o_offset[i].x + o_size[i].x)) &&
+ (pos.y < (o_offset[i].y + o_size[i].y))) {
)
+C(2, vec4 res = texture(overlay_img[i], pos - o_offset[i]);
)
+C(2, imageStore(output_img[i], pos, res);  
)
+C(1, } else {  
)
+C(2, vec4 res = texture(main_img[i], pos); 
)
+C(2, imageStore(output_img[i], pos, res);  
)
+C(1, } 
)
+C(0, }  

[FFmpeg-cvslog] lavfi: add an scale_vulkan filter

2020-02-04 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Oct 27 14:45:36 2019 
+| [d95c509cc64372f8b37d89310250785224751a90] | committer: Lynne

lavfi: add an scale_vulkan filter

This commit adds a basic, non-converting Vulkan scaling filter.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d95c509cc64372f8b37d89310250785224751a90
---

 configure |   1 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_scale_vulkan.c | 352 ++
 4 files changed, 355 insertions(+)

diff --git a/configure b/configure
index d4c0e31f56..2dbf4728f8 100755
--- a/configure
+++ b/configure
@@ -3598,6 +3598,7 @@ zmq_filter_deps="libzmq"
 zoompan_filter_deps="swscale"
 zscale_filter_deps="libzimg const_nan"
 scale_vaapi_filter_deps="vaapi"
+scale_vulkan_filter_deps="vulkan libglslang"
 vpp_qsv_filter_deps="libmfx"
 vpp_qsv_filter_select="qsvvpp"
 xfade_opencl_filter_deps="opencl"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index d49b8bcefa..ed3155670e 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -365,6 +365,7 @@ OBJS-$(CONFIG_SCALE_CUDA_FILTER) += 
vf_scale_cuda.o vf_scale_cuda.pt
 OBJS-$(CONFIG_SCALE_NPP_FILTER)  += vf_scale_npp.o scale_eval.o
 OBJS-$(CONFIG_SCALE_QSV_FILTER)  += vf_scale_qsv.o
 OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o scale_eval.o 
vaapi_vpp.o
+OBJS-$(CONFIG_SCALE_VULKAN_FILTER)   += vf_scale_vulkan.o vulkan.o
 OBJS-$(CONFIG_SCALE2REF_FILTER)  += vf_scale.o scale_eval.o
 OBJS-$(CONFIG_SCROLL_FILTER) += vf_scroll.o
 OBJS-$(CONFIG_SELECT_FILTER) += f_select.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 5fd93c43ed..25e607b359 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -347,6 +347,7 @@ extern AVFilter ff_vf_scale_cuda;
 extern AVFilter ff_vf_scale_npp;
 extern AVFilter ff_vf_scale_qsv;
 extern AVFilter ff_vf_scale_vaapi;
+extern AVFilter ff_vf_scale_vulkan;
 extern AVFilter ff_vf_scale2ref;
 extern AVFilter ff_vf_scroll;
 extern AVFilter ff_vf_select;
diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
new file mode 100644
index 00..1534f2d716
--- /dev/null
+++ b/libavfilter/vf_scale_vulkan.c
@@ -0,0 +1,352 @@
+/*
+ * 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/opt.h"
+#include "vulkan.h"
+#include "scale_eval.h"
+#include "internal.h"
+
+#define CGROUPS (int [3]){ 32, 32, 1 }
+
+enum ScalerFunc {
+F_BILINEAR = 0,
+F_NEAREST,
+
+F_NB,
+};
+
+typedef struct ScaleVulkanContext {
+VulkanFilterContext vkctx;
+
+int initialized;
+FFVkExecContext *exec;
+VulkanPipeline *pl;
+
+/* Shader updators, must be in the main filter struct */
+VkDescriptorImageInfo input_images[3];
+VkDescriptorImageInfo output_images[3];
+
+enum ScalerFunc scaler;
+char *output_format_string;
+char *w_expr;
+char *h_expr;
+} ScaleVulkanContext;
+
+static const char scale_bilinear[] = {
+C(0, void scale_bilinear(int idx, ivec2 pos)   
 )
+C(0, { 
 )
+C(1, const vec2 npos = (vec2(pos) + 0.5f) / 
imageSize(output_img[idx]); )
+C(1, imageStore(output_img[idx], pos, texture(input_img[idx], npos));  
 )
+C(0, } 
 )
+};
+
+static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
+{
+int err;
+VkSampler *sampler;
+VkFilter sampler_mode;
+ScaleVulkanContext *s = ctx->priv;
+
+switch (s->scaler) {
+case F_NEAREST:
+sampler_mode = VK_FILTER_NEAREST;
+break;
+case F_BILINEAR:
+sampler_mode = VK_FILTER_LINEAR;
+break;
+};
+
+/* Create a sampler */
+sampler = ff_vk_init_sampler(ctx, 0, sampler_mode);
+if (!sampler)
+return AVERROR_EXTERNAL;
+
+s->pl = ff_vk_create_pipeline(ctx);
+if (!s->pl)
+return AV

[FFmpeg-cvslog] lavfi: add an chromaber_vulkan filter

2020-02-04 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Oct 27 14:48:16 2019 
+| [907ae87d6eb702eb12f073df2eac6da2560eae6f] | committer: Lynne

lavfi: add an chromaber_vulkan filter

This commit adds a chromatic aberration filter for Vulkan that attempts to
emulate a lens chromatic aberration effect.
For a YUV frame it will instead shift the chroma channels, providing a
simple approximation.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=907ae87d6eb702eb12f073df2eac6da2560eae6f
---

 configure |   1 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_chromaber_vulkan.c | 340 ++
 4 files changed, 343 insertions(+)

diff --git a/configure b/configure
index 293754feaa..ec4ab96d1d 100755
--- a/configure
+++ b/configure
@@ -3469,6 +3469,7 @@ bm3d_filter_select="dct"
 boxblur_filter_deps="gpl"
 boxblur_opencl_filter_deps="opencl gpl"
 bs2b_filter_deps="libbs2b"
+chromaber_vulkan_filter_deps="vulkan libglslang"
 colorkey_opencl_filter_deps="opencl"
 colormatrix_filter_deps="gpl"
 convolution_opencl_filter_deps="opencl"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index e3e2f615e1..f1a673ce6d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -176,6 +176,7 @@ OBJS-$(CONFIG_BOXBLUR_FILTER)+= 
vf_boxblur.o boxblur.o
 OBJS-$(CONFIG_BOXBLUR_OPENCL_FILTER) += vf_avgblur_opencl.o opencl.o \
 opencl/avgblur.o boxblur.o
 OBJS-$(CONFIG_BWDIF_FILTER)  += vf_bwdif.o yadif_common.o
+OBJS-$(CONFIG_CHROMABER_VULKAN_FILTER)   += vf_chromaber_vulkan.o vulkan.o
 OBJS-$(CONFIG_CHROMAHOLD_FILTER) += vf_chromakey.o
 OBJS-$(CONFIG_CHROMAKEY_FILTER)  += vf_chromakey.o
 OBJS-$(CONFIG_CHROMASHIFT_FILTER)+= vf_chromashift.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 4acafdd269..1052978cd4 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -88,6 +88,7 @@ extern AVFilter ff_af_bandreject;
 extern AVFilter ff_af_bass;
 extern AVFilter ff_af_biquad;
 extern AVFilter ff_af_bs2b;
+extern AVFilter ff_vf_chromaber_vulkan;
 extern AVFilter ff_af_channelmap;
 extern AVFilter ff_af_channelsplit;
 extern AVFilter ff_af_chorus;
diff --git a/libavfilter/vf_chromaber_vulkan.c 
b/libavfilter/vf_chromaber_vulkan.c
new file mode 100644
index 00..673b3a7a68
--- /dev/null
+++ b/libavfilter/vf_chromaber_vulkan.c
@@ -0,0 +1,340 @@
+/*
+ * 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/opt.h"
+#include "vulkan.h"
+#include "internal.h"
+
+#define CGROUPS (int [3]){ 32, 32, 1 }
+
+typedef struct ChromaticAberrationVulkanContext {
+VulkanFilterContext vkctx;
+
+int initialized;
+FFVkExecContext *exec;
+VulkanPipeline *pl;
+
+/* Shader updators, must be in the main filter struct */
+VkDescriptorImageInfo input_images[3];
+VkDescriptorImageInfo output_images[3];
+
+/* Push constants / options */
+struct {
+float dist[2];
+} opts;
+} ChromaticAberrationVulkanContext;
+
+static const char distort_chroma_kernel[] = {
+C(0, void distort_rgb(ivec2 size, ivec2 pos)   
)
+C(0, { 
)
+C(1, const vec2 p = ((vec2(pos)/vec2(size)) - 0.5f)*2.0f;  
)
+C(1, const vec2 o = p * (dist - 1.0f); 
)
+C(0,   
)
+C(1, vec4 res; 
)
+C(1, res.r = texture(input_img[0], ((p - o)/2.0f) + 0.5f).r;   
)
+C(1, res.g = texture(input_img[0], ((p)/2.0f) + 0.5f).g;   
)
+C(1, res.b = texture(input_img[0], ((p + o)/2.0f) + 0.5f).b;   
)
+C(1, res.a = texture(input_img[0], ((p)/2.0f) + 0.5f).a;   
)
+C(1, imageStore(output_img[0], pos, res);   

[FFmpeg-cvslog] lavu: bump minor version for the Vulkan patchset

2020-02-04 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Feb  4 23:49:56 2020 
+| [73a8c8e6e47097059faaf758b7056d6657b6] | committer: Lynne

lavu: bump minor version for the Vulkan patchset

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=73a8c8e6e47097059faaf758b7056d6657b6
---

 libavutil/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/version.h b/libavutil/version.h
index af8f614aff..2bc1b98615 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  38
+#define LIBAVUTIL_VERSION_MINOR  39
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

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

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

[FFmpeg-cvslog] lavfi: bump minor version for the Vulkan filters

2020-02-04 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Feb  4 23:52:29 2020 
+| [a71a5d9214eb191394b3104c8b5d7766654e323a] | committer: Lynne

lavfi: bump minor version for the Vulkan filters

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a71a5d9214eb191394b3104c8b5d7766654e323a
---

 libavfilter/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/version.h b/libavfilter/version.h
index 6bace48d9a..4f1e7b1bf9 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR   7
-#define LIBAVFILTER_VERSION_MINOR  73
+#define LIBAVFILTER_VERSION_MINOR  74
 #define LIBAVFILTER_VERSION_MICRO 100
 
 

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

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

[FFmpeg-cvslog] doc/APIchanges: update with Vulkan commit info

2020-02-04 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Feb  4 23:51:55 2020 
+| [ee81713fe39548be62b699d934fbe4a48cb6b142] | committer: Lynne

doc/APIchanges: update with Vulkan commit info

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ee81713fe39548be62b699d934fbe4a48cb6b142
---

 doc/APIchanges | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 31ddc0abfb..e9bea1daee 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,7 +15,7 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
-2020-ww-xx - xx - lavu yy.yy.yyy - hwcontext.h
+2020-ww-xx - xx - lavu 56.39.100 - hwcontext.h
   Add AV_PIX_FMT_VULKAN
   Add AV_HWDEVICE_TYPE_VULKAN and implementation.
 

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

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

[FFmpeg-cvslog] lavu/tx: mention FFT output is not normalized

2020-02-08 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Feb  8 23:06:09 2020 
+| [d500eff3cce7ab0c6f7101860b633ca955a9f85e] | committer: Lynne

lavu/tx: mention FFT output is not normalized

Not even FFTW's output is normalized.
This should prevent at least some users from complaining that doing a forward
transform followed by an inverse transform has a mismatching output to the
original input.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d500eff3cce7ab0c6f7101860b633ca955a9f85e
---

 libavutil/tx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/tx.h b/libavutil/tx.h
index d6cdfdf9f2..8b405c0021 100644
--- a/libavutil/tx.h
+++ b/libavutil/tx.h
@@ -35,7 +35,7 @@ typedef struct AVComplexDouble {
 enum AVTXType {
 /**
  * Standard complex to complex FFT with sample data type AVComplexFloat.
- * Scaling currently unsupported
+ * Output is not 1/len normalized. Scaling currently unsupported.
  */
 AV_TX_FLOAT_FFT = 0,
 /**

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

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

[FFmpeg-cvslog] doc/APIchanges: fix vulkan hwcontext date

2020-02-08 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Feb  8 23:32:46 2020 
+| [9b9f441ab39d12086bfae044094dbcd8979b8d90] | committer: Lynne

doc/APIchanges: fix vulkan hwcontext date

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b9f441ab39d12086bfae044094dbcd8979b8d90
---

 doc/APIchanges | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index e9bea1daee..81969c301c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,7 +15,7 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
-2020-ww-xx - xx - lavu 56.39.100 - hwcontext.h
+2020-02-04 - xx - lavu 56.39.100 - hwcontext.h
   Add AV_PIX_FMT_VULKAN
   Add AV_HWDEVICE_TYPE_VULKAN and implementation.
 

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

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

[FFmpeg-cvslog] lavu/tx: slightly optimize fft15

2020-02-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Mon Feb 10 17:37:34 2020 
+| [223b58c74b4070b5726ed29ddd8df7b343c6b78a] | committer: Lynne

lavu/tx: slightly optimize fft15

Saves 2 additions.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=223b58c74b4070b5726ed29ddd8df7b343c6b78a
---

 libavutil/tx_template.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index 0dafc4ba76..f30f3bf5b6 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -160,8 +160,8 @@ static av_always_inline void NAME(FFTComplex *out, 
FFTComplex *in,
 BF(t[3].im, t[2].re, in[2].re, in[3].re);  
   \
 BF(t[3].re, t[2].im, in[2].im, in[3].im);  
   \

   \
-out[D0*stride].re = in[0].re + in[1].re + in[2].re + in[3].re + in[4].re;  
   \
-out[D0*stride].im = in[0].im + in[1].im + in[2].im + in[3].im + in[4].im;  
   \
+out[D0*stride].re = in[0].re + t[0].re + t[2].re;  
   \
+out[D0*stride].im = in[0].im + t[0].im + t[2].im;  
   \

   \
 SMUL(t[4].re, t[0].re, TX_NAME(ff_cos_53)[2].re, TX_NAME(ff_cos_53)[3].re, 
t[2].re, t[0].re); \
 SMUL(t[4].im, t[0].im, TX_NAME(ff_cos_53)[2].re, TX_NAME(ff_cos_53)[3].re, 
t[2].im, t[0].im); \

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

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

[FFmpeg-cvslog] lavu/tx: undef the correct macro

2020-02-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Mon Feb 10 17:36:45 2020 
+| [a38c6f47c978187c37c0154ced84f1ea4810c7ab] | committer: Lynne

lavu/tx: undef the correct macro

It was renamed and no warning was given for undeffing a nonexisting one.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a38c6f47c978187c37c0154ced84f1ea4810c7ab
---

 libavutil/tx_template.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index d33c9ce351..0dafc4ba76 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -567,7 +567,7 @@ int TX_NAME(ff_tx_init_mdct_fft)(AVTXContext *s, av_tx_fn 
*tx,
 CHECK_FACTOR(n, 15, len)
 CHECK_FACTOR(n,  5, len)
 CHECK_FACTOR(n,  3, len)
-#undef CHECK_NPTWO_FACTOR
+#undef CHECK_FACTOR
 
 /* len must be a power of two now */
 if (!(len & (len - 1)) && len >= 4 && len <= max_ptwo) {

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

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

[FFmpeg-cvslog] lavu/tx: implement 32 bit fixed point FFT and MDCT

2020-02-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Feb  8 23:13:28 2020 
+| [e8f054b095baa194623b3852f06fc507ae697503] | committer: Lynne

lavu/tx: implement 32 bit fixed point FFT and MDCT

Required minimal changes to the code so made sense to implement.
FFT and MDCT tested, the output of both was properly rounded.
Fun fact: the non-power-of-two fixed-point FFT and MDCT are the fastest ever
non-power-of-two fixed-point FFT and MDCT written.
This can replace the power of two integer MDCTs in aac and ac3 if the
MIPS optimizations are ported across.
Unfortunately the ac3 encoder uses a 16-bit fixed point forward transform,
unlike the encoder which uses a 32bit inverse transform, so some modifications
might be required there.

The 3-point FFT is somewhat less accurate than it otherwise could be,
having minor rounding errors with bigger transforms. However, this
could be improved later, and the way its currently written is the way one
would write assembly for it.
Similar rounding errors can also be found throughout the power of two FFTs
as well, though those are more difficult to correct.
Despite this, the integer transforms are more than accurate enough.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e8f054b095baa194623b3852f06fc507ae697503
---

 doc/APIchanges  |   3 ++
 libavutil/Makefile  |   3 +-
 libavutil/tx.c  |  20 ++-
 libavutil/tx.h  |  13 +
 libavutil/tx_int32.c|  21 
 libavutil/tx_priv.h |  61 +++--
 libavutil/tx_template.c | 139 
 libavutil/version.h |   2 +-
 8 files changed, 172 insertions(+), 90 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 30f188d6aa..761f37f2d2 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-02-13 - xx - lavu 56.41.100 - tx.h
+  Add AV_TX_INT32_FFT and AV_TX_INT32_MDCT
+
 2020-02-12 - xx - lavu 56.40.100 - log.h
   Add av_log_once().
 
diff --git a/libavutil/Makefile b/libavutil/Makefile
index b189f9abea..a2dae8e89a 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -163,7 +163,8 @@ OBJS = adler32.o
\
tea.o\
tx.o \
tx_float.o   \
-   tx_double.o
+   tx_double.o  \
+   tx_int32.o
 
 OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o
 OBJS-$(CONFIG_D3D11VA)  += hwcontext_d3d11va.o
diff --git a/libavutil/tx.c b/libavutil/tx.c
index b8683b416b..3b0568a5e1 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -18,6 +18,18 @@
 
 #include "tx_priv.h"
 
+int ff_tx_type_is_mdct(enum AVTXType type)
+{
+switch (type) {
+case AV_TX_FLOAT_MDCT:
+case AV_TX_DOUBLE_MDCT:
+case AV_TX_INT32_MDCT:
+return 1;
+default:
+return 0;
+}
+}
+
 /* Calculates the modular multiplicative inverse, not fast, replace */
 static av_always_inline int mulinv(int n, int m)
 {
@@ -35,11 +47,10 @@ int ff_tx_gen_compound_mapping(AVTXContext *s)
 const int n = s->n;
 const int m = s->m;
 const int inv   = s->inv;
-const int type  = s->type;
 const int len   = n*m;
 const int m_inv = mulinv(m, n);
 const int n_inv = mulinv(n, m);
-const int mdct  = type == AV_TX_FLOAT_MDCT || type == AV_TX_DOUBLE_MDCT;
+const int mdct  = ff_tx_type_is_mdct(s->type);
 
 if (!(s->pfatab = av_malloc(2*len*sizeof(*s->pfatab
 return AVERROR(ENOMEM);
@@ -128,6 +139,11 @@ av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, 
enum AVTXType type,
 if ((err = ff_tx_init_mdct_fft_double(s, tx, type, inv, len, scale, 
flags)))
 goto fail;
 break;
+case AV_TX_INT32_FFT:
+case AV_TX_INT32_MDCT:
+if ((err = ff_tx_init_mdct_fft_int32(s, tx, type, inv, len, scale, 
flags)))
+goto fail;
+break;
 default:
 err = AVERROR(EINVAL);
 goto fail;
diff --git a/libavutil/tx.h b/libavutil/tx.h
index 8b405c0021..53018c84e6 100644
--- a/libavutil/tx.h
+++ b/libavutil/tx.h
@@ -32,6 +32,10 @@ typedef struct AVComplexDouble {
 double re, im;
 } AVComplexDouble;
 
+typedef struct AVComplexInt32 {
+int32_t re, im;
+} AVComplexInt32;
+
 enum AVTXType {
 /**
  * Standard complex to complex FFT with sample data type AVComplexFloat.
@@ -51,6 +55,15 @@ enum AVTXType {
  * Same as AV_TX_FLOAT_MDCT with data and scale type of double.
  */
 AV_TX_DOUBLE_MDCT = 3,
+/**
+ * Same as AV_TX_FLOAT_FFT with a data type of AVComplexInt32.
+ */
+AV_TX_INT32_FFT = 4,
+/**
+ * Same as AV_TX_FLOAT_MDCT with data type o

[FFmpeg-cvslog] lavu/tx: improve 3-point fixed precision

2020-02-14 Thread Lynne
ffmpeg | branch: master | Lynne  | Fri Feb 14 19:55:00 2020 
+| [e1c84856bb7d804e74904ba117a2ca9700211082] | committer: Lynne

lavu/tx: improve 3-point fixed precision

There's just no reason not to when its so easy (albeit messy) and its also
reducing the precision of all non-power-of-two transforms that use it.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e1c84856bb7d804e74904ba117a2ca9700211082
---

 libavutil/tx_priv.h |  4 
 libavutil/tx_template.c | 23 ++-
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h
index 6fabea2d4d..e0d980abfb 100644
--- a/libavutil/tx_priv.h
+++ b/libavutil/tx_priv.h
@@ -47,8 +47,6 @@ typedef void FFTComplex;
 
 #if defined(TX_FLOAT) || defined(TX_DOUBLE)
 
-#define MUL(x, y) ((x)*(y))
-
 #define CMUL(dre, dim, are, aim, bre, bim) do {
\
 (dre) = (are) * (bre) - (aim) * (bim); 
\
 (dim) = (are) * (bim) + (aim) * (bre); 
\
@@ -65,8 +63,6 @@ typedef void FFTComplex;
 
 #elif defined(TX_INT32)
 
-#define MUL(x, y) ((int32_t)(((int64_t)(x) * (int64_t)(y) + 0x4000) >> 31))
-
 /* Properly rounds the result */
 #define CMUL(dre, dim, are, aim, bre, bim) do {
\
 int64_t accu;  
\
diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index f30f3bf5b6..69158e07f9 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -131,6 +131,9 @@ static av_always_inline void fft3(FFTComplex *out, 
FFTComplex *in,
   ptrdiff_t stride)
 {
 FFTComplex tmp[2];
+#ifdef TX_INT32
+int64_t mtmp[4];
+#endif
 
 BF(tmp[0].re, tmp[1].im, in[1].im, in[2].im);
 BF(tmp[0].im, tmp[1].re, in[1].re, in[2].re);
@@ -138,15 +141,25 @@ static av_always_inline void fft3(FFTComplex *out, 
FFTComplex *in,
 out[0*stride].re = in[0].re + tmp[1].re;
 out[0*stride].im = in[0].im + tmp[1].im;
 
-tmp[0].re = MUL(TX_NAME(ff_cos_53)[0].re, tmp[0].re);
-tmp[0].im = MUL(TX_NAME(ff_cos_53)[0].im, tmp[0].im);
-tmp[1].re = MUL(TX_NAME(ff_cos_53)[1].re, tmp[1].re);
-tmp[1].im = MUL(TX_NAME(ff_cos_53)[1].re, tmp[1].im);
-
+#ifdef TX_INT32
+mtmp[0] = (int64_t)TX_NAME(ff_cos_53)[0].re * tmp[0].re;
+mtmp[1] = (int64_t)TX_NAME(ff_cos_53)[0].im * tmp[0].im;
+mtmp[2] = (int64_t)TX_NAME(ff_cos_53)[1].re * tmp[1].re;
+mtmp[3] = (int64_t)TX_NAME(ff_cos_53)[1].re * tmp[1].im;
+out[1*stride].re = in[0].re - (mtmp[2] + mtmp[0] + 0x4000 >> 31);
+out[1*stride].im = in[0].im - (mtmp[3] - mtmp[1] + 0x4000 >> 31);
+out[2*stride].re = in[0].re - (mtmp[2] - mtmp[0] + 0x4000 >> 31);
+out[2*stride].im = in[0].im - (mtmp[3] + mtmp[1] + 0x4000 >> 31);
+#else
+tmp[0].re = TX_NAME(ff_cos_53)[0].re * tmp[0].re;
+tmp[0].im = TX_NAME(ff_cos_53)[0].im * tmp[0].im;
+tmp[1].re = TX_NAME(ff_cos_53)[1].re * tmp[1].re;
+tmp[1].im = TX_NAME(ff_cos_53)[1].re * tmp[1].im;
 out[1*stride].re = in[0].re - tmp[1].re + tmp[0].re;
 out[1*stride].im = in[0].im - tmp[1].im - tmp[0].im;
 out[2*stride].re = in[0].re - tmp[1].re - tmp[0].re;
 out[2*stride].im = in[0].im - tmp[1].im + tmp[0].im;
+#endif
 }
 
 #define DECL_FFT5(NAME, D0, D1, D2, D3, D4)
   \

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

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

[FFmpeg-cvslog] hwcontext_vulkan: initialize semaphores of DMABUF imports

2020-03-12 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Mar 12 18:01:07 2020 
+| [501bd57bdbc488db93c95d40682ef0b4f01ccec5] | committer: Lynne

hwcontext_vulkan: initialize semaphores of DMABUF imports

There was a recent change in Intel's driver that triggered a driver-internal
error if the semaphore given to the command buffer wasn't initialized.
Given that the specifications require the semaphore to be initialized,
this is within spec. Unlike what's causing it in the first place, which is
that there are no ways to extract/import dma sync objects from DMABUFs,
so we must leave our semaphores bare.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=501bd57bdbc488db93c95d40682ef0b4f01ccec5
---

 libavutil/hwcontext_vulkan.c | 51 +---
 1 file changed, 38 insertions(+), 13 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 51fdbd2489..6c2372f7fb 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1139,12 +1139,19 @@ static int alloc_bind_mem(AVHWFramesContext *hwfc, 
AVVkFrame *f,
 return 0;
 }
 
-static int prepare_frame(AVHWFramesContext *hwfc, AVVkFrame *frame)
+enum PrepMode {
+PREP_MODE_WRITE,
+PREP_MODE_RO_SHADER,
+};
+
+static int prepare_frame(AVHWFramesContext *hwfc, VulkanExecCtx *ectx,
+ AVVkFrame *frame, enum PrepMode pmode)
 {
 VkResult ret;
+VkImageLayout new_layout;
+VkAccessFlags new_access;
 AVHWDeviceContext *ctx = hwfc->device_ctx;
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
-VulkanFramesPriv *s = hwfc->internal->priv;
 const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
 
 VkImageMemoryBarrier img_bar[AV_NUM_DATA_POINTERS] = { 0 };
@@ -1157,13 +1164,24 @@ static int prepare_frame(AVHWFramesContext *hwfc, 
AVVkFrame *frame)
 VkSubmitInfo s_info = {
 .sType= VK_STRUCTURE_TYPE_SUBMIT_INFO,
 .commandBufferCount   = 1,
-.pCommandBuffers  = &s->cmd.buf,
+.pCommandBuffers  = &ectx->buf,
 
 .pSignalSemaphores= frame->sem,
 .signalSemaphoreCount = planes,
 };
 
-ret = vkBeginCommandBuffer(s->cmd.buf, &cmd_start);
+switch (pmode) {
+case PREP_MODE_WRITE:
+new_layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
+new_access = VK_ACCESS_TRANSFER_WRITE_BIT;
+break;
+case PREP_MODE_RO_SHADER:
+new_layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
+new_access = VK_ACCESS_TRANSFER_READ_BIT;
+break;
+}
+
+ret = vkBeginCommandBuffer(ectx->buf, &cmd_start);
 if (ret != VK_SUCCESS)
 return AVERROR_EXTERNAL;
 
@@ -1173,9 +1191,9 @@ static int prepare_frame(AVHWFramesContext *hwfc, 
AVVkFrame *frame)
 for (int i = 0; i < planes; i++) {
 img_bar[i].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
 img_bar[i].srcAccessMask = 0x0;
-img_bar[i].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
+img_bar[i].dstAccessMask = new_access;
 img_bar[i].oldLayout = frame->layout[i];
-img_bar[i].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
+img_bar[i].newLayout = new_layout;
 img_bar[i].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
 img_bar[i].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
 img_bar[i].image = frame->img[i];
@@ -1187,20 +1205,20 @@ static int prepare_frame(AVHWFramesContext *hwfc, 
AVVkFrame *frame)
 frame->access[i] = img_bar[i].dstAccessMask;
 }
 
-vkCmdPipelineBarrier(s->cmd.buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
+vkCmdPipelineBarrier(ectx->buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
  VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
  0, NULL, 0, NULL, planes, img_bar);
 
-ret = vkEndCommandBuffer(s->cmd.buf);
+ret = vkEndCommandBuffer(ectx->buf);
 if (ret != VK_SUCCESS)
 return AVERROR_EXTERNAL;
 
-ret = vkQueueSubmit(s->cmd.queue, 1, &s_info, s->cmd.fence);
+ret = vkQueueSubmit(ectx->queue, 1, &s_info, ectx->fence);
 if (ret != VK_SUCCESS) {
 return AVERROR_EXTERNAL;
 } else {
-vkWaitForFences(hwctx->act_dev, 1, &s->cmd.fence, VK_TRUE, UINT64_MAX);
-vkResetFences(hwctx->act_dev, 1, &s->cmd.fence);
+vkWaitForFences(hwctx->act_dev, 1, &ectx->fence, VK_TRUE, UINT64_MAX);
+vkResetFences(hwctx->act_dev, 1, &ectx->fence);
 }
 
 return 0;
@@ -1371,7 +1389,7 @@ static AVBufferRef *vulkan_pool_alloc(void *opaque, int 
size)
 if (err)
 goto fail;
 
-err = prepare_frame(hwfc, f);
+err = prepare_frame(hwfc, &p->cmd, f, PREP_MODE_WRITE);
 if (err)
 goto fail;
 
@@ -1775,7 +1793,7 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 /* We&

[FFmpeg-cvslog] hwcontext_vulkan: support more than one plane per DMABUF layer

2020-03-12 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Mar 12 18:59:12 2020 
+| [6353b9e4abd8e3e0c9ae743701f38510939fe6f9] | committer: Lynne

hwcontext_vulkan: support more than one plane per DMABUF layer

Requires the dmabuf modifiers extension.
Allows for importing of compressed images with a second plane.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6353b9e4abd8e3e0c9ae743701f38510939fe6f9
---

 libavutil/hwcontext_vulkan.c | 44 ++--
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 626b3ab5b7..f3aa1f0d8c 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1658,24 +1658,20 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 int err = 0;
 VkResult ret;
 AVVkFrame *f;
+int bind_counts = 0;
 AVHWDeviceContext *ctx = hwfc->device_ctx;
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
 VulkanDevicePriv *p = ctx->internal->priv;
 const AVPixFmtDescriptor *fmt_desc = av_pix_fmt_desc_get(hwfc->sw_format);
 const int has_modifiers = p->extensions & EXT_DRM_MODIFIER_FLAGS;
-VkSubresourceLayout plane_data[AV_NUM_DATA_POINTERS];
-VkBindImageMemoryInfo bind_info[AV_NUM_DATA_POINTERS];
+VkSubresourceLayout plane_data[AV_NUM_DATA_POINTERS] = { 0 };
+VkBindImageMemoryInfo bind_info[AV_NUM_DATA_POINTERS] = { 0 };
+VkBindImagePlaneMemoryInfo plane_info[AV_NUM_DATA_POINTERS] = { 0 };
 VkExternalMemoryHandleTypeFlagBits htype = 
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
 
 VK_LOAD_PFN(hwctx->inst, vkGetMemoryFdPropertiesKHR);
 
 for (int i = 0; i < desc->nb_layers; i++) {
-if (desc->layers[i].nb_planes > 1) {
-av_log(ctx, AV_LOG_ERROR, "Cannot import DMABUFS with more than 1 "
-  "plane per layer!\n");
-return AVERROR(EINVAL);
-}
-
 if (drm_to_vulkan_fmt(desc->layers[i].format) == VK_FORMAT_UNDEFINED) {
 av_log(ctx, AV_LOG_ERROR, "Unsupported DMABUF layer format 
%#08x!\n",
desc->layers[i].format);
@@ -1729,10 +1725,13 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL;
 
 for (int i = 0; i < desc->nb_layers; i++) {
+const int planes = desc->layers[i].nb_planes;
+const int signal_p = has_modifiers && (planes > 1);
+
 VkImageDrmFormatModifierExplicitCreateInfoEXT drm_info = {
 .sType = 
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT,
 .drmFormatModifier = desc->objects[0].format_modifier,
-.drmFormatModifierPlaneCount = desc->layers[i].nb_planes,
+.drmFormatModifierPlaneCount = planes,
 .pPlaneLayouts = (const VkSubresourceLayout *)&plane_data,
 };
 
@@ -1759,7 +1758,7 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 .extent.depth  = 1,
 .mipLevels = 1,
 .arrayLayers   = 1,
-.flags = VK_IMAGE_CREATE_ALIAS_BIT,
+.flags = VK_IMAGE_CREATE_ALIAS_BIT | signal_p ? 
VK_IMAGE_CREATE_DISJOINT_BIT : 0x0,
 .tiling= f->tiling,
 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, /* specs say so */
 .usage = DEFAULT_USAGE_FLAGS,
@@ -1767,7 +1766,7 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 .samples   = VK_SAMPLE_COUNT_1_BIT,
 };
 
-for (int j = 0; j < desc->layers[i].nb_planes; j++) {
+for (int j = 0; j < planes; j++) {
 plane_data[j].offset = desc->layers[i].planes[j].offset;
 plane_data[j].rowPitch   = desc->layers[i].planes[j].pitch;
 plane_data[j].size   = 0; /* The specs say so for all 3 */
@@ -1801,16 +1800,25 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 f->layout[i] = image_create_info.initialLayout;
 f->access[i] = 0x0;
 
-/* TODO: Fix to support more than 1 plane per layer */
-bind_info[i].sType  = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO;
-bind_info[i].pNext  = NULL;
-bind_info[i].image  = f->img[i];
-bind_info[i].memory = f->mem[desc->layers[i].planes[0].object_index];
-bind_info[i].memoryOffset = desc->layers[i].planes[0].offset;
+for (int j = 0; j < planes; j++) {
+VkImageAspectFlagBits aspect = j == 0 ? 
VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT :
+   j == 1 ? 
VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXT :
+  

[FFmpeg-cvslog] hwcontext_vulkan: duplicate DMABUF objects before importing them

2020-03-12 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Mar 12 18:03:43 2020 
+| [b31959d776e6da3ff8519121bafae9753f2be20f] | committer: Lynne

hwcontext_vulkan: duplicate DMABUF objects before importing them

The specifications are very vague about who has ownership, and in this case,
Vulkan takes ownership of all DMABUF FDs passed to it, causing errors
to occur if someone gave us images for mapping which were meant to be kept.
The old behavior worked with one-way VAAPI and DMABUF imports, but was broken
with clients like wlroots' dmabuf-capture.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b31959d776e6da3ff8519121bafae9753f2be20f
---

 libavutil/hwcontext_vulkan.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 6c2372f7fb..626b3ab5b7 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1699,15 +1699,16 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 VkImportMemoryFdInfoKHR idesc = {
 .sType  = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
 .handleType = htype,
-.fd = desc->objects[i].fd,
+.fd = dup(desc->objects[i].fd),
 };
 
 ret = pfn_vkGetMemoryFdPropertiesKHR(hwctx->act_dev, htype,
- desc->objects[i].fd, &fdmp);
+ idesc.fd, &fdmp);
 if (ret != VK_SUCCESS) {
 av_log(hwfc, AV_LOG_ERROR, "Failed to get FD properties: %s\n",
vk_ret2str(ret));
 err = AVERROR_EXTERNAL;
+close(idesc.fd);
 goto fail;
 }
 
@@ -1715,8 +1716,10 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 
 err = alloc_mem(ctx, &req, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
 &idesc, &f->flags, &f->mem[i]);
-if (err)
+if (err) {
+close(idesc.fd);
 return err;
+}
 
 f->size[i] = desc->objects[i].size;
 }

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

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

[FFmpeg-cvslog] hwcontext_vulkan: minor corrections for DMABUF mapping

2020-03-12 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Mar 12 16:46:01 2020 
+| [08d0a8992d75bbcffe9e7f3392cc94a7f84fc9df] | committer: Lynne

hwcontext_vulkan: minor corrections for DMABUF mapping

We need to consider the amount of layers instead of the image's planes.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=08d0a8992d75bbcffe9e7f3392cc94a7f84fc9df
---

 libavutil/hwcontext_vulkan.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 0fe88e6b9f..8ed0e6edfa 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1643,7 +1643,6 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 AVHWDeviceContext *ctx = hwfc->device_ctx;
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
 VulkanDevicePriv *p = ctx->internal->priv;
-const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
 const AVPixFmtDescriptor *fmt_desc = av_pix_fmt_desc_get(hwfc->sw_format);
 const int has_modifiers = p->extensions & EXT_DRM_MODIFIER_FLAGS;
 VkSubresourceLayout plane_data[AV_NUM_DATA_POINTERS];
@@ -1696,7 +1695,8 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 
 req.memoryTypeBits = fdmp.memoryTypeBits;
 
-err = alloc_mem(ctx, &req, 0x0, &idesc, &f->flags, &f->mem[i]);
+err = alloc_mem(ctx, &req, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
+&idesc, &f->flags, &f->mem[i]);
 if (err)
 return err;
 
@@ -1789,7 +1789,7 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 }
 
 /* Bind the allocated memory to the images */
-ret = vkBindImageMemory2(hwctx->act_dev, planes, bind_info);
+ret = vkBindImageMemory2(hwctx->act_dev, desc->nb_layers, bind_info);
 if (ret != VK_SUCCESS) {
 av_log(ctx, AV_LOG_ERROR, "Failed to bind memory: %s\n",
vk_ret2str(ret));
@@ -1801,11 +1801,12 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 return 0;
 
 fail:
-for (int i = 0; i < planes; i++) {
+for (int i = 0; i < desc->nb_layers; i++) {
 vkDestroyImage(hwctx->act_dev, f->img[i], hwctx->alloc);
-vkFreeMemory(hwctx->act_dev, f->mem[i], hwctx->alloc);
 vkDestroySemaphore(hwctx->act_dev, f->sem[i], hwctx->alloc);
 }
+for (int i = 0; i < desc->nb_objects; i++)
+vkFreeMemory(hwctx->act_dev, f->mem[i], hwctx->alloc);
 
 av_free(f);
 

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

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

[FFmpeg-cvslog] hwcontext_vulkan: only convert image layout for transfers if necessary

2020-03-12 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Mar 12 16:57:14 2020 
+| [9086af2a0a590c7f576b72379d1708392cd96d5c] | committer: Lynne

hwcontext_vulkan: only convert image layout for transfers if necessary

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9086af2a0a590c7f576b72379d1708392cd96d5c
---

 libavutil/hwcontext_vulkan.c | 46 
 1 file changed, 29 insertions(+), 17 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 8ed0e6edfa..51fdbd2489 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -2437,6 +2437,8 @@ static int transfer_image_buf(AVHWDeviceContext *ctx, 
AVVkFrame *frame,
 VkResult ret;
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
 VulkanDevicePriv *s = ctx->internal->priv;
+
+int bar_num = 0;
 VkPipelineStageFlagBits sem_wait_dst[AV_NUM_DATA_POINTERS];
 
 const int planes = av_pix_fmt_count_planes(pix_fmt);
@@ -2469,29 +2471,39 @@ static int transfer_image_buf(AVHWDeviceContext *ctx, 
AVVkFrame *frame,
 
 /* Change the image layout to something more optimal for transfers */
 for (int i = 0; i < planes; i++) {
-img_bar[i].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
-img_bar[i].srcAccessMask = 0x0;
-img_bar[i].dstAccessMask = to_buf ? VK_ACCESS_TRANSFER_READ_BIT :
+VkImageLayout new_layout = to_buf ? 
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL :
+
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
+VkAccessFlags new_access = to_buf ? VK_ACCESS_TRANSFER_READ_BIT :
 VK_ACCESS_TRANSFER_WRITE_BIT;
-img_bar[i].oldLayout = frame->layout[i];
-img_bar[i].newLayout = to_buf ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL :
-VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
-img_bar[i].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
-img_bar[i].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
-img_bar[i].image = frame->img[i];
-img_bar[i].subresourceRange.levelCount = 1;
-img_bar[i].subresourceRange.layerCount = 1;
-img_bar[i].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
 
 sem_wait_dst[i] = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
 
-frame->layout[i] = img_bar[i].newLayout;
-frame->access[i] = img_bar[i].dstAccessMask;
+/* If the layout matches and we have read access skip the barrier */
+if ((frame->layout[i] == new_layout) && (frame->access[i] & 
new_access))
+continue;
+
+img_bar[bar_num].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+img_bar[bar_num].srcAccessMask = 0x0;
+img_bar[bar_num].dstAccessMask = new_access;
+img_bar[bar_num].oldLayout = frame->layout[i];
+img_bar[bar_num].newLayout = new_layout;
+img_bar[bar_num].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+img_bar[bar_num].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+img_bar[bar_num].image = frame->img[i];
+img_bar[bar_num].subresourceRange.levelCount = 1;
+img_bar[bar_num].subresourceRange.layerCount = 1;
+img_bar[bar_num].subresourceRange.aspectMask = 
VK_IMAGE_ASPECT_COLOR_BIT;
+
+frame->layout[i] = img_bar[bar_num].newLayout;
+frame->access[i] = img_bar[bar_num].dstAccessMask;
+
+bar_num++;
 }
 
-vkCmdPipelineBarrier(s->cmd.buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
- VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
- 0, NULL, 0, NULL, planes, img_bar);
+if (bar_num)
+vkCmdPipelineBarrier(s->cmd.buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
+ VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
+ 0, NULL, 0, NULL, bar_num, img_bar);
 
 /* Schedule a copy for each plane */
 for (int i = 0; i < planes; i++) {

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

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

[FFmpeg-cvslog] changelog: add entry for the Vulkan hwcontext and filters

2020-03-12 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Mar 12 20:20:22 2020 
+| [d778be6e4a0565e9a96adec57339e4c8a2464664] | committer: Lynne

changelog: add entry for the Vulkan hwcontext and filters

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d778be6e4a0565e9a96adec57339e4c8a2464664
---

 Changelog | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Changelog b/Changelog
index db2ca92e8a..d1572553a5 100644
--- a/Changelog
+++ b/Changelog
@@ -46,6 +46,8 @@ version :
 - High Voltage Software ADPCM decoder
 - LEGO Racers ALP (.tun & .pcm) demuxer
 - AMQP 0-9-1 protocol (RabbitMQ)
+- Vulkan support
+- avgblur_vulkan, overlay_vulkan, scale_vulkan and chromaber_vulkan filters
 
 
 version 4.2:

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

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

[FFmpeg-cvslog] diracdec: rewrite golomb reader

2020-03-12 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Mar  1 11:23:53 2020 
+| [675bb1f4f9de76f2c0eb1c8b1be6781a2cd52d29] | committer: Lynne

diracdec: rewrite golomb reader

This version is able to output multiple coefficients at a time and
is able to altogether remove actual golomb code parsing.
Its also able to partially recover the last coefficient in case
the packet is incomplete.

Total decoder performance gain for 8bit 420 1080p lossless: 40%.
Total decoder performance gain for 10bit 420 1080p lossless: 40%.

clang was able to vectorize the loop much better than
my handwritten assembly, but gcc was very naive and didn't.

Lookup table is a rewritten version of vc2hqdecode.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=675bb1f4f9de76f2c0eb1c8b1be6781a2cd52d29
---

 libavcodec/dirac_vlc.c | 1309 
 libavcodec/dirac_vlc.h |   30 +-
 libavcodec/diracdec.c  |   12 +-
 3 files changed, 1102 insertions(+), 249 deletions(-)

diff --git a/libavcodec/dirac_vlc.c b/libavcodec/dirac_vlc.c
index 496d8177cd..fbe28017bc 100644
--- a/libavcodec/dirac_vlc.c
+++ b/libavcodec/dirac_vlc.c
@@ -1,7 +1,4 @@
 /*
- * Copyright (C) 2016 Open Broadcast Systems Ltd.
- * Author2016 Rostislav Pehlivanov 
- *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
@@ -21,232 +18,1114 @@
 
 #include "dirac_vlc.h"
 
-#define LUT_SIZE   (1 << LUT_BITS)
-#define RSIZE_BITS (CHAR_BIT*sizeof(residual))
-
-#define CONVERT_TO_RESIDUE(a, b)   
\
-(((residual)(a)) << (RSIZE_BITS - (b)))
-
-#define INIT_RESIDUE(N)
\
-residual N = 0;
\
-av_unused int32_t N ## _bits  = 0
-
-#define SET_RESIDUE(N, I, B)   
\
-N  = CONVERT_TO_RESIDUE(I, B); 
\
-N ## _bits = B
-
-#define APPEND_RESIDUE(N, M)   
\
-N  |= M >> (N ## _bits);   
\
-N ## _bits  = (N ## _bits + (M ## _bits)) & 0x3F
-
-int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,
-   int bytes, uint8_t *_dst, int coeffs)
-{
-int i, b, c_idx = 0;
-int32_t *dst = (int32_t *)_dst;
-DiracGolombLUT *future[4], *l = &lut_ctx[2*LUT_SIZE + buf[0]];
-INIT_RESIDUE(res);
-
-for (b = 1; b <= bytes; b++) {
-future[0] = &lut_ctx[buf[b]];
-future[1] = future[0] + 1*LUT_SIZE;
-future[2] = future[0] + 2*LUT_SIZE;
-future[3] = future[0] + 3*LUT_SIZE;
-
-if ((c_idx + 1) > coeffs)
-return c_idx;
-
-/* res_bits is a hint for better branch prediction */
-if (res_bits && l->sign) {
-int32_t coeff = 1;
-APPEND_RESIDUE(res, l->preamble);
-for (i = 0; i < (res_bits >> 1) - 1; i++) {
-coeff <<= 1;
-coeff |= (res >> (RSIZE_BITS - 2*i - 2)) & 1;
-}
-dst[c_idx++] = l->sign * (coeff - 1);
-res_bits = res = 0;
-}
-
-memcpy(&dst[c_idx], l->ready, LUT_BITS*sizeof(int32_t));
-c_idx += l->ready_num;
+enum {
+/* Next byte contains an exactly aligned start to a new symbol (even bit) 
*/
+STATE_START  = 0,
+/* Next byte should end the current value on an odd bit */
+STATE_FOLLOW = 256,
+/* Byte is completely data and doesn't end nor start a value */
+STATE_DATA   = 512,
+/* Byte has the current value's sign bit and starts a new value */
+STATE_SIGN   = 768,
+};
 
-APPEND_RESIDUE(res, l->leftover);
+/* Exactly 128 bits */
+typedef struct LUTState {
+int16_t   val0;  /* Bits to which to add after applying preshift */
+int16_t   val1;
+int16_t   val2;
+int16_t   val3;
+int16_t   val4;
+uint8_t   val0_bits; /* The size of val0 in bits */
+int8_tsign;  /* Sign of the current value (0 == zero the value) */
+int8_tnum;   /* Number of values in this byte */
+uint8_t   val;   /* Init value in case current value was terminated */
+uint16_t  state; /* Expected state for the next byte */
+} LUTState;
 
-l = future[l->need_s ? 3 : !res_bits ? 2 : res_bits & 1];
-}
+const DECLARE_ALIGNED(32, LUTState, ff_dirac_golomb_lut)[1024] = {
+{ +16,  0,  0,  0,  0, 5, +1, 0,  0, STATE_FOLLOW },
+{ +17,  0,  0,  0,  0, 5, +1, 0,  0, STATE_FOLLOW },
+{  +8,  0,  0,  0,  0, 4, +1, 1,  0,  STATE_START },
+{  +8,  0,  0,  0,  0, 4, -1, 1,  0,  STATE_START },
+{ +18,  0,  0,  0,  0, 5, +1, 0,  0, STATE_FOLLOW },
+{ +19,  0,  0,  0,  0, 5, +1, 0,  0, STATE_FOLLOW },

[FFmpeg-cvslog] hwcontext_vulkan: fix imported image bitmask

2020-03-17 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Mar 17 13:08:06 2020 
+| [ecc3dceff44b8612c80014d45a514df882883940] | committer: Lynne

hwcontext_vulkan: fix imported image bitmask

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ecc3dceff44b8612c80014d45a514df882883940
---

 libavutil/hwcontext_vulkan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index f3aa1f0d8c..ed88979d0d 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1758,7 +1758,8 @@ static int 
vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
 .extent.depth  = 1,
 .mipLevels = 1,
 .arrayLayers   = 1,
-.flags = VK_IMAGE_CREATE_ALIAS_BIT | signal_p ? 
VK_IMAGE_CREATE_DISJOINT_BIT : 0x0,
+.flags = VK_IMAGE_CREATE_ALIAS_BIT |
+ (signal_p ? VK_IMAGE_CREATE_DISJOINT_BIT : 0x0),
 .tiling= f->tiling,
 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, /* specs say so */
 .usage = DEFAULT_USAGE_FLAGS,

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

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

[FFmpeg-cvslog] scale_vulkan: add support for RGB->YUV conversions

2020-03-17 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Mar 15 10:30:34 2020 
+| [1a5e9ae4d8e5ee34c983f16a280c9a262a3fbf8d] | committer: Lynne

scale_vulkan: add support for RGB->YUV conversions

Only top-left chroma position supported for now.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1a5e9ae4d8e5ee34c983f16a280c9a262a3fbf8d
---

 libavfilter/vf_scale_vulkan.c | 300 +-
 libavfilter/vulkan.c  |  12 ++
 libavfilter/vulkan.h  |   5 +
 3 files changed, 254 insertions(+), 63 deletions(-)

diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
index 1534f2d716..c5c64ae96c 100644
--- a/libavfilter/vf_scale_vulkan.c
+++ b/libavfilter/vf_scale_vulkan.c
@@ -20,6 +20,7 @@
 #include "vulkan.h"
 #include "scale_eval.h"
 #include "internal.h"
+#include "colorspace.h"
 
 #define CGROUPS (int [3]){ 32, 32, 1 }
 
@@ -36,22 +37,67 @@ typedef struct ScaleVulkanContext {
 int initialized;
 FFVkExecContext *exec;
 VulkanPipeline *pl;
+FFVkBuffer params_buf;
 
 /* Shader updators, must be in the main filter struct */
 VkDescriptorImageInfo input_images[3];
 VkDescriptorImageInfo output_images[3];
+VkDescriptorBufferInfo params_desc;
 
 enum ScalerFunc scaler;
-char *output_format_string;
+char *out_format_string;
+enum AVColorRange out_range;
 char *w_expr;
 char *h_expr;
 } ScaleVulkanContext;
 
 static const char scale_bilinear[] = {
-C(0, void scale_bilinear(int idx, ivec2 pos)   
 )
+C(0, vec4 scale_bilinear(int idx, ivec2 pos)   
 )
 C(0, { 
 )
 C(1, const vec2 npos = (vec2(pos) + 0.5f) / 
imageSize(output_img[idx]); )
-C(1, imageStore(output_img[idx], pos, texture(input_img[idx], npos));  
 )
+C(1, return texture(input_img[idx], npos); 
 )
+C(0, } 
 )
+};
+
+static const char rgb2yuv[] = {
+C(0, vec4 rgb2yuv(vec4 src, int fullrange) 
 )
+C(0, { 
 )
+C(1, src *= yuv_matrix;
 )
+C(1, if (fullrange == 1) { 
 )
+C(2, src += vec4(0.0, 0.5, 0.5, 0.0);  
 )
+C(1, } else {  
 )
+C(2, src *= vec4(219.0 / 255.0, 224.0 / 255.0, 224.0 / 255.0, 
1.0); )
+C(2, src += vec4(16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0, 0.0); 
 )
+C(1, } 
 )
+C(1, return src;   
 )
+C(0, } 
 )
+};
+
+static const char write_nv12[] = {
+C(0, void write_nv12(vec4 src, ivec2 pos)  
 )
+C(0, { 
 )
+C(1, imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0));   
 )
+C(1, pos /= ivec2(2);  
 )
+C(1, imageStore(output_img[1], pos, vec4(src.g, src.b, 0.0, 0.0)); 
 )
+C(0, } 
 )
+};
+
+static const char write_420[] = {
+C(0, void write_420(vec4 src, ivec2 pos)   
 )
+C(0, { 
 )
+C(1, imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0));   
 )
+C(1, pos /= ivec2(2);  
 )
+C(1, imageStore(output_img[1], pos, vec4(src.g, 0.0, 0.0, 0.0));   
 )
+C(1, imageStore(output_img[2], pos, vec4(src.b, 0.0, 0.0, 0.0));   
 )
+C(0, } 
 )
+};
+
+static const char write_444[] = {
+C(0, void write_444(vec4 src, ivec2 pos)   
 )
+C(0, { 
 )
+C(1, imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0));   
 )
+C(1, imageStore(output_img[1], pos, vec4(src.g, 0.0, 0.0, 0.0));   
 )
+C(1, imageStore(output_img[2], pos, vec4(src.b, 0.0, 0.0, 0.0));   
 )
 C(0, } 
 )
 };
 
@@ -103,6 +149,16 @@ static av_cold int init_filter(AVFilterContext *ctx, 
AVFrame *in)
 },
 };
 
+VulkanDescriptorSetBinding desc_b = {
+ 

[FFmpeg-cvslog] MAINTAINERS: add myself and my gpg key

2020-03-18 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Mar 17 22:56:03 2020 
+| [2e611cd9c042009fae49ef0f11f1086a5efd7021] | committer: Lynne

MAINTAINERS: add myself and my gpg key

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2e611cd9c042009fae49ef0f11f1086a5efd7021
---

 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 55e2b385b5..ebb0cf1f08 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -79,6 +79,7 @@ Other:
   float_dsp Loren Merritt
   hash  Reimar Doeffinger
   hwcontext_cuda*   Timo Rothenpieler
+  hwcontext_vulkan*     Lynne
   intfloat* Michael Niedermayer
   integer.c, integer.h  Michael Niedermayer
   lzo   Reimar Doeffinger
@@ -89,6 +90,7 @@ Other:
   rational.c, rational.hMichael Niedermayer
   rc4   Reimar Doeffinger
   ripemd.c, ripemd.hJames Almer
+  tx*   Lynne
 
 
 libavcodec
@@ -606,6 +608,7 @@ James Almer   7751 2E8C FD94 A169 57E6 9A7A 
1463 01AD 7376 59E0
 Jean Delvare  7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A
 Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
 Lou Logan (llogan)7D68 DC73 CBEF EABB 671A B6CF 621C 2E28 82F8 DC3A
+Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464
 Michael Niedermayer   9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
 Nicolas George24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93
 Nikolay Aleksandrov   8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1

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

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

[FFmpeg-cvslog] lavu/tx: improve documentation

2020-03-23 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Mar 14 16:10:06 2020 
+| [9f494d1397d123efd23cf772eb381e194785f4ea] | committer: Lynne

lavu/tx: improve documentation

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9f494d1397d123efd23cf772eb381e194785f4ea
---

 libavutil/tx.h | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavutil/tx.h b/libavutil/tx.h
index 53018c84e6..cacfd604d1 100644
--- a/libavutil/tx.h
+++ b/libavutil/tx.h
@@ -40,11 +40,17 @@ enum AVTXType {
 /**
  * Standard complex to complex FFT with sample data type AVComplexFloat.
  * Output is not 1/len normalized. Scaling currently unsupported.
+ * The stride parameter is ignored.
  */
 AV_TX_FLOAT_FFT = 0,
 /**
  * Standard MDCT with sample data type of float and a scale type of
  * float. Length is the frame size, not the window size (which is 2x frame)
+ * For forward transforms, the stride specifies the spacing between each
+ * sample in the output array in bytes. The input must be a flat array.
+ * For inverse transforms, the stride specifies the spacing between each
+ * sample in the input array in bytes. The output will be a flat array.
+ * Stride must be a non-zero multiple of sizeof(float).
  */
 AV_TX_FLOAT_MDCT = 1,
 /**
@@ -53,6 +59,7 @@ enum AVTXType {
 AV_TX_DOUBLE_FFT = 2,
 /**
  * Same as AV_TX_FLOAT_MDCT with data and scale type of double.
+ * Stride must be a non-zero multiple of sizeof(double).
  */
 AV_TX_DOUBLE_MDCT = 3,
 /**
@@ -62,6 +69,7 @@ enum AVTXType {
 /**
  * Same as AV_TX_FLOAT_MDCT with data type of int32_t and scale type of 
float.
  * Only scale values less than or equal to 1.0 are supported.
+ * Stride must be a non-zero multiple of sizeof(int32_t).
  */
 AV_TX_INT32_MDCT = 5,
 };
@@ -75,8 +83,11 @@ enum AVTXType {
  * @param s the transform context
  * @param out the output array
  * @param in the input array
- * @param stride the input or output stride (depending on transform direction)
- * in bytes, currently implemented for all MDCT transforms
+ * @param stride the input or output stride in bytes
+ *
+ * The out and in arrays must be aligned to the maximum required by the CPU
+ * architecture.
+ * The stride must follow the constraints the transform type has specified.
  */
 typedef void (*av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t 
stride);
 

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

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

[FFmpeg-cvslog] lavu/tx: add 2-point FFT transform

2020-03-23 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Feb 25 06:49:26 2020 
+| [2465fe1302f2c87b37496a00ab490061a2a7ce03] | committer: Lynne

lavu/tx: add 2-point FFT transform

By itself, this allows 6-point, 10-point and 30-point transforms.
When the 9-point transform is added it allows for 18-point FFT,
and also for a 36-point MDCT (used by MP3).

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2465fe1302f2c87b37496a00ab490061a2a7ce03
---

 libavutil/tx.h  |  2 +-
 libavutil/tx_template.c | 28 ++--
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/libavutil/tx.h b/libavutil/tx.h
index cacfd604d1..418e8ec1ed 100644
--- a/libavutil/tx.h
+++ b/libavutil/tx.h
@@ -93,7 +93,7 @@ typedef void (*av_tx_fn)(AVTXContext *s, void *out, void *in, 
ptrdiff_t stride);
 
 /**
  * Initialize a transform context with the given configuration
- * Currently power of two lengths from 4 to 131072 are supported, along with
+ * Currently power of two lengths from 2 to 131072 are supported, along with
  * any length decomposable to a power of two and either 3, 5 or 15.
  *
  * @param ctx the context to allocate, will be NULL on error
diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index 69158e07f9..7f4ca2f31e 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -286,6 +286,14 @@ static void fft##n(FFTComplex *z)\
 pass(z,TX_NAME(ff_cos_##n),n4/2);\
 }
 
+static void fft2(FFTComplex *z)
+{
+FFTComplex tmp;
+BF(tmp.re, z[0].re, z[0].re, z[1].re);
+BF(tmp.im, z[0].im, z[0].im, z[1].im);
+z[1] = tmp;
+}
+
 static void fft4(FFTComplex *z)
 {
 FFTSample t1, t2, t3, t4, t5, t6, t7, t8;
@@ -347,8 +355,8 @@ DECL_FFT(65536,32768,16384)
 DECL_FFT(131072,65536,32768)
 
 static void (* const fft_dispatch[])(FFTComplex*) = {
-fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024,
-fft2048, fft4096, fft8192, fft16384, fft32768, fft65536, fft131072
+NULL, fft2, fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512,
+fft1024, fft2048, fft4096, fft8192, fft16384, fft32768, fft65536, fft131072
 };
 
 #define DECL_COMP_FFT(N)   
\
@@ -359,7 +367,7 @@ static void compound_fft_##N##xM(AVTXContext *s, void 
*_out,   \
 FFTComplex *in = _in;  
\
 FFTComplex *out = _out;
\
 FFTComplex fft##N##in[N];  
\
-void (*fftp)(FFTComplex *z) = fft_dispatch[av_log2(m) - 2];
\
+void (*fftp)(FFTComplex *z) = fft_dispatch[av_log2(m)];
\

\
 for (int i = 0; i < m; i++) {  
\
 for (int j = 0; j < N; j++)
\
@@ -383,7 +391,7 @@ static void monolithic_fft(AVTXContext *s, void *_out, void 
*_in,
 {
 FFTComplex *in = _in;
 FFTComplex *out = _out;
-int m = s->m, mb = av_log2(m) - 2;
+int m = s->m, mb = av_log2(m);
 for (int i = 0; i < m; i++)
 out[s->revtab[i]] = in[i];
 fft_dispatch[mb](out);
@@ -398,7 +406,7 @@ static void compound_imdct_##N##xM(AVTXContext *s, void 
*_dst, void *_src, \
 const int m = s->m, len8 = N*m >> 1;   
\
 const int *in_map = s->pfatab, *out_map = in_map + N*m;
\
 const FFTSample *src = _src, *in1, *in2;   
\
-void (*fftp)(FFTComplex *) = fft_dispatch[av_log2(m) - 2]; 
\
+void (*fftp)(FFTComplex *) = fft_dispatch[av_log2(m)]; 
\

\
 stride /= sizeof(*src); /* To convert it from bytes */ 
\
 in1 = src; 
\
@@ -439,7 +447,7 @@ static void compound_mdct_##N##xM(AVTXContext *s, void 
*_dst, void *_src,  \
 FFTComplex *exp = s->exptab, tmp, fft##N##in[N];   
\
 const int m = s->m, len4 = N*m, len3 = len4 * 3, len8 = len4 >> 1; 
\
 const int *in_map = s->pfatab, *out_map = in_map + N*m;
\
-void (*fftp)(FFTComplex *) = fft_dispatch[av_log2(m) - 2]; 
\
+void (*fftp)(FFTComplex *) = fft_dispatch[av_log2(m)]; 
\

\
 stride /= sizeof(*dst);
\

\
@@ -485,7 +493,7 @@ static void monolithic_imdct(AVTXContext *s, void *_dst, 
void *_src,
 FFTComplex *z = _dst, *ex

[FFmpeg-cvslog] movenc: mark Opus encapsulation as stable

2020-03-27 Thread Lynne
ffmpeg | branch: master | Lynne  | Mon Mar 23 22:03:24 2020 
+| [ca7a192d104f08a4dbfda31a6c4f29a1f05074ad] | committer: Lynne

movenc: mark Opus encapsulation as stable

The specifications are de-facto frozen now as they've already been used in
production for years, the author has indicated reluctance on IRC to change
it further, and the only potential changes would, from what I understand,
be forward-compatible.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ca7a192d104f08a4dbfda31a6c4f29a1f05074ad
---

 libavformat/movenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index ce82acf914..1c178fc4bc 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6500,7 +6500,8 @@ static int mov_init(AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "%s only supported in MP4.\n", 
avcodec_get_name(track->par->codec_id));
 return AVERROR(EINVAL);
 }
-if (s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
+if (track->par->codec_id != AV_CODEC_ID_OPUS &&
+s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
 av_log(s, AV_LOG_ERROR,
"%s in MP4 support is experimental, add "
"'-strict %d' if you want to use it.\n",

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

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

[FFmpeg-cvslog] scale_vulkan: correctly copy the colormatrix

2020-04-06 Thread Lynne
ffmpeg | branch: master | Lynne  | Mon Apr  6 19:15:51 2020 
+0100| [ca76a5ba1a35e317d0fb327fffe3ad9add6b7e61] | committer: Lynne

scale_vulkan: correctly copy the colormatrix

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ca76a5ba1a35e317d0fb327fffe3ad9add6b7e61
---

 libavfilter/vf_scale_vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
index c5c64ae96c..4f1e484bc9 100644
--- a/libavfilter/vf_scale_vulkan.c
+++ b/libavfilter/vf_scale_vulkan.c
@@ -251,7 +251,7 @@ static av_cold int init_filter(AVFilterContext *ctx, 
AVFrame *in)
 
 for (int y = 0; y < 3; y++)
 for (int x = 0; x < 3; x++)
-par->yuv_matrix[x][y] = tmp_mat[y][x];
+par->yuv_matrix[x][y] = tmp_mat[x][y];
 
 par->yuv_matrix[3][3] = 1.0;
 

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

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

[FFmpeg-cvslog] hwcontext_vulkan: only use one semaphore per image

2020-04-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Mon Apr  6 18:18:50 2020 
+0100| [97b526c192add6f252b327245fd9223546867352] | committer: Lynne

hwcontext_vulkan: only use one semaphore per image

The idea was to allow separate planes to be filtered independently, however,
in hindsight, literaly nothing uses separate per-plane semaphores and it
would only work when each plane is backed by separate device memory.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=97b526c192add6f252b327245fd9223546867352
---

 libavfilter/vulkan.c |  38 ++--
 libavutil/hwcontext_vulkan.c | 138 ++-
 libavutil/hwcontext_vulkan.h |   4 +-
 3 files changed, 89 insertions(+), 91 deletions(-)

diff --git a/libavfilter/vulkan.c b/libavfilter/vulkan.c
index ff76ab15e9..c103440529 100644
--- a/libavfilter/vulkan.c
+++ b/libavfilter/vulkan.c
@@ -390,32 +390,28 @@ int ff_vk_add_exec_dep(AVFilterContext *avctx, 
FFVkExecContext *e,
AVFrame *frame, VkPipelineStageFlagBits 
in_wait_dst_flag)
 {
 AVVkFrame *f = (AVVkFrame *)frame->data[0];
-AVHWFramesContext *fc = (AVHWFramesContext *)frame->hw_frames_ctx->data;
-int planes = av_pix_fmt_count_planes(fc->sw_format);
 
-for (int i = 0; i < planes; i++) {
-e->sem_wait = av_fast_realloc(e->sem_wait, &e->sem_wait_alloc,
-  (e->sem_wait_cnt + 
1)*sizeof(*e->sem_wait));
-if (!e->sem_wait)
-return AVERROR(ENOMEM);
+e->sem_wait = av_fast_realloc(e->sem_wait, &e->sem_wait_alloc,
+  (e->sem_wait_cnt + 1)*sizeof(*e->sem_wait));
+if (!e->sem_wait)
+return AVERROR(ENOMEM);
 
-e->sem_wait_dst = av_fast_realloc(e->sem_wait_dst, 
&e->sem_wait_dst_alloc,
-  (e->sem_wait_cnt + 
1)*sizeof(*e->sem_wait_dst));
-if (!e->sem_wait_dst)
-return AVERROR(ENOMEM);
+e->sem_wait_dst = av_fast_realloc(e->sem_wait_dst, &e->sem_wait_dst_alloc,
+  (e->sem_wait_cnt + 
1)*sizeof(*e->sem_wait_dst));
+if (!e->sem_wait_dst)
+return AVERROR(ENOMEM);
 
-e->sem_sig = av_fast_realloc(e->sem_sig, &e->sem_sig_alloc,
- (e->sem_sig_cnt + 1)*sizeof(*e->sem_sig));
-if (!e->sem_sig)
-return AVERROR(ENOMEM);
+e->sem_sig = av_fast_realloc(e->sem_sig, &e->sem_sig_alloc,
+ (e->sem_sig_cnt + 1)*sizeof(*e->sem_sig));
+if (!e->sem_sig)
+return AVERROR(ENOMEM);
 
-e->sem_wait[e->sem_wait_cnt] = f->sem[i];
-e->sem_wait_dst[e->sem_wait_cnt] = in_wait_dst_flag;
-e->sem_wait_cnt++;
+e->sem_wait[e->sem_wait_cnt] = f->sem;
+e->sem_wait_dst[e->sem_wait_cnt] = in_wait_dst_flag;
+e->sem_wait_cnt++;
 
-e->sem_sig[e->sem_sig_cnt] = f->sem[i];
-e->sem_sig_cnt++;
-}
+e->sem_sig[e->sem_sig_cnt] = f->sem;
+e->sem_sig_cnt++;
 
 return 0;
 }
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index ed88979d0d..e4546f67ca 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -81,7 +81,7 @@ typedef struct AVVkFrameInternal {
 CUexternalMemory ext_mem[AV_NUM_DATA_POINTERS];
 CUmipmappedArray cu_mma[AV_NUM_DATA_POINTERS];
 CUarray cu_array[AV_NUM_DATA_POINTERS];
-CUexternalSemaphore cu_sem[AV_NUM_DATA_POINTERS];
+CUexternalSemaphore cu_sem;
 #endif
 } AVVkFrameInternal;
 
@@ -1042,9 +1042,10 @@ static void vulkan_free_internal(AVVkFrameInternal 
*internal)
 AVCUDADeviceContextInternal *cu_internal = cuda_dev->internal;
 CudaFunctions *cu = cu_internal->cuda_dl;
 
+if (internal->cu_sem)
+CHECK_CU(cu->cuDestroyExternalSemaphore(internal->cu_sem));
+
 for (int i = 0; i < planes; i++) {
-if (internal->cu_sem[i])
-CHECK_CU(cu->cuDestroyExternalSemaphore(internal->cu_sem[i]));
 if (internal->cu_mma[i])
 CHECK_CU(cu->cuMipmappedArrayDestroy(internal->cu_mma[i]));
 if (internal->ext_mem[i])
@@ -1070,9 +1071,10 @@ static void vulkan_frame_free(void *opaque, uint8_t 
*data)
 for (int i = 0; i < planes; i++) {
 vkDestroyImage(hwctx->act_dev, f->img[i], hwctx->alloc);
 vkFreeMemory(hwctx->act_dev, f->mem[i], hwctx->alloc);
-vkDestroySemaphore(hwctx->act_dev, f->sem[i], hwctx->alloc);
 }
 
+vkDestroySemaphore(hwctx->act_dev, f->sem, hwctx->alloc);
+
 av_free(f);
 }
 
@@ -1166,8 +1168,8 @@ static int prepare_frame(AVHWFramesContext *hwfc, 
VulkanExecCtx *ectx,
 .commandBufferCount 

[FFmpeg-cvslog] hwcontext_vulkan: correctly download and upload flipped images

2020-04-21 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Apr 21 18:55:24 2020 
+0100| [e3c7b22451799a2890062b756b645cc5f2e8752e] | committer: Lynne

hwcontext_vulkan: correctly download and upload flipped images

We derive the destination buffer stride from the input stride,
which meant if the image was flipped with a negative stride,
we'd be FFALIGNING a negative number which ends up being huge,
thus making the Vulkan buffer allocation fail and the whole
image transfer fail.

Only found out about this as OpenGL compositors can copy an entire
image with a single call if its flipped, rather than iterate over
each line.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e3c7b22451799a2890062b756b645cc5f2e8752e
---

 libavutil/hwcontext_vulkan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index e4546f67ca..fa53d9d121 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -2638,7 +2638,7 @@ static int 
vulkan_transfer_data_from_mem(AVHWFramesContext *hwfc, AVFrame *dst,
 int h = src->height;
 int p_height = i > 0 ? AV_CEIL_RSHIFT(h, log2_chroma) : h;
 
-tmp.linesize[i] = src->linesize[i];
+tmp.linesize[i] = FFABS(src->linesize[i]);
 err = create_buf(dev_ctx, &buf[i], p_height,
  &tmp.linesize[i], VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, NULL, NULL);
@@ -2793,7 +2793,7 @@ static int vulkan_transfer_data_to_mem(AVHWFramesContext 
*hwfc, AVFrame *dst,
 int h = dst->height;
 int p_height = i > 0 ? AV_CEIL_RSHIFT(h, log2_chroma) : h;
 
-tmp.linesize[i] = dst->linesize[i];
+tmp.linesize[i] = FFABS(dst->linesize[i]);
 err = create_buf(dev_ctx, &buf[i], p_height,
  &tmp.linesize[i], VK_BUFFER_USAGE_TRANSFER_DST_BIT,
  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, NULL, NULL);

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

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

[FFmpeg-cvslog] overlay_vulkan: add support for overlaying images with an alpha channel

2020-04-23 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Apr 23 18:08:14 2020 
+0100| [f66ac83c22d8c088832ce8df922b08a0caa11833] | committer: Lynne

overlay_vulkan: add support for overlaying images with an alpha channel

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f66ac83c22d8c088832ce8df922b08a0caa11833
---

 libavfilter/vf_overlay_vulkan.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_overlay_vulkan.c b/libavfilter/vf_overlay_vulkan.c
index 7cedcc6e88..83cfae40e2 100644
--- a/libavfilter/vf_overlay_vulkan.c
+++ b/libavfilter/vf_overlay_vulkan.c
@@ -59,11 +59,27 @@ static const char overlay_noalpha[] = {
 C(0, } 
)
 };
 
+static const char overlay_alpha[] = {
+C(0, void overlay_alpha_opaque(int i, ivec2 pos)   
)
+C(0, { 
)
+C(1, vec4 res = texture(main_img[i], pos); 
)
+C(1, if ((o_offset[i].x <= pos.x) && (o_offset[i].y <= pos.y) &&
+ (pos.x < (o_offset[i].x + o_size[i].x)) &&
+ (pos.y < (o_offset[i].y + o_size[i].y))) {
)
+C(2, vec4 ovr = texture(overlay_img[i], pos - o_offset[i]);
)
+C(2, res = ovr * ovr.a + res * (1.0f - ovr.a); 
)
+C(2, res.a = 1.0f; 
)
+C(2, imageStore(output_img[i], pos, res);  
)
+C(1, } 
)
+C(1, imageStore(output_img[i], pos, res);  
)
+C(0, } 
)
+};
+
 static av_cold int init_filter(AVFilterContext *ctx)
 {
 int err;
 OverlayVulkanContext *s = ctx->priv;
-VkSampler *sampler = ff_vk_init_sampler(ctx, 1, VK_FILTER_LINEAR);
+VkSampler *sampler = ff_vk_init_sampler(ctx, 1, VK_FILTER_NEAREST);
 if (!sampler)
 return AVERROR_EXTERNAL;
 
@@ -73,6 +89,7 @@ static av_cold int init_filter(AVFilterContext *ctx)
 
 { /* Create the shader */
 const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
+const int ialpha = av_pix_fmt_desc_get(s->vkctx.input_format)->flags & 
AV_PIX_FMT_FLAG_ALPHA;
 
 VulkanDescriptorSetBinding desc_i[3] = {
 {
@@ -126,12 +143,16 @@ static av_cold int init_filter(AVFilterContext *ctx)
 RET(ff_vk_add_descriptor_set(ctx, s->pl, shd, &desc_b, 1, 0)); /* set 
1 */
 
 GLSLD(   overlay_noalpha  
);
+GLSLD(   overlay_alpha
);
 GLSLC(0, void main()  
);
 GLSLC(0, {
);
 GLSLC(1, ivec2 pos = ivec2(gl_GlobalInvocationID.xy); 
);
 GLSLF(1, int planes = %i;  
,planes);
 GLSLC(1, for (int i = 0; i < planes; i++) {   
);
-GLSLC(2, overlay_noalpha(i, pos); 
);
+if (ialpha)
+GLSLC(2, overlay_alpha_opaque(i, pos);
);
+else
+GLSLC(2, overlay_noalpha(i, pos); 
);
 GLSLC(1, }
);
 GLSLC(0, }
);
 

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

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

[FFmpeg-cvslog] scale_vulkan: take frame cropping parameters in account when scaling

2020-04-23 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Apr 23 18:09:00 2020 
+0100| [b136a983035e41058804fdab59078fdaaf5c5e86] | committer: Lynne

scale_vulkan: take frame cropping parameters in account when scaling

Then sample_aspect_ratio line at the bottom was cargo-culted from the vaapi
scaling filter, but its unnecesary.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b136a983035e41058804fdab59078fdaaf5c5e86
---

 libavfilter/vf_scale_vulkan.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
index 4f1e484bc9..328e6bcce5 100644
--- a/libavfilter/vf_scale_vulkan.c
+++ b/libavfilter/vf_scale_vulkan.c
@@ -52,9 +52,11 @@ typedef struct ScaleVulkanContext {
 } ScaleVulkanContext;
 
 static const char scale_bilinear[] = {
-C(0, vec4 scale_bilinear(int idx, ivec2 pos)   
 )
+C(0, vec4 scale_bilinear(int idx, ivec2 pos, vec2 crop_range, vec2 
crop_off))
 C(0, { 
 )
-C(1, const vec2 npos = (vec2(pos) + 0.5f) / 
imageSize(output_img[idx]); )
+C(1, vec2 npos = (vec2(pos) + 0.5f) / imageSize(output_img[idx]);  
 )
+C(1, npos *= crop_range;/* Reduce the range */ 
 )
+C(1, npos += crop_off;  /* Offset the start */ 
 )
 C(1, return texture(input_img[idx], npos); 
 )
 C(0, } 
 )
 };
@@ -108,6 +110,11 @@ static av_cold int init_filter(AVFilterContext *ctx, 
AVFrame *in)
 VkFilter sampler_mode;
 ScaleVulkanContext *s = ctx->priv;
 
+int crop_x = in->crop_left;
+int crop_y = in->crop_top;
+int crop_w = in->width - (in->crop_left + in->crop_right);
+int crop_h = in->height - (in->crop_top + in->crop_bottom);
+
 switch (s->scaler) {
 case F_NEAREST:
 sampler_mode = VK_FILTER_NEAREST;
@@ -186,6 +193,9 @@ static av_cold int init_filter(AVFilterContext *ctx, 
AVFrame *in)
 GLSLC(0, { 
  );
 GLSLC(1, ivec2 size;   
  );
 GLSLC(1, ivec2 pos = ivec2(gl_GlobalInvocationID.xy);  
  );
+GLSLF(1, vec2 in_d = vec2(%i, %i); ,in->width, 
in->height);
+GLSLF(1, vec2 c_r = vec2(%i, %i) / in_d;  ,crop_w, 
crop_h);
+GLSLF(1, vec2 c_o = vec2(%i, %i) / in_d;   
,crop_x,crop_y);
 GLSLC(0,   
  );
 
 if (s->vkctx.output_format == s->vkctx.input_format) {
@@ -195,14 +205,14 @@ static av_cold int init_filter(AVFilterContext *ctx, 
AVFrame *in)
 switch (s->scaler) {
 case F_NEAREST:
 case F_BILINEAR:
-GLSLF(2, vec4 res = scale_bilinear(%i, pos);   
,i);
+GLSLF(2, vec4 res = scale_bilinear(%i, pos, c_r, c_o); 
,i);
 GLSLF(2, imageStore(output_img[%i], pos, res); 
,i);
 break;
 };
 GLSLC(1, } 
  );
 }
 } else {
-GLSLC(1, vec4 res = scale_bilinear(0, pos);
  );
+GLSLC(1, vec4 res = scale_bilinear(0, pos, c_r, c_o);  
  );
 GLSLF(1, res = rgb2yuv(res, %i);,s->out_range == 
AVCOL_RANGE_JPEG);
 switch (s->vkctx.output_format) {
 case AV_PIX_FMT_NV12:GLSLC(1, write_nv12(res, pos); ); break;
@@ -454,11 +464,6 @@ static int scale_vulkan_config_output(AVFilterLink 
*outlink)
 if (err < 0)
 return err;
 
-if (inlink->sample_aspect_ratio.num)
-outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * 
inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio);
-else
-outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
-
 return 0;
 }
 

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

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

[FFmpeg-cvslog] oggdec: add support for proper demuxing of chained Opus files and streams

2020-04-30 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Apr 28 12:25:46 2020 
+0100| [8296443a70f052a6f5c9a867d28b83a5eb7d304d] | committer: Lynne

oggdec: add support for proper demuxing of chained Opus files and streams

Part of this patch is based on Paul B Mahol's patch from last year.

This also allows for single-stream parameter/codec changes.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8296443a70f052a6f5c9a867d28b83a5eb7d304d
---

 libavformat/oggdec.c   | 45 +
 libavformat/oggdec.h   |  1 +
 libavformat/oggparseopus.c |  1 +
 3 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 92dcafe2ed..c591bafddd 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -178,6 +178,7 @@ static int ogg_reset(AVFormatContext *s)
 if (start_pos <= s->internal->data_offset) {
 os->lastpts = 0;
 }
+os->start_trimming = 0;
 os->end_trimming = 0;
 av_freep(&os->new_metadata);
 os->new_metadata_size = 0;
@@ -206,7 +207,8 @@ static const struct ogg_codec *ogg_find_codec(uint8_t *buf, 
int size)
  * situation where a new audio stream spawn (identified with a new serial) and
  * must replace the previous one (track switch).
  */
-static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic)
+static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic,
+  int probing)
 {
 struct ogg *ogg = s->priv_data;
 struct ogg_stream *os;
@@ -220,24 +222,25 @@ static int ogg_replace_stream(AVFormatContext *s, 
uint32_t serial, char *magic)
 
 /* Check for codecs */
 codec = ogg_find_codec(magic, 8);
-if (!codec) {
+if (!codec && !probing) {
 av_log(s, AV_LOG_ERROR, "Cannot identify new stream\n");
 return AVERROR_INVALIDDATA;
 }
 
-/* If the codec matches, then we assume its a replacement */
-for (i = 0; i < ogg->nstreams; i++) {
-if (ogg->streams[i].codec == codec)
-break;
-}
-
-/* Otherwise, create a new stream */
-if (i >= ogg->nstreams)
-return ogg_new_stream(s, serial);
-
-os = &ogg->streams[i];
-os->serial = serial;
-os->codec  = codec;
+/* We only have a single stream anyway, so if there's a new stream with
+ * a different codec just replace it */
+os = &ogg->streams[0];
+os->serial  = serial;
+os->codec   = codec;
+os->serial  = serial;
+os->lastpts = 0;
+os->lastdts = 0;
+os->start_trimming = 0;
+os->end_trimming = 0;
+
+/* Chained files have extradata as a new packet */
+if (codec == &ff_opus_codec)
+os->header = -1;
 
 return i;
 }
@@ -294,7 +297,7 @@ static int data_packets_seen(const struct ogg *ogg)
 return 0;
 }
 
-static int ogg_read_page(AVFormatContext *s, int *sid)
+static int ogg_read_page(AVFormatContext *s, int *sid, int probing)
 {
 AVIOContext *bc = s->pb;
 struct ogg *ogg = s->priv_data;
@@ -417,7 +420,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 /* CRC is correct so we can be 99% sure there's an actual change here */
 if (idx < 0) {
 if (data_packets_seen(ogg))
-idx = ogg_replace_stream(s, serial, readout_buf);
+idx = ogg_replace_stream(s, serial, readout_buf, probing);
 else
 idx = ogg_new_stream(s, serial);
 
@@ -492,7 +495,7 @@ static int ogg_packet(AVFormatContext *s, int *sid, int 
*dstart, int *dsize,
 idx = ogg->curidx;
 
 while (idx < 0) {
-ret = ogg_read_page(s, &idx);
+ret = ogg_read_page(s, &idx, 0);
 if (ret < 0)
 return ret;
 }
@@ -643,7 +646,7 @@ static int ogg_get_length(AVFormatContext *s)
 avio_seek(s->pb, end, SEEK_SET);
 ogg->page_pos = -1;
 
-while (!ogg_read_page(s, &i)) {
+while (!ogg_read_page(s, &i, 1)) {
 if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
 ogg->streams[i].codec) {
 s->streams[i]->duration =
@@ -847,13 +850,15 @@ retry:
 pkt->duration = os->pduration;
 pkt->pos  = fpos;
 
-if (os->end_trimming) {
+if (os->start_trimming || os->end_trimming) {
 uint8_t *side_data = av_packet_new_side_data(pkt,
  AV_PKT_DATA_SKIP_SAMPLES,
  10);
 if(!side_data)
 return AVERROR(ENOMEM);
+ AV_WL32(side_data + 0, os->start_trimming);
 AV_WL32(side_data + 4, os->end_trimming);
+os->start_trimming = 0;
 os->end_trimming = 0;
 }
 
diff --git a/libavformat

[FFmpeg-cvslog] oggdec: use ffio_ensure_seekback() to seek back on incorrect data

2020-04-30 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Apr 28 12:55:17 2020 
+0100| [e983197cbc93420b67aa7e811be47d7278c2c8a2] | committer: Lynne

oggdec: use ffio_ensure_seekback() to seek back on incorrect data

This cleans up the code and simplifies it.
It also speeds up parsing since the old pb position was incorrect.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e983197cbc93420b67aa7e811be47d7278c2c8a2
---

 libavformat/oggdec.c | 68 +---
 1 file changed, 27 insertions(+), 41 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index e0188c7c59..92dcafe2ed 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -206,59 +206,40 @@ static const struct ogg_codec *ogg_find_codec(uint8_t 
*buf, int size)
  * situation where a new audio stream spawn (identified with a new serial) and
  * must replace the previous one (track switch).
  */
-static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, int size)
+static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic)
 {
 struct ogg *ogg = s->priv_data;
 struct ogg_stream *os;
 const struct ogg_codec *codec;
 int i = 0;
 
-if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
-uint8_t magic[8];
-avio_seek(s->pb, -size, SEEK_CUR);
-if (avio_read(s->pb, magic, sizeof(magic)) != sizeof(magic))
-return AVERROR_INVALIDDATA;
-avio_seek(s->pb, size - sizeof(magic), SEEK_CUR);
-codec = ogg_find_codec(magic, sizeof(magic));
-if (!codec) {
-av_log(s, AV_LOG_ERROR, "Cannot identify new stream\n");
-return AVERROR_INVALIDDATA;
-}
-for (i = 0; i < ogg->nstreams; i++) {
-if (ogg->streams[i].codec == codec)
-break;
-}
-if (i >= ogg->nstreams)
-return ogg_new_stream(s, serial);
-} else if (ogg->nstreams != 1) {
+if (ogg->nstreams != 1) {
 avpriv_report_missing_feature(s, "Changing stream parameters in 
multistream ogg");
 return AVERROR_PATCHWELCOME;
 }
 
-os = &ogg->streams[i];
-
-os->serial  = serial;
-return i;
+/* Check for codecs */
+codec = ogg_find_codec(magic, 8);
+if (!codec) {
+av_log(s, AV_LOG_ERROR, "Cannot identify new stream\n");
+return AVERROR_INVALIDDATA;
+}
 
-#if 0
-buf = os->buf;
-bufsize = os->bufsize;
-codec   = os->codec;
+/* If the codec matches, then we assume its a replacement */
+for (i = 0; i < ogg->nstreams; i++) {
+if (ogg->streams[i].codec == codec)
+break;
+}
 
-if (!ogg->state || ogg->state->streams[i].private != os->private)
-av_freep(&ogg->streams[i].private);
+/* Otherwise, create a new stream */
+if (i >= ogg->nstreams)
+return ogg_new_stream(s, serial);
 
-/* Set Ogg stream settings similar to what is done in ogg_new_stream(). We
- * also re-use the ogg_stream allocated buffer */
-memset(os, 0, sizeof(*os));
-os->serial  = serial;
-os->bufsize = bufsize;
-os->buf = buf;
-os->header  = -1;
-os->codec   = codec;
+os = &ogg->streams[i];
+os->serial = serial;
+os->codec  = codec;
 
 return i;
-#endif
 }
 
 static int ogg_new_stream(AVFormatContext *s, uint32_t serial)
@@ -325,6 +306,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 uint32_t crc, crc_tmp;
 int size = 0, idx;
 int64_t version, page_pos;
+int64_t start_pos;
 uint8_t sync[4];
 uint8_t segments[255];
 uint8_t *readout_buf;
@@ -364,6 +346,10 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 /* 0x4fa9b05f = av_crc(AV_CRC_32_IEEE, 0x0, "OggS", 4) */
 ffio_init_checksum(bc, ff_crc04C11DB7_update, 0x4fa9b05f);
 
+/* To rewind if checksum is bad/check magic on switches - this is the max 
packet size */
+ffio_ensure_seekback(bc, MAX_PAGE_SIZE);
+start_pos = avio_tell(bc);
+
 version = avio_r8(bc);
 flags   = avio_r8(bc);
 gp  = avio_rl64(bc);
@@ -414,7 +400,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 av_log(s, AV_LOG_ERROR, "CRC mismatch!\n");
 if (idx < 0)
 av_free(readout_buf);
-avio_seek(bc, -size, SEEK_CUR);
+avio_seek(bc, start_pos, SEEK_SET);
 return 0;
 }
 
@@ -424,14 +410,14 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 av_log(s, AV_LOG_ERROR, "Invalid Ogg vers!\n");
 if (idx < 0)
 av_free(readout_buf);
-avio_seek(bc, -size, SEEK_CUR);
+avio_seek(bc, start_pos, SEEK_SET);
 return 0;
 }
 
 /* CRC is correct so we can be 99% sure there's an actual change here */
 if (idx < 0) {
 if 

[FFmpeg-cvslog] oggdec: eliminate copies and extra buffers

2020-04-30 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Apr 28 12:41:34 2020 
+0100| [f619e1ec66b89215582eff4404b681b760540b4f] | committer: Lynne

oggdec: eliminate copies and extra buffers

This also makes implementing CRC checking far simpler and more robust.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f619e1ec66b89215582eff4404b681b760540b4f
---

 libavformat/oggdec.c | 127 +++
 1 file changed, 58 insertions(+), 69 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 95190589ab..7db26840b2 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -205,7 +205,7 @@ static const struct ogg_codec *ogg_find_codec(uint8_t *buf, 
int size)
  * situation where a new audio stream spawn (identified with a new serial) and
  * must replace the previous one (track switch).
  */
-static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, int nsegs)
+static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, int size)
 {
 struct ogg *ogg = s->priv_data;
 struct ogg_stream *os;
@@ -214,11 +214,10 @@ static int ogg_replace_stream(AVFormatContext *s, 
uint32_t serial, int nsegs)
 
 if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
 uint8_t magic[8];
-int64_t pos = avio_tell(s->pb);
-avio_skip(s->pb, nsegs);
+avio_seek(s->pb, -size, SEEK_CUR);
 if (avio_read(s->pb, magic, sizeof(magic)) != sizeof(magic))
 return AVERROR_INVALIDDATA;
-avio_seek(s->pb, pos, SEEK_SET);
+avio_seek(s->pb, size - sizeof(magic), SEEK_CUR);
 codec = ogg_find_codec(magic, sizeof(magic));
 if (!codec) {
 av_log(s, AV_LOG_ERROR, "Cannot identify new stream\n");
@@ -303,27 +302,6 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t 
serial)
 return idx;
 }
 
-static int ogg_new_buf(struct ogg *ogg, int idx)
-{
-struct ogg_stream *os = ogg->streams + idx;
-uint8_t *nb = av_malloc(os->bufsize + AV_INPUT_BUFFER_PADDING_SIZE);
-int size = os->bufpos - os->pstart;
-
-if (!nb)
-return AVERROR(ENOMEM);
-
-if (os->buf) {
-memcpy(nb, os->buf + os->pstart, size);
-av_free(os->buf);
-}
-
-os->buf= nb;
-os->bufpos = size;
-os->pstart = 0;
-
-return 0;
-}
-
 static int data_packets_seen(const struct ogg *ogg)
 {
 int i;
@@ -343,8 +321,11 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 int flags, nsegs;
 uint64_t gp;
 uint32_t serial;
-int size, idx;
+int size = 0, idx;
+int64_t page_pos;
 uint8_t sync[4];
+uint8_t segments[255];
+uint8_t *readout_buf;
 int sp = 0;
 
 ret = avio_read(bc, sync, 4);
@@ -387,47 +368,73 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 gp = avio_rl64(bc);
 serial = avio_rl32(bc);
 avio_skip(bc, 8); /* seq, crc */
-nsegs  = avio_r8(bc);
+
+nsegs= avio_r8(bc);
+page_pos = avio_tell(bc) - 27;
+
+ret = avio_read(bc, segments, nsegs);
+if (ret < nsegs)
+return ret < 0 ? ret : AVERROR_EOF;
 
 if (avio_feof(bc))
 return AVERROR_EOF;
 
+for (i = 0; i < nsegs; i++)
+size += segments[i];
+
 idx = ogg_find_stream(ogg, serial);
+if (idx >= 0) {
+os = ogg->streams + idx;
+
+/* Even if invalid guarantee there's enough memory to read the page */
+if (os->bufsize - os->bufpos < size) {
+uint8_t *nb = av_realloc(os->buf, 2*os->bufsize + 
AV_INPUT_BUFFER_PADDING_SIZE);
+if (!nb)
+return AVERROR(ENOMEM);
+os->buf = nb;
+os->bufsize *= 2;
+}
+
+readout_buf = os->buf + os->bufpos;
+} else {
+readout_buf = av_malloc(size);
+}
+
+ret = avio_read(bc, readout_buf, size);
+if (ret < size) {
+if (idx < 0)
+av_free(readout_buf);
+return ret < 0 ? ret : AVERROR_EOF;
+}
+
 if (idx < 0) {
 if (data_packets_seen(ogg))
-idx = ogg_replace_stream(s, serial, nsegs);
+idx = ogg_replace_stream(s, serial, size);
 else
 idx = ogg_new_stream(s, serial);
 
 if (idx < 0) {
 av_log(s, AV_LOG_ERROR, "failed to create or replace stream\n");
+av_free(readout_buf);
 return idx;
 }
-}
 
-os = ogg->streams + idx;
-ogg->page_pos =
-os->page_pos = avio_tell(bc) - 27;
+os = ogg->streams + idx;
 
-if (os->psize > 0) {
-ret = ogg_new_buf(ogg, idx);
-if (ret < 0)
-return ret;
+memcpy(os->buf + os->bufpos, readout_buf, size);
+av_free(readout_buf);
 }
 
-ret = avio_read(bc, os->segments, nsegs);
-if (ret < nsegs)
-return ret < 0

[FFmpeg-cvslog] oggdec: verify page checksum

2020-04-30 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Apr 28 12:52:11 2020 
+0100| [9ad47762c17d2c6d06595aa17b88112baa91b72c] | committer: Lynne

oggdec: verify page checksum

This makes decoding far more robust, since OggS, the ogg magic,
can be commonly found randomly in streams, which previously made
the demuxer think there's a new stream or a change in such.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ad47762c17d2c6d06595aa17b88112baa91b72c
---

 libavformat/oggdec.c | 46 ++
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 7db26840b2..e0188c7c59 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -31,6 +31,7 @@
 #include 
 #include "libavutil/avassert.h"
 #include "libavutil/intreadwrite.h"
+#include "avio_internal.h"
 #include "oggdec.h"
 #include "avformat.h"
 #include "internal.h"
@@ -321,8 +322,9 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 int flags, nsegs;
 uint64_t gp;
 uint32_t serial;
+uint32_t crc, crc_tmp;
 int size = 0, idx;
-int64_t page_pos;
+int64_t version, page_pos;
 uint8_t sync[4];
 uint8_t segments[255];
 uint8_t *readout_buf;
@@ -359,15 +361,19 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 return AVERROR_INVALIDDATA;
 }
 
-if (avio_r8(bc) != 0) {  /* version */
-av_log (s, AV_LOG_ERROR, "ogg page, unsupported version\n");
-return AVERROR_INVALIDDATA;
-}
+/* 0x4fa9b05f = av_crc(AV_CRC_32_IEEE, 0x0, "OggS", 4) */
+ffio_init_checksum(bc, ff_crc04C11DB7_update, 0x4fa9b05f);
 
-flags  = avio_r8(bc);
-gp = avio_rl64(bc);
-serial = avio_rl32(bc);
-avio_skip(bc, 8); /* seq, crc */
+version = avio_r8(bc);
+flags   = avio_r8(bc);
+gp  = avio_rl64(bc);
+serial  = avio_rl32(bc);
+avio_skip(bc, 4); /* seq */
+
+crc_tmp = ffio_get_checksum(bc);
+crc = avio_rb32(bc);
+crc_tmp = ff_crc04C11DB7_update(crc_tmp, (uint8_t[4]){0}, 4);
+ffio_init_checksum(bc, ff_crc04C11DB7_update, crc_tmp);
 
 nsegs= avio_r8(bc);
 page_pos = avio_tell(bc) - 27;
@@ -376,9 +382,6 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 if (ret < nsegs)
 return ret < 0 ? ret : AVERROR_EOF;
 
-if (avio_feof(bc))
-return AVERROR_EOF;
-
 for (i = 0; i < nsegs; i++)
 size += segments[i];
 
@@ -407,6 +410,25 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
 return ret < 0 ? ret : AVERROR_EOF;
 }
 
+if (crc ^ ffio_get_checksum(bc)) {
+av_log(s, AV_LOG_ERROR, "CRC mismatch!\n");
+if (idx < 0)
+av_free(readout_buf);
+avio_seek(bc, -size, SEEK_CUR);
+return 0;
+}
+
+/* Since we're almost sure its a valid packet, checking the version after
+ * the checksum lets the demuxer be more tolerant */
+if (version) {
+av_log(s, AV_LOG_ERROR, "Invalid Ogg vers!\n");
+if (idx < 0)
+av_free(readout_buf);
+avio_seek(bc, -size, SEEK_CUR);
+return 0;
+}
+
+/* CRC is correct so we can be 99% sure there's an actual change here */
 if (idx < 0) {
 if (data_packets_seen(ogg))
 idx = ogg_replace_stream(s, serial, size);

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

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

[FFmpeg-cvslog] fate/oggopus-demux: fix fate failure

2020-04-30 Thread Lynne
ffmpeg | branch: master | Lynne  | Fri May  1 01:36:43 2020 
+0100| [4fd0559b77cfdd38d37a94a45cc830d90454194e] | committer: Lynne

fate/oggopus-demux: fix fate failure

Failure was due to the extra comment printed by libavcodec/utils.c since
side data is used to signal the skipped samples.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4fd0559b77cfdd38d37a94a45cc830d90454194e
---

 tests/ref/fate/oggopus-demux | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/ref/fate/oggopus-demux b/tests/ref/fate/oggopus-demux
index 9192760700..580758c0dc 100644
--- a/tests/ref/fate/oggopus-demux
+++ b/tests/ref/fate/oggopus-demux
@@ -5,7 +5,7 @@
 #sample_rate 0: 48000
 #channel_layout 0: 3
 #channel_layout_name 0: stereo
-0,   -356,   -356,  960,  402, 0x89b1c40f
+0,   -356,   -356,  960,  402, 0x89b1c40f, S=1,   10, 
0x03f10065
 0,604,604,  960,  216, 0x7bf97146
 0,   1564,   1564,  960,  215, 0x6cb86d8b
 0,   2524,   2524,  960,  218, 0x9cfd691c

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

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

[FFmpeg-cvslog] lavc/bsf: add an Opus metadata bitstream filter

2020-05-05 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun May  3 21:17:33 2020 
+0100| [bdd57e2a371f70ee75f70bfde5a9a162c76b48ba] | committer: Lynne

lavc/bsf: add an Opus metadata bitstream filter

The only adjustable field is the gain. Some ripping/transcoding programs
have started to use it.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bdd57e2a371f70ee75f70bfde5a9a162c76b48ba
---

 libavcodec/Makefile|  1 +
 libavcodec/bitstream_filters.c |  1 +
 libavcodec/opus_metadata_bsf.c | 72 ++
 3 files changed, 74 insertions(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 28076c2c83..cf72f55aff 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1116,6 +1116,7 @@ OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF)  += 
mp3_header_decompress_bsf.o \
 OBJS-$(CONFIG_MPEG2_METADATA_BSF) += mpeg2_metadata_bsf.o
 OBJS-$(CONFIG_NOISE_BSF)  += noise_bsf.o
 OBJS-$(CONFIG_NULL_BSF)   += null_bsf.o
+OBJS-$(CONFIG_OPUS_METADATA_BSF)  += opus_metadata_bsf.o
 OBJS-$(CONFIG_PRORES_METADATA_BSF)+= prores_metadata_bsf.o
 OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF)   += remove_extradata_bsf.o
 OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 6b5ffe4d70..f1b24baa53 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -49,6 +49,7 @@ extern const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf;
 extern const AVBitStreamFilter ff_mov2textsub_bsf;
 extern const AVBitStreamFilter ff_noise_bsf;
 extern const AVBitStreamFilter ff_null_bsf;
+extern const AVBitStreamFilter ff_opus_metadata_bsf;
 extern const AVBitStreamFilter ff_prores_metadata_bsf;
 extern const AVBitStreamFilter ff_remove_extradata_bsf;
 extern const AVBitStreamFilter ff_text2movsub_bsf;
diff --git a/libavcodec/opus_metadata_bsf.c b/libavcodec/opus_metadata_bsf.c
new file mode 100644
index 00..867ad830d3
--- /dev/null
+++ b/libavcodec/opus_metadata_bsf.c
@@ -0,0 +1,72 @@
+/*
+ * 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 "bsf.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+
+typedef struct OpusBSFContext {
+const AVClass *class;
+int gain;
+} OpusBSFContext;
+
+static int opus_metadata_filter(AVBSFContext *bsfc, AVPacket *pkt)
+{
+return ff_bsf_get_packet_ref(bsfc, pkt);
+}
+
+static int opus_metadata_init(AVBSFContext *bsfc)
+{
+OpusBSFContext *s = bsfc->priv_data;
+
+if (bsfc->par_out->extradata_size < 19)
+return AVERROR_INVALIDDATA;
+
+AV_WL16(bsfc->par_out->extradata + 16, s->gain);
+
+return 0;
+}
+
+#define OFFSET(x) offsetof(OpusBSFContext, x)
+#define FLAGS (AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_BSF_PARAM)
+static const AVOption opus_metadata_options[] = {
+{ "gain", "Gain, actual amplification is pow(10, gain/(20.0*256))", 
OFFSET(gain),
+  AV_OPT_TYPE_INT, { .i64 = 0 }, -(INT16_MAX + 1), INT16_MAX, .flags = 
FLAGS },
+
+{ NULL },
+};
+
+static const AVClass opus_metadata_class = {
+.class_name = "opus_metadata_bsf",
+.item_name  = av_default_item_name,
+.option = opus_metadata_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+static const enum AVCodecID codec_ids[] = {
+AV_CODEC_ID_OPUS, AV_CODEC_ID_NONE,
+};
+
+const AVBitStreamFilter ff_opus_metadata_bsf = {
+.name   = "opus_metadata",
+.priv_data_size = sizeof(OpusBSFContext),
+.priv_class = &opus_metadata_class,
+.init   = &opus_metadata_init,
+.filter = &opus_metadata_filter,
+.codec_ids  = codec_ids,
+};

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

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

[FFmpeg-cvslog] hwcontext_vulkan: optionally enable the VK_KHR_surface extension if available

2020-05-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun May 10 11:21:52 2020 
+0100| [b69f5a72cec0f604b8160c5d18a56036522635b8] | committer: Lynne

hwcontext_vulkan: optionally enable the VK_KHR_surface extension if available

This allows any phys_device derived to be used as a display rendering device.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b69f5a72cec0f604b8160c5d18a56036522635b8
---

 libavutil/hwcontext_vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index fa53d9d121..43e7cddbc5 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -187,7 +187,7 @@ typedef struct VulkanOptExtension {
 } VulkanOptExtension;
 
 static const VulkanOptExtension optional_instance_exts[] = {
-/* For future use */
+{ VK_KHR_SURFACE_EXTENSION_NAME, EXT_OPTIONAL },
 };
 
 static const VulkanOptExtension optional_device_exts[] = {

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

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

[FFmpeg-cvslog] mpeg4audio: rename AOT_USAC_NOSBR to AOT_USAC

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun  5 04:53:18 2024 
+0200| [8a2fe8a5b964e8ccb0cba642f7aefe256a0fb356] | committer: Lynne

mpeg4audio: rename AOT_USAC_NOSBR to AOT_USAC

The issue is that AOT 45 isn't defined anywhere, and looking at the git
blame, it seems to have sprung up through a reordering of the enum,
and adding a hole.

The spec does not define an explicit AOT for SBR and no SBR, and only
uses AOT 42 (previously AOT_USAC_NOSBR), so just rename AOT_USAC to
it and replace its use everywhere.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a2fe8a5b964e8ccb0cba642f7aefe256a0fb356
---

 libavcodec/aac/aacdec.c | 7 ++-
 libavcodec/mpeg4audio.h | 3 +--
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 2b8322fc68..24d2bdde4c 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1046,7 +1046,6 @@ static int decode_audio_specific_config_gb(AACDecContext 
*ac,
 return ret;
 break;
 #if CONFIG_AAC_DECODER
-case AOT_USAC_NOSBR: /* fallthrough */
 case AOT_USAC:
 if ((ret = ff_aac_usac_config_decode(ac, avctx, gb,
  oc, m4ac->chan_config)) < 0)
@@ -1571,8 +1570,7 @@ int ff_aac_decode_tns(AACDecContext *ac, 
TemporalNoiseShaping *tns,
   GetBitContext *gb, const IndividualChannelStream *ics)
 {
 int tns_max_order = INT32_MAX;
-const int is_usac = ac->oc[1].m4ac.object_type == AOT_USAC ||
-ac->oc[1].m4ac.object_type == AOT_USAC_NOSBR;
+const int is_usac = ac->oc[1].m4ac.object_type == AOT_USAC;
 int w, filt, i, coef_len, coef_res, coef_compress;
 const int is8 = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE;
 
@@ -2421,8 +2419,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, 
AVFrame *frame,
 
 ac->tags_mapped = 0;
 
-if ((ac->oc[1].m4ac.object_type == AOT_USAC) ||
-(ac->oc[1].m4ac.object_type == AOT_USAC_NOSBR)) {
+if (ac->oc[1].m4ac.object_type == AOT_USAC) {
 if (ac->is_fixed) {
 avpriv_report_missing_feature(ac->avctx,
   "AAC USAC fixed-point decoding");
diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
index 56615ef321..5daba7824b 100644
--- a/libavcodec/mpeg4audio.h
+++ b/libavcodec/mpeg4audio.h
@@ -108,10 +108,9 @@ enum AudioObjectType {
 AOT_ER_AAC_ELD,///< N   Error Resilient 
Enhanced Low Delay
 AOT_SMR_SIMPLE,///< N   Symbolic Music 
Representation Simple
 AOT_SMR_MAIN,  ///< N   Symbolic Music 
Representation Main
-AOT_USAC_NOSBR,///< N   Unified Speech and 
Audio Coding (no SBR)
+AOT_USAC,  ///< Y   Unified Speech and 
Audio Coding
 AOT_SAOC,  ///< N   Spatial Audio 
Object Coding
 AOT_LD_SURROUND,   ///< N   Low Delay MPEG 
Surround
-AOT_USAC,  ///< N   Unified Speech and 
Audio Coding
 };
 
 #define MAX_PCE_SIZE 320 ///https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] mpeg4audio: explicitly define each AOT

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun  5 05:00:18 2024 
+0200| [ee419804da2a6a44a4af5d949869f0e98306d2fc] | committer: Lynne

mpeg4audio: explicitly define each AOT

This makes it far easier to figure out which AOT belongs to which
profile.
Also, explicitly highlight the holes.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ee419804da2a6a44a4af5d949869f0e98306d2fc
---

 libavcodec/mpeg4audio.h | 82 +
 1 file changed, 42 insertions(+), 40 deletions(-)

diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
index 5daba7824b..0819e48a42 100644
--- a/libavcodec/mpeg4audio.h
+++ b/libavcodec/mpeg4audio.h
@@ -68,49 +68,51 @@ int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, 
const uint8_t *buf,
   int size, int sync_extension, void *logctx);
 
 enum AudioObjectType {
-AOT_NULL,
+AOT_NULL = 0,
// Support?Name
-AOT_AAC_MAIN,  ///< Y   Main
-AOT_AAC_LC,///< Y   Low Complexity
-AOT_AAC_SSR,   ///< N (code in SoC repo)Scalable Sample 
Rate
-AOT_AAC_LTP,   ///< Y   Long Term 
Prediction
-AOT_SBR,   ///< Y   Spectral Band 
Replication
-AOT_AAC_SCALABLE,  ///< N   Scalable
-AOT_TWINVQ,///< N   Twin Vector 
Quantizer
-AOT_CELP,  ///< N   Code Excited 
Linear Prediction
-AOT_HVXC,  ///< N   Harmonic Vector 
eXcitation Coding
+AOT_AAC_MAIN =  1, ///< Y   Main
+AOT_AAC_LC   =  2, ///< Y   Low Complexity
+AOT_AAC_SSR  =  3, ///< N (code in SoC repo)Scalable Sample 
Rate
+AOT_AAC_LTP  =  4, ///< Y   Long Term 
Prediction
+AOT_SBR  =  5, ///< Y   Spectral Band 
Replication
+AOT_AAC_SCALABLE =  6, ///< N   Scalable
+AOT_TWINVQ   =  7, ///< N   Twin Vector 
Quantizer
+AOT_CELP =  8, ///< N   Code Excited 
Linear Prediction
+AOT_HVXC =  9, ///< N   Harmonic Vector 
eXcitation Coding
+
 AOT_TTSI = 12, ///< N   Text-To-Speech 
Interface
-AOT_MAINSYNTH, ///< N   Main Synthesis
-AOT_WAVESYNTH, ///< N   Wavetable Synthesis
-AOT_MIDI,  ///< N   General MIDI
-AOT_SAFX,  ///< N   Algorithmic 
Synthesis and Audio Effects
-AOT_ER_AAC_LC, ///< N   Error Resilient 
Low Complexity
+AOT_MAINSYNTH= 13, ///< N   Main Synthesis
+AOT_WAVESYNTH= 14, ///< N   Wavetable Synthesis
+AOT_MIDI = 15, ///< N   General MIDI
+AOT_SAFX = 16, ///< N   Algorithmic 
Synthesis and Audio Effects
+AOT_ER_AAC_LC= 17, ///< N   Error Resilient 
Low Complexity
+
 AOT_ER_AAC_LTP   = 19, ///< N   Error Resilient 
Long Term Prediction
-AOT_ER_AAC_SCALABLE,   ///< N   Error Resilient 
Scalable
-AOT_ER_TWINVQ, ///< N   Error Resilient 
Twin Vector Quantizer
-AOT_ER_BSAC,   ///< N   Error Resilient 
Bit-Sliced Arithmetic Coding
-AOT_ER_AAC_LD, ///< N   Error Resilient 
Low Delay
-AOT_ER_CELP,   ///< N   Error Resilient 
Code Excited Linear Prediction
-AOT_ER_HVXC,   ///< N   Error Resilient 
Harmonic Vector eXcitation Coding
-AOT_ER_HILN,   ///< N   Error Resilient 
Harmonic and Individual Lines plus Noise
-AOT_ER_PARAM,  ///< N   Error Resilient 
Parametric
-AOT_SSC,   ///< N   SinuSoidal Coding
-AOT_PS,///< N   Parametric Stereo
-AOT_SURROUND,  ///< N   MPEG Surround
-AOT_ESCAPE,///< Y   Escape Value
-AOT_L1,///< Y   Layer 1
-AOT_L2,///< Y   Layer 2
-AOT_L3,///< Y   Layer 3
-AOT_DST, 

[FFmpeg-cvslog] aacdec: increase MAX_ELEM_ID to 64

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun  5 18:23:12 2024 
+0200| [5c328e6c1e56fdb12fcf3a89b18079ad983cbe5b] | committer: Lynne

aacdec: increase MAX_ELEM_ID to 64

In USAC, we set the max to 64.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5c328e6c1e56fdb12fcf3a89b18079ad983cbe5b
---

 libavcodec/aac.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index 9508760fa6..fc6d1361b2 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -31,7 +31,7 @@
 #define AVCODEC_AAC_H
 
 #define MAX_CHANNELS 64
-#define MAX_ELEM_ID 16
+#define MAX_ELEM_ID 64
 
 #define TNS_MAX_ORDER 20
 #define MAX_LTP_LONG_SFB 40

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

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


[FFmpeg-cvslog] aac: define a new profile for USAC

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun  5 05:01:42 2024 
+0200| [1c066867df5b786d486cfa1070af101b38542177] | committer: Lynne

aac: define a new profile for USAC

This allows users to determine whether a stream is USAC or not.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1c066867df5b786d486cfa1070af101b38542177
---

 libavcodec/aac/aacdec_usac.c | 4 
 libavcodec/defs.h| 1 +
 libavcodec/profiles.c| 1 +
 libavcodec/profiles.h| 1 +
 4 files changed, 7 insertions(+)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 7b36b49d63..5c3bb8d4ac 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -494,6 +494,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 }
 }
 
+ac->avctx->profile = AV_PROFILE_AAC_USAC;
+
 ret = ff_aac_usac_reset_state(ac, oc);
 if (ret < 0)
 return ret;
@@ -1533,6 +1535,8 @@ int ff_aac_usac_decode_frame(AVCodecContext *avctx, 
AACDecContext *ac,
 ff_aac_output_configure(ac, ac->oc[1].layout_map, 
ac->oc[1].layout_map_tags,
 ac->oc[1].status, 0);
 
+ac->avctx->profile = AV_PROFILE_AAC_USAC;
+
 indep_flag = get_bits1(gb);
 
 nb_ch_el = 0;
diff --git a/libavcodec/defs.h b/libavcodec/defs.h
index 00d840ec19..7ddfdcad0b 100644
--- a/libavcodec/defs.h
+++ b/libavcodec/defs.h
@@ -73,6 +73,7 @@
 #define AV_PROFILE_AAC_HE_V2   28
 #define AV_PROFILE_AAC_LD  22
 #define AV_PROFILE_AAC_ELD 38
+#define AV_PROFILE_AAC_USAC41
 #define AV_PROFILE_MPEG2_AAC_LOW  128
 #define AV_PROFILE_MPEG2_AAC_HE   131
 
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 052b77926e..44bdf6f85b 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -33,6 +33,7 @@ const AVProfile ff_aac_profiles[] = {
 { AV_PROFILE_AAC_MAIN,  "Main" },
 { AV_PROFILE_AAC_SSR,   "SSR"  },
 { AV_PROFILE_AAC_LTP,   "LTP"  },
+{ AV_PROFILE_AAC_USAC,  "xHE-AAC" },
 { AV_PROFILE_UNKNOWN },
 };
 
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 842201718b..33b7ffc17a 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -35,6 +35,7 @@
 FF_AVCTX_PROFILE_OPTION("aac_he_v2", NULL, AUDIO, 
AV_PROFILE_AAC_HE_V2)\
 FF_AVCTX_PROFILE_OPTION("aac_ld",NULL, AUDIO, AV_PROFILE_AAC_LD)\
 FF_AVCTX_PROFILE_OPTION("aac_eld",   NULL, AUDIO, AV_PROFILE_AAC_ELD)\
+FF_AVCTX_PROFILE_OPTION("aac_xhe",   NULL, AUDIO, AV_PROFILE_AAC_USAC)\
 FF_AVCTX_PROFILE_OPTION("mpeg2_aac_low", NULL, AUDIO, 
AV_PROFILE_MPEG2_AAC_LOW)\
 FF_AVCTX_PROFILE_OPTION("mpeg2_aac_he",  NULL, AUDIO, 
AV_PROFILE_MPEG2_AAC_HE)\
 

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

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


[FFmpeg-cvslog] lavc: bump minor and add APIchanges entry for new USAC profile

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun  5 05:04:58 2024 
+0200| [91fd6ca000cb87302f5c689de50fcd626939a362] | committer: Lynne

lavc: bump minor and add APIchanges entry for new USAC profile

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=91fd6ca000cb87302f5c689de50fcd626939a362
---

 doc/APIchanges   | 3 +++
 libavcodec/version.h | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index e36a01336c..891eaebf1a 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-06-08 - xx - lavc 61.7.100 - defs.h
+  Add AV_PROFILE_AAC_USAC.
+
 2024-06-02 - xx - lavu 59.21.100 - channel_layout.h
   Add AV_CHAN_SIDE_SURROUND_RIGHT and AV_CH_SIDE_SURROUND_LEFT.
   Add AV_CHAN_SIDE_SURROUND_RIGHT and AV_CH_SIDE_SURROUND_RIGHT.
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 39dbec0208..7acb261bb3 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,8 +29,8 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR   6
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MINOR   7
+#define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \

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

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


[FFmpeg-cvslog] aacdec_usac: clean up nb_elems on error

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun  5 18:25:00 2024 
+0200| [62cd6d9e596fd4e4f5ade39de36203b547b5250b] | committer: Lynne

aacdec_usac: clean up nb_elems on error

Require that there is a valid layout with a valid number of channels
before accepting nb_elems.
The value is required when flushing.

Thanks to kasper93 for figuring it out.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62cd6d9e596fd4e4f5ade39de36203b547b5250b
---

 libavcodec/aac/aacdec_usac.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 5c3bb8d4ac..3a573ab573 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -401,6 +401,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 if (usac->nb_elems > 64) {
 av_log(ac->avctx, AV_LOG_ERROR, "Too many elements: %i\n",
usac->nb_elems);
+usac->nb_elems = 0;
 return AVERROR(EINVAL);
 }
 
@@ -413,6 +414,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 (elem_id[0] + elem_id[1] + elem_id[2] + 1) > nb_channels) {
 av_log(ac->avctx, AV_LOG_ERROR, "Too many channels for the channel 
"
 "configuration\n");
+usac->nb_elems = 0;
 return AVERROR(EINVAL);
 }
 
@@ -458,6 +460,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 ret = ff_aac_output_configure(ac, layout_map, elem_id[0] + elem_id[1] + 
elem_id[2], OC_GLOBAL_HDR, 0);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Unable to parse channel config!\n");
+usac->nb_elems = 0;
 return ret;
 }
 

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

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


[FFmpeg-cvslog] aacdec_usac: correctly set and use the layout map

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun  5 19:40:54 2024 
+0200| [25b848a0bd08a96f4d8e8242cd049c3295b730ef] | committer: Lynne

aacdec_usac: correctly set and use the layout map

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=25b848a0bd08a96f4d8e8242cd049c3295b730ef
---

 libavcodec/aac/aacdec_usac.c | 105 ++-
 1 file changed, 63 insertions(+), 42 deletions(-)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 04dd5facff..561734f930 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -268,17 +268,25 @@ int ff_aac_usac_reset_state(AACDecContext *ac, 
OutputConfiguration *oc)
 /* Initialize state */
 for (int i = 0; i < usac->nb_elems; i++) {
 AACUsacElemConfig *e = &usac->elems[i];
-if (e->type != ID_USAC_SCE && e->type != ID_USAC_CPE)
+if (e->type == ID_USAC_EXT)
 continue;
 
-if (e->type == ID_USAC_SCE) {
+switch (e->type) {
+case ID_USAC_SCE:
 ch = 1;
 type = TYPE_SCE;
 id = elem_id[0]++;
-} else {
+break;
+case ID_USAC_CPE:
 ch = 2;
 type = TYPE_CPE;
 id = elem_id[1]++;
+break;
+case ID_USAC_LFE:
+ch = 1;
+type = TYPE_LFE;
+id = elem_id[2]++;
+break;
 }
 
 che = ff_aac_get_che(ac, type, id);
@@ -318,7 +326,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 AACUSACConfig *usac = &oc->usac;
 int elem_id[3 /* SCE, CPE, LFE */];
 
-uint8_t layout_map[MAX_ELEM_ID*4][3];
+int map_pos_set = 0;
+uint8_t layout_map[MAX_ELEM_ID*4][3] = { 0 };
 
 memset(usac, 0, sizeof(*usac));
 
@@ -391,6 +400,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 /* Fill in the number of expected channels */
 for (int i = 0; i < nb_elements; i++)
 nb_channels += layout_map[i][0] == TYPE_CPE ? 2 : 1;
+
+map_pos_set = 1;
 }
 
 /* UsacDecoderConfig */
@@ -404,12 +415,12 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 }
 
 for (int i = 0; i < usac->nb_elems; i++) {
+int map_count = elem_id[0] + elem_id[1] + elem_id[2];
 AACUsacElemConfig *e = &usac->elems[i];
 memset(e, 0, sizeof(*e));
 
 e->type = get_bits(gb, 2); /* usacElementType */
-if (e->type != ID_USAC_EXT &&
-(elem_id[0] + elem_id[1] + elem_id[2] + 1) > nb_channels) {
+if (e->type != ID_USAC_EXT && (map_count + 1) > nb_channels) {
 av_log(ac->avctx, AV_LOG_ERROR, "Too many channels for the channel 
"
 "configuration\n");
 usac->nb_elems = 0;
@@ -425,30 +436,31 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 decode_usac_element_core(e, gb, sbr_ratio);
 if (e->sbr.ratio > 0)
 decode_usac_sbr_data(e, gb);
-layout_map[i][0] = TYPE_SCE;
-layout_map[i][1] = i;
-layout_map[i][2] = AAC_CHANNEL_FRONT;
-elem_id[0]++;
+layout_map[map_count][0] = TYPE_SCE;
+layout_map[map_count][1] = elem_id[0]++;
+if (!map_pos_set)
+layout_map[map_count][2] = AAC_CHANNEL_FRONT;
 
 break;
 case ID_USAC_CPE: /* UsacChannelPairElementConf */
 /* UsacCoreConfig */
 decode_usac_element_core(e, gb, sbr_ratio);
 decode_usac_element_pair(e, gb);
-layout_map[i][0] = TYPE_CPE;
-layout_map[i][1] = i;
-layout_map[i][2] = AAC_CHANNEL_FRONT;
-elem_id[1]++;
+layout_map[map_count][0] = TYPE_CPE;
+layout_map[map_count][1] = elem_id[1]++;
+if (!map_pos_set)
+layout_map[map_count][2] = AAC_CHANNEL_FRONT;
 
 break;
 case ID_USAC_LFE: /* LFE */
 /* LFE has no need for any configuration */
 e->tw_mdct = 0;
 e->noise_fill = 0;
-layout_map[i][0] = TYPE_LFE;
-layout_map[i][1] = i;
-layout_map[i][2] = AAC_CHANNEL_LFE;
-elem_id[2]++;
+layout_map[map_count][0] = TYPE_LFE;
+layout_map[map_count][1] = elem_id[2]++;
+if (!map_pos_set)
+layout_map[map_count][2] = AAC_CHANNEL_LFE;
+
 break;
 case ID_USAC_EXT: /* EXT */
 ret = decode_usac_extension(ac, e, gb);
@@ -458,7 +470,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 };
 }
 
-ret = ff_aac_output_configure(ac, layout_map, elem_id[0] + e

[FFmpeg-cvslog] aacdec_usac: tag LFE channels as such in the channel map

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun  5 18:31:52 2024 
+0200| [91ab17e2fe57d5c093f9a2c63342e58df6cf024b] | committer: Lynne

aacdec_usac: tag LFE channels as such in the channel map

Missed.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=91ab17e2fe57d5c093f9a2c63342e58df6cf024b
---

 libavcodec/aac/aacdec_usac.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 3a573ab573..b12eda90e1 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -447,6 +447,9 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 /* LFE has no need for any configuration */
 e->tw_mdct = 0;
 e->noise_fill = 0;
+layout_map[i][0] = TYPE_LFE;
+layout_map[i][1] = i;
+layout_map[i][2] = AAC_CHANNEL_LFE;
 elem_id[2]++;
 break;
 case ID_USAC_EXT: /* EXT */

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

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


[FFmpeg-cvslog] aacdec_usac: respect tns_on_lr flag

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Jun  6 02:25:03 2024 
+0200| [8ecaa64b9bceb68d9107ba5a5e8d1dfaa40bf21f] | committer: Lynne

aacdec_usac: respect tns_on_lr flag

This was left out, and due to av_unused, forgotten about.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8ecaa64b9bceb68d9107ba5a5e8d1dfaa40bf21f
---

 libavcodec/aac/aacdec.h  |  1 +
 libavcodec/aac/aacdec_usac.c | 16 
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index ee21a94007..f0a33e7ac3 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -230,6 +230,7 @@ typedef struct SingleChannelElement {
 typedef struct AACUsacStereo {
 uint8_t common_window;
 uint8_t common_tw;
+uint8_t tns_on_lr; ///< Apply TNS before M/S and stereo prediction
 
 uint8_t ms_mask_mode;
 uint8_t config_idx;
diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 561734f930..3b4e980df4 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -876,14 +876,14 @@ static int decode_usac_stereo_info(AACDecContext *ac, 
AACUSACConfig *usac,
 return AVERROR_PATCHWELCOME;
 }
 
+us->tns_on_lr = 0;
 sce1->tns.present = sce2->tns.present = 0;
 if (tns_active) {
-av_unused int tns_on_lr;
 int common_tns = 0;
 if (us->common_window)
 common_tns = get_bits1(gb);
 
-tns_on_lr = get_bits1(gb);
+us->tns_on_lr = get_bits1(gb);
 if (common_tns) {
 ret = ff_aac_decode_tns(ac, &sce1->tns, gb, ics1);
 if (ret < 0)
@@ -1214,6 +1214,14 @@ static void spectrum_decode(AACDecContext *ac, 
AACUSACConfig *usac,
 }
 
 if (nb_channels > 1 && us->common_window) {
+for (int ch = 0; ch < nb_channels; ch++) {
+SingleChannelElement *sce = &cpe->ch[ch];
+
+/* Apply TNS, if the tns_on_lr bit is not set. */
+if (sce->tns.present && !us->tns_on_lr)
+ac->dsp.apply_tns(sce->coeffs, &sce->tns, &sce->ics, 1);
+}
+
 if (us->ms_mask_mode == 3) {
 const float *filt;
 complex_stereo_downmix_cur(ac, cpe, us->dmix_re);
@@ -1248,8 +1256,8 @@ static void spectrum_decode(AACDecContext *ac, 
AACUSACConfig *usac,
 for (int ch = 0; ch < nb_channels; ch++) {
 SingleChannelElement *sce = &cpe->ch[ch];
 
-/* Apply TNS */
-if (sce->tns.present)
+/* Apply TNS, if it hasn't been applied yet. */
+if (sce->tns.present && ((nb_channels == 1) || (us->tns_on_lr)))
 ac->dsp.apply_tns(sce->coeffs, &sce->tns, &sce->ics, 1);
 
 ac->oc[1].m4ac.frame_length_short ? 
ac->dsp.imdct_and_windowing_768(ac, sce) :

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

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


[FFmpeg-cvslog] aacdec_usac: remove fallback for custom maps with invalid position

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun  5 18:43:08 2024 
+0200| [ae495b56ffc9a80fffe608e5ef42720ea968952d] | committer: Lynne

aacdec_usac: remove fallback for custom maps with invalid position

Not needed as every possible index is mapped.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae495b56ffc9a80fffe608e5ef42720ea968952d
---

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

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index b12eda90e1..04dd5facff 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -371,8 +371,6 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 for (int i = 0; i < nb_channels; i++) {
 AVChannelCustom *cm = &ac->oc[1].ch_layout.u.map[i];
 cm->id = usac_ch_pos_to_av[get_bits(gb, 5)]; /* bsOutputChannelPos 
*/
-if (cm->id == AV_CHAN_NONE)
-cm->id = AV_CHAN_UNKNOWN;
 }
 
 ret = av_channel_layout_retype(&ac->oc[1].ch_layout,

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

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


[FFmpeg-cvslog] aacdec_usac: decouple TNS active from TNS data present flag

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Jun  6 03:50:44 2024 
+0200| [1ad9a4008bbb4fbcf3691bc56851d877c955b9e4] | committer: Lynne

aacdec_usac: decouple TNS active from TNS data present flag

The issue was that in case of common TNS parameters, TNS was
entirely skipped, as tns.present was set to 0.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1ad9a4008bbb4fbcf3691bc56851d877c955b9e4
---

 libavcodec/aac/aacdec.h  |  1 +
 libavcodec/aac/aacdec_usac.c | 25 +++--
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index f0a33e7ac3..a2ef4a82e8 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -125,6 +125,7 @@ typedef struct LongTermPrediction {
 typedef struct AACUsacElemData {
 uint8_t core_mode;
 uint8_t scale_factor_grouping;
+uint8_t tns_data_present;
 
 /* Timewarping ratio */
 #define NUM_TW_NODES 16
diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 9b28a9e90b..97655787ee 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -877,7 +877,7 @@ static int decode_usac_stereo_info(AACDecContext *ac, 
AACUSACConfig *usac,
 }
 
 us->tns_on_lr = 0;
-sce1->tns.present = sce2->tns.present = 0;
+ue1->tns_data_present = ue2->tns_data_present = 0;
 if (tns_active) {
 int common_tns = 0;
 if (us->common_window)
@@ -889,15 +889,17 @@ static int decode_usac_stereo_info(AACDecContext *ac, 
AACUSACConfig *usac,
 if (ret < 0)
 return ret;
 memcpy(&sce2->tns, &sce1->tns, sizeof(sce1->tns));
-sce2->tns.present = 0;
-sce1->tns.present = 0;
+sce2->tns.present = 1;
+sce1->tns.present = 1;
+ue1->tns_data_present = 0;
+ue2->tns_data_present = 0;
 } else {
 if (get_bits1(gb)) {
-sce2->tns.present = 1;
-sce1->tns.present = 1;
+ue1->tns_data_present = 1;
+ue2->tns_data_present = 1;
 } else {
-sce2->tns.present = get_bits1(gb);
-sce1->tns.present = !sce2->tns.present;
+ue2->tns_data_present = get_bits1(gb);
+ue1->tns_data_present = !ue2->tns_data_present;
 }
 }
 }
@@ -1277,12 +1279,14 @@ static int decode_usac_core_coder(AACDecContext *ac, 
AACUSACConfig *usac,
 uint8_t global_gain;
 
 us->common_window = 0;
-che->ch[0].tns.present = che->ch[1].tns.present = 0;
 
 for (int ch = 0; ch < nb_channels; ch++) {
 SingleChannelElement *sce = &che->ch[ch];
 AACUsacElemData *ue = &sce->ue;
 
+sce->tns.present = 0;
+ue->tns_data_present = 0;
+
 ue->core_mode = get_bits1(gb);
 }
 
@@ -1306,7 +1310,7 @@ static int decode_usac_core_coder(AACDecContext *ac, 
AACUSACConfig *usac,
 
 if ((nb_channels == 1) ||
 (che->ch[0].ue.core_mode != che->ch[1].ue.core_mode))
-sce->tns.present = get_bits1(gb);
+ue->tns_data_present = get_bits1(gb);
 
 /* fd_channel_stream */
 global_gain = get_bits(gb, 8);
@@ -1351,7 +1355,8 @@ static int decode_usac_core_coder(AACDecContext *ac, 
AACUSACConfig *usac,
 
 ac->dsp.dequant_scalefactors(sce);
 
-if (sce->tns.present) {
+if (ue->tns_data_present) {
+sce->tns.present = 1;
 ret = ff_aac_decode_tns(ac, &sce->tns, gb, ics);
 if (ret < 0)
 return ret;

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

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


[FFmpeg-cvslog] aacdec_usac: skip coeff decoding if the number to be decoded is 0

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Jun  6 04:38:47 2024 
+0200| [a18d0659f403cf4b93a3c5a293a42e0ff7348e90] | committer: Lynne

aacdec_usac: skip coeff decoding if the number to be decoded is 0

Yet another thing not mentioned in the spec.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a18d0659f403cf4b93a3c5a293a42e0ff7348e90
---

 libavcodec/aac/aacdec_usac.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 97655787ee..5dd489a43b 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -572,9 +572,15 @@ static int decode_spectrum_and_dequant_ac(AACDecContext 
*s, float coef[1024],
 int gb_count;
 GetBitContext gb2;
 
-ff_aac_ac_init(&ac, gb);
 c = ff_aac_ac_map_process(state, reset, N);
 
+if (!len) {
+ff_aac_ac_finish(state, 0, N);
+return 0;
+}
+
+ff_aac_ac_init(&ac, gb);
+
 /* Backup reader for rolling back by 14 bits at the end */
 gb2 = *gb;
 gb_count = get_bits_count(&gb2);

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

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


[FFmpeg-cvslog] aacdec_usac: do not continue parsing bitstream on core_mode == 1

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Jun  6 02:51:51 2024 
+0200| [c0fdb0cdfdbd9aff82a18402341827bf23c425f1] | committer: Lynne

aacdec_usac: do not continue parsing bitstream on core_mode == 1

Although LPD is not functional yet, the bitstream ends at that point.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c0fdb0cdfdbd9aff82a18402341827bf23c425f1
---

 libavcodec/aac/aacdec_usac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 3b4e980df4..9b28a9e90b 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -1301,6 +1301,7 @@ static int decode_usac_core_coder(AACDecContext *ac, 
AACUSACConfig *usac,
 ret = ff_aac_ldp_parse_channel_stream(ac, usac, ue, gb);
 if (ret < 0)
 return ret;
+continue;
 }
 
 if ((nb_channels == 1) ||

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

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


[FFmpeg-cvslog] aacdec_usac: do not round noise amplitude values

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Jun  6 17:23:47 2024 
+0200| [9b41cc04300e8d00ae3a6326639e975712e21bb6] | committer: Lynne

aacdec_usac: do not round noise amplitude values

Use floating point division instead of integer division.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b41cc04300e8d00ae3a6326639e975712e21bb6
---

 libavcodec/aac/aacdec_usac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 5dd489a43b..9173f1b354 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -930,7 +930,7 @@ static void apply_noise_fill(AACDecContext *ac, 
SingleChannelElement *sce,
 float *coef;
 IndividualChannelStream *ics = &sce->ics;
 
-float noise_val = pow(2, (ue->noise.level - 14)/3);
+float noise_val = powf(2, ((float)ue->noise.level - 14.0f)/3.0f);
 int noise_offset = ue->noise.offset - 16;
 int band_off;
 

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

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


[FFmpeg-cvslog] aacdec_usac: use correct TNS values

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Jun  6 17:33:18 2024 
+0200| [722352333524cb2047d09e2548b495f511de4331] | committer: Lynne

aacdec_usac: use correct TNS values

The standard slightly modified the maximum TNS bands allowed.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=722352333524cb2047d09e2548b495f511de4331
---

 libavcodec/aac/aacdec_usac.c | 4 ++--
 libavcodec/aactab.c  | 8 
 libavcodec/aactab.h  | 3 +++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 9173f1b354..edbf0bc1be 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -757,7 +757,7 @@ static int setup_sce(AACDecContext *ac, 
SingleChannelElement *sce,
 ics->swb_offset = ff_swb_offset_128[usac->rate_idx];
 ics->num_swb = ff_aac_num_swb_128[usac->rate_idx];
 }
-ics->tns_max_bands = ff_tns_max_bands_128[usac->rate_idx];
+ics->tns_max_bands = ff_tns_max_bands_usac_128[usac->rate_idx];
 
 /* Setup scalefactor grouping. 7 bit mask. */
 ics->num_window_groups = 0;
@@ -780,7 +780,7 @@ static int setup_sce(AACDecContext *ac, 
SingleChannelElement *sce,
 ics->swb_offset = ff_swb_offset_1024[usac->rate_idx];
 ics->num_swb = ff_aac_num_swb_1024[usac->rate_idx];
 }
-ics->tns_max_bands = ff_tns_max_bands_1024[usac->rate_idx];
+ics->tns_max_bands = ff_tns_max_bands_usac_1024[usac->rate_idx];
 
 ics->group_len[0] = 1;
 ics->num_window_groups = 1;
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index 7b040531aa..8d4587d241 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -1985,6 +1985,10 @@ const uint8_t ff_tns_max_bands_1024[] = {
 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39, 39
 };
 
+const uint8_t ff_tns_max_bands_usac_1024[] = {
+31, 31, 34, 40, 42, 51, 47, 47, 43, 43, 43, 40, 40
+};
+
 const uint8_t ff_tns_max_bands_512[] = {
 0, 0, 0, 31, 32, 37, 31, 31, 0, 0, 0, 0, 0
 };
@@ -1996,6 +2000,10 @@ const uint8_t ff_tns_max_bands_480[] = {
 const uint8_t ff_tns_max_bands_128[] = {
 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
 };
+
+const uint8_t ff_tns_max_bands_usac_128[] = {
+9, 9, 10, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15
+};
 // @}
 
 const uint8_t ff_usac_noise_fill_start_offset[2][2] = {
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index 8dbb2098c5..84879aa8f8 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -115,6 +115,9 @@ extern const uint8_t ff_tns_max_bands_512 [13];
 extern const uint8_t ff_tns_max_bands_480 [13];
 extern const uint8_t ff_tns_max_bands_128 [13];
 
+extern const uint8_t ff_tns_max_bands_usac_1024[13];
+extern const uint8_t ff_tns_max_bands_usac_128[13];
+
 /* [x][y], x == 1 -> frame len is 768 frames, y == 1 -> is eight_short */
 extern const uint8_t ff_usac_noise_fill_start_offset[2][2];
 

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

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


[FFmpeg-cvslog] aacdec_usac: fix stereo alpha values for transients

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Fri Jun  7 04:13:54 2024 
+0200| [c2d459cb516d05deb388248f2972b456840c9022] | committer: Lynne

aacdec_usac: fix stereo alpha values for transients

Typo.
Also added comments and fixed the branch underneath.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c2d459cb516d05deb388248f2972b456840c9022
---

 libavcodec/aac/aacdec.c  |  1 +
 libavcodec/aac/aacdec.h  |  1 +
 libavcodec/aac/aacdec_usac.c | 26 +-
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 24d2bdde4c..eecb6d8f3d 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1334,6 +1334,7 @@ static int decode_ics_info(AACDecContext *ac, 
IndividualChannelStream *ics,
 ics->use_kb_window[1]   = ics->use_kb_window[0];
 ics->use_kb_window[0]   = get_bits1(gb);
 }
+ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1);
 ics->num_window_groups  = 1;
 ics->group_len[0]   = 1;
 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index a2ef4a82e8..86faf6454a 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -164,6 +164,7 @@ typedef struct IndividualChannelStream {
 enum WindowSequence window_sequence[2];
 uint8_t use_kb_window[2];   ///< If set, use Kaiser-Bessel window, 
otherwise use a sine window.
 int num_window_groups;
+int prev_num_window_groups; ///< Previous frame's number of window groups
 uint8_t group_len[8];
 LongTermPrediction ltp;
 const uint16_t *swb_offset; ///< table of offsets to the lowest spectral 
coefficient of a scalefactor band, sfb, for a particular window
diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index edbf0bc1be..fbec6e26bd 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -658,7 +658,9 @@ static int decode_spectrum_and_dequant_ac(AACDecContext *s, 
float coef[1024],
 
 static int decode_usac_stereo_cplx(AACDecContext *ac, AACUsacStereo *us,
ChannelElement *cpe, GetBitContext *gb,
-   int num_window_groups, int indep_flag)
+   int num_window_groups,
+   int prev_num_window_groups,
+   int indep_flag)
 {
 int delta_code_time;
 IndividualChannelStream *ics = &cpe->ch[0].ics;
@@ -696,15 +698,18 @@ static int decode_usac_stereo_cplx(AACDecContext *ac, 
AACUsacStereo *us,
 float last_alpha_q_im = 0;
 if (delta_code_time) {
 if (g) {
-last_alpha_q_re = us->prev_alpha_q_re[(g - 
1)*cpe->max_sfb_ste + sfb];
-last_alpha_q_im = us->prev_alpha_q_im[(g - 
1)*cpe->max_sfb_ste + sfb];
-} else if ((ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) &&
-   ics->window_sequence[1] == EIGHT_SHORT_SEQUENCE ||
-   ics->window_sequence[1] == EIGHT_SHORT_SEQUENCE) {
+/* Transient, after the first group - use the current 
frame,
+ * previous window, alpha values. */
+last_alpha_q_re = us->alpha_q_re[(g - 1)*cpe->max_sfb_ste 
+ sfb];
+last_alpha_q_im = us->alpha_q_im[(g - 1)*cpe->max_sfb_ste 
+ sfb];
+} else if (!g &&
+   (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) &&
+   (ics->window_sequence[1] == EIGHT_SHORT_SEQUENCE)) {
 /* The spec doesn't explicitly mention this, but it 
doesn't make
  * any other sense otherwise! */
-last_alpha_q_re = us->prev_alpha_q_re[7*cpe->max_sfb_ste + 
sfb];
-last_alpha_q_im = us->prev_alpha_q_im[7*cpe->max_sfb_ste + 
sfb];
+const int wg = prev_num_window_groups - 1;
+last_alpha_q_re = us->prev_alpha_q_re[wg*cpe->max_sfb_ste 
+ sfb];
+last_alpha_q_im = us->prev_alpha_q_im[wg*cpe->max_sfb_ste 
+ sfb];
 } else {
 last_alpha_q_re = us->prev_alpha_q_re[g*cpe->max_sfb_ste + 
sfb];
 last_alpha_q_im = us->prev_alpha_q_im[g*cpe->max_sfb_ste + 
sfb];
@@ -749,6 +754,7 @@ static int setup_sce(AACDecContext *ac, 
SingleChannelElement *sce,
 IndividualChannelStream *ics = &sce->ics;
 
 /* Setup window parameters */
+ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1);
 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
 if (usac->core_frame_len == 768) {
 ics->swb_offset = f

[FFmpeg-cvslog] aacdec_usac: zero out alpha values for the current frame

2024-06-07 Thread Lynne
ffmpeg | branch: master | Lynne  | Fri Jun  7 04:17:13 2024 
+0200| [714596bcbf990ec3e82f8fde110954755cc1bf6e] | committer: Lynne

aacdec_usac: zero out alpha values for the current frame

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=714596bcbf990ec3e82f8fde110954755cc1bf6e
---

 libavcodec/aac/aacdec_usac.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index fbec6e26bd..aa89b83182 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -691,6 +691,10 @@ static int decode_usac_stereo_cplx(AACDecContext *ac, 
AACUsacStereo *us,
 if (!indep_flag)
 delta_code_time = get_bits1(gb);
 
+/* Alpha values must be zeroed out if pred_used is 0. */
+memset(us->alpha_q_re, 0, sizeof(us->alpha_q_re));
+memset(us->alpha_q_im, 0, sizeof(us->alpha_q_im));
+
 /* TODO: shouldn't be needed */
 for (int g = 0; g < num_window_groups; g++) {
 for (int sfb = 0; sfb < cpe->max_sfb_ste; sfb += SFB_PER_PRED_BAND) {

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

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


[FFmpeg-cvslog] aacdec_usac: dequantize scalefactors after noise synthesis

2024-06-11 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun 12 03:20:56 2024 
+0200| [11a8e0a4e585c0a5acf09397e39bccf45e1ba7ae] | committer: Lynne

aacdec_usac: dequantize scalefactors after noise synthesis

The issue here is that the spec implied that the offset is done
on the dequantized scalefactor, but in fact, it is done on the
scalefactor offset. Delay dequantizing the scalefactors until
after noise synthesis is performed, and change to apply the
offset onto the offset.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=11a8e0a4e585c0a5acf09397e39bccf45e1ba7ae
---

 libavcodec/aac/aacdec_usac.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index aa89b83182..100203ff71 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -971,7 +971,7 @@ static void apply_noise_fill(AACDecContext *ac, 
SingleChannelElement *sce,
 }
 
 if (band_quantized_to_zero)
-sce->sf[g*ics->max_sfb + sfb] += noise_offset;
+sce->sfo[g*ics->max_sfb + sfb] += noise_offset;
 }
 coef += g_len << 7;
 }
@@ -987,6 +987,9 @@ static void spectrum_scale(AACDecContext *ac, 
SingleChannelElement *sce,
 if (ue->noise.level)
 apply_noise_fill(ac, sce, ue);
 
+/* Noise filling may apply an offset to the scalefactor offset */
+ac->dsp.dequant_scalefactors(sce);
+
 /* Apply scalefactors */
 coef = sce->coeffs;
 for (int g = 0; g < ics->num_window_groups; g++) {
@@ -1371,8 +1374,6 @@ static int decode_usac_core_coder(AACDecContext *ac, 
AACUSACConfig *usac,
 if (ret < 0)
 return ret;
 
-ac->dsp.dequant_scalefactors(sce);
-
 if (ue->tns_data_present) {
 sce->tns.present = 1;
 ret = ff_aac_decode_tns(ac, &sce->tns, gb, ics);

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

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


[FFmpeg-cvslog] aacdec_usac: rename spectrum decode function and remove unused arg

2024-06-11 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun 12 03:25:07 2024 
+0200| [d79fbad366896873d9d4d219cce9578797944dea] | committer: Lynne

aacdec_usac: rename spectrum decode function and remove unused arg

The LC part of the decoder combines scalefactor application with
spectrum decoding, and this was the plan here, but that's not possible,
so change the function name.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d79fbad366896873d9d4d219cce9578797944dea
---

 libavcodec/aac/aacdec_usac.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 100203ff71..81aba5ddf4 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -560,10 +560,9 @@ static int decode_usac_scale_factors(AACDecContext *ac,
  *
  * @return  Returns error status. 0 - OK, !0 - error
  */
-static int decode_spectrum_and_dequant_ac(AACDecContext *s, float coef[1024],
-  GetBitContext *gb, const float 
sf[120],
-  AACArithState *state, int reset,
-  uint16_t len, uint16_t N)
+static int decode_spectrum_ac(AACDecContext *s, float coef[1024],
+  GetBitContext *gb, AACArithState *state,
+  int reset, uint16_t len, uint16_t N)
 {
 AACArith ac;
 int i, a, b;
@@ -1396,10 +1395,8 @@ static int decode_usac_core_coder(AACDecContext *ac, 
AACUSACConfig *usac,
 else
 N = usac->core_frame_len;
 
-ret = decode_spectrum_and_dequant_ac(ac, sce->coeffs + win*128, gb,
- sce->sf, &ue->ac,
- arith_reset_flag && (win == 
0),
- lg, N);
+ret = decode_spectrum_ac(ac, sce->coeffs + win*128, gb, &ue->ac,
+ arith_reset_flag && (win == 0), lg, N);
 if (ret < 0)
 return ret;
 }

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

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


[FFmpeg-cvslog] aacdec_usac: always zero out alpha_q values for stereo streams

2024-06-11 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun 12 03:31:58 2024 
+0200| [bdd3c6ca5015e29d12fa3d317a6d8b6958156a93] | committer: Lynne

aacdec_usac: always zero out alpha_q values for stereo streams

The issue is that if a frame has no complex stereo prediction,
the alpha values must all be assumed to be zero if the next frame
has complex prediction and uses delta coding.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bdd3c6ca5015e29d12fa3d317a6d8b6958156a93
---

 libavcodec/aac/aacdec_usac.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 81aba5ddf4..98e8c1c0bc 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -690,10 +690,6 @@ static int decode_usac_stereo_cplx(AACDecContext *ac, 
AACUsacStereo *us,
 if (!indep_flag)
 delta_code_time = get_bits1(gb);
 
-/* Alpha values must be zeroed out if pred_used is 0. */
-memset(us->alpha_q_re, 0, sizeof(us->alpha_q_re));
-memset(us->alpha_q_im, 0, sizeof(us->alpha_q_im));
-
 /* TODO: shouldn't be needed */
 for (int g = 0; g < num_window_groups; g++) {
 for (int sfb = 0; sfb < cpe->max_sfb_ste; sfb += SFB_PER_PRED_BAND) {
@@ -828,6 +824,11 @@ static int decode_usac_stereo_info(AACDecContext *ac, 
AACUSACConfig *usac,
 us->common_window = 0;
 us->common_tw = 0;
 
+/* Alpha values must always be zeroed out for the current frame,
+ * as they are propagated to the next frame and may be used. */
+memset(us->alpha_q_re, 0, sizeof(us->alpha_q_re));
+memset(us->alpha_q_im, 0, sizeof(us->alpha_q_im));
+
 if (!(!ue1->core_mode && !ue2->core_mode))
 return 0;
 

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

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


[FFmpeg-cvslog] configure: update copyright year

2024-06-14 Thread Lynne
ffmpeg | branch: release/5.1 | Lynne  | Mon Jan  1 00:00:00 2024 
+| [68f2794354fda2675187fd9414532845fce2bd7a] | committer: Michael 
Niedermayer

configure: update copyright year

(cherry picked from commit b95ee2ec5f84054de8bf6db9fe1b1119d569f269)
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=68f2794354fda2675187fd9414532845fce2bd7a
---

 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 42bd6b5397..39a5bb8b7d 100755
--- a/configure
+++ b/configure
@@ -7785,7 +7785,7 @@ cat > $TMPH <https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] configure: update copyright year

2024-06-15 Thread Lynne
ffmpeg | branch: release/4.3 | Lynne  | Mon Jan  1 00:00:00 2024 
+| [41a5eae142c8f00980ae6d58bf3cf8a869e5231a] | committer: Michael 
Niedermayer

configure: update copyright year

(cherry picked from commit b95ee2ec5f84054de8bf6db9fe1b1119d569f269)
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=41a5eae142c8f00980ae6d58bf3cf8a869e5231a
---

 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 5734edaa5a..b111033590 100755
--- a/configure
+++ b/configure
@@ -7515,7 +7515,7 @@ cat > $TMPH <https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] aacdec_usac: remove custom rate_idx and use standard variable for it

2024-06-21 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Jun 16 10:28:05 2024 
+0200| [d45e20c37b1144d9c4ff08732a94fee0786dc0b5] | committer: Lynne

aacdec_usac: remove custom rate_idx and use standard variable for it

m4ac.sampling_index is what aacdec.c uses.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d45e20c37b1144d9c4ff08732a94fee0786dc0b5
---

 libavcodec/aac/aacdec.h  |  1 -
 libavcodec/aac/aacdec_usac.c | 35 ++-
 2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index d1a80e9ac1..e5a79a7139 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -350,7 +350,6 @@ typedef struct AACUsacElemConfig {
 
 typedef struct AACUSACConfig {
 uint8_t core_sbr_frame_len_idx; /* coreSbrFrameLengthIndex */
-uint8_t rate_idx;
 uint16_t core_frame_len;
 uint16_t stream_identifier;
 
diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index eb0e7d3659..e5504117d0 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -316,7 +316,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
   GetBitContext *gb, OutputConfiguration *oc,
   int channel_config)
 {
-int ret, idx;
+int ret;
 uint8_t freq_idx;
 uint8_t channel_config_idx;
 int nb_channels = 0;
@@ -334,20 +334,10 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 freq_idx = get_bits(gb, 5); /* usacSamplingFrequencyIndex */
 if (freq_idx == 0x1f) {
 samplerate = get_bits(gb, 24); /* usacSamplingFrequency */
-
-/* Try to match up an index for the custom sample rate.
- * TODO: not sure if correct */
-for (idx = 0; idx < /* FF_ARRAY_ELEMS(ff_aac_usac_samplerate) */ 32; 
idx++) {
-if (ff_aac_usac_samplerate[idx] >= samplerate)
-break;
-}
-idx = FFMIN(idx, /* FF_ARRAY_ELEMS(ff_aac_usac_samplerate) */ 32 - 1);
-usac->rate_idx = idx;
 } else {
 samplerate = ff_aac_usac_samplerate[freq_idx];
 if (samplerate < 0)
 return AVERROR(EINVAL);
-usac->rate_idx = freq_idx;
 }
 
 m4ac->sample_rate = avctx->sample_rate = samplerate;
@@ -364,6 +354,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 usac->core_sbr_frame_len_idx == 4 ? 1 :
 0;
 
+m4ac->sampling_index = ff_aac_sample_rate_idx(m4ac->sample_rate);
+
 channel_config_idx = get_bits(gb, 5); /* channelConfigurationIndex */
 if (!channel_config_idx) {
 /* UsacChannelConfig() */
@@ -751,18 +743,19 @@ static int setup_sce(AACDecContext *ac, 
SingleChannelElement *sce,
 {
 AACUsacElemData *ue = &sce->ue;
 IndividualChannelStream *ics = &sce->ics;
+const int sampling_index = ac->oc[1].m4ac.sampling_index;
 
 /* Setup window parameters */
 ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1);
 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
 if (usac->core_frame_len == 768) {
-ics->swb_offset = ff_swb_offset_96[usac->rate_idx];
-ics->num_swb = ff_aac_num_swb_96[usac->rate_idx];
+ics->swb_offset = ff_swb_offset_96[sampling_index];
+ics->num_swb = ff_aac_num_swb_96[sampling_index];
 } else {
-ics->swb_offset = ff_swb_offset_128[usac->rate_idx];
-ics->num_swb = ff_aac_num_swb_128[usac->rate_idx];
+ics->swb_offset = ff_swb_offset_128[sampling_index];
+ics->num_swb = ff_aac_num_swb_128[sampling_index];
 }
-ics->tns_max_bands = ff_tns_max_bands_usac_128[usac->rate_idx];
+ics->tns_max_bands = ff_tns_max_bands_usac_128[sampling_index];
 
 /* Setup scalefactor grouping. 7 bit mask. */
 ics->num_window_groups = 0;
@@ -779,13 +772,13 @@ static int setup_sce(AACDecContext *ac, 
SingleChannelElement *sce,
 ics->num_windows = 8;
 } else {
 if (usac->core_frame_len == 768) {
-ics->swb_offset = ff_swb_offset_768[usac->rate_idx];
-ics->num_swb = ff_aac_num_swb_768[usac->rate_idx];
+ics->swb_offset = ff_swb_offset_768[sampling_index];
+ics->num_swb = ff_aac_num_swb_768[sampling_index];
 } else {
-ics->swb_offset = ff_swb_offset_1024[usac->rate_idx];
-ics->num_swb = ff_aac_num_swb_1024[usac->rate_idx];
+ics->swb_offset = ff_swb_offset_1024[sampling_index];
+ics->num_swb = ff_aac_num_swb_1024[sampling_index];
 }
-ics->tns_max_bands = ff_tns_max_bands_usac_1024[usac->rate_idx];
+ics->tns_max_bands = ff_tns_max_bands_usac_1024[sampling_index];

[FFmpeg-cvslog] aac: expose ff_aac_sample_rate_idx() in aac.h

2024-06-21 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Jun 16 10:20:56 2024 
+0200| [50e5b78b79f5b908e249ca5aca23be7be23bedad] | committer: Lynne

aac: expose ff_aac_sample_rate_idx() in aac.h

The rate index is a value important to both encoders and decoders.
USAC needs it as well, so put it into the shared main header.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=50e5b78b79f5b908e249ca5aca23be7be23bedad
---

 libavcodec/aac.h| 16 
 libavcodec/aac/aacdec.c | 18 +-
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index fc6d1361b2..78026a5887 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -103,4 +103,20 @@ typedef struct Pulse {
 int amp[4];
 } Pulse;
 
+static inline int ff_aac_sample_rate_idx(int rate)
+{
+ if (92017 <= rate) return 0;
+else if (75132 <= rate) return 1;
+else if (55426 <= rate) return 2;
+else if (46009 <= rate) return 3;
+else if (37566 <= rate) return 4;
+else if (27713 <= rate) return 5;
+else if (23004 <= rate) return 6;
+else if (18783 <= rate) return 7;
+else if (13856 <= rate) return 8;
+else if (11502 <= rate) return 9;
+else if (9391  <= rate) return 10;
+elsereturn 11;
+}
+
 #endif /* AVCODEC_AAC_H */
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index eecb6d8f3d..ea2ba84a80 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1095,22 +1095,6 @@ static int decode_audio_specific_config(AACDecContext 
*ac,
sync_extension);
 }
 
-static int sample_rate_idx (int rate)
-{
- if (92017 <= rate) return 0;
-else if (75132 <= rate) return 1;
-else if (55426 <= rate) return 2;
-else if (46009 <= rate) return 3;
-else if (37566 <= rate) return 4;
-else if (27713 <= rate) return 5;
-else if (23004 <= rate) return 6;
-else if (18783 <= rate) return 7;
-else if (13856 <= rate) return 8;
-else if (11502 <= rate) return 9;
-else if (9391  <= rate) return 10;
-elsereturn 11;
-}
-
 static av_cold int decode_close(AVCodecContext *avctx)
 {
 AACDecContext *ac = avctx->priv_data;
@@ -1211,7 +1195,7 @@ av_cold int ff_aac_decode_init(AVCodecContext *avctx)
 uint8_t layout_map[MAX_ELEM_ID*4][3];
 int layout_map_tags;
 
-sr = sample_rate_idx(avctx->sample_rate);
+sr = ff_aac_sample_rate_idx(avctx->sample_rate);
 ac->oc[1].m4ac.sampling_index = sr;
 ac->oc[1].m4ac.channels = avctx->ch_layout.nb_channels;
 ac->oc[1].m4ac.sbr = -1;

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

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


[FFmpeg-cvslog] aacdec_ac: fix an overread

2024-06-21 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Jun 16 10:22:25 2024 
+0200| [89de2f0de1a41349fe827c00c8f52ca3c12594ad] | committer: Lynne

aacdec_ac: fix an overread

Fixes reading state->last[i + 1] in ff_aac_ac_get_context for the
last array member.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=89de2f0de1a41349fe827c00c8f52ca3c12594ad
---

 libavcodec/aac/aacdec_ac.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aac/aacdec_ac.h b/libavcodec/aac/aacdec_ac.h
index 0b98c0f0d9..b8d4ade4c6 100644
--- a/libavcodec/aac/aacdec_ac.h
+++ b/libavcodec/aac/aacdec_ac.h
@@ -25,7 +25,7 @@
 #include "libavcodec/get_bits.h"
 
 typedef struct AACArithState {
-uint8_t last[512 /* 2048 / 4 */];
+uint8_t last[512 /* 2048 / 4 */ + 1];
 int last_len;
 uint8_t cur[4];
 uint16_t state_pre;

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

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


[FFmpeg-cvslog] aacdec_usac: rename noise_scale to noise_bands

2024-06-21 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Jun 16 10:25:26 2024 
+0200| [a381cbc7c77bc9477d9c42607a4e849aa20cdd06] | committer: Lynne

aacdec_usac: rename noise_scale to noise_bands

This was a typo.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a381cbc7c77bc9477d9c42607a4e849aa20cdd06
---

 libavcodec/aac/aacdec.h  | 2 +-
 libavcodec/aac/aacdec_usac.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index 86faf6454a..d1a80e9ac1 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -315,7 +315,7 @@ typedef struct AACUsacElemConfig {
 
 uint8_t freq_scale; /* dflt_freq_scale */
 uint8_t alter_scale : 1; /* dflt_alter_scale */
-uint8_t noise_scale; /* dflt_noise_scale */
+uint8_t noise_bands; /* dflt_noise_bands */
 
 uint8_t limiter_bands; /* dflt_limiter_bands */
 uint8_t limiter_gains; /* dflt_limiter_gains */
diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 065bc869d9..eb0e7d3659 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -162,11 +162,11 @@ static void decode_usac_sbr_data(AACUsacElemConfig *e, 
GetBitContext *gb)
 
 e->sbr.dflt.freq_scale = 2;
 e->sbr.dflt.alter_scale = 1;
-e->sbr.dflt.noise_scale = 2;
+e->sbr.dflt.noise_bands = 2;
 if (header_extra1) {
 e->sbr.dflt.freq_scale = get_bits(gb, 2); /* dflt_freq_scale */
 e->sbr.dflt.alter_scale = get_bits1(gb); /* dflt_alter_scale */
-e->sbr.dflt.noise_scale = get_bits(gb, 2); /* dflt_noise_scale */
+e->sbr.dflt.noise_bands = get_bits(gb, 2); /* dflt_noise_bands */
 }
 
 e->sbr.dflt.limiter_bands = 2;

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

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


[FFmpeg-cvslog] aacdec_usac: apply specification fix M55715

2024-06-21 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jun 12 14:32:22 2024 
+0200| [1c3545f053bea8d919608f47d02bc095a006411f] | committer: Lynne

aacdec_usac: apply specification fix M55715

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1c3545f053bea8d919608f47d02bc095a006411f
---

 libavcodec/aac/aacdec_usac.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 98e8c1c0bc..065bc869d9 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -835,6 +835,11 @@ static int decode_usac_stereo_info(AACDecContext *ac, 
AACUSACConfig *usac,
 tns_active = get_bits1(gb);
 us->common_window = get_bits1(gb);
 
+if (!us->common_window || indep_flag) {
+memset(us->prev_alpha_q_re, 0, sizeof(us->prev_alpha_q_re));
+memset(us->prev_alpha_q_im, 0, sizeof(us->prev_alpha_q_im));
+}
+
 if (us->common_window) {
 /* ics_info() */
 ics1->window_sequence[1] = ics1->window_sequence[0];
@@ -845,6 +850,20 @@ static int decode_usac_stereo_info(AACDecContext *ac, 
AACUSACConfig *usac,
 ics2->use_kb_window[1] = ics2->use_kb_window[0];
 ics1->use_kb_window[0] = ics2->use_kb_window[0] = get_bits1(gb);
 
+/* If there's a change in the transform sequence, zero out last frame's
+ * stereo prediction coefficients */
+if ((ics1->window_sequence[0] == EIGHT_SHORT_SEQUENCE &&
+ ics1->window_sequence[1] != EIGHT_SHORT_SEQUENCE) ||
+(ics1->window_sequence[1] == EIGHT_SHORT_SEQUENCE &&
+ ics1->window_sequence[0] != EIGHT_SHORT_SEQUENCE) ||
+(ics2->window_sequence[0] == EIGHT_SHORT_SEQUENCE &&
+ ics2->window_sequence[1] != EIGHT_SHORT_SEQUENCE) ||
+(ics2->window_sequence[1] == EIGHT_SHORT_SEQUENCE &&
+ ics2->window_sequence[0] != EIGHT_SHORT_SEQUENCE)) {
+memset(us->prev_alpha_q_re, 0, sizeof(us->prev_alpha_q_re));
+memset(us->prev_alpha_q_im, 0, sizeof(us->prev_alpha_q_im));
+}
+
 if (ics1->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
 ics1->max_sfb = ics2->max_sfb = get_bits(gb, 4);
 ue1->scale_factor_grouping = ue2->scale_factor_grouping = 
get_bits(gb, 7);

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

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


[FFmpeg-cvslog] aacdec_usac, aacsbr: implement SBR support for USAC

2024-06-23 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Jun 16 10:52:13 2024 
+0200| [0b67c83b2eadf6350587ae7c4a63a8f9bba67cae] | committer: Lynne

aacdec_usac, aacsbr: implement SBR support for USAC

Currently, no eSBR features are supported.
Thankfully, no encoders exist for it yet.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0b67c83b2eadf6350587ae7c4a63a8f9bba67cae
---

 libavcodec/aac/aacdec_usac.c | 119 +++---
 libavcodec/aacsbr.h  |  11 ++
 libavcodec/aacsbr_template.c | 232 ---
 libavcodec/sbr.h |  32 +++---
 4 files changed, 351 insertions(+), 43 deletions(-)

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index e5504117d0..132ffee9c2 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -23,6 +23,8 @@
 #include "aacdec_lpd.h"
 #include "aacdec_ac.h"
 
+#include "libavcodec/aacsbr.h"
+
 #include "libavcodec/aactab.h"
 #include "libavutil/mem.h"
 #include "libavcodec/mpeg4audio.h"
@@ -145,7 +147,8 @@ static int decode_loudness_set(AACDecContext *ac, 
AACUSACConfig *usac,
 return 0;
 }
 
-static void decode_usac_sbr_data(AACUsacElemConfig *e, GetBitContext *gb)
+static int decode_usac_sbr_data(AACDecContext *ac,
+AACUsacElemConfig *e, GetBitContext *gb)
 {
 uint8_t header_extra1;
 uint8_t header_extra2;
@@ -153,6 +156,10 @@ static void decode_usac_sbr_data(AACUsacElemConfig *e, 
GetBitContext *gb)
 e->sbr.harmonic_sbr = get_bits1(gb); /* harmonicSBR */
 e->sbr.bs_intertes = get_bits1(gb); /* bs_interTes */
 e->sbr.bs_pvc = get_bits1(gb); /* bs_pvc */
+if (e->sbr.harmonic_sbr || e->sbr.bs_intertes || e->sbr.bs_pvc) {
+avpriv_report_missing_feature(ac->avctx, "AAC USAC eSBR");
+return AVERROR_PATCHWELCOME;
+}
 
 e->sbr.dflt.start_freq = get_bits(gb, 4); /* dflt_start_freq */
 e->sbr.dflt.stop_freq = get_bits(gb, 4); /* dflt_stop_freq */
@@ -179,6 +186,8 @@ static void decode_usac_sbr_data(AACUsacElemConfig *e, 
GetBitContext *gb)
 e->sbr.dflt.interpol_freq = get_bits1(gb); /* dflt_interpol_freq */
 e->sbr.dflt.smoothing_mode = get_bits1(gb); /* dflt_smoothing_mode */
 }
+
+return 0;
 }
 
 static void decode_usac_element_core(AACUsacElemConfig *e,
@@ -190,13 +199,17 @@ static void decode_usac_element_core(AACUsacElemConfig *e,
 e->sbr.ratio = sbr_ratio;
 }
 
-static void decode_usac_element_pair(AACUsacElemConfig *e, GetBitContext *gb)
+static int decode_usac_element_pair(AACDecContext *ac,
+AACUsacElemConfig *e, GetBitContext *gb)
 {
 e->stereo_config_index = 0;
 if (e->sbr.ratio) {
-decode_usac_sbr_data(e, gb);
+int ret = decode_usac_sbr_data(ac, e, gb);
+if (ret < 0)
+return ret;
 e->stereo_config_index = get_bits(gb, 2);
 }
+
 if (e->stereo_config_index) {
 e->mps.freq_res = get_bits(gb, 3); /* bsFreqRes */
 e->mps.fixed_gain = get_bits(gb, 3); /* bsFixedGainDMX */
@@ -216,6 +229,8 @@ static void decode_usac_element_pair(AACUsacElemConfig *e, 
GetBitContext *gb)
 if (e->mps.temp_shape_config == 2)
 e->mps.env_quant_mode = get_bits1(gb); /* bsEnvQuantMode */
 }
+
+return 0;
 }
 
 static int decode_usac_extension(AACDecContext *ac, AACUsacElemConfig *e,
@@ -294,6 +309,9 @@ int ff_aac_usac_reset_state(AACDecContext *ac, 
OutputConfiguration *oc)
 AACUsacStereo *us = &che->us;
 memset(us, 0, sizeof(*us));
 
+if (e->sbr.ratio)
+ff_aac_sbr_config_usac(ac, che, e);
+
 for (int j = 0; j < ch; j++) {
 SingleChannelElement *sce = &che->ch[ch];
 AACUsacElemData *ue = &sce->ue;
@@ -320,6 +338,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 uint8_t freq_idx;
 uint8_t channel_config_idx;
 int nb_channels = 0;
+int ratio_mult, ratio_dec;
 int samplerate;
 int sbr_ratio;
 MPEG4AudioConfig *m4ac = &oc->m4ac;
@@ -340,8 +359,6 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 return AVERROR(EINVAL);
 }
 
-m4ac->sample_rate = avctx->sample_rate = samplerate;
-
 usac->core_sbr_frame_len_idx = get_bits(gb, 3); /* coreSbrFrameLengthIndex 
*/
 m4ac->frame_length_short = usac->core_sbr_frame_len_idx == 0 ||
usac->core_sbr_frame_len_idx == 2;
@@ -354,7 +371,26 @@ int ff_aac_usac_config_decode(AACDecContext *ac, 
AVCodecContext *avctx,
 usac->core_sbr_frame_len_idx == 4 ? 1 :
 0;
 
+if (sbr_ratio == 2) {
+ratio_mult = 8;
+ratio_dec = 3;
+} else if (sbr_ratio == 3) {
+ 

[FFmpeg-cvslog] lavu/stereo3d: change the horizontal FOV field to a rational

2024-06-24 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Jun 23 15:58:28 2024 
+0200| [dae12ddb2e5d4ec8cf5a965f4ac793edfa3802d6] | committer: Lynne

lavu/stereo3d: change the horizontal FOV field to a rational

This avoids hardcoding any implementation-specific limitiations as
part of the API, and allows for future expandability.

This also allows API users to more conveniently convert the
values into floats without hardcoding specific conversion constants.

The API was committed a few days ago, so changing this field now
is within the realms of acceptable.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dae12ddb2e5d4ec8cf5a965f4ac793edfa3802d6
---

 fftools/ffprobe.c| 2 +-
 libavformat/dump.c   | 5 +++--
 libavformat/mov.c| 3 ++-
 libavutil/stereo3d.c | 1 +
 libavutil/stereo3d.h | 4 ++--
 tests/ref/fate/matroska-spherical-mono   | 2 +-
 tests/ref/fate/matroska-spherical-mono-remux | 4 ++--
 tests/ref/fate/matroska-stereo_mode  | 8 
 tests/ref/fate/matroska-vp8-alpha-remux  | 2 +-
 tests/ref/fate/mov-spherical-mono| 2 +-
 10 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index d7ba980ff9..b69a75ff9a 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2548,7 +2548,7 @@ static void print_pkt_side_data(WriterContext *w,
 print_str("primary_eye", 
av_stereo3d_primary_eye_name(stereo->primary_eye));
 print_int("baseline", stereo->baseline);
 print_q("horizontal_disparity_adjustment", 
stereo->horizontal_disparity_adjustment, '/');
-print_int("horizontal_field_of_view", 
stereo->horizontal_field_of_view);
+print_q("horizontal_field_of_view", 
stereo->horizontal_field_of_view, '/');
 } else if (sd->type == AV_PKT_DATA_SPHERICAL) {
 const AVSphericalMapping *spherical = (AVSphericalMapping 
*)sd->data;
 print_str("projection", 
av_spherical_projection_name(spherical->projection));
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 61a2c6a29f..b71b5356dc 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -267,8 +267,9 @@ static void dump_stereo3d(void *ctx, const AVPacketSideData 
*sd, int log_level)
 if (stereo->horizontal_disparity_adjustment.num && 
stereo->horizontal_disparity_adjustment.den)
 av_log(ctx, log_level, ", horizontal_disparity_adjustment: %d/%d",
stereo->horizontal_disparity_adjustment.num, 
stereo->horizontal_disparity_adjustment.den);
-if (stereo->horizontal_field_of_view)
-av_log(ctx, log_level, ", horizontal_field_of_view: %"PRIu32"", 
stereo->horizontal_field_of_view);
+if (stereo->horizontal_field_of_view.num && 
stereo->horizontal_field_of_view.den)
+av_log(ctx, log_level, ", horizontal_field_of_view: %d/%d", 
stereo->horizontal_field_of_view.num,
+   stereo->horizontal_field_of_view.den);
 
 if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
 av_log(ctx, log_level, " (inverted)");
diff --git a/libavformat/mov.c b/libavformat/mov.c
index f08fec3fb6..fe8a963c6e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6782,7 +6782,8 @@ static int mov_read_hfov(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return AVERROR(ENOMEM);
 }
 
-sc->stereo3d->horizontal_field_of_view = avio_rb32(pb);
+sc->stereo3d->horizontal_field_of_view.num = avio_rb32(pb);
+sc->stereo3d->horizontal_field_of_view.den = 1000; // thousands of a degree
 
 return 0;
 }
diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
index 19e81e4124..ad6064e5d9 100644
--- a/libavutil/stereo3d.c
+++ b/libavutil/stereo3d.c
@@ -29,6 +29,7 @@
 static void get_defaults(AVStereo3D *stereo)
 {
 stereo->horizontal_disparity_adjustment = (AVRational) { 0, 1 };
+stereo->horizontal_field_of_view = (AVRational) { 0, 1 };
 }
 
 AVStereo3D *av_stereo3d_alloc(void)
diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h
index 00a5c3900e..d8b191118c 100644
--- a/libavutil/stereo3d.h
+++ b/libavutil/stereo3d.h
@@ -224,9 +224,9 @@ typedef struct AVStereo3D {
 AVRational horizontal_disparity_adjustment;
 
 /**
- * Horizontal field of view in thousanths of a degree. Zero if unset.
+ * Horizontal field of view, in degrees. Zero if unset.
  */
-uint32_t horizontal_field_of_view;
+AVRational horizontal_field_of_view;
 } AVStereo3D;
 
 /**
diff --git a/tests/ref/fate/matroska-spherical-mono 
b/tests/ref/fate/matroska-spherical-mono
index b108596350..065b109a41 100644
--- a/tests/ref/fate/matroska-spherical-mono
+++ b/tests/ref/fate/matroska-spherical-mono
@@

[FFmpeg-cvslog] vulkan: rename read_only to singular

2024-07-14 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Jul 14 18:30:26 2024 
+0200| [80ddc727178837a5ea5e6e463f28fedf6c1051dd] | committer: Lynne

vulkan: rename read_only to singular

There's nothing stopping users from writing to such buffers.
Its more accurate to say they are singular, i.e. not duplicated
between multiple submissions.

This can be helpful for global statistics, or error propagation
purposes.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=80ddc727178837a5ea5e6e463f28fedf6c1051dd
---

 libavutil/vulkan.c | 10 +-
 libavutil/vulkan.h |  5 +++--
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index a9125ea6b9..11c17ee6f3 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -1465,7 +1465,7 @@ static const struct descriptor_props {
 int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl,
   FFVkSPIRVShader *shd,
   FFVulkanDescriptorSetBinding *desc, int 
nb,
-  int read_only, int print_to_shader_only)
+  int singular, int print_to_shader_only)
 {
 VkResult ret;
 int has_sampler = 0;
@@ -1535,7 +1535,7 @@ int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, 
FFVulkanPipeline *pl,
 vk->GetDescriptorSetLayoutBindingOffsetEXT(s->hwctx->act_dev, 
set->layout,
i, &set->binding_offset[i]);
 
-set->read_only = read_only;
+set->singular = singular;
 set->nb_bindings = nb;
 pl->nb_descriptor_sets++;
 
@@ -1592,7 +1592,7 @@ int ff_vk_exec_pipeline_register(FFVulkanContext *s, 
FFVkExecPool *pool,
 
 for (int i = 0; i < pl->nb_descriptor_sets; i++) {
 FFVulkanDescriptorSet *set = &pl->desc_set[i];
-int nb = set->read_only ? 1 : pool->pool_size;
+int nb = set->singular ? 1 : pool->pool_size;
 
 err = ff_vk_create_buf(s, &set->buf, set->aligned_size*nb,
NULL, NULL, set->usage,
@@ -1624,7 +1624,7 @@ static inline void update_set_descriptor(FFVulkanContext 
*s, FFVkExecContext *e,
  size_t desc_size)
 {
 FFVulkanFunctions *vk = &s->vkfn;
-const size_t exec_offset = set->read_only ? 0 : set->aligned_size*e->idx;
+const size_t exec_offset = set->singular ? 0 : set->aligned_size*e->idx;
 void *desc = set->desc_mem + /* Base */
  exec_offset +   /* Execution context */
  set->binding_offset[bind_idx] + /* Descriptor binding */
@@ -1831,7 +1831,7 @@ void ff_vk_exec_bind_pipeline(FFVulkanContext *s, 
FFVkExecContext *e,
 
 if (pl->nb_descriptor_sets) {
 for (int i = 0; i < pl->nb_descriptor_sets; i++)
-offsets[i] = pl->desc_set[i].read_only ? 0 : 
pl->desc_set[i].aligned_size*e->idx;
+offsets[i] = pl->desc_set[i].singular ? 0 : 
pl->desc_set[i].aligned_size*e->idx;
 
 /* Bind descriptor buffers */
 vk->CmdBindDescriptorBuffersEXT(e->buf, pl->nb_descriptor_sets, 
pl->desc_bind);
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index 15d954fcb8..81898841ad 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -125,7 +125,8 @@ typedef struct FFVulkanDescriptorSet {
 VkDeviceSize *binding_offset;
 int nb_bindings;
 
-int read_only;
+/* Descriptor set is shared between all submissions */
+int singular;
 } FFVulkanDescriptorSet;
 
 typedef struct FFVulkanPipeline {
@@ -463,7 +464,7 @@ void ff_vk_update_push_exec(FFVulkanContext *s, 
FFVkExecContext *e,
 int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl,
   FFVkSPIRVShader *shd,
   FFVulkanDescriptorSetBinding *desc, int 
nb,
-  int read_only, int print_to_shader_only);
+  int singular, int print_to_shader_only);
 
 /* Initialize/free a pipeline. */
 int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl,

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

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


[FFmpeg-cvslog] vulkan: set VkDescriptorAddressInfoEXT.sType

2024-07-14 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Jul 14 18:27:23 2024 
+0200| [e11087b1629ed9df6c5810120b94597267684b17] | committer: Lynne

vulkan: set VkDescriptorAddressInfoEXT.sType

This was not done, resulting in validation issues, and potential
driver issues.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e11087b1629ed9df6c5810120b94597267684b17
---

 libavutil/vulkan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index e0208c5a7c..a9125ea6b9 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -1689,6 +1689,7 @@ int ff_vk_set_descriptor_buffer(FFVulkanContext *s, 
FFVulkanPipeline *pl,
 .type = desc_set->binding[bind].descriptorType,
 };
 VkDescriptorAddressInfoEXT desc_buf_info = {
+.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_ADDRESS_INFO_EXT,
 .address = addr,
 .range = len,
 .format = fmt,

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

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


[FFmpeg-cvslog] aacdec: set ac->output_elements upon channel element free

2024-07-23 Thread Lynne
ffmpeg | branch: master | Lynne  | Mon Jul 22 03:20:32 2024 
+0200| [b1b69ccbc0b2043e60b95735acced292413c44a5] | committer: Lynne

aacdec: set ac->output_elements upon channel element free

The issue is that ac->output_elements is populated from
ac->che, which may be freed, leaving dangling pointers in this
list.

Should fix clusterfuzz.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b1b69ccbc0b2043e60b95735acced292413c44a5
---

 libavcodec/aac/aacdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index ea2ba84a80..c37de2e003 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -166,6 +166,7 @@ static av_cold int che_configure(AACDecContext *ac,
 ac->proc.sbr_ctx_close(ac->che[type][id]);
 }
 av_freep(&ac->che[type][id]);
+memset(ac->output_element, 0, sizeof(ac->output_element));
 }
 return 0;
 }

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

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


[FFmpeg-cvslog] vulkan: use the new queue family mechanism

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jul 10 01:52:42 2024 
+0200| [bedfabc4373d1cf84e75107c42a56657f2c26520] | committer: Lynne

vulkan: use the new queue family mechanism

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bedfabc4373d1cf84e75107c42a56657f2c26520
---

 libavutil/vulkan.c | 68 --
 libavutil/vulkan.h |  2 +-
 2 files changed, 21 insertions(+), 49 deletions(-)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 11c17ee6f3..cec8354ba6 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -189,37 +189,14 @@ int ff_vk_load_props(FFVulkanContext *s)
 
 static int vk_qf_get_index(FFVulkanContext *s, VkQueueFlagBits dev_family, int 
*nb)
 {
-int ret, num;
-
-switch (dev_family) {
-case VK_QUEUE_GRAPHICS_BIT:
-ret = s->hwctx->queue_family_index;
-num = s->hwctx->nb_graphics_queues;
-break;
-case VK_QUEUE_COMPUTE_BIT:
-ret = s->hwctx->queue_family_comp_index;
-num = s->hwctx->nb_comp_queues;
-break;
-case VK_QUEUE_TRANSFER_BIT:
-ret = s->hwctx->queue_family_tx_index;
-num = s->hwctx->nb_tx_queues;
-break;
-case VK_QUEUE_VIDEO_ENCODE_BIT_KHR:
-ret = s->hwctx->queue_family_encode_index;
-num = s->hwctx->nb_encode_queues;
-break;
-case VK_QUEUE_VIDEO_DECODE_BIT_KHR:
-ret = s->hwctx->queue_family_decode_index;
-num = s->hwctx->nb_decode_queues;
-break;
-default:
-av_assert0(0); /* Should never happen */
+for (int i = 0; i < s->hwctx->nb_qf; i++) {
+if (s->hwctx->qf[i].flags & dev_family) {
+*nb = s->hwctx->qf[i].num;
+return s->hwctx->qf[i].idx;
+}
 }
 
-if (nb)
-*nb = num;
-
-return ret;
+av_assert0(0); /* Should never happen */
 }
 
 int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
@@ -229,25 +206,20 @@ int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx 
*qf,
 if (!s->nb_qfs) {
 s->nb_qfs = 0;
 
-/* Simply fills in all unique queues into s->qfs */
-if (s->hwctx->queue_family_index >= 0)
-s->qfs[s->nb_qfs++] = s->hwctx->queue_family_index;
-if (!s->nb_qfs || s->qfs[0] != s->hwctx->queue_family_tx_index)
-s->qfs[s->nb_qfs++] = s->hwctx->queue_family_tx_index;
-if (!s->nb_qfs || (s->qfs[0] != s->hwctx->queue_family_comp_index &&
-   s->qfs[1] != s->hwctx->queue_family_comp_index))
-s->qfs[s->nb_qfs++] = s->hwctx->queue_family_comp_index;
-if (s->hwctx->queue_family_decode_index >= 0 &&
- (s->qfs[0] != s->hwctx->queue_family_decode_index &&
-  s->qfs[1] != s->hwctx->queue_family_decode_index &&
-  s->qfs[2] != s->hwctx->queue_family_decode_index))
-s->qfs[s->nb_qfs++] = s->hwctx->queue_family_decode_index;
-if (s->hwctx->queue_family_encode_index >= 0 &&
- (s->qfs[0] != s->hwctx->queue_family_encode_index &&
-  s->qfs[1] != s->hwctx->queue_family_encode_index &&
-  s->qfs[2] != s->hwctx->queue_family_encode_index &&
-  s->qfs[3] != s->hwctx->queue_family_encode_index))
-s->qfs[s->nb_qfs++] = s->hwctx->queue_family_encode_index;
+for (int i = 0; i < s->hwctx->nb_qf; i++) {
+/* Skip duplicates */
+int skip = 0;
+for (int j = 0; j < s->nb_qfs; j++) {
+if (s->qfs[j] == s->hwctx->qf[i].idx) {
+skip = 1;
+break;
+}
+}
+if (skip)
+continue;
+
+s->qfs[s->nb_qfs++] = s->hwctx->qf[i].idx;
+}
 }
 
 return (qf->queue_family = vk_qf_get_index(s, dev_family, &qf->nb_queues));
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index 81898841ad..4b4705a25e 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -258,7 +258,7 @@ typedef struct FFVulkanContext {
 AVHWFramesContext *frames;
 AVVulkanFramesContext *hwfc;
 
-uint32_t   qfs[5];
+uint32_t   qfs[64];
 intnb_qfs;
 
 /* Properties */

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

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


[FFmpeg-cvslog] hwcontext_vulkan: add a new mechanism to expose used queue families

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Jul  9 03:03:19 2024 
+0200| [13489c8a2154a2e0e8fd3c3c45f7856b4c3110b0] | committer: Lynne

hwcontext_vulkan: add a new mechanism to expose used queue families

The issue with the old mechanism is that we had to introduce new
API each time we needed a new queue family, and all the queue families
were functionally fixed to a given purpose.

Nvidia's GPUs are able to handle video encoding and compute on the
same queue, which results in a speedup when pre-processing is required.

Also, this enables us to expose optical flow queues for frame interpolation.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=13489c8a2154a2e0e8fd3c3c45f7856b4c3110b0
---

 libavutil/hwcontext_vulkan.c | 85 +++-
 libavutil/hwcontext_vulkan.h | 25 +
 libavutil/version.h  |  2 +-
 3 files changed, 94 insertions(+), 18 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index da377aa1a4..33d856ddd3 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1423,12 +1423,13 @@ static void unlock_queue(AVHWDeviceContext *ctx, 
uint32_t queue_family, uint32_t
 
 static int vulkan_device_init(AVHWDeviceContext *ctx)
 {
-int err;
+int err = 0;
 uint32_t qf_num;
 VulkanDevicePriv *p = ctx->hwctx;
 AVVulkanDeviceContext *hwctx = &p->p;
 FFVulkanFunctions *vk = &p->vkctx.vkfn;
-VkQueueFamilyProperties *qf;
+VkQueueFamilyProperties2 *qf;
+VkQueueFamilyVideoPropertiesKHR *qf_vid;
 int graph_index, comp_index, tx_index, enc_index, dec_index;
 
 /* Set device extension flags */
@@ -1474,38 +1475,53 @@ static int vulkan_device_init(AVHWDeviceContext *ctx)
 return AVERROR_EXTERNAL;
 }
 
-qf = av_malloc_array(qf_num, sizeof(VkQueueFamilyProperties));
+qf = av_malloc_array(qf_num, sizeof(VkQueueFamilyProperties2));
 if (!qf)
 return AVERROR(ENOMEM);
 
-vk->GetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &qf_num, qf);
+qf_vid = av_malloc_array(qf_num, sizeof(VkQueueFamilyVideoPropertiesKHR));
+if (!qf_vid) {
+av_free(qf);
+return AVERROR(ENOMEM);
+}
+
+for (uint32_t i = 0; i < qf_num; i++) {
+qf_vid[i] = (VkQueueFamilyVideoPropertiesKHR) {
+.sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_VIDEO_PROPERTIES_KHR,
+};
+qf[i] = (VkQueueFamilyProperties2) {
+.sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2,
+.pNext = &qf_vid[i],
+};
+}
+
+vk->GetPhysicalDeviceQueueFamilyProperties2(hwctx->phys_dev, &qf_num, qf);
 
 p->qf_mutex = av_calloc(qf_num, sizeof(*p->qf_mutex));
 if (!p->qf_mutex) {
-av_free(qf);
-return AVERROR(ENOMEM);
+err = AVERROR(ENOMEM);
+goto end;
 }
 p->nb_tot_qfs = qf_num;
 
 for (uint32_t i = 0; i < qf_num; i++) {
-p->qf_mutex[i] = av_calloc(qf[i].queueCount, sizeof(**p->qf_mutex));
+p->qf_mutex[i] = av_calloc(qf[i].queueFamilyProperties.queueCount,
+   sizeof(**p->qf_mutex));
 if (!p->qf_mutex[i]) {
-av_free(qf);
-return AVERROR(ENOMEM);
+err = AVERROR(ENOMEM);
+goto end;
 }
-for (uint32_t j = 0; j < qf[i].queueCount; j++) {
+for (uint32_t j = 0; j < qf[i].queueFamilyProperties.queueCount; j++) {
 err = pthread_mutex_init(&p->qf_mutex[i][j], NULL);
 if (err != 0) {
 av_log(ctx, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n",
av_err2str(err));
-av_free(qf);
-return AVERROR(err);
+err = AVERROR(err);
+goto end;
 }
 }
 }
 
-av_free(qf);
-
 graph_index = hwctx->nb_graphics_queues ? hwctx->queue_family_index : -1;
 comp_index  = hwctx->nb_comp_queues ? hwctx->queue_family_comp_index : -1;
 tx_index= hwctx->nb_tx_queues ? hwctx->queue_family_tx_index : -1;
@@ -1517,13 +1533,15 @@ static int vulkan_device_init(AVHWDeviceContext *ctx)
 if (ctx_qf < 0 && required) {  
 \
 av_log(ctx, AV_LOG_ERROR, "%s queue family is required, but marked 
as missing"  \
" in the context!\n", type);
 \
-return AVERROR(EINVAL);
 \
+err = AVERROR(EINVAL); 
 \
+goto end;  
 \
 } else if (fidx < 0 || ctx_qf < 0) { 

[FFmpeg-cvslog] hwcontext_vulkan: rewrite queue picking system for the new API

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Jul 16 17:14:42 2024 
+0200| [8790a30882d9e48c20b61b3a7ac1ff3225bf649c] | committer: Lynne

hwcontext_vulkan: rewrite queue picking system for the new API

This allows us to support different video ops on different queues,
as well as any other arbitrary queues we need.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8790a30882d9e48c20b61b3a7ac1ff3225bf649c
---

 libavutil/hwcontext_vulkan.c | 262 +++
 1 file changed, 167 insertions(+), 95 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 33d856ddd3..5baf68660a 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1028,16 +1028,51 @@ end:
 }
 
 /* Picks the least used qf with the fewest unneeded flags, or -1 if none found 
*/
-static inline int pick_queue_family(VkQueueFamilyProperties *qf, uint32_t 
num_qf,
+static inline int pick_queue_family(VkQueueFamilyProperties2 *qf, uint32_t 
num_qf,
 VkQueueFlagBits flags)
 {
 int index = -1;
 uint32_t min_score = UINT32_MAX;
 
 for (int i = 0; i < num_qf; i++) {
-const VkQueueFlagBits qflags = qf[i].queueFlags;
+VkQueueFlagBits qflags = qf[i].queueFamilyProperties.queueFlags;
+
+/* Per the spec, reporting transfer caps is optional for these 2 types 
*/
+if ((flags & VK_QUEUE_TRANSFER_BIT) &&
+(qflags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT)))
+qflags |= VK_QUEUE_TRANSFER_BIT;
+
 if (qflags & flags) {
-uint32_t score = av_popcount(qflags) + qf[i].timestampValidBits;
+uint32_t score = av_popcount(qflags) + 
qf[i].queueFamilyProperties.timestampValidBits;
+if (score < min_score) {
+index = i;
+min_score = score;
+}
+}
+}
+
+if (index > -1)
+qf[index].queueFamilyProperties.timestampValidBits++;
+
+return index;
+}
+
+static inline int pick_video_queue_family(VkQueueFamilyProperties2 *qf,
+  VkQueueFamilyVideoPropertiesKHR 
*qf_vid, uint32_t num_qf,
+  VkVideoCodecOperationFlagBitsKHR 
flags)
+{
+int index = -1;
+uint32_t min_score = UINT32_MAX;
+
+for (int i = 0; i < num_qf; i++) {
+const VkQueueFlagBits qflags = qf[i].queueFamilyProperties.queueFlags;
+const VkQueueFlagBits vflags = qf_vid[i].videoCodecOperations;
+
+if (!(qflags & (VK_QUEUE_VIDEO_ENCODE_BIT_KHR | 
VK_QUEUE_VIDEO_DECODE_BIT_KHR)))
+continue;
+
+if (vflags & flags) {
+uint32_t score = av_popcount(vflags) + 
qf[i].queueFamilyProperties.timestampValidBits;
 if (score < min_score) {
 index = i;
 min_score = score;
@@ -1046,7 +1081,7 @@ static inline int 
pick_queue_family(VkQueueFamilyProperties *qf, uint32_t num_qf
 }
 
 if (index > -1)
-qf[index].timestampValidBits++;
+qf[index].queueFamilyProperties.timestampValidBits++;
 
 return index;
 }
@@ -1054,12 +1089,12 @@ static inline int 
pick_queue_family(VkQueueFamilyProperties *qf, uint32_t num_qf
 static int setup_queue_families(AVHWDeviceContext *ctx, VkDeviceCreateInfo *cd)
 {
 uint32_t num;
-float *weights;
-VkQueueFamilyProperties *qf = NULL;
 VulkanDevicePriv *p = ctx->hwctx;
 AVVulkanDeviceContext *hwctx = &p->p;
 FFVulkanFunctions *vk = &p->vkctx.vkfn;
-int graph_index, comp_index, tx_index, enc_index, dec_index;
+
+VkQueueFamilyProperties2 *qf = NULL;
+VkQueueFamilyVideoPropertiesKHR *qf_vid = NULL;
 
 /* First get the number of queue families */
 vk->GetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &num, NULL);
@@ -1069,118 +1104,155 @@ static int setup_queue_families(AVHWDeviceContext 
*ctx, VkDeviceCreateInfo *cd)
 }
 
 /* Then allocate memory */
-qf = av_malloc_array(num, sizeof(VkQueueFamilyProperties));
+qf = av_malloc_array(num, sizeof(VkQueueFamilyProperties2));
 if (!qf)
 return AVERROR(ENOMEM);
 
+qf_vid = av_malloc_array(num, sizeof(VkQueueFamilyVideoPropertiesKHR));
+if (!qf_vid)
+return AVERROR(ENOMEM);
+
+for (uint32_t i = 0; i < num; i++) {
+qf_vid[i] = (VkQueueFamilyVideoPropertiesKHR) {
+.sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_VIDEO_PROPERTIES_KHR,
+};
+qf[i] = (VkQueueFamilyProperties2) {
+.sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2,
+.pNext = &qf_vid[i],
+};
+}
+
 /* Finally retrieve the queue families */
-vk->GetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &num, qf);
+vk->GetPhysicalDeviceQueueFamilyProperties2(hwctx->phys_dev, &num, qf);
 
 av_log(ctx, AV_LOG_VERBOSE, "

[FFmpeg-cvslog] hwcontext_vulkan: initialize optical flow queues if available

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Jul 16 17:16:34 2024 
+0200| [a30b7c0158fe744678ca9e4c53b3f343d9f387ff] | committer: Lynne

hwcontext_vulkan: initialize optical flow queues if available

Lets us implement FPS conversion.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a30b7c0158fe744678ca9e4c53b3f343d9f387ff
---

 libavutil/hwcontext_vulkan.c | 18 +++---
 libavutil/vulkan.c   |  6 +-
 libavutil/vulkan.h   |  1 +
 libavutil/vulkan_functions.h |  8 
 libavutil/vulkan_loader.h|  1 +
 5 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 5baf68660a..c81fc95af2 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -105,6 +105,7 @@ typedef struct VulkanDevicePriv {
 VkPhysicalDeviceDescriptorBufferFeaturesEXT desc_buf_features;
 VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_features;
 VkPhysicalDeviceCooperativeMatrixFeaturesKHR coop_matrix_features;
+VkPhysicalDeviceOpticalFlowFeaturesNV optical_flow_features;
 
 /* Queues */
 pthread_mutex_t **qf_mutex;
@@ -429,6 +430,7 @@ static const VulkanOptExtension optional_device_exts[] = {
 { VK_EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME,  
FF_VK_EXT_DEVICE_DRM },
 { VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME,  
FF_VK_EXT_ATOMIC_FLOAT   },
 { VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME,   
FF_VK_EXT_COOP_MATRIX},
+{ VK_NV_OPTICAL_FLOW_EXTENSION_NAME,  
FF_VK_EXT_OPTICAL_FLOW   },
 
 /* Imports/exports */
 { VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME,   
FF_VK_EXT_EXTERNAL_FD_MEMORY },
@@ -1127,13 +1129,14 @@ static int setup_queue_families(AVHWDeviceContext *ctx, 
VkDeviceCreateInfo *cd)
 
 av_log(ctx, AV_LOG_VERBOSE, "Queue families:\n");
 for (int i = 0; i < num; i++) {
-av_log(ctx, AV_LOG_VERBOSE, "%i:%s%s%s%s%s%s%s (queues: %i)\n", i,
+av_log(ctx, AV_LOG_VERBOSE, "%i:%s%s%s%s%s%s%s%s (queues: %i)\n", 
i,
((qf[i].queueFamilyProperties.queueFlags) & 
VK_QUEUE_GRAPHICS_BIT) ? " graphics" : "",
((qf[i].queueFamilyProperties.queueFlags) & 
VK_QUEUE_COMPUTE_BIT) ? " compute" : "",
((qf[i].queueFamilyProperties.queueFlags) & 
VK_QUEUE_TRANSFER_BIT) ? " transfer" : "",
((qf[i].queueFamilyProperties.queueFlags) & 
VK_QUEUE_VIDEO_ENCODE_BIT_KHR) ? " encode" : "",
((qf[i].queueFamilyProperties.queueFlags) & 
VK_QUEUE_VIDEO_DECODE_BIT_KHR) ? " decode" : "",
((qf[i].queueFamilyProperties.queueFlags) & 
VK_QUEUE_SPARSE_BINDING_BIT) ? " sparse" : "",
+   ((qf[i].queueFamilyProperties.queueFlags) & 
VK_QUEUE_OPTICAL_FLOW_BIT_NV) ? " optical_flow" : "",
((qf[i].queueFamilyProperties.queueFlags) & 
VK_QUEUE_PROTECTED_BIT) ? " protected" : "",
qf[i].queueFamilyProperties.queueCount);
 
@@ -1177,6 +1180,7 @@ static int setup_queue_families(AVHWDeviceContext *ctx, 
VkDeviceCreateInfo *cd)
 PICK_QF(VK_QUEUE_GRAPHICS_BIT, VK_VIDEO_CODEC_OPERATION_NONE_KHR);
 PICK_QF(VK_QUEUE_COMPUTE_BIT, VK_VIDEO_CODEC_OPERATION_NONE_KHR);
 PICK_QF(VK_QUEUE_TRANSFER_BIT, VK_VIDEO_CODEC_OPERATION_NONE_KHR);
+PICK_QF(VK_QUEUE_OPTICAL_FLOW_BIT_NV, VK_VIDEO_CODEC_OPERATION_NONE_KHR);
 
 PICK_QF(VK_QUEUE_VIDEO_ENCODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR);
 PICK_QF(VK_QUEUE_VIDEO_DECODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR);
@@ -1318,9 +1322,13 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 VkPhysicalDeviceTimelineSemaphoreFeatures timeline_features = {
 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES,
 };
+VkPhysicalDeviceOpticalFlowFeaturesNV optical_flow_features = {
+.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV,
+.pNext = &timeline_features,
+};
 VkPhysicalDeviceCooperativeMatrixFeaturesKHR coop_matrix_features = {
 .sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR,
-.pNext = &timeline_features,
+.pNext = &optical_flow_features,
 };
 VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_features = {
 .sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT,
@@ -1364,7 +1372,9 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 p->atomic_float_features.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT;
 p->atomic_float_features.pNext = &p->coop_matrix_feat

[FFmpeg-cvslog] vulkan_video: remove NIH pooled buffer implementation

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Jul 18 10:12:09 2024 
+0200| [6757cdb5350fdad381adfe42b305457897f86c8e] | committer: Lynne

vulkan_video: remove NIH pooled buffer implementation

The code predates ff_vk_get_pooled_buffer().

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6757cdb5350fdad381adfe42b305457897f86c8e
---

 libavcodec/vulkan_decode.c | 41 ++-
 libavcodec/vulkan_decode.h |  2 ++
 libavcodec/vulkan_video.c  | 82 --
 libavcodec/vulkan_video.h  | 15 -
 4 files changed, 28 insertions(+), 112 deletions(-)

diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index d8c75cd0e6..67d9b27242 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -260,7 +260,7 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, 
FFVulkanDecodePicture *vp,
 const int nb = *nb_slices;
 uint8_t *slices;
 uint32_t *slice_off;
-FFVkVideoBuffer *vkbuf;
+FFVkBuffer *vkbuf;
 
 size_t new_size = vp->slices_size + startcode_len + size +
   ctx->caps.minBitstreamBufferSizeAlignment;
@@ -274,29 +274,38 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, 
FFVulkanDecodePicture *vp,
 *offsets = dec->slice_off = slice_off;
 slice_off[nb] = vp->slices_size;
 
-vkbuf = vp->slices_buf ? (FFVkVideoBuffer *)vp->slices_buf->data : NULL;
-if (!vkbuf || vkbuf->buf.size < new_size) {
+vkbuf = vp->slices_buf ? (FFVkBuffer *)vp->slices_buf->data : NULL;
+if (!vkbuf || vkbuf->size < new_size) {
 int err;
 AVBufferRef *new_ref;
-FFVkVideoBuffer *new_buf;
-err = ff_vk_video_get_buffer(&ctx->s, &ctx->common, &new_ref,
- VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR,
- ctx->s.hwfc->create_pnext, new_size);
+FFVkBuffer *new_buf;
+
+/* No point in requesting anything smaller. */
+size_t buf_size = FFMAX(new_size, 1024*1024);
+
+/* Align buffer to nearest power of two. Makes fragmentation management
+ * easier, and gives us ample headroom. */
+buf_size = 2 << av_log2(buf_size);
+
+err = ff_vk_get_pooled_buffer(&ctx->s, &ctx->buf_pool, &new_ref,
+  VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR,
+  ctx->s.hwfc->create_pnext, buf_size,
+  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
 if (err < 0)
 return err;
 
-new_buf = (FFVkVideoBuffer *)new_ref->data;
+new_buf = (FFVkBuffer *)new_ref->data;
 
 /* Copy data from the old buffer */
 if (vkbuf) {
-memcpy(new_buf->mem, vkbuf->mem, vp->slices_size);
+memcpy(new_buf->mapped_mem, vkbuf->mapped_mem, vp->slices_size);
 av_buffer_unref(&vp->slices_buf);
 }
 
 vp->slices_buf = new_ref;
 vkbuf = new_buf;
 }
-slices = vkbuf->mem;
+slices = vkbuf->mapped_mem;
 
 /* Startcode */
 memcpy(slices + vp->slices_size, startcode_prefix, startcode_len);
@@ -347,7 +356,7 @@ int ff_vk_decode_frame(AVCodecContext *avctx,
 int err;
 VkResult ret;
 VkCommandBuffer cmd_buf;
-FFVkVideoBuffer *sd_buf;
+FFVkBuffer *sd_buf;
 
 FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
 FFVulkanDecodeShared *ctx = dec->shared_ctx;
@@ -400,13 +409,13 @@ int ff_vk_decode_frame(AVCodecContext *avctx,
"Result of previous frame decoding: %"PRId64"\n", 
prev_sub_res);
 }
 
-sd_buf = (FFVkVideoBuffer *)vp->slices_buf->data;
+sd_buf = (FFVkBuffer *)vp->slices_buf->data;
 
 /* Flush if needed */
-if (!(sd_buf->buf.flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
+if (!(sd_buf->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
 VkMappedMemoryRange flush_buf = {
 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
-.memory = sd_buf->buf.mem,
+.memory = sd_buf->mem,
 .offset = 0,
 .size = FFALIGN(vp->slices_size,
 
ctx->s.props.properties.limits.nonCoherentAtomSize),
@@ -420,7 +429,7 @@ int ff_vk_decode_frame(AVCodecContext *avctx,
 }
 }
 
-vp->decode_info.srcBuffer   = sd_buf->buf.buf;
+vp->decode_info.srcBuffer   = sd_buf->buf;
 vp->decode_info.srcBufferOffset = 0;
 vp->decode_info.srcBufferRange  = data_size;
 
@@ -621,6 +630,8 @@ static void free_common(FFRefStructOpaque unused, void *obj)
  ctx->empty_session_params,
  s->hwctx->alloc);
 
+a

[FFmpeg-cvslog] hwcontext_vulkan: remove unused struct

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Thu Jul 18 10:16:27 2024 
+0200| [81c5d4ea0e5e90bc030d31ab9e7d0cf090988b96] | committer: Lynne

hwcontext_vulkan: remove unused struct

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=81c5d4ea0e5e90bc030d31ab9e7d0cf090988b96
---

 libavutil/hwcontext_vulkan.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index c81fc95af2..e2ef599a0d 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -67,19 +67,6 @@
 #define CHECK_CU(x) FF_CUDA_CHECK_DL(cuda_cu, cu, x)
 #endif
 
-typedef struct VulkanQueueCtx {
-VkFence fence;
-VkQueue queue;
-int was_synchronous;
-int qf;
-int qidx;
-
-/* Buffer dependencies */
-AVBufferRef **buf_deps;
-int nb_buf_deps;
-unsigned int buf_deps_alloc_size;
-} VulkanQueueCtx;
-
 typedef struct VulkanDevicePriv {
 /**
  * The public AVVulkanDeviceContext. See hwcontext_vulkan.h for it.

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

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


[FFmpeg-cvslog] hwcontext_vulkan: rewrite upload/download

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Fri Jul 19 00:10:06 2024 
+0200| [aea4d4b423c62aecf326ef3ae1578710faa3eca6] | committer: Lynne

hwcontext_vulkan: rewrite upload/download

This commit was long overdue. The old transfer dubiously tried to
merge as much code as possible, and had very little in the way
of optimizations, apart from basic host-mapping.

The new code uses buffer pools for any temporary bufflers, and
handles falling back to buffer-based uploads if host-mapping fails.

Roundtrip performance difference:
ffmpeg -init_hw_device "vulkan=vk:0,debug=0,disable_multiplane=1" -f lavfi \
-i color=red:s=3840x2160 -vf hwupload,hwdownload,format=yuv420p -f null -

7900XTX:
Before: 224fps
After: 502fps

Ada, with proprietary drivers:
Before: 29fps
After: 54fps

Alder Lake:
Before: 85fps
After: 108fps

With the host-mapping codepath disabled:
Before: 32fps
After: 51fps

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aea4d4b423c62aecf326ef3ae1578710faa3eca6
---

 libavutil/hwcontext_vulkan.c | 503 ---
 libavutil/vulkan.c   |   5 +-
 2 files changed, 326 insertions(+), 182 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index e2ef599a0d..05e078e7d9 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -129,6 +129,9 @@ typedef struct VulkanFramesPriv {
 FFVkExecPool upload_exec;
 FFVkExecPool download_exec;
 
+/* Temporary buffer pools */
+AVBufferPool *tmp;
+
 /* Modifier info list to free at uninit */
 VkImageDrmFormatModifierListCreateInfoEXT *modifier_info;
 } VulkanFramesPriv;
@@ -2425,6 +2428,8 @@ static void vulkan_frames_uninit(AVHWFramesContext *hwfc)
 ff_vk_exec_pool_free(&p->vkctx, &fp->compute_exec);
 ff_vk_exec_pool_free(&p->vkctx, &fp->upload_exec);
 ff_vk_exec_pool_free(&p->vkctx, &fp->download_exec);
+
+av_buffer_pool_uninit(&fp->tmp);
 }
 
 static int vulkan_frames_init(AVHWFramesContext *hwfc)
@@ -3451,128 +3456,288 @@ static int vulkan_map_from(AVHWFramesContext *hwfc, 
AVFrame *dst,
 return AVERROR(ENOSYS);
 }
 
-static size_t get_req_buffer_size(VulkanDevicePriv *p, int *stride, int height)
+static int copy_buffer_data(AVHWFramesContext *hwfc, AVBufferRef *buf,
+AVFrame *swf, VkBufferImageCopy *region,
+int planes, int upload)
 {
-size_t size;
-*stride = FFALIGN(*stride, 
p->props.properties.limits.optimalBufferCopyRowPitchAlignment);
-size = height*(*stride);
-size = FFALIGN(size, p->props.properties.limits.minMemoryMapAlignment);
-return size;
+VkResult ret;
+VulkanDevicePriv *p = hwfc->device_ctx->hwctx;
+FFVulkanFunctions *vk = &p->vkctx.vkfn;
+AVVulkanDeviceContext *hwctx = &p->p;
+
+FFVkBuffer *vkbuf = (FFVkBuffer *)buf->data;
+
+const VkMappedMemoryRange flush_info = {
+.sType  = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
+.memory = vkbuf->mem,
+.size   = VK_WHOLE_SIZE,
+};
+
+if (!(vkbuf->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) && !upload) {
+ret = vk->InvalidateMappedMemoryRanges(hwctx->act_dev, 1,
+   &flush_info);
+if (ret != VK_SUCCESS) {
+av_log(hwfc, AV_LOG_ERROR, "Failed to invalidate buffer data: 
%s\n",
+   ff_vk_ret2str(ret));
+return AVERROR_EXTERNAL;
+}
+}
+
+for (int i = 0; i < planes; i++)
+av_image_copy_plane(vkbuf->mapped_mem + region[i].bufferOffset,
+region[i].bufferRowLength,
+swf->data[i],
+swf->linesize[i],
+swf->linesize[i],
+region[i].imageExtent.height);
+
+if (!(vkbuf->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) && upload) {
+ret = vk->FlushMappedMemoryRanges(hwctx->act_dev, 1,
+  &flush_info);
+if (ret != VK_SUCCESS) {
+av_log(hwfc, AV_LOG_ERROR, "Failed to flush buffer data: %s\n",
+   ff_vk_ret2str(ret));
+return AVERROR_EXTERNAL;
+}
+}
+
+return 0;
 }
 
-static int transfer_image_buf(AVHWFramesContext *hwfc, AVFrame *f,
-  AVBufferRef **bufs, size_t *buf_offsets,
-  const int *buf_stride, int w,
-  int h, enum AVPixelFormat pix_fmt, int to_buf)
+static int get_plane_buf(AVHWFramesContext *hwfc, AVBufferRef **dst,
+ AVFrame *swf, VkBufferImageCopy *region, int upload)
 {
 int err;
-AVVkFrame *frame = (AVVkFrame *)f->data[0];
 VulkanFramesPriv *fp = hwfc->hwctx;
 VulkanDevic

[FFmpeg-cvslog] hwcontext_vulkan: add HOST_CACHED flag to transfer buffer

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Fri Aug  9 01:42:06 2024 
+0200| [9e606b33a8e25fa8df383bcf3229e0203f79fae3] | committer: Lynne

hwcontext_vulkan: add HOST_CACHED flag to transfer buffer

Significantly speeds up downloads on devices without host mapping.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e606b33a8e25fa8df383bcf3229e0203f79fae3
---

 libavutil/hwcontext_vulkan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 05e078e7d9..a022eda93b 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -3541,7 +3541,8 @@ static int get_plane_buf(AVHWFramesContext *hwfc, 
AVBufferRef **dst,
   VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
   VK_BUFFER_USAGE_TRANSFER_DST_BIT,
   NULL, buf_offset,
-  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
+  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
+  VK_MEMORY_PROPERTY_HOST_CACHED_BIT);
 if (err < 0)
 return err;
 

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

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


[FFmpeg-cvslog] hwcontext_vulkan: enable storageBuffer16BitAccess if available

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jul 24 11:40:05 2024 
+0200| [c19af16f8db4eac1d603d0b8e439c03946a262b7] | committer: Lynne

hwcontext_vulkan: enable storageBuffer16BitAccess if available

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c19af16f8db4eac1d603d0b8e439c03946a262b7
---

 libavutil/hwcontext_vulkan.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index bd32ecef9c..3cc037d1f4 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1399,6 +1399,8 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 
 p->device_features_1_1.samplerYcbcrConversion = 
dev_features_1_1.samplerYcbcrConversion;
 p->device_features_1_1.storagePushConstant16 = 
dev_features_1_1.storagePushConstant16;
+p->device_features_1_1.storageBuffer16BitAccess = 
dev_features_1_1.storageBuffer16BitAccess;
+p->device_features_1_1.uniformAndStorageBuffer16BitAccess = 
dev_features_1_1.uniformAndStorageBuffer16BitAccess;
 
 p->device_features_1_2.timelineSemaphore = 1;
 p->device_features_1_2.bufferDeviceAddress = 
dev_features_1_2.bufferDeviceAddress;

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

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


[FFmpeg-cvslog] vulkan_shaderc: fix error reporting for certain errors

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jul 24 00:53:28 2024 
+0200| [2f7dfb0d157b680bca68bc9e57f7c3529fbfc0fe] | committer: Lynne

vulkan_shaderc: fix error reporting for certain errors

The issue is that shaderc_result_get_num_errors may sometime
return 0 even when shaderc_result_get_compilation_status returns
a non-zero error code.
Since we use the result from the former, override the status
if it returned 0.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f7dfb0d157b680bca68bc9e57f7c3529fbfc0fe
---

 libavfilter/vulkan_shaderc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavfilter/vulkan_shaderc.c b/libavfilter/vulkan_shaderc.c
index 38be1030ad..455e81767e 100644
--- a/libavfilter/vulkan_shaderc.c
+++ b/libavfilter/vulkan_shaderc.c
@@ -65,6 +65,9 @@ static int shdc_shader_compile(FFVkSPIRVCompiler *ctx, void 
*avctx,
 warn = shaderc_result_get_num_warnings(res);
 message = shaderc_result_get_error_message(res);
 
+if (ret != shaderc_compilation_status_success && !err)
+err = 1;
+
 loglevel = err ? AV_LOG_ERROR : warn ? AV_LOG_WARNING : AV_LOG_VERBOSE;
 
 ff_vk_shader_print(avctx, shd, loglevel);

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

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


[FFmpeg-cvslog] vulkan: use allocator callback for buffer creation

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jul 24 20:19:15 2024 
+0200| [8eac11105b0addc6f9ff53d4f082171db459e172] | committer: Lynne

vulkan: use allocator callback for buffer creation

This would've let to a segfault if custom allocators were used.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8eac11105b0addc6f9ff53d4f082171db459e172
---

 libavutil/vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index df7758cc1e..7b45e43a89 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -855,7 +855,7 @@ int ff_vk_create_buf(FFVulkanContext *s, FFVkBuffer *buf, 
size_t size,
 .pNext = &ded_req,
 };
 
-ret = vk->CreateBuffer(s->hwctx->act_dev, &buf_spawn, NULL, &buf->buf);
+ret = vk->CreateBuffer(s->hwctx->act_dev, &buf_spawn, s->hwctx->alloc, 
&buf->buf);
 if (ret != VK_SUCCESS) {
 av_log(s, AV_LOG_ERROR, "Failed to create buffer: %s\n",
ff_vk_ret2str(ret));

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

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


[FFmpeg-cvslog] hwcontext_vulkan: constify validation layer features table

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jul 24 00:39:31 2024 
+0200| [957d34784ad98cb342cd8b23f114b17094f92f5c] | committer: Lynne

hwcontext_vulkan: constify validation layer features table

The struct data seem to get corrupted otherwise.
Possibly a validation layer or libvulkan issue.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=957d34784ad98cb342cd8b23f114b17094f92f5c
---

 libavutil/hwcontext_vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index a022eda93b..bd32ecef9c 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -777,7 +777,7 @@ static int create_instance(AVHWDeviceContext *ctx, 
AVDictionary *opts)
 goto fail;
 
 if (debug_mode) {
-VkValidationFeatureEnableEXT feat_list[] = {
+static const VkValidationFeatureEnableEXT feat_list[] = {
 VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT,
 VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT,
 VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT,

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

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


[FFmpeg-cvslog] vulkan_shaderc: add debug information to shaders

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jul 24 11:44:06 2024 
+0200| [12f868cab558af8e32829eb5ed38189ce9b93f72] | committer: Lynne

vulkan_shaderc: add debug information to shaders

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=12f868cab558af8e32829eb5ed38189ce9b93f72
---

 libavfilter/vulkan_shaderc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vulkan_shaderc.c b/libavfilter/vulkan_shaderc.c
index 455e81767e..9e8a3d17ac 100644
--- a/libavfilter/vulkan_shaderc.c
+++ b/libavfilter/vulkan_shaderc.c
@@ -51,6 +51,7 @@ static int shdc_shader_compile(FFVkSPIRVCompiler *ctx, void 
*avctx,
 shaderc_compile_options_set_target_env(opts, shaderc_target_env_vulkan,
shaderc_env_version_vulkan_1_2);
 shaderc_compile_options_set_target_spirv(opts, shaderc_spirv_version_1_5);
+shaderc_compile_options_set_generate_debug_info(opts);
 shaderc_compile_options_set_optimization_level(opts,

shaderc_optimization_level_performance);
 

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

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


[FFmpeg-cvslog] hwcontext_vulkan: add support for VK_EXT_shader_object

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Jul 24 12:58:34 2024 
+0200| [55adcb4fc516eb3f14a24a497c81dd1e39e42777] | committer: Lynne

hwcontext_vulkan: add support for VK_EXT_shader_object

We'd like to use it eventually, and its already covered by
the minimum version of the headers we require.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=55adcb4fc516eb3f14a24a497c81dd1e39e42777
---

 libavutil/hwcontext_vulkan.c | 14 --
 libavutil/vulkan_functions.h |  7 ++-
 libavutil/vulkan_loader.h|  1 +
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 3cc037d1f4..ebd6e083e4 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -93,6 +93,7 @@ typedef struct VulkanDevicePriv {
 VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_features;
 VkPhysicalDeviceCooperativeMatrixFeaturesKHR coop_matrix_features;
 VkPhysicalDeviceOpticalFlowFeaturesNV optical_flow_features;
+VkPhysicalDeviceShaderObjectFeaturesEXT shader_object_features;
 
 /* Queues */
 pthread_mutex_t **qf_mutex;
@@ -421,6 +422,7 @@ static const VulkanOptExtension optional_device_exts[] = {
 { VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME,  
FF_VK_EXT_ATOMIC_FLOAT   },
 { VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME,   
FF_VK_EXT_COOP_MATRIX},
 { VK_NV_OPTICAL_FLOW_EXTENSION_NAME,  
FF_VK_EXT_OPTICAL_FLOW   },
+{ VK_EXT_SHADER_OBJECT_EXTENSION_NAME,
FF_VK_EXT_SHADER_OBJECT  },
 
 /* Imports/exports */
 { VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME,   
FF_VK_EXT_EXTERNAL_FD_MEMORY },
@@ -1312,9 +1314,13 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 VkPhysicalDeviceTimelineSemaphoreFeatures timeline_features = {
 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES,
 };
+VkPhysicalDeviceShaderObjectFeaturesEXT shader_object_features = {
+.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT,
+.pNext = &timeline_features,
+};
 VkPhysicalDeviceOpticalFlowFeaturesNV optical_flow_features = {
 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV,
-.pNext = &timeline_features,
+.pNext = &shader_object_features,
 };
 VkPhysicalDeviceCooperativeMatrixFeaturesKHR coop_matrix_features = {
 .sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR,
@@ -1364,7 +1370,9 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 p->coop_matrix_features.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR;
 p->coop_matrix_features.pNext = &p->optical_flow_features;
 p->optical_flow_features.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV;
-p->optical_flow_features.pNext = NULL;
+p->optical_flow_features.pNext = &p->shader_object_features;
+p->shader_object_features.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT;
+p->shader_object_features.pNext = NULL;
 
 ctx->free = vulkan_device_free;
 
@@ -1432,6 +1440,8 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 
 p->optical_flow_features.opticalFlow = optical_flow_features.opticalFlow;
 
+p->shader_object_features.shaderObject = 
shader_object_features.shaderObject;
+
 dev_info.pNext = &hwctx->device_features;
 
 /* Setup queue family */
diff --git a/libavutil/vulkan_functions.h b/libavutil/vulkan_functions.h
index 3f0b96f77e..20711b130d 100644
--- a/libavutil/vulkan_functions.h
+++ b/libavutil/vulkan_functions.h
@@ -47,6 +47,7 @@ typedef enum FFVulkanExtensions {
 FF_VK_EXT_ATOMIC_FLOAT   = 1ULL << 15, /* 
VK_EXT_shader_atomic_float */
 FF_VK_EXT_COOP_MATRIX= 1ULL << 16, /* 
VK_KHR_cooperative_matrix */
 FF_VK_EXT_OPTICAL_FLOW   = 1ULL << 17, /* VK_NV_optical_flow */
+FF_VK_EXT_SHADER_OBJECT  = 1ULL << 18, /* VK_EXT_shader_object */
 
 FF_VK_EXT_NO_FLAG= 1ULL << 31,
 } FFVulkanExtensions;
@@ -219,7 +220,11 @@ typedef enum FFVulkanExtensions {

  \
 /* Shaders */  
  \
 MACRO(1, 1, FF_VK_EXT_NO_FLAG,  CreateShaderModule)
  \
-MACRO(1, 1, FF_VK_EXT_NO_FLAG,  DestroyShaderModule)
+MACRO(1, 1, FF_VK_EXT_NO_FLAG,  DestroyShaderModule)   
\
+MACRO(1, 1, FF_VK_EXT_SHADER_OBJECT,CmdBindShadersEXT) 
\
+MACRO(1, 1, FF_VK_EXT_SHADER_OBJECT,CreateShad

[FFmpeg-cvslog] vulkan_decode: force layered_dpb to 0 when dedicated_dpb is 0

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Aug 10 17:13:57 2024 
+0200| [ca591e6b50ee616fc36711cc66d594e51209dddb] | committer: Lynne

vulkan_decode: force layered_dpb to 0 when dedicated_dpb is 0

layered_dpb only makes sense when dedicated_dpb is set to 1.
For some mysterious reason, some Nvidia drivers stopped indicating
SEPARATE_REFRENCES, but kept the COINCIDE flag, which broke
the code.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ca591e6b50ee616fc36711cc66d594e51209dddb
---

 libavcodec/vulkan_decode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index 67d9b27242..e86f128635 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -923,9 +923,9 @@ static int vulkan_decode_get_profile(AVCodecContext *avctx, 
AVBufferRef *frames_
 return AVERROR_EXTERNAL;
 }
 
-/* TODO: make dedicated_dpb tunable */
 dec->dedicated_dpb = !(dec_caps->flags & 
VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR);
-dec->layered_dpb = !(caps->flags & 
VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR);
+dec->layered_dpb = !dec->dedicated_dpb ? 0 :
+   !(caps->flags & 
VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR);
 
 if (dec->dedicated_dpb) {
 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;

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

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


[FFmpeg-cvslog] hwcontext_vulkan: correct comment in header

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Aug 11 01:01:35 2024 
+0200| [0b25f0bc1d17a7759120e0ac1bcf901258a93cf9] | committer: Lynne

hwcontext_vulkan: correct comment in header

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0b25f0bc1d17a7759120e0ac1bcf901258a93cf9
---

 libavutil/hwcontext_vulkan.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.h b/libavutil/hwcontext_vulkan.h
index 55647f1705..2688a4757b 100644
--- a/libavutil/hwcontext_vulkan.h
+++ b/libavutil/hwcontext_vulkan.h
@@ -63,9 +63,8 @@ typedef struct AVVulkanDeviceContext {
 const VkAllocationCallbacks *alloc;
 
 /**
- * Pointer to the instance-provided vkGetInstanceProcAddr loading function.
- * If NULL, will pick either libvulkan or libvolk, depending on libavutil's
- * compilation settings, and set this field.
+ * Pointer to a vkGetInstanceProcAddr loading function.
+ * If unset, will dynamically load and use libvulkan.
  */
 PFN_vkGetInstanceProcAddr get_proc_addr;
 

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

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


[FFmpeg-cvslog] hwcontext_vulkan: add support for Vulkan encoding

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Dec 28 06:31:11 2022 
+0100| [2ce0e51503d9178b190660ede8e716f6a134c2ec] | committer: Lynne

hwcontext_vulkan: add support for Vulkan encoding

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2ce0e51503d9178b190660ede8e716f6a134c2ec
---

 libavutil/hwcontext_vulkan.c | 10 ++
 libavutil/vulkan_functions.h |  9 +
 libavutil/vulkan_loader.h|  3 +++
 3 files changed, 22 insertions(+)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index ebd6e083e4..05fadd1b55 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -437,8 +437,11 @@ static const VulkanOptExtension optional_device_exts[] = {
 
 /* Video encoding/decoding */
 { VK_KHR_VIDEO_QUEUE_EXTENSION_NAME,  
FF_VK_EXT_VIDEO_QUEUE},
+{ VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME,   
FF_VK_EXT_VIDEO_ENCODE_QUEUE },
 { VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME,   
FF_VK_EXT_VIDEO_DECODE_QUEUE },
+{ VK_KHR_VIDEO_ENCODE_H264_EXTENSION_NAME,
FF_VK_EXT_VIDEO_ENCODE_H264  },
 { VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME,
FF_VK_EXT_VIDEO_DECODE_H264  },
+{ VK_KHR_VIDEO_ENCODE_H265_EXTENSION_NAME,
FF_VK_EXT_VIDEO_ENCODE_H265  },
 { VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME,
FF_VK_EXT_VIDEO_DECODE_H265  },
 { VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME, 
FF_VK_EXT_VIDEO_DECODE_AV1   },
 };
@@ -2078,6 +2081,7 @@ enum PrepMode {
 PREP_MODE_EXTERNAL_IMPORT,
 PREP_MODE_DECODING_DST,
 PREP_MODE_DECODING_DPB,
+PREP_MODE_ENCODING_DPB,
 };
 
 static int prepare_frame(AVHWFramesContext *hwfc, FFVkExecPool *ectx,
@@ -2139,6 +2143,10 @@ static int prepare_frame(AVHWFramesContext *hwfc, 
FFVkExecPool *ectx,
 new_layout = VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR;
 new_access = VK_ACCESS_TRANSFER_READ_BIT | 
VK_ACCESS_TRANSFER_WRITE_BIT;
 break;
+case PREP_MODE_ENCODING_DPB:
+new_layout = VK_IMAGE_LAYOUT_VIDEO_ENCODE_DPB_KHR;
+new_access = VK_ACCESS_TRANSFER_READ_BIT | 
VK_ACCESS_TRANSFER_WRITE_BIT;
+break;
 }
 
 ff_vk_frame_barrier(&p->vkctx, exec, &tmp_frame, img_bar, &nb_img_bar,
@@ -2399,6 +2407,8 @@ static AVBufferRef *vulkan_pool_alloc(void *opaque, 
size_t size)
 err = prepare_frame(hwfc, &fp->compute_exec, f, 
PREP_MODE_DECODING_DPB);
 else if (hwctx->usage & VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR)
 err = prepare_frame(hwfc, &fp->compute_exec, f, 
PREP_MODE_DECODING_DST);
+else if (hwctx->usage & VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)
+err = prepare_frame(hwfc, &fp->compute_exec, f, 
PREP_MODE_ENCODING_DPB);
 else
 err = prepare_frame(hwfc, &fp->compute_exec, f, PREP_MODE_WRITE);
 if (err)
diff --git a/libavutil/vulkan_functions.h b/libavutil/vulkan_functions.h
index 20711b130d..5fbde96cfe 100644
--- a/libavutil/vulkan_functions.h
+++ b/libavutil/vulkan_functions.h
@@ -49,6 +49,10 @@ typedef enum FFVulkanExtensions {
 FF_VK_EXT_OPTICAL_FLOW   = 1ULL << 17, /* VK_NV_optical_flow */
 FF_VK_EXT_SHADER_OBJECT  = 1ULL << 18, /* VK_EXT_shader_object */
 
+FF_VK_EXT_VIDEO_ENCODE_QUEUE = 1ULL << 28, /* 
VK_KHR_video_encode_queue */
+FF_VK_EXT_VIDEO_ENCODE_H264  = 1ULL << 29, /* VK_KHR_video_encode_h264 
*/
+FF_VK_EXT_VIDEO_ENCODE_H265  = 1ULL << 30, /* VK_KHR_video_encode_h265 
*/
+
 FF_VK_EXT_NO_FLAG= 1ULL << 31,
 } FFVulkanExtensions;
 
@@ -196,6 +200,11 @@ typedef enum FFVulkanExtensions {

\
 /* Video decoding */   
\
 MACRO(1, 1, FF_VK_EXT_VIDEO_DECODE_QUEUE,   CmdDecodeVideoKHR) 
\
+   
\
+/* Video encoding */   
\
+MACRO(1, 1, FF_VK_EXT_VIDEO_ENCODE_QUEUE,   CmdEncodeVideoKHR) 
\
+MACRO(1, 1, FF_VK_EXT_VIDEO_ENCODE_QUEUE,   
GetEncodedVideoSessionParametersKHR)   \
+MACRO(1, 0, FF_VK_EXT_VIDEO_ENCODE_QUEUE,   
GetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR) \

  \
 /* Pipeline */ 
  \
 MACRO(1, 1, FF_VK_EXT_NO_FLAG,  CreatePipelineLayout)  
  \
diff --git a/libavutil/vulkan_loader.h b/libavutil/vulkan_loader.h
index befed51860..f75569340f 100644
--- a/libavutil/vulkan_loader.h
+++ b/libavutil/vulkan_loader.h
@@ -57,8 +5

[FFmpeg-cvslog] libavutil: deprecate the old Vulkan queue API, add doc/APIchanges entries

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Aug 10 17:46:04 2024 
+0200| [5f0f1f7b7a6e6dde16101f919c18de710a51ca64] | committer: Lynne

libavutil: deprecate the old Vulkan queue API, add doc/APIchanges entries

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5f0f1f7b7a6e6dde16101f919c18de710a51ca64
---

 doc/APIchanges   |  9 +
 libavutil/hwcontext_vulkan.c |  8 
 libavutil/hwcontext_vulkan.h | 12 
 libavutil/version.h  |  1 +
 4 files changed, 30 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index 046828ded1..173f317ea1 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,15 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-08-10 - x - lavu 59.34.100 - hwcontext_vulkan.h
+  Add qf and nb_qf to AVVulkanDeviceContext.
+  Deprecate queue_family_index, nb_graphics_queues,
+  queue_family_tx_index, nb_tx_queues.
+  queue_family_comp_index, nb_comp_queues.
+  queue_family_encode_index, nb_encode_queues.
+  queue_family_decode_index, and nb_decode_queues,
+  from AVVulkanDeviceContext.
+
 2024-07-30 - x - lavu 59.32.100 - cpu.h
   Deprecate AV_CPU_FLAG_RVF and AV_CPU_FLAG_RVD without replacement.
   Deprecate AV_CPU_FLAG_RVB_ADDR, subsumed into AV_CPU_FLAG_RVB.
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 05fadd1b55..59d519727b 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1228,6 +1228,8 @@ static int setup_queue_families(AVHWDeviceContext *ctx, 
VkDeviceCreateInfo *cd)
 };
 }
 
+#if FF_API_VULKAN_FIXED_QUEUES
+FF_DISABLE_DEPRECATION_WARNINGS
 /* Setup deprecated fields */
 hwctx->queue_family_index= -1;
 hwctx->queue_family_comp_index   = -1;
@@ -1252,6 +1254,8 @@ static int setup_queue_families(AVHWDeviceContext *ctx, 
VkDeviceCreateInfo *cd)
 }
 
 #undef SET_OLD_QF
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
 return 0;
 }
@@ -1611,6 +1615,8 @@ static int vulkan_device_init(AVHWDeviceContext *ctx)
 }
 }
 
+#if FF_API_VULKAN_FIXED_QUEUES
+FF_DISABLE_DEPRECATION_WARNINGS
 graph_index = hwctx->nb_graphics_queues ? hwctx->queue_family_index : -1;
 comp_index  = hwctx->nb_comp_queues ? hwctx->queue_family_comp_index : -1;
 tx_index= hwctx->nb_tx_queues ? hwctx->queue_family_tx_index : -1;
@@ -1678,6 +1684,8 @@ static int vulkan_device_init(AVHWDeviceContext *ctx)
 ADD_QUEUE(hwctx->queue_family_encode_index, hwctx->nb_encode_queues, 
VK_QUEUE_VIDEO_ENCODE_BIT_KHR);
 #undef ADD_QUEUE
 }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
 for (int i = 0; i < hwctx->nb_qf; i++) {
 if (!hwctx->qf[i].video_caps &&
diff --git a/libavutil/hwcontext_vulkan.h b/libavutil/hwcontext_vulkan.h
index 7959a84592..55647f1705 100644
--- a/libavutil/hwcontext_vulkan.h
+++ b/libavutil/hwcontext_vulkan.h
@@ -113,6 +113,7 @@ typedef struct AVVulkanDeviceContext {
 const char * const *enabled_dev_extensions;
 int nb_enabled_dev_extensions;
 
+#if FF_API_VULKAN_FIXED_QUEUES
 /**
  * Queue family index for graphics operations, and the number of queues
  * enabled for it. If unavaiable, will be set to -1. Not required.
@@ -120,21 +121,27 @@ typedef struct AVVulkanDeviceContext {
  * queue family, or pick the one with the least unrelated flags set.
  * Queue indices here may overlap if a queue has to share capabilities.
  */
+attribute_deprecated
 int queue_family_index;
+attribute_deprecated
 int nb_graphics_queues;
 
 /**
  * Queue family index for transfer operations and the number of queues
  * enabled. Required.
  */
+attribute_deprecated
 int queue_family_tx_index;
+attribute_deprecated
 int nb_tx_queues;
 
 /**
  * Queue family index for compute operations and the number of queues
  * enabled. Required.
  */
+attribute_deprecated
 int queue_family_comp_index;
+attribute_deprecated
 int nb_comp_queues;
 
 /**
@@ -142,7 +149,9 @@ typedef struct AVVulkanDeviceContext {
  * If the device doesn't support such, queue_family_encode_index will be 
-1.
  * Not required.
  */
+attribute_deprecated
 int queue_family_encode_index;
+attribute_deprecated
 int nb_encode_queues;
 
 /**
@@ -150,8 +159,11 @@ typedef struct AVVulkanDeviceContext {
  * If the device doesn't support such, queue_family_decode_index will be 
-1.
  * Not required.
  */
+attribute_deprecated
 int queue_family_decode_index;
+attribute_deprecated
 int nb_decode_queues;
+#endif
 
 /**
  * Locks a queue, preventing other threads from submitting any command
diff --git a/libavutil/version.h b/libavutil/version.h
index de8938e811..84eb3a388a 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -114,6 +114,7 @@
 #define FF_API_H274

[FFmpeg-cvslog] vulkan: load queue families upon loading properties

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Aug 10 21:51:32 2024 
+0200| [d6c08a41cb576ad2e160761a0bfd44cf9e3b6232] | committer: Lynne

vulkan: load queue families upon loading properties

Avoids the need to call ff_vk_qf_init if manually filling in
a queue family structure.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d6c08a41cb576ad2e160761a0bfd44cf9e3b6232
---

 libavutil/vulkan.c | 41 +++--
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 13344b7aed..4e275bc7af 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -83,6 +83,25 @@ const char *ff_vk_ret2str(VkResult res)
 #undef CASE
 }
 
+static void load_enabled_qfs(FFVulkanContext *s)
+{
+s->nb_qfs = 0;
+for (int i = 0; i < s->hwctx->nb_qf; i++) {
+/* Skip duplicates */
+int skip = 0;
+for (int j = 0; j < s->nb_qfs; j++) {
+if (s->qfs[j] == s->hwctx->qf[i].idx) {
+skip = 1;
+break;
+}
+}
+if (skip)
+continue;
+
+s->qfs[s->nb_qfs++] = s->hwctx->qf[i].idx;
+}
+}
+
 int ff_vk_load_props(FFVulkanContext *s)
 {
 FFVulkanFunctions *vk = &s->vkfn;
@@ -131,6 +150,8 @@ int ff_vk_load_props(FFVulkanContext *s)
 vk->GetPhysicalDeviceMemoryProperties(s->hwctx->phys_dev, &s->mprops);
 vk->GetPhysicalDeviceFeatures2(s->hwctx->phys_dev, &s->feats);
 
+load_enabled_qfs(s);
+
 if (s->qf_props)
 return 0;
 
@@ -207,24 +228,8 @@ int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx 
*qf,
   VkQueueFlagBits dev_family)
 {
 /* Fill in queue families from context if not done yet */
-if (!s->nb_qfs) {
-s->nb_qfs = 0;
-
-for (int i = 0; i < s->hwctx->nb_qf; i++) {
-/* Skip duplicates */
-int skip = 0;
-for (int j = 0; j < s->nb_qfs; j++) {
-if (s->qfs[j] == s->hwctx->qf[i].idx) {
-skip = 1;
-break;
-}
-}
-if (skip)
-continue;
-
-s->qfs[s->nb_qfs++] = s->hwctx->qf[i].idx;
-}
-}
+if (!s->nb_qfs)
+load_enabled_qfs(s);
 
 return (qf->queue_family = vk_qf_get_index(s, dev_family, &qf->nb_queues));
 }

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

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


[FFmpeg-cvslog] vulkan_decode: port to the new queue family API

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Aug 11 03:27:46 2024 
+0200| [680d969a305c0927480573a1b455024088b51aeb] | committer: Lynne

vulkan_decode: port to the new queue family API

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=680d969a305c0927480573a1b455024088b51aeb
---

 libavcodec/vulkan_decode.c | 18 +-
 libavcodec/vulkan_video.c  | 14 ++
 libavcodec/vulkan_video.h  |  5 +
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index e6e14778cb..b89bfa17f2 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -1118,7 +1118,7 @@ int ff_vk_decode_uninit(AVCodecContext *avctx)
 
 int ff_vk_decode_init(AVCodecContext *avctx)
 {
-int err, qf, cxpos = 0, cypos = 0, nb_q = 0;
+int err, cxpos = 0, cypos = 0, nb_q = 0;
 VkResult ret;
 FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
 FFVulkanDecodeShared *ctx;
@@ -1183,18 +1183,18 @@ int ff_vk_decode_init(AVCodecContext *avctx)
 goto fail;
 
 /* Create queue context */
-qf = ff_vk_qf_init(s, &ctx->qf, VK_QUEUE_VIDEO_DECODE_BIT_KHR);
-
 vk_desc = get_codecdesc(avctx->codec_id);
-/* Check for support */
-if (!(s->video_props[qf].videoCodecOperations & vk_desc->decode_op)) {
-av_log(avctx, AV_LOG_ERROR, "Decoding %s not supported on the given "
-   "queue family %i!\n", avcodec_get_name(avctx->codec_id), qf);
-return AVERROR(EINVAL);
+err = ff_vk_video_qf_init(s, &ctx->qf,
+  VK_QUEUE_VIDEO_DECODE_BIT_KHR,
+  vk_desc->decode_op);
+if (err < 0) {
+av_log(avctx, AV_LOG_ERROR, "Decoding of %s is not supported by this 
device\n",
+   avcodec_get_name(avctx->codec_id));
+return err;
 }
 
 /* Enable queries if supported */
-if (s->query_props[qf].queryResultStatusSupport)
+if (s->query_props[ctx->qf.queue_family].queryResultStatusSupport)
 nb_q = 1;
 
 session_create.flags = 0x0;
diff --git a/libavcodec/vulkan_video.c b/libavcodec/vulkan_video.c
index f2a15d392e..b9a0ed5022 100644
--- a/libavcodec/vulkan_video.c
+++ b/libavcodec/vulkan_video.c
@@ -177,6 +177,20 @@ int ff_vk_h265_level_to_av(StdVideoH265LevelIdc level)
 }
 }
 
+int ff_vk_video_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
+VkQueueFlagBits family, 
VkVideoCodecOperationFlagBitsKHR caps)
+{
+for (int i = 0; i < s->hwctx->nb_qf; i++) {
+if ((s->hwctx->qf[i].flags & family) &&
+(s->hwctx->qf[i].video_caps & caps)) {
+qf->queue_family = s->hwctx->qf[i].idx;
+qf->nb_queues = s->hwctx->qf[i].num;
+return 0;
+}
+}
+return AVERROR(ENOTSUP);
+}
+
 av_cold void ff_vk_video_common_uninit(FFVulkanContext *s,
FFVkVideoCommon *common)
 {
diff --git a/libavcodec/vulkan_video.h b/libavcodec/vulkan_video.h
index 1894f1f1b7..2cb9419fd8 100644
--- a/libavcodec/vulkan_video.h
+++ b/libavcodec/vulkan_video.h
@@ -54,6 +54,11 @@ VkVideoChromaSubsamplingFlagBitsKHR 
ff_vk_subsampling_from_av_desc(const AVPixFm
  */
 VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth(int depth);
 
+/**
+ * Chooses a QF and loads it into a context.
+ */
+int ff_vk_video_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf,
+VkQueueFlagBits family, 
VkVideoCodecOperationFlagBitsKHR caps);
 
 /**
  * Convert level from Vulkan to AV.

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

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


[FFmpeg-cvslog] vulkan_decode: add \n to error message

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sat Aug 10 18:20:58 2024 
+0200| [1c05661ec4e83aecd1b07037e5cff6100234a3b6] | committer: Lynne

vulkan_decode: add \n to error message

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1c05661ec4e83aecd1b07037e5cff6100234a3b6
---

 libavcodec/vulkan_decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index e86f128635..e6e14778cb 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -88,7 +88,7 @@ int ff_vk_update_thread_context(AVCodecContext *dst, const 
AVCodecContext *src)
 
 const VkVideoProfileInfoKHR *profile = get_video_profile(ctx, 
dst->codec_id);
 if (!profile) {
-av_log(dst, AV_LOG_ERROR, "Video profile missing from frames 
context!");
+av_log(dst, AV_LOG_ERROR, "Video profile missing from frames 
context!\n");
 return AVERROR(EINVAL);
 }
 

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

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


[FFmpeg-cvslog] vulkan: add support for encode feedback queries

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Fri Aug  9 13:36:01 2024 
+0200| [83cd77563fe008e34b70dcf1dd4d94c048dbf4fa] | committer: Lynne

vulkan: add support for encode feedback queries

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83cd77563fe008e34b70dcf1dd4d94c048dbf4fa
---

 libavutil/vulkan.c | 26 --
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 7b45e43a89..13344b7aed 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -281,6 +281,15 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, 
FFVkQueueFamilyCtx *qf,
 VkCommandPoolCreateInfo cqueue_create;
 VkCommandBufferAllocateInfo cbuf_create;
 
+const VkQueryPoolVideoEncodeFeedbackCreateInfoKHR *ef = NULL;
+
+if (query_type == VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR) {
+ef = ff_vk_find_struct(query_create_pnext,
+   
VK_STRUCTURE_TYPE_QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR);
+if (!ef)
+return AVERROR(EINVAL);
+}
+
 /* Create command pool */
 cqueue_create = (VkCommandPoolCreateInfo) {
 .sType  = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
@@ -338,21 +347,18 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, 
FFVkQueueFamilyCtx *qf,
 }
 
 pool->nb_queries = nb_queries;
-pool->query_status_stride = 2;
+pool->query_status_stride = 1 + 1; /* One result, one status by 
default */
 pool->query_results = nb_queries;
-pool->query_statuses = 0; /* if radv supports it, nb_queries; */
+pool->query_statuses = nb_queries;
 
-#if 0 /* CONFIG_VULKAN_ENCODE */
 /* Video encode quieries produce two results per query */
 if (query_type == VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR) {
-pool->query_status_stride = 3; /* 
skip,skip,result,skip,skip,result */
-pool->query_results *= 2;
-} else
-#endif
-if (query_type == VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR) {
+int nb_results = av_popcount(ef->encodeFeedbackFlags);
+pool->query_status_stride = nb_results + 1;
+pool->query_results *= nb_results;
+} else if (query_type == VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR) {
 pool->query_status_stride = 1;
 pool->query_results = 0;
-pool->query_statuses = nb_queries;
 }
 
 pool->qd_size = (pool->query_results + 
pool->query_statuses)*(query_64bit ? 8 : 4);
@@ -444,7 +450,7 @@ VkResult ff_vk_exec_get_query(FFVulkanContext *s, 
FFVkExecContext *e,
   e->query_idx,
   pool->nb_queries,
   pool->qd_size, e->query_data,
-  pool->query_64bit ? 8 : 4, qf);
+  pool->qd_size, qf);
 if (ret != VK_SUCCESS)
 return ret;
 

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

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


[FFmpeg-cvslog] nlmeans_vulkan: fix uninitialized reads

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Aug 11 04:27:20 2024 
+0200| [12080ff0404059847df8bc30cc5023a9010f60b2] | committer: Lynne

nlmeans_vulkan: fix uninitialized reads

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=12080ff0404059847df8bc30cc5023a9010f60b2
---

 libavfilter/vf_nlmeans_vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_nlmeans_vulkan.c b/libavfilter/vf_nlmeans_vulkan.c
index 5840aea4a7..be9305854b 100644
--- a/libavfilter/vf_nlmeans_vulkan.c
+++ b/libavfilter/vf_nlmeans_vulkan.c
@@ -564,7 +564,7 @@ static av_cold int init_filter(AVFilterContext *ctx)
 NLMeansVulkanContext *s = ctx->priv;
 FFVulkanContext *vkctx = &s->vkctx;
 const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
-FFVkSPIRVCompiler *spv;
+FFVkSPIRVCompiler *spv = NULL;
 int *offsets_buf;
 int offsets_dispatched = 0, nb_dispatches = 0;
 

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

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


[FFmpeg-cvslog] hwcontext_vulkan: do not chain structs of unsupported extensions in vkCreateDevice

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Aug 11 04:27:52 2024 
+0200| [ef11a6456d40de57bbda9369ecedf5f242020703] | committer: Lynne

hwcontext_vulkan: do not chain structs of unsupported extensions in 
vkCreateDevice

Fixes:

vkCreateDevice(): pCreateInfo->pNext 
includes a
pointer to a VkPhysicalDeviceOpticalFlowFeaturesNV, but when creating VkDevice, 
the
parent extension (VK_NV_optical_flow) was not included in 
ppEnabledExtensionNames.
The Vulkan spec states: Each pNext member of any structure (including this one) 
in
the pNext chain must be either NULL or a pointer to a valid struct for extending
VkDeviceCreateInfo.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ef11a6456d40de57bbda9369ecedf5f242020703
---

 libavutil/hwcontext_vulkan.c | 32 +---
 libavutil/vulkan.h   |  9 +
 2 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 59d519727b..bdf39407e1 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1369,17 +1369,27 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 p->device_features_1_2.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
 p->device_features_1_2.pNext = &p->device_features_1_3;
 p->device_features_1_3.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
-p->device_features_1_3.pNext = &p->desc_buf_features;
-p->desc_buf_features.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT;
-p->desc_buf_features.pNext = &p->atomic_float_features;
-p->atomic_float_features.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT;
-p->atomic_float_features.pNext = &p->coop_matrix_features;
-p->coop_matrix_features.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR;
-p->coop_matrix_features.pNext = &p->optical_flow_features;
-p->optical_flow_features.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV;
-p->optical_flow_features.pNext = &p->shader_object_features;
-p->shader_object_features.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT;
-p->shader_object_features.pNext = NULL;
+p->device_features_1_3.pNext = NULL;
+
+#define OPT_CHAIN(EXT_FLAG, STRUCT_P, TYPE)\
+do {   \
+if (p->vkctx.extensions & EXT_FLAG) {  \
+(STRUCT_P)->sType = TYPE;  \
+ff_vk_link_struct(hwctx->device_features.pNext, STRUCT_P); \
+}  \
+} while (0)
+
+OPT_CHAIN(FF_VK_EXT_DESCRIPTOR_BUFFER, &p->desc_buf_features,
+  
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT);
+OPT_CHAIN(FF_VK_EXT_ATOMIC_FLOAT, &p->atomic_float_features,
+  
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT);
+OPT_CHAIN(FF_VK_EXT_COOP_MATRIX, &p->coop_matrix_features,
+  
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR);
+OPT_CHAIN(FF_VK_EXT_SHADER_OBJECT, &p->shader_object_features,
+  VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT);
+OPT_CHAIN(FF_VK_EXT_OPTICAL_FLOW, &p->optical_flow_features,
+  VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV);
+#undef OPT_CHAIN
 
 ctx->free = vulkan_device_free;
 
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index ee0ea18fac..05bd71ae45 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -291,6 +291,15 @@ static inline const void *ff_vk_find_struct(const void 
*chain, VkStructureType s
 return NULL;
 }
 
+static inline void ff_vk_link_struct(void *chain, const void *in)
+{
+VkBaseOutStructure *out = chain;
+while (out->pNext)
+out = out->pNext;
+
+out->pNext = (void *)in;
+}
+
 /* Identity mapping - r = r, b = b, g = g, a = a */
 extern const VkComponentMapping ff_comp_identity_map;
 

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

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


[FFmpeg-cvslog] hwcontext_vulkan: ignore false positive validation errors

2024-08-10 Thread Lynne
ffmpeg | branch: master | Lynne  | Sun Aug 11 05:01:43 2024 
+0200| [e25667f9f14fa71d655265905fa91aa39953a17e] | committer: Lynne

hwcontext_vulkan: ignore false positive validation errors

Issue ref:
https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/6627

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e25667f9f14fa71d655265905fa91aa39953a17e
---

 libavutil/hwcontext_vulkan.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index bdf39407e1..55dd657ddd 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -454,6 +454,14 @@ static VkBool32 VKAPI_CALL 
vk_dbg_callback(VkDebugUtilsMessageSeverityFlagBitsEX
 int l;
 AVHWDeviceContext *ctx = priv;
 
+/* Ignore false positives */
+switch (data->messageIdNumber) {
+case 0x30f4ac70: /* VUID-VkImageCreateInfo-pNext-06811 */
+return VK_FALSE;
+default:
+break;
+}
+
 switch (severity) {
 case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: l = AV_LOG_VERBOSE; 
break;
 case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT:l = AV_LOG_INFO;
break;
@@ -466,7 +474,7 @@ static VkBool32 VKAPI_CALL 
vk_dbg_callback(VkDebugUtilsMessageSeverityFlagBitsEX
 for (int i = 0; i < data->cmdBufLabelCount; i++)
 av_log(ctx, l, "\t%i: %s\n", i, data->pCmdBufLabels[i].pLabelName);
 
-return 0;
+return VK_FALSE;
 }
 
 #define ADD_VAL_TO_LIST(list, count, val)  
\

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

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


[FFmpeg-cvslog] vulkan: make sure descriptor buffers are always DEVICE_LOCAL

2024-08-13 Thread Lynne
ffmpeg | branch: master | Lynne  | Tue Aug 13 19:03:43 2024 
+0200| [d138d7a595b7ff3aa1808ad36e5695a5546b12ec] | committer: Lynne

vulkan: make sure descriptor buffers are always DEVICE_LOCAL

Implementations are required to list memory heaps in the most optimal
order. But its better to be explicit for this particular allocation.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d138d7a595b7ff3aa1808ad36e5695a5546b12ec
---

 libavutil/vulkan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 4e275bc7af..bb8e7ae786 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -1580,6 +1580,7 @@ int ff_vk_exec_pipeline_register(FFVulkanContext *s, 
FFVkExecPool *pool,
 
 err = ff_vk_create_buf(s, &set->buf, set->aligned_size*nb,
NULL, NULL, set->usage,
+   VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
 if (err < 0)

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

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


[FFmpeg-cvslog] vulkan_decode: use the correct queue family for decoding ops

2024-08-15 Thread Lynne
ffmpeg | branch: master | Lynne  | Wed Aug 14 14:22:28 2024 
+0200| [869f4aec484be200ea676d7d45c5b12c9b914434] | committer: Lynne

vulkan_decode: use the correct queue family for decoding ops

In 680d969a305c0927480573a1b455024088b51aeb, the new API was
used to find a queue family for dispatch, but the found queue
family was not used for decoding, just for dispatching.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=869f4aec484be200ea676d7d45c5b12c9b914434
---

 libavcodec/vulkan_decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index b89bfa17f2..c7a32cc439 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -1198,7 +1198,7 @@ int ff_vk_decode_init(AVCodecContext *avctx)
 nb_q = 1;
 
 session_create.flags = 0x0;
-session_create.queueFamilyIndex = s->hwctx->queue_family_decode_index;
+session_create.queueFamilyIndex = ctx->qf.queue_family;
 session_create.maxCodedExtent = ctx->caps.maxCodedExtent;
 session_create.maxDpbSlots = ctx->caps.maxDpbSlots;
 session_create.maxActiveReferencePictures = 
ctx->caps.maxActiveReferencePictures;

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

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


  1   2   3   4   5   6   7   8   9   >