[FFmpeg-devel] [PATCH] avfilter/af_afade: remove fade duration limit

2021-04-28 Thread realies
>From 8a4fe250e508932d8018adbb1af95d7c4a599a58 Mon Sep 17 00:00:00 2001
From: realies 
Date: Fri, 9 Apr 2021 21:57:47 +0100
Subject: [PATCH] avfilter/af_afade: remove fade duration limit

Removes arbitrary filter duration to allow fades up to the limit
of available memory. A docs warning has been added noting memory
use & potential delay with large fade durations on some muxer
configurations.
---
 doc/filters.texi   | 3 +++
 libavfilter/af_afade.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5e35fa6467..05ac14f30c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1146,6 +1146,9 @@ no fade applied
 @end table
 @end table

+Warning: This filter requires memory to buffer the fade duration. Some
+muxer configurations can cause delays with large fade durations.
+
 @subsection Commands

 This filter supports the all above options as @ref{commands}.
diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c
index 976b6752cd..23ece37774 100644
--- a/libavfilter/af_afade.c
+++ b/libavfilter/af_afade.c
@@ -385,8 +385,8 @@ AVFilter ff_af_afade = {
 static const AVOption acrossfade_options[] = {
 { "nb_samples",   "set number of samples for cross fade
duration", OFFSET(nb_samples),   AV_OPT_TYPE_INT,{.i64 = 44100},
1, INT32_MAX/10, FLAGS },
 { "ns",   "set number of samples for cross fade
duration", OFFSET(nb_samples),   AV_OPT_TYPE_INT,{.i64 = 44100},
1, INT32_MAX/10, FLAGS },
-{ "duration", "set cross fade duration",
 OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0 },  0,
6000, FLAGS },
-{ "d","set cross fade duration",
 OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0 },  0,
6000, FLAGS },
+{ "duration", "set cross fade duration",
 OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0 },  0, INT_MAX,
FLAGS },
+{ "d","set cross fade duration",
 OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0 },  0, INT_MAX,
FLAGS },
 { "overlap",  "overlap 1st stream end with 2nd stream start",
 OFFSET(overlap),  AV_OPT_TYPE_BOOL,   {.i64 = 1}, 0,  1,
FLAGS },
 { "o","overlap 1st stream end with 2nd stream start",
 OFFSET(overlap),  AV_OPT_TYPE_BOOL,   {.i64 = 1}, 0,  1,
FLAGS },
 { "curve1",   "set fade curve type for 1st stream",
 OFFSET(curve),AV_OPT_TYPE_INT,{.i64 = TRI  }, NONE,
NB_CURVES - 1, FLAGS, "curve" },
-- 
2.25.1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: dlopen libvulkan

2021-04-28 Thread Lynne
Apr 29, 2021, 04:35 by d...@lynne.ee:

> Apr 29, 2021, 03:54 by d...@lynne.ee:
>
>> While Vulkan itself went more or less the way it was expected to go, 
>> libvulkan didn't quite solve all of the opengl loader issues. It's 
>> multi-vendor,
>> yes, but unfortunately, the code is Google/Khronos QUALITY, so suffers from
>> big static linking issues (static linking on anything but OSX is 
>> unsupported),
>> has bugs, and due to the prefix system used, there are 3 or so ways to type 
>> out
>> functions.
>>
>> Just solve all of those problems by dlopening it. We even have nice emulation
>> for it on Windows.
>>
>> Patch attached.
>>
>
> Thanks to jamrial for telling me to zero extralibs, now there's no linking
> at all to libvulkan.
> v2 attached.
>

v3 attached.

>From 810036010a79811dfe9f20f6cf34368bbdeeecd9 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 29 Apr 2021 03:37:42 +0200
Subject: [PATCH v3] hwcontext_vulkan: dlopen libvulkan

While Vulkan itself went more or less the way it was expected to go,
libvulkan didn't quite solve all of the opengl loader issues. It's multi-vendor,
yes, but unfortunately, the code is Google/Khronos QUALITY, so suffers from
big static linking issues (static linking on anything but OSX is unsupported),
has bugs, and due to the prefix system used, there are 3 or so ways to type out
functions.

Just solve all of those problems by dlopening it. We even have nice emulation
for it on Windows.
---
 configure|  3 ++-
 libavutil/hwcontext_vulkan.c | 51 +---
 2 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 820f719a32..151c74890d 100755
--- a/configure
+++ b/configure
@@ -2920,6 +2920,7 @@ nvdec_deps="ffnvcodec"
 vaapi_x11_deps="xlib"
 videotoolbox_hwaccel_deps="videotoolbox pthreads"
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
+vulkan_deps_any="libdl LoadLibrary"
 xvmc_deps="X11_extensions_XvMClib_h"
 
 av1_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_AV1"
@@ -6739,7 +6740,7 @@ enabled vdpau &&
 enabled crystalhd && check_lib crystalhd "stdint.h libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
 
 enabled vulkan &&
-require_pkg_config vulkan "vulkan >= 1.1.97" "vulkan/vulkan.h" vkCreateInstance
+require_pkg_config vulkan "vulkan >= 1.1.97" "vulkan/vulkan.h" vkCreateInstance && eval vulkan_extralibs=""
 
 if enabled x86; then
 case $target_os in
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 7bb05ca1c7..52de5ab122 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -26,8 +26,11 @@
 #include "hwcontext_internal.h"
 #include "hwcontext_vulkan.h"
 
-VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance,
-   const char *name);
+#ifdef _WIN32
+#include "compat/w32dlfcn.h"
+#else
+#include 
+#endif
 
 #if CONFIG_LIBDRM
 #include 
@@ -186,7 +189,8 @@ typedef struct VulkanExecCtx {
 } VulkanExecCtx;
 
 typedef struct VulkanDevicePriv {
-/* Vulkan loader functions */
+/* Vulkan library and loader functions */
+void *libvulkan;
 VulkanFunctions vkfn;
 
 /* Properties */
@@ -369,6 +373,40 @@ static int pixfmt_is_supported(AVHWDeviceContext *dev_ctx, enum AVPixelFormat p,
 return 1;
 }
 
+static int load_libvulkan(AVHWDeviceContext *ctx)
+{
+AVVulkanDeviceContext *hwctx = ctx->hwctx;
+VulkanDevicePriv *p = ctx->internal->priv;
+
+static const char *lib_names[] = {
+#if defined(_WIN32)
+"vulkan-1.dll",
+#elif defined(__APPLE__)
+"libvulkan.dylib",
+"libvulkan.1.dylib",
+"libMoltenVK.dylib",
+#else
+"libvulkan.so.1",
+"libvulkan.so",
+#endif
+};
+
+for (int i = 0; i < FF_ARRAY_ELEMS(lib_names); i++) {
+p->libvulkan = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
+if (p->libvulkan)
+break;
+}
+
+if (!p->libvulkan) {
+av_log(ctx, AV_LOG_ERROR, "Unable to open the libvulkan library!\n");
+return AVERROR_UNKNOWN;
+}
+
+hwctx->get_proc_addr = (PFN_vkGetInstanceProcAddr)dlsym(p->libvulkan, "vkGetInstanceProcAddr");
+
+return 0;
+}
+
 static int load_functions(AVHWDeviceContext *ctx, int has_inst, int has_dev)
 {
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
@@ -649,7 +687,9 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts)
 };
 
 if (!hwctx->get_proc_addr) {
-hwctx->get_proc_addr = vkGetInstanceProcAddr;
+err = load_libvulkan(ctx);
+if (err < 0)
+return err;
 }
 
 err = load_functions(ctx, 0, 0);
@@ -1188,6 +1228,9 @@ static void vulkan_device_free(AVHWDeviceContext *ctx)
 
 vk->DestroyInstance(hwctx->inst, hwctx->alloc);
 
+if (p->libvulkan)
+dlclose(p->libvulkan);
+
 for (int i = 0; i < hwctx->nb_enabled_inst_extensions; i++)
 av_free((void *)hwctx->enabled_inst

Re: [FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: dlopen libvulkan

2021-04-28 Thread Lynne
Apr 29, 2021, 04:35 by d...@lynne.ee:

> Apr 29, 2021, 03:54 by d...@lynne.ee:
>
>> While Vulkan itself went more or less the way it was expected to go, 
>> libvulkan didn't quite solve all of the opengl loader issues. It's 
>> multi-vendor,
>> yes, but unfortunately, the code is Google/Khronos QUALITY, so suffers from
>> big static linking issues (static linking on anything but OSX is 
>> unsupported),
>> has bugs, and due to the prefix system used, there are 3 or so ways to type 
>> out
>> functions.
>>
>> Just solve all of those problems by dlopening it. We even have nice emulation
>> for it on Windows.
>>
>> Patch attached.
>>
>
> Thanks to jamrial for telling me to zero extralibs, now there's no linking
> at all to libvulkan.
> v2 attached.
>

v3 attached.

>From 810036010a79811dfe9f20f6cf34368bbdeeecd9 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 29 Apr 2021 03:37:42 +0200
Subject: [PATCH v3] hwcontext_vulkan: dlopen libvulkan

While Vulkan itself went more or less the way it was expected to go,
libvulkan didn't quite solve all of the opengl loader issues. It's multi-vendor,
yes, but unfortunately, the code is Google/Khronos QUALITY, so suffers from
big static linking issues (static linking on anything but OSX is unsupported),
has bugs, and due to the prefix system used, there are 3 or so ways to type out
functions.

Just solve all of those problems by dlopening it. We even have nice emulation
for it on Windows.
---
 configure|  3 ++-
 libavutil/hwcontext_vulkan.c | 51 +---
 2 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 820f719a32..151c74890d 100755
--- a/configure
+++ b/configure
@@ -2920,6 +2920,7 @@ nvdec_deps="ffnvcodec"
 vaapi_x11_deps="xlib"
 videotoolbox_hwaccel_deps="videotoolbox pthreads"
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
+vulkan_deps_any="libdl LoadLibrary"
 xvmc_deps="X11_extensions_XvMClib_h"
 
 av1_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_AV1"
@@ -6739,7 +6740,7 @@ enabled vdpau &&
 enabled crystalhd && check_lib crystalhd "stdint.h libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
 
 enabled vulkan &&
-require_pkg_config vulkan "vulkan >= 1.1.97" "vulkan/vulkan.h" vkCreateInstance
+require_pkg_config vulkan "vulkan >= 1.1.97" "vulkan/vulkan.h" vkCreateInstance && eval vulkan_extralibs=""
 
 if enabled x86; then
 case $target_os in
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 7bb05ca1c7..52de5ab122 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -26,8 +26,11 @@
 #include "hwcontext_internal.h"
 #include "hwcontext_vulkan.h"
 
-VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance,
-   const char *name);
+#ifdef _WIN32
+#include "compat/w32dlfcn.h"
+#else
+#include 
+#endif
 
 #if CONFIG_LIBDRM
 #include 
@@ -186,7 +189,8 @@ typedef struct VulkanExecCtx {
 } VulkanExecCtx;
 
 typedef struct VulkanDevicePriv {
-/* Vulkan loader functions */
+/* Vulkan library and loader functions */
+void *libvulkan;
 VulkanFunctions vkfn;
 
 /* Properties */
@@ -369,6 +373,40 @@ static int pixfmt_is_supported(AVHWDeviceContext *dev_ctx, enum AVPixelFormat p,
 return 1;
 }
 
+static int load_libvulkan(AVHWDeviceContext *ctx)
+{
+AVVulkanDeviceContext *hwctx = ctx->hwctx;
+VulkanDevicePriv *p = ctx->internal->priv;
+
+static const char *lib_names[] = {
+#if defined(_WIN32)
+"vulkan-1.dll",
+#elif defined(__APPLE__)
+"libvulkan.dylib",
+"libvulkan.1.dylib",
+"libMoltenVK.dylib",
+#else
+"libvulkan.so.1",
+"libvulkan.so",
+#endif
+};
+
+for (int i = 0; i < FF_ARRAY_ELEMS(lib_names); i++) {
+p->libvulkan = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
+if (p->libvulkan)
+break;
+}
+
+if (!p->libvulkan) {
+av_log(ctx, AV_LOG_ERROR, "Unable to open the libvulkan library!\n");
+return AVERROR_UNKNOWN;
+}
+
+hwctx->get_proc_addr = (PFN_vkGetInstanceProcAddr)dlsym(p->libvulkan, "vkGetInstanceProcAddr");
+
+return 0;
+}
+
 static int load_functions(AVHWDeviceContext *ctx, int has_inst, int has_dev)
 {
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
@@ -649,7 +687,9 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts)
 };
 
 if (!hwctx->get_proc_addr) {
-hwctx->get_proc_addr = vkGetInstanceProcAddr;
+err = load_libvulkan(ctx);
+if (err < 0)
+return err;
 }
 
 err = load_functions(ctx, 0, 0);
@@ -1188,6 +1228,9 @@ static void vulkan_device_free(AVHWDeviceContext *ctx)
 
 vk->DestroyInstance(hwctx->inst, hwctx->alloc);
 
+if (p->libvulkan)
+dlclose(p->libvulkan);
+
 for (int i = 0; i < hwctx->nb_enabled_inst_extensions; i++)
 av_free((void *)hwctx->enabled_inst

Re: [FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: dlopen libvulkan

2021-04-28 Thread Lynne
Apr 29, 2021, 04:35 by d...@lynne.ee:

> Apr 29, 2021, 03:54 by d...@lynne.ee:
>
>> While Vulkan itself went more or less the way it was expected to go, 
>> libvulkan didn't quite solve all of the opengl loader issues. It's 
>> multi-vendor,
>> yes, but unfortunately, the code is Google/Khronos QUALITY, so suffers from
>> big static linking issues (static linking on anything but OSX is 
>> unsupported),
>> has bugs, and due to the prefix system used, there are 3 or so ways to type 
>> out
>> functions.
>>
>> Just solve all of those problems by dlopening it. We even have nice emulation
>> for it on Windows.
>>
>> Patch attached.
>>
>
> Thanks to jamrial for telling me to zero extralibs, now there's no linking
> at all to libvulkan.
> v2 attached.
>

v3 attached.

>From 810036010a79811dfe9f20f6cf34368bbdeeecd9 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 29 Apr 2021 03:37:42 +0200
Subject: [PATCH v3] hwcontext_vulkan: dlopen libvulkan

While Vulkan itself went more or less the way it was expected to go,
libvulkan didn't quite solve all of the opengl loader issues. It's multi-vendor,
yes, but unfortunately, the code is Google/Khronos QUALITY, so suffers from
big static linking issues (static linking on anything but OSX is unsupported),
has bugs, and due to the prefix system used, there are 3 or so ways to type out
functions.

Just solve all of those problems by dlopening it. We even have nice emulation
for it on Windows.
---
 configure|  3 ++-
 libavutil/hwcontext_vulkan.c | 51 +---
 2 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 820f719a32..151c74890d 100755
--- a/configure
+++ b/configure
@@ -2920,6 +2920,7 @@ nvdec_deps="ffnvcodec"
 vaapi_x11_deps="xlib"
 videotoolbox_hwaccel_deps="videotoolbox pthreads"
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
+vulkan_deps_any="libdl LoadLibrary"
 xvmc_deps="X11_extensions_XvMClib_h"
 
 av1_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_AV1"
@@ -6739,7 +6740,7 @@ enabled vdpau &&
 enabled crystalhd && check_lib crystalhd "stdint.h libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
 
 enabled vulkan &&
-require_pkg_config vulkan "vulkan >= 1.1.97" "vulkan/vulkan.h" vkCreateInstance
+require_pkg_config vulkan "vulkan >= 1.1.97" "vulkan/vulkan.h" vkCreateInstance && eval vulkan_extralibs=""
 
 if enabled x86; then
 case $target_os in
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 7bb05ca1c7..52de5ab122 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -26,8 +26,11 @@
 #include "hwcontext_internal.h"
 #include "hwcontext_vulkan.h"
 
-VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance,
-   const char *name);
+#ifdef _WIN32
+#include "compat/w32dlfcn.h"
+#else
+#include 
+#endif
 
 #if CONFIG_LIBDRM
 #include 
@@ -186,7 +189,8 @@ typedef struct VulkanExecCtx {
 } VulkanExecCtx;
 
 typedef struct VulkanDevicePriv {
-/* Vulkan loader functions */
+/* Vulkan library and loader functions */
+void *libvulkan;
 VulkanFunctions vkfn;
 
 /* Properties */
@@ -369,6 +373,40 @@ static int pixfmt_is_supported(AVHWDeviceContext *dev_ctx, enum AVPixelFormat p,
 return 1;
 }
 
+static int load_libvulkan(AVHWDeviceContext *ctx)
+{
+AVVulkanDeviceContext *hwctx = ctx->hwctx;
+VulkanDevicePriv *p = ctx->internal->priv;
+
+static const char *lib_names[] = {
+#if defined(_WIN32)
+"vulkan-1.dll",
+#elif defined(__APPLE__)
+"libvulkan.dylib",
+"libvulkan.1.dylib",
+"libMoltenVK.dylib",
+#else
+"libvulkan.so.1",
+"libvulkan.so",
+#endif
+};
+
+for (int i = 0; i < FF_ARRAY_ELEMS(lib_names); i++) {
+p->libvulkan = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
+if (p->libvulkan)
+break;
+}
+
+if (!p->libvulkan) {
+av_log(ctx, AV_LOG_ERROR, "Unable to open the libvulkan library!\n");
+return AVERROR_UNKNOWN;
+}
+
+hwctx->get_proc_addr = (PFN_vkGetInstanceProcAddr)dlsym(p->libvulkan, "vkGetInstanceProcAddr");
+
+return 0;
+}
+
 static int load_functions(AVHWDeviceContext *ctx, int has_inst, int has_dev)
 {
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
@@ -649,7 +687,9 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts)
 };
 
 if (!hwctx->get_proc_addr) {
-hwctx->get_proc_addr = vkGetInstanceProcAddr;
+err = load_libvulkan(ctx);
+if (err < 0)
+return err;
 }
 
 err = load_functions(ctx, 0, 0);
@@ -1188,6 +1228,9 @@ static void vulkan_device_free(AVHWDeviceContext *ctx)
 
 vk->DestroyInstance(hwctx->inst, hwctx->alloc);
 
+if (p->libvulkan)
+dlclose(p->libvulkan);
+
 for (int i = 0; i < hwctx->nb_enabled_inst_extensions; i++)
 av_free((void *)hwctx->enabled_inst

Re: [FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: dlopen libvulkan

2021-04-28 Thread Lynne
Apr 29, 2021, 03:54 by d...@lynne.ee:

> While Vulkan itself went more or less the way it was expected to go, 
> libvulkan didn't quite solve all of the opengl loader issues. It's 
> multi-vendor,
> yes, but unfortunately, the code is Google/Khronos QUALITY, so suffers from
> big static linking issues (static linking on anything but OSX is unsupported),
> has bugs, and due to the prefix system used, there are 3 or so ways to type 
> out
> functions.
>
> Just solve all of those problems by dlopening it. We even have nice emulation
> for it on Windows.
>
> Patch attached.
>

Thanks to jamrial for telling me to zero extralibs, now there's no linking
at all to libvulkan.
v2 attached.

>From 9c2778fe82490b96c9efeba3fe09077fbf13cfe0 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 29 Apr 2021 03:37:42 +0200
Subject: [PATCH v2 2/2] hwcontext_vulkan: dlopen libvulkan

While Vulkan itself went more or less the way it was expected to go,
libvulkan didn't quite solve all of the opengl loader issues. It's multi-vendor,
yes, but unfortunately, the code is Google/Khronos QUALITY, so suffers from
big static linking issues (static linking on anything but OSX is unsupported),
has bugs, and due to the prefix system used, there are 3 or so ways to type out
functions.

Just solve all of those problems by dlopening it. We even have nice emulation
for it on Windows.
---
 configure|  4 ++-
 libavutil/hwcontext_vulkan.c | 51 +---
 2 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 820f719a32..fbd85e3244 100755
--- a/configure
+++ b/configure
@@ -2920,6 +2920,8 @@ nvdec_deps="ffnvcodec"
 vaapi_x11_deps="xlib"
 videotoolbox_hwaccel_deps="videotoolbox pthreads"
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
+vulkan_deps_any="libdl LoadLibrary"
+vulkan_hwaccel_extralibs=""
 xvmc_deps="X11_extensions_XvMClib_h"
 
 av1_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_AV1"
@@ -6739,7 +6741,7 @@ enabled vdpau &&
 enabled crystalhd && check_lib crystalhd "stdint.h libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
 
 enabled vulkan &&
-require_pkg_config vulkan "vulkan >= 1.1.97" "vulkan/vulkan.h" vkCreateInstance
+require_cpp_condition vulkan vulkan/vulkan.h "defined VK_VERSION_1_1"
 
 if enabled x86; then
 case $target_os in
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 7bb05ca1c7..52de5ab122 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -26,8 +26,11 @@
 #include "hwcontext_internal.h"
 #include "hwcontext_vulkan.h"
 
-VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance,
-   const char *name);
+#ifdef _WIN32
+#include "compat/w32dlfcn.h"
+#else
+#include 
+#endif
 
 #if CONFIG_LIBDRM
 #include 
@@ -186,7 +189,8 @@ typedef struct VulkanExecCtx {
 } VulkanExecCtx;
 
 typedef struct VulkanDevicePriv {
-/* Vulkan loader functions */
+/* Vulkan library and loader functions */
+void *libvulkan;
 VulkanFunctions vkfn;
 
 /* Properties */
@@ -369,6 +373,40 @@ static int pixfmt_is_supported(AVHWDeviceContext *dev_ctx, enum AVPixelFormat p,
 return 1;
 }
 
+static int load_libvulkan(AVHWDeviceContext *ctx)
+{
+AVVulkanDeviceContext *hwctx = ctx->hwctx;
+VulkanDevicePriv *p = ctx->internal->priv;
+
+static const char *lib_names[] = {
+#if defined(_WIN32)
+"vulkan-1.dll",
+#elif defined(__APPLE__)
+"libvulkan.dylib",
+"libvulkan.1.dylib",
+"libMoltenVK.dylib",
+#else
+"libvulkan.so.1",
+"libvulkan.so",
+#endif
+};
+
+for (int i = 0; i < FF_ARRAY_ELEMS(lib_names); i++) {
+p->libvulkan = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
+if (p->libvulkan)
+break;
+}
+
+if (!p->libvulkan) {
+av_log(ctx, AV_LOG_ERROR, "Unable to open the libvulkan library!\n");
+return AVERROR_UNKNOWN;
+}
+
+hwctx->get_proc_addr = (PFN_vkGetInstanceProcAddr)dlsym(p->libvulkan, "vkGetInstanceProcAddr");
+
+return 0;
+}
+
 static int load_functions(AVHWDeviceContext *ctx, int has_inst, int has_dev)
 {
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
@@ -649,7 +687,9 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts)
 };
 
 if (!hwctx->get_proc_addr) {
-hwctx->get_proc_addr = vkGetInstanceProcAddr;
+err = load_libvulkan(ctx);
+if (err < 0)
+return err;
 }
 
 err = load_functions(ctx, 0, 0);
@@ -1188,6 +1228,9 @@ static void vulkan_device_free(AVHWDeviceContext *ctx)
 
 vk->DestroyInstance(hwctx->inst, hwctx->alloc);
 
+if (p->libvulkan)
+dlclose(p->libvulkan);
+
 for (int i = 0; i < hwctx->nb_enabled_inst_extensions; i++)
 av_free((void *)hwctx->enabled_inst_extensions[i]);
 av_free((void *)hwctx->enabled_inst_extensions);
-- 
2.31.1.498.g6

Re: [FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: dynamically load functions

2021-04-28 Thread Lynne
Apr 29, 2021, 03:52 by d...@lynne.ee:

> This patch allows for alternative loader implementations. 
>
> Patch attached.
>

Forgot to fix a flag, v2 attached.

>From a55c2c8e802cc9ab7ad5a0562198a3a1a3797d76 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 29 Apr 2021 02:44:41 +0200
Subject: [PATCH v2 1/2] hwcontext_vulkan: dynamically load functions

This patch allows for alternative loader implementations.
---
 libavutil/hwcontext_cuda.c   |   5 +-
 libavutil/hwcontext_vulkan.c | 512 +--
 libavutil/hwcontext_vulkan.h |   7 +
 3 files changed, 376 insertions(+), 148 deletions(-)

diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
index cfdf2d7fd4..48f7ecbdd3 100644
--- a/libavutil/hwcontext_cuda.c
+++ b/libavutil/hwcontext_cuda.c
@@ -427,16 +427,19 @@ static int cuda_device_derive(AVHWDeviceContext *device_ctx,
 
 switch (src_ctx->type) {
 #if CONFIG_VULKAN
+#define TYPE PFN_vkGetPhysicalDeviceProperties2
 case AV_HWDEVICE_TYPE_VULKAN: {
 AVVulkanDeviceContext *vkctx = src_ctx->hwctx;
+TYPE prop_fn = (TYPE)vkctx->get_proc_addr(vkctx->inst, "vkGetPhysicalDeviceProperties2");
 VkPhysicalDeviceProperties2 vk_dev_props = {
 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
 .pNext = &vk_idp,
 };
-vkGetPhysicalDeviceProperties2(vkctx->phys_dev, &vk_dev_props);
+prop_fn(vkctx->phys_dev, &vk_dev_props);
 src_uuid = vk_idp.deviceUUID;
 break;
 }
+#undef TYPE
 #endif
 default:
 return AVERROR(ENOSYS);
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 48327ad98f..7bb05ca1c7 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#define VK_NO_PROTOTYPES
+
 #include "config.h"
 #include "pixdesc.h"
 #include "avstring.h"
@@ -24,6 +26,9 @@
 #include "hwcontext_internal.h"
 #include "hwcontext_vulkan.h"
 
+VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance,
+   const char *name);
+
 #if CONFIG_LIBDRM
 #include 
 #include 
@@ -41,6 +46,126 @@
 #define CHECK_CU(x) FF_CUDA_CHECK_DL(cuda_cu, cu, x)
 #endif
 
+enum VulkanExtensions {
+EXT_EXTERNAL_DMABUF_MEMORY = 1 <<  0, /* VK_EXT_external_memory_dma_buf */
+EXT_DRM_MODIFIER_FLAGS = 1 <<  1, /* VK_EXT_image_drm_format_modifier */
+EXT_EXTERNAL_FD_MEMORY = 1 <<  2, /* VK_KHR_external_memory_fd */
+EXT_EXTERNAL_FD_SEM= 1 <<  3, /* VK_KHR_external_semaphore_fd */
+EXT_EXTERNAL_HOST_MEMORY   = 1 <<  4, /* VK_EXT_external_memory_host */
+EXT_PUSH_DESCRIPTORS   = 1 <<  5, /* VK_KHR_push_descriptor */
+EXT_DEBUG_UTILS= 1 <<  6, /* VK_EXT_debug_utils */
+
+EXT_NO_FLAG= 1 << 31,
+};
+
+#define FN_LIST(MACRO) \
+/* Instance */ \
+MACRO(0, 0, EXT_NO_FLAG,  EnumerateInstanceExtensionProperties)\
+MACRO(0, 0, EXT_NO_FLAG,  CreateInstance)  \
+MACRO(1, 0, EXT_NO_FLAG,  DestroyInstance) \
+   \
+/* Debug */\
+MACRO(1, 0, EXT_NO_FLAG,  CreateDebugUtilsMessengerEXT)\
+MACRO(1, 0, EXT_NO_FLAG,  DestroyDebugUtilsMessengerEXT)   \
+   \
+/* Device */   \
+MACRO(1, 0, EXT_NO_FLAG,  GetDeviceProcAddr)   \
+MACRO(1, 0, EXT_NO_FLAG,  CreateDevice)\
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceFeatures)   \
+MACRO(1, 0, EXT_NO_FLAG,  DestroyDevice)   \
+   \
+MACRO(1, 0, EXT_NO_FLAG,  EnumeratePhysicalDevices)\
+MACRO(1, 0, EXT_NO_FLAG,  EnumerateDeviceExtensionProperties)  \
+   \
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceProperties2)\
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceMemoryProperties)   \
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceFormatProperties2)  \
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceImageFormatProperties2) \
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceQueueFamily

[FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: dlopen libvulkan

2021-04-28 Thread Lynne
While Vulkan itself went more or less the way it was expected to go, 
libvulkan didn't quite solve all of the opengl loader issues. It's multi-vendor,
yes, but unfortunately, the code is Google/Khronos QUALITY, so suffers from
big static linking issues (static linking on anything but OSX is unsupported),
has bugs, and due to the prefix system used, there are 3 or so ways to type out
functions.

Just solve all of those problems by dlopening it. We even have nice emulation
for it on Windows.

Patch attached.

>From 69d09ae9c477e51c5115f9c71a5cc5d9188f378d Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 29 Apr 2021 03:37:42 +0200
Subject: [PATCH 2/2] hwcontext_vulkan: dlopen libvulkan

While Vulkan itself went more or less the way it was expected to go,
libvulkan didn't quite solve all of the opengl loader issues. It's multi-vendor,
yes, but unfortunately, the code is Google/Khronos QUALITY, so suffers from
big static linking issues (static linking on anything but OSX is unsupported),
has bugs, and due to the prefix system used, there are 3 or so ways to type out
functions.

Just solve all of those problems by dlopening it. We even have nice emulation
for it on Windows.
---
 configure|  3 ++-
 libavutil/hwcontext_vulkan.c | 51 +---
 2 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 820f719a32..40922f9ad6 100755
--- a/configure
+++ b/configure
@@ -2920,6 +2920,7 @@ nvdec_deps="ffnvcodec"
 vaapi_x11_deps="xlib"
 videotoolbox_hwaccel_deps="videotoolbox pthreads"
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
+vulkan_deps_any="libdl LoadLibrary"
 xvmc_deps="X11_extensions_XvMClib_h"
 
 av1_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_AV1"
@@ -6739,7 +6740,7 @@ enabled vdpau &&
 enabled crystalhd && check_lib crystalhd "stdint.h libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
 
 enabled vulkan &&
-require_pkg_config vulkan "vulkan >= 1.1.97" "vulkan/vulkan.h" vkCreateInstance
+check_cpp_condition vulkan vulkan/vulkan.h "defined VK_VERSION_1_1"
 
 if enabled x86; then
 case $target_os in
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index cfaf554af9..209439d427 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -26,8 +26,11 @@
 #include "hwcontext_internal.h"
 #include "hwcontext_vulkan.h"
 
-VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance,
-   const char *name);
+#ifdef _WIN32
+#include "compat/w32dlfcn.h"
+#else
+#include 
+#endif
 
 #if CONFIG_LIBDRM
 #include 
@@ -186,7 +189,8 @@ typedef struct VulkanExecCtx {
 } VulkanExecCtx;
 
 typedef struct VulkanDevicePriv {
-/* Vulkan loader functions */
+/* Vulkan library and loader functions */
+void *libvulkan;
 VulkanFunctions vkfn;
 
 /* Properties */
@@ -369,6 +373,40 @@ static int pixfmt_is_supported(AVHWDeviceContext *dev_ctx, enum AVPixelFormat p,
 return 1;
 }
 
+static int load_libvulkan(AVHWDeviceContext *ctx)
+{
+AVVulkanDeviceContext *hwctx = ctx->hwctx;
+VulkanDevicePriv *p = ctx->internal->priv;
+
+static const char *lib_names[] = {
+#if defined(_WIN32)
+"vulkan-1.dll",
+#elif defined(__APPLE__)
+"libvulkan.dylib",
+"libvulkan.1.dylib",
+"libMoltenVK.dylib",
+#else
+"libvulkan.so.1",
+"libvulkan.so",
+#endif
+};
+
+for (int i = 0; i < FF_ARRAY_ELEMS(lib_names); i++) {
+p->libvulkan = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
+if (p->libvulkan)
+break;
+}
+
+if (!p->libvulkan) {
+av_log(ctx, AV_LOG_ERROR, "Unable to open the libvulkan library!\n");
+return AVERROR_UNKNOWN;
+}
+
+hwctx->get_proc_addr = (PFN_vkGetInstanceProcAddr)dlsym(p->libvulkan, "vkGetInstanceProcAddr");
+
+return 0;
+}
+
 static int load_functions(AVHWDeviceContext *ctx, int has_inst, int has_dev)
 {
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
@@ -649,7 +687,9 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts)
 };
 
 if (!hwctx->get_proc_addr) {
-hwctx->get_proc_addr = vkGetInstanceProcAddr;
+err = load_libvulkan(ctx);
+if (err < 0)
+return err;
 }
 
 err = load_functions(ctx, 0, 0);
@@ -1188,6 +1228,9 @@ static void vulkan_device_free(AVHWDeviceContext *ctx)
 
 vk->DestroyInstance(hwctx->inst, hwctx->alloc);
 
+if (p->libvulkan)
+dlclose(p->libvulkan);
+
 for (int i = 0; i < hwctx->nb_enabled_inst_extensions; i++)
 av_free((void *)hwctx->enabled_inst_extensions[i]);
 av_free((void *)hwctx->enabled_inst_extensions);
-- 
2.31.1.498.g6c1eba8ee3d

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

To unsubscribe, visit link above, or email
ffmpeg-d

[FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: dynamically load functions

2021-04-28 Thread Lynne
This patch allows for alternative loader implementations. 

Patch attached.

>From 7ab5acd9b999b5aaa0748870c748d3ee31ea94d3 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 29 Apr 2021 02:44:41 +0200
Subject: [PATCH 1/2] hwcontext_vulkan: dynamically load functions

This patch allows for alternative loader implementations.
---
 libavutil/hwcontext_vulkan.c | 510 +--
 libavutil/hwcontext_vulkan.h |   7 +
 2 files changed, 371 insertions(+), 146 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 48327ad98f..cfaf554af9 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#define VK_NO_PROTOTYPES
+
 #include "config.h"
 #include "pixdesc.h"
 #include "avstring.h"
@@ -24,6 +26,9 @@
 #include "hwcontext_internal.h"
 #include "hwcontext_vulkan.h"
 
+VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance,
+   const char *name);
+
 #if CONFIG_LIBDRM
 #include 
 #include 
@@ -41,6 +46,126 @@
 #define CHECK_CU(x) FF_CUDA_CHECK_DL(cuda_cu, cu, x)
 #endif
 
+enum VulkanExtensions {
+EXT_EXTERNAL_DMABUF_MEMORY = 1 <<  0, /* VK_EXT_external_memory_dma_buf */
+EXT_DRM_MODIFIER_FLAGS = 1 <<  1, /* VK_EXT_image_drm_format_modifier */
+EXT_EXTERNAL_FD_MEMORY = 1 <<  2, /* VK_KHR_external_memory_fd */
+EXT_EXTERNAL_FD_SEM= 1 <<  3, /* VK_KHR_external_semaphore_fd */
+EXT_EXTERNAL_HOST_MEMORY   = 1 <<  4, /* VK_EXT_external_memory_host */
+EXT_PUSH_DESCRIPTORS   = 1 <<  5, /* VK_KHR_push_descriptor */
+EXT_DEBUG_UTILS= 1 <<  6, /* VK_EXT_debug_utils */
+
+EXT_NO_FLAG= 1 << 31,
+};
+
+#define FN_LIST(MACRO) \
+/* Instance */ \
+MACRO(0, 0, EXT_NO_FLAG,  EnumerateInstanceExtensionProperties)\
+MACRO(0, 0, EXT_NO_FLAG,  CreateInstance)  \
+MACRO(1, 0, EXT_NO_FLAG,  DestroyInstance) \
+   \
+/* Debug */\
+MACRO(1, 0, EXT_NO_FLAG,  CreateDebugUtilsMessengerEXT)\
+MACRO(1, 0, EXT_NO_FLAG,  DestroyDebugUtilsMessengerEXT)   \
+   \
+/* Device */   \
+MACRO(1, 0, EXT_NO_FLAG,  GetDeviceProcAddr)   \
+MACRO(1, 0, EXT_NO_FLAG,  CreateDevice)\
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceFeatures)   \
+MACRO(1, 0, EXT_NO_FLAG,  DestroyDevice)   \
+   \
+MACRO(1, 0, EXT_NO_FLAG,  EnumeratePhysicalDevices)\
+MACRO(1, 0, EXT_NO_FLAG,  EnumerateDeviceExtensionProperties)  \
+   \
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceProperties2)\
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceMemoryProperties)   \
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceFormatProperties2)  \
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceImageFormatProperties2) \
+MACRO(1, 0, EXT_NO_FLAG,  GetPhysicalDeviceQueueFamilyProperties)  \
+   \
+/* Command pool */ \
+MACRO(1, 1, EXT_NO_FLAG,  CreateCommandPool)   \
+MACRO(1, 1, EXT_NO_FLAG,  DestroyCommandPool)  \
+   \
+/* Command buffer */   \
+MACRO(1, 1, EXT_NO_FLAG,  AllocateCommandBuffers)  \
+MACRO(1, 1, EXT_NO_FLAG,  BeginCommandBuffer)  \
+MACRO(1, 1, EXT_NO_FLAG,  EndCommandBuffer)\
+MACRO(1, 1, EXT_NO_FLAG,  FreeCommandBuffers)  \
+   \
+/* Queue */\
+MACRO(1, 1, EXT_NO_FLAG,  

Re: [FFmpeg-devel] [PATCH 2/2] lavc/aarch64: add hevc epel/qpel assembly

2021-04-28 Thread chen
inline comment with prefix [MC]

At 2021-04-29 03:50:26, "Josh Dekker"  wrote:
>From: Rafal Dabrowa 
>
>Benchmarked on Apple M1:
>
>put_hevc_epel_bi_h4_8_c: 69.9
>put_hevc_epel_bi_h4_8_neon: 15.4
>put_hevc_epel_bi_h6_8_c: 137.1
>put_hevc_epel_bi_h6_8_neon: 31.9
>put_hevc_epel_bi_h8_8_c: 124.6
>put_hevc_epel_bi_h8_8_neon: 40.9
>put_hevc_epel_bi_h12_8_c: 331.9
>put_hevc_epel_bi_h12_8_neon: 72.4
>put_hevc_epel_bi_h16_8_c: 383.4
>put_hevc_epel_bi_h16_8_neon: 124.9
>put_hevc_epel_bi_h24_8_c: 771.6
>put_hevc_epel_bi_h24_8_neon: 209.6
>put_hevc_epel_bi_h32_8_c: 1324.4
>put_hevc_epel_bi_h32_8_neon: 389.4
>put_hevc_epel_bi_h48_8_c: 2869.6
>put_hevc_epel_bi_h48_8_neon: 730.1
>put_hevc_epel_bi_h64_8_c: 4992.6
>put_hevc_epel_bi_h64_8_neon: 1490.4
>put_hevc_epel_bi_hv4_8_c: 163.4
>put_hevc_epel_bi_hv4_8_neon: 38.4
>put_hevc_epel_bi_hv6_8_c: 292.4
>put_hevc_epel_bi_hv6_8_neon: 66.4
>put_hevc_epel_bi_hv8_8_c: 375.6
>put_hevc_epel_bi_hv8_8_neon: 62.4
>put_hevc_epel_bi_hv12_8_c: 831.6
>put_hevc_epel_bi_hv12_8_neon: 134.9
>put_hevc_epel_bi_hv16_8_c: 1257.9
>put_hevc_epel_bi_hv16_8_neon: 214.1
>put_hevc_epel_bi_hv24_8_c: 2666.6
>put_hevc_epel_bi_hv24_8_neon: 391.1
>put_hevc_epel_bi_hv32_8_c: 4722.4
>put_hevc_epel_bi_hv32_8_neon: 734.1
>put_hevc_epel_bi_hv48_8_c: 10100.4
>put_hevc_epel_bi_hv48_8_neon: 1570.4
>put_hevc_epel_bi_hv64_8_c: 17613.4
>put_hevc_epel_bi_hv64_8_neon: 2810.6
>put_hevc_epel_bi_v4_8_c: 77.4
>put_hevc_epel_bi_v4_8_neon: 18.6
>put_hevc_epel_bi_v6_8_c: 142.1
>put_hevc_epel_bi_v6_8_neon: 27.1
>put_hevc_epel_bi_v8_8_c: 192.9
>put_hevc_epel_bi_v8_8_neon: 9.1
>put_hevc_epel_bi_v12_8_c: 415.6
>put_hevc_epel_bi_v12_8_neon: 55.6
>put_hevc_epel_bi_v16_8_c: 487.6
>put_hevc_epel_bi_v16_8_neon: 61.9
>put_hevc_epel_bi_v24_8_c: 957.4
>put_hevc_epel_bi_v24_8_neon: 131.1
>put_hevc_epel_bi_v32_8_c: 1540.4
>put_hevc_epel_bi_v32_8_neon: 210.4
>put_hevc_epel_bi_v48_8_c: 3242.9
>put_hevc_epel_bi_v48_8_neon: 465.6
>put_hevc_epel_bi_v64_8_c: 5441.1
>put_hevc_epel_bi_v64_8_neon: 818.1
>put_hevc_epel_h4_8_c: 41.6
>put_hevc_epel_h4_8_neon: 8.4
>put_hevc_epel_h6_8_c: 110.1
>put_hevc_epel_h6_8_neon: 24.4
>put_hevc_epel_h8_8_c: 41.6
>put_hevc_epel_h8_8_neon: 17.6
>put_hevc_epel_h12_8_c: 183.1
>put_hevc_epel_h12_8_neon: 58.1
>put_hevc_epel_h16_8_c: 146.6
>put_hevc_epel_h16_8_neon: 83.4
>put_hevc_epel_h24_8_c: 240.4
>put_hevc_epel_h24_8_neon: 157.1
>put_hevc_epel_h32_8_c: 431.1
>put_hevc_epel_h32_8_neon: 292.1
>put_hevc_epel_h48_8_c: 858.6
>put_hevc_epel_h48_8_neon: 557.4
>put_hevc_epel_h64_8_c: 1536.6
>put_hevc_epel_h64_8_neon: 1116.6
>put_hevc_epel_hv4_8_c: 152.6
>put_hevc_epel_hv4_8_neon: 34.9
>put_hevc_epel_hv6_8_c: 269.6
>put_hevc_epel_hv6_8_neon: 61.6
>put_hevc_epel_hv8_8_c: 307.4
>put_hevc_epel_hv8_8_neon: 76.9
>put_hevc_epel_hv12_8_c: 702.6
>put_hevc_epel_hv12_8_neon: 113.1
>put_hevc_epel_hv16_8_c: 1081.4
>put_hevc_epel_hv16_8_neon: 190.6
>put_hevc_epel_hv24_8_c: 2276.1
>put_hevc_epel_hv24_8_neon: 345.1
>put_hevc_epel_hv32_8_c: 4068.6
>put_hevc_epel_hv32_8_neon: 780.4
>put_hevc_epel_hv48_8_c: 8754.1
>put_hevc_epel_hv48_8_neon: 1394.4
>put_hevc_epel_hv64_8_c: 15402.1
>put_hevc_epel_hv64_8_neon: 2616.6
>put_hevc_epel_uni_hv4_8_c: 142.1
>put_hevc_epel_uni_hv4_8_neon: 46.6
>put_hevc_epel_uni_hv6_8_c: 298.4
>put_hevc_epel_uni_hv6_8_neon: 72.4
>put_hevc_epel_uni_hv8_8_c: 352.9
>put_hevc_epel_uni_hv8_8_neon: 75.1
>put_hevc_epel_uni_hv12_8_c: 776.6
>put_hevc_epel_uni_hv12_8_neon: 125.9
>put_hevc_epel_uni_hv16_8_c: 1216.1
>put_hevc_epel_uni_hv16_8_neon: 199.1
>put_hevc_epel_uni_hv24_8_c: 2577.9
>put_hevc_epel_uni_hv24_8_neon: 386.6
>put_hevc_epel_uni_hv32_8_c: 4554.9
>put_hevc_epel_uni_hv32_8_neon: 710.9
>put_hevc_epel_uni_hv48_8_c: 9869.1
>put_hevc_epel_uni_hv48_8_neon: 1499.4
>put_hevc_epel_uni_hv64_8_c: 17307.1
>put_hevc_epel_uni_hv64_8_neon: 2750.6
>put_hevc_epel_uni_v4_8_c: 59.9
>put_hevc_epel_uni_v4_8_neon: 21.9
>put_hevc_epel_uni_v6_8_c: 136.1
>put_hevc_epel_uni_v6_8_neon: 19.6
>put_hevc_epel_uni_v8_8_c: 222.4
>put_hevc_epel_uni_v8_8_neon: 17.1
>put_hevc_epel_uni_v12_8_c: 481.6
>put_hevc_epel_uni_v12_8_neon: 42.4
>put_hevc_epel_uni_v16_8_c: 424.4
>put_hevc_epel_uni_v16_8_neon: 63.4
>put_hevc_epel_uni_v24_8_c: 1184.1
>put_hevc_epel_uni_v24_8_neon: 109.9
>put_hevc_epel_uni_v32_8_c: 1401.1
>put_hevc_epel_uni_v32_8_neon: 182.9
>put_hevc_epel_uni_v48_8_c: 2933.9
>put_hevc_epel_uni_v48_8_neon: 388.9
>put_hevc_epel_uni_v64_8_c: 5044.9
>put_hevc_epel_uni_v64_8_neon: 701.1
>put_hevc_epel_v4_8_c: 31.9
>put_hevc_epel_v4_8_neon: 13.4
>put_hevc_epel_v6_8_c: 95.1
>put_hevc_epel_v6_8_neon: 16.4
>put_hevc_epel_v8_8_c: 98.9
>put_hevc_epel_v8_8_neon: 26.1
>put_hevc_epel_v12_8_c: 283.9
>put_hevc_epel_v12_8_neon: 36.9
>put_hevc_epel_v16_8_c: 229.6
>put_hevc_epel_v16_8_neon: 41.9
>put_hevc_epel_v24_8_c: 376.4
>put_hevc_epel_v24_8_neon: 90.4
>put_hevc_epel_v32_8_c: 577.4
>put_hevc_epel_v32_8_neon: 188.4
>put_hevc_epel_v48_8_c: 1058.4
>put_hevc_epel_v48_8_neon: 350.6
>put_hevc_epel_v64_8_c: 1647.4
>put_hevc_epel_v64_8_neon: 647.9
>put_hevc_pel_bi_pixels4

Re: [FFmpeg-devel] [PATCH v3 1/3] avformat/mpegtsenc: Fix mpegts_write_pes() for private_stream_2 and other types

2021-04-28 Thread zheng qian
On Thu, Apr 29, 2021 at 4:40 AM Marton Balint  wrote:
>
> Thanks, applied the series with slightly modified/extended commit
> message based on your earlier commit message.
>
> Regards,
> Marton

Thank you!

Best regards,
zheng
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] fate: add adpcm_ima_ws test in a VQA v3 file

2021-04-28 Thread Zane van Iperen




On 28/4/21 11:19 pm, Zane van Iperen wrote:

Signed-off-by: Zane van Iperen 
---
  tests/fate/adpcm.mak |  3 +++
  tests/ref/fate/adpcm-ima-ws-vqa3 | 18 ++
  2 files changed, 21 insertions(+)
  create mode 100644 tests/ref/fate/adpcm-ima-ws-vqa3



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

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


Re: [FFmpeg-devel] [PATCH 1/4] avformat/mvdec: Check sample rate in parse_audio_var()

2021-04-28 Thread Peter Ross
On Wed, Apr 28, 2021 at 05:06:33PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -63542400238284 * 16 cannot be 
> represented in type 'long'
> Fixes: 
> 33612/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5704741108711424
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/mvdec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
> index 2f72f9eb4f..b1450e08da 100644
> --- a/libavformat/mvdec.c
> +++ b/libavformat/mvdec.c
> @@ -157,6 +157,8 @@ static int parse_audio_var(AVFormatContext *avctx, 
> AVStream *st,
>  return set_channels(avctx, st, var_read_int(pb, size));
>  } else if (!strcmp(name, "SAMPLE_RATE")) {
>  st->codecpar->sample_rate = var_read_int(pb, size);
> +if (st->codecpar->sample_rate <= 0)
> +return AVERROR_INVALIDDATA;
>  avpriv_set_pts_info(st, 33, 1, st->codecpar->sample_rate);
>  } else if (!strcmp(name, "SAMPLE_WIDTH")) {
>  uint64_t bpc = var_read_int(pb, size) * (uint64_t)8;
> -- 
> 2.17.1

please apply

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 1/2] lavu/checkasm: add (private) kperf timing for macOS

2021-04-28 Thread Josh Dekker
Signed-off-by: Josh Dekker 
---
 configure |   2 +
 libavutil/Makefile|   1 +
 libavutil/macos_kperf.c   | 140 ++
 libavutil/macos_kperf.h   |  23 +++
 libavutil/timer.h |  17 -
 tests/checkasm/checkasm.c |  14 +++-
 tests/checkasm/checkasm.h |   7 +-
 7 files changed, 200 insertions(+), 4 deletions(-)
 create mode 100644 libavutil/macos_kperf.c
 create mode 100644 libavutil/macos_kperf.h

diff --git a/configure b/configure
index 820f719a32..a79052ad28 100755
--- a/configure
+++ b/configure
@@ -489,6 +489,7 @@ Developer options (useful when working on FFmpeg itself):
   --ignore-tests=TESTS comma-separated list (without "fate-" prefix
in the name) of tests whose result is ignored
   --enable-linux-perf  enable Linux Performance Monitor API
+  --enable-macos-kperf enable macOS kperf (private) API
   --disable-large-testsdisable tests that use a large amount of memory
 
 NOTE: Object files are built at the place where configure is launched.
@@ -1947,6 +1948,7 @@ CONFIG_LIST="
 fontconfig
 large_tests
 linux_perf
+macos_kperf
 memory_poisoning
 neon_clobber_test
 ossfuzz
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 47efb718d2..18dc5f22d9 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -181,6 +181,7 @@ OBJS-$(CONFIG_D3D11VA)  += 
hwcontext_d3d11va.o
 OBJS-$(CONFIG_DXVA2)+= hwcontext_dxva2.o
 OBJS-$(CONFIG_LIBDRM)   += hwcontext_drm.o
 OBJS-$(CONFIG_LZO)  += lzo.o
+OBJS-$(CONFIG_MACOS_KPERF)  += macos_kperf.o
 OBJS-$(CONFIG_MEDIACODEC)   += hwcontext_mediacodec.o
 OBJS-$(CONFIG_OPENCL)   += hwcontext_opencl.o
 OBJS-$(CONFIG_QSV)  += hwcontext_qsv.o
diff --git a/libavutil/macos_kperf.c b/libavutil/macos_kperf.c
new file mode 100644
index 00..d5de491e12
--- /dev/null
+++ b/libavutil/macos_kperf.c
@@ -0,0 +1,140 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 "macos_kperf.h"
+#include 
+#include 
+#include 
+
+#define KPERF_LIST \
+F(int, kpc_get_counting, void) \
+F(int, kpc_force_all_ctrs_set, int)\
+F(int, kpc_set_counting, uint32_t) \
+F(int, kpc_set_thread_counting, uint32_t)  \
+F(int, kpc_set_config, uint32_t, void *)   \
+F(int, kpc_get_config, uint32_t, void *)   \
+F(int, kpc_set_period, uint32_t, void *)   \
+F(int, kpc_get_period, uint32_t, void *)   \
+F(uint32_t, kpc_get_counter_count, uint32_t)   \
+F(uint32_t, kpc_get_config_count, uint32_t)\
+F(int, kperf_sample_get, int *)\
+F(int, kpc_get_thread_counters, int, unsigned int, void *)
+
+#define F(ret, name, ...)  \
+typedef ret name##proc(__VA_ARGS__);   \
+static name##proc *name = NULL;
+KPERF_LIST
+#undef F
+
+#define CFGWORD_EL0A32EN_MASK (0x1)
+#define CFGWORD_EL0A64EN_MASK (0x2)
+#define CFGWORD_EL1EN_MASK(0x4)
+#define CFGWORD_EL3EN_MASK(0x8)
+#define CFGWORD_ALLMODES_MASK (0xf)
+
+#define CPMU_NONE 0
+#define CPMU_CORE_CYCLE 0x02
+#define CPMU_INST_A64 0x8c
+#define CPMU_INST_BRANCH 0x8d
+#define CPMU_SYNC_DC_LOAD_MISS 0xbf
+#define CPMU_SYNC_DC_STORE_MISS 0xc0
+#define CPMU_SYNC_DTLB_MISS 0xc1
+#define CPMU_SYNC_ST_HIT_YNGR_LD 0xc4
+#define CPMU_SYNC_BR_ANY_MISP 0xcb
+#define CPMU_FED_IC_MISS_DEM 0xd3
+#define CPMU_FED_ITLB_MISS 0xd4
+
+#define KPC_CLASS_FIXED_MASK(1 << 0)
+#define KPC_CLASS_CONFIGURABLE_MASK (1 << 1)
+#define KPC_CLASS_POWER_MASK(1 << 2)
+#define KPC_CLASS_RAWPMU_MASK   (1 << 3)
+
+#define COUNTERS_COUNT 10
+#define CONFIG_COUNT 8
+#define KPC_MASK (KPC_CLASS_CONFIGURABLE_MASK | KPC_CLASS_FIXED_MASK)
+
+int ff_kperf_setup()
+{
+uint64_t config[COUNTERS_COUNT] = {0};
+config[0] = CPMU_CORE_CYCLE | CFGWORD_EL0A64EN_MASK;
+// config[3] = CPMU_INST_BRANCH | CFGWORD_EL0A64EN_MASK;
+/

[FFmpeg-devel] [PATCH 0/2] ARM64 HEVC QPEL/EPEL

2021-04-28 Thread Josh Dekker
This is a patch originally, submitted in 2017 (author/date info left
intact). At the time, it didn't get much attention I assume due to the
sheer size of it. I have split the patch into only its QPEL/EPEL parts,
rebasing, and doing some cleaning of the patches as much is reasonable
for a 9001 line diff. I also have SAO band (non-working) and 32x32 IDCT
(working but honestly in a worse state than these patches).

This patch gives a large overall speedup roughly 30% in my testing. The
only problem is that (as previously stated), 1) it's a lot of code, the
original author didn't make use of macros. 2) it's only 8-bit. I will be
writing 10-bit assembly, and whilst I do that will clean-up/macro-ify
the current 8-bit assembly. Though there is still lots to be done.

Our current IDCTs for HEVC aren't great either, I had a 40% speedup on
the 16x16 one in testing. The assembly is far from 'done' but we're
getting closer slowly at least.

There were some suggestions for smaller improvements in the previous
reviews and I have not applied those. The first course of action is to
refractor it so that it is possible to work on the code without going
insane. I think it's fine to use it whilst I'm working on refractoring
it due to the large speedup: the code-weight in the binary should be
relatively similar even after that anyway.

Also, updated kperf patch as per Lynne's request.

--.
Josh


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

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/mpegtsenc: move is_dvb_subtitle/is_dvb_teletext initialization upwards

2021-04-28 Thread Marton Balint




On Sat, 24 Apr 2021, Marton Balint wrote:


Signed-off-by: Marton Balint 
---
libavformat/mpegtsenc.c | 13 +++--
1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index a357f3a6aa..8ff834be4e 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1300,8 +1300,10 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
MpegTSWrite *ts = s->priv_data;
uint8_t buf[TS_PACKET_SIZE];
uint8_t *q;
-int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, 
is_dvb_teletext, flags;
+int val, is_start, len, header_len, write_pcr, flags;
int afc_len, stuffing_len;
+int is_dvb_subtitle = (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE);
+int is_dvb_teletext = (st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT);
int64_t delay = av_rescale(s->max_delay, 9, AV_TIME_BASE);
int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && 
!ts_st->prev_payload_key;
int force_sdt = 0;
@@ -1412,8 +1414,6 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
*q++ = 0x00;
*q++ = 0x00;
*q++ = 0x01;
-is_dvb_subtitle = 0;
-is_dvb_teletext = 0;
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->codecpar->codec_id == AV_CODEC_ID_DIRAC)
*q++ = STREAM_ID_EXTENDED_STREAM_ID;
@@ -1438,13 +1438,6 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
pts = dts = AV_NOPTS_VALUE;
} else {
*q++ = STREAM_ID_PRIVATE_STREAM_1;
-if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
-if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
-is_dvb_subtitle = 1;
-} else if (st->codecpar->codec_id == 
AV_CODEC_ID_DVB_TELETEXT) {
-is_dvb_teletext = 1;
-}
-}
}
header_len = 0;
flags  = 0;


Applied the series.

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

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


Re: [FFmpeg-devel] [PATCH v3 1/3] avformat/mpegtsenc: Fix mpegts_write_pes() for private_stream_2 and other types

2021-04-28 Thread Marton Balint




On Sun, 25 Apr 2021, zheng qian wrote:


On Sun, Apr 25, 2021 at 2:13 AM Marton Balint  wrote:


The order of the patches seems wrong. Patch/3 (or similar) should be
applied first, otherwise you are checking the stream_id provided via side
data, not the stream id actually used.

Also note that is_dvb_teletext/is_dvb_subtitle might not be set if certain
stream_id is used, that can also cause issues.

I will send a patch series for these two issues, please check them and if
they look good then rebase your patchset on top of that.

You should add the relevant stream type constants to mpegts.h and use
those for the checks, you can spare the comments that way.



I have sent a new patchset v4 for these changes.
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=3833

Notice that I re-sent the 3/4 patch file which seems to be lost,
so please pay attention to the order.


Thanks, applied the series with slightly modified/extended commit 
message based on your earlier commit message.


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

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


Re: [FFmpeg-devel] [PATCH 4/4] avcodec/faxcompr: Check for invalid VLC in decode_group3_1d_line()

2021-04-28 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: infinite loop
> Fixes: 
> 33674/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4816457818046464
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/faxcompr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/faxcompr.c b/libavcodec/faxcompr.c
> index 7bf11d80ca..f1f7e67762 100644
> --- a/libavcodec/faxcompr.c
> +++ b/libavcodec/faxcompr.c
> @@ -213,7 +213,7 @@ static int decode_group3_1d_line(AVCodecContext *avctx, 
> GetBitContext *gb,
>  run += t;
>  if (t < 64) {
>  *runs++ = run;
> -if (runs >= runend) {
> +if (runs >= runend || t < 0) {
>  av_log(avctx, AV_LOG_ERROR, "Run overrun\n");
>  return AVERROR_INVALIDDATA;
>  }
> 
This t is unsigned, so your added check is void. There is btw an else
part here that checks for errors: "} else if ((int)t == -1) {".
The only way I can think of for an infinite loop is that the part after
the end of the get_bits-reader needn't be zeroed and so it can be
mistaken for a valid code and enter the codepath for valid codes; in
particular, it can be a code corresponding to the symbol 0 in which case
one is not saved by the "if (pix_left <= run) {" check. And given that
this code does not use the unchecked bitstream reader, it will never
advance.
So it seems like the best way to fix this is to check for whether there
are any bits left before the get_vlc2() call.

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

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


[FFmpeg-devel] [PATCH 1/4] avformat/mvdec: Check sample rate in parse_audio_var()

2021-04-28 Thread Michael Niedermayer
Fixes: signed integer overflow: -63542400238284 * 16 cannot be represented 
in type 'long'
Fixes: 
33612/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5704741108711424

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

diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
index 2f72f9eb4f..b1450e08da 100644
--- a/libavformat/mvdec.c
+++ b/libavformat/mvdec.c
@@ -157,6 +157,8 @@ static int parse_audio_var(AVFormatContext *avctx, AVStream 
*st,
 return set_channels(avctx, st, var_read_int(pb, size));
 } else if (!strcmp(name, "SAMPLE_RATE")) {
 st->codecpar->sample_rate = var_read_int(pb, size);
+if (st->codecpar->sample_rate <= 0)
+return AVERROR_INVALIDDATA;
 avpriv_set_pts_info(st, 33, 1, st->codecpar->sample_rate);
 } else if (!strcmp(name, "SAMPLE_WIDTH")) {
 uint64_t bpc = var_read_int(pb, size) * (uint64_t)8;
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 2/4] avcodec/utils: do "calc from frame_bytes, channels, and block_align" in 64bit

2021-04-28 Thread Michael Niedermayer
Fixes: signed integer overflow: 104962766 * 32 cannot be represented in type 
'int'
Fixes: 
33614/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-6252129036664832

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/utils.c | 26 +-
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 9cee989098..e5e239fd98 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -733,25 +733,33 @@ static int get_audio_frame_duration(enum AVCodecID id, 
int sr, int ch, int ba,
 if (ba > 0) {
 /* calc from frame_bytes, channels, and block_align */
 int blocks = frame_bytes / ba;
-int64_t tmp;
+int64_t tmp = 0;
 switch (id) {
 case AV_CODEC_ID_ADPCM_IMA_WAV:
 if (bps < 2 || bps > 5)
 return 0;
 tmp = blocks * (1LL + (ba - 4 * ch) / (bps * ch) * 8);
-if (tmp != (int)tmp)
-return 0;
-return tmp;
+break;
 case AV_CODEC_ID_ADPCM_IMA_DK3:
-return blocks * (((ba - 16) * 2 / 3 * 4) / ch);
+tmp = blocks * (((ba - 16LL) * 2 / 3 * 4) / ch);
+break;
 case AV_CODEC_ID_ADPCM_IMA_DK4:
-return blocks * (1 + (ba - 4 * ch) * 2 / ch);
+tmp = blocks * (1 + (ba - 4LL * ch) * 2 / ch);
+break;
 case AV_CODEC_ID_ADPCM_IMA_RAD:
-return blocks * ((ba - 4 * ch) * 2 / ch);
+tmp = blocks * ((ba - 4LL * ch) * 2 / ch);
+break;
 case AV_CODEC_ID_ADPCM_MS:
-return blocks * (2 + (ba - 7 * ch) * 2LL / ch);
+tmp = blocks * (2 + (ba - 7LL * ch) * 2LL / ch);
+break;
 case AV_CODEC_ID_ADPCM_MTAF:
-return blocks * (ba - 16) * 2 / ch;
+tmp = blocks * (ba - 16LL) * 2 / ch;
+break;
+}
+if (tmp) {
+if (tmp != (int)tmp)
+return 0;
+return tmp;
 }
 }
 
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 4/4] avcodec/faxcompr: Check for invalid VLC in decode_group3_1d_line()

2021-04-28 Thread Michael Niedermayer
Fixes: infinite loop
Fixes: 
33674/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4816457818046464

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

diff --git a/libavcodec/faxcompr.c b/libavcodec/faxcompr.c
index 7bf11d80ca..f1f7e67762 100644
--- a/libavcodec/faxcompr.c
+++ b/libavcodec/faxcompr.c
@@ -213,7 +213,7 @@ static int decode_group3_1d_line(AVCodecContext *avctx, 
GetBitContext *gb,
 run += t;
 if (t < 64) {
 *runs++ = run;
-if (runs >= runend) {
+if (runs >= runend || t < 0) {
 av_log(avctx, AV_LOG_ERROR, "Run overrun\n");
 return AVERROR_INVALIDDATA;
 }
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 3/4] avformat/mov: Fix incorrect overflow detection in mov_read_sidx()

2021-04-28 Thread Michael Niedermayer
Fixes: signed integer overflow: 9223372036854775807 + 1442840321 cannot be 
represented in type 'long'
Fixes: 
33670/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6644379491106816

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ca8f06c4cd..0f94abd040 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5080,7 +5080,7 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 if (frag_stream_info)
 frag_stream_info->sidx_pts = timestamp;
 
-if (av_sat_add64(offset, size) != offset + size ||
+if (av_sat_add64(offset, size) != offset + (uint64_t)size ||
 av_sat_add64(pts, duration) != pts + (uint64_t)duration
 )
 return AVERROR_INVALIDDATA;
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH] avcodec/mjpegdec: fix SOF check in EOI

2021-04-28 Thread James Almer
For frames decoded with skip_frame == AVDISCARD_ALL, a picture is not allocated
and got_picture is never set to 1 even if a SOF and SOS were parsed.
The existing check in EOI only cares if a SOF was parsed, not if a picture
allocated, so change it and add a new check to explicitly ensure a picture was
allocated when skip_frame != AVDISCARD_ALL.

Fixes probing and decoding when skip_frame is AVDISCARD_ALL.

Signed-off-by: James Almer 
---
 libavcodec/mjpegdec.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 16aed078f6..c829172200 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2560,11 +2560,16 @@ eoi_parser:
 s->progressive && s->cur_scan && s->got_picture)
 mjpeg_idct_scan_progressive_ac(s);
 s->cur_scan = 0;
-if (!s->got_picture) {
+if (!s->seen_sof) {
 av_log(avctx, AV_LOG_WARNING,
"Found EOI before any SOF, ignoring\n");
 break;
 }
+if (!s->got_picture && avctx->skip_frame != AVDISCARD_ALL) {
+av_log(avctx, AV_LOG_WARNING,
+   "Found EOI before any SOS, ignoring\n");
+break;
+}
 if (s->interlaced) {
 s->bottom_field ^= 1;
 /* if not bottom field, do not output image yet */
-- 
2.31.1

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

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


Re: [FFmpeg-devel] [PATCH 2/4] avcodec/mv30: Check available space in decode_intra() more completly

2021-04-28 Thread Michael Niedermayer
On Thu, Feb 11, 2021 at 10:29:15PM +0100, Paul B Mahol wrote:
> this is hack

what else do you suggest?

thx

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

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] fate: add adpcm_ima_ws test in a VQA v3 file

2021-04-28 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 tests/fate/adpcm.mak |  3 +++
 tests/ref/fate/adpcm-ima-ws-vqa3 | 18 ++
 2 files changed, 21 insertions(+)
 create mode 100644 tests/ref/fate/adpcm-ima-ws-vqa3

diff --git a/tests/fate/adpcm.mak b/tests/fate/adpcm.mak
index f858a808c5..a7d4dbcf6c 100644
--- a/tests/fate/adpcm.mak
+++ b/tests/fate/adpcm.mak
@@ -73,6 +73,9 @@ fate-adpcm-ima_wav-stereo: CMD = md5 -i 
$(TARGET_SAMPLES)/qt-surge-suite/surge-2
 FATE_ADPCM-$(call DEMDEC, WSVQA, ADPCM_IMA_WS) += fate-adpcm-ima-ws
 fate-adpcm-ima-ws: CMD = framecrc -i 
$(TARGET_SAMPLES)/vqa/cc-demo1-partial.vqa -vn
 
+FATE_ADPCM-$(call DEMDEC, WSVQA, ADPCM_IMA_WS) += fate-adpcm-ima-ws-vqa3
+fate-adpcm-ima-ws-vqa3: CMD = framecrc -i 
$(TARGET_SAMPLES)/vqa/small-cut-v3.vqa -vn -af aresample
+
 FATE_ADPCM-$(call DEMDEC, DXA, ADPCM_MS) += fate-adpcm-ms-mono
 fate-adpcm-ms-mono: CMD = framecrc -i $(TARGET_SAMPLES)/dxa/meetsquid.dxa -t 2 
-vn
 
diff --git a/tests/ref/fate/adpcm-ima-ws-vqa3 b/tests/ref/fate/adpcm-ima-ws-vqa3
new file mode 100644
index 00..c2f14cd1a8
--- /dev/null
+++ b/tests/ref/fate/adpcm-ima-ws-vqa3
@@ -0,0 +1,18 @@
+#tb 0: 1/22050
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 22050
+#channel_layout 0: 4
+#channel_layout_name 0: mono
+0,  0,  0, 1470, 2940, 0xca80b853
+0,   1470,   1470, 1470, 2940, 0x250c9f84
+0,   2940,   2940, 1470, 2940, 0x18b3d2d7
+0,   4410,   4410, 1470, 2940, 0xbf8cb0d6
+0,   5880,   5880, 1470, 2940, 0x4ac3b688
+0,   7350,   7350, 1470, 2940, 0x01ebbd5a
+0,   8820,   8820, 1470, 2940, 0x9943817d
+0,  10290,  10290, 1470, 2940, 0x41325eb6
+0,  11760,  11760, 1470, 2940, 0xe447274e
+0,  13230,  13230, 1470, 2940, 0x51ddfa56
+0,  14700,  14700, 1470, 2940, 0x475b058c
+0,  16170,  16170, 1470, 2940, 0xd10e2b54
-- 
2.29.3

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

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


Re: [FFmpeg-devel] [PATCH v3 1/2] avfilter/dnn/dnn_backend_tf: simplify the code with ff_hex_to_data

2021-04-28 Thread lance . lmwang
On Wed, Apr 28, 2021 at 12:26:54PM +, Guo, Yejun wrote:
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > lance.lmw...@gmail.com
> > Sent: 2021年4月28日 18:47
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Limin Wang 
> > Subject: [FFmpeg-devel] [PATCH v3 1/2] avfilter/dnn/dnn_backend_tf:
> > simplify the code with ff_hex_to_data
> > 
> > From: Limin Wang 
> > 
> > please use tools/python/tf_sess_config.py to get the sess_config after that.
> > note the byte order of session config is in normal order.
> > bump the MICRO version for the config change.
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavfilter/dnn/dnn_backend_tf.c | 42 +++--
> >  libavfilter/version.h|  2 +-
> >  tools/python/tf_sess_config.py   | 45
> > 
> >  3 files changed, 54 insertions(+), 35 deletions(-)
> >  create mode 100644 tools/python/tf_sess_config.py
> > 
> > diff --git a/libavfilter/dnn/dnn_backend_tf.c
> > b/libavfilter/dnn/dnn_backend_tf.c
> > index fb799d2..076dd3d 100644
> > --- a/libavfilter/dnn/dnn_backend_tf.c
> > +++ b/libavfilter/dnn/dnn_backend_tf.c
> > @@ -28,6 +28,7 @@
> >  #include "dnn_backend_native_layer_conv2d.h"
> >  #include "dnn_backend_native_layer_depth2space.h"
> >  #include "libavformat/avio.h"
> > +#include "libavformat/internal.h"
> >  #include "libavutil/avassert.h"
> >  #include "../internal.h"
> >  #include "dnn_backend_native_layer_pad.h"
> > @@ -206,53 +207,26 @@ static DNNReturnType load_tf_model(TFModel
> > *tf_model, const char *model_filename
> > 
> >  // prepare the sess config data
> >  if (tf_model->ctx.options.sess_config != NULL) {
> > +const char *config;
> >  /*
> >  tf_model->ctx.options.sess_config is hex to present the serialized
> > proto
> >  required by TF_SetConfig below, so we need to first generate the
> > serialized
> > -proto in a python script, the following is a script example to
> > generate
> > -serialized proto which specifies one GPU, we can change the script
> > to add
> > -more options.
> > -
> > -import tensorflow as tf
> > -gpu_options = tf.GPUOptions(visible_device_list='0')
> > -config = tf.ConfigProto(gpu_options=gpu_options)
> > -s = config.SerializeToString()
> > -b = ''.join("%02x" % int(ord(b)) for b in s[::-1])
> > -print('0x%s' % b)
> > -
> > -the script output looks like: 0xab...cd, and then pass 0xab...cd to
> > sess_config.
> > +proto in a python script, tools/python/tf_sess_config.py is a 
> > script
> > example
> > +to generate the configs of sess_config.
> >  */
> > -char tmp[3];
> > -tmp[2] = '\0';
> > -
> >  if (strncmp(tf_model->ctx.options.sess_config, "0x", 2) != 0) {
> >  av_log(ctx, AV_LOG_ERROR, "sess_config should start with
> > '0x'\n");
> >  return DNN_ERROR;
> >  }
> > +config = tf_model->ctx.options.sess_config + 2;
> > +sess_config_length = ff_hex_to_data(NULL, config);
> > 
> > -sess_config_length = strlen(tf_model->ctx.options.sess_config);
> > -if (sess_config_length % 2 != 0) {
> > -av_log(ctx, AV_LOG_ERROR, "the length of sess_config is not
> > even (%s), "
> > -  "please re-generate the
> > config.\n",
> > -
> > tf_model->ctx.options.sess_config);
> > -return DNN_ERROR;
> > -}
> > -
> > -sess_config_length -= 2; //ignore the first '0x'
> > -sess_config_length /= 2; //get the data length in byte
> > -
> > -sess_config = av_malloc(sess_config_length);
> > +sess_config = av_mallocz(sess_config_length +
> > AV_INPUT_BUFFER_PADDING_SIZE);
> 
> just get a concern, why we need to add PADDING_SIZE here.
> Will there be potential issue if not add?

I just want to make sure it's safe even if the sess_config_length is zero.



> 
> >  if (!sess_config) {
> >  av_log(ctx, AV_LOG_ERROR, "failed to allocate memory\n");
> >  return DNN_ERROR;
> >  }
> > -
> > -for (int i = 0; i < sess_config_length; i++) {
> > -int index = 2 + (sess_config_length - 1 - i) * 2;
> > -tmp[0] = tf_model->ctx.options.sess_config[index];
> > -tmp[1] = tf_model->ctx.options.sess_config[index + 1];
> > -sess_config[i] = strtol(tmp, NULL, 16);
> > -}
> > +ff_hex_to_data(sess_config, config);
> >  }
> > 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

Re: [FFmpeg-devel] [PATCH v3 2/2] doc/filters: Documentation to add sess_config option for tensorflow backend

2021-04-28 Thread lance . lmwang
On Wed, Apr 28, 2021 at 12:31:53PM +, Guo, Yejun wrote:
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > lance.lmw...@gmail.com
> > Sent: 2021年4月28日 18:47
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Limin Wang 
> > Subject: [FFmpeg-devel] [PATCH v3 2/2] doc/filters: Documentation to add
> > sess_config option for tensorflow backend
> > 
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  doc/filters.texi | 14 --
> >  1 file changed, 12 insertions(+), 2 deletions(-)
> > 
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index e99d70a..24f2335 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -10161,6 +10161,9 @@ The label id is considered as name if the label
> > file is not provided.
> >  @item backend_configs
> >  Set the configs to be passed into backend
> > 
> > +For tensorflow backend, you can set its configs with @option{sess_config}
> > options,
> > +please use tools/python/tf_sess_config.py to get the configs
> > +
> >  @item async
> >  use DNN async execution if set (default: set),
> >  roll back to sync execution if the backend does not support async.
> > @@ -10214,6 +10217,9 @@ Set the input name of the dnn network.
> >  @item output
> >  Set the output name of the dnn network.
> > 
> > +For tensorflow backend, you can set its configs with @option{sess_config}
> > options,
> > +please use tools/python/tf_sess_config.py to get the configs
> > +
> >  @item async
> >  use DNN async execution if set (default: set),
> >  roll back to sync execution if the backend does not support async.
> > @@ -10242,9 +10248,10 @@ Handle the Y channel with srcnn.pb (see
> > @ref{sr} filter) for frame with yuv420p
> >  @end example
> > 
> >  @item
> > -Handle the Y channel with espcn.pb (see @ref{sr} filter), which changes
> > frame size, for format yuv420p (planar YUV formats supported):
> > +Handle the Y channel with espcn.pb (see @ref{sr} filter), which changes
> > frame size, for format yuv420p (planar YUV formats supported), please
> > +use tools/python/tf_sess_config.py to get the configs for your system.
> 
> use tools/python/tf_sess_config.py to get the configs of TensorFlow backend 
> for your system.

OK, will update it. Also merge first version change for add backend_configs 
section.

> 
> >  @example
> > -./ffmpeg -i 480p.jpg -vf
> > format=yuv420p,dnn_processing=dnn_backend=tensorflow:model=espcn.pb:
> > input=x:output=y -y tmp.espcn.jpg
> > +./ffmpeg -i 480p.jpg -vf
> > format=yuv420p,dnn_processing=dnn_backend=tensorflow:model=espcn.pb:
> > input=x:output=y:backend_configs=sess_config=0x10022805320e09cdcc
> > ec3f20012a01303801 -y tmp.espcn.jpg
> >  @end example
> > 
> >  @end itemize
> > @@ -18905,6 +18912,9 @@ Note that different backends use different file
> > formats. TensorFlow backend
> >  can load files for both formats, while native backend can load files for 
> > only
> >  its format.
> > 
> > +For tensorflow backend, you can set its configs with @option{sess_config}
> > options,
> > +please use tools/python/tf_sess_config.py to get the configs.
> > +
> 
> this change can be removed since it is under vf.

OK, will remove it.

> 
> >  @item scale_factor
> >  Set scale factor for SRCNN model. Allowed values are @code{2}, @code{3}
> > and @code{4}.
> >  Default value is @code{2}. Scale factor is necessary for SRCNN model,
> > because it accepts
> > --
> > 1.8.3.1
> > 
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > 
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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


Re: [FFmpeg-devel] [PATCH v3 2/2] doc/filters: Documentation to add sess_config option for tensorflow backend

2021-04-28 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> lance.lmw...@gmail.com
> Sent: 2021年4月28日 18:47
> To: ffmpeg-devel@ffmpeg.org
> Cc: Limin Wang 
> Subject: [FFmpeg-devel] [PATCH v3 2/2] doc/filters: Documentation to add
> sess_config option for tensorflow backend
> 
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  doc/filters.texi | 14 --
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index e99d70a..24f2335 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -10161,6 +10161,9 @@ The label id is considered as name if the label
> file is not provided.
>  @item backend_configs
>  Set the configs to be passed into backend
> 
> +For tensorflow backend, you can set its configs with @option{sess_config}
> options,
> +please use tools/python/tf_sess_config.py to get the configs
> +
>  @item async
>  use DNN async execution if set (default: set),
>  roll back to sync execution if the backend does not support async.
> @@ -10214,6 +10217,9 @@ Set the input name of the dnn network.
>  @item output
>  Set the output name of the dnn network.
> 
> +For tensorflow backend, you can set its configs with @option{sess_config}
> options,
> +please use tools/python/tf_sess_config.py to get the configs
> +
>  @item async
>  use DNN async execution if set (default: set),
>  roll back to sync execution if the backend does not support async.
> @@ -10242,9 +10248,10 @@ Handle the Y channel with srcnn.pb (see
> @ref{sr} filter) for frame with yuv420p
>  @end example
> 
>  @item
> -Handle the Y channel with espcn.pb (see @ref{sr} filter), which changes
> frame size, for format yuv420p (planar YUV formats supported):
> +Handle the Y channel with espcn.pb (see @ref{sr} filter), which changes
> frame size, for format yuv420p (planar YUV formats supported), please
> +use tools/python/tf_sess_config.py to get the configs for your system.

use tools/python/tf_sess_config.py to get the configs of TensorFlow backend for 
your system.

>  @example
> -./ffmpeg -i 480p.jpg -vf
> format=yuv420p,dnn_processing=dnn_backend=tensorflow:model=espcn.pb:
> input=x:output=y -y tmp.espcn.jpg
> +./ffmpeg -i 480p.jpg -vf
> format=yuv420p,dnn_processing=dnn_backend=tensorflow:model=espcn.pb:
> input=x:output=y:backend_configs=sess_config=0x10022805320e09cdcc
> ec3f20012a01303801 -y tmp.espcn.jpg
>  @end example
> 
>  @end itemize
> @@ -18905,6 +18912,9 @@ Note that different backends use different file
> formats. TensorFlow backend
>  can load files for both formats, while native backend can load files for only
>  its format.
> 
> +For tensorflow backend, you can set its configs with @option{sess_config}
> options,
> +please use tools/python/tf_sess_config.py to get the configs.
> +

this change can be removed since it is under vf.

>  @item scale_factor
>  Set scale factor for SRCNN model. Allowed values are @code{2}, @code{3}
> and @code{4}.
>  Default value is @code{2}. Scale factor is necessary for SRCNN model,
> because it accepts
> --
> 1.8.3.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v3 1/2] avfilter/dnn/dnn_backend_tf: simplify the code with ff_hex_to_data

2021-04-28 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> lance.lmw...@gmail.com
> Sent: 2021年4月28日 18:47
> To: ffmpeg-devel@ffmpeg.org
> Cc: Limin Wang 
> Subject: [FFmpeg-devel] [PATCH v3 1/2] avfilter/dnn/dnn_backend_tf:
> simplify the code with ff_hex_to_data
> 
> From: Limin Wang 
> 
> please use tools/python/tf_sess_config.py to get the sess_config after that.
> note the byte order of session config is in normal order.
> bump the MICRO version for the config change.
> 
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/dnn/dnn_backend_tf.c | 42 +++--
>  libavfilter/version.h|  2 +-
>  tools/python/tf_sess_config.py   | 45
> 
>  3 files changed, 54 insertions(+), 35 deletions(-)
>  create mode 100644 tools/python/tf_sess_config.py
> 
> diff --git a/libavfilter/dnn/dnn_backend_tf.c
> b/libavfilter/dnn/dnn_backend_tf.c
> index fb799d2..076dd3d 100644
> --- a/libavfilter/dnn/dnn_backend_tf.c
> +++ b/libavfilter/dnn/dnn_backend_tf.c
> @@ -28,6 +28,7 @@
>  #include "dnn_backend_native_layer_conv2d.h"
>  #include "dnn_backend_native_layer_depth2space.h"
>  #include "libavformat/avio.h"
> +#include "libavformat/internal.h"
>  #include "libavutil/avassert.h"
>  #include "../internal.h"
>  #include "dnn_backend_native_layer_pad.h"
> @@ -206,53 +207,26 @@ static DNNReturnType load_tf_model(TFModel
> *tf_model, const char *model_filename
> 
>  // prepare the sess config data
>  if (tf_model->ctx.options.sess_config != NULL) {
> +const char *config;
>  /*
>  tf_model->ctx.options.sess_config is hex to present the serialized
> proto
>  required by TF_SetConfig below, so we need to first generate the
> serialized
> -proto in a python script, the following is a script example to
> generate
> -serialized proto which specifies one GPU, we can change the script
> to add
> -more options.
> -
> -import tensorflow as tf
> -gpu_options = tf.GPUOptions(visible_device_list='0')
> -config = tf.ConfigProto(gpu_options=gpu_options)
> -s = config.SerializeToString()
> -b = ''.join("%02x" % int(ord(b)) for b in s[::-1])
> -print('0x%s' % b)
> -
> -the script output looks like: 0xab...cd, and then pass 0xab...cd to
> sess_config.
> +proto in a python script, tools/python/tf_sess_config.py is a script
> example
> +to generate the configs of sess_config.
>  */
> -char tmp[3];
> -tmp[2] = '\0';
> -
>  if (strncmp(tf_model->ctx.options.sess_config, "0x", 2) != 0) {
>  av_log(ctx, AV_LOG_ERROR, "sess_config should start with
> '0x'\n");
>  return DNN_ERROR;
>  }
> +config = tf_model->ctx.options.sess_config + 2;
> +sess_config_length = ff_hex_to_data(NULL, config);
> 
> -sess_config_length = strlen(tf_model->ctx.options.sess_config);
> -if (sess_config_length % 2 != 0) {
> -av_log(ctx, AV_LOG_ERROR, "the length of sess_config is not
> even (%s), "
> -  "please re-generate the
> config.\n",
> -
> tf_model->ctx.options.sess_config);
> -return DNN_ERROR;
> -}
> -
> -sess_config_length -= 2; //ignore the first '0x'
> -sess_config_length /= 2; //get the data length in byte
> -
> -sess_config = av_malloc(sess_config_length);
> +sess_config = av_mallocz(sess_config_length +
> AV_INPUT_BUFFER_PADDING_SIZE);

just get a concern, why we need to add PADDING_SIZE here.
Will there be potential issue if not add?

>  if (!sess_config) {
>  av_log(ctx, AV_LOG_ERROR, "failed to allocate memory\n");
>  return DNN_ERROR;
>  }
> -
> -for (int i = 0; i < sess_config_length; i++) {
> -int index = 2 + (sess_config_length - 1 - i) * 2;
> -tmp[0] = tf_model->ctx.options.sess_config[index];
> -tmp[1] = tf_model->ctx.options.sess_config[index + 1];
> -sess_config[i] = strtol(tmp, NULL, 16);
> -}
> +ff_hex_to_data(sess_config, config);
>  }
> 

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

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


[FFmpeg-devel] [PATCH v3 2/2] doc/filters: Documentation to add sess_config option for tensorflow backend

2021-04-28 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/filters.texi | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index e99d70a..24f2335 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10161,6 +10161,9 @@ The label id is considered as name if the label file is 
not provided.
 @item backend_configs
 Set the configs to be passed into backend
 
+For tensorflow backend, you can set its configs with @option{sess_config} 
options,
+please use tools/python/tf_sess_config.py to get the configs
+
 @item async
 use DNN async execution if set (default: set),
 roll back to sync execution if the backend does not support async.
@@ -10214,6 +10217,9 @@ Set the input name of the dnn network.
 @item output
 Set the output name of the dnn network.
 
+For tensorflow backend, you can set its configs with @option{sess_config} 
options,
+please use tools/python/tf_sess_config.py to get the configs
+
 @item async
 use DNN async execution if set (default: set),
 roll back to sync execution if the backend does not support async.
@@ -10242,9 +10248,10 @@ Handle the Y channel with srcnn.pb (see @ref{sr} 
filter) for frame with yuv420p
 @end example
 
 @item
-Handle the Y channel with espcn.pb (see @ref{sr} filter), which changes frame 
size, for format yuv420p (planar YUV formats supported):
+Handle the Y channel with espcn.pb (see @ref{sr} filter), which changes frame 
size, for format yuv420p (planar YUV formats supported), please
+use tools/python/tf_sess_config.py to get the configs for your system.
 @example
-./ffmpeg -i 480p.jpg -vf 
format=yuv420p,dnn_processing=dnn_backend=tensorflow:model=espcn.pb:input=x:output=y
 -y tmp.espcn.jpg
+./ffmpeg -i 480p.jpg -vf 
format=yuv420p,dnn_processing=dnn_backend=tensorflow:model=espcn.pb:input=x:output=y:backend_configs=sess_config=0x10022805320e09cdccec3f20012a01303801
 -y tmp.espcn.jpg
 @end example
 
 @end itemize
@@ -18905,6 +18912,9 @@ Note that different backends use different file 
formats. TensorFlow backend
 can load files for both formats, while native backend can load files for only
 its format.
 
+For tensorflow backend, you can set its configs with @option{sess_config} 
options,
+please use tools/python/tf_sess_config.py to get the configs.
+
 @item scale_factor
 Set scale factor for SRCNN model. Allowed values are @code{2}, @code{3} and 
@code{4}.
 Default value is @code{2}. Scale factor is necessary for SRCNN model, because 
it accepts
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v3 1/2] avfilter/dnn/dnn_backend_tf: simplify the code with ff_hex_to_data

2021-04-28 Thread lance . lmwang
From: Limin Wang 

please use tools/python/tf_sess_config.py to get the sess_config after that.
note the byte order of session config is in normal order.
bump the MICRO version for the config change.

Signed-off-by: Limin Wang 
---
 libavfilter/dnn/dnn_backend_tf.c | 42 +++--
 libavfilter/version.h|  2 +-
 tools/python/tf_sess_config.py   | 45 
 3 files changed, 54 insertions(+), 35 deletions(-)
 create mode 100644 tools/python/tf_sess_config.py

diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index fb799d2..076dd3d 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -28,6 +28,7 @@
 #include "dnn_backend_native_layer_conv2d.h"
 #include "dnn_backend_native_layer_depth2space.h"
 #include "libavformat/avio.h"
+#include "libavformat/internal.h"
 #include "libavutil/avassert.h"
 #include "../internal.h"
 #include "dnn_backend_native_layer_pad.h"
@@ -206,53 +207,26 @@ static DNNReturnType load_tf_model(TFModel *tf_model, 
const char *model_filename
 
 // prepare the sess config data
 if (tf_model->ctx.options.sess_config != NULL) {
+const char *config;
 /*
 tf_model->ctx.options.sess_config is hex to present the serialized 
proto
 required by TF_SetConfig below, so we need to first generate the 
serialized
-proto in a python script, the following is a script example to generate
-serialized proto which specifies one GPU, we can change the script to 
add
-more options.
-
-import tensorflow as tf
-gpu_options = tf.GPUOptions(visible_device_list='0')
-config = tf.ConfigProto(gpu_options=gpu_options)
-s = config.SerializeToString()
-b = ''.join("%02x" % int(ord(b)) for b in s[::-1])
-print('0x%s' % b)
-
-the script output looks like: 0xab...cd, and then pass 0xab...cd to 
sess_config.
+proto in a python script, tools/python/tf_sess_config.py is a script 
example
+to generate the configs of sess_config.
 */
-char tmp[3];
-tmp[2] = '\0';
-
 if (strncmp(tf_model->ctx.options.sess_config, "0x", 2) != 0) {
 av_log(ctx, AV_LOG_ERROR, "sess_config should start with '0x'\n");
 return DNN_ERROR;
 }
+config = tf_model->ctx.options.sess_config + 2;
+sess_config_length = ff_hex_to_data(NULL, config);
 
-sess_config_length = strlen(tf_model->ctx.options.sess_config);
-if (sess_config_length % 2 != 0) {
-av_log(ctx, AV_LOG_ERROR, "the length of sess_config is not even 
(%s), "
-  "please re-generate the config.\n",
-  tf_model->ctx.options.sess_config);
-return DNN_ERROR;
-}
-
-sess_config_length -= 2; //ignore the first '0x'
-sess_config_length /= 2; //get the data length in byte
-
-sess_config = av_malloc(sess_config_length);
+sess_config = av_mallocz(sess_config_length + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!sess_config) {
 av_log(ctx, AV_LOG_ERROR, "failed to allocate memory\n");
 return DNN_ERROR;
 }
-
-for (int i = 0; i < sess_config_length; i++) {
-int index = 2 + (sess_config_length - 1 - i) * 2;
-tmp[0] = tf_model->ctx.options.sess_config[index];
-tmp[1] = tf_model->ctx.options.sess_config[index + 1];
-sess_config[i] = strtol(tmp, NULL, 16);
-}
+ff_hex_to_data(sess_config, config);
 }
 
 graph_def = read_graph(model_filename);
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 4325551..f12bc87 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR   8
 #define LIBAVFILTER_VERSION_MINOR   0
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/tools/python/tf_sess_config.py b/tools/python/tf_sess_config.py
new file mode 100644
index 000..5705b1a
--- /dev/null
+++ b/tools/python/tf_sess_config.py
@@ -0,0 +1,45 @@
+# Copyright (c) 2021
+#
+# 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 Softwar

Re: [FFmpeg-devel] [PATCH v3 2/5] avcodec/mips: Refine get_cabac_inline_mips.

2021-04-28 Thread 殷时友


> 2021年4月12日 下午11:59,殷时友  写道:
> 
> 
>> 2021年3月31日 下午10:39,Michael Niedermayer  写道:
>> 
>> On Tue, Mar 30, 2021 at 08:51:52PM +0800, Shiyou Yin wrote:
>>> 1. Refined function get_cabac_inline_mips.
>>> 2. Optimize function get_cabac_bypass and get_cabac_bypass_sign.
>>> 
>>> Speed of decoding h264: 4.89x ==> 5.05x(tested on 3A4000).
>>> ---
>>> libavcodec/mips/cabac.h | 131 
>>> +---
>>> 1 file changed, 102 insertions(+), 29 deletions(-)
>> 
>> This breaks fate with qemu mips
>> 
>> --- ffmpeg/tests/ref/fate/hevc-cabac-tudepth 2021-03-26 18:34:55.142789579 
>> +0100
>> +++ tests/data/fate/hevc-cabac-tudepth   2021-03-31 16:36:50.613173111 
>> +0200
>> @@ -3,4 +3,4 @@
>> #codec_id 0: rawvideo
>> #dimensions 0: 64x64
>> #sar 0: 0/1
>> -0,  0,  0,1,12288, 0x0127a0d9
>> +0,  0,  0,1,12288, 0xa330b3bd
>> Test hevc-cabac-tudepth failed. Look at 
>> tests/data/fate/hevc-cabac-tudepth.err for details.
>> ffmpeg/tests/Makefile:255: recipe for target 'fate-hevc-cabac-tudepth' failed
>> make: *** [fate-hevc-cabac-tudepth] Error 1
>> 
> 
> This bug is caused by using ‘lhu’ to load two byte date on bigendian 
> environment. Has been fixed in V4.  
> Please help  to merge them.
> 
> BTW, I found another failed case ‘fate-sub2video_time_limited’  when testing 
> origin/master
> with cross compiler mips-linux-gnu-gcc-8 on debian10-x64 and run fate  with 
> qemu-mips.
> I will try to analyze it later.
> 
> My configuration: --samples=../../fate-suite/ 
> --target-exec='/usr/bin/qemu-mips -cpu 74Kf -L /usr/mips-linux-gnu/' 
> --cross-prefix=/usr/mips-linux-gnu/bin/ --cc=mips-linux-gnu-gcc-8 --arch=mips 
> --target-os=linux --optflags='-O3 -g -static' --extra-ldflags=‘-static' 
> --enable-cross-compile --enable-static --enable-gpl --disable-pthreads 
> --disable-iconv --disable-mipsfpu
> 
> TESTsub2video_time_limited
> --- src/tests/ref/fate/sub2video_time_limited 2021-04-10 11:53:37.661350105 
> +0800
> +++ tests/data/fate/sub2video_time_limited2021-04-12 23:18:29.355527385 
> +0800
> @@ -4,5 +4,5 @@
> #dimensions 0: 1920x1080
> #sar 0: 0/1
> 0,  2,  2,1,  8294400, 0x
> -0,  2,  2,1,  8294400, 0xa87c518f
> -0, 10, 10,1,  8294400, 0xa87c518f
> +0,  2,  2,1,  8294400, 0xea5a518f
> +0, 10, 10,1,  8294400, 0xea5a518f
> Test sub2video_time_limited failed. Look at 
> tests/data/fate/sub2video_time_limited.err for details.
> make: *** [src/tests/Makefile:256:fate-sub2video_time_limited] 错误 1
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe”.

Hello, Michael
Can fate-sub2video_time_limited pass on your mips qemu before? I doubt if it’s 
qemu’s problem.
I build latest master branch without my patch set and disabled all asm code, 
then run fate test in qemu-mips which download from debian10 repository. 

../ffmpeg/configure --samples=../../fate-suite/ 
--target-exec='/usr/bin/qemu-mips -cpu 74Kf -L /usr/mips-linux-gnu/' 
--cross-prefix=/usr/mips-linux-gnu/bin/ --cc=mips-linux-gnu-gcc-8 --arch=mips 
--target-os=linux --optflags='-O3 -g -static' --extra-ldflags=-static 
--enable-cross-compile --enable-static --enable-gpl --disable-mipsfpu 
--disable-iconv --disable-pthreads  --disable-asm --cpu=74kf
make fate-sub2video_time_limited

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

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


[FFmpeg-devel] [PATCH] libswscale: Make sws_init_context thread safe.

2021-04-28 Thread Peter Lundblad
Call ff_sws_rgb2rgb_init via ff_thread_once instead of checking one of the
variables it updates.
---
 libswscale/utils.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libswscale/utils.c b/libswscale/utils.c
index 6bac7b658d..d673209d95 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -49,6 +49,7 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/thread.h"
 #include "libavutil/aarch64/cpu.h"
 #include "libavutil/ppc/cpu.h"
 #include "libavutil/x86/asm.h"
@@ -1189,12 +1190,13 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter 
*srcFilter,
 int ret = 0;
 enum AVPixelFormat tmpFmt;
 static const float float_mult = 1.0f / 255.0f;
+static AVOnce rgb2rgb_once = AV_ONCE_INIT;
 
 cpu_flags = av_get_cpu_flags();
 flags = c->flags;
 emms_c();
-if (!rgb15to16)
-ff_sws_rgb2rgb_init();
+if (ff_thread_once(&rgb2rgb_once, ff_sws_rgb2rgb_init) != 0)
+return AVERROR_UNKNOWN;
 
 unscaled = (srcW == dstW && srcH == dstH);
 
-- 
2.31.1.527.g47e6f16901-goog

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

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


[FFmpeg-devel] [PATCH] ignore additional generated tools files

2021-04-28 Thread Brad Hards
---
 tools/.gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/.gitignore b/tools/.gitignore
index c0958f40cb..61512261a7 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -3,6 +3,7 @@
 /bisect.need
 /crypto_bench
 /cws2fws
+/enum_options
 /fourcc2pixfmt
 /ffescape
 /ffeval
@@ -16,4 +17,5 @@
 /trasher
 /seek_print
 /uncoded_frame
+/venc_data_dump
 /zmqsend
-- 
2.27.0

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

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


Re: [FFmpeg-devel] [PATCH 2/4] avformat/rpl: Use 64bit in bitrate computation and check it

2021-04-28 Thread Michael Niedermayer
On Tue, Apr 27, 2021 at 09:31:56PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: signed integer overflow: 6 * 4 cannot be represented in type 
> > 'int'
> > Fixes: 
> > 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_RPL_fuzzer-6726188921913344
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/rpl.c | 6 --
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/rpl.c b/libavformat/rpl.c
> > index b98488c7b1..558e5718ba 100644
> > --- a/libavformat/rpl.c
> > +++ b/libavformat/rpl.c
> > @@ -207,8 +207,10 @@ static int rpl_read_header(AVFormatContext *s)
> >  ast->codecpar->bits_per_coded_sample = 4;
> >  
> >  ast->codecpar->bit_rate = ast->codecpar->sample_rate *
> > -  ast->codecpar->bits_per_coded_sample *
> > -  ast->codecpar->channels;
> > +  
> > (int64_t)ast->codecpar->bits_per_coded_sample;
> > +if (ast->codecpar->bit_rate > INT64_MAX / ast->codecpar->channels)
> > +return AVERROR_INVALIDDATA;
> > +ast->codecpar->bit_rate *= ast->codecpar->channels;
> >  
> >  ast->codecpar->codec_id = AV_CODEC_ID_NONE;
> >  switch (audio_format) {
> > 
> read_line_and_int() can return zero and so you must not divide by
> channels. (Something like __builtin_smulll_overflow() might be
> advantageous here.)

hmm, i saw bits_per_coded_sample cant be 0 and wanted to use that
but clearly i didnt, fascinating.
will switch channels out with bits_per_coded_sample

thx

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

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] libavutil: additional side_data accessor

2021-04-28 Thread Brad Hards
Ping. Anything more required on this patch?

Brad


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

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


Re: [FFmpeg-devel] [PATCH 24/34] avcodec/zmbvenc: Avoid copying packet data

2021-04-28 Thread Tomas Härdin
mån 2021-04-26 klockan 00:34 +0200 skrev Andreas Rheinhardt:
> Here the packet size is known before allocating the packet because
> the encoder itself works with an internal buffer, so one can pass
> this information to ff_alloc_packet2() to avoid the implicit use
> of another intermediate buffer for the packet data.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/zmbvenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
> index 4b3416219b..8933d06ede 100644
> --- a/libavcodec/zmbvenc.c
> +++ b/libavcodec/zmbvenc.c
> @@ -281,7 +281,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  }
>  
>  pkt_size = c->zstream.total_out + 1 + 6*keyframe;
> -if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0)
> +if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, pkt_size)) <
> 0)

Looks correct

/Tomas

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

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


Re: [FFmpeg-devel] [PATCH 23/34] avcodec/zmbvenc: Simplify setting keyframe flag

2021-04-28 Thread Tomas Härdin
mån 2021-04-26 klockan 00:34 +0200 skrev Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/zmbvenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
> index 319381dd48..4b3416219b 100644
> --- a/libavcodec/zmbvenc.c
> +++ b/libavcodec/zmbvenc.c
> @@ -294,10 +294,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  *buf++ = c->fmt; // format
>  *buf++ = ZMBV_BLOCK; // block width
>  *buf++ = ZMBV_BLOCK; // block height
> +pkt->flags |= AV_PKT_FLAG_KEY;
>  }
>  memcpy(buf, c->comp_buf, c->zstream.total_out);
>  
> -pkt->flags |= AV_PKT_FLAG_KEY*keyframe;

Looks OK

/Tomas

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

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