* [FFmpeg-devel] [PATCH 3/3] avfilter: use the getters for xGA font data arrays
2025-07-22 0:46 [FFmpeg-devel] [PATCH 1/3] avutil/xga_font_data: add getters to access the shared arrays James Almer
2025-07-22 0:46 ` [FFmpeg-devel] [PATCH 2/3] avcodec: use the getters for xGA font data arrays James Almer
@ 2025-07-22 0:46 ` James Almer
2025-07-22 2:45 ` [FFmpeg-devel] [PATCH 1/3] avutil/xga_font_data: add getters to access the shared arrays Kacper Michajlow
2 siblings, 0 replies; 5+ messages in thread
From: James Almer @ 2025-07-22 0:46 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavfilter/af_aiir.c | 2 +-
libavfilter/avf_showcqt.c | 3 ++-
libavfilter/avf_showspectrum.c | 2 +-
libavfilter/avf_showvolume.c | 2 +-
libavfilter/f_ebur128.c | 4 ++--
libavfilter/f_graphmonitor.c | 2 +-
libavfilter/src_avsynctest.c | 3 ++-
libavfilter/vf_datascope.c | 3 ++-
libavfilter/vf_vectorscope.c | 8 ++++----
libavfilter/vf_waveform.c | 16 ++++++++--------
libavfilter/vsrc_testsrc.c | 3 ++-
11 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 9a43235ad6..f18b6e9286 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -1038,7 +1038,7 @@ static void drawtext(AVFrame *pic, int x, int y, const char *txt, uint32_t color
int font_height;
int i;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (i = 0; txt[i]; i++) {
int char_y, mask;
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index 8ff6ecbe09..5050f46e25 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -655,6 +655,7 @@ fail:
static int render_default_font(AVFrame *tmp)
{
const char *str = "EF G A BC D ";
+ const uint8_t *vga16_font = avpriv_vga16_font_get();
int x, u, v, mask;
uint8_t *data = tmp->data[0];
int linesize = tmp->linesize[0];
@@ -666,7 +667,7 @@ static int render_default_font(AVFrame *tmp)
for (v = 0; v < height; v++) {
uint8_t *p = startptr + v * linesize + height/2 * 4 * u;
for (mask = 0x80; mask; mask >>= 1, p += 4) {
- if (mask & avpriv_vga16_font[str[u] * 16 + v])
+ if (mask & vga16_font[str[u] * 16 + v])
p[3] = 255;
else
p[3] = 0;
diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c
index dc608c450a..ee71d55894 100644
--- a/libavfilter/avf_showspectrum.c
+++ b/libavfilter/avf_showspectrum.c
@@ -492,7 +492,7 @@ static void drawtext(AVFrame *pic, int x, int y, const char *txt, int o)
const uint8_t *font;
int font_height;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (int i = 0; txt[i]; i++) {
int char_y, mask;
diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c
index e760caad2d..8472e86a15 100644
--- a/libavfilter/avf_showvolume.c
+++ b/libavfilter/avf_showvolume.c
@@ -225,7 +225,7 @@ static void drawtext(AVFrame *pic, int x, int y, const char *txt, int o)
int font_height;
int i;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (i = 0; txt[i]; i++) {
int char_y, mask;
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 63669b71de..a352f3831f 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -246,8 +246,8 @@ static void drawtext(AVFrame *pic, int x, int y, int ftid, const uint8_t *color,
int font_height;
va_list vl;
- if (ftid == FONT16) font = avpriv_vga16_font, font_height = 16;
- else if (ftid == FONT8) font = avpriv_cga_font, font_height = 8;
+ if (ftid == FONT16) font = avpriv_vga16_font_get(), font_height = 16;
+ else if (ftid == FONT8) font = avpriv_cga_font_get(), font_height = 8;
else return;
va_start(vl, fmt);
diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c
index de9946586c..20cdcce79d 100644
--- a/libavfilter/f_graphmonitor.c
+++ b/libavfilter/f_graphmonitor.c
@@ -186,7 +186,7 @@ static void drawtext(AVFrame *pic, int x, int y, const char *txt,
int font_height;
int i;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
if (y + 8 >= pic->height ||
x + len * 8 >= pic->width)
diff --git a/libavfilter/src_avsynctest.c b/libavfilter/src_avsynctest.c
index 68dffba43a..9c71a9fee8 100644
--- a/libavfilter/src_avsynctest.c
+++ b/libavfilter/src_avsynctest.c
@@ -252,6 +252,7 @@ static int audio_frame(AVFilterLink *outlink)
static void draw_text(FFDrawContext *draw, AVFrame *out, FFDrawColor *color,
int x0, int y0, const uint8_t *text)
{
+ const uint8_t *cga_font = avpriv_cga_font_get();
int x = x0;
for (; *text; text++) {
@@ -262,7 +263,7 @@ static void draw_text(FFDrawContext *draw, AVFrame *out, FFDrawColor *color,
}
ff_blend_mask(draw, color, out->data, out->linesize,
out->width, out->height,
- avpriv_cga_font + *text * 8, 1, 8, 8, 0, 0, x, y0);
+ &cga_font[*text * 8], 1, 8, 8, 0, 0, x, y0);
x += 8;
}
}
diff --git a/libavfilter/vf_datascope.c b/libavfilter/vf_datascope.c
index 6efeb875a6..87137cee83 100644
--- a/libavfilter/vf_datascope.c
+++ b/libavfilter/vf_datascope.c
@@ -88,6 +88,7 @@ static int query_formats(const AVFilterContext *ctx,
static void draw_text(FFDrawContext *draw, AVFrame *frame, FFDrawColor *color,
int x0, int y0, const uint8_t *text, int vertical)
{
+ const uint8_t *cga_font = avpriv_cga_font_get();
int x = x0;
for (; *text; text++) {
@@ -98,7 +99,7 @@ static void draw_text(FFDrawContext *draw, AVFrame *frame, FFDrawColor *color,
}
ff_blend_mask(draw, color, frame->data, frame->linesize,
frame->width, frame->height,
- avpriv_cga_font + *text * 8, 1, 8, 8, 0, 0, x, y0);
+ &cga_font[*text * 8], 1, 8, 8, 0, 0, x, y0);
if (vertical) {
x = x0;
y0 += 8;
diff --git a/libavfilter/vf_vectorscope.c b/libavfilter/vf_vectorscope.c
index 2143f9dcc2..eeee166172 100644
--- a/libavfilter/vf_vectorscope.c
+++ b/libavfilter/vf_vectorscope.c
@@ -968,7 +968,7 @@ static void draw_ihtext(AVFrame *out, int x, int y, float o1, float o2, const ch
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
@@ -993,7 +993,7 @@ static void draw_ihtext16(AVFrame *out, int x, int y, float o1, float o2, const
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
@@ -1019,7 +1019,7 @@ static void draw_htext(AVFrame *out, int x, int y, float o1, float o2, const cha
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
@@ -1045,7 +1045,7 @@ static void draw_htext16(AVFrame *out, int x, int y, float o1, float o2, const c
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c
index 6d2b529e88..a8e4e71bf6 100644
--- a/libavfilter/vf_waveform.c
+++ b/libavfilter/vf_waveform.c
@@ -2635,7 +2635,7 @@ static void draw_htext(AVFrame *out, int x, int y, int mult, float o1, float o2,
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
@@ -2661,7 +2661,7 @@ static void draw_htext16(AVFrame *out, int x, int y, int mult, float o1, float o
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
@@ -2687,7 +2687,7 @@ static void draw_vtext(AVFrame *out, int x, int y, int mult, float o1, float o2,
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
@@ -2712,7 +2712,7 @@ static void draw_vtext16(AVFrame *out, int x, int y, int mult, float o1, float o
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
@@ -2779,7 +2779,7 @@ static void idraw_htext(AVFrame *out, int x, int y, int mult, float o1, float o2
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
@@ -2805,7 +2805,7 @@ static void idraw_htext16(AVFrame *out, int x, int y, int mult, float o1, float
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
@@ -2831,7 +2831,7 @@ static void idraw_vtext(AVFrame *out, int x, int y, int mult, float o1, float o2
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
@@ -2856,7 +2856,7 @@ static void idraw_vtext16(AVFrame *out, int x, int y, int mult, float o1, float
int font_height;
int i, plane;
- font = avpriv_cga_font, font_height = 8;
+ font = avpriv_cga_font_get(), font_height = 8;
for (plane = 0; plane < 4 && out->data[plane]; plane++) {
for (i = 0; txt[i]; i++) {
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 78680441a8..81301edbfe 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -733,6 +733,7 @@ static uint32_t color_gradient(unsigned index)
static void draw_text(TestSourceContext *s, AVFrame *frame, FFDrawColor *color,
int x0, int y0, const uint8_t *text)
{
+ const uint8_t *vga16_font = avpriv_vga16_font_get();
int x = x0;
for (; *text; text++) {
@@ -743,7 +744,7 @@ static void draw_text(TestSourceContext *s, AVFrame *frame, FFDrawColor *color,
}
ff_blend_mask(&s->draw, color, frame->data, frame->linesize,
frame->width, frame->height,
- avpriv_vga16_font + *text * 16, 1, 8, 16, 0, 0, x, y0);
+ &vga16_font[*text * 16], 1, 8, 16, 0, 0, x, y0);
x += 8;
}
}
--
2.50.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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/3] avutil/xga_font_data: add getters to access the shared arrays
2025-07-22 0:46 [FFmpeg-devel] [PATCH 1/3] avutil/xga_font_data: add getters to access the shared arrays James Almer
2025-07-22 0:46 ` [FFmpeg-devel] [PATCH 2/3] avcodec: use the getters for xGA font data arrays James Almer
2025-07-22 0:46 ` [FFmpeg-devel] [PATCH 3/3] avfilter: " James Almer
@ 2025-07-22 2:45 ` Kacper Michajlow
2025-07-22 2:48 ` Kacper Michajlow
2 siblings, 1 reply; 5+ messages in thread
From: Kacper Michajlow @ 2025-07-22 2:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Tue, 22 Jul 2025 at 02:47, James Almer <jamrial@gmail.com> wrote:
>
> And stop exposing the arrays on the next major bump.
>
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> libavutil/xga_font_data.c | 16 ++++++++++++++++
> libavutil/xga_font_data.h | 6 ++++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/libavutil/xga_font_data.c b/libavutil/xga_font_data.c
> index 3aed3142cf..e4b21760f8 100644
> --- a/libavutil/xga_font_data.c
> +++ b/libavutil/xga_font_data.c
> @@ -26,6 +26,9 @@
> #include <stdint.h>
> #include "xga_font_data.h"
>
> +#if LIBAVUTIL_VERSION_MAJOR > 60
> +static
> +#endif
> const uint8_t avpriv_cga_font[2048] = {
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
> 0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00,
> @@ -157,6 +160,14 @@ const uint8_t avpriv_cga_font[2048] = {
> 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> };
>
> +const uint8_t *avpriv_cga_font_get(void)
> +{
> + return avpriv_cga_font;
> +}
> +
> +#if LIBAVUTIL_VERSION_MAJOR > 60
> +static
> +#endif
> const uint8_t avpriv_vga16_font[4096] = {
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00,
> @@ -415,3 +426,8 @@ const uint8_t avpriv_vga16_font[4096] = {
> 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00,
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
> };
> +
> +const uint8_t *avpriv_vga16_font_get(void)
> +{
> + return avpriv_vga16_font;
> +}
> diff --git a/libavutil/xga_font_data.h b/libavutil/xga_font_data.h
> index 69dc337120..90d3cec4ce 100644
> --- a/libavutil/xga_font_data.h
> +++ b/libavutil/xga_font_data.h
> @@ -28,8 +28,14 @@
>
> #include <stdint.h>
> #include "internal.h"
> +#include "version.h"
>
> +#if LIBAVUTIL_VERSION_MAJOR < 61
> extern av_export_avutil const uint8_t avpriv_cga_font[2048];
> extern av_export_avutil const uint8_t avpriv_vga16_font[4096];
> +#endif
> +
> +const uint8_t *avpriv_cga_font_get(void);
> +const uint8_t *avpriv_vga16_font_get(void);
Looks good. Accessing data from DLLs without dllimport requires
manually resolving the indirection. While using a function works even
without dllimport, while it may be used to better code generation and
removing one function patching when dynamic linker loads it. All other
FFmpeg code is not using dllimport, so it should be fine to remove
these two remaining ones. This will allow all objects to be the same
between shared/static build and fix checkasm static linking.
For my information, isn't avpriv_ prefix used for internal symbols
shared between libs? Does it need a deprecation period? Are users
supposed to be accessing them?
- Kacper
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread