Re: [FFmpeg-devel] [PATCH v2] avfilter: fix data type for {Tile, Untile}Context's image size

2024-07-23 Thread Marvin Scholz (ePirat)

> On 24. Jul 2024, at 00:10, Michael Niedermayer  wrote:
> 
> On Tue, Jul 23, 2024 at 12:17:43PM -0300, James Almer wrote:
>>> On 7/19/2024 12:31 PM, Paul B Mahol wrote:
>>> Internal/private filter structures/API changes does not need be mentioned
>>> in that file, isn't that fact obvious even for average Joe?
>> 
>> There's no reason to be condescending or aggressive over something so
>> irrelevant. Is it so hard to just state the APIChanges entry is not needed?
> 
> "so irrelevant" sounds condescending to me too
> 
> either way, i support pointing out if something sounds 
> rude/condescending/aggressive
> (theres nothing bad in pointing that out, first step is always being aware
> one said something that others find offensive)
> 
> 
>> 
>> I'm writing this representing the CC. This is not the only case you were
>> pointlessly aggressive to someone in the past week or so. Consider it a
>> warning before further action is taken.
> 
> This part i do not agree with.
> First, i dont think we actually had a majority for a warning, I see 4 of 5
> members of the CC replying but only 2 talking about a warning.
> 


What a joke is the CC if this is not warning-worthy…

And if you do not point it out in public, it looks like to everyone else such 
behavior is tolerated, to everyone else.

> Also (as i said previously) Politely pointing out to people when they write
> offensive things is a good thing, it has been effective in channeling
> discussions into a positive and friendlier direction,
> especially when done in real time. (You did the previously several times
> successfully)
> 
> Adding a "threat" in the form of a warning maybe works for some people in
> some cases. But in others its more like slapping an already angry guy in the 
> face.
> You get slapped harder back then have to punch and get punched back and then
> things spiral downward. And whetaver the exact outcome its a bad outcome
> 

Having less toxic people in the community is a bad outcome? Ok then we have 
different definitions of bad.


> thx
> 
> [...]
> 
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> During times of universal deceit, telling the truth becomes a
> revolutionary act. -- George Orwell
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avutil/hwcontext_videotoolbox: Fix build with older SDKs

2024-07-23 Thread Marvin Scholz
The previous fix was not sufficient.
To make things easier to reason about, split the function and
add the guards there instead of complicating the call site more.
---
 libavutil/hwcontext_videotoolbox.c | 51 +++---
 1 file changed, 39 insertions(+), 12 deletions(-)

diff --git a/libavutil/hwcontext_videotoolbox.c 
b/libavutil/hwcontext_videotoolbox.c
index ab7556936d..1794459943 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -532,6 +532,37 @@ CFStringRef av_map_videotoolbox_color_trc_from_av(enum 
AVColorTransferCharacteri
 }
 }
 
+/**
+ * Copy all attachments for the specified mode from the given buffer.
+ */
+static CFDictionaryRef vt_cv_buffer_copy_attachments(CVBufferRef buffer,
+ CVAttachmentMode 
attachment_mode)
+{
+CFDictionaryRef dict;
+
+// Check that our SDK is at least macOS 12 / iOS 15 / tvOS 15
+#if (TARGET_OS_OSX  && defined(__MAC_12_0)&& 
__MAC_OS_X_VERSION_MAX_ALLOWED  >= __MAC_12_0) || \
+(TARGET_OS_IOS  && defined(__IPHONE_15_0) && 
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_15_0)  || \
+(TARGET_OS_TV   && defined(__TVOS_15_0)   && 
__TV_OS_VERSION_MAX_ALLOWED >= __TVOS_15_0)
+// On recent enough versions, just use the respective API
+if (__builtin_available(macOS 12.0, iOS 15.0, tvOS 15.0, *))
+return CVBufferCopyAttachments(buffer, attachment_mode);
+#endif
+
+// Check that the target is lower than macOS 12 / iOS 15 / tvOS 15
+// else this would generate a deprecation warning and anyway never run 
because
+// the runtime availability check above would be always true.
+#if (TARGET_OS_OSX  && (!defined(__MAC_12_0)|| 
__MAC_OS_X_VERSION_MIN_REQUIRED  < __MAC_12_0)) || \
+(TARGET_OS_IOS  && (!defined(__IPHONE_15_0) || 
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_15_0))  || \
+(TARGET_OS_TV   && (!defined(__TVOS_15_0)   || 
__TV_OS_VERSION_MIN_REQUIRED < __TVOS_15_0))
+// Fallback on SDKs or runtime versions < macOS 12 / iOS 15 / tvOS 15
+dict = CVBufferGetAttachments(buffer, attachment_mode);
+return (dict) ? CFDictionaryCreateCopy(NULL, dict) : NULL;
+#else
+return NULL; // Impossible, just make the compiler happy
+#endif
+}
+
 static int vt_pixbuf_set_colorspace(void *log_ctx,
 CVPixelBufferRef pixbuf, const AVFrame 
*src)
 {
@@ -591,24 +622,20 @@ static int vt_pixbuf_set_colorspace(void *log_ctx,
 #if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 100800) || \
 (TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 10)
 if (__builtin_available(macOS 10.8, iOS 10, *)) {
-CFDictionaryRef attachments = NULL;
-if (__builtin_available(macOS 12.0, iOS 15.0, *))
-attachments = CVBufferCopyAttachments(pixbuf, 
kCVAttachmentMode_ShouldPropagate);
-#if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED <= 12) || \
-(TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED <= 15)
-else {
-CFDictionaryRef tmp = CVBufferGetAttachments(pixbuf, 
kCVAttachmentMode_ShouldPropagate);
-if (tmp)
-attachments = CFDictionaryCreateCopy(NULL, tmp);
-}
-#endif
+CFDictionaryRef attachments =
+vt_cv_buffer_copy_attachments(pixbuf, 
kCVAttachmentMode_ShouldPropagate);
+
 if (attachments) {
-colorspace = 
CVImageBufferCreateColorSpaceFromAttachments(attachments);
+colorspace =
+CVImageBufferCreateColorSpaceFromAttachments(attachments);
 CFRelease(attachments);
 }
 }
 #endif
 
+// Done outside the above preprocessor code and if's so that
+// in any case a wrong kCVImageBufferCGColorSpaceKey is removed
+// if the above code is not used or fails.
 if (colorspace) {
 CVBufferSetAttachment(pixbuf, kCVImageBufferCGColorSpaceKey,
 colorspace, kCVAttachmentMode_ShouldPropagate);

base-commit: fa5a6055422a9e38905de9274e63f245cef96c57
-- 
2.39.3 (Apple Git-146)
___
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] ffbuild: add METALCC and METALLIB to BRIEF

2024-07-12 Thread Marvin Scholz
---
 ffbuild/common.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffbuild/common.mak b/ffbuild/common.mak
index 87a3ffd2b0..023adb8567 100644
--- a/ffbuild/common.mak
+++ b/ffbuild/common.mak
@@ -18,7 +18,7 @@ BIN2C = $(BIN2CEXE)
 ifndef V
 Q  = @
 ECHO   = printf "$(1)\t%s\n" $(2)
-BRIEF  = CC CXX OBJCC HOSTCC HOSTLD AS X86ASM AR LD STRIP CP WINDRES NVCC BIN2C
+BRIEF  = CC CXX OBJCC HOSTCC HOSTLD AS X86ASM AR LD STRIP CP WINDRES NVCC 
BIN2C METALCC METALLIB
 SILENT = DEPCC DEPHOSTCC DEPAS DEPX86ASM RANLIB RM
 
 MSG= $@

base-commit: 85706f5136cf7c88f95843b2634dd3f7d7d2cb6d
-- 
2.39.3 (Apple Git-146)
___
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] avcodec/pcm-dvdenc: use av_assert_unreachable

2024-07-12 Thread Marvin Scholz
Fixes a compiler warning about quant possibly being uninitialised.
---
 libavcodec/pcm-dvdenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c
index 71e9b6915a..f553d8076a 100644
--- a/libavcodec/pcm-dvdenc.c
+++ b/libavcodec/pcm-dvdenc.c
@@ -58,7 +58,7 @@ static av_cold int pcm_dvd_encode_init(AVCodecContext *avctx)
 quant = 2;
 break;
 default:
-av_assert1(0);
+av_assert_unreachable();
 }
 
 avctx->bits_per_coded_sample = 16 + quant * 4;
-- 
2.39.3 (Apple Git-146)
___
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/af_afftdn: use av_assert_unreachable

2024-07-12 Thread Marvin Scholz
Fixes a compiler warning about mag possibly being uninitialised.
---
 libavfilter/af_afftdn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index a2e6ca6107..f26b620cfb 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -378,7 +378,7 @@ static void process_frame(AVFilterContext *ctx,
 noisy_data[i] = mag = hypot(fft_data_dbl[i].re, 
fft_data_dbl[i].im);
 break;
 default:
-av_assert2(0);
+av_assert_unreachable();
 }
 
 power = mag * mag;
-- 
2.39.3 (Apple Git-146)


___
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] avutil/avassert: Add av_assert_unreachable()

2024-07-12 Thread Marvin Scholz
---
 libavutil/avassert.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavutil/avassert.h b/libavutil/avassert.h
index 1895fb7551..cdab912fe4 100644
--- a/libavutil/avassert.h
+++ b/libavutil/avassert.h
@@ -75,4 +75,16 @@
  */
 void av_assert0_fpu(void);
 
+/**
+ * Assert this can not be reached
+ */
+#if AV_HAS_BUILTIN(__builtin_unreachable)
+#define av_assert_unreachable() do {   \
+av_assert2(0);  \
+__builtin_unreachable();\
+} while (0)
+#else
+#define av_assert_unreachable() av_assert2(0)
+#endif
+
 #endif /* AVUTIL_AVASSERT_H */

base-commit: 85706f5136cf7c88f95843b2634dd3f7d7d2cb6d
-- 
2.39.3 (Apple Git-146)


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

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


[FFmpeg-devel] [PATCH 11/11] avfilter/yadif_common: fix mixed declaration and code

2024-07-12 Thread Marvin Scholz
Fix a "mixing declarations and code is incompatible with standards
before C99" warning.
---
 libavfilter/vf_yadif_videotoolbox.m | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_yadif_videotoolbox.m 
b/libavfilter/vf_yadif_videotoolbox.m
index eb7026395e..5cc7585f3f 100644
--- a/libavfilter/vf_yadif_videotoolbox.m
+++ b/libavfilter/vf_yadif_videotoolbox.m
@@ -205,6 +205,7 @@ static av_cold int do_init(AVFilterContext *ctx) 
API_AVAILABLE(macos(10.11), ios
 YADIFVTContext *s = ctx->priv;
 NSError *err = nil;
 CVReturn ret;
+dispatch_data_t libData;
 
 s->mtlDevice = MTLCreateSystemDefaultDevice();
 if (!s->mtlDevice) {
@@ -214,7 +215,7 @@ static av_cold int do_init(AVFilterContext *ctx) 
API_AVAILABLE(macos(10.11), ios
 
 av_log(ctx, AV_LOG_INFO, "Using Metal device: %s\n", 
s->mtlDevice.name.UTF8String);
 
-dispatch_data_t libData = dispatch_data_create(
+libData = dispatch_data_create(
 ff_vf_yadif_videotoolbox_metallib_data,
 ff_vf_yadif_videotoolbox_metallib_len,
 nil,
-- 
2.39.3 (Apple Git-146)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 10/11] avfilter/yadif_common: remove unused variable

2024-07-12 Thread Marvin Scholz
---
 libavfilter/vf_yadif_videotoolbox.m | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavfilter/vf_yadif_videotoolbox.m 
b/libavfilter/vf_yadif_videotoolbox.m
index c47d3edfb8..eb7026395e 100644
--- a/libavfilter/vf_yadif_videotoolbox.m
+++ b/libavfilter/vf_yadif_videotoolbox.m
@@ -172,7 +172,6 @@ static void filter(AVFilterContext *ctx, AVFrame *dst,
 static av_cold void do_uninit(AVFilterContext *ctx) 
API_AVAILABLE(macos(10.11), ios(8.0))
 {
 YADIFVTContext *s = ctx->priv;
-YADIFContext *y = >yadif;
 
 ff_yadif_uninit(ctx);
 
-- 
2.39.3 (Apple Git-146)


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

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


[FFmpeg-devel] [PATCH 09/11] avfilter/vf_coreimage: silence AVFrame deprecation warnings

2024-07-12 Thread Marvin Scholz
Deprecation warning need to be disabled here as we set deprecated
fields.
---
 libavfilter/vf_coreimage.m | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m
index 38355414bd..45b16cc48a 100644
--- a/libavfilter/vf_coreimage.m
+++ b/libavfilter/vf_coreimage.m
@@ -296,14 +296,18 @@ static int request_frame(AVFilterLink *link)
 
 frame->pts = ctx->pts;
 frame->duration= 1;
+frame->flags  |= AV_FRAME_FLAG_KEY;
+frame->flags  &= ~AV_FRAME_FLAG_INTERLACED;
+
+FF_DISABLE_DEPRECATION_WARNINGS
 #if FF_API_FRAME_KEY
 frame->key_frame   = 1;
 #endif
-frame->flags  |= AV_FRAME_FLAG_KEY;
 #if FF_API_INTERLACED_FRAME
 frame->interlaced_frame= 0;
 #endif
-frame->flags  &= ~AV_FRAME_FLAG_INTERLACED;
+FF_ENABLE_DEPRECATION_WARNINGS
+
 frame->pict_type   = AV_PICTURE_TYPE_I;
 frame->sample_aspect_ratio = ctx->sar;
 
-- 
2.39.3 (Apple Git-146)


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

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


[FFmpeg-devel] [PATCH 08/11] avfilter/vf_coreimage: simplify list_filters code

2024-07-12 Thread Marvin Scholz
Use fast-enumeration and get rid of unnecessary intermediate variables.
---
 libavfilter/vf_coreimage.m | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m
index bfc17764b5..38355414bd 100644
--- a/libavfilter/vf_coreimage.m
+++ b/libavfilter/vf_coreimage.m
@@ -102,18 +102,13 @@ static void list_filters(CoreImageContext *ctx)
 filter_categories = [NSArray arrayWithObjects:kCICategoryGenerator, 
nil];
 }
 
-NSArray *filter_names = [CIFilter 
filterNamesInCategories:filter_categories];
-NSEnumerator *filters = [filter_names objectEnumerator];
-
-NSString *filter_name;
-while (filter_name = [filters nextObject]) {
-CIFilter *filter = [CIFilter filterWithName:filter_name];
-NSDictionary *filter_attribs = [filter attributes]; // 
-NSArray  *filter_inputs  = [filter inputKeys];  // 
+for (NSString *filter_name in [CIFilter 
filterNamesInCategories:filter_categories]) {
+CIFilter *filter = [CIFilter filterWithName:filter_name];
+NSDictionary *filter_attribs = [filter attributes];
 
 av_log(ctx, AV_LOG_INFO, "Filter: %s\n", [filter_name UTF8String]);
 
-for (NSString *input in filter_inputs) {
+for (NSString *input in [filter inputKeys]) {
 NSDictionary *input_attribs = [filter_attribs valueForKey:input];
 NSString *input_class   = [input_attribs 
valueForKey:kCIAttributeClass];
 if ([input_class isEqualToString:@"NSNumber"]) {
-- 
2.39.3 (Apple Git-146)


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

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


[FFmpeg-devel] [PATCH 07/11] avfilter/vf_coreimage: fix mixed declaration and code

2024-07-12 Thread Marvin Scholz
Fix several "mixing declarations and code is incompatible with
standards before C99" warnings.
---
 libavfilter/vf_coreimage.m | 60 ++
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m
index 4d4cdfb7c7..bfc17764b5 100644
--- a/libavfilter/vf_coreimage.m
+++ b/libavfilter/vf_coreimage.m
@@ -66,6 +66,7 @@
 static int config_output(AVFilterLink *link)
 {
 CoreImageContext *ctx = link->src->priv;
+const AVPixFmtDescriptor *desc;
 
 link->w   = ctx->w;
 link->h   = ctx->h;
@@ -73,7 +74,7 @@ static int config_output(AVFilterLink *link)
 link->frame_rate  = ctx->frame_rate;
 link->time_base   = ctx->time_base;
 
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
+desc   = av_pix_fmt_desc_get(link->format);
 ctx->bits_per_component= av_get_bits_per_pixel(desc) / 
desc->nb_components;
 
 return 0;
@@ -106,14 +107,13 @@ static void list_filters(CoreImageContext *ctx)
 
 NSString *filter_name;
 while (filter_name = [filters nextObject]) {
-av_log(ctx, AV_LOG_INFO, "Filter: %s\n", [filter_name UTF8String]);
-NSString *input;
-
 CIFilter *filter = [CIFilter filterWithName:filter_name];
 NSDictionary *filter_attribs = [filter attributes]; // 
 NSArray  *filter_inputs  = [filter inputKeys];  // 
 
-for (input in filter_inputs) {
+av_log(ctx, AV_LOG_INFO, "Filter: %s\n", [filter_name UTF8String]);
+
+for (NSString *input in filter_inputs) {
 NSDictionary *input_attribs = [filter_attribs valueForKey:input];
 NSString *input_class   = [input_attribs 
valueForKey:kCIAttributeClass];
 if ([input_class isEqualToString:@"NSNumber"]) {
@@ -139,6 +139,11 @@ static void list_filters(CoreImageContext *ctx)
 static int apply_filter(CoreImageContext *ctx, AVFilterLink *link, AVFrame 
*frame)
 {
 int i;
+CGImageRef out;
+CGRect out_rect;
+CIFilter *filter= NULL;
+CIImage  *filter_input  = (__bridge CIImage*)ctx->input_image;
+CIImage  *filter_output = NULL;
 
 // (re-)initialize input image
 const CGSize frame_size = {
@@ -150,26 +155,22 @@ static int apply_filter(CoreImageContext *ctx, 
AVFilterLink *link, AVFrame *fram
length:frame->height*frame->linesize[0]
freeWhenDone:NO];
 
-CIImage *ret = [(__bridge CIImage*)ctx->input_image initWithBitmapData:data
-
bytesPerRow:frame->linesize[0]
-size:frame_size
-format:kCIFormatARGB8
-
colorSpace:ctx->color_space]; //kCGColorSpaceGenericRGB
+CIImage *ret = [filter_input initWithBitmapData:data
+ bytesPerRow:frame->linesize[0]
+ size:frame_size
+ format:kCIFormatARGB8
+ colorSpace:ctx->color_space]; 
//kCGColorSpaceGenericRGB
 if (!ret) {
 av_log(ctx, AV_LOG_ERROR, "Input image could not be initialized.\n");
 return AVERROR_EXTERNAL;
 }
 
-CIFilter *filter   = NULL;
-CIImage *filter_input  = (__bridge CIImage*)ctx->input_image;
-CIImage *filter_output = NULL;
-
 // successively apply all filters
 for (i = 0; i < ctx->num_filters; i++) {
 if (i) {
 // set filter input to previous filter output
 filter_input= [(__bridge CIImage*)ctx->filters[i-1] 
valueForKey:kCIOutputImageKey];
-CGRect out_rect = [filter_input extent];
+out_rect = [filter_input extent];
 if (out_rect.size.width > frame->width || out_rect.size.height > 
frame->height) {
 // do not keep padded image regions after filtering
 out_rect.origin.x= 0.0f;
@@ -206,7 +207,7 @@ static int apply_filter(CoreImageContext *ctx, AVFilterLink 
*link, AVFrame *fram
 }
 
 // do not keep padded image regions after filtering
-CGRect out_rect = [filter_output extent];
+out_rect = [filter_output extent];
 if (out_rect.size.width > frame->width || out_rect.size.height > 
frame->height) {
 av_log(ctx, AV_LOG_DEBUG, "Cropping output image.\n");
 out_rect.origin.x= 0.0f;
@@ -215,8 +216,8 @@ static int apply_filter(CoreImageContext *ctx, AVFilterLink 
*link, AVFrame *fram
 out_rect.size.height = frame->height;
 }
 
-CGImageRef out = [(__bridge CIContext*)ctx->glctx 
createCGImage:filter_output
-  fromRect:out_rect];
+out = [(__bridge CIContext*)ctx->glctx 

[FFmpeg-devel] [PATCH 06/11] lavfi/metal: simplify fallback

2024-07-12 Thread Marvin Scholz
Instead of using a fallback variable, just do an early return.
---
 libavfilter/metal/utils.m | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavfilter/metal/utils.m b/libavfilter/metal/utils.m
index d5c85e619d..6a9e5ef7cf 100644
--- a/libavfilter/metal/utils.m
+++ b/libavfilter/metal/utils.m
@@ -24,7 +24,6 @@ void ff_metal_compute_encoder_dispatch(id device,
id encoder,
NSUInteger width, NSUInteger height)
 {
-BOOL fallback = YES;
 MTLSize threadsPerThreadgroup;
 NSUInteger w, h;
 
@@ -39,11 +38,13 @@ void ff_metal_compute_encoder_dispatch(id device,
 if ([device supportsFamily:MTLGPUFamilyCommon3]) {
 MTLSize threadsPerGrid = MTLSizeMake(width, height, 1);
 [encoder dispatchThreads:threadsPerGrid 
threadsPerThreadgroup:threadsPerThreadgroup];
-fallback = NO;
+return;
 }
 }
 #endif
-if (fallback) {
+
+// Fallback path, if we took the above one we already returned so none of 
this is reached
+{
 MTLSize threadgroups = MTLSizeMake((width + w - 1) / w,
(height + h - 1) / h,
1);
-- 
2.39.3 (Apple Git-146)


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

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


[FFmpeg-devel] [PATCH 05/11] lavfi/metal: fix mixed declaration and code

2024-07-12 Thread Marvin Scholz
Fix a "mixing declarations and code is incompatible with standards
before C99" warning.
---
 libavfilter/metal/utils.m | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavfilter/metal/utils.m b/libavfilter/metal/utils.m
index f365d3ceea..d5c85e619d 100644
--- a/libavfilter/metal/utils.m
+++ b/libavfilter/metal/utils.m
@@ -24,11 +24,15 @@ void ff_metal_compute_encoder_dispatch(id device,
id encoder,
NSUInteger width, NSUInteger height)
 {
-[encoder setComputePipelineState:pipeline];
-NSUInteger w = pipeline.threadExecutionWidth;
-NSUInteger h = pipeline.maxTotalThreadsPerThreadgroup / w;
-MTLSize threadsPerThreadgroup = MTLSizeMake(w, h, 1);
 BOOL fallback = YES;
+MTLSize threadsPerThreadgroup;
+NSUInteger w, h;
+
+[encoder setComputePipelineState:pipeline];
+w = pipeline.threadExecutionWidth;
+h = pipeline.maxTotalThreadsPerThreadgroup / w;
+threadsPerThreadgroup = MTLSizeMake(w, h, 1);
+
 // MAC_OS_X_VERSION_10_15 is only defined on SDKs new enough to include 
its functionality (including iOS, tvOS, etc)
 #ifdef MAC_OS_X_VERSION_10_15
 if (@available(macOS 10.15, iOS 11, tvOS 14.5, *)) {
-- 
2.39.3 (Apple Git-146)


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

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


[FFmpeg-devel] [PATCH 04/11] avdevice/avfoundation: remove write-only variable

2024-07-12 Thread Marvin Scholz
The block_buffer was only ever written to but then never used in the
following code, making it unnecessary.

Fixes a "variable 'block_buffer' set but not used" compiler warning.
---
 libavdevice/avfoundation.m | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 17900d39d9..72a7f24b7d 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -632,7 +632,6 @@ static int get_video_config(AVFormatContext *s)
 {
 AVFContext *ctx = (AVFContext*)s->priv_data;
 CVImageBufferRef image_buffer;
-CMBlockBufferRef block_buffer;
 CGSize image_buffer_size;
 AVStream* stream = avformat_new_stream(s, NULL);
 
@@ -652,7 +651,6 @@ static int get_video_config(AVFormatContext *s)
 avpriv_set_pts_info(stream, 64, 1, avf_time_base);
 
 image_buffer = CMSampleBufferGetImageBuffer(ctx->current_frame);
-block_buffer = CMSampleBufferGetDataBuffer(ctx->current_frame);
 
 if (image_buffer) {
 image_buffer_size = CVImageBufferGetEncodedSize(image_buffer);
-- 
2.39.3 (Apple Git-146)


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

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


[FFmpeg-devel] [PATCH 03/11] avdevice/avfoundation: fix mixed declarations and code

2024-07-12 Thread Marvin Scholz
Fix several "mixing declarations and code is incompatible with standards
before C99" warnings.
---
 libavdevice/avfoundation.m | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index c5a09c6563..17900d39d9 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -680,6 +680,7 @@ static int get_audio_config(AVFormatContext *s)
 {
 AVFContext *ctx = (AVFContext*)s->priv_data;
 CMFormatDescriptionRef format_desc;
+const AudioStreamBasicDescription *basic_desc;
 AVStream* stream = avformat_new_stream(s, NULL);
 
 if (!stream) {
@@ -698,7 +699,7 @@ static int get_audio_config(AVFormatContext *s)
 avpriv_set_pts_info(stream, 64, 1, avf_time_base);
 
 format_desc = CMSampleBufferGetFormatDescription(ctx->current_audio_frame);
-const AudioStreamBasicDescription *basic_desc = 
CMAudioFormatDescriptionGetStreamBasicDescription(format_desc);
+basic_desc = 
CMAudioFormatDescriptionGetStreamBasicDescription(format_desc);
 
 if (!basic_desc) {
 unlock_frames(ctx);
@@ -765,7 +766,9 @@ static int get_audio_config(AVFormatContext *s)
 
 static NSArray* getDevicesWithMediaType(AVMediaType mediaType) {
 #if ((TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 10) || 
(TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500))
+AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession;
 NSMutableArray *deviceTypes = nil;
+
 if (mediaType == AVMediaTypeVideo) {
 deviceTypes = [NSMutableArray 
arrayWithArray:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]];
 #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 10)
@@ -810,7 +813,7 @@ static int get_audio_config(AVFormatContext *s)
 return nil;
 }
 
-AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession =
+captureDeviceDiscoverySession =
 [AVCaptureDeviceDiscoverySession
 discoverySessionWithDeviceTypes:deviceTypes
   mediaType:mediaType
@@ -899,8 +902,9 @@ static int avf_read_header(AVFormatContext *s)
 } else if (ctx->video_device_index < ctx->num_video_devices + 
num_screens) {
 #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 CGDirectDisplayID screens[num_screens];
+AVCaptureScreenInput* capture_screen_input;
 CGGetActiveDisplayList(num_screens, screens, _screens);
-AVCaptureScreenInput* capture_screen_input = 
[[[AVCaptureScreenInput alloc] 
initWithDisplayID:screens[ctx->video_device_index - ctx->num_video_devices]] 
autorelease];
+capture_screen_input = [[[AVCaptureScreenInput alloc] 
initWithDisplayID:screens[ctx->video_device_index - ctx->num_video_devices]] 
autorelease];
 
 if (ctx->framerate.num > 0) {
 capture_screen_input.minFrameDuration = 
CMTimeMake(ctx->framerate.den, ctx->framerate.num);
@@ -954,8 +958,9 @@ static int avf_read_header(AVFormatContext *s)
 int idx;
 if(sscanf(ctx->video_filename, "Capture screen %d", ) && idx < 
num_screens) {
 CGDirectDisplayID screens[num_screens];
+AVCaptureScreenInput* capture_screen_input;
 CGGetActiveDisplayList(num_screens, screens, _screens);
-AVCaptureScreenInput* capture_screen_input = 
[[[AVCaptureScreenInput alloc] initWithDisplayID:screens[idx]] autorelease];
+capture_screen_input = [[[AVCaptureScreenInput alloc] 
initWithDisplayID:screens[idx]] autorelease];
 video_device = (AVCaptureDevice*) capture_screen_input;
 ctx->video_device_index = ctx->num_video_devices + idx;
 ctx->video_is_screen = 1;
@@ -1123,10 +1128,12 @@ static int avf_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 do {
 CVImageBufferRef image_buffer;
 CMBlockBufferRef block_buffer;
+CMItemCount count;
+CMSampleTimingInfo timing_info;
 lock_frames(ctx);
 
 if (ctx->current_frame != nil) {
-int status;
+int status = 0;
 int length = 0;
 
 image_buffer = CMSampleBufferGetImageBuffer(ctx->current_frame);
@@ -1146,9 +1153,6 @@ static int avf_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 return AVERROR(EIO);
 }
 
-CMItemCount count;
-CMSampleTimingInfo timing_info;
-
 if 
(CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_frame, 1, 
_info, ) == noErr) {
 AVRational timebase_q = av_make_q(1, 
timing_info.presentationTimeStamp.timescale);
 pkt->pts = pkt->dts = 
av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q, 
avf_time_base_q);
@@ -1160,7 +1164,6 @@ static int avf_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (image_buffer) {
 status = 

[FFmpeg-devel] [PATCH 02/11] avfilter/af_channelsplit: fix mixed declaration and code

2024-07-12 Thread Marvin Scholz
Fix a "mixing declarations and code is incompatible with standards
before C99" warning.
---
 libavfilter/af_channelsplit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_channelsplit.c b/libavfilter/af_channelsplit.c
index 43b2667750..b91195a4c6 100644
--- a/libavfilter/af_channelsplit.c
+++ b/libavfilter/af_channelsplit.c
@@ -151,6 +151,7 @@ static int query_formats(AVFilterContext *ctx)
 
 static int filter_frame(AVFilterLink *outlink, AVFrame *buf)
 {
+AVFrame *buf_out;
 AVFilterContext *ctx = outlink->src;
 ChannelSplitContext *s = ctx->priv;
 const int i = FF_OUTLINK_IDX(outlink);
@@ -159,7 +160,7 @@ static int filter_frame(AVFilterLink *outlink, AVFrame *buf)
 
 av_assert1(channel >= 0);
 
-AVFrame *buf_out = av_frame_clone(buf);
+buf_out = av_frame_clone(buf);
 if (!buf_out)
 return AVERROR(ENOMEM);
 
-- 
2.39.3 (Apple Git-146)


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

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


[FFmpeg-devel] [PATCH 01/11] avdevice/audiotoolbox: fix mixed declaration and code

2024-07-12 Thread Marvin Scholz
Fix a bunch of "mixing declarations and code is incompatible with
standards before C99" warnings.
---
 libavdevice/audiotoolbox.m | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavdevice/audiotoolbox.m b/libavdevice/audiotoolbox.m
index 7d95c34593..dd607589b4 100644
--- a/libavdevice/audiotoolbox.m
+++ b/libavdevice/audiotoolbox.m
@@ -77,6 +77,9 @@ static av_cold int at_write_header(AVFormatContext *avctx)
 ATContext *ctx = (ATContext*)avctx->priv_data;
 OSStatus err = noErr;
 CFStringRef device_UID = NULL;
+const char *stream_name = avctx->url;
+AVCodecParameters *codecpar = avctx->streams[0]->codecpar;
+AudioStreamBasicDescription device_format = {0};
 AudioDeviceID *devices;
 int num_devices;
 
@@ -133,7 +136,6 @@ static av_cold int at_write_header(AVFormatContext *avctx)
 
 // get user-defined device UID or use default device
 // -audio_device_index overrides any URL given
-const char *stream_name = avctx->url;
 if (stream_name && ctx->audio_device_index == -1) {
 sscanf(stream_name, "%d", >audio_device_index);
 }
@@ -163,10 +165,8 @@ static av_cold int at_write_header(AVFormatContext *avctx)
 }
 
 av_freep();
-AVCodecParameters *codecpar = avctx->streams[0]->codecpar;
 
 // audio format
-AudioStreamBasicDescription device_format = {0};
 device_format.mSampleRate= codecpar->sample_rate;
 device_format.mFormatID  = kAudioFormatLinearPCM;
 device_format.mFormatFlags  |= (codecpar->format == AV_SAMPLE_FMT_FLT) 
? kLinearPCMFormatFlagIsFloat : 0;
@@ -237,6 +237,7 @@ static av_cold int at_write_header(AVFormatContext *avctx)
 
 static int at_write_packet(AVFormatContext *avctx, AVPacket *pkt)
 {
+AudioQueueBufferRef buf;
 ATContext *ctx = (ATContext*)avctx->priv_data;
 OSStatus err = noErr;
 
@@ -256,7 +257,7 @@ static int at_write_packet(AVFormatContext *avctx, AVPacket 
*pkt)
 }
 }
 
-AudioQueueBufferRef buf = ctx->buffer[ctx->cur_buf];
+buf = ctx->buffer[ctx->cur_buf];
 
 // copy audio data into buffer and enqueue the buffer
 memcpy(buf->mAudioData, pkt->data, buf->mAudioDataBytesCapacity);

base-commit: 85706f5136cf7c88f95843b2634dd3f7d7d2cb6d
-- 
2.39.3 (Apple Git-146)


___
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/hwcontext_videotoolbox: Fix build with older SDKs

2024-07-09 Thread Marvin Scholz
I've accidentally used API not available on the checked version.
Additionally check for the SDK to be new enough to even have the
CVImageBufferCreateColorSpaceFromAttachments API to not fail
the build.
---
 libavutil/hwcontext_videotoolbox.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_videotoolbox.c 
b/libavutil/hwcontext_videotoolbox.c
index 953155ce32..ab7556936d 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -588,13 +588,26 @@ static int vt_pixbuf_set_colorspace(void *log_ctx,
 } else
 CVBufferRemoveAttachment(pixbuf, kCVImageBufferGammaLevelKey);
 
+#if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 100800) || \
+(TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 10)
 if (__builtin_available(macOS 10.8, iOS 10, *)) {
-CFDictionaryRef attachments = CVBufferCopyAttachments(pixbuf, 
kCVAttachmentMode_ShouldPropagate);
+CFDictionaryRef attachments = NULL;
+if (__builtin_available(macOS 12.0, iOS 15.0, *))
+attachments = CVBufferCopyAttachments(pixbuf, 
kCVAttachmentMode_ShouldPropagate);
+#if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED <= 12) || \
+(TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED <= 15)
+else {
+CFDictionaryRef tmp = CVBufferGetAttachments(pixbuf, 
kCVAttachmentMode_ShouldPropagate);
+if (tmp)
+attachments = CFDictionaryCreateCopy(NULL, tmp);
+}
+#endif
 if (attachments) {
 colorspace = 
CVImageBufferCreateColorSpaceFromAttachments(attachments);
 CFRelease(attachments);
 }
 }
+#endif
 
 if (colorspace) {
 CVBufferSetAttachment(pixbuf, kCVImageBufferCGColorSpaceKey,

base-commit: 9fb8d13d56f20728141fd7070d8a325720727d57
-- 
2.39.3 (Apple Git-146)
___
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/aacdec_usac: Fix array size

2024-07-02 Thread Marvin Scholz
The array in ff_aac_usac_mdst_filt_cur that is passed to that has a size
of 7 elements, not 6 and the code in the function accesses the array at
index 6, which would be out of bounds if the size was actually 6.

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

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 4856c1786b..32b3c534bf 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -1134,7 +1134,7 @@ static void complex_stereo_downmix_cur(AACDecContext *ac, 
ChannelElement *cpe,
 }
 }
 
-static void complex_stereo_interpolate_imag(float *im, float *re, const float 
f[6],
+static void complex_stereo_interpolate_imag(float *im, float *re, const float 
f[7],
 int len, int factor_even, int 
factor_odd)
 {
 int i = 0;

base-commit: e783e45e29e78616debba7f6d1fe6e54dc336496
-- 
2.39.3 (Apple Git-146)
___
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] lavfi/perlin: Fix out of bounds stack buffer write

2024-07-02 Thread Marvin Scholz
An incorrect calculation in ff_perlin_init causes a write to the
stack array at index 256, which is out of bounds.

Fixes: CID1608711
---
 libavfilter/perlin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/perlin.c b/libavfilter/perlin.c
index 09bae7ad33..ffad8c1e4e 100644
--- a/libavfilter/perlin.c
+++ b/libavfilter/perlin.c
@@ -129,7 +129,7 @@ int ff_perlin_init(FFPerlin *perlin, double period, int 
octaves, double persiste
 for (i = 0; i < 256; i++) {
 unsigned int random_idx = av_lfg_get() % (256-i);
 uint8_t random_val = random_permutations[random_idx];
-random_permutations[random_idx] = random_permutations[256-i];
+random_permutations[random_idx] = random_permutations[255-i];
 
 perlin->permutations[i] = perlin->permutations[i+256] = random_val;
 }

base-commit: e783e45e29e78616debba7f6d1fe6e54dc336496
-- 
2.39.3 (Apple Git-146)
___
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 3/3] avutil/hwcontext_videotoolbox: Set CVBuffer CGColorSpace

2024-05-29 Thread Marvin Scholz
In addition to the other properties, try to obtain the right
CGColorSpace and set it as well, else it could lead to a CVBuffer
tagged as BT.2020 but with a CGColorSpace indicating BT.709.

Therefore it is essential for consistency to set a colorspace
according to the other values, or if none can be obtained (for example
because the other values are all unspecified) unset it as well.

Fix #10884
---
 libavutil/hwcontext_videotoolbox.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/libavutil/hwcontext_videotoolbox.c 
b/libavutil/hwcontext_videotoolbox.c
index 0af2ab822f..953155ce32 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -535,6 +535,7 @@ CFStringRef av_map_videotoolbox_color_trc_from_av(enum 
AVColorTransferCharacteri
 static int vt_pixbuf_set_colorspace(void *log_ctx,
 CVPixelBufferRef pixbuf, const AVFrame 
*src)
 {
+CGColorSpaceRef colorspace = NULL;
 CFStringRef colormatrix = NULL, colorpri = NULL, colortrc = NULL;
 Float32 gamma = 0;
 
@@ -587,6 +588,21 @@ static int vt_pixbuf_set_colorspace(void *log_ctx,
 } else
 CVBufferRemoveAttachment(pixbuf, kCVImageBufferGammaLevelKey);
 
+if (__builtin_available(macOS 10.8, iOS 10, *)) {
+CFDictionaryRef attachments = CVBufferCopyAttachments(pixbuf, 
kCVAttachmentMode_ShouldPropagate);
+if (attachments) {
+colorspace = 
CVImageBufferCreateColorSpaceFromAttachments(attachments);
+CFRelease(attachments);
+}
+}
+
+if (colorspace) {
+CVBufferSetAttachment(pixbuf, kCVImageBufferCGColorSpaceKey,
+colorspace, kCVAttachmentMode_ShouldPropagate);
+CFRelease(colorspace);
+} else
+CVBufferRemoveAttachment(pixbuf, kCVImageBufferCGColorSpaceKey);
+
 return 0;
 }
 
-- 
2.39.3 (Apple Git-146)
___
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/3] avutil/hwcontext_videotoolbox: Update documentation

2024-05-29 Thread Marvin Scholz
The documentation was not clear at all what specifically the
function does, so it was left unspecified if it will unset or
not touch attachments it could not map from the AVFrame.

The documentation of the return  value was wrong as well.
---
 libavutil/hwcontext_videotoolbox.h | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavutil/hwcontext_videotoolbox.h 
b/libavutil/hwcontext_videotoolbox.h
index 600e9f2c8d..d35cfbb6c1 100644
--- a/libavutil/hwcontext_videotoolbox.h
+++ b/libavutil/hwcontext_videotoolbox.h
@@ -90,8 +90,15 @@ CFStringRef av_map_videotoolbox_color_primaries_from_av(enum 
AVColorPrimaries pr
 CFStringRef av_map_videotoolbox_color_trc_from_av(enum 
AVColorTransferCharacteristic trc);
 
 /**
- * Update a CVPixelBufferRef's metadata to based on an AVFrame.
- * Returns 0 if no known equivalent was found.
+ * Set CVPixelBufferRef's metadata based on an AVFrame.
+ *
+ * Sets/unsets the CVPixelBuffer attachments to match as closely as possible 
the
+ * AVFrame metadata. To prevent inconsistent attachments, the attachments for 
properties
+ * that could not be matched or are unspecified in the given AVFrame are 
unset. So if
+ * any attachments already covered by AVFrame metadata need to be set to a 
specific
+ * value, this should happen after calling this function.
+ *
+ * Returns < 0 in case of an error.
  */
 int av_vt_pixbuf_set_attachments(void *log_ctx,
  CVPixelBufferRef pixbuf, const struct AVFrame 
*src);
-- 
2.39.3 (Apple Git-146)


___
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/3] avutil/hwcontext_videotoolbox: Unset undefined values

2024-05-29 Thread Marvin Scholz
When mapping AVFrame properties to the CVBuffer attachments, it is
necessary to properly delete undefined attachments, else we can
leave incorrect values in there guessed from VideoToolbox for
example, leading to inconsistent results where the AVFrame and
CVBuffer differ in metadata.

Ref #10884
---
 libavutil/hwcontext_videotoolbox.c | 76 --
 1 file changed, 41 insertions(+), 35 deletions(-)

diff --git a/libavutil/hwcontext_videotoolbox.c 
b/libavutil/hwcontext_videotoolbox.c
index 9f82b104c3..0af2ab822f 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -342,8 +342,10 @@ static int vt_pixbuf_set_par(void *log_ctx,
 CFNumberRef num = NULL, den = NULL;
 AVRational avpar = src->sample_aspect_ratio;
 
-if (avpar.num == 0)
+if (avpar.num == 0) {
+CVBufferRemoveAttachment(pixbuf, kCVImageBufferPixelAspectRatioKey);
 return 0;
+}
 
 av_reduce(, ,
 avpar.num, avpar.den,
@@ -423,7 +425,10 @@ static int vt_pixbuf_set_chromaloc(void *log_ctx,
 kCVImageBufferChromaLocationTopFieldKey,
 loc,
 kCVAttachmentMode_ShouldPropagate);
-}
+} else
+CVBufferRemoveAttachment(
+pixbuf,
+kCVImageBufferChromaLocationTopFieldKey);
 
 return 0;
 }
@@ -534,52 +539,53 @@ static int vt_pixbuf_set_colorspace(void *log_ctx,
 Float32 gamma = 0;
 
 colormatrix = av_map_videotoolbox_color_matrix_from_av(src->colorspace);
-if (!colormatrix && src->colorspace != AVCOL_SPC_UNSPECIFIED)
-av_log(log_ctx, AV_LOG_WARNING, "Color space %s is not supported.\n", 
av_color_space_name(src->colorspace));
+if (colormatrix)
+CVBufferSetAttachment(pixbuf, kCVImageBufferYCbCrMatrixKey,
+colormatrix, kCVAttachmentMode_ShouldPropagate);
+else {
+CVBufferRemoveAttachment(pixbuf, kCVImageBufferYCbCrMatrixKey);
+if (src->colorspace != AVCOL_SPC_UNSPECIFIED)
+av_log(log_ctx, AV_LOG_WARNING,
+"Color space %s is not supported.\n",
+av_color_space_name(src->colorspace));
+}
 
 colorpri = 
av_map_videotoolbox_color_primaries_from_av(src->color_primaries);
-if (!colorpri && src->color_primaries != AVCOL_PRI_UNSPECIFIED)
-av_log(log_ctx, AV_LOG_WARNING, "Color primaries %s is not 
supported.\n", av_color_primaries_name(src->color_primaries));
+if (colorpri)
+CVBufferSetAttachment(pixbuf, kCVImageBufferColorPrimariesKey,
+colorpri, kCVAttachmentMode_ShouldPropagate);
+else {
+CVBufferRemoveAttachment(pixbuf, kCVImageBufferColorPrimariesKey);
+if (src->color_primaries != AVCOL_SPC_UNSPECIFIED)
+av_log(log_ctx, AV_LOG_WARNING,
+"Color primaries %s is not supported.\n",
+av_color_primaries_name(src->color_primaries));
+}
 
 colortrc = av_map_videotoolbox_color_trc_from_av(src->color_trc);
-if (!colortrc && src->color_trc != AVCOL_TRC_UNSPECIFIED)
-av_log(log_ctx, AV_LOG_WARNING, "Color transfer function %s is not 
supported.\n", av_color_transfer_name(src->color_trc));
+if (colortrc)
+CVBufferSetAttachment(pixbuf, kCVImageBufferTransferFunctionKey,
+colorpri, kCVAttachmentMode_ShouldPropagate);
+else {
+CVBufferRemoveAttachment(pixbuf, kCVImageBufferTransferFunctionKey);
+if (src->color_trc != AVCOL_TRC_UNSPECIFIED)
+av_log(log_ctx, AV_LOG_WARNING,
+"Color transfer function %s is not supported.\n",
+av_color_transfer_name(src->color_trc));
+}
 
 if (src->color_trc == AVCOL_TRC_GAMMA22)
 gamma = 2.2;
 else if (src->color_trc == AVCOL_TRC_GAMMA28)
 gamma = 2.8;
 
-if (colormatrix) {
-CVBufferSetAttachment(
-pixbuf,
-kCVImageBufferYCbCrMatrixKey,
-colormatrix,
-kCVAttachmentMode_ShouldPropagate);
-}
-if (colorpri) {
-CVBufferSetAttachment(
-pixbuf,
-kCVImageBufferColorPrimariesKey,
-colorpri,
-kCVAttachmentMode_ShouldPropagate);
-}
-if (colortrc) {
-CVBufferSetAttachment(
-pixbuf,
-kCVImageBufferTransferFunctionKey,
-colortrc,
-kCVAttachmentMode_ShouldPropagate);
-}
 if (gamma != 0) {
 CFNumberRef gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, 
);
-CVBufferSetAttachment(
-pixbuf,
-kCVImageBufferGammaLevelKey,
-gamma_level,
-kCVAttachmentMode_ShouldPropagate);
+CVBufferSetAttachment(pixbuf, kCVImageBufferGammaLevelKey,
+gamma_level, kCVAttachmentMode_ShouldPropagate);
 CFRelease(gamma_level);
-}
+} else
+CVBufferRemoveAttachment(pixbuf, kCVImageBufferGammaLevelKey);
 
 return 0;
 }

base-commit: 

[FFmpeg-devel] [PATCH v2] avutil/hwcontext_videotoolbox: Set proper CVBuffer colorspace

2024-05-20 Thread Marvin Scholz
Fix #10884
---
 libavutil/hwcontext_videotoolbox.c | 54 +-
 1 file changed, 38 insertions(+), 16 deletions(-)

diff --git a/libavutil/hwcontext_videotoolbox.c 
b/libavutil/hwcontext_videotoolbox.c
index 9f82b104c3..4a35bfc7ff 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -530,6 +530,8 @@ CFStringRef av_map_videotoolbox_color_trc_from_av(enum 
AVColorTransferCharacteri
 static int vt_pixbuf_set_colorspace(void *log_ctx,
 CVPixelBufferRef pixbuf, const AVFrame 
*src)
 {
+CGColorSpaceRef colorspace = NULL;
+CFMutableDictionaryRef attachments = NULL;
 CFStringRef colormatrix = NULL, colorpri = NULL, colortrc = NULL;
 Float32 gamma = 0;
 
@@ -550,37 +552,57 @@ static int vt_pixbuf_set_colorspace(void *log_ctx,
 else if (src->color_trc == AVCOL_TRC_GAMMA28)
 gamma = 2.8;
 
+attachments = CFDictionaryCreateMutable(NULL, 0,
+ 
,
+ 
);
+if (!attachments)
+return AVERROR(ENOMEM);
+
 if (colormatrix) {
-CVBufferSetAttachment(
-pixbuf,
+CFDictionarySetValue(
+attachments,
 kCVImageBufferYCbCrMatrixKey,
-colormatrix,
-kCVAttachmentMode_ShouldPropagate);
+colormatrix);
 }
 if (colorpri) {
-CVBufferSetAttachment(
-pixbuf,
+CFDictionarySetValue(
+attachments,
 kCVImageBufferColorPrimariesKey,
-colorpri,
-kCVAttachmentMode_ShouldPropagate);
+colorpri);
 }
 if (colortrc) {
-CVBufferSetAttachment(
-pixbuf,
+CFDictionarySetValue(
+attachments,
 kCVImageBufferTransferFunctionKey,
-colortrc,
-kCVAttachmentMode_ShouldPropagate);
+colortrc);
 }
 if (gamma != 0) {
 CFNumberRef gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, 
);
-CVBufferSetAttachment(
-pixbuf,
+CFDictionarySetValue(
+attachments,
 kCVImageBufferGammaLevelKey,
-gamma_level,
-kCVAttachmentMode_ShouldPropagate);
+gamma_level);
 CFRelease(gamma_level);
 }
 
+if (__builtin_available(macOS 10.8, iOS 10, *))
+colorspace = CVImageBufferCreateColorSpaceFromAttachments(attachments);
+
+if (colorspace) {
+CFDictionarySetValue(
+attachments,
+kCVImageBufferCGColorSpaceKey,
+colorspace);
+CFRelease(colorspace);
+} else
+av_log(log_ctx, AV_LOG_WARNING, "Unable to set proper colorspace for 
the CVImageBuffer.\n");
+
+CVBufferSetAttachments(
+pixbuf,
+attachments,
+kCVAttachmentMode_ShouldPropagate);
+CFRelease(attachments);
+
 return 0;
 }
 

base-commit: 463c573e6b6489c588bee90124d5cf92db8ccaaa
-- 
2.39.3 (Apple Git-145)
___
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/hwcontext: Set proper CVBuffer colorspace

2024-05-19 Thread Marvin Scholz
Fix #10884
---
 libavutil/hwcontext_videotoolbox.c | 54 +-
 1 file changed, 38 insertions(+), 16 deletions(-)

diff --git a/libavutil/hwcontext_videotoolbox.c 
b/libavutil/hwcontext_videotoolbox.c
index 9f82b104c3..4a35bfc7ff 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -530,6 +530,8 @@ CFStringRef av_map_videotoolbox_color_trc_from_av(enum 
AVColorTransferCharacteri
 static int vt_pixbuf_set_colorspace(void *log_ctx,
 CVPixelBufferRef pixbuf, const AVFrame 
*src)
 {
+CGColorSpaceRef colorspace = NULL;
+CFMutableDictionaryRef attachments = NULL;
 CFStringRef colormatrix = NULL, colorpri = NULL, colortrc = NULL;
 Float32 gamma = 0;
 
@@ -550,37 +552,57 @@ static int vt_pixbuf_set_colorspace(void *log_ctx,
 else if (src->color_trc == AVCOL_TRC_GAMMA28)
 gamma = 2.8;
 
+attachments = CFDictionaryCreateMutable(NULL, 0,
+ 
,
+ 
);
+if (!attachments)
+return AVERROR(ENOMEM);
+
 if (colormatrix) {
-CVBufferSetAttachment(
-pixbuf,
+CFDictionarySetValue(
+attachments,
 kCVImageBufferYCbCrMatrixKey,
-colormatrix,
-kCVAttachmentMode_ShouldPropagate);
+colormatrix);
 }
 if (colorpri) {
-CVBufferSetAttachment(
-pixbuf,
+CFDictionarySetValue(
+attachments,
 kCVImageBufferColorPrimariesKey,
-colorpri,
-kCVAttachmentMode_ShouldPropagate);
+colorpri);
 }
 if (colortrc) {
-CVBufferSetAttachment(
-pixbuf,
+CFDictionarySetValue(
+attachments,
 kCVImageBufferTransferFunctionKey,
-colortrc,
-kCVAttachmentMode_ShouldPropagate);
+colortrc);
 }
 if (gamma != 0) {
 CFNumberRef gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, 
);
-CVBufferSetAttachment(
-pixbuf,
+CFDictionarySetValue(
+attachments,
 kCVImageBufferGammaLevelKey,
-gamma_level,
-kCVAttachmentMode_ShouldPropagate);
+gamma_level);
 CFRelease(gamma_level);
 }
 
+if (__builtin_available(macOS 10.8, iOS 10, *))
+colorspace = CVImageBufferCreateColorSpaceFromAttachments(attachments);
+
+if (colorspace) {
+CFDictionarySetValue(
+attachments,
+kCVImageBufferCGColorSpaceKey,
+colorspace);
+CFRelease(colorspace);
+} else
+av_log(log_ctx, AV_LOG_WARNING, "Unable to set proper colorspace for 
the CVImageBuffer.\n");
+
+CVBufferSetAttachments(
+pixbuf,
+attachments,
+kCVAttachmentMode_ShouldPropagate);
+CFRelease(attachments);
+
 return 0;
 }
 

base-commit: 463c573e6b6489c588bee90124d5cf92db8ccaaa
-- 
2.39.3 (Apple Git-145)
___
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] doc/developer: add examples to clarify code style

2024-05-18 Thread Marvin Scholz
Given the frequency that new developers, myself included, get the
code style wrong, it is useful to add some examples to clarify how
things should be done.
---
 doc/developer.texi | 57 +-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/doc/developer.texi b/doc/developer.texi
index 63835dfa06..d7bf3f9cb8 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -115,7 +115,7 @@ Objective-C where required for interacting with 
macOS-specific interfaces.
 
 @section Code formatting conventions
 
-There are the following guidelines regarding the indentation in files:
+There are the following guidelines regarding the code style in files:
 
 @itemize @bullet
 @item
@@ -135,6 +135,61 @@ K coding style is used.
 @end itemize
 The presentation is one inspired by 'indent -i4 -kr -nut'.
 
+@subsection Examples
+Some notable examples to illustrate common code style in FFmpeg:
+
+@itemize @bullet
+
+@item
+Spaces around @code{if}/@code{do}/@code{while}/@code{for} conditions and 
assigments:
+
+@example c
+if (condition)
+av_foo();
+@end example
+
+@example c
+for (size_t i = 0; i < len; i++)
+av_bar(i);
+@end example
+
+@example c
+size_t size = 0;
+@end example
+
+However no spaces between the parentheses and condition, unless it helps
+readability of complex conditions, so the following should not be done:
+
+@example c
+// Wrong:
+if ( cond )
+av_foo();
+@end example
+
+@item
+No unnecessary parentheses, unless it helps readability:
+
+@example c
+flags = s->mb_x ? RIGHT_EDGE : LEFT_EDGE | RIGHT_EDGE;
+@end example
+
+@item
+No braces around single-line blocks:
+
+@example c
+if (bits_pixel == 24)
+avctx->pix_fmt = AV_PIX_FMT_BGR24;
+else if (bits_pixel == 8)
+avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+else @{
+av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
+return AVERROR_INVALIDDATA;
+@}
+@end example
+
+@end itemize
+
+
 @subsection Vim configuration
 In order to configure Vim to follow FFmpeg formatting conventions, paste
 the following snippet into your @file{.vimrc}:

base-commit: 86e418ffd7bbdc0530e1e4d5bd7534b6e03b5b05
-- 
2.39.3 (Apple Git-145)
___
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] avdevice/avfoundation: fix macOS/iOS/tvOS SDK conditional checks

2024-04-17 Thread Marvin Scholz
This fixes the checks to properly use runtime feature detection and
check the SDK version (*_MAX_ALLOWED) instead of the targeted version
for the relevant APIs.

The target is still checked (*_MIN_REQUIRED) to avoid using deprecated
methods when targeting new enough versions.
---
 libavdevice/avfoundation.m | 164 ++---
 1 file changed, 116 insertions(+), 48 deletions(-)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index e558ad7d90..a52e7df37b 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -28,6 +28,7 @@
 #import 
 #include 
 
+#include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
@@ -764,57 +765,124 @@ static int get_audio_config(AVFormatContext *s)
 }
 
 static NSArray* getDevicesWithMediaType(AVMediaType mediaType) {
-#if ((TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 10) || 
(TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500))
-NSMutableArray *deviceTypes = nil;
-if (mediaType == AVMediaTypeVideo) {
-deviceTypes = [NSMutableArray 
arrayWithArray:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]];
-#if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 10)
-[deviceTypes addObject: AVCaptureDeviceTypeBuiltInDualCamera];
-[deviceTypes addObject: AVCaptureDeviceTypeBuiltInTelephotoCamera];
-#endif
-#if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110100)
-[deviceTypes addObject: AVCaptureDeviceTypeBuiltInTrueDepthCamera];
-#endif
-#if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 13)
-[deviceTypes addObject: AVCaptureDeviceTypeBuiltInTripleCamera];
-[deviceTypes addObject: AVCaptureDeviceTypeBuiltInDualWideCamera];
-[deviceTypes addObject: AVCaptureDeviceTypeBuiltInUltraWideCamera];
-#endif
-#if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED >= 13)
-[deviceTypes addObject: AVCaptureDeviceTypeDeskViewCamera];
-#endif
-#if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150400)
-[deviceTypes addObject: 
AVCaptureDeviceTypeBuiltInLiDARDepthCamera];
-#endif
-#if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 17 || 
(TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED >= 14))
-[deviceTypes addObject: AVCaptureDeviceTypeContinuityCamera];
-#endif
-} else if (mediaType == AVMediaTypeAudio) {
-#if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 17 || 
(TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED >= 14))
-deviceTypes = [NSMutableArray 
arrayWithArray:@[AVCaptureDeviceTypeMicrophone]];
-#else
-deviceTypes = [NSMutableArray 
arrayWithArray:@[AVCaptureDeviceTypeBuiltInMicrophone]];
-#endif
-} else if (mediaType == AVMediaTypeMuxed) {
-#if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 17 || 
(TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED >= 14))
-deviceTypes = [NSMutableArray 
arrayWithArray:@[AVCaptureDeviceTypeExternal]];
-#elif (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 14)
-deviceTypes = [NSMutableArray 
arrayWithArray:@[AVCaptureDeviceTypeExternalUnknown]];
-#else
+
+#if (TARGET_OS_OSX&& defined(__MAC_10_15)   && 
MAC_OS_X_VERSION_MAX_ALLOWED>= __MAC_10_15) || \
+(TARGET_OS_IOS&& defined(__IPHONE_10_0) && 
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0) || \
+(TARGET_OS_TV && defined(__TVOS_17_0)   && __TV_OS_VERSION_MAX_ALLOWED 
>= __TVOS_17_0)
+if (__builtin_available(macOS 10.15, iOS 10, tvOS 17, *)) {
+
+NSMutableArray *deviceTypes = nil;
+
+if (mediaType == AVMediaTypeVideo) {
+deviceTypes = [NSMutableArray 
arrayWithArray:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]];
+
+#if (TARGET_OS_IOS || TARGET_OS_TV)
+// Devices only available on iOS/tvOS
+[deviceTypes addObject: AVCaptureDeviceTypeBuiltInDualCamera];
+[deviceTypes addObject: 
AVCaptureDeviceTypeBuiltInTelephotoCamera];
+
+#if (TARGET_OS_IOS && defined(__IPHONE_11_1) && 
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_1) || \
+(TARGET_OS_TV  && defined(__TVOS_17_0)   && 
__TV_OS_VERSION_MAX_ALLOWED >= __TVOS_17_0)
+if (__builtin_available(iOS 11.1, tvOS 17, *)) {
+[deviceTypes addObject: 
AVCaptureDeviceTypeBuiltInTrueDepthCamera];
+}
+#endif
+
+#if (TARGET_OS_IOS && defined(__IPHONE_13_0) && 
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0) || \
+(TARGET_OS_TV  && defined(__TVOS_17_0)   && 
__TV_OS_VERSION_MAX_ALLOWED >= __TVOS_17_0)
+

[FFmpeg-devel] [PATCH 2/2] fate: enhance tpad filter test

2023-11-07 Thread Marvin Scholz
Adds another test that uses the start_duration and stop_duration
options instead of start and stop.
---
 tests/fate/filter-video.mak |  3 ++-
 tests/ref/fate/filter-tpad-add-duration | 11 +++
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/filter-tpad-add-duration

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 789ec6414c..58edc70f46 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -299,9 +299,10 @@ fate-filter-tblend: CMD = framecrc -c:v pgmyuv -i $(SRC) 
-vf tblend=all_mode=dif
 FATE_FILTER_VSYNTH_PGMYUV-$(CONFIG_TELECINE_FILTER) += fate-filter-telecine
 fate-filter-telecine: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf telecine
 
-FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC2 TPAD) += fate-filter-tpad-add 
fate-filter-tpad-clone
+FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC2 TPAD) += fate-filter-tpad-add 
fate-filter-tpad-clone fate-filter-tpad-add-duration
 fate-filter-tpad-add:   CMD = framecrc -lavfi 
testsrc2=d=1:r=2,tpad=start=1:stop=3:color=gray
 fate-filter-tpad-clone: CMD = framecrc -lavfi 
testsrc2=d=1:r=2,tpad=start=1:stop=2:stop_mode=clone:color=black
+fate-filter-tpad-add-duration: CMD = framecrc -lavfi 
testsrc2=d=1:r=2,tpad=start_duration=0.5s:stop_duration=1.5s:color=gray
 
 FATE_FILTER_VSYNTH_PGMYUV-$(CONFIG_TRANSPOSE_FILTER) += fate-filter-transpose
 fate-filter-transpose: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf transpose
diff --git a/tests/ref/fate/filter-tpad-add-duration 
b/tests/ref/fate/filter-tpad-add-duration
new file mode 100644
index 00..10e01655a1
--- /dev/null
+++ b/tests/ref/fate/filter-tpad-add-duration
@@ -0,0 +1,11 @@
+#tb 0: 1/2
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 320x240
+#sar 0: 1/1
+0,  0,  0,1,   115200, 0x2213b502
+0,  1,  1,1,   115200, 0xeba70ff3
+0,  2,  2,1,   115200, 0xa764e4d5
+0,  3,  3,1,   115200, 0x2213b502
+0,  4,  4,1,   115200, 0x2213b502
+0,  5,  5,1,   115200, 0x2213b502
-- 
2.39.3 (Apple Git-145)

___
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] avfilter/vf_tpad: fix check for drawing initialization

2023-11-07 Thread Marvin Scholz
The check if drawing needs to be initialized and supported formats
should be drawable ones was flawed, as pad_stop/pad_start is only
populated from stop_duration/start_duration after these checks.

To fix that, check the _duration variants as well and for better
readability and maintainability break the check out into its own
helper.

Fixes a regression from 86b252ea9dee18006910e30646ad1067f2d1323f
Fix #10621
---
 libavfilter/vf_tpad.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index 7990403e81..1efe4ec479 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -70,11 +70,17 @@ static const AVOption tpad_options[] = {
 
 AVFILTER_DEFINE_CLASS(tpad);
 
+static int needs_drawing(const TPadContext *s) {
+return (
+(s->stop_mode  == MODE_ADD && (s->pad_stop  != 0 || s->stop_duration  
!= 0)) ||
+(s->start_mode == MODE_ADD && (s->pad_start != 0 || s->start_duration 
!= 0))
+);
+}
+
 static int query_formats(AVFilterContext *ctx)
 {
 TPadContext *s = ctx->priv;
-if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
-(s->start_mode == MODE_ADD && s->pad_start != 0))
+if (needs_drawing(s))
 return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
 
 return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO));
@@ -196,8 +202,7 @@ static int config_input(AVFilterLink *inlink)
 AVFilterContext *ctx = inlink->dst;
 TPadContext *s = ctx->priv;
 
-if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
-(s->start_mode == MODE_ADD && s->pad_start != 0)) {
+if (needs_drawing(s)) {
 ff_draw_init(>draw, inlink->format, 0);
 ff_draw_color(>draw, >color, s->rgba_color);
 }
-- 
2.39.3 (Apple Git-145)

___
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] libavformat/http: expose actual Location header value

2023-09-19 Thread Marvin Scholz


On 19 Sep 2023, at 10:52, Michael Riedl wrote:

> This is needed for muxers which need to access the Location header as 
> transmitted when no redirection happen.
>

Why are you sending the same patch over and over to the ML?

If you have new versions of a patchset, reply to the original and change the 
topic to:

[PATCH v2 1/2] etc...

(You can use the -vN option of git-format-patch/send-email for that.)

Else it is rather frustrating and confusing for people trying to review
your patches…

> Signed-off-by: Michael Riedl 
> ---
>  libavformat/http.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavformat/http.c b/libavformat/http.c
> index c0fe7c36d91..27f9c8e3000 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -166,6 +166,7 @@ static const AVOption options[] = {
>  { "basic", "HTTP basic authentication", 0, AV_OPT_TYPE_CONST, { .i64 = 
> HTTP_AUTH_BASIC }, 0, 0, D | E, "auth_type"},
>  { "send_expect_100", "Force sending an Expect: 100-continue header for 
> POST", OFFSET(send_expect_100), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, E },
>  { "location", "The actual location of the data received", 
> OFFSET(location), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E },
> +{ "new_location", "The location header value of the data received", 
> OFFSET(new_location), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
>  { "offset", "initial byte offset", OFFSET(off), AV_OPT_TYPE_INT64, { 
> .i64 = 0 }, 0, INT64_MAX, D },
>  { "end_offset", "try to limit the request to bytes preceding this 
> offset", OFFSET(end_off), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, D },
>  { "method", "Override the HTTP method or set the expected HTTP method 
> from a client", OFFSET(method), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D 
> | E },
> -- 
> 2.39.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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avfilter: add libvmaf_cuda

2023-09-18 Thread Marvin Scholz
>  enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 2.0.0" 
> libvmaf.h vmaf_init
> +enabled libvmaf   && require_pkg_config libvmaf_cuda "libvmaf >= 
> 2.0.0" libvmaf_cuda.h vmaf_cuda_state_init
>  enabled libvo_amrwbenc&& require libvo_amrwbenc vo-amrwbenc/enc_if.h 
> E_IF_init -lvo-amrwbenc
>  enabled libvorbis && require_pkg_config libvorbis vorbis 
> vorbis/codec.h vorbis_info_init &&
>   require_pkg_config libvorbisenc vorbisenc 
> vorbis/vorbisenc.h vorbis_encode_init

I am far from an expert with the configure script but won't that cause 
--enable-libvmaf to fail when
libvmaf is built without cuda support? Which seems undesirable to me…

On 18 Sep 2023, at 18:42, Kyle Swanson wrote:

> Hi,
>
> On Fri, Sep 15, 2023 at 3:34 PM Timo Rothenpieler  
> wrote:
>> I don't see why it wouldn't work. It doesn't matter what it is, it's
>> just the name of the dependency.
>
> Patch attached.
>
> Thanks,
> Kyle
> ___
> 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] trac backups

2023-09-12 Thread Marvin Scholz



On 13 Sep 2023, at 0:13, Michael Niedermayer wrote:

> Hi all
>
> our trac backups died 6 months ago
> i just noticed as i checked the backups before deleting spam with trac-admin
> backups are working again
>
> failure reason where expired gpg keys
>
> thx
>
> PS: yeah, iam slightly unhappy noone noticed this for 6 months

Who else other than you has access to the infrastructure?

>
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> When the tyrant has disposed of foreign enemies by conquest or treaty, and
> there is nothing more to fear from them, then he is always stirring up
> some war or other, in order that the people may require a leader. -- Plato
> ___
> 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 2/2] lavc/videotoolboxenc: Get the encoder supported properties

2023-09-07 Thread Marvin Scholz



On 8 Sep 2023, at 4:55, Jun Zhao wrote:

> Get the encoder supported properties list, it will be used for
> feature support checks.
>
> Signed-off-by: Jun Zhao 
> ---
>  libavcodec/videotoolboxenc.c | 70 
>  1 file changed, 47 insertions(+), 23 deletions(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 2e96990741..832147b6cd 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -232,6 +232,7 @@ typedef struct VTEncContext {
>  AVClass *class;
>  enum AVCodecID codec_id;
>  VTCompressionSessionRef session;
> +CFDictionaryRef supported_props;
>  CFStringRef ycbcr_matrix;
>  CFStringRef color_primaries;
>  CFStringRef transfer_function;
> @@ -321,6 +322,34 @@ static void clear_frame_queue(VTEncContext *vtctx)
>  set_async_error(vtctx, 0);
>  }
>
> +static void vtenc_reset(VTEncContext *vtctx)
> +{
> +if (vtctx->session) {
> +CFRelease(vtctx->session);
> +vtctx->session = NULL;
> +}
> +
> +if (vtctx->supported_props) {
> +CFRelease(vtctx->supported_props);
> +vtctx->supported_props = NULL;
> +}
> +
> +if (vtctx->color_primaries) {
> +CFRelease(vtctx->color_primaries);
> +vtctx->color_primaries = NULL;
> +}
> +
> +if (vtctx->transfer_function) {
> +CFRelease(vtctx->transfer_function);
> +vtctx->transfer_function = NULL;
> +}
> +
> +if (vtctx->ycbcr_matrix) {
> +CFRelease(vtctx->ycbcr_matrix);
> +vtctx->ycbcr_matrix = NULL;
> +}
> +}
> +
>  static int vtenc_q_pop(VTEncContext *vtctx, bool wait, CMSampleBufferRef 
> *buf, ExtraSEI **sei)
>  {
>  BufNode *info;
> @@ -1110,6 +1139,20 @@ static int vtenc_create_encoder(AVCodecContext   
> *avctx,
>  return AVERROR_EXTERNAL;
>  }
>
> +if (__builtin_available(macOS 10.13, iOS 11, tvOS 11, *)) {

Thanks, though this needs the proper SDK guards as well too, to not break
building with SDKs older than 10.13, unless FFmpeg does not care about this.

See 
https://epir.at/2019/10/30/api-availability-and-target-conditionals/#checking-api-availability-at-compile-time

> +status = VTCopySupportedPropertyDictionaryForEncoder(avctx->width,
> + avctx->height,
> + codec_type,
> + enc_info,
> + NULL,
> + 
> >supported_props);
> +
> +if (status != noErr) {
> +av_log(avctx, AV_LOG_ERROR,"Error retrieving the supported 
> property dictionary err=%"PRId64"\n", (int64_t)status);
> +return AVERROR_EXTERNAL;
> +}
> +}
> +
>  // Dump the init encoder
>  {
>  CFStringRef encoderID = NULL;
> @@ -1662,7 +1705,6 @@ static av_cold int vtenc_init(AVCodecContext *avctx)
>  // It can happen when user set avctx->profile directly.
>  if (vtctx->profile == AV_PROFILE_UNKNOWN)
>  vtctx->profile = avctx->profile;
> -vtctx->session = NULL;
>  status = vtenc_configure_encoder(avctx);
>  if (status) return status;
>
> @@ -2431,8 +2473,8 @@ static int create_cv_pixel_buffer(AVCodecContext   
> *avctx,
>
>  vtstatus = VTCompressionSessionPrepareToEncodeFrames(vtctx->session);
>  if (vtstatus == kVTInvalidSessionErr) {
> -CFRelease(vtctx->session);
> -vtctx->session = NULL;
> +vtenc_reset(vtctx);
> +
>  status = vtenc_configure_encoder(avctx);
>  if (status == 0)
>  pix_buf_pool = 
> VTCompressionSessionGetPixelBufferPool(vtctx->session);
> @@ -2688,10 +2730,7 @@ static int vtenc_populate_extradata(AVCodecContext   
> *avctx,
>
>  pe_cleanup:
>  CVPixelBufferRelease(pix_buf);
> -if(vtctx->session)
> -CFRelease(vtctx->session);
> -
> -vtctx->session = NULL;
> +vtenc_reset(vtctx);
>  vtctx->frame_ct_out = 0;
>
>  av_assert0(status != 0 || (avctx->extradata && avctx->extradata_size > 
> 0));
> @@ -2714,23 +2753,8 @@ static av_cold int vtenc_close(AVCodecContext *avctx)
>  clear_frame_queue(vtctx);
>  pthread_cond_destroy(>cv_sample_sent);
>  pthread_mutex_destroy(>lock);
> -CFRelease(vtctx->session);
> -vtctx->session = NULL;
> -
> -if (vtctx->color_primaries) {
> -CFRelease(vtctx->color_primaries);
> -vtctx->color_primaries = NULL;
> -}
>
> -if (vtctx->transfer_function) {
> -CFRelease(vtctx->transfer_function);
> -vtctx->transfer_function = NULL;
> -}
> -
> -if (vtctx->ycbcr_matrix) {
> -CFRelease(vtctx->ycbcr_matrix);
> -vtctx->ycbcr_matrix = NULL;
> -}
> +vtenc_reset(vtctx);
>
>  return 0;
>  }
> -- 
> 2.25.1
>
> 

Re: [FFmpeg-devel] [PATCH v2 2/2] lavc/videotoolboxenc: Get the encoder supported properties

2023-09-05 Thread Marvin Scholz
On 5 Sep 2023, at 18:02, Jun Zhao wrote:

> Get the encoder supported properties list, it will be used for
> feature support checks.
>
> Signed-off-by: Jun Zhao 
> ---
>  libavcodec/videotoolboxenc.c | 68 
>  1 file changed, 45 insertions(+), 23 deletions(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 3512d35b73..0142342c58 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -232,6 +232,7 @@ typedef struct VTEncContext {
>  AVClass *class;
>  enum AVCodecID codec_id;
>  VTCompressionSessionRef session;
> +CFDictionaryRef supported_props;
>  CFStringRef ycbcr_matrix;
>  CFStringRef color_primaries;
>  CFStringRef transfer_function;
> @@ -321,6 +322,34 @@ static void clear_frame_queue(VTEncContext *vtctx)
>  set_async_error(vtctx, 0);
>  }
>
> +static void vtenc_reset(VTEncContext *vtctx)
> +{
> +if (vtctx->session) {
> +CFRelease(vtctx->session);
> +vtctx->session = NULL;
> +}
> +
> +if (vtctx->supported_props) {
> +CFRelease(vtctx->supported_props);
> +vtctx->supported_props = NULL;
> +}
> +
> +if (vtctx->color_primaries) {
> +CFRelease(vtctx->color_primaries);
> +vtctx->color_primaries = NULL;
> +}
> +
> +if (vtctx->transfer_function) {
> +CFRelease(vtctx->transfer_function);
> +vtctx->transfer_function = NULL;
> +}
> +
> +if (vtctx->ycbcr_matrix) {
> +CFRelease(vtctx->ycbcr_matrix);
> +vtctx->ycbcr_matrix = NULL;
> +}
> +}
> +
>  static int vtenc_q_pop(VTEncContext *vtctx, bool wait, CMSampleBufferRef 
> *buf, ExtraSEI **sei)
>  {
>  BufNode *info;
> @@ -1110,6 +1139,18 @@ static int vtenc_create_encoder(AVCodecContext   
> *avctx,
>  return AVERROR_EXTERNAL;
>  }
>
> +status = VTCopySupportedPropertyDictionaryForEncoder(avctx->width,
> + avctx->height,
> + codec_type,
> + enc_info,
> + NULL,
> + 
> >supported_props);

Only available starting macOS 10.13+, needs to be handled accordingly, I think.

> +
> +if (status != noErr) {
> +av_log(avctx, AV_LOG_ERROR,"Error retrieving the supported property 
> dictionary err=%"PRId64"\n", (int64_t)status);
> +return AVERROR_EXTERNAL;
> +}
> +
>  // Dump the init encoder
>  {
>  CFStringRef encoderID = NULL;
> @@ -1660,7 +1701,6 @@ static av_cold int vtenc_init(AVCodecContext *avctx)
>  // It can happen when user set avctx->profile directly.
>  if (vtctx->profile == FF_PROFILE_UNKNOWN)
>  vtctx->profile = avctx->profile;
> -vtctx->session = NULL;
>  status = vtenc_configure_encoder(avctx);
>  if (status) return status;
>
> @@ -2429,8 +2469,8 @@ static int create_cv_pixel_buffer(AVCodecContext   
> *avctx,
>
>  vtstatus = VTCompressionSessionPrepareToEncodeFrames(vtctx->session);
>  if (vtstatus == kVTInvalidSessionErr) {
> -CFRelease(vtctx->session);
> -vtctx->session = NULL;
> +vtenc_reset(vtctx);
> +
>  status = vtenc_configure_encoder(avctx);
>  if (status == 0)
>  pix_buf_pool = 
> VTCompressionSessionGetPixelBufferPool(vtctx->session);
> @@ -2686,10 +2726,7 @@ static int vtenc_populate_extradata(AVCodecContext   
> *avctx,
>
>  pe_cleanup:
>  CVPixelBufferRelease(pix_buf);
> -if(vtctx->session)
> -CFRelease(vtctx->session);
> -
> -vtctx->session = NULL;
> +vtenc_reset(vtctx);
>  vtctx->frame_ct_out = 0;
>
>  av_assert0(status != 0 || (avctx->extradata && avctx->extradata_size > 
> 0));
> @@ -2712,23 +2749,8 @@ static av_cold int vtenc_close(AVCodecContext *avctx)
>  clear_frame_queue(vtctx);
>  pthread_cond_destroy(>cv_sample_sent);
>  pthread_mutex_destroy(>lock);
> -CFRelease(vtctx->session);
> -vtctx->session = NULL;
>
> -if (vtctx->color_primaries) {
> -CFRelease(vtctx->color_primaries);
> -vtctx->color_primaries = NULL;
> -}
> -
> -if (vtctx->transfer_function) {
> -CFRelease(vtctx->transfer_function);
> -vtctx->transfer_function = NULL;
> -}
> -
> -if (vtctx->ycbcr_matrix) {
> -CFRelease(vtctx->ycbcr_matrix);
> -vtctx->ycbcr_matrix = NULL;
> -}
> +vtenc_reset(vtctx);
>
>  return 0;
>  }
> -- 
> 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 v3 5/5] lavfi/vf_xfade_vulkan: add wipes

2023-08-21 Thread Marvin Scholz
Add the wipetl, wipetr, wipebl, wipebr effects.
---
 libavfilter/vf_xfade_vulkan.c | 60 +++
 1 file changed, 60 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index 283a8e0710..fdad8c913d 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -81,6 +81,10 @@ enum XFadeTransitions {
 CIRCLECLOSE,
 DISSOLVE,
 PIXELIZE,
+WIPETL,
+WIPETR,
+WIPEBL,
+WIPEBR,
 NB_TRANSITIONS,
 };
 
@@ -246,6 +250,54 @@ static const char transition_pixelize[] = {
 C(0, } 
   )
 };
 
+static const char transition_wipetl[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
   )
+C(0, { 
   )
+C(1, ivec2 size = imageSize(output_images[idx]);   
   )
+C(1, float zw = size.x * (1.0 - progress); 
   )
+C(1, float zh = size.y * (1.0 - progress); 
   )
+C(1, vec4 a = texture(a_images[idx], pos); 
   )
+C(1, vec4 b = texture(b_images[idx], pos); 
   )
+C(1, imageStore(output_images[idx], pos, (pos.y <= zh && pos.x <= zw) 
? a : b);   )
+C(0, } 
   )
+};
+
+static const char transition_wipetr[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
   )
+C(0, { 
   )
+C(1, ivec2 size = imageSize(output_images[idx]);   
   )
+C(1, float zw = size.x * (progress);   
   )
+C(1, float zh = size.y * (1.0 - progress); 
   )
+C(1, vec4 a = texture(a_images[idx], pos); 
   )
+C(1, vec4 b = texture(b_images[idx], pos); 
   )
+C(1, imageStore(output_images[idx], pos, (pos.y <= zh && pos.x > zw) ? 
a : b);)
+C(0, } 
   )
+};
+
+static const char transition_wipebl[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
   )
+C(0, { 
   )
+C(1, ivec2 size = imageSize(output_images[idx]);   
   )
+C(1, float zw = size.x * (1.0 - progress); 
   )
+C(1, float zh = size.y * (progress);   
   )
+C(1, vec4 a = texture(a_images[idx], pos); 
   )
+C(1, vec4 b = texture(b_images[idx], pos); 
   )
+C(1, imageStore(output_images[idx], pos, (pos.y > zh && pos.x <= zw) ? 
a : b);)
+C(0, } 
   )
+};
+
+static const char transition_wipebr[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
   )
+C(0, { 
   )
+C(1, ivec2 size = imageSize(output_images[idx]);   
   )
+C(1, float zw = size.x * (progress);   
   )
+C(1, float zh = size.y * (progress);   
   )
+C(1, vec4 a = texture(a_images[idx], pos); 
   )
+C(1, vec4 b = texture(b_images[idx], pos); 
   )
+C(1, imageStore(output_images[idx], pos, (pos.y > zh && pos.x > zw) ? 
a : b); )
+C(0, } 
   )
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
 [FADE]  = transition_fade,
 [WIPELEFT]  = transition_wipeleft,
@@ -260,6 +312,10 @@ static const char* transitions_map[NB_TRANSITIONS] = {
 [CIRCLECLOSE]   = transition_circleclose,
 [DISSOLVE]  = transition_dissolve,
 [PIXELIZE]  = transition_pixelize,
+[WIPETL]= transition_wipetl,
+[WIPETR]= transition_wipetr,
+[WIPEBL]= transition_wipebl,
+[WIPEBR]= transition_wipebr,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -614,6 

[FFmpeg-devel] [PATCH v3 4/5] lavfi/vf_xfade_vulkan: add pixelize

2023-08-21 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index 6f932d..283a8e0710 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -80,6 +80,7 @@ enum XFadeTransitions {
 CIRCLEOPEN,
 CIRCLECLOSE,
 DISSOLVE,
+PIXELIZE,
 NB_TRANSITIONS,
 };
 
@@ -230,6 +231,21 @@ static const char transition_dissolve[] = {
 C(0, } 
)
 };
 
+static const char transition_pixelize[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
   )
+C(0, { 
   )
+C(1, ivec2 size = imageSize(output_images[idx]);   
   )
+C(1, float d = min(progress, 1.0 - progress);  
   )
+C(1, float dist = ceil(d * 50.0) / 50.0;   
   )
+C(1, float sq = 2.0 * dist * min(size.x, size.y) / 20.0;   
   )
+C(1, float sx = dist > 0.0 ? min((floor(pos.x / sq) + 0.5) * sq, 
size.x - 1) : pos.x; )
+C(1, float sy = dist > 0.0 ? min((floor(pos.y / sq) + 0.5) * sq, 
size.y - 1) : pos.y; )
+C(1, vec4 a = texture(a_images[idx], vec2(sx, sy));
   )
+C(1, vec4 b = texture(b_images[idx], vec2(sx, sy));
   )
+C(1, imageStore(output_images[idx], pos, mix(a, b, progress)); 
   )
+C(0, } 
   )
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
 [FADE]  = transition_fade,
 [WIPELEFT]  = transition_wipeleft,
@@ -243,6 +259,7 @@ static const char* transitions_map[NB_TRANSITIONS] = {
 [CIRCLEOPEN]= transition_circleopen,
 [CIRCLECLOSE]   = transition_circleclose,
 [DISSOLVE]  = transition_dissolve,
+[PIXELIZE]  = transition_pixelize,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -596,6 +613,7 @@ static const AVOption xfade_vulkan_options[] = {
 { "circleopen", "circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
 { "circleclose", "circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
 { "dissolve", "dissolve transition", 0, AV_OPT_TYPE_CONST, 
{.i64=DISSOLVE}, 0, 0, FLAGS, "transition" },
+{ "pixelize", "pixelize transition", 0, AV_OPT_TYPE_CONST, 
{.i64=PIXELIZE}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.37.0 (Apple Git-136)

___
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 3/5] lavfi/vf_xfade_vulkan: add dissolve

2023-08-21 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index 880b3b1afe..6f932d 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -79,6 +79,7 @@ enum XFadeTransitions {
 SLIDERIGHT,
 CIRCLEOPEN,
 CIRCLECLOSE,
+DISSOLVE,
 NB_TRANSITIONS,
 };
 
@@ -212,6 +213,23 @@ static const char transition_circleclose[] = {
 C(0, } 
)
 };
 
+#define SHADER_FRAND_FUNC  
  \
+C(0, float frand(vec2 v)   
) \
+C(0, { 
) \
+C(1, return fract(sin(dot(v, vec2(12.9898, 78.233))) * 43758.545); 
) \
+C(0, } 
)
+
+static const char transition_dissolve[] = {
+SHADER_FRAND_FUNC
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, float sm = frand(pos) * 2.0 + (1.0 - progress) * 2.0 - 1.5;   
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, imageStore(output_images[idx], pos, sm >= 0.5 ? a : b);   
)
+C(0, } 
)
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
 [FADE]  = transition_fade,
 [WIPELEFT]  = transition_wipeleft,
@@ -224,6 +242,7 @@ static const char* transitions_map[NB_TRANSITIONS] = {
 [SLIDERIGHT]= transition_slideright,
 [CIRCLEOPEN]= transition_circleopen,
 [CIRCLECLOSE]   = transition_circleclose,
+[DISSOLVE]  = transition_dissolve,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -576,6 +595,7 @@ static const AVOption xfade_vulkan_options[] = {
 { "slideright", "slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
 { "circleopen", "circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
 { "circleclose", "circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
+{ "dissolve", "dissolve transition", 0, AV_OPT_TYPE_CONST, 
{.i64=DISSOLVE}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.37.0 (Apple Git-136)

___
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/5] lavfi/vf_xfade_vulkan: reindent after last commit

2023-08-21 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 38 +--
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index 23c61bdb48..880b3b1afe 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -213,17 +213,17 @@ static const char transition_circleclose[] = {
 };
 
 static const char* transitions_map[NB_TRANSITIONS] = {
-[FADE]  = transition_fade,
-[WIPELEFT]  = transition_wipeleft,
-[WIPERIGHT] = transition_wiperight,
-[WIPEUP]= transition_wipeup,
-[WIPEDOWN]  = transition_wipedown,
-[SLIDEDOWN] = transition_slidedown,
-[SLIDEUP]   = transition_slideup,
-[SLIDELEFT] = transition_slideleft,
-[SLIDERIGHT]= transition_slideright,
-[CIRCLEOPEN]= transition_circleopen,
-[CIRCLECLOSE]=transition_circleclose,
+[FADE]  = transition_fade,
+[WIPELEFT]  = transition_wipeleft,
+[WIPERIGHT] = transition_wiperight,
+[WIPEUP]= transition_wipeup,
+[WIPEDOWN]  = transition_wipedown,
+[SLIDEDOWN] = transition_slidedown,
+[SLIDEUP]   = transition_slideup,
+[SLIDELEFT] = transition_slideleft,
+[SLIDERIGHT]= transition_slideright,
+[CIRCLEOPEN]= transition_circleopen,
+[CIRCLECLOSE]   = transition_circleclose,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -565,17 +565,17 @@ static AVFrame *get_video_buffer(AVFilterLink *inlink, 
int w, int h)
 
 static const AVOption xfade_vulkan_options[] = {
 { "transition", "set cross fade transition", OFFSET(transition), 
AV_OPT_TYPE_INT, {.i64=FADE}, 0, NB_TRANSITIONS-1, FLAGS, "transition" },
-{ "fade",  "fade transition", 0, AV_OPT_TYPE_CONST, {.i64=FADE}, 
0, 0, FLAGS, "transition" },
-{ "wipeleft",  "wipe left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPELEFT}, 0, 0, FLAGS, "transition" },
+{ "fade", "fade transition", 0, AV_OPT_TYPE_CONST, {.i64=FADE}, 0, 0, 
FLAGS, "transition" },
+{ "wipeleft", "wipe left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPELEFT}, 0, 0, FLAGS, "transition" },
 { "wiperight", "wipe right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPERIGHT}, 0, 0, FLAGS, "transition" },
-{ "wipeup","wipe up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEUP}, 0, 0, FLAGS, "transition" },
-{ "wipedown",  "wipe down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEDOWN}, 0, 0, FLAGS, "transition" },
+{ "wipeup", "wipe up transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEUP}, 
0, 0, FLAGS, "transition" },
+{ "wipedown", "wipe down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEDOWN}, 0, 0, FLAGS, "transition" },
 { "slidedown", "slide down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEDOWN}, 0, 0, FLAGS, "transition" },
-{ "slideup",   "slide up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
+{ "slideup", "slide up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
 { "slideleft", "slide left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDELEFT}, 0, 0, FLAGS, "transition" },
-{ "slideright","slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
-{ "circleopen","circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
-{ "circleclose","circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
+{ "slideright", "slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
+{ "circleopen", "circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
+{ "circleclose", "circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.37.0 (Apple Git-136)

___
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/5] lavfi/vf_xfade_vulkan: add circleopen/circleclose

2023-08-21 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 37 +++
 1 file changed, 37 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index f393dde202..23c61bdb48 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -77,6 +77,8 @@ enum XFadeTransitions {
 SLIDEUP,
 SLIDELEFT,
 SLIDERIGHT,
+CIRCLEOPEN,
+CIRCLECLOSE,
 NB_TRANSITIONS,
 };
 
@@ -179,6 +181,37 @@ static const char transition_slideright[] = {
 C(0, } 
)
 };
 
+#define SHADER_CIRCLE_COMMON   
  \
+C(0, void circle(int idx, ivec2 pos, float progress, bool open)
) \
+C(0, { 
) \
+C(1, const ivec2 half_size = imageSize(output_images[idx]) / 2;
) \
+C(1, const float z = dot(half_size, half_size);
) \
+C(1, float p = ((open ? (1.0 - progress) : progress) - 0.5) * 3.0; 
) \
+C(1, ivec2 dsize = pos - half_size;
) \
+C(1, float sm = dot(dsize, dsize) / z + p; 
) \
+C(1, vec4 a = texture(a_images[idx], pos); 
) \
+C(1, vec4 b = texture(b_images[idx], pos); 
) \
+C(1, imageStore(output_images[idx], pos, \
+mix(open ? b : a, open ? a : b, \
+smoothstep(0.f, 1.f, sm)));
) \
+C(0, } 
)
+
+static const char transition_circleopen[] = {
+SHADER_CIRCLE_COMMON
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, circle(idx, pos, progress, true); 
)
+C(0, } 
)
+};
+
+static const char transition_circleclose[] = {
+SHADER_CIRCLE_COMMON
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, circle(idx, pos, progress, false);
)
+C(0, } 
)
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
 [FADE]  = transition_fade,
 [WIPELEFT]  = transition_wipeleft,
@@ -189,6 +222,8 @@ static const char* transitions_map[NB_TRANSITIONS] = {
 [SLIDEUP]   = transition_slideup,
 [SLIDELEFT] = transition_slideleft,
 [SLIDERIGHT]= transition_slideright,
+[CIRCLEOPEN]= transition_circleopen,
+[CIRCLECLOSE]=transition_circleclose,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -539,6 +574,8 @@ static const AVOption xfade_vulkan_options[] = {
 { "slideup",   "slide up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
 { "slideleft", "slide left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDELEFT}, 0, 0, FLAGS, "transition" },
 { "slideright","slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
+{ "circleopen","circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
+{ "circleclose","circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.37.0 (Apple Git-136)

___
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 3/4] avfilter: Deduplicate default video inputs/outputs

2023-08-03 Thread Marvin Scholz



On 3 Aug 2023, at 16:33, Andreas Rheinhardt wrote:

> Lots of video filters use a very simple input or output:
> An array with a single AVFilterPad whose name is "default"
> and whose type is AVMEDIA_TYPE_VIDEO; everything else is unset.
>
> Given that we never use pointer equality for inputs or outputs*,
> we can simply use a single AVFilterPad instead of dozens; this
> even saves .data.rel.ro (8312B here) as well as relocations.
>
> *: In fact, several filters (like the filters in vf_lut.c)
> already use the same outputs; furthermore, ff_filter_alloc()
> duplicates the input and output pads so that we do not even
> work with the pads directly.
>
> Signed-off-by: Andreas Rheinhardt 
> ---

[...]

> +#include "internal.h"
> +
> +/* An AVFilterPad array whose only entry has name "default"
> + * and is of type video. */
> +extern const AVFilterPad ff_video_default_filterpad[1];

This should probably be a Doxygen comment.

>
>  AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h);
>  AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int 
> align);
> -- 
> 2.34.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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] lavfi/vf_xfade_vulkan: add dissolve

2023-07-24 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index faa19a0518..0409d6bdb1 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -78,6 +78,7 @@ enum XFadeTransitions {
 SLIDERIGHT,
 CIRCLEOPEN,
 CIRCLECLOSE,
+DISSOLVE,
 NB_TRANSITIONS,
 };
 
@@ -211,6 +212,23 @@ static const char transition_circleclose[] = {
 C(0, } 
)
 };
 
+#define SHADER_FRAND_FUNC  
  \
+C(0, float frand(vec2 v)   
) \
+C(0, { 
) \
+C(1, return fract(sin(dot(v, vec2(12.9898, 78.233))) * 43758.545); 
) \
+C(0, } 
)
+
+static const char transition_dissolve[] = {
+SHADER_FRAND_FUNC
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, float sm = frand(pos) * 2.0 + (1.0 - progress) * 2.0 - 1.5;   
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, imageStore(output_images[idx], pos, sm >= 0.5 ? a : b);   
)
+C(0, } 
)
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
 [FADE]  = transition_fade,
 [WIPELEFT]  = transition_wipeleft,
@@ -223,6 +241,7 @@ static const char* transitions_map[NB_TRANSITIONS] = {
 [SLIDERIGHT]= transition_slideright,
 [CIRCLEOPEN]= transition_circleopen,
 [CIRCLECLOSE]   = transition_circleclose,
+[DISSOLVE]  = transition_dissolve,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -575,6 +594,7 @@ static const AVOption xfade_vulkan_options[] = {
 { "slideright", "slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
 { "circleopen", "circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
 { "circleclose", "circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
+{ "dissolve", "dissolve transition", 0, AV_OPT_TYPE_CONST, 
{.i64=DISSOLVE}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.39.2

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

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


Re: [FFmpeg-devel] [PATCH 1/2] lavfi/vf_xfade_vulkan: add circleopen/circleclose

2023-07-24 Thread Marvin Scholz


On 24 Jul 2023, at 23:11, Marvin Scholz wrote:

> ---
>  libavfilter/vf_xfade_vulkan.c | 43 +++
>  1 file changed, 43 insertions(+)
>
> diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
> index 8825717890..d044714199 100644
> --- a/libavfilter/vf_xfade_vulkan.c
> +++ b/libavfilter/vf_xfade_vulkan.c
> @@ -76,6 +76,8 @@ enum XFadeTransitions {
>  SLIDEUP,
>  SLIDELEFT,
>  SLIDERIGHT,
> +CIRCLEOPEN,
> +CIRCLECLOSE,
>  NB_TRANSITIONS,
>  };
>
> @@ -178,6 +180,43 @@ static const char transition_slideright[] = {
>  C(0, }   
>   )
>  };
>
> +#define SHADER_HYPOT_FUNC
>   \
> +C(0, float hypot(ivec2 v) {  
> ) \
> +C(1, ivec2 sqr = v * v;  
> ) \
> +C(1, return sqrt(sqr.x + sqr.y); 
> ) \
> +C(0, }   
> )
> +
> +#define SHADER_CIRCLE_COMMON 
> \
> +SHADER_HYPOT_FUNC
> \
> +C(0, void circle(int idx, ivec2 pos, float progress, bool open)  
>   ) \
> +C(0, {   
>   ) \
> +C(1, const ivec2 half_size = imageSize(output_images[idx]) / 2;  
>   ) \
> +C(1, const float z = hypot(half_size);   
>   ) \
> +C(1, float p = ((open ? (1.0 - progress) : progress) - 0.5) * 3.0;   
>   ) \
> +C(1, float sm = hypot(pos - half_size) / z + p;  
>   ) \
> +C(1, vec4 a = texture(a_images[idx], pos);   
>   ) \
> +C(1, vec4 b = texture(b_images[idx], pos);   
>   ) \
> +C(1, imageStore(output_images[idx], pos, \
> +mix(open ? b : a, open ? a : b, \
> +smoothstep(0.f, 1.f, sm)));  
>   ) \
> +C(0, }   
>   )
> +
> +static const char transition_circleopen[] = {
> +SHADER_CIRCLE_COMMON
> +C(0, void transition(int idx, ivec2 pos, float progress) 
>   )
> +C(0, {   
>   )
> +C(1, circle(idx, pos, progress, true);   
>   )
> +C(0, }   
>   )
> +};
> +
> +static const char transition_circleclose[] = {
> +SHADER_CIRCLE_COMMON
> +C(0, void transition(int idx, ivec2 pos, float progress) 
>   )
> +C(0, {   
>   )
> +C(1, circle(idx, pos, progress, false);  
>   )
> +C(0, }   
>   )
> +};
> +
>  static const char* transitions_map[NB_TRANSITIONS] = {
>  [FADE]  = transition_fade,
>  [WIPELEFT]  = transition_wipeleft,
> @@ -188,6 +227,8 @@ static const char* transitions_map[NB_TRANSITIONS] = {
>  [SLIDEUP]   = transition_slideup,
>  [SLIDELEFT] = transition_slideleft,
>  [SLIDERIGHT]= transition_slideright,
> +[CIRCLEOPEN]= transition_circleopen,
> +[CIRCLECLOSE]=transition_circleclose,
>  };
>
>  static av_cold int init_vulkan(AVFilterContext *avctx)
> @@ -538,6 +579,8 @@ static const AVOption xfade_vulkan_options[] = {
>  { "slideup",   "slide up transition", 0, AV_OPT_TYPE_CONST, 
> {.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
>  { "slideleft", "slide left transition", 0, AV_OPT_TYPE_CONST, 
> {.i64=SLIDELEFT}, 0, 0, FLAGS, "transition" },
>  { "slideright","slide right transition", 0, AV_OPT_TYPE_CONST, 
> {.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
> +{ "circleopen","circleopen transition", 0, AV_OPT_TYPE_CONST, 
> {.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
> +{ "circleclose","circleclose transition", 0, AV_OPT_TYPE_CONST, 
> {.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
>  { "duration", "set cross fade duration", OFFSET(duration), 
> AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAG

[FFmpeg-devel] [PATCH 2/2] lavfi/vf_xfade_vulkan: reindent after last commit

2023-07-24 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 38 +--
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index c3b08b52f5..faa19a0518 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -212,17 +212,17 @@ static const char transition_circleclose[] = {
 };
 
 static const char* transitions_map[NB_TRANSITIONS] = {
-[FADE]  = transition_fade,
-[WIPELEFT]  = transition_wipeleft,
-[WIPERIGHT] = transition_wiperight,
-[WIPEUP]= transition_wipeup,
-[WIPEDOWN]  = transition_wipedown,
-[SLIDEDOWN] = transition_slidedown,
-[SLIDEUP]   = transition_slideup,
-[SLIDELEFT] = transition_slideleft,
-[SLIDERIGHT]= transition_slideright,
-[CIRCLEOPEN]= transition_circleopen,
-[CIRCLECLOSE]=transition_circleclose,
+[FADE]  = transition_fade,
+[WIPELEFT]  = transition_wipeleft,
+[WIPERIGHT] = transition_wiperight,
+[WIPEUP]= transition_wipeup,
+[WIPEDOWN]  = transition_wipedown,
+[SLIDEDOWN] = transition_slidedown,
+[SLIDEUP]   = transition_slideup,
+[SLIDELEFT] = transition_slideleft,
+[SLIDERIGHT]= transition_slideright,
+[CIRCLEOPEN]= transition_circleopen,
+[CIRCLECLOSE]   = transition_circleclose,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -564,17 +564,17 @@ static AVFrame *get_video_buffer(AVFilterLink *inlink, 
int w, int h)
 
 static const AVOption xfade_vulkan_options[] = {
 { "transition", "set cross fade transition", OFFSET(transition), 
AV_OPT_TYPE_INT, {.i64=FADE}, 0, NB_TRANSITIONS-1, FLAGS, "transition" },
-{ "fade",  "fade transition", 0, AV_OPT_TYPE_CONST, {.i64=FADE}, 
0, 0, FLAGS, "transition" },
-{ "wipeleft",  "wipe left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPELEFT}, 0, 0, FLAGS, "transition" },
+{ "fade", "fade transition", 0, AV_OPT_TYPE_CONST, {.i64=FADE}, 0, 0, 
FLAGS, "transition" },
+{ "wipeleft", "wipe left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPELEFT}, 0, 0, FLAGS, "transition" },
 { "wiperight", "wipe right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPERIGHT}, 0, 0, FLAGS, "transition" },
-{ "wipeup","wipe up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEUP}, 0, 0, FLAGS, "transition" },
-{ "wipedown",  "wipe down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEDOWN}, 0, 0, FLAGS, "transition" },
+{ "wipeup", "wipe up transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEUP}, 
0, 0, FLAGS, "transition" },
+{ "wipedown", "wipe down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEDOWN}, 0, 0, FLAGS, "transition" },
 { "slidedown", "slide down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEDOWN}, 0, 0, FLAGS, "transition" },
-{ "slideup",   "slide up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
+{ "slideup", "slide up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
 { "slideleft", "slide left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDELEFT}, 0, 0, FLAGS, "transition" },
-{ "slideright","slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
-{ "circleopen","circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
-{ "circleclose","circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
+{ "slideright", "slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
+{ "circleopen", "circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
+{ "circleclose", "circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.39.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 1/2] lavfi/vf_xfade_vulkan: add circleopen/circleclose

2023-07-24 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 37 +++
 1 file changed, 37 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index 8825717890..c3b08b52f5 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -76,6 +76,8 @@ enum XFadeTransitions {
 SLIDEUP,
 SLIDELEFT,
 SLIDERIGHT,
+CIRCLEOPEN,
+CIRCLECLOSE,
 NB_TRANSITIONS,
 };
 
@@ -178,6 +180,37 @@ static const char transition_slideright[] = {
 C(0, } 
)
 };
 
+#define SHADER_CIRCLE_COMMON   
  \
+C(0, void circle(int idx, ivec2 pos, float progress, bool open)
) \
+C(0, { 
) \
+C(1, const ivec2 half_size = imageSize(output_images[idx]) / 2;
) \
+C(1, const float z = dot(half_size, half_size);
) \
+C(1, float p = ((open ? (1.0 - progress) : progress) - 0.5) * 3.0; 
) \
+C(1, ivec2 dsize = pos - half_size;
) \
+C(1, float sm = dot(dsize, dsize) / z + p; 
) \
+C(1, vec4 a = texture(a_images[idx], pos); 
) \
+C(1, vec4 b = texture(b_images[idx], pos); 
) \
+C(1, imageStore(output_images[idx], pos, \
+mix(open ? b : a, open ? a : b, \
+smoothstep(0.f, 1.f, sm)));
) \
+C(0, } 
)
+
+static const char transition_circleopen[] = {
+SHADER_CIRCLE_COMMON
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, circle(idx, pos, progress, true); 
)
+C(0, } 
)
+};
+
+static const char transition_circleclose[] = {
+SHADER_CIRCLE_COMMON
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, circle(idx, pos, progress, false);
)
+C(0, } 
)
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
 [FADE]  = transition_fade,
 [WIPELEFT]  = transition_wipeleft,
@@ -188,6 +221,8 @@ static const char* transitions_map[NB_TRANSITIONS] = {
 [SLIDEUP]   = transition_slideup,
 [SLIDELEFT] = transition_slideleft,
 [SLIDERIGHT]= transition_slideright,
+[CIRCLEOPEN]= transition_circleopen,
+[CIRCLECLOSE]=transition_circleclose,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -538,6 +573,8 @@ static const AVOption xfade_vulkan_options[] = {
 { "slideup",   "slide up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
 { "slideleft", "slide left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDELEFT}, 0, 0, FLAGS, "transition" },
 { "slideright","slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
+{ "circleopen","circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
+{ "circleclose","circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.39.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_xfade_vulkan: reindent after last commit

2023-07-24 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 38 +--
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index d044714199..4f26398410 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -218,17 +218,17 @@ static const char transition_circleclose[] = {
 };
 
 static const char* transitions_map[NB_TRANSITIONS] = {
-[FADE]  = transition_fade,
-[WIPELEFT]  = transition_wipeleft,
-[WIPERIGHT] = transition_wiperight,
-[WIPEUP]= transition_wipeup,
-[WIPEDOWN]  = transition_wipedown,
-[SLIDEDOWN] = transition_slidedown,
-[SLIDEUP]   = transition_slideup,
-[SLIDELEFT] = transition_slideleft,
-[SLIDERIGHT]= transition_slideright,
-[CIRCLEOPEN]= transition_circleopen,
-[CIRCLECLOSE]=transition_circleclose,
+[FADE]  = transition_fade,
+[WIPELEFT]  = transition_wipeleft,
+[WIPERIGHT] = transition_wiperight,
+[WIPEUP]= transition_wipeup,
+[WIPEDOWN]  = transition_wipedown,
+[SLIDEDOWN] = transition_slidedown,
+[SLIDEUP]   = transition_slideup,
+[SLIDELEFT] = transition_slideleft,
+[SLIDERIGHT]= transition_slideright,
+[CIRCLEOPEN]= transition_circleopen,
+[CIRCLECLOSE]   = transition_circleclose,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -570,17 +570,17 @@ static AVFrame *get_video_buffer(AVFilterLink *inlink, 
int w, int h)
 
 static const AVOption xfade_vulkan_options[] = {
 { "transition", "set cross fade transition", OFFSET(transition), 
AV_OPT_TYPE_INT, {.i64=FADE}, 0, NB_TRANSITIONS-1, FLAGS, "transition" },
-{ "fade",  "fade transition", 0, AV_OPT_TYPE_CONST, {.i64=FADE}, 
0, 0, FLAGS, "transition" },
-{ "wipeleft",  "wipe left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPELEFT}, 0, 0, FLAGS, "transition" },
+{ "fade", "fade transition", 0, AV_OPT_TYPE_CONST, {.i64=FADE}, 0, 0, 
FLAGS, "transition" },
+{ "wipeleft", "wipe left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPELEFT}, 0, 0, FLAGS, "transition" },
 { "wiperight", "wipe right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPERIGHT}, 0, 0, FLAGS, "transition" },
-{ "wipeup","wipe up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEUP}, 0, 0, FLAGS, "transition" },
-{ "wipedown",  "wipe down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEDOWN}, 0, 0, FLAGS, "transition" },
+{ "wipeup", "wipe up transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEUP}, 
0, 0, FLAGS, "transition" },
+{ "wipedown", "wipe down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEDOWN}, 0, 0, FLAGS, "transition" },
 { "slidedown", "slide down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEDOWN}, 0, 0, FLAGS, "transition" },
-{ "slideup",   "slide up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
+{ "slideup", "slide up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
 { "slideleft", "slide left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDELEFT}, 0, 0, FLAGS, "transition" },
-{ "slideright","slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
-{ "circleopen","circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
-{ "circleclose","circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
+{ "slideright", "slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
+{ "circleopen", "circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
+{ "circleclose", "circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.39.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 1/2] lavfi/vf_xfade_vulkan: add circleopen/circleclose

2023-07-24 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index 8825717890..d044714199 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -76,6 +76,8 @@ enum XFadeTransitions {
 SLIDEUP,
 SLIDELEFT,
 SLIDERIGHT,
+CIRCLEOPEN,
+CIRCLECLOSE,
 NB_TRANSITIONS,
 };
 
@@ -178,6 +180,43 @@ static const char transition_slideright[] = {
 C(0, } 
)
 };
 
+#define SHADER_HYPOT_FUNC  
\
+C(0, float hypot(ivec2 v) {  ) 
\
+C(1, ivec2 sqr = v * v;  ) 
\
+C(1, return sqrt(sqr.x + sqr.y); ) 
\
+C(0, }   )
+
+#define SHADER_CIRCLE_COMMON   
  \
+SHADER_HYPOT_FUNC  
  \
+C(0, void circle(int idx, ivec2 pos, float progress, bool open)
) \
+C(0, { 
) \
+C(1, const ivec2 half_size = imageSize(output_images[idx]) / 2;
) \
+C(1, const float z = hypot(half_size); 
) \
+C(1, float p = ((open ? (1.0 - progress) : progress) - 0.5) * 3.0; 
) \
+C(1, float sm = hypot(pos - half_size) / z + p;
) \
+C(1, vec4 a = texture(a_images[idx], pos); 
) \
+C(1, vec4 b = texture(b_images[idx], pos); 
) \
+C(1, imageStore(output_images[idx], pos, \
+mix(open ? b : a, open ? a : b, \
+smoothstep(0.f, 1.f, sm)));
) \
+C(0, } 
)
+
+static const char transition_circleopen[] = {
+SHADER_CIRCLE_COMMON
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, circle(idx, pos, progress, true); 
)
+C(0, } 
)
+};
+
+static const char transition_circleclose[] = {
+SHADER_CIRCLE_COMMON
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, circle(idx, pos, progress, false);
)
+C(0, } 
)
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
 [FADE]  = transition_fade,
 [WIPELEFT]  = transition_wipeleft,
@@ -188,6 +227,8 @@ static const char* transitions_map[NB_TRANSITIONS] = {
 [SLIDEUP]   = transition_slideup,
 [SLIDELEFT] = transition_slideleft,
 [SLIDERIGHT]= transition_slideright,
+[CIRCLEOPEN]= transition_circleopen,
+[CIRCLECLOSE]=transition_circleclose,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -538,6 +579,8 @@ static const AVOption xfade_vulkan_options[] = {
 { "slideup",   "slide up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
 { "slideleft", "slide left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDELEFT}, 0, 0, FLAGS, "transition" },
 { "slideright","slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
+{ "circleopen","circleopen transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLEOPEN}, 0, 0, FLAGS, "transition" },
+{ "circleclose","circleclose transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CIRCLECLOSE}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.39.2

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

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


Re: [FFmpeg-devel] [PATCH v2 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread Marvin Scholz



On 22 Jul 2023, at 21:10, John Cox wrote:

> On Sat, 22 Jul 2023 20:54:04 +0200, you wrote:
>
>> On 22 Jul 2023, at 18:41, John Cox wrote:
>>
>>> Add a callback to enable user allocation of video frames on the final
>>> stage of a filter chain.
>>>
>>> Signed-off-by: John Cox 
>>> ---
>>>  libavfilter/buffersink.c | 21 +
>>>  libavfilter/buffersink.h | 27 +++
>>>  libavfilter/version.h|  2 +-
>>>  3 files changed, 49 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
>>> index 306c283f77..070b743186 100644
>>> --- a/libavfilter/buffersink.c
>>> +++ b/libavfilter/buffersink.c
>>> @@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
>>>  int sample_rates_size;
>>>
>>>  AVFrame *peeked_frame;
>>> +
>>> +union {
>>> +av_buffersink_alloc_video_frame * video;
>>> +} alloc_cb;
>>> +void * alloc_v;
>>>  } BufferSinkContext;
>>>
>>>  #define NB_ITEMS(list) (list ## _size / sizeof(*list))
>>> @@ -154,6 +159,21 @@ int attribute_align_arg 
>>> av_buffersink_get_samples(AVFilterContext *ctx,
>>>  return get_frame_internal(ctx, frame, 0, nb_samples);
>>>  }
>>>
>>> +static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
>>> +{
>>> +AVFilterContext * const ctx = link->dst;
>>> +BufferSinkContext * const bs = ctx->priv;
>>> +return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w, h) 
>>> :
>>> +ff_default_get_video_buffer(link, w, h);
>>> +}
>>> +
>>> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
>>> av_buffersink_alloc_video_frame * cb, void * v)
>>> +{
>>> +BufferSinkContext * const bs = ctx->priv;
>>> +bs->alloc_cb.video = cb;
>>> +bs->alloc_v = v;
>>> +}
>>> +
>>>  static av_cold int common_init(AVFilterContext *ctx)
>>>  {
>>>  BufferSinkContext *buf = ctx->priv;
>>> @@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] 
>>> = {
>>>  {
>>>  .name = "default",
>>>  .type = AVMEDIA_TYPE_VIDEO,
>>> +.get_buffer = {.video = alloc_video_buffer},
>>>  },
>>>  };
>>>
>>> diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
>>> index 64e08de53e..73f0ddc476 100644
>>> --- a/libavfilter/buffersink.h
>>> +++ b/libavfilter/buffersink.h
>>> @@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, 
>>> AVFrame *frame);
>>>   */
>>>  int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
>>> nb_samples);
>>>
>>> +/**
>>> + * Callback from av_buffersink_set_alloc_video_frame to allocate
>>> + * a frame
>>> + *
>>> + * @param ctx pointer to a context of the abuffersink AVFilter.
>>> + * @param v opaque pointer passed to
>>> + *  av_buffersink_set_alloc_video_frame
>>
>> Nit:
>>
>> You can use @ref av_buffersink_set_alloc_video_frame  or even
>> shorter ::av_buffersink_set_alloc_video_frame to get a proper
>> reference to that function that will be linked.
>
> Thanks - will do - Is documentation built from this? I had a quick look
> to see if I could find some output to verify what I'd done but I failed
> to find it.

You can generate it (if you have doxygen installed) by running:

make apidoc

and it will end up in doc/doxy/html.

>
>>> + * @param w width of frame to allocate
>>> + * @param height of frame to allocate
>>> + *
>>> + * @return
>>> + * - The newly allocated frame
>>> + * - NULL if error
>>
>> Nit:
>>
>> This can use retval, for example like that:
>>
>> @retval AVFrame* The newly allocated frame
>> @retval NULL Error allocating the frame
>
> Will do.
>
> Ta
>
> JC
>
>>> + */
>>> +typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx, 
>>> void * v, int w, int h);
>>> +
>>> +/**
>>> + * Set a video frame allocation method for buffersink
>>> + *
>>> + * @param ctx pointer to a context of the abuffersink AVFilter.
>>> + * @param cb Callback to the allocation function. If set to NULL
>>> + *   then the default avfilter allocation function will
>>> + *   be used.
>>> + * @param v  Opaque to pass to the allocation function
>>> + */
>>> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
>>> av_buffersink_alloc_video_frame * cb, void * v);
>>> +
>>>  /**
>>>   * @}
>>>   */
>>> diff --git a/libavfilter/version.h b/libavfilter/version.h
>>> index c001693e3c..54950497be 100644
>>> --- a/libavfilter/version.h
>>> +++ b/libavfilter/version.h
>>> @@ -31,7 +31,7 @@
>>>
>>>  #include "version_major.h"
>>>
>>> -#define LIBAVFILTER_VERSION_MINOR   8
>>> +#define LIBAVFILTER_VERSION_MINOR   9
>>>  #define LIBAVFILTER_VERSION_MICRO 102
>>>
>>>
>>> -- 
>>> 2.39.2
>>>
>>> ___
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>> 

Re: [FFmpeg-devel] [PATCH v2 1/1] avfilter/buffersink: Add video frame allocation callback

2023-07-22 Thread Marvin Scholz
On 22 Jul 2023, at 18:41, John Cox wrote:

> Add a callback to enable user allocation of video frames on the final
> stage of a filter chain.
>
> Signed-off-by: John Cox 
> ---
>  libavfilter/buffersink.c | 21 +
>  libavfilter/buffersink.h | 27 +++
>  libavfilter/version.h|  2 +-
>  3 files changed, 49 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
> index 306c283f77..070b743186 100644
> --- a/libavfilter/buffersink.c
> +++ b/libavfilter/buffersink.c
> @@ -62,6 +62,11 @@ typedef struct BufferSinkContext {
>  int sample_rates_size;
>
>  AVFrame *peeked_frame;
> +
> +union {
> +av_buffersink_alloc_video_frame * video;
> +} alloc_cb;
> +void * alloc_v;
>  } BufferSinkContext;
>
>  #define NB_ITEMS(list) (list ## _size / sizeof(*list))
> @@ -154,6 +159,21 @@ int attribute_align_arg 
> av_buffersink_get_samples(AVFilterContext *ctx,
>  return get_frame_internal(ctx, frame, 0, nb_samples);
>  }
>
> +static AVFrame * alloc_video_buffer(AVFilterLink *link, int w, int h)
> +{
> +AVFilterContext * const ctx = link->dst;
> +BufferSinkContext * const bs = ctx->priv;
> +return bs->alloc_cb.video ? bs->alloc_cb.video(ctx, bs->alloc_v, w, h) :
> +ff_default_get_video_buffer(link, w, h);
> +}
> +
> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
> av_buffersink_alloc_video_frame * cb, void * v)
> +{
> +BufferSinkContext * const bs = ctx->priv;
> +bs->alloc_cb.video = cb;
> +bs->alloc_v = v;
> +}
> +
>  static av_cold int common_init(AVFilterContext *ctx)
>  {
>  BufferSinkContext *buf = ctx->priv;
> @@ -381,6 +401,7 @@ static const AVFilterPad avfilter_vsink_buffer_inputs[] = 
> {
>  {
>  .name = "default",
>  .type = AVMEDIA_TYPE_VIDEO,
> +.get_buffer = {.video = alloc_video_buffer},
>  },
>  };
>
> diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
> index 64e08de53e..73f0ddc476 100644
> --- a/libavfilter/buffersink.h
> +++ b/libavfilter/buffersink.h
> @@ -166,6 +166,33 @@ int av_buffersink_get_frame(AVFilterContext *ctx, 
> AVFrame *frame);
>   */
>  int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
> nb_samples);
>
> +/**
> + * Callback from av_buffersink_set_alloc_video_frame to allocate
> + * a frame
> + *
> + * @param ctx pointer to a context of the abuffersink AVFilter.
> + * @param v opaque pointer passed to
> + *  av_buffersink_set_alloc_video_frame

Nit:

You can use @ref av_buffersink_set_alloc_video_frame  or even
shorter ::av_buffersink_set_alloc_video_frame to get a proper
reference to that function that will be linked.

> + * @param w width of frame to allocate
> + * @param height of frame to allocate
> + *
> + * @return
> + * - The newly allocated frame
> + * - NULL if error

Nit:

This can use retval, for example like that:

@retval AVFrame* The newly allocated frame
@retval NULL Error allocating the frame

> + */
> +typedef AVFrame * av_buffersink_alloc_video_frame(AVFilterContext * ctx, 
> void * v, int w, int h);
> +
> +/**
> + * Set a video frame allocation method for buffersink
> + *
> + * @param ctx pointer to a context of the abuffersink AVFilter.
> + * @param cb Callback to the allocation function. If set to NULL
> + *   then the default avfilter allocation function will
> + *   be used.
> + * @param v  Opaque to pass to the allocation function
> + */
> +void av_buffersink_set_alloc_video_frame(AVFilterContext *ctx, 
> av_buffersink_alloc_video_frame * cb, void * v);
> +
>  /**
>   * @}
>   */
> diff --git a/libavfilter/version.h b/libavfilter/version.h
> index c001693e3c..54950497be 100644
> --- a/libavfilter/version.h
> +++ b/libavfilter/version.h
> @@ -31,7 +31,7 @@
>
>  #include "version_major.h"
>
> -#define LIBAVFILTER_VERSION_MINOR   8
> +#define LIBAVFILTER_VERSION_MINOR   9
>  #define LIBAVFILTER_VERSION_MICRO 102
>
>
> -- 
> 2.39.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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] lavc/audiotoolbox: fix build failure on osx 10.5 (v3)

2023-07-15 Thread Marvin Scholz



On 15 Jul 2023, at 21:36, Pavel Koshevoy wrote:

> ---
>  libavcodec/audiotoolboxdec.c | 2 ++
>  libavcodec/audiotoolboxenc.c | 4 
>  2 files changed, 6 insertions(+)
>
> diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
> index 82babe3d31..5456f916cf 100644
> --- a/libavcodec/audiotoolboxdec.c
> +++ b/libavcodec/audiotoolboxdec.c
> @@ -71,10 +71,12 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, 
> int profile)
>  return kAudioFormatAMR;
>  case AV_CODEC_ID_EAC3:
>  return kAudioFormatEnhancedAC3;
> +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
>  case AV_CODEC_ID_GSM_MS:
>  return kAudioFormatMicrosoftGSM;
>  case AV_CODEC_ID_ILBC:
>  return kAudioFormatiLBC;
> +#endif
>  case AV_CODEC_ID_MP1:
>  return kAudioFormatMPEGLayer1;
>  case AV_CODEC_ID_MP2:
> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index 1ccfda4d20..46aca4c7ff 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -69,15 +69,19 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, 
> int profile)
>  return kAudioFormatMPEG4AAC_HE_V2;
>  case FF_PROFILE_AAC_LD:
>  return kAudioFormatMPEG4AAC_LD;
> +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
>  case FF_PROFILE_AAC_ELD:
>  return kAudioFormatMPEG4AAC_ELD;
> +#endif
>  }
>  case AV_CODEC_ID_ADPCM_IMA_QT:
>  return kAudioFormatAppleIMA4;
>  case AV_CODEC_ID_ALAC:
>  return kAudioFormatAppleLossless;
> +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
>  case AV_CODEC_ID_ILBC:
>  return kAudioFormatiLBC;
> +#endif
>  case AV_CODEC_ID_PCM_ALAW:
>  return kAudioFormatALaw;
>  case AV_CODEC_ID_PCM_MULAW:
> -- 
> 2.35.3

Thanks, LGTM from my side though I can not push it
as I have no commit access, so someone else has to
do that.

>
> ___
> 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] lavc/audiotoolbox: fix build failure on osx 10.5 (v2)

2023-07-15 Thread Marvin Scholz
On 15 Jul 2023, at 17:40, Pavel Koshevoy wrote:

> ---
>  libavcodec/audiotoolboxdec.c | 2 ++
>  libavcodec/audiotoolboxenc.c | 4 
>  2 files changed, 6 insertions(+)
>

Hi, thanks for the patch, small remark below:

> diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
> index 82babe3d31..e336aade8b 100644
> --- a/libavcodec/audiotoolboxdec.c
> +++ b/libavcodec/audiotoolboxdec.c
> @@ -71,10 +71,12 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, 
> int profile)
>  return kAudioFormatAMR;
>  case AV_CODEC_ID_EAC3:
>  return kAudioFormatEnhancedAC3;
> +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
>  case AV_CODEC_ID_GSM_MS:
>  return kAudioFormatMicrosoftGSM;
>  case AV_CODEC_ID_ILBC:
>  return kAudioFormatiLBC;
> +#endif
>  case AV_CODEC_ID_MP1:
>  return kAudioFormatMPEGLayer1;
>  case AV_CODEC_ID_MP2:
> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index 1ccfda4d20..e5217d952d 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -69,15 +69,19 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, 
> int profile)
>  return kAudioFormatMPEG4AAC_HE_V2;
>  case FF_PROFILE_AAC_LD:
>  return kAudioFormatMPEG4AAC_LD;
> +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060

I think you should use __MAC_OS_X_VERSION_MIN_REQUIRED, as the __ENVIRONMENT_* 
is
an implementation detail and not documented IIRC. (Same below)

>  case FF_PROFILE_AAC_ELD:
>  return kAudioFormatMPEG4AAC_ELD;
> +#endif
>  }
>  case AV_CODEC_ID_ADPCM_IMA_QT:
>  return kAudioFormatAppleIMA4;
>  case AV_CODEC_ID_ALAC:
>  return kAudioFormatAppleLossless;
> +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
>  case AV_CODEC_ID_ILBC:
>  return kAudioFormatiLBC;
> +#endif
>  case AV_CODEC_ID_PCM_ALAW:
>  return kAudioFormatALaw;
>  case AV_CODEC_ID_PCM_MULAW:
> -- 
> 2.35.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".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/dict: add av_dict_pop

2023-07-03 Thread Marvin Scholz



On 3 Jul 2023, at 20:02, Andreas Rheinhardt wrote:

> Marvin Scholz:
>>
>>
>> On 3 Jul 2023, at 2:18, Andreas Rheinhardt wrote:
>>
>>> Marvin Scholz:
>>>> This new API allows to remove an entry and obtain ownership of the
>>>> key/value that was associated with the removed entry.
>>>> ---
>>>>
>>>> Changes since v1:
>>>> - Clarify documentation about av_free having to be used.
>>>> - Fix fate test to not rely on specific error code value
>>>>
>>>>  doc/APIchanges |  4 
>>>>  libavutil/dict.c   | 27 +++
>>>>  libavutil/dict.h   | 26 ++
>>>>  libavutil/tests/dict.c | 38 ++
>>>>  libavutil/version.h|  4 ++--
>>>>  tests/ref/fate/dict| 12 
>>>>  6 files changed, 109 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/doc/APIchanges b/doc/APIchanges
>>>> index f040211f7d..d55821f682 100644
>>>> --- a/doc/APIchanges
>>>> +++ b/doc/APIchanges
>>>> @@ -2,6 +2,10 @@ The last version increases of all libraries were on 
>>>> 2023-02-09
>>>>
>>>>  API changes, most recent first:
>>>>
>>>> +2023-06-02 - xx - lavu 58.14.100 - dict.h
>>>> +  Add av_dict_pop() to remove an entry from a dict
>>>> +  and get ownership of the removed key/value.
>>>> +
>>>>  2023-05-29 - xx - lavc 60.16.100 - avcodec.h codec_id.h
>>>>Add AV_CODEC_ID_EVC, FF_PROFILE_EVC_BASELINE, and FF_PROFILE_EVC_MAIN.
>>>>
>>>> diff --git a/libavutil/dict.c b/libavutil/dict.c
>>>> index f673977a98..ac41771994 100644
>>>> --- a/libavutil/dict.c
>>>> +++ b/libavutil/dict.c
>>>> @@ -173,6 +173,33 @@ int av_dict_set_int(AVDictionary **pm, const char 
>>>> *key, int64_t value,
>>>>  return av_dict_set(pm, key, valuestr, flags);
>>>>  }
>>>>
>>>> +int av_dict_pop(AVDictionary **pm, const char *key,
>>>> +char **out_key, char **out_value, int flags)
>>>> +{
>>>> +AVDictionary *m = *pm;
>>>> +AVDictionaryEntry *entry = NULL;
>>> Why don't you merge this initialization and the assignment below?
>>>
>>>> +entry = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags);
>>>> +if (!entry)
>>>> +return AVERROR(ENOENT);
>>>> +
>>>> +if (out_key)
>>>> +*out_key = entry->key;
>>>> +else
>>>> +av_free(entry->key);
>>>> +
>>>> +if (out_value)
>>>> +*out_value = entry->value;
>>>> +else
>>>> +av_free(entry->value);
>>>> +
>>>> +*entry = m->elems[--m->count];
>>>> +if (m && !m->count) {
>>>
>>> The check for m is completely unnecessary; Coverity will probably
>>> complain about this (because this check implies that m can be NULL, but
>>> then the line above the check would crash).
>>>
>>>> +av_freep(>elems);
>>>> +av_freep(pm);
>>>> +}
>>>> +return 0;
>>>> +}
>>>> +
>>>>  static int parse_key_value_pair(AVDictionary **pm, const char **buf,
>>>>  const char *key_val_sep, const char 
>>>> *pairs_sep,
>>>>  int flags)
>>>> diff --git a/libavutil/dict.h b/libavutil/dict.h
>>>> index 713c9e361a..31d38dabec 100644
>>>> --- a/libavutil/dict.h
>>>> +++ b/libavutil/dict.h
>>>> @@ -172,6 +172,32 @@ int av_dict_set(AVDictionary **pm, const char *key, 
>>>> const char *value, int flags
>>>>   */
>>>>  int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, 
>>>> int flags);
>>>>
>>>> +/**
>>>> + * Remove the entry with the given key from the dictionary.
>>>> + *
>>>> + * Search for an entry matching @p key and remove it, if found. Optionally
>>>> + * the found key and/or value can be returned using the @p out_key and
>>>> + * @p out_value arguments.
>>>> + *
>>>> + * If more than one entry matches, only one entry is removed and returned
>>>> + 

Re: [FFmpeg-devel] Create video from one picture and one audio file

2023-07-03 Thread Marvin Scholz
On 3 Jul 2023, at 14:13, Matej Marko wrote:

> Create video from one picture and one audio file
>  
> Hello,
>  

You already sent your email once before, do not re-send the
same thing please. If you have things to add, reply to your previously
sent e-mail so it is properly threaded.

> This command not work correct. Video is longer than audio file
> ffmpeg -loop 1 -framerate 2/60 -i 22.jpg -i 22.mp3 -c:v libvpx-vp9 -c:a copy 
> -shortest -r 2 video-vystup2.mkv
>  
> This command not work correct too. Video is no possible convert for YouTube 
> servers.
> ffmpeg -framerate 1 -i 22.jpg -i 22.mp3 -c:a copy -c:v libvpx-vp9 
> video-vystup.mkv
>  
> Audio an picture yo can download here
> https://mega.nz/folder/JuID2BiA#uZ4qVDe6yb0xjDjiXFlJvw 
> 
>  
> Or can you me please help?
> FFMPEG developers, can you please repair it?
>  
> Thanks
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/dict: add av_dict_pop

2023-07-03 Thread Marvin Scholz



On 3 Jul 2023, at 2:18, Andreas Rheinhardt wrote:

> Marvin Scholz:
>> This new API allows to remove an entry and obtain ownership of the
>> key/value that was associated with the removed entry.
>> ---
>>
>> Changes since v1:
>> - Clarify documentation about av_free having to be used.
>> - Fix fate test to not rely on specific error code value
>>
>>  doc/APIchanges |  4 
>>  libavutil/dict.c   | 27 +++
>>  libavutil/dict.h   | 26 ++
>>  libavutil/tests/dict.c | 38 ++
>>  libavutil/version.h|  4 ++--
>>  tests/ref/fate/dict| 12 
>>  6 files changed, 109 insertions(+), 2 deletions(-)
>>
>> diff --git a/doc/APIchanges b/doc/APIchanges
>> index f040211f7d..d55821f682 100644
>> --- a/doc/APIchanges
>> +++ b/doc/APIchanges
>> @@ -2,6 +2,10 @@ The last version increases of all libraries were on 
>> 2023-02-09
>>
>>  API changes, most recent first:
>>
>> +2023-06-02 - xx - lavu 58.14.100 - dict.h
>> +  Add av_dict_pop() to remove an entry from a dict
>> +  and get ownership of the removed key/value.
>> +
>>  2023-05-29 - xx - lavc 60.16.100 - avcodec.h codec_id.h
>>Add AV_CODEC_ID_EVC, FF_PROFILE_EVC_BASELINE, and FF_PROFILE_EVC_MAIN.
>>
>> diff --git a/libavutil/dict.c b/libavutil/dict.c
>> index f673977a98..ac41771994 100644
>> --- a/libavutil/dict.c
>> +++ b/libavutil/dict.c
>> @@ -173,6 +173,33 @@ int av_dict_set_int(AVDictionary **pm, const char *key, 
>> int64_t value,
>>  return av_dict_set(pm, key, valuestr, flags);
>>  }
>>
>> +int av_dict_pop(AVDictionary **pm, const char *key,
>> +char **out_key, char **out_value, int flags)
>> +{
>> +AVDictionary *m = *pm;
>> +AVDictionaryEntry *entry = NULL;
> Why don't you merge this initialization and the assignment below?
>
>> +entry = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags);
>> +if (!entry)
>> +return AVERROR(ENOENT);
>> +
>> +if (out_key)
>> +*out_key = entry->key;
>> +else
>> +av_free(entry->key);
>> +
>> +if (out_value)
>> +*out_value = entry->value;
>> +else
>> +av_free(entry->value);
>> +
>> +*entry = m->elems[--m->count];
>> +if (m && !m->count) {
>
> The check for m is completely unnecessary; Coverity will probably
> complain about this (because this check implies that m can be NULL, but
> then the line above the check would crash).
>
>> +av_freep(>elems);
>> +av_freep(pm);
>> +}
>> +return 0;
>> +}
>> +
>>  static int parse_key_value_pair(AVDictionary **pm, const char **buf,
>>  const char *key_val_sep, const char 
>> *pairs_sep,
>>  int flags)
>> diff --git a/libavutil/dict.h b/libavutil/dict.h
>> index 713c9e361a..31d38dabec 100644
>> --- a/libavutil/dict.h
>> +++ b/libavutil/dict.h
>> @@ -172,6 +172,32 @@ int av_dict_set(AVDictionary **pm, const char *key, 
>> const char *value, int flags
>>   */
>>  int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int 
>> flags);
>>
>> +/**
>> + * Remove the entry with the given key from the dictionary.
>> + *
>> + * Search for an entry matching @p key and remove it, if found. Optionally
>> + * the found key and/or value can be returned using the @p out_key and
>> + * @p out_value arguments.
>> + *
>> + * If more than one entry matches, only one entry is removed and returned
>> + * on each call. Which entry is returned first in that case is undefined.
>> + *
>> + * @param pmPointer to a pointer to a dictionary struct.
>> + * @param key   Entry key to match.
>> + * @param out_key   Pointer whose pointee will be set to the matched
>> + *  entry key. Must be freed using av_dict_free() by
>
> This is wrong: It must be freed using av_free() (or av_freep()); same below.

Indeed, copy paste mistake, sorry.

>
>> + *  the caller. May be NULL.
>> + * @param out_value Pointer whose pointee will be set to the matched
>> + *  entry value. Must be freed using av_dict_free() by
>> + *  the caller. May be NULL.
>> + *
>> + * @retval 0Success
>> + * @retval AVERROR(ENOENT)  No item

Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/dict: add av_dict_pop

2023-07-02 Thread Marvin Scholz
On 2 Jul 2023, at 10:43, Stefano Sabatini wrote:

> On date Sunday 2023-06-25 12:49:05 +0200, Marvin Scholz wrote:
>> This new API allows to remove an entry and obtain ownership of the
>> key/value that was associated with the removed entry.
>> ---
>>
>> Changes since v1:
>> - Clarify documentation about av_free having to be used.
>> - Fix fate test to not rely on specific error code value
>>
>>  doc/APIchanges |  4 
>>  libavutil/dict.c   | 27 +++
>>  libavutil/dict.h   | 26 ++
>>  libavutil/tests/dict.c | 38 ++
>>  libavutil/version.h|  4 ++--
>>  tests/ref/fate/dict| 12 
>>  6 files changed, 109 insertions(+), 2 deletions(-)
>>
>> diff --git a/doc/APIchanges b/doc/APIchanges
>> index f040211f7d..d55821f682 100644
>> --- a/doc/APIchanges
>> +++ b/doc/APIchanges
>> @@ -2,6 +2,10 @@ The last version increases of all libraries were on 
>> 2023-02-09
>>
>>  API changes, most recent first:
>>
>> +2023-06-02 - xx - lavu 58.14.100 - dict.h
>> +  Add av_dict_pop() to remove an entry from a dict
>> +  and get ownership of the removed key/value.
>> +
>>  2023-05-29 - xx - lavc 60.16.100 - avcodec.h codec_id.h
>>Add AV_CODEC_ID_EVC, FF_PROFILE_EVC_BASELINE, and FF_PROFILE_EVC_MAIN.
>>
>> diff --git a/libavutil/dict.c b/libavutil/dict.c
>> index f673977a98..ac41771994 100644
>> --- a/libavutil/dict.c
>> +++ b/libavutil/dict.c
>> @@ -173,6 +173,33 @@ int av_dict_set_int(AVDictionary **pm, const char *key, 
>> int64_t value,
>>  return av_dict_set(pm, key, valuestr, flags);
>>  }
>>
>> +int av_dict_pop(AVDictionary **pm, const char *key,
>> +char **out_key, char **out_value, int flags)
>> +{
>> +AVDictionary *m = *pm;
>> +AVDictionaryEntry *entry = NULL;
>> +entry = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags);
>> +if (!entry)
>> +return AVERROR(ENOENT);
>> +
>> +if (out_key)
>> +*out_key = entry->key;
>> +else
>> +av_free(entry->key);
>> +
>> +if (out_value)
>> +*out_value = entry->value;
>> +else
>> +av_free(entry->value);
>> +
>> +*entry = m->elems[--m->count];
>> +if (m && !m->count) {
>> +av_freep(>elems);
>> +av_freep(pm);
>> +}
>> +return 0;
>> +}
>> +
>>  static int parse_key_value_pair(AVDictionary **pm, const char **buf,
>>  const char *key_val_sep, const char 
>> *pairs_sep,
>>  int flags)
>> diff --git a/libavutil/dict.h b/libavutil/dict.h
>> index 713c9e361a..31d38dabec 100644
>> --- a/libavutil/dict.h
>> +++ b/libavutil/dict.h
>> @@ -172,6 +172,32 @@ int av_dict_set(AVDictionary **pm, const char *key, 
>> const char *value, int flags
>>   */
>>  int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int 
>> flags);
>>
>> +/**
>> + * Remove the entry with the given key from the dictionary.
>> + *
>> + * Search for an entry matching @p key and remove it, if found. Optionally
>> + * the found key and/or value can be returned using the @p out_key and
>> + * @p out_value arguments.
>
> Note: I checked the code and we see that in some cases we use `param`
> (e.g. in mem.h) but I prefer this format (although apparently not used
> in other places) since it looks more consistent with the doxygen
> syntax.
>
>> + *
>> + * If more than one entry matches, only one entry is removed and returned
>> + * on each call. Which entry is returned first in that case is undefined.
>> + *
>> + * @param pmPointer to a pointer to a dictionary struct.
>> + * @param key   Entry key to match.
>> + * @param out_key   Pointer whose pointee will be set to the matched
>> + *  entry key. Must be freed using av_dict_free() by
>> + *  the caller. May be NULL.
>> + * @param out_value Pointer whose pointee will be set to the matched
>> + *  entry value. Must be freed using av_dict_free() by
>> + *  the caller. May be NULL.
>
> missing docs for flags, something like:
> @param flags flags passed to av_dict_get to look for the entry
>
> should be fine
>

Can whoever ends up merging this maybe add that?
If not, I can send a new revision with this change next weekend or so.

> [...]
>
> Looks good otherwise, thanks.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 3/3] avutil/dict: constify av_dict_get return

2023-06-25 Thread Marvin Scholz
---
 doc/examples/qsv_transcode.c   |  2 +-
 libavcodec/libaomenc.c |  2 +-
 libavcodec/libkvazaar.c|  2 +-
 libavcodec/libsvtav1.c |  2 +-
 libavcodec/libvpxenc.c |  2 +-
 libavcodec/libx264.c   |  2 +-
 libavcodec/libx265.c   |  2 +-
 libavcodec/mjpegdec.c  |  2 +-
 libavcodec/qsvenc.c|  2 +-
 libavfilter/avfilter.c |  2 +-
 libavfilter/f_bench.c  |  2 +-
 libavfilter/f_drawgraph.c  |  2 +-
 libavfilter/f_select.c |  4 +--
 libavfilter/vf_cover_rect.c|  2 +-
 libavfilter/vf_drawtext.c  |  2 +-
 libavformat/aiffenc.c  |  2 +-
 libavformat/argo_asf.c |  2 +-
 libavformat/asfenc.c   |  6 ++--
 libavformat/au.c   |  2 +-
 libavformat/avformat.h |  2 +-
 libavformat/avidec.c   |  2 +-
 libavformat/avienc.c   |  2 +-
 libavformat/avio.c |  4 +--
 libavformat/dashenc.c  |  6 ++--
 libavformat/dvenc.c|  2 +-
 libavformat/flacdec.c  |  2 +-
 libavformat/flacenc.c  |  6 ++--
 libavformat/flvdec.c   |  2 +-
 libavformat/gxfenc.c   |  2 +-
 libavformat/http.c |  8 +++---
 libavformat/id3v2.c|  6 ++--
 libavformat/id3v2enc.c |  2 +-
 libavformat/imfdec.c   |  2 +-
 libavformat/matroskadec.c  |  2 +-
 libavformat/mov.c  |  6 ++--
 libavformat/movenc.c   | 46 +++---
 libavformat/mp3enc.c   |  6 ++--
 libavformat/mpegtsenc.c|  6 ++--
 libavformat/mux.c  |  2 +-
 libavformat/mux_utils.c|  2 +-
 libavformat/mxfenc.c   | 14 -
 libavformat/riffenc.c  |  2 +-
 libavformat/rmenc.c|  2 +-
 libavformat/sapenc.c   |  2 +-
 libavformat/sdp.c  |  2 +-
 libavformat/segment.c  |  4 +--
 libavformat/soxenc.c   |  2 +-
 libavformat/tee.c  |  2 +-
 libavformat/ttmlenc.c  |  4 +--
 libavformat/wavenc.c   |  4 +--
 libavformat/webmdashenc.c  | 30 +--
 libavutil/dict.c   |  9 +-
 libavutil/dict.h   |  5 
 libavutil/hwcontext_cuda.c |  2 +-
 libavutil/hwcontext_qsv.c  |  2 +-
 libavutil/hwcontext_vulkan.c   |  8 +++---
 libavutil/version.h|  1 +
 tests/api/api-threadmessage-test.c |  2 +-
 58 files changed, 136 insertions(+), 123 deletions(-)

diff --git a/doc/examples/qsv_transcode.c b/doc/examples/qsv_transcode.c
index 48128b200c..cc4c203d94 100644
--- a/doc/examples/qsv_transcode.c
+++ b/doc/examples/qsv_transcode.c
@@ -87,7 +87,7 @@ static int dynamic_set_parameter(AVCodecContext *avctx)
 frame_number++;
 if (current_setting_number < setting_number &&
 frame_number == dynamic_setting[current_setting_number].frame_number) {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 ret = str_to_dict(dynamic_setting[current_setting_number++].optstr, 
);
 if (ret < 0) {
 fprintf(stderr, "The dynamic parameter is wrong\n");
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 16747e7e92..af6d50f9e3 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -999,7 +999,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 #if AOM_ENCODER_ABI_VERSION >= 23
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 
 while ((en = av_dict_get(ctx->aom_params, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
 int ret = aom_codec_set_option(>encoder, en->key, en->value);
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 2ef34dd82e..2178f7ec45 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -104,7 +104,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (ctx->kvz_params) {
 AVDictionary *dict = NULL;
 if (!av_dict_parse_string(, ctx->kvz_params, "=", ",", 0)) {
-AVDictionaryEntry *entry = NULL;
+const AVDictionaryEntry *entry = NULL;
 while ((entry = av_dict_get(dict, "", entry, 
AV_DICT_IGNORE_SUFFIX))) {
 if (!api->config_parse(cfg, entry->key, entry->value)) {
 av_log(avctx, AV_LOG_WARNING, "Invalid option: %s=%s.\n",
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 718a04d221..0f423cdbb8 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -151,7 +151,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
*param,
 {
 SvtContext *svt_enc = avctx->priv_data;
 const AVPixFmtDescriptor *desc;
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 
 // Update param from options
 #if 

[FFmpeg-devel] [PATCH v2 2/3] avformat/tee: use av_dict_pop

2023-06-25 Thread Marvin Scholz
This is a well-defined way to "steal" the value of the dict entry.
---
 libavformat/tee.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index cb555f52fd..70f3f2eb29 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -157,6 +157,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 {
 int i, ret;
 AVDictionary *options = NULL, *bsf_options = NULL;
+char *entry_val = NULL;
 AVDictionaryEntry *entry;
 char *filename;
 char *format = NULL, *select = NULL, *on_fail = NULL;
@@ -171,15 +172,15 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 return ret;
 
 #define CONSUME_OPTION(option, field, action) do {  \
-if ((entry = av_dict_get(options, option, NULL, 0))) {  \
-field = entry->value;   \
+if ((!av_dict_pop(, option, NULL, _val, 0))) {\
+field = entry_val;  \
 { action }  \
-av_dict_set(, option, NULL, 0); \
+av_freep(_val);   \
 }   \
 } while (0)
 #define STEAL_OPTION(option, field) \
 CONSUME_OPTION(option, field,   \
-   entry->value = NULL; /* prevent it from being freed */)
+   entry_val = NULL; /* prevent it from being freed */)
 #define PROCESS_OPTION(option, field, function, on_error)   \
 CONSUME_OPTION(option, field, if ((ret = function) < 0) { { on_error } 
goto end; })
 
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH v2 1/3] avutil/dict: add av_dict_pop

2023-06-25 Thread Marvin Scholz
This new API allows to remove an entry and obtain ownership of the
key/value that was associated with the removed entry.
---

Changes since v1:
- Clarify documentation about av_free having to be used.
- Fix fate test to not rely on specific error code value

 doc/APIchanges |  4 
 libavutil/dict.c   | 27 +++
 libavutil/dict.h   | 26 ++
 libavutil/tests/dict.c | 38 ++
 libavutil/version.h|  4 ++--
 tests/ref/fate/dict| 12 
 6 files changed, 109 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index f040211f7d..d55821f682 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-06-02 - xx - lavu 58.14.100 - dict.h
+  Add av_dict_pop() to remove an entry from a dict
+  and get ownership of the removed key/value.
+
 2023-05-29 - xx - lavc 60.16.100 - avcodec.h codec_id.h
   Add AV_CODEC_ID_EVC, FF_PROFILE_EVC_BASELINE, and FF_PROFILE_EVC_MAIN.
 
diff --git a/libavutil/dict.c b/libavutil/dict.c
index f673977a98..ac41771994 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -173,6 +173,33 @@ int av_dict_set_int(AVDictionary **pm, const char *key, 
int64_t value,
 return av_dict_set(pm, key, valuestr, flags);
 }
 
+int av_dict_pop(AVDictionary **pm, const char *key,
+char **out_key, char **out_value, int flags)
+{
+AVDictionary *m = *pm;
+AVDictionaryEntry *entry = NULL;
+entry = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags);
+if (!entry)
+return AVERROR(ENOENT);
+
+if (out_key)
+*out_key = entry->key;
+else
+av_free(entry->key);
+
+if (out_value)
+*out_value = entry->value;
+else
+av_free(entry->value);
+
+*entry = m->elems[--m->count];
+if (m && !m->count) {
+av_freep(>elems);
+av_freep(pm);
+}
+return 0;
+}
+
 static int parse_key_value_pair(AVDictionary **pm, const char **buf,
 const char *key_val_sep, const char *pairs_sep,
 int flags)
diff --git a/libavutil/dict.h b/libavutil/dict.h
index 713c9e361a..31d38dabec 100644
--- a/libavutil/dict.h
+++ b/libavutil/dict.h
@@ -172,6 +172,32 @@ int av_dict_set(AVDictionary **pm, const char *key, const 
char *value, int flags
  */
 int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int 
flags);
 
+/**
+ * Remove the entry with the given key from the dictionary.
+ *
+ * Search for an entry matching @p key and remove it, if found. Optionally
+ * the found key and/or value can be returned using the @p out_key and
+ * @p out_value arguments.
+ *
+ * If more than one entry matches, only one entry is removed and returned
+ * on each call. Which entry is returned first in that case is undefined.
+ *
+ * @param pmPointer to a pointer to a dictionary struct.
+ * @param key   Entry key to match.
+ * @param out_key   Pointer whose pointee will be set to the matched
+ *  entry key. Must be freed using av_dict_free() by
+ *  the caller. May be NULL.
+ * @param out_value Pointer whose pointee will be set to the matched
+ *  entry value. Must be freed using av_dict_free() by
+ *  the caller. May be NULL.
+ *
+ * @retval 0Success
+ * @retval AVERROR(ENOENT)  No item for the given key found
+ * @retval "Other (negative) AVERROR"   Other failure
+ */
+int av_dict_pop(AVDictionary **pm, const char *key,
+char **out_key, char **out_value, int flags);
+
 /**
  * Parse the key/value pairs list and add the parsed entries to a dictionary.
  *
diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c
index bececefb31..06d94ecc9a 100644
--- a/libavutil/tests/dict.c
+++ b/libavutil/tests/dict.c
@@ -158,5 +158,43 @@ int main(void)
 printf("%s\n", e->value);
 av_dict_free();
 
+char *key, *val = NULL;
+int ret;
+printf("\nTesting av_dict_pop() with existing AVDictionaryEntry.key as 
key\n");
+av_dict_set(, "test-key", "test-value", 0);
+ret = av_dict_pop(, "test-key", , , 0);
+printf("%s: %s (Return code: %i)\n",
+(key) ? key : "(null)",
+(val) ? val : "(null)", ret);
+e = av_dict_get(dict, "test-key", NULL, 0);
+printf("%s\n", (e) ? e->value : "(null)");
+av_freep();
+av_freep();
+
+printf("\nTesting av_dict_pop() with nonexistent key\n");
+ret = av_dict_pop(, "test-key", , , 0);
+printf("%s: %s ",
+(key) ? key : "(null)",
+(val) ? val : "(null)");
+if (ret == AVERROR(ENOENT))
+printf("(Return code: ENOENT)\n");
+else
+printf("(Return code: Unexpected error: %i)\n", ret);
+e = av_dict_get(dict, "test-key", NULL, 0);
+printf("%s\n", (e) ? e->value : 

Re: [FFmpeg-devel] lavfi/vf_libplacebo: generalize to multiple inputs

2023-06-20 Thread Marvin Scholz
On 18 Jun 2023, at 13:16, Niklas Haas wrote:

> Changes since v1:
> - added explicit `if (s->inputs)` check to input_uninit() loop
> - added extra `!s->status` check to handle case of negative PTS on
>   status change (since `s->status_pts >= 0` would fail here)
>
>

Tested and LGTM from my side

> ___
> 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] avformat/mov: fix overallocation when reading pssh/saiz

2023-06-12 Thread Marvin Scholz (ePirat)
Hi,

> On 12. Jun 2023, at 13:56, Zhao Zhili  wrote:
> 
> From: Zhao Zhili 
> 
> mov_try_read_block() allocates 1MB at least, which can be more than
> enough. It was called when reading saiz box, which can appear
> periodically inside fmp4. This consumes a lot of memory.
> 
> We can fix mov_try_read_block() by clamp 'block_size' with 'size'.
> However, the function is harmful than helpful. It avoids allocating
> large memory when the real data is small. Even in that case, if
> allocating large memory directly failed, it's fine to return ENOMEM;
> if allocating success and reading doesn't match the given size, it's
> fine to free and return AVERROR_INVALIDDATA. In other cases, it's a
> waste of CPU and memory.
> 
> So I decided to remove the function, and replace it by call
> av_malloc() and avio_read() directly.
> 
> mov_read_saiz() and mov_read_pssh() need more check, but they don't
> belong to this patch.
> 
> Fixes #7641 and #9243.
> 
> Signed-off-by: Zhao Zhili 
> ---
> libavformat/mov.c | 63 +++
> 1 file changed, 25 insertions(+), 38 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index a8d004e02b..3d0969545a 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -6649,38 +6649,6 @@ finish:
> return ret;
> }
> 
> -/**
> - * Tries to read the given number of bytes from the stream and puts it in a
> - * newly allocated buffer.  This reads in small chunks to avoid allocating 
> large
> - * memory if the file contains an invalid/malicious size value.

I fail to see how your replacement code addresses the malicious size value case 
that this function mitigated, see in more detail what I mean below…

> - */
> -static int mov_try_read_block(AVIOContext *pb, size_t size, uint8_t **data)
> -{
> -const unsigned int block_size = 1024 * 1024;
> -uint8_t *buffer = NULL;
> -unsigned int alloc_size = 0, offset = 0;
> -while (offset < size) {
> -unsigned int new_size =
> -alloc_size >= INT_MAX - block_size ? INT_MAX : alloc_size + 
> block_size;
> -uint8_t *new_buffer = av_fast_realloc(buffer, _size, new_size);
> -unsigned int to_read = FFMIN(size, alloc_size) - offset;
> -if (!new_buffer) {
> -av_free(buffer);
> -return AVERROR(ENOMEM);
> -}
> -buffer = new_buffer;
> -
> -if (avio_read(pb, buffer + offset, to_read) != to_read) {
> -av_free(buffer);
> -return AVERROR_INVALIDDATA;
> -}
> -offset += to_read;
> -}
> -
> -*data = buffer;
> -return 0;
> -}
> -
> static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> {
> MOVEncryptionIndex *encryption_index;
> @@ -6736,15 +6704,24 @@ static int mov_read_saiz(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
> 
> encryption_index->auxiliary_info_default_size = avio_r8(pb);
> sample_count = avio_rb32(pb);
> -encryption_index->auxiliary_info_sample_count = sample_count;
> 
> if (encryption_index->auxiliary_info_default_size == 0) {
> -ret = mov_try_read_block(pb, sample_count, 
> _index->auxiliary_info_sizes);
> -if (ret < 0) {
> -av_log(c->fc, AV_LOG_ERROR, "Failed to read the auxiliary 
> info\n");
> +encryption_index->auxiliary_info_sizes = av_malloc(sample_count);
> +if (!encryption_index->auxiliary_info_sizes)
> +return AVERROR(ENOMEM);
> +
> +ret = avio_read(pb, encryption_index->auxiliary_info_sizes, 
> sample_count);
> +if (ret != sample_count) {
> +av_freep(_index->auxiliary_info_sizes);
> +
> +if (ret >= 0)
> +ret = AVERROR_INVALIDDATA;
> +av_log(c->fc, AV_LOG_ERROR, "Failed to read the auxiliary info, 
> %s\n",
> +   av_err2str(ret));
> return ret;
> }
> }
> +encryption_index->auxiliary_info_sample_count = sample_count;
> 
> if (encryption_index->auxiliary_offsets_count) {
> return mov_parse_auxiliary_info(c, sc, pb, encryption_index);
> @@ -6913,9 +6890,19 @@ static int mov_read_pssh(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
> }
> 
> extra_data_size = avio_rb32(pb);
> -ret = mov_try_read_block(pb, extra_data_size, _data);
> -if (ret < 0)
> +extra_data = av_malloc(extra_data_size);

If I understand correctly you are now effectively passing a potentially 
malicious size value directly to malloc, allowing an attacker to exhaust memory 
with a crafted file.

> +if (!extra_data) {
> +ret = AVERROR(ENOMEM);
> goto finish;
> +}
> +ret = avio_read(pb, extra_data, extra_data_size);
> +if (ret != extra_data_size) {
> +av_free(extra_data);
> +
> +if (ret >= 0)
> +ret = AVERROR_INVALIDDATA;
> +goto finish;
> +}
> 
> av_freep(>data);  // malloc(0) may still allocate something.
> info->data = extra_data;
> -- 
> 2.25.1
> 

Re: [FFmpeg-devel] [PATCH v5 5/5] lavfi/format: add a hwmap auto conversion filter

2023-06-07 Thread Marvin Scholz



On 25 Apr 2023, at 9:26, Tong Wu wrote:

> When two formats lists cannot be merged, a scale filter is
> auto-inserted. However, when it comes to hardware map, we have to
> manually add a hwmap filter to do the conversion. This patch introduces
> an auto hwmap filter to do the hwmap conversion automatically.
>

Thanks for trying to improve this!

I've recently done quite a bit of experimentation with hardware
filters and at least for the Cuda - Vulkan - Cuda case, hwmap
was useless, and I was told I need to use hwupload instead, so I wonder
what cases this would help with?

I just fear that, especially given the bad error messages hwmap gives,
this will just implicitly insert it because it seemingly works but then
just fail to actually do the job and give an absolutely indescriptive
error to the user for a filter they did not even insert themselves.

> Signed-off-by: Tong Wu 
> ---
>  libavfilter/avfiltergraph.c | 3 ++-
>  libavfilter/formats.c   | 4 
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
> index 8af0467bc5..b2b627ad6a 100644
> --- a/libavfilter/avfiltergraph.c
> +++ b/libavfilter/avfiltergraph.c
> @@ -402,7 +402,8 @@ static int insert_auto_filter(AVFilterContext **convert, 
> AVFilterGraph *graph,
>  AVFilterContext *ctx;
>  AVFilterLink *inlink, *outlink;
>  char inst_name[30];
> -const char *opts = FF_FIELD_AT(char *, 
> neg->conversion_filters[conv_step].conversion_opts_offset, *graph);
> +const char *opts = 
> neg->conversion_filters[conv_step].conversion_opts_offset == 0 ? NULL :
> +   FF_FIELD_AT(char *, 
> neg->conversion_filters[conv_step].conversion_opts_offset, *graph);
>  const char *name = neg->conversion_filters[conv_step].conversion_filter;
>
>  if (!(filter = avfilter_get_by_name(name))) {
> diff --git a/libavfilter/formats.c b/libavfilter/formats.c
> index c8e20e5b20..fee10fa0ee 100644
> --- a/libavfilter/formats.c
> +++ b/libavfilter/formats.c
> @@ -331,6 +331,10 @@ static const AVFilterFormatsFilter filters_video[] = {
>  .conversion_filter = "scale",
>  .conversion_opts_offset = offsetof(AVFilterGraph, scale_sws_opts),
>  },
> +{
> +.conversion_filter = "hwmap",
> +.conversion_opts_offset = 0,
> +}
>  };
>
>  static const AVFilterFormatsFilter filters_audio[] = {
> -- 
> 2.39.1.windows.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v3 4/4] lavfi/vf_xfade_vulkan: add slide transitions

2023-06-06 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 58 +++
 1 file changed, 58 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index 58552ab734..f1f248c288 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -72,6 +72,10 @@ enum XFadeTransitions {
 WIPERIGHT,
 WIPEUP,
 WIPEDOWN,
+SLIDEDOWN,
+SLIDEUP,
+SLIDELEFT,
+SLIDERIGHT,
 NB_TRANSITIONS,
 };
 
@@ -128,12 +132,62 @@ static const char transition_wipedown[] = {
 C(0, } 
)
 };
 
+#define SHADER_SLIDE_COMMON
  \
+C(0, void slide(int idx, ivec2 pos, float progress, ivec2 direction)   
) \
+C(0, { 
) \
+C(1, ivec2 size = imageSize(output_images[idx]);   
) \
+C(1, ivec2 pi = ivec2(progress * size);
) \
+C(1, ivec2 p = pos + pi * direction;   
) \
+C(1, ivec2 f = p % size;   
) \
+C(1, f = f + size * ivec2(f.x < 0, f.y < 0);   
) \
+C(1, vec4 a = texture(a_images[idx], f);   
) \
+C(1, vec4 b = texture(b_images[idx], f);   
) \
+C(1, vec4 r = (p.y >= 0 && p.x >= 0 && size.y > p.y &&  size.x > p.x) 
? a : b; ) \
+C(1, imageStore(output_images[idx], pos, r);   
) \
+C(0, } 
)
+
+static const char transition_slidedown[] = {
+SHADER_SLIDE_COMMON
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, slide(idx, pos, progress, ivec2(0, -1));  
)
+C(0, } 
)
+};
+
+static const char transition_slideup[] = {
+SHADER_SLIDE_COMMON
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, slide(idx, pos, progress, ivec2(0, +1));  
)
+C(0, } 
)
+};
+
+static const char transition_slideleft[] = {
+SHADER_SLIDE_COMMON
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, slide(idx, pos, progress, ivec2(+1, 0));  
)
+C(0, } 
)
+};
+
+static const char transition_slideright[] = {
+SHADER_SLIDE_COMMON
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, slide(idx, pos, progress, ivec2(-1, 0));  
)
+C(0, } 
)
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
 [FADE]  = transition_fade,
 [WIPELEFT]  = transition_wipeleft,
 [WIPERIGHT] = transition_wiperight,
 [WIPEUP]= transition_wipeup,
 [WIPEDOWN]  = transition_wipedown,
+[SLIDEDOWN] = transition_slidedown,
+[SLIDEUP]   = transition_slideup,
+[SLIDELEFT] = transition_slideleft,
+[SLIDERIGHT]= transition_slideright,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -481,6 +535,10 @@ static const AVOption xfade_vulkan_options[] = {
 { "wiperight", "wipe right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPERIGHT}, 0, 0, FLAGS, "transition" },
 { "wipeup","wipe up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEUP}, 0, 0, FLAGS, "transition" },
 { "wipedown",  "wipe down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEDOWN}, 0, 0, FLAGS, "transition" },
+{ "slidedown", "slide down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEDOWN}, 0, 0, FLAGS, "transition" },
+{ "slideup",   "slide up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
+{ "slideleft", "slide left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDELEFT}, 0, 0, FLAGS, "transition" },
+{ "slideright","slide right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=SLIDERIGHT}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade 

[FFmpeg-devel] [PATCH v3 3/4] lavfi/vf_xfade_vulkan: add wipedown transition

2023-06-06 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index 0244802e9c..58552ab734 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -71,6 +71,7 @@ enum XFadeTransitions {
 WIPELEFT,
 WIPERIGHT,
 WIPEUP,
+WIPEDOWN,
 NB_TRANSITIONS,
 };
 
@@ -116,11 +117,23 @@ static const char transition_wipeup[] = {
 C(0, } 
)
 };
 
+static const char transition_wipedown[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, ivec2 size = imageSize(output_images[idx]);   
)
+C(1, int  s = int(size.y * progress);  
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, imageStore(output_images[idx], pos, pos.y > s ? a : b);   
)
+C(0, } 
)
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
 [FADE]  = transition_fade,
 [WIPELEFT]  = transition_wipeleft,
 [WIPERIGHT] = transition_wiperight,
 [WIPEUP]= transition_wipeup,
+[WIPEDOWN]  = transition_wipedown,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -467,6 +480,7 @@ static const AVOption xfade_vulkan_options[] = {
 { "wipeleft",  "wipe left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPELEFT}, 0, 0, FLAGS, "transition" },
 { "wiperight", "wipe right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPERIGHT}, 0, 0, FLAGS, "transition" },
 { "wipeup","wipe up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEUP}, 0, 0, FLAGS, "transition" },
+{ "wipedown",  "wipe down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEDOWN}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.37.0 (Apple Git-136)

___
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/4] lavfi/vf_xfade_vulkan: add wipeup transition

2023-06-06 Thread Marvin Scholz
---
 libavfilter/vf_xfade_vulkan.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index f18a7b33aa..0244802e9c 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -70,6 +70,7 @@ enum XFadeTransitions {
 FADE,
 WIPELEFT,
 WIPERIGHT,
+WIPEUP,
 NB_TRANSITIONS,
 };
 
@@ -104,10 +105,22 @@ static const char transition_wiperight[] = {
 C(0, } 
)
 };
 
+static const char transition_wipeup[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, ivec2 size = imageSize(output_images[idx]);   
)
+C(1, int  s = int(size.y * (1.0 - progress));  
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, imageStore(output_images[idx], pos, pos.y > s ? b : a);   
)
+C(0, } 
)
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
 [FADE]  = transition_fade,
 [WIPELEFT]  = transition_wipeleft,
 [WIPERIGHT] = transition_wiperight,
+[WIPEUP]= transition_wipeup,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -453,6 +466,7 @@ static const AVOption xfade_vulkan_options[] = {
 { "fade",  "fade transition", 0, AV_OPT_TYPE_CONST, {.i64=FADE}, 
0, 0, FLAGS, "transition" },
 { "wipeleft",  "wipe left transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPELEFT}, 0, 0, FLAGS, "transition" },
 { "wiperight", "wipe right transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPERIGHT}, 0, 0, FLAGS, "transition" },
+{ "wipeup","wipe up transition", 0, AV_OPT_TYPE_CONST, 
{.i64=WIPEUP}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { NULL }
-- 
2.37.0 (Apple Git-136)

___
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/4] libavfilter: add vf_xfade_vulkan

2023-06-06 Thread Marvin Scholz
This is an initial version of vf_xfade_vulkan based
on vf_xfade_opencl, for now only a subset of transitions
are supported.
---

Changes to v2:
- Fixed activate handling, same as in my patch for the xfade filter
- Added all remaining transitions the OpenCL filter supports

 configure |   1 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_xfade_vulkan.c | 499 ++
 4 files changed, 502 insertions(+)
 create mode 100644 libavfilter/vf_xfade_vulkan.c

diff --git a/configure b/configure
index 2992dae283..378cab1f3d 100755
--- a/configure
+++ b/configure
@@ -3824,6 +3824,7 @@ scale_vulkan_filter_deps="vulkan spirv_compiler"
 vpp_qsv_filter_deps="libmfx"
 vpp_qsv_filter_select="qsvvpp"
 xfade_opencl_filter_deps="opencl"
+xfade_vulkan_filter_deps="vulkan spirv_compiler"
 yadif_cuda_filter_deps="ffnvcodec"
 yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
 yadif_videotoolbox_filter_deps="metal corevideo videotoolbox"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 18935b1616..ff149a3733 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -552,6 +552,7 @@ OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
 OBJS-$(CONFIG_XCORRELATE_FILTER) += vf_convolve.o framesync.o
 OBJS-$(CONFIG_XFADE_FILTER)  += vf_xfade.o
 OBJS-$(CONFIG_XFADE_OPENCL_FILTER)   += vf_xfade_opencl.o opencl.o 
opencl/xfade.o
+OBJS-$(CONFIG_XFADE_VULKAN_FILTER)   += vf_xfade_vulkan.o vulkan.o 
vulkan_filter.o
 OBJS-$(CONFIG_XMEDIAN_FILTER)+= vf_xmedian.o framesync.o
 OBJS-$(CONFIG_XSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o yadif_common.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f1f781101b..6593e4eb83 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -519,6 +519,7 @@ extern const AVFilter ff_vf_xbr;
 extern const AVFilter ff_vf_xcorrelate;
 extern const AVFilter ff_vf_xfade;
 extern const AVFilter ff_vf_xfade_opencl;
+extern const AVFilter ff_vf_xfade_vulkan;
 extern const AVFilter ff_vf_xmedian;
 extern const AVFilter ff_vf_xstack;
 extern const AVFilter ff_vf_yadif;
diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
new file mode 100644
index 00..f18a7b33aa
--- /dev/null
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -0,0 +1,499 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/random_seed.h"
+#include "libavutil/opt.h"
+#include "vulkan_filter.h"
+#include "vulkan_spirv.h"
+#include "filters.h"
+#include "internal.h"
+
+#define IN_A  0
+#define IN_B  1
+#define IN_NB 2
+
+typedef struct XFadeParameters {
+float progress;
+} XFadeParameters;
+
+typedef struct XFadeVulkanContext {
+FFVulkanContext vkctx;
+
+int transition;
+int64_t duration;
+int64_t offset;
+
+int initialized;
+FFVulkanPipelinepl;
+FFVkExecPoole;
+FFVkQueueFamilyCtx  qf;
+FFVkSPIRVShader shd;
+VkSampler   sampler;
+
+// PTS when the fade should start (in IN_A timebase)
+int64_t start_pts;
+
+// PTS offset between IN_A and IN_B
+int64_t inputs_offset_pts;
+
+// Duration of the transition
+int64_t duration_pts;
+
+// Current PTS of the first input (IN_A)
+int64_t pts;
+
+// If frames are currently just passed through
+// unmodified, like before and after the actual
+// transition.
+int passthrough;
+
+int status[IN_NB];
+} XFadeVulkanContext;
+
+enum XFadeTransitions {
+FADE,
+WIPELEFT,
+WIPERIGHT,
+NB_TRANSITIONS,
+};
+
+static const char transition_fade[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, 

Re: [FFmpeg-devel] [PATCH 1/3] avutil/dict: add av_dict_pop

2023-06-04 Thread Marvin Scholz



On 4 Jun 2023, at 16:25, Stefano Sabatini wrote:

> On date Friday 2023-05-26 11:11:48 +0200, Marvin Scholz wrote:
>> On 26 May 2023, at 8:05, Stefano Sabatini wrote:
>>
>>> On date Monday 2023-05-22 11:23:24 +0200, Marvin Scholz wrote:
>>>> On 22 May 2023, at 1:52, Stefano Sabatini wrote:
> [...]
>>> Should we also support the case with multiple same-key values?
>>
>> I don't see what could be improved there. You just call it multiple times,
>> or what do you mean?
>>>
>
>>> Also maybe we should mention that this operation might alterate the
>>> order of the entries (unless we add a new flag to shift the
>>> trailing data when an entry is removed).
>>
>
>> We currently IIRC nowhere give guarantees on the order of items in the
>> dict, which we probably should keep that way especially in regards to
>> your next point.
>
> OK, anyway this is pretty unrelated to the current patch (might be
> done as a followup). I was checking the current documentation and it's
> missing some important information (I'll try to send a patch to fix
> that later).
>
> [...]
>
> About your patch, please mention that the pop operation is
> destructive. We probably want to make that behavior configurable
> through flags, but I'm fine to keep the current behavior for
> consistency with the set(NULL) operation.

What do you mean by "destructive"?

>
> [...]
>
> Thanks (sorry again for the slow reply).
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2] lavfi/vf_xfade: rewrite activate inputs handling

2023-06-02 Thread Marvin Scholz
The old code was not properly handling a bunch of edge-cases with
streams terminating earlier and also did not properly report back EOF
to the first input.

This fixes at least one case where the filter could stop doing
anything:

ffmpeg -f lavfi -i "color=blue:d=10" -f lavfi -i "color=aqua:d=0" 
-filter_complex "[0][1]xfade=duration=2:offset=0:transition=wiperight" -f null -
---

Changes to v1:

- Fix an issue discovered by Paul where the timestmap offset was incorrectly 
calculated
  leading to one frame with identical PTS as the previous one.
- Removed accidentally introduced trailing spaces

 libavfilter/vf_xfade.c | 212 -
 1 file changed, 124 insertions(+), 88 deletions(-)

diff --git a/libavfilter/vf_xfade.c b/libavfilter/vf_xfade.c
index a13a7db627..92f5139ec5 100644
--- a/libavfilter/vf_xfade.c
+++ b/libavfilter/vf_xfade.c
@@ -95,14 +95,23 @@ typedef struct XFadeContext {
 int depth;
 int is_rgb;
 
+// PTS when the fade should start (in first inputs timebase)
+int64_t start_pts;
+
+// PTS offset between first and second input
+int64_t inputs_offset_pts;
+
+// Duration of the transition
 int64_t duration_pts;
-int64_t offset_pts;
-int64_t first_pts;
-int64_t last_pts;
+
+// Current PTS of the first input
 int64_t pts;
-int xfade_is_over;
-int need_second;
-int eof[2];
+
+// If frames are currently just passed through unmodified,
+// like before and after the actual transition.
+int passthrough;
+
+int status[2];
 AVFrame *xf[2];
 int max_value;
 uint16_t black[4];
@@ -1935,12 +1944,10 @@ static int config_output(AVFilterLink *outlink)
 s->white[0] = s->white[3] = s->max_value;
 s->white[1] = s->white[2] = s->is_rgb ? s->max_value : s->max_value / 2;
 
-s->first_pts = s->last_pts = s->pts = AV_NOPTS_VALUE;
+s->start_pts = s->inputs_offset_pts = AV_NOPTS_VALUE;
 
 if (s->duration)
 s->duration_pts = av_rescale_q(s->duration, AV_TIME_BASE_Q, 
outlink->time_base);
-if (s->offset)
-s->offset_pts = av_rescale_q(s->offset, AV_TIME_BASE_Q, 
outlink->time_base);
 
 switch (s->transition) {
 case CUSTOM: s->transitionf = s->depth <= 8 ? custom8_transition : 
custom16_transition; break;
@@ -2037,7 +2044,7 @@ static int xfade_frame(AVFilterContext *ctx, AVFrame *a, 
AVFrame *b)
 {
 XFadeContext *s = ctx->priv;
 AVFilterLink *outlink = ctx->outputs[0];
-float progress = av_clipf(1.f - ((float)(s->pts - s->first_pts - 
s->offset_pts) / s->duration_pts), 0.f, 1.f);
+float progress = av_clipf(1.f - ((float)(s->pts - s->start_pts) / 
s->duration_pts), 0.f, 1.f);
 ThreadData td;
 AVFrame *out;
 
@@ -2055,99 +2062,128 @@ static int xfade_frame(AVFilterContext *ctx, AVFrame 
*a, AVFrame *b)
 return ff_filter_frame(outlink, out);
 }
 
-static int xfade_activate(AVFilterContext *ctx)
+static int forward_frame(XFadeContext *s,
+ AVFilterLink *inlink, AVFilterLink *outlink)
 {
-XFadeContext *s = ctx->priv;
-AVFilterLink *outlink = ctx->outputs[0];
-AVFrame *in = NULL;
+int64_t status_pts;
 int ret = 0, status;
-int64_t pts;
+AVFrame *frame = NULL;
 
-FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
+ret = ff_inlink_consume_frame(inlink, );
+if (ret < 0)
+return ret;
 
-if (s->xfade_is_over) {
-if (!s->eof[0]) {
-if (ff_inlink_queued_frames(ctx->inputs[0]) > 0) {
-ret = ff_inlink_consume_frame(ctx->inputs[0], );
-if (ret > 0)
-av_frame_free();
-}
-ff_inlink_set_status(ctx->inputs[0], AVERROR_EOF);
-s->eof[0] = 1;
-}
-ret = ff_inlink_consume_frame(ctx->inputs[1], );
-if (ret < 0) {
-return ret;
-} else if (ret > 0) {
-in->pts = (in->pts - s->last_pts) + s->pts;
-return ff_filter_frame(outlink, in);
-} else if (ff_inlink_acknowledge_status(ctx->inputs[1], , 
)) {
-ff_outlink_set_status(outlink, status, s->pts);
-return 0;
-} else if (!ret) {
-if (ff_outlink_frame_wanted(outlink))
-ff_inlink_request_frame(ctx->inputs[1]);
-return 0;
-}
+if (ret > 0) {
+// If we do not have an offset yet, it's because we
+// never got a first input. Just offset to 0
+if (s->inputs_offset_pts == AV_NOPTS_VALUE)
+s->inputs_offset_pts = -frame->pts;
+
+// We got a frame, nothing to do other than adjusting the timestamp
+frame->pts += s->inputs_offset_pts;
+return ff_filter_frame(outlink, frame);
 }
 
-if (ff_inlink_queued_frames(ctx->inputs[0]) > 0) {
-s->xf[0] = ff_inlink_peek_frame(ctx->inputs[0], 0);
-if (s->xf[0]) {
-if (s->first_pts == AV_NOPTS_VALUE) {
-s->first_pts = 

[FFmpeg-devel] [PATCH] lavfi/vf_xfade: rewrite activate inputs handling

2023-06-02 Thread Marvin Scholz
The old code was not properly handling a bunch of edge-cases with
streams terminating earlier and also did not properly report back EOF
to the first input.

This fixes at least one case where the filter could stop doing
anything:

ffmpeg -f lavfi -i "color=blue:d=10" -f lavfi -i "color=aqua:d=0" 
-filter_complex "[0][1]xfade=duration=2:offset=0:transition=wiperight" -f null -
---
 libavfilter/vf_xfade.c | 208 -
 1 file changed, 120 insertions(+), 88 deletions(-)

diff --git a/libavfilter/vf_xfade.c b/libavfilter/vf_xfade.c
index a13a7db627..f98ff81918 100644
--- a/libavfilter/vf_xfade.c
+++ b/libavfilter/vf_xfade.c
@@ -95,14 +95,23 @@ typedef struct XFadeContext {
 int depth;
 int is_rgb;
 
+// PTS when the fade should start (in first inputs timebase)
+int64_t start_pts;
+
+// PTS offset between first and second input
+int64_t inputs_offset_pts;
+
+// Duration of the transition
 int64_t duration_pts;
-int64_t offset_pts;
-int64_t first_pts;
-int64_t last_pts;
+
+// Current PTS of the first input
 int64_t pts;
-int xfade_is_over;
-int need_second;
-int eof[2];
+
+// If frames are currently just passed through unmodified,
+// like before and after the actual transition.
+int passthrough;
+
+int status[2];
 AVFrame *xf[2];
 int max_value;
 uint16_t black[4];
@@ -1935,12 +1944,10 @@ static int config_output(AVFilterLink *outlink)
 s->white[0] = s->white[3] = s->max_value;
 s->white[1] = s->white[2] = s->is_rgb ? s->max_value : s->max_value / 2;
 
-s->first_pts = s->last_pts = s->pts = AV_NOPTS_VALUE;
+s->start_pts = s->inputs_offset_pts = AV_NOPTS_VALUE;
 
 if (s->duration)
 s->duration_pts = av_rescale_q(s->duration, AV_TIME_BASE_Q, 
outlink->time_base);
-if (s->offset)
-s->offset_pts = av_rescale_q(s->offset, AV_TIME_BASE_Q, 
outlink->time_base);
 
 switch (s->transition) {
 case CUSTOM: s->transitionf = s->depth <= 8 ? custom8_transition : 
custom16_transition; break;
@@ -2037,7 +2044,7 @@ static int xfade_frame(AVFilterContext *ctx, AVFrame *a, 
AVFrame *b)
 {
 XFadeContext *s = ctx->priv;
 AVFilterLink *outlink = ctx->outputs[0];
-float progress = av_clipf(1.f - ((float)(s->pts - s->first_pts - 
s->offset_pts) / s->duration_pts), 0.f, 1.f);
+float progress = av_clipf(1.f - ((float)(s->pts - s->start_pts) / 
s->duration_pts), 0.f, 1.f);
 ThreadData td;
 AVFrame *out;
 
@@ -2055,99 +2062,124 @@ static int xfade_frame(AVFilterContext *ctx, AVFrame 
*a, AVFrame *b)
 return ff_filter_frame(outlink, out);
 }
 
-static int xfade_activate(AVFilterContext *ctx)
+static int forward_frame(XFadeContext *s,
+ AVFilterLink *inlink, AVFilterLink *outlink)
 {
-XFadeContext *s = ctx->priv;
-AVFilterLink *outlink = ctx->outputs[0];
-AVFrame *in = NULL;
+int64_t status_pts;
 int ret = 0, status;
-int64_t pts;
+AVFrame *frame = NULL;
 
-FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
+ret = ff_inlink_consume_frame(inlink, );
+if (ret < 0)
+return ret;
 
-if (s->xfade_is_over) {
-if (!s->eof[0]) {
-if (ff_inlink_queued_frames(ctx->inputs[0]) > 0) {
-ret = ff_inlink_consume_frame(ctx->inputs[0], );
-if (ret > 0)
-av_frame_free();
-}
-ff_inlink_set_status(ctx->inputs[0], AVERROR_EOF);
-s->eof[0] = 1;
-}
-ret = ff_inlink_consume_frame(ctx->inputs[1], );
-if (ret < 0) {
-return ret;
-} else if (ret > 0) {
-in->pts = (in->pts - s->last_pts) + s->pts;
-return ff_filter_frame(outlink, in);
-} else if (ff_inlink_acknowledge_status(ctx->inputs[1], , 
)) {
-ff_outlink_set_status(outlink, status, s->pts);
-return 0;
-} else if (!ret) {
-if (ff_outlink_frame_wanted(outlink))
-ff_inlink_request_frame(ctx->inputs[1]);
-return 0;
-}
+if (ret > 0) {
+// Calculate PTS offset to first input
+if (s->inputs_offset_pts == AV_NOPTS_VALUE)
+s->inputs_offset_pts = s->pts - frame->pts;
+
+// We got a frame, nothing to do other than adjusting the timestamp
+frame->pts += s->inputs_offset_pts;
+return ff_filter_frame(outlink, frame);
 }
 
-if (ff_inlink_queued_frames(ctx->inputs[0]) > 0) {
-s->xf[0] = ff_inlink_peek_frame(ctx->inputs[0], 0);
-if (s->xf[0]) {
-if (s->first_pts == AV_NOPTS_VALUE) {
-s->first_pts = s->xf[0]->pts;
-}
-s->pts = s->xf[0]->pts;
-if (s->first_pts + s->offset_pts > s->xf[0]->pts) {
-s->xf[0] = NULL;
-s->need_second = 0;
-ff_inlink_consume_frame(ctx->inputs[0], );
-return 

[FFmpeg-devel] [PATCH] lavfi/vf_blend_vulkan: fix leak on error

2023-06-02 Thread Marvin Scholz
---
 libavfilter/vf_blend_vulkan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_blend_vulkan.c b/libavfilter/vf_blend_vulkan.c
index 530f4981c2..717efcee41 100644
--- a/libavfilter/vf_blend_vulkan.c
+++ b/libavfilter/vf_blend_vulkan.c
@@ -249,7 +249,8 @@ static int blend_frame(FFFrameSync *fs)
 if (top_fc->sw_format != bottom_fc->sw_format) {
 av_log(avctx, AV_LOG_ERROR,
"Currently the sw format of the bottom video need to match 
the top!\n");
-return AVERROR(EINVAL);
+err = AVERROR(EINVAL);
+goto fail;
 }
 RET(init_filter(avctx));
 }
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH v2] libavfilter: add vf_xfade_vulkan

2023-05-29 Thread Marvin Scholz
This is an initial version of vf_xfade_vulkan based
on vf_xfade_opencl, for now only fade and wipeleft
transitions are supported.
---

Changes to v1:
 - Added proper configure _deps to require vulkan and
   the spirv compiler

This should fix the Patchwork build failure.

 configure |   1 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_xfade_vulkan.c | 441 ++
 4 files changed, 444 insertions(+)
 create mode 100644 libavfilter/vf_xfade_vulkan.c

diff --git a/configure b/configure
index 495493aa0e..a7c5897fd8 100755
--- a/configure
+++ b/configure
@@ -3777,6 +3777,7 @@ scale_vulkan_filter_deps="vulkan spirv_compiler"
 vpp_qsv_filter_deps="libmfx"
 vpp_qsv_filter_select="qsvvpp"
 xfade_opencl_filter_deps="opencl"
+xfade_vulkan_filter_deps="vulkan spirv_compiler"
 yadif_cuda_filter_deps="ffnvcodec"
 yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
 yadif_videotoolbox_filter_deps="metal corevideo videotoolbox"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 18935b1616..ff149a3733 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -552,6 +552,7 @@ OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
 OBJS-$(CONFIG_XCORRELATE_FILTER) += vf_convolve.o framesync.o
 OBJS-$(CONFIG_XFADE_FILTER)  += vf_xfade.o
 OBJS-$(CONFIG_XFADE_OPENCL_FILTER)   += vf_xfade_opencl.o opencl.o 
opencl/xfade.o
+OBJS-$(CONFIG_XFADE_VULKAN_FILTER)   += vf_xfade_vulkan.o vulkan.o 
vulkan_filter.o
 OBJS-$(CONFIG_XMEDIAN_FILTER)+= vf_xmedian.o framesync.o
 OBJS-$(CONFIG_XSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o yadif_common.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f1f781101b..6593e4eb83 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -519,6 +519,7 @@ extern const AVFilter ff_vf_xbr;
 extern const AVFilter ff_vf_xcorrelate;
 extern const AVFilter ff_vf_xfade;
 extern const AVFilter ff_vf_xfade_opencl;
+extern const AVFilter ff_vf_xfade_vulkan;
 extern const AVFilter ff_vf_xmedian;
 extern const AVFilter ff_vf_xstack;
 extern const AVFilter ff_vf_yadif;
diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
new file mode 100644
index 00..4a47c68fb4
--- /dev/null
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -0,0 +1,441 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/random_seed.h"
+#include "libavutil/opt.h"
+#include "vulkan_filter.h"
+#include "vulkan_spirv.h"
+#include "filters.h"
+#include "internal.h"
+
+#define IN_A 0
+#define IN_B 1
+
+enum XFadeTransitions {
+FADE,
+WIPELEFT,
+NB_TRANSITIONS,
+};
+
+typedef struct XFadeParameters {
+float progress;
+} XFadeParameters;
+
+typedef struct XFadeVulkanContext {
+FFVulkanContext vkctx;
+
+int transition;
+int64_t duration;
+int64_t offset;
+
+int initialized;
+FFVulkanPipelinepl;
+FFVkExecPoole;
+FFVkQueueFamilyCtx  qf;
+FFVkSPIRVShader shd;
+VkSampler   sampler;
+
+int64_t duration_pts;
+int64_t offset_pts;
+int64_t first_pts;
+int64_t last_pts;
+int64_t pts;
+int xfade_is_over;
+int need_second;
+int eof[2];
+AVFrame *xf[2];
+} XFadeVulkanContext;
+
+static const char transition_fade[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, imageStore(output_images[idx], pos, mix(b, a, progress)); 
)
+C(0, } 
)
+};
+
+static const char transition_wipeleft[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+

[FFmpeg-devel] [PATCH] libavfilter: add vf_xfade_vulkan

2023-05-29 Thread Marvin Scholz
This is an initial version of vf_xfade_vulkan based
on vf_xfade_opencl, for now only fade and wipeleft
transitions are supported.
---
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_xfade_vulkan.c | 441 ++
 3 files changed, 443 insertions(+)
 create mode 100644 libavfilter/vf_xfade_vulkan.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 18935b1616..ff149a3733 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -552,6 +552,7 @@ OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
 OBJS-$(CONFIG_XCORRELATE_FILTER) += vf_convolve.o framesync.o
 OBJS-$(CONFIG_XFADE_FILTER)  += vf_xfade.o
 OBJS-$(CONFIG_XFADE_OPENCL_FILTER)   += vf_xfade_opencl.o opencl.o 
opencl/xfade.o
+OBJS-$(CONFIG_XFADE_VULKAN_FILTER)   += vf_xfade_vulkan.o vulkan.o 
vulkan_filter.o
 OBJS-$(CONFIG_XMEDIAN_FILTER)+= vf_xmedian.o framesync.o
 OBJS-$(CONFIG_XSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o yadif_common.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f1f781101b..6593e4eb83 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -519,6 +519,7 @@ extern const AVFilter ff_vf_xbr;
 extern const AVFilter ff_vf_xcorrelate;
 extern const AVFilter ff_vf_xfade;
 extern const AVFilter ff_vf_xfade_opencl;
+extern const AVFilter ff_vf_xfade_vulkan;
 extern const AVFilter ff_vf_xmedian;
 extern const AVFilter ff_vf_xstack;
 extern const AVFilter ff_vf_yadif;
diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
new file mode 100644
index 00..4a47c68fb4
--- /dev/null
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -0,0 +1,441 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/random_seed.h"
+#include "libavutil/opt.h"
+#include "vulkan_filter.h"
+#include "vulkan_spirv.h"
+#include "filters.h"
+#include "internal.h"
+
+#define IN_A 0
+#define IN_B 1
+
+enum XFadeTransitions {
+FADE,
+WIPELEFT,
+NB_TRANSITIONS,
+};
+
+typedef struct XFadeParameters {
+float progress;
+} XFadeParameters;
+
+typedef struct XFadeVulkanContext {
+FFVulkanContext vkctx;
+
+int transition;
+int64_t duration;
+int64_t offset;
+
+int initialized;
+FFVulkanPipelinepl;
+FFVkExecPoole;
+FFVkQueueFamilyCtx  qf;
+FFVkSPIRVShader shd;
+VkSampler   sampler;
+
+int64_t duration_pts;
+int64_t offset_pts;
+int64_t first_pts;
+int64_t last_pts;
+int64_t pts;
+int xfade_is_over;
+int need_second;
+int eof[2];
+AVFrame *xf[2];
+} XFadeVulkanContext;
+
+static const char transition_fade[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, imageStore(output_images[idx], pos, mix(b, a, progress)); 
)
+C(0, } 
)
+};
+
+static const char transition_wipeleft[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, ivec2 size = imageSize(output_images[idx]);   
)
+C(1, int  s = int(size.x * progress);  
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, imageStore(output_images[idx], pos, pos.x > s ? b : a);   
)
+C(0, } 
)
+};
+
+static av_cold int init_filter(AVFilterContext *avctx)
+{
+int 

Re: [FFmpeg-devel] [PATCH 1/3] avutil/dict: add av_dict_pop

2023-05-26 Thread Marvin Scholz


On 26 May 2023, at 22:02, Michael Niedermayer wrote:

> On Fri, May 26, 2023 at 11:11:48AM +0200, Marvin Scholz wrote:
>>
>>
>> On 26 May 2023, at 8:05, Stefano Sabatini wrote:
>>
>>> On date Monday 2023-05-22 11:23:24 +0200, Marvin Scholz wrote:
>>>> On 22 May 2023, at 1:52, Stefano Sabatini wrote:
>>>>
>>>>> On date Monday 2023-05-01 13:44:54 +0200, Marvin Scholz wrote:
>>>>>> This new API allows to remove an entry and obtain ownership of the
>>>>>> key/value that was associated with the removed entry.
>>>>
>>>> Thanks for the review!
>>>>
>>>>>> ---
>>>>>>  doc/APIchanges |  4 
>>>>>>  libavutil/dict.c   | 27 +++
>>>>>>  libavutil/dict.h   | 20 
>>>>>>  libavutil/tests/dict.c | 34 ++
>>>>>>  libavutil/version.h|  2 +-
>>>>>>  tests/ref/fate/dict| 12 
>>>>>>  6 files changed, 98 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/doc/APIchanges b/doc/APIchanges
>>>>>> index 0b609e3d3b..5b807873b7 100644
>>>>>> --- a/doc/APIchanges
>>>>>> +++ b/doc/APIchanges
>>>>>> @@ -2,6 +2,10 @@ The last version increases of all libraries were on 
>>>>>> 2023-02-09
>>>>>>
>>>>>>  API changes, most recent first:
>>>>>>
>>>>>> +2023-04-29 - xx - lavu 58.7.100 - dict.c
>>>>>> +  Add av_dict_pop() to remove an entry from a dict
>>>>>> +  and get ownership of the removed key/value.
>>>>>> +
>>>>>>  2023-04-10 - xx - lavu 58.6.100 - frame.h
>>>>>>av_frame_get_plane_buffer() now accepts const AVFrame*.
>>>>>>
>>>>>> diff --git a/libavutil/dict.c b/libavutil/dict.c
>>>>>> index f673977a98..ac41771994 100644
>>>>>> --- a/libavutil/dict.c
>>>>>> +++ b/libavutil/dict.c
>>>>>> @@ -173,6 +173,33 @@ int av_dict_set_int(AVDictionary **pm, const char 
>>>>>> *key, int64_t value,
>>>>>>  return av_dict_set(pm, key, valuestr, flags);
>>>>>>  }
>>>>>>
>>>>>> +int av_dict_pop(AVDictionary **pm, const char *key,
>>>>>> +char **out_key, char **out_value, int flags)
>>>>>> +{
>>>>>> +AVDictionary *m = *pm;
>>>>>> +AVDictionaryEntry *entry = NULL;
>>>>>> +entry = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags);
>>>>>> +if (!entry)
>>>>>> +return AVERROR(ENOENT);
>>>>>> +
>>>>>> +if (out_key)
>>>>>> +*out_key = entry->key;
>>>>>> +else
>>>>>> +av_free(entry->key);
>>>>>> +
>>>>>> +if (out_value)
>>>>>> +*out_value = entry->value;
>>>>>> +else
>>>>>> +av_free(entry->value);
>>>>>> +
>>>>>> +*entry = m->elems[--m->count];
>>>>>
>>>>>> +if (m && !m->count) {
>>>>>> +av_freep(>elems);
>>>>>> +av_freep(pm);
>>>>>> +}
>>>>>
>>>>> I'm not sure this is the right behavior. Should we clear the
>>>>> dictionary when it is empty? What if you need to refill it later?
>>>>>
>>>>
>>>
>>>> Thats the same behaviour as if you use av_dict_set to remove all items
>>>> and IMO this should be consistent.
>>>
>>>> Additionally NULL means an empty AVDictionary, suddenly
>>>> having a non-NULL but empty dictionary seems like a very bad idea.
>>>
>>> Sorry for the slow reply, I see.
>>>
>>> [...]
>>>>>> +/**
>>>>>> + * Remove the entry with the given key from the dictionary.
>>>>>> + *
>>>>>
>>>>>> + * Search for an entry matching `key` and remove it, if found. 
>>>>>> Optionally
>>>>>
>>>>> Not sure the `foo` syntax is supported by doxygen (and probably we
>>>>> sh

Re: [FFmpeg-devel] [PATCH 1/3] avutil/dict: add av_dict_pop

2023-05-26 Thread Marvin Scholz


On 26 May 2023, at 8:05, Stefano Sabatini wrote:

> On date Monday 2023-05-22 11:23:24 +0200, Marvin Scholz wrote:
>> On 22 May 2023, at 1:52, Stefano Sabatini wrote:
>>
>>> On date Monday 2023-05-01 13:44:54 +0200, Marvin Scholz wrote:
>>>> This new API allows to remove an entry and obtain ownership of the
>>>> key/value that was associated with the removed entry.
>>
>> Thanks for the review!
>>
>>>> ---
>>>>  doc/APIchanges |  4 
>>>>  libavutil/dict.c   | 27 +++
>>>>  libavutil/dict.h   | 20 
>>>>  libavutil/tests/dict.c | 34 ++
>>>>  libavutil/version.h|  2 +-
>>>>  tests/ref/fate/dict| 12 
>>>>  6 files changed, 98 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/doc/APIchanges b/doc/APIchanges
>>>> index 0b609e3d3b..5b807873b7 100644
>>>> --- a/doc/APIchanges
>>>> +++ b/doc/APIchanges
>>>> @@ -2,6 +2,10 @@ The last version increases of all libraries were on 
>>>> 2023-02-09
>>>>
>>>>  API changes, most recent first:
>>>>
>>>> +2023-04-29 - xx - lavu 58.7.100 - dict.c
>>>> +  Add av_dict_pop() to remove an entry from a dict
>>>> +  and get ownership of the removed key/value.
>>>> +
>>>>  2023-04-10 - xx - lavu 58.6.100 - frame.h
>>>>av_frame_get_plane_buffer() now accepts const AVFrame*.
>>>>
>>>> diff --git a/libavutil/dict.c b/libavutil/dict.c
>>>> index f673977a98..ac41771994 100644
>>>> --- a/libavutil/dict.c
>>>> +++ b/libavutil/dict.c
>>>> @@ -173,6 +173,33 @@ int av_dict_set_int(AVDictionary **pm, const char 
>>>> *key, int64_t value,
>>>>  return av_dict_set(pm, key, valuestr, flags);
>>>>  }
>>>>
>>>> +int av_dict_pop(AVDictionary **pm, const char *key,
>>>> +char **out_key, char **out_value, int flags)
>>>> +{
>>>> +AVDictionary *m = *pm;
>>>> +AVDictionaryEntry *entry = NULL;
>>>> +entry = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags);
>>>> +if (!entry)
>>>> +return AVERROR(ENOENT);
>>>> +
>>>> +if (out_key)
>>>> +*out_key = entry->key;
>>>> +else
>>>> +av_free(entry->key);
>>>> +
>>>> +if (out_value)
>>>> +*out_value = entry->value;
>>>> +else
>>>> +av_free(entry->value);
>>>> +
>>>> +*entry = m->elems[--m->count];
>>>
>>>> +if (m && !m->count) {
>>>> +av_freep(>elems);
>>>> +av_freep(pm);
>>>> +}
>>>
>>> I'm not sure this is the right behavior. Should we clear the
>>> dictionary when it is empty? What if you need to refill it later?
>>>
>>
>
>> Thats the same behaviour as if you use av_dict_set to remove all items
>> and IMO this should be consistent.
>
>> Additionally NULL means an empty AVDictionary, suddenly
>> having a non-NULL but empty dictionary seems like a very bad idea.
>
> Sorry for the slow reply, I see.
>
> [...]
>>>> +/**
>>>> + * Remove the entry with the given key from the dictionary.
>>>> + *
>>>
>>>> + * Search for an entry matching `key` and remove it, if found. Optionally
>>>
>>> Not sure the `foo` syntax is supported by doxygen (and probably we
>>> should eschew it for consistency with the other doxys).
>>>
>>
>> I tested it locally and it works fine and its much more readable than the
>> alternatives.
>>
>> However if you feel it should be removed I am happy to do that, I have no
>> strong opinions there.
>
> Please let's avoid to add more syntax variance (also I'm not sure when
> the `var` syntax was introduced).
>

Ok I will submit a new patch with it removed.

> [...]
>
> Should we also support the case with multiple same-key values?

I don't see what could be improved there. You just call it multiple times,
or what do you mean?

>
> Also maybe we should mention that this operation might alterate the
> order of the entries (unless we add a new flag to shift the
> trailing data when an entry is removed).

We currently IIRC nowhere give guarantees on the order 

[FFmpeg-devel] [PATCH v3 2/2] avfilter/vf_tpad: accept hardware frames in clone-only mode

2023-05-22 Thread Marvin Scholz
When no drawing is to be performed, tpad can work fine with
hardware frames, so advertise this in the query_formats
callback and ensure the drawing context is never initialised
when just cloning frames.
---
 libavfilter/vf_tpad.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index d0fa7df8be..c2e266cb1a 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -71,7 +71,12 @@ AVFILTER_DEFINE_CLASS(tpad);
 
 static int query_formats(AVFilterContext *ctx)
 {
-return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+TPadContext *s = ctx->priv;
+if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
+(s->start_mode == MODE_ADD && s->pad_start != 0))
+return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+
+return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO));
 }
 
 static int activate(AVFilterContext *ctx)
@@ -190,8 +195,11 @@ static int config_input(AVFilterLink *inlink)
 AVFilterContext *ctx = inlink->dst;
 TPadContext *s = ctx->priv;
 
-ff_draw_init(>draw, inlink->format, 0);
-ff_draw_color(>draw, >color, s->rgba_color);
+if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
+(s->start_mode == MODE_ADD && s->pad_start != 0)) {
+ff_draw_init(>draw, inlink->format, 0);
+ff_draw_color(>draw, >color, s->rgba_color);
+}
 
 if (s->start_duration)
 s->pad_start = av_rescale_q(s->start_duration, inlink->frame_rate, 
av_inv_q(AV_TIME_BASE_Q));
-- 
2.37.0 (Apple Git-136)

___
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/vf_tpad: use enum for start/stop_mode

2023-05-22 Thread Marvin Scholz
---
 libavfilter/vf_tpad.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index f0c065f0c3..d0fa7df8be 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -27,6 +27,12 @@
 #include "formats.h"
 #include "drawutils.h"
 
+enum PadMode {
+MODE_ADD = 0,
+MODE_CLONE,
+NB_MODE
+};
+
 typedef struct TPadContext {
 const AVClass *class;
 int pad_start;
@@ -51,10 +57,10 @@ typedef struct TPadContext {
 static const AVOption tpad_options[] = {
 { "start", "set the number of frames to delay input",  
OFFSET(pad_start),  AV_OPT_TYPE_INT,   {.i64=0},0,   INT_MAX, VF },
 { "stop",  "set the number of frames to add after input finished", 
OFFSET(pad_stop),   AV_OPT_TYPE_INT,   {.i64=0},   -1,   INT_MAX, VF },
-{ "start_mode", "set the mode of added frames to start",   
OFFSET(start_mode), AV_OPT_TYPE_INT,   {.i64=0},0, 1, VF, 
"mode" },
-{ "add",   "add solid-color frames",   0,  
AV_OPT_TYPE_CONST, {.i64=0},0, 0, VF, "mode" },
-{ "clone", "clone first/last frame",   0,  
AV_OPT_TYPE_CONST, {.i64=1},0, 0, VF, "mode" },
-{ "stop_mode",  "set the mode of added frames to end", 
OFFSET(stop_mode),  AV_OPT_TYPE_INT,   {.i64=0},0, 1, VF, 
"mode" },
+{ "start_mode", "set the mode of added frames to start",   
OFFSET(start_mode), AV_OPT_TYPE_INT,   {.i64=MODE_ADD}, 0, NB_MODE-1, VF, 
"mode" },
+{ "add",   "add solid-color frames",   0,  
AV_OPT_TYPE_CONST, {.i64=MODE_ADD},   0, 0, VF, "mode" },
+{ "clone", "clone first/last frame",   0,  
AV_OPT_TYPE_CONST, {.i64=MODE_CLONE}, 0, 0, VF, "mode" },
+{ "stop_mode",  "set the mode of added frames to end", 
OFFSET(stop_mode),  AV_OPT_TYPE_INT,   {.i64=MODE_ADD}, 0, NB_MODE-1, VF, 
"mode" },
 { "start_duration", "set the duration to delay input", 
OFFSET(start_duration), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, VF },
 { "stop_duration",  "set the duration to pad input",   
OFFSET(stop_duration),  AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, VF },
 { "color", "set the color of the added frames",
OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str="black"},  0, 0, VF },
@@ -91,7 +97,7 @@ static int activate(AVFilterContext *ctx)
 }
 }
 
-if (s->start_mode == 0 && s->pad_start > 0 && 
ff_outlink_frame_wanted(outlink)) {
+if (s->start_mode == MODE_ADD && s->pad_start > 0 && 
ff_outlink_frame_wanted(outlink)) {
 frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!frame)
 return AVERROR(ENOMEM);
@@ -106,7 +112,7 @@ static int activate(AVFilterContext *ctx)
 return ff_filter_frame(outlink, frame);
 }
 
-if (s->start_mode == 1 && s->pad_start > 0) {
+if (s->start_mode == MODE_CLONE && s->pad_start > 0) {
 if (s->eof) {
 ff_outlink_set_status(outlink, AVERROR_EOF, 0);
 return 0;
@@ -133,7 +139,7 @@ static int activate(AVFilterContext *ctx)
 if (ret < 0)
 return ret;
 if (ret > 0) {
-if (s->stop_mode == 1 && s->pad_stop != 0) {
+if (s->stop_mode == MODE_CLONE && s->pad_stop != 0) {
 av_frame_free(>cache_stop);
 s->cache_stop = av_frame_clone(frame);
 }
@@ -147,14 +153,14 @@ static int activate(AVFilterContext *ctx)
 ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
 return 0;
 }
-if (s->stop_mode == 0) {
+if (s->stop_mode == MODE_ADD) {
 frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!frame)
 return AVERROR(ENOMEM);
 ff_fill_rectangle(>draw, >color,
   frame->data, frame->linesize,
   0, 0, frame->width, frame->height);
-} else if (s->stop_mode == 1) {
+} else if (s->stop_mode == MODE_CLONE) {
 if (!s->cache_stop) {
 s->pad_stop = 0;
 ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
-- 
2.37.0 (Apple Git-136)

___
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/3] avutil/dict: add av_dict_pop

2023-05-22 Thread Marvin Scholz



On 22 May 2023, at 1:52, Stefano Sabatini wrote:

> On date Monday 2023-05-01 13:44:54 +0200, Marvin Scholz wrote:
>> This new API allows to remove an entry and obtain ownership of the
>> key/value that was associated with the removed entry.

Thanks for the review!

>> ---
>>  doc/APIchanges |  4 
>>  libavutil/dict.c   | 27 +++
>>  libavutil/dict.h   | 20 
>>  libavutil/tests/dict.c | 34 ++
>>  libavutil/version.h|  2 +-
>>  tests/ref/fate/dict| 12 
>>  6 files changed, 98 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/APIchanges b/doc/APIchanges
>> index 0b609e3d3b..5b807873b7 100644
>> --- a/doc/APIchanges
>> +++ b/doc/APIchanges
>> @@ -2,6 +2,10 @@ The last version increases of all libraries were on 
>> 2023-02-09
>>
>>  API changes, most recent first:
>>
>> +2023-04-29 - xx - lavu 58.7.100 - dict.c
>> +  Add av_dict_pop() to remove an entry from a dict
>> +  and get ownership of the removed key/value.
>> +
>>  2023-04-10 - xx - lavu 58.6.100 - frame.h
>>av_frame_get_plane_buffer() now accepts const AVFrame*.
>>
>> diff --git a/libavutil/dict.c b/libavutil/dict.c
>> index f673977a98..ac41771994 100644
>> --- a/libavutil/dict.c
>> +++ b/libavutil/dict.c
>> @@ -173,6 +173,33 @@ int av_dict_set_int(AVDictionary **pm, const char *key, 
>> int64_t value,
>>  return av_dict_set(pm, key, valuestr, flags);
>>  }
>>
>> +int av_dict_pop(AVDictionary **pm, const char *key,
>> +char **out_key, char **out_value, int flags)
>> +{
>> +AVDictionary *m = *pm;
>> +AVDictionaryEntry *entry = NULL;
>> +entry = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags);
>> +if (!entry)
>> +return AVERROR(ENOENT);
>> +
>> +if (out_key)
>> +*out_key = entry->key;
>> +else
>> +av_free(entry->key);
>> +
>> +if (out_value)
>> +*out_value = entry->value;
>> +else
>> +av_free(entry->value);
>> +
>> +*entry = m->elems[--m->count];
>
>> +if (m && !m->count) {
>> +av_freep(>elems);
>> +av_freep(pm);
>> +}
>
> I'm not sure this is the right behavior. Should we clear the
> dictionary when it is empty? What if you need to refill it later?
>

Thats the same behaviour as if you use av_dict_set to remove all items
and IMO this should be consistent.
Additionally NULL means an empty AVDictionary, suddenly
having a non-NULL but empty dictionary seems like a very bad idea.

>> +return 0;
>> +}
>> +
>>  static int parse_key_value_pair(AVDictionary **pm, const char **buf,
>>  const char *key_val_sep, const char 
>> *pairs_sep,
>>  int flags)
>> diff --git a/libavutil/dict.h b/libavutil/dict.h
>> index 713c9e361a..b2ab55a026 100644
>> --- a/libavutil/dict.h
>> +++ b/libavutil/dict.h
>> @@ -172,6 +172,26 @@ int av_dict_set(AVDictionary **pm, const char *key, 
>> const char *value, int flags
>>   */
>>  int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int 
>> flags);
>>
>> +/**
>> + * Remove the entry with the given key from the dictionary.
>> + *
>
>> + * Search for an entry matching `key` and remove it, if found. Optionally
>
> Not sure the `foo` syntax is supported by doxygen (and probably we
> should eschew it for consistency with the other doxys).
>

I tested it locally and it works fine and its much more readable than the
alternatives.

However if you feel it should be removed I am happy to do that, I have no
strong opinions there.

>> + * the found key and/or value can be returned using the 
>> `out_key`/`out_value`
>> + * arguments.
>
> ___
> 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] lavc/videotoolboxenc: support additional options

2023-05-20 Thread Marvin Scholz



On 21 May 2023, at 0:24, Rick Kern wrote:

> Added support for more VideoToolbox encoder options:
> - qmin and qmax options are now used
> - max_slice_bytes: Max number of bytes per H.264 slice
> - max_ref_frames: Limit the number of reference frames
> - Disable open GOP when the cgop flag is set
> - power_efficient: Enable power-efficient mode
> ---
>  libavcodec/videotoolboxenc.c | 177 ++-
>  1 file changed, 176 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index b017c90c36..be29d13629 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -120,6 +120,11 @@ static struct{
>  CFStringRef 
> kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder;
>  CFStringRef 
> kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder;
>  CFStringRef kVTVideoEncoderSpecification_EnableLowLatencyRateControl;
> +CFStringRef kVTCompressionPropertyKey_AllowOpenGOP;
> +CFStringRef kVTCompressionPropertyKey_MaximizePowerEfficiency;
> +CFStringRef kVTCompressionPropertyKey_ReferenceBufferCount;
> +CFStringRef kVTCompressionPropertyKey_MaxAllowedFrameQP;
> +CFStringRef kVTCompressionPropertyKey_MinAllowedFrameQP;
>
>  getParameterSetAtIndex 
> CMVideoFormatDescriptionGetHEVCParameterSetAtIndex;
>  } compat_keys;
> @@ -188,6 +193,13 @@ static void loadVTEncSymbols(void){
>  "RequireHardwareAcceleratedVideoEncoder");
>  GET_SYM(kVTVideoEncoderSpecification_EnableLowLatencyRateControl,
>  "EnableLowLatencyRateControl");
> +GET_SYM(kVTCompressionPropertyKey_AllowOpenGOP, "AllowOpenGOP");
> +GET_SYM(kVTCompressionPropertyKey_MaximizePowerEfficiency,
> +"MaximizePowerEfficiency");
> +GET_SYM(kVTCompressionPropertyKey_ReferenceBufferCount,
> +"ReferenceBufferCount");
> +GET_SYM(kVTCompressionPropertyKey_MaxAllowedFrameQP, 
> "MaxAllowedFrameQP");
> +GET_SYM(kVTCompressionPropertyKey_MinAllowedFrameQP, 
> "MinAllowedFrameQP");
>  }
>
>  typedef enum VT_H264Profile {
> @@ -268,6 +280,10 @@ typedef struct VTEncContext {
>
>  /* can't be bool type since AVOption will access it as int */
>  int a53_cc;
> +
> +int max_slice_bytes;
> +int power_efficient;
> +int max_ref_frames;
>  } VTEncContext;
>
>  static int vtenc_populate_extradata(AVCodecContext   *avctx,
> @@ -1106,6 +1122,78 @@ static bool vtenc_qscale_enabled(void)
>  return !TARGET_OS_IPHONE && TARGET_CPU_ARM64;
>  }
>
> +static int set_encoder_int_property_or_log(
> +AVCodecContext* avctx,
> +CFStringRef key,
> +const char* print_option_name,
> +int value) {

Nit: These should probably be aligned with the opening brace,
like other functions do in this file.

> +int status;
> +VTEncContext *vtctx = avctx->priv_data;
> +CFNumberRef value_cfnum = CFNumberCreate(
> +kCFAllocatorDefault,
> +kCFNumberIntType,
> +);
> +
> +if (value_cfnum == NULL) {
> +return AVERROR(ENOMEM);
> +}
> +
> +status = VTSessionSetProperty(vtctx->session, key, value_cfnum);
> +if (status == kVTPropertyNotSupportedErr) {
> +av_log(
> +avctx,
> +AV_LOG_INFO,
> +"This device does not support the %s option. Value %d 
> ignored.\n",
> +print_option_name,
> +value);
> +} else if (status != 0) {
> +av_log(
> +avctx,
> +AV_LOG_ERROR,
> +"Error setting %s=%d: Error %d\n",
> +print_option_name,
> +value,
> +status);
> +}
> +
> +CFRelease (value_cfnum);
> +
> +return 0;
> +}
> +
> +static int set_encoder_bool_property_or_log(
> +AVCodecContext* avctx,
> +CFStringRef key,
> +const char* print_option_name,
> +int value) {

Nit: These should probably be aligned with the opening brace,
like other functions do in this file.

> +int status;
> +VTEncContext *vtctx = avctx->priv_data;
> +
> +status = VTSessionSetProperty(
> +vtctx->session,
> +key,
> +value ? kCFBooleanTrue : kCFBooleanFalse);
> +
> +if (status == kVTPropertyNotSupportedErr) {
> +av_log(
> +avctx,
> +AV_LOG_INFO,
> +"This device does not support the %s option. Value %d 
> ignored.\n",
> +print_option_name,
> +value);
> +} else if (status != 0) {
> +av_log(
> +avctx,
> +AV_LOG_ERROR,
> +"Error setting %s=%d: Error %d\n",
> +print_option_name,
> +value,
> +status);
> +}
> +
> +return 0;
> +}

You could avoid the repetition here by having a separate function that
takes a CFTypeRef and does the set + error handling + log part.

> +
>  static int vtenc_create_encoder(AVCodecContext   *avctx,
>  

[FFmpeg-devel] [PATCH 1/2] avfilter/vf_tpad: use enum for start/stop_mode

2023-05-01 Thread Marvin Scholz
---
 libavfilter/vf_tpad.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index f0c065f0c3..88c3c99de4 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -27,6 +27,12 @@
 #include "formats.h"
 #include "drawutils.h"
 
+enum PadMode {
+MODE_ADD = 0,
+MODE_CLONE,
+NB_MODE
+};
+
 typedef struct TPadContext {
 const AVClass *class;
 int pad_start;
@@ -51,10 +57,10 @@ typedef struct TPadContext {
 static const AVOption tpad_options[] = {
 { "start", "set the number of frames to delay input",  
OFFSET(pad_start),  AV_OPT_TYPE_INT,   {.i64=0},0,   INT_MAX, VF },
 { "stop",  "set the number of frames to add after input finished", 
OFFSET(pad_stop),   AV_OPT_TYPE_INT,   {.i64=0},   -1,   INT_MAX, VF },
-{ "start_mode", "set the mode of added frames to start",   
OFFSET(start_mode), AV_OPT_TYPE_INT,   {.i64=0},0, 1, VF, 
"mode" },
-{ "add",   "add solid-color frames",   0,  
AV_OPT_TYPE_CONST, {.i64=0},0, 0, VF, "mode" },
-{ "clone", "clone first/last frame",   0,  
AV_OPT_TYPE_CONST, {.i64=1},0, 0, VF, "mode" },
-{ "stop_mode",  "set the mode of added frames to end", 
OFFSET(stop_mode),  AV_OPT_TYPE_INT,   {.i64=0},0, 1, VF, 
"mode" },
+{ "start_mode", "set the mode of added frames to start",   
OFFSET(start_mode), AV_OPT_TYPE_INT,   {.i64=MODE_ADD}, 0, NB_MODE-1, VF, 
"mode" },
+{ "add",   "add solid-color frames",   0,  
AV_OPT_TYPE_CONST, {.i64=MODE_ADD},   0, 0, VF, "mode" },
+{ "clone", "clone first/last frame",   0,  
AV_OPT_TYPE_CONST, {.i64=MODE_CLONE}, 0, 0, VF, "mode" },
+{ "stop_mode",  "set the mode of added frames to end", 
OFFSET(stop_mode),  AV_OPT_TYPE_INT,   {.i64=0},0, NB_MODE-1, VF, 
"mode" },
 { "start_duration", "set the duration to delay input", 
OFFSET(start_duration), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, VF },
 { "stop_duration",  "set the duration to pad input",   
OFFSET(stop_duration),  AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, VF },
 { "color", "set the color of the added frames",
OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str="black"},  0, 0, VF },
@@ -91,7 +97,7 @@ static int activate(AVFilterContext *ctx)
 }
 }
 
-if (s->start_mode == 0 && s->pad_start > 0 && 
ff_outlink_frame_wanted(outlink)) {
+if (s->start_mode == MODE_ADD && s->pad_start > 0 && 
ff_outlink_frame_wanted(outlink)) {
 frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!frame)
 return AVERROR(ENOMEM);
@@ -106,7 +112,7 @@ static int activate(AVFilterContext *ctx)
 return ff_filter_frame(outlink, frame);
 }
 
-if (s->start_mode == 1 && s->pad_start > 0) {
+if (s->start_mode == MODE_CLONE && s->pad_start > 0) {
 if (s->eof) {
 ff_outlink_set_status(outlink, AVERROR_EOF, 0);
 return 0;
@@ -133,7 +139,7 @@ static int activate(AVFilterContext *ctx)
 if (ret < 0)
 return ret;
 if (ret > 0) {
-if (s->stop_mode == 1 && s->pad_stop != 0) {
+if (s->stop_mode == MODE_CLONE && s->pad_stop != 0) {
 av_frame_free(>cache_stop);
 s->cache_stop = av_frame_clone(frame);
 }
@@ -147,14 +153,14 @@ static int activate(AVFilterContext *ctx)
 ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
 return 0;
 }
-if (s->stop_mode == 0) {
+if (s->stop_mode == MODE_ADD) {
 frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!frame)
 return AVERROR(ENOMEM);
 ff_fill_rectangle(>draw, >color,
   frame->data, frame->linesize,
   0, 0, frame->width, frame->height);
-} else if (s->stop_mode == 1) {
+} else if (s->stop_mode == MODE_CLONE) {
 if (!s->cache_stop) {
 s->pad_stop = 0;
 ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
-- 
2.37.0 (Apple Git-136)

___
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] avfilter/vf_tpad: accept hardware frames in clone-only mode

2023-05-01 Thread Marvin Scholz
When no drawing is to be performed, tpad can work fine with
hardware frames, so advertise this in the query_formats
callback and ensure the drawing context is never initialised
when just cloning frames.
---
 libavfilter/vf_tpad.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index 88c3c99de4..cabfe33685 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -71,7 +71,12 @@ AVFILTER_DEFINE_CLASS(tpad);
 
 static int query_formats(AVFilterContext *ctx)
 {
-return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+TPadContext *s = ctx->priv;
+if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
+(s->start_mode == MODE_ADD && s->pad_start != 0))
+return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+
+return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO));
 }
 
 static int activate(AVFilterContext *ctx)
@@ -190,8 +195,11 @@ static int config_input(AVFilterLink *inlink)
 AVFilterContext *ctx = inlink->dst;
 TPadContext *s = ctx->priv;
 
-ff_draw_init(>draw, inlink->format, 0);
-ff_draw_color(>draw, >color, s->rgba_color);
+if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
+(s->start_mode == MODE_ADD && s->pad_start != 0)) {
+ff_draw_init(>draw, inlink->format, 0);
+ff_draw_color(>draw, >color, s->rgba_color);
+}
 
 if (s->start_duration)
 s->pad_start = av_rescale_q(s->start_duration, inlink->frame_rate, 
av_inv_q(AV_TIME_BASE_Q));
-- 
2.37.0 (Apple Git-136)

___
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] avutil/dict: constify av_dict_get return

2023-05-01 Thread Marvin Scholz
---
 doc/examples/qsv_transcode.c   |  2 +-
 libavcodec/libaomenc.c |  2 +-
 libavcodec/libkvazaar.c|  2 +-
 libavcodec/libsvtav1.c |  2 +-
 libavcodec/libvpxenc.c |  2 +-
 libavcodec/libx264.c   |  2 +-
 libavcodec/libx265.c   |  2 +-
 libavcodec/mjpegdec.c  |  2 +-
 libavcodec/qsvenc.c|  2 +-
 libavfilter/avfilter.c |  2 +-
 libavfilter/f_bench.c  |  2 +-
 libavfilter/f_drawgraph.c  |  2 +-
 libavfilter/f_select.c |  4 +--
 libavfilter/vf_cover_rect.c|  2 +-
 libavfilter/vf_drawtext.c  |  2 +-
 libavformat/aiffenc.c  |  2 +-
 libavformat/argo_asf.c |  2 +-
 libavformat/asfenc.c   |  6 ++--
 libavformat/au.c   |  2 +-
 libavformat/avformat.h |  2 +-
 libavformat/avidec.c   |  2 +-
 libavformat/avienc.c   |  2 +-
 libavformat/avio.c |  4 +--
 libavformat/dashenc.c  |  6 ++--
 libavformat/dvenc.c|  2 +-
 libavformat/flacdec.c  |  2 +-
 libavformat/flacenc.c  |  6 ++--
 libavformat/flvdec.c   |  2 +-
 libavformat/gxfenc.c   |  2 +-
 libavformat/http.c |  8 +++---
 libavformat/id3v2.c|  6 ++--
 libavformat/id3v2enc.c |  2 +-
 libavformat/imfdec.c   |  2 +-
 libavformat/matroskadec.c  |  2 +-
 libavformat/mov.c  |  6 ++--
 libavformat/movenc.c   | 46 +++---
 libavformat/mp3enc.c   |  6 ++--
 libavformat/mpegtsenc.c|  6 ++--
 libavformat/mux.c  |  2 +-
 libavformat/mux_utils.c|  2 +-
 libavformat/mxfenc.c   | 14 -
 libavformat/riffenc.c  |  2 +-
 libavformat/rmenc.c|  2 +-
 libavformat/sapenc.c   |  2 +-
 libavformat/sdp.c  |  2 +-
 libavformat/segment.c  |  4 +--
 libavformat/soxenc.c   |  2 +-
 libavformat/tee.c  |  2 +-
 libavformat/ttmlenc.c  |  4 +--
 libavformat/wavenc.c   |  4 +--
 libavformat/webmdashenc.c  | 30 +--
 libavutil/dict.c   |  9 +-
 libavutil/dict.h   |  5 
 libavutil/hwcontext_cuda.c |  2 +-
 libavutil/hwcontext_qsv.c  |  2 +-
 libavutil/hwcontext_vulkan.c   |  8 +++---
 libavutil/version.h|  1 +
 tests/api/api-threadmessage-test.c |  2 +-
 58 files changed, 136 insertions(+), 123 deletions(-)

diff --git a/doc/examples/qsv_transcode.c b/doc/examples/qsv_transcode.c
index 48128b200c..cc4c203d94 100644
--- a/doc/examples/qsv_transcode.c
+++ b/doc/examples/qsv_transcode.c
@@ -87,7 +87,7 @@ static int dynamic_set_parameter(AVCodecContext *avctx)
 frame_number++;
 if (current_setting_number < setting_number &&
 frame_number == dynamic_setting[current_setting_number].frame_number) {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 ret = str_to_dict(dynamic_setting[current_setting_number++].optstr, 
);
 if (ret < 0) {
 fprintf(stderr, "The dynamic parameter is wrong\n");
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 0b88102c77..8a32f31677 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -999,7 +999,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 #if AOM_ENCODER_ABI_VERSION >= 23
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 
 while ((en = av_dict_get(ctx->aom_params, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
 int ret = aom_codec_set_option(>encoder, en->key, en->value);
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 168486f4ec..f9f3ce8e52 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -103,7 +103,7 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
 if (ctx->kvz_params) {
 AVDictionary *dict = NULL;
 if (!av_dict_parse_string(, ctx->kvz_params, "=", ",", 0)) {
-AVDictionaryEntry *entry = NULL;
+const AVDictionaryEntry *entry = NULL;
 while ((entry = av_dict_get(dict, "", entry, 
AV_DICT_IGNORE_SUFFIX))) {
 if (!api->config_parse(cfg, entry->key, entry->value)) {
 av_log(avctx, AV_LOG_WARNING, "Invalid option: %s=%s.\n",
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 9174e2753c..e959c1cab0 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -151,7 +151,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
*param,
 {
 SvtContext *svt_enc = avctx->priv_data;
 const AVPixFmtDescriptor *desc;
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 
 // Update 

[FFmpeg-devel] [PATCH 2/3] avformat/tee: use av_dict_pop

2023-05-01 Thread Marvin Scholz
This is a well-defined way to "steal" the value of the dict entry.
---
 libavformat/tee.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index cb555f52fd..70f3f2eb29 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -157,6 +157,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 {
 int i, ret;
 AVDictionary *options = NULL, *bsf_options = NULL;
+char *entry_val = NULL;
 AVDictionaryEntry *entry;
 char *filename;
 char *format = NULL, *select = NULL, *on_fail = NULL;
@@ -171,15 +172,15 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 return ret;
 
 #define CONSUME_OPTION(option, field, action) do {  \
-if ((entry = av_dict_get(options, option, NULL, 0))) {  \
-field = entry->value;   \
+if ((!av_dict_pop(, option, NULL, _val, 0))) {\
+field = entry_val;  \
 { action }  \
-av_dict_set(, option, NULL, 0); \
+av_freep(_val);   \
 }   \
 } while (0)
 #define STEAL_OPTION(option, field) \
 CONSUME_OPTION(option, field,   \
-   entry->value = NULL; /* prevent it from being freed */)
+   entry_val = NULL; /* prevent it from being freed */)
 #define PROCESS_OPTION(option, field, function, on_error)   \
 CONSUME_OPTION(option, field, if ((ret = function) < 0) { { on_error } 
goto end; })
 
-- 
2.37.0 (Apple Git-136)

___
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] avutil/dict: add av_dict_pop

2023-05-01 Thread Marvin Scholz
This new API allows to remove an entry and obtain ownership of the
key/value that was associated with the removed entry.
---
 doc/APIchanges |  4 
 libavutil/dict.c   | 27 +++
 libavutil/dict.h   | 20 
 libavutil/tests/dict.c | 34 ++
 libavutil/version.h|  2 +-
 tests/ref/fate/dict| 12 
 6 files changed, 98 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 0b609e3d3b..5b807873b7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-04-29 - xx - lavu 58.7.100 - dict.c
+  Add av_dict_pop() to remove an entry from a dict
+  and get ownership of the removed key/value.
+
 2023-04-10 - xx - lavu 58.6.100 - frame.h
   av_frame_get_plane_buffer() now accepts const AVFrame*.
 
diff --git a/libavutil/dict.c b/libavutil/dict.c
index f673977a98..ac41771994 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -173,6 +173,33 @@ int av_dict_set_int(AVDictionary **pm, const char *key, 
int64_t value,
 return av_dict_set(pm, key, valuestr, flags);
 }
 
+int av_dict_pop(AVDictionary **pm, const char *key,
+char **out_key, char **out_value, int flags)
+{
+AVDictionary *m = *pm;
+AVDictionaryEntry *entry = NULL;
+entry = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags);
+if (!entry)
+return AVERROR(ENOENT);
+
+if (out_key)
+*out_key = entry->key;
+else
+av_free(entry->key);
+
+if (out_value)
+*out_value = entry->value;
+else
+av_free(entry->value);
+
+*entry = m->elems[--m->count];
+if (m && !m->count) {
+av_freep(>elems);
+av_freep(pm);
+}
+return 0;
+}
+
 static int parse_key_value_pair(AVDictionary **pm, const char **buf,
 const char *key_val_sep, const char *pairs_sep,
 int flags)
diff --git a/libavutil/dict.h b/libavutil/dict.h
index 713c9e361a..b2ab55a026 100644
--- a/libavutil/dict.h
+++ b/libavutil/dict.h
@@ -172,6 +172,26 @@ int av_dict_set(AVDictionary **pm, const char *key, const 
char *value, int flags
  */
 int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int 
flags);
 
+/**
+ * Remove the entry with the given key from the dictionary.
+ *
+ * Search for an entry matching `key` and remove it, if found. Optionally
+ * the found key and/or value can be returned using the `out_key`/`out_value`
+ * arguments.
+ *
+ * If more than one entry matches, only one entry is removed and returned
+ * on each call. Which entry is returned first in that case is undefined.
+ *
+ * @param pmPointer to a pointer to a dictionary struct.
+ * @param key   Entry key to match.
+ * @param out_key   Pointer whose pointee will be set to the matched
+ *  entry key. Must be freed by the caller. May be NULL.
+ * @param out_value Pointer whose pointee will be set to the matched
+ *  entry value. Must be freed by the caller. May be NULL.
+ */
+int av_dict_pop(AVDictionary **pm, const char *key,
+char **out_key, char **out_value, int flags);
+
 /**
  * Parse the key/value pairs list and add the parsed entries to a dictionary.
  *
diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c
index bececefb31..0652794b97 100644
--- a/libavutil/tests/dict.c
+++ b/libavutil/tests/dict.c
@@ -158,5 +158,39 @@ int main(void)
 printf("%s\n", e->value);
 av_dict_free();
 
+char *key, *val = NULL;
+int ret;
+printf("\nTesting av_dict_pop() with existing AVDictionaryEntry.key as 
key\n");
+av_dict_set(, "test-key", "test-value", 0);
+ret = av_dict_pop(, "test-key", , , 0);
+printf("%s: %s (Return code: %i)\n",
+(key) ? key : "(null)",
+(val) ? val : "(null)", ret);
+e = av_dict_get(dict, "test-key", NULL, 0);
+printf("%s\n", (e) ? e->value : "(null)");
+av_freep();
+av_freep();
+
+printf("\nTesting av_dict_pop() with nonexistent key\n");
+ret = av_dict_pop(, "test-key", , , 0);
+printf("%s: %s (Return code: %i)\n",
+(key) ? key : "(null)",
+(val) ? val : "(null)", ret);
+e = av_dict_get(dict, "test-key", NULL, 0);
+printf("%s\n", (e) ? e->value : "(null)");
+av_freep();
+av_freep();
+
+printf("\nTesting av_dict_pop() with prefix key match\n");
+av_dict_set(, "prefix-test-key", "test-value", 0);
+ret = av_dict_pop(, "prefix-test", , , AV_DICT_IGNORE_SUFFIX);
+printf("%s: %s (Return code: %i)\n",
+(key) ? key : "(null)",
+(val) ? val : "(null)", ret);
+e = av_dict_get(dict, "prefix-test", NULL, AV_DICT_IGNORE_SUFFIX);
+printf("%s\n", (e) ? e->value : "(null)");
+av_freep();
+av_freep();
+
 return 0;
 }
diff --git a/libavutil/version.h 

Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_tpad: accept hardware frames in clone-only mode

2023-04-19 Thread Marvin Scholz


On 19 Apr 2023, at 12:42, Marvin Scholz wrote:

> When no drawing is to be performed, tpad can work fine with
> hardware frames, so advertise this in the query_formats
> callback and ensure the drawing context is never initialized
> when just cloning frames.
> ---
>  libavfilter/vf_tpad.c | 15 ---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
> index 88c3c99de4..9a9d06a8b8 100644
> --- a/libavfilter/vf_tpad.c
> +++ b/libavfilter/vf_tpad.c
> @@ -71,7 +71,13 @@ AVFILTER_DEFINE_CLASS(tpad);
>
>  static int query_formats(AVFilterContext *ctx)
>  {
> -return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
> +TPadContext *s = ctx->priv;
> +if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
> +(s->start_mode == MODE_ADD && s->pad_start != 0))
> +return ff_set_common_formats(ctx, 
> ff_draw_supported_pixel_formats(0));
> +
> +fprintf(stderr, "ONLY COPY\n");

Apparently I am not fully awake yet and forgot to update the commit with the 
removal
of this debug output… Will obviously be removed in the next iteration.

> +return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO));
>  }
>
>  static int activate(AVFilterContext *ctx)
> @@ -190,8 +196,11 @@ static int config_input(AVFilterLink *inlink)
>  AVFilterContext *ctx = inlink->dst;
>  TPadContext *s = ctx->priv;
>
> -ff_draw_init(>draw, inlink->format, 0);
> -ff_draw_color(>draw, >color, s->rgba_color);
> +if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
> +(s->start_mode == MODE_ADD && s->pad_start != 0)) {
> +ff_draw_init(>draw, inlink->format, 0);
> +ff_draw_color(>draw, >color, s->rgba_color);
> +}
>
>  if (s->start_duration)
>  s->pad_start = av_rescale_q(s->start_duration, inlink->frame_rate, 
> av_inv_q(AV_TIME_BASE_Q));
> -- 
> 2.37.0 (Apple Git-136)
___
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] avfilter/vf_tpad: accept hardware frames in clone-only mode

2023-04-19 Thread Marvin Scholz
When no drawing is to be performed, tpad can work fine with
hardware frames, so advertise this in the query_formats
callback and ensure the drawing context is never initialized
when just cloning frames.
---
 libavfilter/vf_tpad.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index 88c3c99de4..9a9d06a8b8 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -71,7 +71,13 @@ AVFILTER_DEFINE_CLASS(tpad);
 
 static int query_formats(AVFilterContext *ctx)
 {
-return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+TPadContext *s = ctx->priv;
+if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
+(s->start_mode == MODE_ADD && s->pad_start != 0))
+return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+
+fprintf(stderr, "ONLY COPY\n");
+return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO));
 }
 
 static int activate(AVFilterContext *ctx)
@@ -190,8 +196,11 @@ static int config_input(AVFilterLink *inlink)
 AVFilterContext *ctx = inlink->dst;
 TPadContext *s = ctx->priv;
 
-ff_draw_init(>draw, inlink->format, 0);
-ff_draw_color(>draw, >color, s->rgba_color);
+if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
+(s->start_mode == MODE_ADD && s->pad_start != 0)) {
+ff_draw_init(>draw, inlink->format, 0);
+ff_draw_color(>draw, >color, s->rgba_color);
+}
 
 if (s->start_duration)
 s->pad_start = av_rescale_q(s->start_duration, inlink->frame_rate, 
av_inv_q(AV_TIME_BASE_Q));
-- 
2.37.0 (Apple Git-136)

___
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] avfilter/vf_tpad: use enum for start/stop_mode

2023-04-19 Thread Marvin Scholz
---
 libavfilter/vf_tpad.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index f0c065f0c3..88c3c99de4 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -27,6 +27,12 @@
 #include "formats.h"
 #include "drawutils.h"
 
+enum PadMode {
+MODE_ADD = 0,
+MODE_CLONE,
+NB_MODE
+};
+
 typedef struct TPadContext {
 const AVClass *class;
 int pad_start;
@@ -51,10 +57,10 @@ typedef struct TPadContext {
 static const AVOption tpad_options[] = {
 { "start", "set the number of frames to delay input",  
OFFSET(pad_start),  AV_OPT_TYPE_INT,   {.i64=0},0,   INT_MAX, VF },
 { "stop",  "set the number of frames to add after input finished", 
OFFSET(pad_stop),   AV_OPT_TYPE_INT,   {.i64=0},   -1,   INT_MAX, VF },
-{ "start_mode", "set the mode of added frames to start",   
OFFSET(start_mode), AV_OPT_TYPE_INT,   {.i64=0},0, 1, VF, 
"mode" },
-{ "add",   "add solid-color frames",   0,  
AV_OPT_TYPE_CONST, {.i64=0},0, 0, VF, "mode" },
-{ "clone", "clone first/last frame",   0,  
AV_OPT_TYPE_CONST, {.i64=1},0, 0, VF, "mode" },
-{ "stop_mode",  "set the mode of added frames to end", 
OFFSET(stop_mode),  AV_OPT_TYPE_INT,   {.i64=0},0, 1, VF, 
"mode" },
+{ "start_mode", "set the mode of added frames to start",   
OFFSET(start_mode), AV_OPT_TYPE_INT,   {.i64=MODE_ADD}, 0, NB_MODE-1, VF, 
"mode" },
+{ "add",   "add solid-color frames",   0,  
AV_OPT_TYPE_CONST, {.i64=MODE_ADD},   0, 0, VF, "mode" },
+{ "clone", "clone first/last frame",   0,  
AV_OPT_TYPE_CONST, {.i64=MODE_CLONE}, 0, 0, VF, "mode" },
+{ "stop_mode",  "set the mode of added frames to end", 
OFFSET(stop_mode),  AV_OPT_TYPE_INT,   {.i64=0},0, NB_MODE-1, VF, 
"mode" },
 { "start_duration", "set the duration to delay input", 
OFFSET(start_duration), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, VF },
 { "stop_duration",  "set the duration to pad input",   
OFFSET(stop_duration),  AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, VF },
 { "color", "set the color of the added frames",
OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str="black"},  0, 0, VF },
@@ -91,7 +97,7 @@ static int activate(AVFilterContext *ctx)
 }
 }
 
-if (s->start_mode == 0 && s->pad_start > 0 && 
ff_outlink_frame_wanted(outlink)) {
+if (s->start_mode == MODE_ADD && s->pad_start > 0 && 
ff_outlink_frame_wanted(outlink)) {
 frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!frame)
 return AVERROR(ENOMEM);
@@ -106,7 +112,7 @@ static int activate(AVFilterContext *ctx)
 return ff_filter_frame(outlink, frame);
 }
 
-if (s->start_mode == 1 && s->pad_start > 0) {
+if (s->start_mode == MODE_CLONE && s->pad_start > 0) {
 if (s->eof) {
 ff_outlink_set_status(outlink, AVERROR_EOF, 0);
 return 0;
@@ -133,7 +139,7 @@ static int activate(AVFilterContext *ctx)
 if (ret < 0)
 return ret;
 if (ret > 0) {
-if (s->stop_mode == 1 && s->pad_stop != 0) {
+if (s->stop_mode == MODE_CLONE && s->pad_stop != 0) {
 av_frame_free(>cache_stop);
 s->cache_stop = av_frame_clone(frame);
 }
@@ -147,14 +153,14 @@ static int activate(AVFilterContext *ctx)
 ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
 return 0;
 }
-if (s->stop_mode == 0) {
+if (s->stop_mode == MODE_ADD) {
 frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!frame)
 return AVERROR(ENOMEM);
 ff_fill_rectangle(>draw, >color,
   frame->data, frame->linesize,
   0, 0, frame->width, frame->height);
-} else if (s->stop_mode == 1) {
+} else if (s->stop_mode == MODE_CLONE) {
 if (!s->cache_stop) {
 s->pad_stop = 0;
 ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
-- 
2.37.0 (Apple Git-136)

___
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 01/19] lavc/avcodec: improve enc/dec API doxy

2023-01-28 Thread Marvin Scholz



On 28 Jan 2023, at 14:23, Anton Khirnov wrote:

> Quoting Marvin Scholz (2023-01-28 12:37:42)
>>
>>
>> On 25 Jan 2023, at 17:55, Anton Khirnov wrote:
>>
>>> Change return value descriptions into proper lists.
>>> ---
>>>  libavcodec/avcodec.h | 81 +++-
>>>  1 file changed, 42 insertions(+), 39 deletions(-)
>>>
>>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>>> index 0ac581d660..f3ca41f126 100644
>>> --- a/libavcodec/avcodec.h
>>> +++ b/libavcodec/avcodec.h
>>> @@ -2605,17 +2605,18 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, 
>>> AVSubtitle *sub,
>>>   *  still has frames buffered, it will return them after 
>>> sending
>>>   *  a flush packet.
>>>   *
>>> - * @return 0 on success, otherwise negative error code:
>>> - *  AVERROR(EAGAIN):   input is not accepted in the current state - 
>>> user
>>> - * must read output with avcodec_receive_frame() 
>>> (once
>>> - * all output is read, the packet should be 
>>> resent, and
>>> - * the call will not fail with EAGAIN).
>>> - *  AVERROR_EOF:   the decoder has been flushed, and no new 
>>> packets can
>>> - * be sent to it (also returned if more than 1 
>>> flush
>>> - * packet is sent)
>>> - *  AVERROR(EINVAL):   codec not opened, it is an encoder, or requires 
>>> flush
>>> - *  AVERROR(ENOMEM):   failed to add packet to internal queue, or 
>>> similar
>>> - *  other errors: legitimate decoding errors
>>> + * @return
>>> + * - 0: success
>>> + * - AVERROR(EAGAIN):   input is not accepted in the current state - user 
>>> must
>>> + *  read output with avcodec_receive_frame() (once all
>>> + *  output is read, the packet should be resent, and 
>>> the
>>> + *  call will not fail with EAGAIN).
>>> + * - AVERROR_EOF:   the decoder has been flushed, and no new packets 
>>> can be
>>> + *  sent to it (also returned if more than 1 flush 
>>> packet is
>>> + *  sent)
>>> + * - AVERROR(EINVAL):   codec not opened, it is an encoder, or requires 
>>> flush
>>> + * - AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
>>> + * - other errors:  legitimate decoding errors
>>>   */
>>
>> Wouldn't @retval work better for such return value documentation?
>
> I don't know, how is it better?
>

It should produce a more consistent output like in other places that use retval 
and is
semantically the more correct choice here.

Currently the documentation of possible return values is a bit all over the 
place with
some using lists, others just explain the values in a sentence, other places 
use retval.

IMO we should consistently try to use retval where it makes sense.

> -- 
> Anton Khirnov
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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 01/19] lavc/avcodec: improve enc/dec API doxy

2023-01-28 Thread Marvin Scholz



On 25 Jan 2023, at 17:55, Anton Khirnov wrote:

> Change return value descriptions into proper lists.
> ---
>  libavcodec/avcodec.h | 81 +++-
>  1 file changed, 42 insertions(+), 39 deletions(-)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 0ac581d660..f3ca41f126 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2605,17 +2605,18 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, 
> AVSubtitle *sub,
>   *  still has frames buffered, it will return them after 
> sending
>   *  a flush packet.
>   *
> - * @return 0 on success, otherwise negative error code:
> - *  AVERROR(EAGAIN):   input is not accepted in the current state - user
> - * must read output with avcodec_receive_frame() 
> (once
> - * all output is read, the packet should be resent, 
> and
> - * the call will not fail with EAGAIN).
> - *  AVERROR_EOF:   the decoder has been flushed, and no new packets 
> can
> - * be sent to it (also returned if more than 1 flush
> - * packet is sent)
> - *  AVERROR(EINVAL):   codec not opened, it is an encoder, or requires 
> flush
> - *  AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
> - *  other errors: legitimate decoding errors
> + * @return
> + * - 0: success
> + * - AVERROR(EAGAIN):   input is not accepted in the current state - user 
> must
> + *  read output with avcodec_receive_frame() (once all
> + *  output is read, the packet should be resent, and the
> + *  call will not fail with EAGAIN).
> + * - AVERROR_EOF:   the decoder has been flushed, and no new packets can 
> be
> + *  sent to it (also returned if more than 1 flush 
> packet is
> + *  sent)
> + * - AVERROR(EINVAL):   codec not opened, it is an encoder, or requires flush
> + * - AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
> + * - other errors:  legitimate decoding errors
>   */

Wouldn't @retval work better for such return value documentation?

>  int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);
>
> @@ -2630,17 +2631,17 @@ int avcodec_send_packet(AVCodecContext *avctx, const 
> AVPacket *avpkt);
>   *  av_frame_unref(frame) before doing anything else.
>   *
>   * @return
> - *  0: success, a frame was returned
> - *  AVERROR(EAGAIN):   output is not available in this state - user must 
> try
> - * to send new input
> - *  AVERROR_EOF:   the codec has been fully flushed, and there will 
> be
> - * no more output frames
> - *  AVERROR(EINVAL):   codec not opened, or it is an encoder without
> - * the AV_CODEC_FLAG_RECON_FRAME flag enabled
> - *  AVERROR_INPUT_CHANGED:   current decoded frame has changed parameters
> - *   with respect to first decoded frame. 
> Applicable
> - *   when flag AV_CODEC_FLAG_DROPCHANGED is set.
> - *  other negative values: legitimate decoding errors
> + * - 0: success, a frame was returned
> + * - AVERROR(EAGAIN):   output is not available in this state - user must
> + *  try to send new input
> + * - AVERROR_EOF:   the codec has been fully flushed, and there will 
> be
> + *  no more output frames
> + * - AVERROR(EINVAL):   codec not opened, or it is an encoder without the
> + *  AV_CODEC_FLAG_RECON_FRAME flag enabled
> + * - AVERROR_INPUT_CHANGED: current decoded frame has changed parameters with
> + *  respect to first decoded frame. Applicable when 
> flag
> + *  AV_CODEC_FLAG_DROPCHANGED is set.
> + * - other negative values: legitimate decoding errors
>   */
>  int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);
>
> @@ -2667,16 +2668,17 @@ int avcodec_receive_frame(AVCodecContext *avctx, 
> AVFrame *frame);
>   *  If it is not set, frame->nb_samples must be equal to
>   *  avctx->frame_size for all frames except the last.
>   *  The final frame may be smaller than avctx->frame_size.
> - * @return 0 on success, otherwise negative error code:
> - *  AVERROR(EAGAIN):   input is not accepted in the current state - user
> - * must read output with avcodec_receive_packet() 
> (once
> - * all output is read, the packet should be resent, 
> and
> - * the call will not fail with EAGAIN).
> - *  AVERROR_EOF:   the encoder has been flushed, and no new frames 
> can
> - *

Re: [FFmpeg-devel] [PATCH 00/26] Major library version bump

2023-01-21 Thread Marvin Scholz
On 21 Jan 2023, at 22:36, Michael Niedermayer wrote:

> On Sat, Jan 21, 2023 at 05:51:34PM +0100, Anton Khirnov wrote:
>> Quoting Michael Niedermayer (2023-01-20 03:05:09)
>>> PS: iam not sure i fully understood the reason behind why versions should be
>>> set to "wrong" values during some period, so as always i might be missing
>>> something
>>
>> The reason is that after the major bump, the API and ABI are declared to
>> be unstable for some period, so people can freely
>> - break ABI, e.g. by reordering struct members
>> - modify API added during the instability period in an arbitrary way
>> without a new major bump for every such change, that would be normally
>> required.
>>
>> My concern is that the instability period is quite long and there is
>> very little indication for our users that they cannot depend on the
>> ABI/API being stable. So I'm proposing to introduce some mechanism to
>> make this more visible for our callers.
>>
>> Alternatively, we could just not have an instability period at all.
>
> Does anyone plan to use the next bumps instability period for anything ?
> If so, i assume theres a good reason why it cannot be done without such
> period easily?
>
> If theres noone -> easy solution, we need no instability period ATM.
> If theres someone, i would ask that someone how long it needs to be
> and write that down in APIchanges. Maybe as in "API is unstable becuase
> of X until 2033-11-11
>

I would like to make av_dict_get return a const
AVDictionaryEntry, just like av_dict_iterate already does.

> a new #define LIBAVCODEC_UNSTABLE could be added but izt feels a bit
> overengeneered. This whole thing is more a exception, isnt it?
>
> thx
>
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> While the State exists there can be no freedom; when there is freedom there
> will be no State. -- Vladimir Lenin
> ___
> 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 00/26] Major library version bump

2023-01-21 Thread Marvin Scholz



On 21 Jan 2023, at 21:17, Hendrik Leppkes wrote:

> On Sat, Jan 21, 2023 at 8:33 PM Marvin Scholz  wrote:
>>>
>>> Alternatively, we could just not have an instability period at all.
>>>
>>
>> Not having any instability period at all seems like a bad idea.
>>
>
> Actually that sounds like the best idea. You would just have to
> prepare the bump in a branch and all unstable changes ready to merge
> in an instant.
> Miss it? Tough. Having months long periods so people can get their
> stuff sorted is way too long. Ideally it should be prepared ahead of
> time and only a "soft instability" period of maybe two weeks reserved
> for bug fixes (don't want to sit on issues for ever), rather then big
> changes or new features.
>

How would it work? If I now make a branch with a breaking
change, where would I put it and how would I get it merged together with
the other breaking changes?

Or do you mean that there should be a public devel branch where API/ABI
breaking patches can be proposed for that will eventually be merged into
master at a defined point in time together with major bump?

> - Hendrik
> ___
> 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 00/26] Major library version bump

2023-01-21 Thread Marvin Scholz


On 21 Jan 2023, at 17:51, Anton Khirnov wrote:

> Quoting Michael Niedermayer (2023-01-20 03:05:09)
>> PS: iam not sure i fully understood the reason behind why versions should be
>> set to "wrong" values during some period, so as always i might be missing
>> something
>
> The reason is that after the major bump, the API and ABI are declared to
> be unstable for some period, so people can freely
> - break ABI, e.g. by reordering struct members
> - modify API added during the instability period in an arbitrary way
> without a new major bump for every such change, that would be normally
> required.
>
> My concern is that the instability period is quite long and there is
> very little indication for our users that they cannot depend on the
> ABI/API being stable. So I'm proposing to introduce some mechanism to
> make this more visible for our callers.

I agree that a better way to know when I have an "unstable" version of
ffmpeg would be great. Even as someone loosely following ffmpeg dev
it is not clear to me when instability period ends and if we are
currently in it or not.

(I mean, I was lucky enough to notice this email now this time, but
that was pure luck…)

>
> Alternatively, we could just not have an instability period at all.
>

Not having any instability period at all seems like a bad idea.

> -- 
> Anton Khirnov
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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] fftools/ffmpeg_ffplay_ffprobe_cmdutils: add -mask_url to replace the protocol address in the command with the asterisk (*)

2022-12-19 Thread Marvin Scholz



On 19 Dec 2022, at 14:37, Nicolas George wrote:

> Marvin Scholz (12022-12-19):
>> IIUC this means the `-mask_url` option has to be the first option passed,
>> which seems a bit of an unfortunate requirement and is not documented at
>> all, as far as I can see. So at least this should be clearly documented
>> to prevent users being confused why the get an unrecognised option error
>> when they do not pass it as the first option.
>
> Indeed. And I see no reason to have this option processed specially like
> that; it requires at least an explanation.
>
>> I am a bit confused how this helps for the issue it tries to solve, as
>> for some amount of time, until this is done, it would expose the full
>> plaintext URL still, no?
>
> This is unavoidable. Still, having sensitive information visible for a
> fraction of a second is better than having sensitive information visible
> for the length of a playback or transcoding process.

I agree, but then the docs should probably mention that to not give a false
sense of absolute security here. And maybe note that it might
be a better option to pass the password via stdin or hide the process
from other users to completely avoid leaking the password.

>
> Regards,
>
> -- 
>   Nicolas George
> ___
> 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] fftools/ffmpeg_ffplay_ffprobe_cmdutils: add -mask_url to replace the protocol address in the command with the asterisk (*)

2022-12-19 Thread Marvin Scholz
On 19 Dec 2022, at 14:15, Wujian(Chin) wrote:

> I have modified the issues. Please review it again. Thank you.
>
> If the protocol address contains the user name and password, The ps -ef 
> command exposes plaintext.
> The -mask_url parameter option is added to replace the protocol address in 
> the command line with the asterisk (*).
> Because other users can run the ps -ef command to view sensitive information 
> such as the user name and password
> in the protocol address, which is insecure.
>
> Signed-off-by: wujian_nanjing 
> ---
>  doc/ffmpeg.texi|  9 +
>  doc/ffplay.texi|  8 
>  doc/ffprobe.texi   |  9 +
>  fftools/cmdutils.c | 47 +++
>  fftools/cmdutils.h | 15 +++
>  fftools/ffmpeg.c   | 16 +---
>  fftools/ffplay.c   | 15 +--
>  fftools/ffprobe.c  | 18 ++
>  8 files changed, 124 insertions(+), 13 deletions(-)
>
> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> index 0367930..1f6cb33 100644
> --- a/doc/ffmpeg.texi
> +++ b/doc/ffmpeg.texi
> @@ -50,6 +50,15 @@ output files. Also do not mix options which belong to 
> different files. All
>  options apply ONLY to the next input or output file and are reset between 
> files.
>
>  @itemize
> +@item -mask_url -i @var{url} (@emph{output})
> +If the protocol address contains the user name and password, The ps -ef 
> command exposes plaintext.
> +The -mask_url parameter option is added to replace the protocol address in 
> the command line with the asterisk (*).
> +Because other users can run the ps -ef command to view sensitive information 
> such as the user name and password
> +in the protocol address, which is insecure.
> +@example
> +ffmpeg -mask_url -i rtsp://username:password-ip:port/stream/test
> +@end example
> +
>  @item
>  To set the video bitrate of the output file to 64 kbit/s:
>  @example
> diff --git a/doc/ffplay.texi b/doc/ffplay.texi
> index 5dd860b..b40fe75 100644
> --- a/doc/ffplay.texi
> +++ b/doc/ffplay.texi
> @@ -120,8 +120,16 @@ sources and sinks).
>  Read @var{input_url}.
>  @end table
>
> +@item -mask_url -i @var{url} (@emph{output})
> +If the protocol address contains the user name and password, The ps -ef 
> command exposes plaintext.
> +The -mask_url parameter option is added to replace the protocol address in 
> the command line with the asterisk (*).
> +Because other users can run the ps -ef command to view sensitive information 
> such as the user name and password
> +in the protocol address, which is insecure.
> +@end table
> +
>  @section Advanced options
>  @table @option
> +
>  @item -stats
>  Print several playback statistics, in particular show the stream
>  duration, the codec parameters, the current position in the stream and
> diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
> index 4dc9f57..33c0e7d 100644
> --- a/doc/ffprobe.texi
> +++ b/doc/ffprobe.texi
> @@ -89,6 +89,15 @@ Set the output printing format.
>  @var{writer_name} specifies the name of the writer, and
>  @var{writer_options} specifies the options to be passed to the writer.
>
> +@item -mask_url -i @var{url} (@emph{output})
> +If the protocol address contains the user name and password, The ps -ef 
> command exposes plaintext.
> +The -mask_url parameter option is added to replace the protocol address in 
> the command line with the asterisk (*).
> +Because other users can run the ps -ef command to view sensitive information 
> such as the user name and password
> +in the protocol address, which is insecure.
> +@example
> +ffprobe -mask_url -i rtsp://username:password-ip:port/stream/test
> +@end example
> +
>  For example for printing the output in JSON format, specify:
>  @example
>  -print_format json
> diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
> index a1de621..c35d7e1 100644
> --- a/fftools/cmdutils.c
> +++ b/fftools/cmdutils.c
> @@ -61,6 +61,40 @@ AVDictionary *format_opts, *codec_opts;
>
>  int hide_banner = 0;
>
> +void param_masking(int argc, char **argv) {
> +int i, j;
> +for (i = 1; i < argc; i++) {
> +char *match = strstr(argv[i], "://");
> +if (match) {
> +int total = strlen(argv[i]);
> +for (j = 0; j < total; j++) {
> +argv[i][j] = '*';
> +}
> +}
> +}
> +}
> +
> +char **copy_argv(int argc, char **argv) {
> +char **argv2;
> +argv2 = av_mallocz(argc * sizeof(char *));
> +if (!argv2)
> +exit_program(1);
> +
> +for (int i = 0; i < argc; i++) {
> +int length = strlen(argv[i]) + 1;
> +argv2[i] = av_mallocz(length * sizeof(char *));
> +if (!argv2[i])
> +exit_program(1);
> +memcpy(argv2[i], argv[i], length - 1);
> +}
> +return argv2;
> +}
> +
> +void free_pp(int argc, char **argv) {
> +for (int i = 0; i < argc; i++)
> +av_free(argv[i]);
> +av_free(argv);
> +}
>  void uninit_opts(void)
>  {
>  av_dict_free(_opts);
> @@ -215,13 +249,13 

Re: [FFmpeg-devel] [PATCH] avformat/file: add fd protocol

2022-12-08 Thread Marvin Scholz


On 8 Dec 2022, at 16:11, Zhao Zhili wrote:

> On Mon, 2022-12-05 at 10:51 +0800, zhilizhao(赵志立) wrote:
>>> On Nov 19, 2022, at 02:48, Zhao Zhili 
>>> wrote:
>>>
>>> From: Zhao Zhili 
>>>
>>> Unlike the pipe protocol, fd protocol has seek support if it
>>> corresponding to a regular file.
>>> ---
>>> Sometimes it's the only way to access files via file descriptor,
>>> e.g.,
>>> requesting a shared file on Android:
>>> https://developer.android.com/training/secure-file-sharing/request-file
>>>
>>> doc/protocols.texi  | 24 +++
>>> libavformat/Makefile|  1 +
>>> libavformat/file.c  | 51
>>> +
>>> libavformat/protocols.c |  1 +
>>> libavformat/version.h   |  4 ++--
>>> 5 files changed, 79 insertions(+), 2 deletions(-)
>>>
>>>
>>
>> Ping for review.
>>
>
> Will apply tomorrow unless there are objections.
>

Maybe I overlooked something but where does the CONFIG_FD_PROTOCOL
define comes from?

> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 07/31] avutil: use av_dict_iterate

2022-11-30 Thread Marvin Scholz
On 27 Nov 2022, at 16:06, James Almer wrote:

> On 11/26/2022 11:46 AM, Marvin Scholz wrote:
>> ---
>>   libavutil/opt.c| 12 ++--
>>   libavutil/tests/dict.c |  2 +-
>>   2 files changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavutil/opt.c b/libavutil/opt.c
>> index a3940f47fb..0a909a8b22 100644
>> --- a/libavutil/opt.c
>> +++ b/libavutil/opt.c
>> @@ -1742,14 +1742,14 @@ void av_opt_free(void *obj)
>>int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
>>   {
>> -AVDictionaryEntry *t = NULL;
>> +const AVDictionaryEntry *t = NULL;
>>   AVDictionary*tmp = NULL;
>>   int ret;
>>if (!options)
>>   return 0;
>>  -while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) {
>> +while ((t = av_dict_iterate(*options, t))) {
>>   ret = av_opt_set(obj, t->key, t->value, search_flags);
>>   if (ret == AVERROR_OPTION_NOT_FOUND)
>>   ret = av_dict_set(, t->key, t->value, 0);
>> @@ -2137,16 +2137,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>   case AV_OPT_TYPE_DICT: {
>>   AVDictionary *dict1 = NULL;
>>   AVDictionary *dict2 = *(AVDictionary **)dst;
>> -AVDictionaryEntry *en1 = NULL;
>> -AVDictionaryEntry *en2 = NULL;
>> +const AVDictionaryEntry *en1 = NULL;
>> +const AVDictionaryEntry *en2 = NULL;
>>   ret = av_dict_parse_string(, o->default_val.str, "=", ":", 
>> 0);
>>   if (ret < 0) {
>>   av_dict_free();
>>   return ret;
>>   }
>>   do {
>> -en1 = av_dict_get(dict1, "", en1, AV_DICT_IGNORE_SUFFIX);
>> -en2 = av_dict_get(dict2, "", en2, AV_DICT_IGNORE_SUFFIX);
>> +en1 = av_dict_iterate(dict1, en1);
>> +en2 = av_dict_iterate(dict2, en2);
>>   } while (en1 && en2 && !strcmp(en1->key, en2->key) && 
>> !strcmp(en1->value, en2->value));
>>   av_dict_free();
>>   return (!en1 && !en2);
>> diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c
>> index d053545f4d..91567289c2 100644
>> --- a/libavutil/tests/dict.c
>> +++ b/libavutil/tests/dict.c
>> @@ -52,7 +52,7 @@ static void test_separators(const AVDictionary *m, const 
>> char pair, const char v
>>   int main(void)
>>   {
>>   AVDictionary *dict = NULL;
>> -AVDictionaryEntry *e;
>> +const AVDictionaryEntry *e;
>
> Spurious change? You're not touching the test otherwise.

Oh indeed!.

>
> In any case, feel free to add the following to this patch:
>
>> diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c
>> index d053545f4d..468391a9f3 100644
>> --- a/libavutil/tests/dict.c
>> +++ b/libavutil/tests/dict.c
>> @@ -52,7 +52,7 @@ static void test_separators(const AVDictionary *m, const 
>> char pair, const char v
>>  int main(void)
>>  {
>>  AVDictionary *dict = NULL;
>> -AVDictionaryEntry *e;
>> +const AVDictionaryEntry *e;
>>  char *buffer = NULL;
>>
>>  printf("Testing av_dict_get_string() and av_dict_parse_string()\n");
>> @@ -94,8 +94,13 @@ int main(void)
>>  if (av_dict_get(dict, NULL, NULL, 0))
>>  printf("av_dict_get() does not correctly handle NULL key.\n");
>>  e = NULL;
>> +printf("Iterating with av_dict_get()\n");
>>  while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX)))
>>  printf("%s %s\n", e->key, e->value);
>> +e = NULL;
>> +printf("Iterating with av_dict_iterate()\n");
>> +while ((e = av_dict_iterate(dict, e)))
>> +printf("%s %s\n", e->key, e->value);
>>  av_dict_free();
>>
>>  if (av_dict_set(, NULL, "a", 0) >= 0 ||
>> diff --git a/tests/ref/fate/dict b/tests/ref/fate/dict
>> index 7205e4c845..a519b49163 100644
>> --- a/tests/ref/fate/dict
>> +++ b/tests/ref/fate/dict
>> @@ -30,6 +30,14 @@ ret 0
>>  aaa aaa   bbb bbb   ccc ccc   \,='" \,='"
>>
>>  Testing av_dict_set()
>> +Iterating with av_dict_get()
>> +a a
>> +b b
>> +c c
>> +d d
>> +e e
>> +ff ff
>> +Iterating with av_dict_iterate()
>>  a a
>>  b b
>>  c c
>
> That should be enough to compare the output of both functions.

I see, thanks. Do you want to apply this change to the patch
when merging saving an unnecessary round trip to the ML?

> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 31/31] avformat/fifo: use av_dict_iterate

2022-11-26 Thread Marvin Scholz
---
 libavformat/fifo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index 7b35c9bf02..c125a97b0d 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -148,8 +148,8 @@ static int fifo_thread_write_header(FifoThreadContext *ctx)
 
 // Check for options unrecognized by underlying muxer
 if (format_options) {
-AVDictionaryEntry *entry = NULL;
-while ((entry = av_dict_get(format_options, "", entry, 
AV_DICT_IGNORE_SUFFIX)))
+const AVDictionaryEntry *entry = NULL;
+while ((entry = av_dict_iterate(format_options, entry)))
 av_log(avf2, AV_LOG_ERROR, "Unknown option '%s'\n", entry->key);
 ret = AVERROR(EINVAL);
 }
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH v2 30/31] avformat/matroskaenc: use av_dict_iterate

2022-11-26 Thread Marvin Scholz
---
 libavformat/matroskaenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 2be4f87284..2deb4284e8 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2048,7 +2048,7 @@ static int mkv_write_tag(MatroskaMuxContext *mkv, const 
AVDictionary *m,
 
 mkv_write_tag_targets(mkv, tmp_bc, elementid, uid);
 
-while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) {
+while ((t = av_dict_iterate(m, t))) {
 if (mkv_check_tag_name(t->key, elementid)) {
 ret = mkv_write_simpletag(tmp_bc, t);
 if (ret < 0)
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH v2 29/31] avformat/http: use av_dict_iterate

2022-11-26 Thread Marvin Scholz
---
 libavformat/http.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index c5c48c7900..7bce821535 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1021,11 +1021,11 @@ static int parse_cookie(HTTPContext *s, const char *p, 
AVDictionary **cookies)
 
 static int cookie_string(AVDictionary *dict, char **cookies)
 {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 int len = 1;
 
 // determine how much memory is needed for the cookies string
-while (e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))
+while ((e = av_dict_iterate(dict, e)))
 len += strlen(e->key) + strlen(e->value) + 1;
 
 // reallocate the cookies
@@ -1036,7 +1036,7 @@ static int cookie_string(AVDictionary *dict, char 
**cookies)
 *cookies[0] = '\0';
 
 // write out the cookies
-while (e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))
+while ((e = av_dict_iterate(dict, e)))
 av_strlcatf(*cookies, len, "%s%s\n", e->key, e->value);
 
 return 0;
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH v2 28/31] avformat/asfenc: use av_dict_iterate

2022-11-26 Thread Marvin Scholz
---
 libavformat/asfenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 70800a6df5..47240fc0a8 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -570,10 +570,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 end_header(pb, hpos);
 }
 if (metadata_count) {
-AVDictionaryEntry *tag = NULL;
+const AVDictionaryEntry *tag = NULL;
 hpos = put_header(pb, _asf_extended_content_header);
 avio_wl16(pb, metadata_count);
-while ((tag = av_dict_get(s->metadata, "", tag, 
AV_DICT_IGNORE_SUFFIX))) {
+while ((tag = av_dict_iterate(s->metadata, tag))) {
 put_str16(pb, dyn_buf, tag->key);
 avio_wl16(pb, 0);
 put_str16(pb, dyn_buf, tag->value);
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH v2 27/31] avformat/apetag: use av_dict_iterate

2022-11-26 Thread Marvin Scholz
---
 libavformat/apetag.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index e861aac0f8..f2794c46f2 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -175,7 +175,7 @@ static int string_is_ascii(const uint8_t *str)
 
 int ff_ape_write_tag(AVFormatContext *s)
 {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 int size, ret, count = 0;
 AVIOContext *dyn_bc;
 uint8_t *dyn_buf;
@@ -184,7 +184,7 @@ int ff_ape_write_tag(AVFormatContext *s)
 return ret;
 
 ff_standardize_creation_time(s);
-while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
+while ((e = av_dict_iterate(s->metadata, e))) {
 int val_len;
 
 if (!string_is_ascii(e->key)) {
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH v2 26/31] avformat/nutenc: use av_dict_iterate

2022-11-26 Thread Marvin Scholz
---
 libavformat/nutenc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 1afdeeb8ab..ff81ee34aa 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -516,7 +516,7 @@ static int add_info(AVIOContext *bc, const char *type, 
const char *value)
 static int write_globalinfo(NUTContext *nut, AVIOContext *bc)
 {
 AVFormatContext *s   = nut->avf;
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 AVIOContext *dyn_bc;
 uint8_t *dyn_buf = NULL;
 int count= 0, dyn_size;
@@ -525,7 +525,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext 
*bc)
 return ret;
 
 ff_standardize_creation_time(s);
-while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
+while ((t = av_dict_iterate(s->metadata, t)))
 count += add_info(dyn_bc, t->key, t->value);
 
 put_v(bc, 0); //stream_if_plus1
@@ -544,7 +544,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext 
*bc)
 static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id) {
 AVFormatContext *s= nut->avf;
 AVStream* st = s->streams[stream_id];
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 AVIOContext *dyn_bc;
 uint8_t *dyn_buf=NULL;
 int count=0, dyn_size, i;
@@ -552,7 +552,7 @@ static int write_streaminfo(NUTContext *nut, AVIOContext 
*bc, int stream_id) {
 if (ret < 0)
 return ret;
 
-while ((t = av_dict_get(st->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
+while ((t = av_dict_iterate(st->metadata, t)))
 count += add_info(dyn_bc, t->key, t->value);
 for (i=0; ff_nut_dispositions[i].flag; ++i) {
 if (st->disposition & ff_nut_dispositions[i].flag)
@@ -587,7 +587,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, 
int id)
 {
 AVIOContext *dyn_bc;
 uint8_t *dyn_buf = NULL;
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 AVChapter *ch= nut->avf->chapters[id];
 int ret, dyn_size, count = 0;
 
@@ -600,7 +600,7 @@ static int write_chapter(NUTContext *nut, AVIOContext *bc, 
int id)
 put_tt(nut, nut->chapter[id].time_base, bc, ch->start); // chapter_start
 put_v(bc, ch->end - ch->start); // chapter_len
 
-while ((t = av_dict_get(ch->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
+while ((t = av_dict_iterate(ch->metadata, t)))
 count += add_info(dyn_bc, t->key, t->value);
 
 put_v(bc, count);
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH v2 25/31] avformat/id3v2enc: use av_dict_iterate

2022-11-26 Thread Marvin Scholz
---
 libavformat/id3v2enc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index 515d2efd7d..ac907c2758 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -150,7 +150,7 @@ static int id3v2_put_priv(ID3v2EncContext *id3, AVIOContext 
*avioc, const char *
 return len + ID3v2_HEADER_SIZE;
 }
 
-static int id3v2_check_write_tag(ID3v2EncContext *id3, AVIOContext *pb, 
AVDictionaryEntry *t,
+static int id3v2_check_write_tag(ID3v2EncContext *id3, AVIOContext *pb, const 
AVDictionaryEntry *t,
  const char table[][4], enum ID3v2Encoding enc)
 {
 uint32_t tag;
@@ -167,13 +167,13 @@ static int id3v2_check_write_tag(ID3v2EncContext *id3, 
AVIOContext *pb, AVDictio
 
 static void id3v2_3_metadata_split_date(AVDictionary **pm)
 {
-AVDictionaryEntry *mtag = NULL;
+const AVDictionaryEntry *mtag = NULL;
 AVDictionary *dst = NULL;
 const char *key, *value;
 char year[5] = {0}, day_month[5] = {0};
 int i;
 
-while ((mtag = av_dict_get(*pm, "", mtag, AV_DICT_IGNORE_SUFFIX))) {
+while ((mtag = av_dict_iterate(*pm, mtag))) {
 key = mtag->key;
 if (!av_strcasecmp(key, "date")) {
 /* split date tag using "-MM-DD" format into year and 
month/day segments */
@@ -220,7 +220,7 @@ void ff_id3v2_start(ID3v2EncContext *id3, AVIOContext *pb, 
int id3v2_version,
 static int write_metadata(AVIOContext *pb, AVDictionary **metadata,
   ID3v2EncContext *id3, int enc)
 {
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 int ret;
 
 ff_metadata_conv(metadata, ff_id3v2_34_metadata_conv, NULL);
@@ -229,7 +229,7 @@ static int write_metadata(AVIOContext *pb, AVDictionary 
**metadata,
 else if (id3->version == 4)
 ff_metadata_conv(metadata, ff_id3v2_4_metadata_conv, NULL);
 
-while ((t = av_dict_get(*metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
+while ((t = av_dict_iterate(*metadata, t))) {
 if ((ret = id3v2_check_write_tag(id3, pb, t, ff_id3v2_tags, enc)) > 0) 
{
 id3->len += ret;
 continue;
-- 
2.37.0 (Apple Git-136)

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


  1   2   3   4   >