[FFmpeg-devel] [PATCH v2] lsws/ppc/yuv2rgb_altivec: Fix build in non-VSX environments with Clang

2023-08-18 Thread Brad Smith
lsws/ppc/yuv2rgb_altivec: Fix build in non-VSX environments with Clang

Add a check for the existence of the vec_xl() function. Clang provides
the function even with VSX not enabled.

v2: test for function if AltiVec is enabled instead of with AltiVec and without 
VSX
---
 configure| 8 
 libswscale/ppc/yuv2rgb_altivec.c | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index ff6a5c3600..637034e87d 100755
--- a/configure
+++ b/configure
@@ -2154,6 +2154,7 @@ ARCH_EXT_LIST_PPC="
 ldbrx
 power8
 ppc4xx
+vec_xl
 vsx
 "
 
@@ -2679,6 +2680,7 @@ altivec_deps="ppc"
 dcbzl_deps="ppc"
 ldbrx_deps="ppc"
 ppc4xx_deps="ppc"
+vec_xl_deps="altivec"
 vsx_deps="altivec"
 power8_deps="vsx"
 
@@ -6221,6 +6223,11 @@ elif enabled ppc; then
 check_cpp_condition power8 "altivec.h" "defined(_ARCH_PWR8)"
 fi
 
+if enabled altivec; then
+check_cc vec_xl altivec.h "const unsigned char *y1i = { 0 };
+vector unsigned char y0 = vec_xl(0, y1i);"
+fi
+
 elif enabled riscv; then
 
 enabled rvv && check_inline_asm rvv '".option arch, +v\nvsetivli zero, 0, 
e8, m1, ta, ma"'
@@ -7731,6 +7738,7 @@ if enabled ppc; then
 echo "POWER8 enabled${power8-no}"
 echo "PPC 4xx optimizations ${ppc4xx-no}"
 echo "dcbzl available   ${dcbzl-no}"
+echo "vec_xl available  ${vec_xl-no}"
 fi
 if enabled loongarch; then
 echo "LSX enabled   ${lsx-no}"
diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
index 5e1033a973..8b0a93796f 100644
--- a/libswscale/ppc/yuv2rgb_altivec.c
+++ b/libswscale/ppc/yuv2rgb_altivec.c
@@ -284,7 +284,7 @@ static inline void cvtyuvtoRGB(SwsContext *c, vector signed 
short Y,
  * 
--
  */
 
-#if !HAVE_VSX
+#if !HAVE_VEC_XL
 static inline vector unsigned char vec_xl(signed long long offset, const ubyte 
*addr)
 {
 const vector unsigned char *v_addr = (const vector unsigned char *) (addr 
+ offset);
@@ -292,7 +292,7 @@ static inline vector unsigned char vec_xl(signed long long 
offset, const ubyte *
 
 return (vector unsigned char) vec_perm(v_addr[0], v_addr[1], align_perm);
 }
-#endif /* !HAVE_VSX */
+#endif /* !HAVE_VEC_XL */
 
 #define DEFCSP420_CVT(name, out_pixels)   \
 static int altivec_ ## name(SwsContext *c, const unsigned char **in,  \
-- 
2.41.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] looking to hire expert for a short project: lossless screen and sound capture 4k@60hz

2023-08-18 Thread Misha Aizatulin



   Interesting - I haven't tried .kkapture because I thought that it only works for demos that are 
using the API as of when the tool was created - which means a lot of the newer demos won't work with 
it. But maybe I'm wrong? I'll poke around.


  Indeed. I tried running kkapture on a demo from 2005 and it worked fine, but a more recent demo 
fails with "startup instrumentation failed".

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

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


Re: [FFmpeg-devel] [PATCH v2] avutil/thread: add wrappers for pthread_cond_t and pthread_t functions

2023-08-18 Thread James Almer

On 8/18/2023 5:16 PM, Michael Niedermayer wrote:

On Fri, Aug 18, 2023 at 01:14:27PM -0300, James Almer wrote:

Signed-off-by: James Almer 
---
Now not defining pthread_t when !HAVE_THREADS, like it's done with cond, mutex,
and once.

  libavutil/thread.h | 30 ++
  1 file changed, 30 insertions(+)


this seems not to build on ppc
AVMutex use before definition

make
AR  libavdevice/libavdevice.a
CC  libavfilter/dnn/dnn_backend_common.o
In file included from src/libavfilter/dnn/dnn_backend_common.h:29:0,
  from src/libavfilter/dnn/dnn_backend_common.c:24:
src/libavutil/thread.h:193:46: error: unknown type name ‘AVMutex’; did you mean 
‘AVFilter’?
  static inline int ff_cond_wait(AVCond *cond, AVMutex *mutex){ return 0; }
   ^~~
   AVFilter
src/libavutil/thread.h:194:51: error: unknown type name ‘AVMutex’; did you mean 
‘AVFilter’?
  static inline int ff_cond_timedwait(AVCond *cond, AVMutex *mutex,
^~~
AVFilter
src/libavfilter/dnn/dnn_backend_common.c: In function 
‘ff_dnn_async_module_cleanup’:
src/libavfilter/dnn/dnn_backend_common.c:94:11: warning: unused variable 
‘status’ [-Wunused-variable]
  void *status = 0;
^~
src/libavfilter/dnn/dnn_backend_common.c: In function 
‘ff_dnn_start_inference_async’:
src/libavfilter/dnn/dnn_backend_common.c:114:11: warning: unused variable 
‘status’ [-Wunused-variable]
  void *status = 0;
^~
At top level:
src/libavfilter/dnn/dnn_backend_common.c:80:14: warning: ‘async_thread_routine’ 
defined but not used [-Wunused-function]
  static void *async_thread_routine(void *args)
   ^~~~
src/ffbuild/common.mak:81: recipe for target 
'libavfilter/dnn/dnn_backend_common.o' failed
make: *** [libavfilter/dnn/dnn_backend_common.o] Error 1


Should be fixed in v3.
___
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] avutil/thread: add wrappers for pthread_cond_t and pthread_t functions

2023-08-18 Thread James Almer
Signed-off-by: James Almer 
---
 libavutil/thread.h | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/libavutil/thread.h b/libavutil/thread.h
index 2f5e7e1cb5..f67b0cdc44 100644
--- a/libavutil/thread.h
+++ b/libavutil/thread.h
@@ -163,11 +163,25 @@ static inline int strict_pthread_once(pthread_once_t 
*once_control, void (*init_
 #define ff_mutex_unlock  pthread_mutex_unlock
 #define ff_mutex_destroy pthread_mutex_destroy
 
+#define AVCond pthread_cond_t
+
+#define ff_cond_init  pthread_cond_init
+#define ff_cond_destroy   pthread_cond_destroy
+#define ff_cond_signalpthread_cond_signal
+#define ff_cond_broadcast pthread_cond_broadcast
+#define ff_cond_wait  pthread_cond_wait
+#define ff_cond_timedwait pthread_cond_timedwait
+
 #define AVOnce pthread_once_t
 #define AV_ONCE_INIT PTHREAD_ONCE_INIT
 
 #define ff_thread_once(control, routine) pthread_once(control, routine)
 
+#define AVThread pthread_t
+
+#define ff_thread_create pthread_create
+#define ff_thread_join   pthread_join
+
 #else
 
 #define AVMutex char
@@ -178,6 +192,16 @@ static inline int ff_mutex_lock(AVMutex *mutex){ return 0; 
}
 static inline int ff_mutex_unlock(AVMutex *mutex){ return 0; }
 static inline int ff_mutex_destroy(AVMutex *mutex){ return 0; }
 
+#define AVCond char
+
+static inline int ff_cond_init(AVCond *cond, const void *attr){ return 0; }
+static inline int ff_cond_destroy(AVCond *cond){ return 0; }
+static inline int ff_cond_signal(AVCond *cond){ return 0; }
+static inline int ff_cond_broadcast(AVCond *cond){ return 0; }
+static inline int ff_cond_wait(AVCond *cond, AVMutex *mutex){ return 0; }
+static inline int ff_cond_timedwait(AVCond *cond, AVMutex *mutex,
+const void *abstime){ return 0; }
+
 #define AVOnce char
 #define AV_ONCE_INIT 0
 
@@ -190,6 +214,12 @@ static inline int ff_thread_once(char *control, void 
(*routine)(void))
 return 0;
 }
 
+#define AVThread char
+
+static inline int ff_thread_create(AVThread *thread, const void *unused_attr,
+   void *(*start_routine)(void*), void *arg){ 
return 0; }
+static inline int ff_thread_join(AVThread thread, void **value_ptr){ return 0; 
}
+
 #endif
 
 static inline int ff_thread_setname(const char *name)
-- 
2.41.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 v2] avutil/thread: add wrappers for pthread_cond_t and pthread_t functions

2023-08-18 Thread Michael Niedermayer
On Fri, Aug 18, 2023 at 01:14:27PM -0300, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> Now not defining pthread_t when !HAVE_THREADS, like it's done with cond, 
> mutex,
> and once.
> 
>  libavutil/thread.h | 30 ++
>  1 file changed, 30 insertions(+)

this seems not to build on ppc
AVMutex use before definition

make
AR  libavdevice/libavdevice.a
CC  libavfilter/dnn/dnn_backend_common.o
In file included from src/libavfilter/dnn/dnn_backend_common.h:29:0,
 from src/libavfilter/dnn/dnn_backend_common.c:24:
src/libavutil/thread.h:193:46: error: unknown type name ‘AVMutex’; did you mean 
‘AVFilter’?
 static inline int ff_cond_wait(AVCond *cond, AVMutex *mutex){ return 0; }
  ^~~
  AVFilter
src/libavutil/thread.h:194:51: error: unknown type name ‘AVMutex’; did you mean 
‘AVFilter’?
 static inline int ff_cond_timedwait(AVCond *cond, AVMutex *mutex,
   ^~~
   AVFilter
src/libavfilter/dnn/dnn_backend_common.c: In function 
‘ff_dnn_async_module_cleanup’:
src/libavfilter/dnn/dnn_backend_common.c:94:11: warning: unused variable 
‘status’ [-Wunused-variable]
 void *status = 0;
   ^~
src/libavfilter/dnn/dnn_backend_common.c: In function 
‘ff_dnn_start_inference_async’:
src/libavfilter/dnn/dnn_backend_common.c:114:11: warning: unused variable 
‘status’ [-Wunused-variable]
 void *status = 0;
   ^~
At top level:
src/libavfilter/dnn/dnn_backend_common.c:80:14: warning: ‘async_thread_routine’ 
defined but not used [-Wunused-function]
 static void *async_thread_routine(void *args)
  ^~~~
src/ffbuild/common.mak:81: recipe for target 
'libavfilter/dnn/dnn_backend_common.o' failed
make: *** [libavfilter/dnn/dnn_backend_common.o] Error 1



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

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


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] lsws/ppc/yuv2rgb_altivec: Fix build in non-VSX environments with Clang

2023-08-18 Thread Brad Smith
lsws/ppc/yuv2rgb_altivec: Fix build in non-VSX environments with Clang

Add a check for the existence of the vec_xl() function. Clang provides
the function even with VSX not enabled.
---
 configure| 8 
 libswscale/ppc/yuv2rgb_altivec.c | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 932998b8d6..268435fbdb 100755
--- a/configure
+++ b/configure
@@ -2154,6 +2154,7 @@ ARCH_EXT_LIST_PPC="
 ldbrx
 power8
 ppc4xx
+vec_xl
 vsx
 "
 
@@ -2679,6 +2680,7 @@ altivec_deps="ppc"
 dcbzl_deps="ppc"
 ldbrx_deps="ppc"
 ppc4xx_deps="ppc"
+vec_xl_deps="altivec"
 vsx_deps="altivec"
 power8_deps="vsx"
 
@@ -6218,6 +6220,11 @@ elif enabled ppc; then
 check_cpp_condition power8 "altivec.h" "defined(_ARCH_PWR8)"
 fi
 
+if enabled altivec && disabled vsx; then
+check_cc vec_xl altivec.h "const unsigned char *y1i = { 0 };
+vector unsigned char y0 = vec_xl(0, y1i);"
+fi
+
 elif enabled riscv; then
 
 enabled rvv && check_inline_asm rvv '".option arch, +v\nvsetivli zero, 0, 
e8, m1, ta, ma"'
@@ -7728,6 +7735,7 @@ if enabled ppc; then
 echo "POWER8 enabled${power8-no}"
 echo "PPC 4xx optimizations ${ppc4xx-no}"
 echo "dcbzl available   ${dcbzl-no}"
+echo "vec_xl available  ${vec_xl-no}"
 fi
 if enabled loongarch; then
 echo "LSX enabled   ${lsx-no}"
diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
index 5e1033a973..8b0a93796f 100644
--- a/libswscale/ppc/yuv2rgb_altivec.c
+++ b/libswscale/ppc/yuv2rgb_altivec.c
@@ -284,7 +284,7 @@ static inline void cvtyuvtoRGB(SwsContext *c, vector signed 
short Y,
  * 
--
  */
 
-#if !HAVE_VSX
+#if !HAVE_VEC_XL
 static inline vector unsigned char vec_xl(signed long long offset, const ubyte 
*addr)
 {
 const vector unsigned char *v_addr = (const vector unsigned char *) (addr 
+ offset);
@@ -292,7 +292,7 @@ static inline vector unsigned char vec_xl(signed long long 
offset, const ubyte *
 
 return (vector unsigned char) vec_perm(v_addr[0], v_addr[1], align_perm);
 }
-#endif /* !HAVE_VSX */
+#endif /* !HAVE_VEC_XL */
 
 #define DEFCSP420_CVT(name, out_pixels)   \
 static int altivec_ ## name(SwsContext *c, const unsigned char **in,  \
-- 
2.41.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] [RFC PATCH] avutil/avutil: make AV_TIME_BASE_Q available in C++

2023-08-18 Thread Michael Niedermayer
On Sat, Aug 19, 2023 at 02:11:31AM +0800, Zhao Zhili wrote:
> From: Zhao Zhili 
> 
> It still different than AV_TIME_BASE_Q in C, like you cannot take
> address of AV_TIME_BASE_Q in C++. It's better than nothing.
> ---

iam in favor of better C++ compatibility of public headers

thx

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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


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] [VideoToolbox] Add HEVC 4:2:2 10-bit encoding profile

2023-08-18 Thread AdrianEddy
---
 libavcodec/avcodec.h |  1 +
 libavcodec/videotoolboxenc.c | 15 +++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 649411ac79..fdcf3905de 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1687,6 +1687,7 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_HEVC_MAIN_10 2
 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
 #define FF_PROFILE_HEVC_REXT4
+#define FF_PROFILE_HEVC_MAIN_10_422 5
 #define FF_PROFILE_HEVC_SCC 9
 
 #define FF_PROFILE_VVC_MAIN_10  1
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 8e493c4f7a..710d6c2227 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -113,6 +113,7 @@ static struct{
 
 CFStringRef kVTProfileLevel_HEVC_Main_AutoLevel;
 CFStringRef kVTProfileLevel_HEVC_Main10_AutoLevel;
+CFStringRef kVTProfileLevel_HEVC_Main42210_AutoLevel;
 
 CFStringRef kVTCompressionPropertyKey_RealTime;
 CFStringRef kVTCompressionPropertyKey_TargetQualityForAlpha;
@@ -181,8 +182,9 @@ static void loadVTEncSymbols(void){
 GET_SYM(kVTProfileLevel_H264_ConstrainedBaseline_AutoLevel, 
"H264_ConstrainedBaseline_AutoLevel");
 GET_SYM(kVTProfileLevel_H264_ConstrainedHigh_AutoLevel, 
"H264_ConstrainedHigh_AutoLevel");
 
-GET_SYM(kVTProfileLevel_HEVC_Main_AutoLevel, "HEVC_Main_AutoLevel");
-GET_SYM(kVTProfileLevel_HEVC_Main10_AutoLevel,   "HEVC_Main10_AutoLevel");
+GET_SYM(kVTProfileLevel_HEVC_Main_AutoLevel,  "HEVC_Main_AutoLevel");
+GET_SYM(kVTProfileLevel_HEVC_Main10_AutoLevel,"HEVC_Main10_AutoLevel");
+GET_SYM(kVTProfileLevel_HEVC_Main42210_AutoLevel, 
"HEVC_Main42210_AutoLevel");
 
 GET_SYM(kVTCompressionPropertyKey_RealTime, "RealTime");
 GET_SYM(kVTCompressionPropertyKey_TargetQualityForAlpha,
@@ -878,6 +880,10 @@ static bool get_vt_hevc_profile_level(AVCodecContext 
*avctx,
 *profile_level_val =
 compat_keys.kVTProfileLevel_HEVC_Main10_AutoLevel;
 break;
+case FF_PROFILE_HEVC_MAIN_10_422:
+*profile_level_val =
+compat_keys.kVTProfileLevel_HEVC_Main42210_AutoLevel;
+break;
 }
 
 if (!*profile_level_val) {
@@ -2836,8 +2842,9 @@ const FFCodec ff_h264_videotoolbox_encoder = {
 
 static const AVOption hevc_options[] = {
 { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = 
FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, INT_MAX, VE, "profile" },
-{ "main", "Main Profile", 0, AV_OPT_TYPE_CONST, { .i64 = 
FF_PROFILE_HEVC_MAIN}, INT_MIN, INT_MAX, VE, "profile" },
-{ "main10",   "Main10 Profile",   0, AV_OPT_TYPE_CONST, { .i64 = 
FF_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, VE, "profile" },
+{ "main",  "Main Profile",  0, AV_OPT_TYPE_CONST, { .i64 = 
FF_PROFILE_HEVC_MAIN}, INT_MIN, INT_MAX, VE, "profile" },
+{ "main10","Main10 Profile",0, AV_OPT_TYPE_CONST, { .i64 = 
FF_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, VE, "profile" },
+{ "main42210", "Main42210 Profile", 0, AV_OPT_TYPE_CONST, { .i64 = 
FF_PROFILE_HEVC_MAIN_10_422 }, INT_MIN, INT_MAX, VE, "profile" },
 
 { "alpha_quality", "Compression quality for the alpha channel", 
OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE },
 
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH 2/2] lavfi/vf_libplacebo: add extra_opts AVDictionary

2023-08-18 Thread Niklas Haas
From: Niklas Haas 

Can be used to configure libplacebo's underlying raw options, which
sometimes includes new or advanced / in-depth settings not (yet) exposed
by vf_libplacebo.
---
 doc/filters.texi| 10 ++
 libavfilter/vf_libplacebo.c | 13 +
 2 files changed, 23 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index cac1ee43810..421785ef46f 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16312,6 +16312,16 @@ Render frames with rounded corners. The value, given 
as a float ranging from
 square to fully circular. In other words, it gives the radius divided by half
 the smaller side length. Defaults to @code{0.0}.
 
+@item extra_opts
+Pass extra libplacebo internal configuration options. These can be specified
+as a list of @var{key}=@var{value} pairs separated by ':'. The following 
example
+shows how to configure a custom filter kernel ("EWA LanczosSharp") and use it
+to double the input image resolution:
+
+@example
+-vf 
"libplacebo=w=iw*2:h=ih*2:extra_opts='upscaler=custom\:upscaler_preset=ewa_lanczos\:upscaler_blur=0.9812505644269356'"
+@end example
+
 @item colorspace
 @item color_primaries
 @item color_trc
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index b9effdbad95..942c3210424 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -192,6 +192,7 @@ typedef struct LibplaceboContext {
 int color_range;
 int color_primaries;
 int color_trc;
+AVDictionary *extra_opts;
 
 /* pl_render_params */
 pl_options opts;
@@ -376,6 +377,7 @@ static int update_settings(AVFilterContext *ctx)
 {
 int err = 0;
 LibplaceboContext *s = ctx->priv;
+AVDictionaryEntry *e = NULL;
 pl_options opts = s->opts;
 int gamut_mode = s->gamut_mode;
 uint8_t color_rgba[4];
@@ -505,6 +507,16 @@ static int update_settings(AVFilterContext *ctx)
 RET(find_scaler(ctx, &opts->params.upscaler, s->upscaler, 0));
 RET(find_scaler(ctx, &opts->params.downscaler, s->downscaler, 0));
 RET(find_scaler(ctx, &opts->params.frame_mixer, s->frame_mixer, 1));
+
+#if PL_API_VER >= 309
+while ((e = av_dict_get(s->extra_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
+if (!pl_options_set_str(s->opts, e->key, e->value)) {
+err = AVERROR(EINVAL);
+goto fail;
+}
+}
+#endif
+
 return 0;
 
 fail:
@@ -1322,6 +1334,7 @@ static const AVOption libplacebo_options[] = {
 { "pad_crop_ratio", "ratio between padding and cropping when normalizing 
SAR (0=pad, 1=crop)", OFFSET(pad_crop_ratio), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 
0.0, 1.0, DYNAMIC },
 { "fillcolor", "Background fill color", OFFSET(fillcolor), 
AV_OPT_TYPE_STRING, {.str = "black"}, .flags = DYNAMIC },
 { "corner_rounding", "Corner rounding radius", OFFSET(corner_rounding), 
AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, .flags = DYNAMIC },
+{ "extra_opts", "Pass extra libplacebo-specific options using a 
:-separated list of key=value pairs", OFFSET(extra_opts), AV_OPT_TYPE_DICT, 
.flags = DYNAMIC },
 
 {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, 
{.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"},
 {"auto", "keep the same colorspace",  0, AV_OPT_TYPE_CONST, {.i64=-1}, 
 INT_MIN, INT_MAX, STATIC, "colorspace"},
-- 
2.41.0

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

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


[FFmpeg-devel] [PATCH 1/2] lavfi/vf_libplacebo: switch to new pl_options struct

2023-08-18 Thread Niklas Haas
From: Niklas Haas 

This new upstream struct simplifies params struct management by allowing
them to all be contained in a single dynamically allocated struct. This
commit switches to the new API in a backwards-compatible way.

The only nontrivial change that was required was to handle
`sigmoid_params` in a way consistent with the rest of the params
structs, instead of setting it directly to the upstream default.
---
 libavfilter/vf_libplacebo.c | 89 -
 1 file changed, 57 insertions(+), 32 deletions(-)

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 34879910538..b9effdbad95 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -42,6 +42,25 @@ static inline AVFrame *pl_get_mapped_avframe(const struct 
pl_frame *frame)
 }
 #endif
 
+#if PL_API_VER >= 309
+#include 
+#else
+typedef struct pl_options_t {
+// Backwards compatibility shim of this struct
+struct pl_render_params params;
+struct pl_deband_params deband_params;
+struct pl_sigmoid_params sigmoid_params;
+struct pl_color_adjustment color_adjustment;
+struct pl_peak_detect_params peak_detect_params;
+struct pl_color_map_params color_map_params;
+struct pl_dither_params dither_params;
+struct pl_cone_params cone_params;
+} *pl_options;
+
+#define pl_options_alloc(log) av_mallocz(sizeof(struct pl_options_t))
+#define pl_options_free(ptr)  av_freep(ptr)
+#endif
+
 enum {
 TONE_MAP_AUTO,
 TONE_MAP_CLIP,
@@ -175,7 +194,7 @@ typedef struct LibplaceboContext {
 int color_trc;
 
 /* pl_render_params */
-struct pl_render_params params;
+pl_options opts;
 char *upscaler;
 char *downscaler;
 char *frame_mixer;
@@ -190,7 +209,6 @@ typedef struct LibplaceboContext {
 int disable_fbos;
 
 /* pl_deband_params */
-struct pl_deband_params deband_params;
 int deband;
 int deband_iterations;
 float deband_threshold;
@@ -198,7 +216,6 @@ typedef struct LibplaceboContext {
 float deband_grain;
 
 /* pl_color_adjustment */
-struct pl_color_adjustment color_adjustment;
 float brightness;
 float contrast;
 float saturation;
@@ -206,7 +223,6 @@ typedef struct LibplaceboContext {
 float gamma;
 
 /* pl_peak_detect_params */
-struct pl_peak_detect_params peak_detect_params;
 int peakdetect;
 float smoothing;
 float min_peak;
@@ -215,7 +231,6 @@ typedef struct LibplaceboContext {
 float percentile;
 
 /* pl_color_map_params */
-struct pl_color_map_params color_map_params;
 int gamut_mode;
 int tonemapping;
 float tonemapping_param;
@@ -239,13 +254,11 @@ typedef struct LibplaceboContext {
 #endif
 
 /* pl_dither_params */
-struct pl_dither_params dither_params;
 int dithering;
 int dither_lut_size;
 int dither_temporal;
 
 /* pl_cone_params */
-struct pl_cone_params cone_params;
 int cones;
 float cone_str;
 
@@ -363,6 +376,7 @@ static int update_settings(AVFilterContext *ctx)
 {
 int err = 0;
 LibplaceboContext *s = ctx->priv;
+pl_options opts = s->opts;
 int gamut_mode = s->gamut_mode;
 uint8_t color_rgba[4];
 
@@ -394,14 +408,16 @@ static int update_settings(AVFilterContext *ctx)
 
 RET(av_parse_color(color_rgba, s->fillcolor, -1, s));
 
-s->deband_params = *pl_deband_params(
+opts->deband_params = *pl_deband_params(
 .iterations = s->deband_iterations,
 .threshold = s->deband_threshold,
 .radius = s->deband_radius,
 .grain = s->deband_grain,
 );
 
-s->color_adjustment = (struct pl_color_adjustment) {
+opts->sigmoid_params = pl_sigmoid_default_params;
+
+opts->color_adjustment = (struct pl_color_adjustment) {
 .brightness = s->brightness,
 .contrast = s->contrast,
 .saturation = s->saturation,
@@ -409,7 +425,7 @@ static int update_settings(AVFilterContext *ctx)
 .gamma = s->gamma,
 };
 
-s->peak_detect_params = *pl_peak_detect_params(
+opts->peak_detect_params = *pl_peak_detect_params(
 .smoothing_period = s->smoothing,
 .minimum_peak = s->min_peak,
 .scene_threshold_low = s->scene_low,
@@ -422,7 +438,7 @@ static int update_settings(AVFilterContext *ctx)
 #endif
 );
 
-s->color_map_params = *pl_color_map_params(
+opts->color_map_params = *pl_color_map_params(
 #if FF_API_LIBPLACEBO_OPTS
 # if PL_API_VER >= 269
 .hybrid_mix = hybrid_mix,
@@ -441,20 +457,20 @@ static int update_settings(AVFilterContext *ctx)
 #endif
 );
 
-set_gamut_mode(&s->color_map_params, gamut_mode);
+set_gamut_mode(&opts->color_map_params, gamut_mode);
 
-s->dither_params = *pl_dither_params(
+opts->dither_params = *pl_dither_params(
 .method = s->dithering,
 .lut_size = s->dither_lut_size,
 .temporal = s->dither_temporal,
 );
 
-s->cone_params = *pl_cone_params(
+opts->cone_params = *pl_cone_params

[FFmpeg-devel] [PATCH 1/2] lavfi/vf_libplacebo: switch to new pl_options struct

2023-08-18 Thread Niklas Haas
From: Niklas Haas 

This new upstream struct simplifies params struct management by allowing
them to all be contained in a single dynamically allocated struct. This
commit switches to the new API in a backwards-compatible way.

The only nontrivial change that was required was to handle
`sigmoid_params` in a way consistent with the rest of the params
structs, instead of setting it directly to the upstream default.
---
 libavfilter/vf_libplacebo.c | 89 -
 1 file changed, 57 insertions(+), 32 deletions(-)

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 34879910538..b9effdbad95 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -42,6 +42,25 @@ static inline AVFrame *pl_get_mapped_avframe(const struct 
pl_frame *frame)
 }
 #endif
 
+#if PL_API_VER >= 309
+#include 
+#else
+typedef struct pl_options_t {
+// Backwards compatibility shim of this struct
+struct pl_render_params params;
+struct pl_deband_params deband_params;
+struct pl_sigmoid_params sigmoid_params;
+struct pl_color_adjustment color_adjustment;
+struct pl_peak_detect_params peak_detect_params;
+struct pl_color_map_params color_map_params;
+struct pl_dither_params dither_params;
+struct pl_cone_params cone_params;
+} *pl_options;
+
+#define pl_options_alloc(log) av_mallocz(sizeof(struct pl_options_t))
+#define pl_options_free(ptr)  av_freep(ptr)
+#endif
+
 enum {
 TONE_MAP_AUTO,
 TONE_MAP_CLIP,
@@ -175,7 +194,7 @@ typedef struct LibplaceboContext {
 int color_trc;
 
 /* pl_render_params */
-struct pl_render_params params;
+pl_options opts;
 char *upscaler;
 char *downscaler;
 char *frame_mixer;
@@ -190,7 +209,6 @@ typedef struct LibplaceboContext {
 int disable_fbos;
 
 /* pl_deband_params */
-struct pl_deband_params deband_params;
 int deband;
 int deband_iterations;
 float deband_threshold;
@@ -198,7 +216,6 @@ typedef struct LibplaceboContext {
 float deband_grain;
 
 /* pl_color_adjustment */
-struct pl_color_adjustment color_adjustment;
 float brightness;
 float contrast;
 float saturation;
@@ -206,7 +223,6 @@ typedef struct LibplaceboContext {
 float gamma;
 
 /* pl_peak_detect_params */
-struct pl_peak_detect_params peak_detect_params;
 int peakdetect;
 float smoothing;
 float min_peak;
@@ -215,7 +231,6 @@ typedef struct LibplaceboContext {
 float percentile;
 
 /* pl_color_map_params */
-struct pl_color_map_params color_map_params;
 int gamut_mode;
 int tonemapping;
 float tonemapping_param;
@@ -239,13 +254,11 @@ typedef struct LibplaceboContext {
 #endif
 
 /* pl_dither_params */
-struct pl_dither_params dither_params;
 int dithering;
 int dither_lut_size;
 int dither_temporal;
 
 /* pl_cone_params */
-struct pl_cone_params cone_params;
 int cones;
 float cone_str;
 
@@ -363,6 +376,7 @@ static int update_settings(AVFilterContext *ctx)
 {
 int err = 0;
 LibplaceboContext *s = ctx->priv;
+pl_options opts = s->opts;
 int gamut_mode = s->gamut_mode;
 uint8_t color_rgba[4];
 
@@ -394,14 +408,16 @@ static int update_settings(AVFilterContext *ctx)
 
 RET(av_parse_color(color_rgba, s->fillcolor, -1, s));
 
-s->deband_params = *pl_deband_params(
+opts->deband_params = *pl_deband_params(
 .iterations = s->deband_iterations,
 .threshold = s->deband_threshold,
 .radius = s->deband_radius,
 .grain = s->deband_grain,
 );
 
-s->color_adjustment = (struct pl_color_adjustment) {
+opts->sigmoid_params = pl_sigmoid_default_params;
+
+opts->color_adjustment = (struct pl_color_adjustment) {
 .brightness = s->brightness,
 .contrast = s->contrast,
 .saturation = s->saturation,
@@ -409,7 +425,7 @@ static int update_settings(AVFilterContext *ctx)
 .gamma = s->gamma,
 };
 
-s->peak_detect_params = *pl_peak_detect_params(
+opts->peak_detect_params = *pl_peak_detect_params(
 .smoothing_period = s->smoothing,
 .minimum_peak = s->min_peak,
 .scene_threshold_low = s->scene_low,
@@ -422,7 +438,7 @@ static int update_settings(AVFilterContext *ctx)
 #endif
 );
 
-s->color_map_params = *pl_color_map_params(
+opts->color_map_params = *pl_color_map_params(
 #if FF_API_LIBPLACEBO_OPTS
 # if PL_API_VER >= 269
 .hybrid_mix = hybrid_mix,
@@ -441,20 +457,20 @@ static int update_settings(AVFilterContext *ctx)
 #endif
 );
 
-set_gamut_mode(&s->color_map_params, gamut_mode);
+set_gamut_mode(&opts->color_map_params, gamut_mode);
 
-s->dither_params = *pl_dither_params(
+opts->dither_params = *pl_dither_params(
 .method = s->dithering,
 .lut_size = s->dither_lut_size,
 .temporal = s->dither_temporal,
 );
 
-s->cone_params = *pl_cone_params(
+opts->cone_params = *pl_cone_params

Re: [FFmpeg-devel] [PATCH v4] vvcdec: add thread executor

2023-08-18 Thread James Almer

On 8/15/2023 11:50 AM, Nuo Mi wrote:

The executor design pattern was inroduced by java

it also adapted by python

Compared to handcrafted thread pool management, it greatly simplifies the 
thread code.
---
  libavutil/Makefile   |   2 +
  libavutil/executor.c | 201 +++
  libavutil/executor.h |  67 +++
  3 files changed, 270 insertions(+)
  create mode 100644 libavutil/executor.c
  create mode 100644 libavutil/executor.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 7828c94dc5..4711f8cde8 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -31,6 +31,7 @@ HEADERS = adler32.h   
  \
encryption_info.h \
error.h   \
eval.h\
+  executor.h\
fifo.h\
file.h\
frame.h   \
@@ -127,6 +128,7 @@ OBJS = adler32.o
\
 encryption_info.o\
 error.o  \
 eval.o   \
+   executor.o   \
 fifo.o   \
 file.o   \
 file_open.o  \
diff --git a/libavutil/executor.c b/libavutil/executor.c
new file mode 100644
index 00..6b47ba0bf2
--- /dev/null
+++ b/libavutil/executor.c
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2023 Nuo Mi
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "internal.h"
+#include "mem.h"
+#include "thread.h"
+
+#include "executor.h"
+
+#if !HAVE_THREADS
+#define pthread_create(t, a, s, ar) 0
+#define pthread_join(t, r)  do {} while(0)
+
+#define pthread_cond_init(c, a) 0
+#define pthread_cond_broadcast(c)   do {} while(0)
+#define pthread_cond_signal(c)  do {} while(0)
+#define pthread_cond_wait(c, m) do {} while(0)
+#define pthread_cond_destroy(c) do {} while(0)
+
+#define pthread_mutex_init(m, a)0
+#define pthread_mutex_lock(l)   do {} while(0)
+#define pthread_mutex_unlock(l) do {} while(0)
+#define pthread_mutex_destroy(l)do {} while(0)


You have ff_mutex_* and AVMutex for this. I sent a patch adding 
ff_cond_* and AVCond, as well as ff_thread_create/join and AVThread to 
thread.h to simplify things.



+#endif
+
+typedef struct ThreadInfo {
+AVExecutor *e;
+pthread_t thread;


You will need to use AVThread, else this will not be defined when 
!HAVE_THREADS.



+} ThreadInfo;
+
+struct AVExecutor {
+AVTaskCallbacks cb;
+int thread_count;
+
+ThreadInfo *threads;
+uint8_t *local_contexts;
+
+pthread_mutex_t lock;
+pthread_cond_t cond;


Same here. AVMutex and AVCond.


+int die;
+
+AVTask *tasks;
+};
+
+static AVTask* remove_task(AVTask **prev, AVTask *t)
+{
+*prev  = t->next;
+t->next = NULL;
+return t;
+}
+
+static void add_task(AVTask **prev, AVTask *t)
+{
+t->next = *prev;
+*prev   = t;
+}
+
+static int run_one_task(AVExecutor *e, void *lc)
+{
+AVTaskCallbacks *cb = &e->cb;
+AVTask **prev;
+
+for (prev = &e->tasks; *prev && !cb->ready(*prev, cb->user_data); prev = 
&(*prev)->next)
+/* nothing */;
+if (*prev) {
+AVTask *t = remove_task(prev, *prev);
+pthread_mutex_unlock(&e->lock);
+cb->run(t, lc, cb->user_data);
+pthread_mutex_lock(&e->lock);
+return 1;
+}
+return 0;
+}
+
+#if HAVE_TH

[FFmpeg-devel] [PATCH v2] avutil/thread: add wrappers for pthread_cond_t and pthread_t functions

2023-08-18 Thread James Almer
Signed-off-by: James Almer 
---
Now not defining pthread_t when !HAVE_THREADS, like it's done with cond, mutex,
and once.

 libavutil/thread.h | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/libavutil/thread.h b/libavutil/thread.h
index 2f5e7e1cb5..7dfa54c6a9 100644
--- a/libavutil/thread.h
+++ b/libavutil/thread.h
@@ -155,6 +155,15 @@ static inline int strict_pthread_once(pthread_once_t 
*once_control, void (*init_
 #include "compat/w32pthreads.h"
 #endif
 
+#define AVCond pthread_cond_t
+
+#define ff_cond_init  pthread_cond_init
+#define ff_cond_destroy   pthread_cond_destroy
+#define ff_cond_signalpthread_cond_signal
+#define ff_cond_broadcast pthread_cond_broadcast
+#define ff_cond_wait  pthread_cond_wait
+#define ff_cond_timedwait pthread_cond_timedwait
+
 #define AVMutex pthread_mutex_t
 #define AV_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
@@ -168,8 +177,23 @@ static inline int strict_pthread_once(pthread_once_t 
*once_control, void (*init_
 
 #define ff_thread_once(control, routine) pthread_once(control, routine)
 
+#define AVThread pthread_t
+
+#define ff_thread_create pthread_create
+#define ff_thread_join   pthread_join
+
 #else
 
+#define AVCond char
+
+static inline int ff_cond_init(AVCond *cond, const void *attr){ return 0; }
+static inline int ff_cond_destroy(AVCond *cond){ return 0; }
+static inline int ff_cond_signal(AVCond *cond){ return 0; }
+static inline int ff_cond_broadcast(AVCond *cond){ return 0; }
+static inline int ff_cond_wait(AVCond *cond, AVMutex *mutex){ return 0; }
+static inline int ff_cond_timedwait(AVCond *cond, AVMutex *mutex,
+const void *abstime){ return 0; }
+
 #define AVMutex char
 #define AV_MUTEX_INITIALIZER 0
 
@@ -190,6 +214,12 @@ static inline int ff_thread_once(char *control, void 
(*routine)(void))
 return 0;
 }
 
+#define AVThread char
+
+static inline int ff_thread_create(AVThread *thread, const void *unused_attr,
+   void *(*start_routine)(void*), void *arg){ 
return 0; }
+static inline int ff_thread_join(AVThread thread, void **value_ptr){ return 0; 
}
+
 #endif
 
 static inline int ff_thread_setname(const char *name)
-- 
2.41.0

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

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


[FFmpeg-devel] [PATCH] avutil/thread: add wrappers for pthread_cond_t and pthread_t functions

2023-08-18 Thread James Almer
Signed-off-by: James Almer 
---
 libavutil/thread.h | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/libavutil/thread.h b/libavutil/thread.h
index 2f5e7e1cb5..1e456f1c29 100644
--- a/libavutil/thread.h
+++ b/libavutil/thread.h
@@ -155,6 +155,15 @@ static inline int strict_pthread_once(pthread_once_t 
*once_control, void (*init_
 #include "compat/w32pthreads.h"
 #endif
 
+#define AVCond pthread_cond_t
+
+#define ff_cond_init  pthread_cond_init
+#define ff_cond_destroy   pthread_cond_destroy
+#define ff_cond_signalpthread_cond_signal
+#define ff_cond_broadcast pthread_cond_broadcast
+#define ff_cond_wait  pthread_cond_wait
+#define ff_cond_timedwait pthread_cond_timedwait
+
 #define AVMutex pthread_mutex_t
 #define AV_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
@@ -170,6 +179,16 @@ static inline int strict_pthread_once(pthread_once_t 
*once_control, void (*init_
 
 #else
 
+#define AVCond char
+
+static inline int ff_cond_init(AVCond *cond, const void *attr){ return 0; }
+static inline int ff_cond_destroy(AVCond *cond){ return 0; }
+static inline int ff_cond_signal(AVCond *cond){ return 0; }
+static inline int ff_cond_broadcast(AVCond *cond){ return 0; }
+static inline int ff_cond_wait(AVCond *cond, AVMutex *mutex){ return 0; }
+static inline int ff_cond_timedwait(AVCond *cond, AVMutex *mutex,
+const void *abstime){ return 0; }
+
 #define AVMutex char
 #define AV_MUTEX_INITIALIZER 0
 
@@ -190,6 +209,14 @@ static inline int ff_thread_once(char *control, void 
(*routine)(void))
 return 0;
 }
 
+typedef struct pthread_t {
+void *dummy;
+} pthread_t;
+
+static inline int pthread_create(pthread_t *thread, const void *unused_attr,
+ void *(*start_routine)(void*), void *arg){ 
return 0; }
+static inline int pthread_join(pthread_t thread, void **value_ptr){ return 0; }
+
 #endif
 
 static inline int ff_thread_setname(const char *name)
-- 
2.41.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 v4] vvcdec: add thread executor

2023-08-18 Thread James Almer

On 8/16/2023 1:42 PM, Rémi Denis-Courmont wrote:

Le tiistaina 15. elokuuta 2023, 17.50.13 EEST Nuo Mi a écrit :

The executor design pattern was inroduced by java
 it also adapted by python

Compared to handcrafted thread pool management, it greatly simplifies the
thread code. ---
  libavutil/Makefile   |   2 +
  libavutil/executor.c | 201 +++
  libavutil/executor.h |  67 +++
  3 files changed, 270 insertions(+)
  create mode 100644 libavutil/executor.c
  create mode 100644 libavutil/executor.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 7828c94dc5..4711f8cde8 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -31,6 +31,7 @@ HEADERS = adler32.h
  \ encryption_info.h
  \ error.h   \ eval.h
  \ +
executor.h\ fifo.h
   \ file.h
   \ frame.h
   \ @@ -127,6 +128,7 @@ OBJS = adler32.o
 \ encryption_info.o
\ error.o
   \ eval.o
  \ +   executor.o
 \ fifo.o
\ file.o   \
file_open.o  \ diff
--git a/libavutil/executor.c b/libavutil/executor.c
new file mode 100644
index 00..6b47ba0bf2
--- /dev/null
+++ b/libavutil/executor.c
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2023 Nuo Mi
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA + */
+#include "internal.h"
+#include "mem.h"
+#include "thread.h"
+
+#include "executor.h"
+
+#if !HAVE_THREADS
+#define pthread_create(t, a, s, ar) 0


Err, this should probably return an error value, e.g. ENOSYS or ENOTSUP.


pthread_create() is used below even if !HAVE_THREADS, so it should not fail.




+#define pthread_join(t, r)  do {} while(0)


...and this should be an unreachable(), assert(0), abort() or something along
those lines.


This is also used below. It being a no-op should be ok.




+
+#define pthread_cond_init(c, a) 0
+#define pthread_cond_broadcast(c)   do {} while(0)
+#define pthread_cond_signal(c)  do {} while(0)
+#define pthread_cond_wait(c, m) do {} while(0)
+#define pthread_cond_destroy(c) do {} while(0)
+
+#define pthread_mutex_init(m, a)0
+#define pthread_mutex_lock(l)   do {} while(0)
+#define pthread_mutex_unlock(l) do {} while(0)
+#define pthread_mutex_destroy(l)do {} while(0)
+#endif
+
+typedef struct ThreadInfo {
+AVExecutor *e;
+pthread_t thread;


Does this even work if !HAVE_THREAD ?


+} ThreadInfo;
+
+struct AVExecutor {
+AVTaskCallbacks cb;
+int thread_count;
+
+ThreadInfo *threads;
+uint8_t *local_contexts;
+
+pthread_mutex_t lock;
+pthread_cond_t cond;
+int die;
+
+AVTask *tasks;
+};
+
+static AVTask* remove_task(AVTask **prev, AVTask *t)
+{
+*prev  = t->next;
+t->next = NULL;
+return t;
+}
+
+static void add_task(AVTask **prev, AVTask *t)
+{
+t->next = *prev;
+*prev   = t;
+}
+
+static int run_one_task(AVExecutor *e, void *lc)
+{
+AVTaskCallbacks *cb = &e->cb;
+AVTask **prev;
+
+for (prev = &e->tasks; *prev && !cb->ready(*prev, cb->user_data); prev
= &(*prev)->next)
+/* nothing */;
+if (*prev) {
+AVTask *t = remove_task(prev, *prev);
+pthread_mutex_unlock(&e->lock);
+cb->run(t, lc, cb->user_data);
+pthread_mutex_lock(&e->lock);
+return 1;
+}
+return 0;
+}
+
+#if HAVE_THREADS
+static void *executor_worker_task(void *data)
+{
+ThreadInfo *ti = (ThreadInfo*)data;
+AVExecutor *e  = ti->e;
+void *lc   = e->local_contexts
+ (ti - e->threads) *
e->cb.local_context_size; +
+pthread_mutex_lock(&e->lock);
+while (1) {
+if (e->die) break;
+
+   

[FFmpeg-devel] h264_vaapi is using vaapi or va-api

2023-08-18 Thread cfd new via ffmpeg-devel
Hi, Folks,
    new FFMPEG user. I used gstreamer before. Now I am trying to build a rtsp 
pipeline.Would like to know whether h264_vaapi uses vaapi or va-api? these two 
are different ingstreamer.

   Thanks,
    Joe
___
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/3] avfilter/vf_transpose_vt: fix output frame dimension

2023-08-18 Thread Zhao Zhili
From: Zhao Zhili 

Create a new hardware frame context when necessary.

Signed-off-by: Zhao Zhili 
---
 libavfilter/vf_transpose_vt.c | 47 +++
 1 file changed, 42 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_transpose_vt.c b/libavfilter/vf_transpose_vt.c
index b5b07e9ef1..da59479a4b 100644
--- a/libavfilter/vf_transpose_vt.c
+++ b/libavfilter/vf_transpose_vt.c
@@ -102,6 +102,39 @@ fail:
 return ret;
 }
 
+static int transpose_vt_recreate_hw_ctx(AVFilterLink *outlink)
+{
+AVFilterContext *avctx = outlink->src;
+AVFilterLink *inlink = outlink->src->inputs[0];
+AVHWFramesContext *hw_frame_ctx_in;
+AVHWFramesContext *hw_frame_ctx_out;
+int err;
+
+av_buffer_unref(&outlink->hw_frames_ctx);
+
+hw_frame_ctx_in = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
+outlink->hw_frames_ctx = av_hwframe_ctx_alloc(hw_frame_ctx_in->device_ref);
+hw_frame_ctx_out = (AVHWFramesContext *)outlink->hw_frames_ctx->data;
+hw_frame_ctx_out->format = AV_PIX_FMT_VIDEOTOOLBOX;
+hw_frame_ctx_out->sw_format = hw_frame_ctx_in->sw_format;
+hw_frame_ctx_out->width = outlink->w;
+hw_frame_ctx_out->height = outlink->h;
+
+err = ff_filter_init_hw_frames(avctx, outlink, 1);
+if (err < 0)
+return err;
+
+err = av_hwframe_ctx_init(outlink->hw_frames_ctx);
+if (err < 0) {
+av_log(avctx, AV_LOG_ERROR,
+   "Failed to init videotoolbox frame context, %s\n",
+   av_err2str(err));
+return err;
+}
+
+return 0;
+}
+
 static int transpose_vt_config_output(AVFilterLink *outlink)
 {
 int err;
@@ -113,6 +146,9 @@ static int transpose_vt_config_output(AVFilterLink *outlink)
 CFBooleanRef hflip = kCFBooleanFalse;
 int swap_w_h = 0;
 
+av_buffer_unref(&outlink->hw_frames_ctx);
+outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx);
+
 if ((inlink->w >= inlink->h && s->passthrough == 
TRANSPOSE_PT_TYPE_LANDSCAPE) ||
 (inlink->w <= inlink->h && s->passthrough == 
TRANSPOSE_PT_TYPE_PORTRAIT)) {
 av_log(avctx, AV_LOG_VERBOSE,
@@ -175,12 +211,12 @@ static int transpose_vt_config_output(AVFilterLink 
*outlink)
 return AVERROR_EXTERNAL;
 }
 
-if (swap_w_h) {
-outlink->w = inlink->h;
-outlink->h = inlink->w;
-}
+if (!swap_w_h)
+return 0;
 
-return 0;
+outlink->w = inlink->h;
+outlink->h = inlink->w;
+return transpose_vt_recreate_hw_ctx(outlink);
 }
 
 #define OFFSET(x) offsetof(TransposeVtContext, x)
@@ -244,4 +280,5 @@ const AVFilter ff_vf_transpose_vt = {
 FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VIDEOTOOLBOX),
 .priv_class = &transpose_vt_class,
 .flags  = AVFILTER_FLAG_HWDEVICE,
+.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
 };
-- 
2.40.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/3] avfilter/vf_transpose_vt: fix declaration-after-statement

2023-08-18 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavfilter/vf_transpose_vt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_transpose_vt.c b/libavfilter/vf_transpose_vt.c
index da59479a4b..a3b2b9be79 100644
--- a/libavfilter/vf_transpose_vt.c
+++ b/libavfilter/vf_transpose_vt.c
@@ -69,11 +69,12 @@ static int transpose_vt_filter_frame(AVFilterLink *link, 
AVFrame *in)
 AVFilterLink *outlink = ctx->outputs[0];
 CVPixelBufferRef src;
 CVPixelBufferRef dst;
+AVFrame *out;
 
 if (s->passthrough)
 return ff_filter_frame(outlink, in);
 
-AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!out) {
 ret = AVERROR(ENOMEM);
 goto fail;
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH 1/3] avfilter/vf_scale_vt: fix output frame dimension

2023-08-18 Thread Zhao Zhili
From: Zhao Zhili 

The output frame dimension is incorrect because it shares hardware
frame context with input.

Signed-off-by: Zhao Zhili 
---
 libavfilter/vf_scale_vt.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/libavfilter/vf_scale_vt.c b/libavfilter/vf_scale_vt.c
index d5b4f12291..af4a8b32c6 100644
--- a/libavfilter/vf_scale_vt.c
+++ b/libavfilter/vf_scale_vt.c
@@ -177,6 +177,8 @@ static int scale_vt_config_output(AVFilterLink *outlink)
 AVFilterContext *avctx = outlink->src;
 ScaleVtContext *s  = avctx->priv;
 AVFilterLink *inlink = outlink->src->inputs[0];
+AVHWFramesContext *hw_frame_ctx_in;
+AVHWFramesContext *hw_frame_ctx_out;
 
 err = ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink,
&s->output_width,
@@ -194,6 +196,28 @@ static int scale_vt_config_output(AVFilterLink *outlink)
 outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
 }
 
+hw_frame_ctx_in = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
+
+av_buffer_unref(&outlink->hw_frames_ctx);
+outlink->hw_frames_ctx = av_hwframe_ctx_alloc(hw_frame_ctx_in->device_ref);
+hw_frame_ctx_out = (AVHWFramesContext *)outlink->hw_frames_ctx->data;
+hw_frame_ctx_out->format = AV_PIX_FMT_VIDEOTOOLBOX;
+hw_frame_ctx_out->sw_format = hw_frame_ctx_in->sw_format;
+hw_frame_ctx_out->width = outlink->w;
+hw_frame_ctx_out->height = outlink->h;
+
+err = ff_filter_init_hw_frames(avctx, outlink, 1);
+if (err < 0)
+return err;
+
+err = av_hwframe_ctx_init(outlink->hw_frames_ctx);
+if (err < 0) {
+av_log(avctx, AV_LOG_ERROR,
+   "Failed to init videotoolbox frame context, %s\n",
+   av_err2str(err));
+return err;
+}
+
 return 0;
 }
 
@@ -242,4 +266,5 @@ const AVFilter ff_vf_scale_vt = {
 FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VIDEOTOOLBOX),
 .priv_class = &scale_vt_class,
 .flags  = AVFILTER_FLAG_HWDEVICE,
+.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
 };
-- 
2.40.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] [RFC PATCH] avutil/avutil: make AV_TIME_BASE_Q available in C++

2023-08-18 Thread Zhao Zhili
From: Zhao Zhili 

It still different than AV_TIME_BASE_Q in C, like you cannot take
address of AV_TIME_BASE_Q in C++. It's better than nothing.
---
 libavutil/avutil.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 64b68bdbd3..5201cc6c5e 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -257,7 +257,12 @@ const char *av_get_media_type_string(enum AVMediaType 
media_type);
  * Internal time base represented as fractional value
  */
 
+#ifdef __cplusplus
+/* ISO C++ forbids compound-literals. */
+#define AV_TIME_BASE_Q  AVRational{1, AV_TIME_BASE}
+#else
 #define AV_TIME_BASE_Q  (AVRational){1, AV_TIME_BASE}
+#endif
 
 /**
  * @}
-- 
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".


[FFmpeg-devel] [PATCH 1/3] avfilter/dnn_filter_common: fix memleak

2023-08-18 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavfilter/dnn_filter_common.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavfilter/dnn_filter_common.c b/libavfilter/dnn_filter_common.c
index d175c91914..3b9182c1d1 100644
--- a/libavfilter/dnn_filter_common.c
+++ b/libavfilter/dnn_filter_common.c
@@ -159,4 +159,10 @@ void ff_dnn_uninit(DnnContext *ctx)
 if (ctx->dnn_module) {
 (ctx->dnn_module->free_model)(&ctx->model);
 }
+if (ctx->model_outputnames) {
+for (int i = 0; i < ctx->nb_outputs; i++)
+av_free(ctx->model_outputnames[i]);
+
+av_freep(&ctx->model_outputnames);
+}
 }
-- 
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".


[FFmpeg-devel] [PATCH 3/3] avfilter/dnn_backend_openvino: reduce indentation in free_model_ov

2023-08-18 Thread Zhao Zhili
From: Zhao Zhili 

No functional changes.

Signed-off-by: Zhao Zhili 
---
 libavfilter/dnn/dnn_backend_openvino.c | 75 +-
 1 file changed, 39 insertions(+), 36 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 071516b17d..6afc80eda5 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -294,44 +294,47 @@ static void infer_completion_callback(void *args)
 
 static void dnn_free_model_ov(DNNModel **model)
 {
-if (*model){
-OVModel *ov_model = (*model)->model;
-while (ff_safe_queue_size(ov_model->request_queue) != 0) {
-OVRequestItem *item = 
ff_safe_queue_pop_front(ov_model->request_queue);
-if (item && item->infer_request) {
-ie_infer_request_free(&item->infer_request);
-}
-av_freep(&item->lltasks);
-av_freep(&item);
-}
-ff_safe_queue_destroy(ov_model->request_queue);
-
-while (ff_queue_size(ov_model->lltask_queue) != 0) {
-LastLevelTaskItem *item = 
ff_queue_pop_front(ov_model->lltask_queue);
-av_freep(&item);
-}
-ff_queue_destroy(ov_model->lltask_queue);
+OVModel *ov_model;
 
-while (ff_queue_size(ov_model->task_queue) != 0) {
-TaskItem *item = ff_queue_pop_front(ov_model->task_queue);
-av_frame_free(&item->in_frame);
-av_frame_free(&item->out_frame);
-av_freep(&item);
-}
-ff_queue_destroy(ov_model->task_queue);
+if (!*model)
+return;
 
-if (ov_model->exe_network)
-ie_exec_network_free(&ov_model->exe_network);
-if (ov_model->network)
-ie_network_free(&ov_model->network);
-if (ov_model->core)
-ie_core_free(&ov_model->core);
-av_free(ov_model->all_output_names);
-av_free(ov_model->all_input_names);
-av_opt_free(&ov_model->ctx);
-av_freep(&ov_model);
-av_freep(model);
-}
+ov_model = (*model)->model;
+while (ff_safe_queue_size(ov_model->request_queue) != 0) {
+OVRequestItem *item = ff_safe_queue_pop_front(ov_model->request_queue);
+if (item && item->infer_request) {
+ie_infer_request_free(&item->infer_request);
+}
+av_freep(&item->lltasks);
+av_freep(&item);
+}
+ff_safe_queue_destroy(ov_model->request_queue);
+
+while (ff_queue_size(ov_model->lltask_queue) != 0) {
+LastLevelTaskItem *item = ff_queue_pop_front(ov_model->lltask_queue);
+av_freep(&item);
+}
+ff_queue_destroy(ov_model->lltask_queue);
+
+while (ff_queue_size(ov_model->task_queue) != 0) {
+TaskItem *item = ff_queue_pop_front(ov_model->task_queue);
+av_frame_free(&item->in_frame);
+av_frame_free(&item->out_frame);
+av_freep(&item);
+}
+ff_queue_destroy(ov_model->task_queue);
+
+if (ov_model->exe_network)
+ie_exec_network_free(&ov_model->exe_network);
+if (ov_model->network)
+ie_network_free(&ov_model->network);
+if (ov_model->core)
+ie_core_free(&ov_model->core);
+av_free(ov_model->all_output_names);
+av_free(ov_model->all_input_names);
+av_opt_free(&ov_model->ctx);
+av_freep(&ov_model);
+av_freep(model);
 }
 
 
-- 
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".


[FFmpeg-devel] [PATCH 2/3] avfilter/dnn_backend_openvino: fix multiple memleaks

2023-08-18 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavfilter/dnn/dnn_backend_openvino.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 46cbe8270e..071516b17d 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -326,6 +326,9 @@ static void dnn_free_model_ov(DNNModel **model)
 ie_network_free(&ov_model->network);
 if (ov_model->core)
 ie_core_free(&ov_model->core);
+av_free(ov_model->all_output_names);
+av_free(ov_model->all_input_names);
+av_opt_free(&ov_model->ctx);
 av_freep(&ov_model);
 av_freep(model);
 }
@@ -821,6 +824,7 @@ static DNNModel *dnn_load_model_ov(const char 
*model_filename, DNNFunctionType f
 goto err;
 }
 APPEND_STRING(ov_model->all_input_names, node_name)
+ie_network_name_free(&node_name);
 }
 status = ie_network_get_outputs_number(ov_model->network, &node_count);
 if (status != OK) {
@@ -834,6 +838,7 @@ static DNNModel *dnn_load_model_ov(const char 
*model_filename, DNNFunctionType f
 goto err;
 }
 APPEND_STRING(ov_model->all_output_names, node_name)
+ie_network_name_free(&node_name);
 }
 
 model->get_input = &get_input_ov;
-- 
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".