swscale/cms,graph,lut3d: Use ff_-prefix, don't export internal functions

Symbols with the sws_* prefix are exported.

Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2025-01-08 21:22:37 +01:00
parent 0bc1d2fac4
commit 4973bb661e
8 changed files with 81 additions and 81 deletions

View file

@ -31,7 +31,7 @@
#include "libswscale/swscale.h"
#include "utils.h"
bool sws_color_map_noop(const SwsColorMap *map)
bool ff_sws_color_map_noop(const SwsColorMap *map)
{
/* If the encoding space is different, we must go through a conversion */
if (map->src.prim != map->dst.prim || map->src.trc != map->dst.trc)
@ -676,14 +676,14 @@ static void generate_slice(void *priv, int jobnr, int threadnr, int nb_jobs,
}
}
int sws_color_map_generate_static(v3u16_t *lut, int size, const SwsColorMap *map)
int ff_sws_color_map_generate_static(v3u16_t *lut, int size, const SwsColorMap *map)
{
return sws_color_map_generate_dynamic(lut, NULL, size, 1, 1, map);
return ff_sws_color_map_generate_dynamic(lut, NULL, size, 1, 1, map);
}
int sws_color_map_generate_dynamic(v3u16_t *input, v3u16_t *output,
int size_input, int size_I, int size_PT,
const SwsColorMap *map)
int ff_sws_color_map_generate_dynamic(v3u16_t *input, v3u16_t *output,
int size_input, int size_I, int size_PT,
const SwsColorMap *map)
{
AVSliceThread *slicethread;
int ret, num_slices;
@ -740,7 +740,7 @@ int sws_color_map_generate_dynamic(v3u16_t *input, v3u16_t *output,
return 0;
}
void sws_tone_map_generate(v2u16_t *lut, int size, const SwsColorMap *map)
void ff_sws_tone_map_generate(v2u16_t *lut, int size, const SwsColorMap *map)
{
CmsCtx ctx = {
.map = *map,

View file

@ -67,7 +67,7 @@ typedef struct SwsColorMap {
* Returns true if the given color map is a semantic no-op - that is,
* the overall RGB end to end transform would an identity mapping.
*/
bool sws_color_map_noop(const SwsColorMap *map);
bool ff_sws_color_map_noop(const SwsColorMap *map);
/**
* Generates a single end-to-end color mapping 3DLUT embedding a static tone
@ -75,19 +75,19 @@ bool sws_color_map_noop(const SwsColorMap *map);
*
* Returns 0 on success, or a negative error code on failure.
*/
int sws_color_map_generate_static(v3u16_t *lut, int size, const SwsColorMap *map);
int ff_sws_color_map_generate_static(v3u16_t *lut, int size, const SwsColorMap *map);
/**
* Generates a split pair of 3DLUTS, going to IPT and back, allowing an
* arbitrary dynamic EETF to be nestled in between these two operations.
*
* See sws_tone_map_generate().
* See ff_sws_tone_map_generate().
*
* Returns 0 on success, or a negative error code on failure.
*/
int sws_color_map_generate_dynamic(v3u16_t *input, v3u16_t *output,
int size_input, int size_I, int size_PT,
const SwsColorMap *map);
int ff_sws_color_map_generate_dynamic(v3u16_t *input, v3u16_t *output,
int size_input, int size_I, int size_PT,
const SwsColorMap *map);
/**
* Generate a 1D LUT of size `size` adapting intensity (I) levels from the
@ -100,6 +100,6 @@ int sws_color_map_generate_dynamic(v3u16_t *input, v3u16_t *output,
*
* Returns 0 on success, or a negative error code on failure.
*/
void sws_tone_map_generate(v2u16_t *lut, int size, const SwsColorMap *map);
void ff_sws_tone_map_generate(v2u16_t *lut, int size, const SwsColorMap *map);
#endif // SWSCALE_GAMUT_MAPPING_H

View file

@ -472,7 +472,7 @@ static int add_legacy_sws_pass(SwsGraph *graph, SwsFormat src, SwsFormat dst,
static void free_lut3d(void *priv)
{
SwsLut3D *lut = priv;
sws_lut3d_free(&lut);
ff_sws_lut3d_free(&lut);
}
static void setup_lut3d(const SwsImg *out, const SwsImg *in, const SwsPass *pass)
@ -480,7 +480,7 @@ static void setup_lut3d(const SwsImg *out, const SwsImg *in, const SwsPass *pass
SwsLut3D *lut = pass->priv;
/* Update dynamic frame metadata from the original source frame */
sws_lut3d_update(lut, &pass->graph->src.color);
ff_sws_lut3d_update(lut, &pass->graph->src.color);
}
static void run_lut3d(const SwsImg *out_base, const SwsImg *in_base,
@ -490,8 +490,8 @@ static void run_lut3d(const SwsImg *out_base, const SwsImg *in_base,
const SwsImg in = shift_img(in_base, y);
const SwsImg out = shift_img(out_base, y);
sws_lut3d_apply(lut, in.data[0], in.linesize[0], out.data[0],
out.linesize[0], pass->width, h);
ff_sws_lut3d_apply(lut, in.data[0], in.linesize[0], out.data[0],
out.linesize[0], pass->width, h);
}
static int adapt_colors(SwsGraph *graph, SwsFormat src, SwsFormat dst,
@ -522,15 +522,15 @@ static int adapt_colors(SwsGraph *graph, SwsFormat src, SwsFormat dst,
map.src = src.color;
map.dst = dst.color;
if (sws_color_map_noop(&map))
if (ff_sws_color_map_noop(&map))
return 0;
lut = sws_lut3d_alloc();
lut = ff_sws_lut3d_alloc();
if (!lut)
return AVERROR(ENOMEM);
fmt_in = sws_lut3d_pick_pixfmt(src, 0);
fmt_out = sws_lut3d_pick_pixfmt(dst, 1);
fmt_in = ff_sws_lut3d_pick_pixfmt(src, 0);
fmt_out = ff_sws_lut3d_pick_pixfmt(dst, 1);
if (fmt_in != src.format) {
SwsFormat tmp = src;
tmp.format = fmt_in;
@ -539,16 +539,16 @@ static int adapt_colors(SwsGraph *graph, SwsFormat src, SwsFormat dst,
return ret;
}
ret = sws_lut3d_generate(lut, fmt_in, fmt_out, &map);
ret = ff_sws_lut3d_generate(lut, fmt_in, fmt_out, &map);
if (ret < 0) {
sws_lut3d_free(&lut);
ff_sws_lut3d_free(&lut);
return ret;
}
pass = pass_add(graph, lut, fmt_out, src.width, src.height,
input, 1, run_lut3d);
if (!pass) {
sws_lut3d_free(&lut);
ff_sws_lut3d_free(&lut);
return AVERROR(ENOMEM);
}
pass->setup = setup_lut3d;
@ -607,8 +607,8 @@ static void sws_graph_worker(void *priv, int jobnr, int threadnr, int nb_jobs,
pass->run(output, input, slice_y, slice_h, pass);
}
int sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src,
int field, SwsGraph **out_graph)
int ff_sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src,
int field, SwsGraph **out_graph)
{
int ret;
SwsGraph *graph = av_mallocz(sizeof(*graph));
@ -641,11 +641,11 @@ int sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src
return 0;
error:
sws_graph_free(&graph);
ff_sws_graph_free(&graph);
return ret;
}
void sws_graph_free(SwsGraph **pgraph)
void ff_sws_graph_free(SwsGraph **pgraph)
{
SwsGraph *graph = *pgraph;
if (!graph)
@ -684,23 +684,23 @@ static int opts_equal(const SwsContext *c1, const SwsContext *c2)
}
int sws_graph_reinit(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src,
int field, SwsGraph **out_graph)
int ff_sws_graph_reinit(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src,
int field, SwsGraph **out_graph)
{
SwsGraph *graph = *out_graph;
if (graph && ff_fmt_equal(&graph->src, src) &&
ff_fmt_equal(&graph->dst, dst) &&
opts_equal(ctx, &graph->opts_copy))
{
sws_graph_update_metadata(graph, &src->color);
ff_sws_graph_update_metadata(graph, &src->color);
return 0;
}
sws_graph_free(out_graph);
return sws_graph_create(ctx, dst, src, field, out_graph);
ff_sws_graph_free(out_graph);
return ff_sws_graph_create(ctx, dst, src, field, out_graph);
}
void sws_graph_update_metadata(SwsGraph *graph, const SwsColor *color)
void ff_sws_graph_update_metadata(SwsGraph *graph, const SwsColor *color)
{
if (!color)
return;
@ -708,10 +708,10 @@ void sws_graph_update_metadata(SwsGraph *graph, const SwsColor *color)
ff_color_update_dynamic(&graph->src.color, color);
}
void sws_graph_run(SwsGraph *graph, uint8_t *const out_data[4],
const int out_linesize[4],
const uint8_t *const in_data[4],
const int in_linesize[4])
void ff_sws_graph_run(SwsGraph *graph, uint8_t *const out_data[4],
const int out_linesize[4],
const uint8_t *const in_data[4],
const int in_linesize[4])
{
SwsImg *out = &graph->exec.output;
SwsImg *in = &graph->exec.input;

View file

@ -114,7 +114,7 @@ typedef struct SwsGraph {
SwsFormat src, dst;
int field;
/** Temporary execution state inside sws_graph_run */
/** Temporary execution state inside ff_sws_graph_run */
struct {
const SwsPass *pass; /* current filter pass */
SwsImg input;
@ -125,34 +125,34 @@ typedef struct SwsGraph {
/**
* Allocate and initialize the filter graph. Returns 0 or a negative error.
*/
int sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src,
int field, SwsGraph **out_graph);
int ff_sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src,
int field, SwsGraph **out_graph);
/**
* Uninitialize any state associate with this filter graph and free it.
*/
void sws_graph_free(SwsGraph **graph);
void ff_sws_graph_free(SwsGraph **graph);
/**
* Update dynamic per-frame HDR metadata without requiring a full reinit.
*/
void sws_graph_update_metadata(SwsGraph *graph, const SwsColor *color);
void ff_sws_graph_update_metadata(SwsGraph *graph, const SwsColor *color);
/**
* Wrapper around sws_graph_create() that reuses the existing graph if the
* Wrapper around ff_sws_graph_create() that reuses the existing graph if the
* format is compatible. This will also update dynamic per-frame metadata.
* Must be called after changing any of the fields in `ctx`, or else they will
* have no effect.
*/
int sws_graph_reinit(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src,
int field, SwsGraph **graph);
int ff_sws_graph_reinit(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src,
int field, SwsGraph **graph);
/**
* Dispatch the filter graph on a single field. Internally threaded.
*/
void sws_graph_run(SwsGraph *graph, uint8_t *const out_data[4],
const int out_linesize[4],
const uint8_t *const in_data[4],
const int in_linesize[4]);
void ff_sws_graph_run(SwsGraph *graph, uint8_t *const out_data[4],
const int out_linesize[4],
const uint8_t *const in_data[4],
const int in_linesize[4]);
#endif /* SWSCALE_GRAPH_H */

View file

@ -29,7 +29,7 @@
#include "csputils.h"
#include "lut3d.h"
SwsLut3D *sws_lut3d_alloc(void)
SwsLut3D *ff_sws_lut3d_alloc(void)
{
SwsLut3D *lut3d = av_malloc(sizeof(*lut3d));
if (!lut3d)
@ -39,17 +39,17 @@ SwsLut3D *sws_lut3d_alloc(void)
return lut3d;
}
void sws_lut3d_free(SwsLut3D **plut3d)
void ff_sws_lut3d_free(SwsLut3D **plut3d)
{
av_freep(plut3d);
}
bool sws_lut3d_test_fmt(enum AVPixelFormat fmt, int output)
bool ff_sws_lut3d_test_fmt(enum AVPixelFormat fmt, int output)
{
return fmt == AV_PIX_FMT_RGBA64;
}
enum AVPixelFormat sws_lut3d_pick_pixfmt(SwsFormat fmt, int output)
enum AVPixelFormat ff_sws_lut3d_pick_pixfmt(SwsFormat fmt, int output)
{
return AV_PIX_FMT_RGBA64;
}
@ -221,19 +221,19 @@ static av_always_inline v3u16_t apply_tone_map(const SwsLut3D *lut3d, v3u16_t ip
return ipt;
}
int sws_lut3d_generate(SwsLut3D *lut3d, enum AVPixelFormat fmt_in,
enum AVPixelFormat fmt_out, const SwsColorMap *map)
int ff_sws_lut3d_generate(SwsLut3D *lut3d, enum AVPixelFormat fmt_in,
enum AVPixelFormat fmt_out, const SwsColorMap *map)
{
int ret;
if (!sws_lut3d_test_fmt(fmt_in, 0) || !sws_lut3d_test_fmt(fmt_out, 1))
if (!ff_sws_lut3d_test_fmt(fmt_in, 0) || !ff_sws_lut3d_test_fmt(fmt_out, 1))
return AVERROR(EINVAL);
lut3d->dynamic = map->src.frame_peak.num > 0;
lut3d->map = *map;
if (lut3d->dynamic) {
ret = sws_color_map_generate_dynamic(&lut3d->input[0][0][0],
ret = ff_sws_color_map_generate_dynamic(&lut3d->input[0][0][0],
&lut3d->output[0][0][0],
INPUT_LUT_SIZE, OUTPUT_LUT_SIZE_I,
OUTPUT_LUT_SIZE_PT, map);
@ -241,15 +241,15 @@ int sws_lut3d_generate(SwsLut3D *lut3d, enum AVPixelFormat fmt_in,
return ret;
/* Make sure initial state is valid */
sws_lut3d_update(lut3d, &map->src);
ff_sws_lut3d_update(lut3d, &map->src);
return 0;
} else {
return sws_color_map_generate_static(&lut3d->input[0][0][0],
return ff_sws_color_map_generate_static(&lut3d->input[0][0][0],
INPUT_LUT_SIZE, map);
}
}
void sws_lut3d_update(SwsLut3D *lut3d, const SwsColor *new_src)
void ff_sws_lut3d_update(SwsLut3D *lut3d, const SwsColor *new_src)
{
if (!new_src || !lut3d->dynamic)
return;
@ -257,11 +257,11 @@ void sws_lut3d_update(SwsLut3D *lut3d, const SwsColor *new_src)
lut3d->map.src.frame_peak = new_src->frame_peak;
lut3d->map.src.frame_avg = new_src->frame_avg;
sws_tone_map_generate(lut3d->tone_map, TONE_LUT_SIZE, &lut3d->map);
ff_sws_tone_map_generate(lut3d->tone_map, TONE_LUT_SIZE, &lut3d->map);
}
void sws_lut3d_apply(const SwsLut3D *lut3d, const uint8_t *in, int in_stride,
uint8_t *out, int out_stride, int w, int h)
void ff_sws_lut3d_apply(const SwsLut3D *lut3d, const uint8_t *in, int in_stride,
uint8_t *out, int out_stride, int w, int h)
{
while (h--) {
const uint16_t *in16 = (const uint16_t *) in;

View file

@ -59,40 +59,40 @@ typedef struct SwsLut3D {
v2u16_t tone_map[TONE_LUT_SIZE]; /* new luma, desaturation */
} SwsLut3D;
SwsLut3D *sws_lut3d_alloc(void);
void sws_lut3d_free(SwsLut3D **lut3d);
SwsLut3D *ff_sws_lut3d_alloc(void);
void ff_sws_lut3d_free(SwsLut3D **lut3d);
/**
* Test to see if a given format is supported by the 3DLUT input/output code.
*/
bool sws_lut3d_test_fmt(enum AVPixelFormat fmt, int output);
bool ff_sws_lut3d_test_fmt(enum AVPixelFormat fmt, int output);
/**
* Pick the best compatible pixfmt for a given SwsFormat.
*/
enum AVPixelFormat sws_lut3d_pick_pixfmt(SwsFormat fmt, int output);
enum AVPixelFormat ff_sws_lut3d_pick_pixfmt(SwsFormat fmt, int output);
/**
* Recalculate the (static) 3DLUT state with new settings. This will recompute
* everything. To only update per-frame tone mapping state, instead call
* sws_lut3d_update().
* ff_sws_lut3d_update().
*
* Returns 0 or a negative error code.
*/
int sws_lut3d_generate(SwsLut3D *lut3d, enum AVPixelFormat fmt_in,
enum AVPixelFormat fmt_out, const SwsColorMap *map);
int ff_sws_lut3d_generate(SwsLut3D *lut3d, enum AVPixelFormat fmt_in,
enum AVPixelFormat fmt_out, const SwsColorMap *map);
/**
* Update the tone mapping state. This will only use per-frame metadata. The
* static metadata is ignored.
*/
void sws_lut3d_update(SwsLut3D *lut3d, const SwsColor *new_src);
void ff_sws_lut3d_update(SwsLut3D *lut3d, const SwsColor *new_src);
/**
* Applies a color transformation to a plane. The format must match the format
* provided during sws_lut3d_update().
* provided during ff_sws_lut3d_update().
*/
void sws_lut3d_apply(const SwsLut3D *lut3d, const uint8_t *in, int in_stride,
uint8_t *out, int out_stride, int w, int h);
void ff_sws_lut3d_apply(const SwsLut3D *lut3d, const uint8_t *in, int in_stride,
uint8_t *out, int out_stride, int w, int h);
#endif /* SWSCALE_LUT3D_H */

View file

@ -1403,7 +1403,7 @@ int sws_scale_frame(SwsContext *sws, AVFrame *dst, const AVFrame *src)
int dst_linesize[4], src_linesize[4];
get_frame_pointers(dst, dst_data, dst_linesize, field);
get_frame_pointers(src, src_data, src_linesize, field);
sws_graph_run(graph, dst_data, dst_linesize,
ff_sws_graph_run(graph, dst_data, dst_linesize,
(const uint8_t **) src_data, src_linesize);
if (!graph->dst.interlaced)
break;
@ -1461,7 +1461,7 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src)
goto fail;
}
ret = sws_graph_reinit(ctx, &dst_fmt, &src_fmt, field, &s->graph[field]);
ret = ff_sws_graph_reinit(ctx, &dst_fmt, &src_fmt, field, &s->graph[field]);
if (ret < 0) {
err_msg = "Failed initializing scaling graph";
goto fail;
@ -1474,7 +1474,7 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src)
}
if (!src_fmt.interlaced) {
sws_graph_free(&s->graph[FIELD_BOTTOM]);
ff_sws_graph_free(&s->graph[FIELD_BOTTOM]);
break;
}
@ -1490,7 +1490,7 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src)
av_color_primaries_name(dst_fmt.color.prim), av_color_transfer_name(dst_fmt.color.trc));
for (int i = 0; i < FF_ARRAY_ELEMS(s->graph); i++)
sws_graph_free(&s->graph[i]);
ff_sws_graph_free(&s->graph[i]);
return ret;
}

View file

@ -2480,7 +2480,7 @@ void sws_freeContext(SwsContext *sws)
return;
for (i = 0; i < FF_ARRAY_ELEMS(c->graph); i++)
sws_graph_free(&c->graph[i]);
ff_sws_graph_free(&c->graph[i]);
for (i = 0; i < c->nb_slice_ctx; i++)
sws_freeContext(c->slice_ctx[i]);