Skip to content

Commit e598931

Browse files
committed
Add support for all image formats to filter strobe
1 parent e4faf85 commit e598931

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/modules/plus/filter_strobe.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* filter_strobe.c -- simple strobing filter
33
* Copyright (C) 2020 Martin Sandsmark <martin.sandsmark@kde.org>
4+
* Copyright (C) 2025 Meltytech, LLC
45
*
56
* This library is free software; you can redistribute it and/or
67
* modify it under the terms of the GNU Lesser General Public
@@ -20,6 +21,7 @@
2021
#include <framework/mlt_factory.h>
2122
#include <framework/mlt_filter.h>
2223
#include <framework/mlt_frame.h>
24+
#include <framework/mlt_log.h>
2325
#include <framework/mlt_producer.h>
2426
#include <framework/mlt_property.h>
2527
#include <framework/mlt_service.h>
@@ -54,7 +56,8 @@ static int filter_get_image(mlt_frame frame,
5456
return mlt_frame_get_image(frame, image, format, width, height, 0);
5557
}
5658

57-
*format = mlt_image_rgba;
59+
if (*format == mlt_image_movit || *format == mlt_image_opengl_texture)
60+
*format = mlt_image_rgba;
5861
int error = mlt_frame_get_image(frame, image, format, width, height, 1);
5962
if (error) {
6063
return error;
@@ -71,6 +74,26 @@ static int filter_get_image(mlt_frame frame,
7174
}
7275
// Clear any alpha buffer that may be attached to the frame
7376
mlt_frame_set_alpha(frame, NULL, 0, NULL);
77+
} else if (*format == mlt_image_rgba64) {
78+
uint16_t *p = (uint16_t *) *image;
79+
for (size_t i = 0; i < pixelCount; i++) {
80+
p[3] = 0;
81+
p += 4;
82+
}
83+
// Clear any alpha buffer that may be attached to the frame
84+
mlt_frame_set_alpha(frame, NULL, 0, NULL);
85+
} else {
86+
int size = 0;
87+
uint8_t *a = mlt_frame_get_alpha_size(frame, &size);
88+
if (!a || size < pixelCount) {
89+
a = mlt_pool_alloc(pixelCount);
90+
if (!a) {
91+
mlt_log_error(MLT_FILTER_SERVICE(filter), "Unable to allocate alpha\n");
92+
return 1;
93+
}
94+
mlt_frame_set_alpha(frame, a, pixelCount, NULL);
95+
}
96+
memset(a, 0, pixelCount);
7497
}
7598

7699
return 0;

src/modules/plus/filter_strobe.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ schema_version: 7.0
22
type: filter
33
identifier: strobe
44
title: Alpha strobing
5-
version: 1
5+
version: 2
66
copyright: Martin Sandsmark
77
creator: Martin Sandsmark
88
license: LGPLv2.1

0 commit comments

Comments
 (0)