47#define UOP_NAME(OP, ABBR) [OP] = { #OP, ABBR },
65#define FMT(FIELD, VALUE, ...) av_bprintf(bp, designated ? ", ." FIELD " = " VALUE : ", " VALUE, __VA_ARGS__)
66#define FMT_SUB(FIELD, VALUE, ...) av_bprintf(bp, designated ? ", ." FIELD " = {" VALUE "}" : ", " VALUE, __VA_ARGS__)
87 FMT_SUB(
"par.move.dst",
"%d, %d, %d, %d, %d, %d",
90 FMT_SUB(
"par.move.src",
"%d, %d, %d, %d, %d, %d",
96 FMT_SUB(
"par.pack.pattern",
"%d, %d, %d, %d",
106 FMT(
"par.lin.one",
"0x%05x", par->
lin.
one);
112 FMT_SUB(
"par.dither.y_offset",
"%u, %u, %u, %u",
130 AVBPrint *bp =
ref->data.opaque;
134 av_bprintf(bp,
", .type = %-13s, .uop = %-24s, .mask = 0x%x",
145 AVBPrint *bp =
ref->data.opaque;
148 av_bprintf(bp,
" \\\n MACRO(__VA_ARGS__, %-40s, %-13s, %-24s, 0x%x",
159 AVBPrint *bp =
ref->data.opaque;
162 av_bprintf(bp,
"\n DECL_OP %%1, %-40s, %-13s, %-24s, 0x%x",
179 memset(&
key->data, 0,
sizeof(
key->data));
232 .guard =
"SWSCALE_UOPS_MACROS_H",
236 .guard =
"SWSCALE_X86_UOPS_MACROS_H",
258 if (!
s->backend->flags[
i])
296 const SwsUOp *
a = opaque, *
b = elem;
297 if (
a->type !=
b->type)
298 return (
int)
b->type -
a->type;
299 if (
a->uop !=
b->uop)
300 return (
int)
b->uop -
a->uop;
337 if (!graph || !
ctx) {
386#define BPRINT_STR(str) av_bprint_append_data(bp, str, strlen(str))
398 AVBPrint bprint, *
const bp = &bprint;
403" * This file is automatically generated. Do not edit manually.\n"
404" * To regenerate, run: make fate-sws-uops-macros GEN=1\n"
410" * Boilerplate helper macros, for template-based backends. These will be\n"
411" * instantiated like this, with parameters in struct order:\n"
412" * MACRO(__VA_ARGS__, NAME, TYPE, UOP, MASK, [PARAMS,])\n"
413" * The _STRUCT variants pass all arguments in C struct syntax, while the\n"
414" * plain variants give them as separate C values (e.g. for use in calls)\n"
416"#define SWS_GLUE3(x, y, z) x ## _ ## y ## _ ## z\n"
417"#define SWS_FOR(TYPE, UOP, MACRO, ...) \\\n"
418" SWS_GLUE3(SWS_FOR, TYPE, UOP)(MACRO, __VA_ARGS__)\n"
419"#define SWS_FOR_STRUCT(TYPE, UOP, MACRO, ...) \\\n"
420" SWS_GLUE3(SWS_FOR_STRUCT, TYPE, UOP)(MACRO, __VA_ARGS__)\n"
426 const char *macro =
uop_names[
key.uop].full +
sizeof(
"SWS_UOP_") - 1;
447 AVBPrint bprint, *
const bp = &bprint;
451";******************************************************************************\n"
452";* This file is automatically generated. Do not edit manually.\n"
453";* To regenerate, run: make fate-sws-uops-macros GEN=1\n"
455";* Boilerplate helper macros, for template-based backends. Invoking\n"
456";* DECL_<TYPE>_<UOP> MACRO will instantiate, for every matching uop:\n"
457";* DECL_OP MACRO, NAME, TYPE, UOP, MASK, [PARAMS]\n"
458";* with parameters in struct order.\n"
459";******************************************************************************");
464 const char *macro =
uop_names[
key.uop].full +
sizeof(
"SWS_UOP_") - 1;
485 if (fputs(str,
out) < 0 || fputc(
'\n',
out) < 0)
487 if (fclose(
out) != 0 &&
ret >= 0)
494 fprintf(stderr,
"Usage: uops_macros_gen [-backend BACKEND] [-nasm FILE]\n"
495 "Writes C macros to stdout, and optionally NASM macros to FILE\n"
496 "BACKEND is one of: c (default), x86\n");
503 _setmode(_fileno(stdout), _O_BINARY);
507 const char *nasm_path =
NULL;
508 for (
int i = 1;
i < argc;
i += 2) {
511 if (!strcmp(argv[
i],
"-backend")) {
515 }
else if (!strcmp(argv[
i],
"-nasm")) {
516 nasm_path = argv[
i + 1];
533 if (
ret >= 0 && nasm_path) {
static AVFormatContext * ctx
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_UNLIMITED
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
SwsGraph * ff_sws_graph_alloc(void)
Allocate an empty SwsGraph.
void ff_sws_graph_free(SwsGraph **pgraph)
Uninitialize any state associate with this filter graph and free it.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
void av_tree_enumerate(AVTreeNode *t, void *opaque, int(*cmp)(void *opaque, void *elem), int(*enu)(void *opaque, void *elem))
Apply enu(opaque, &elem) to all the elements in the tree in a given range.
void * av_tree_insert(AVTreeNode **tp, void *key, int(*cmp)(const void *key, const void *b), AVTreeNode **next)
Insert or remove an element.
void av_tree_destroy(AVTreeNode *t)
struct AVTreeNode * av_tree_node_alloc(void)
Allocate an AVTreeNode.
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
void sws_free_context(SwsContext **ctx)
Free the context and everything associated with it, and write NULL to the provided pointer.
@ SWS_SCALE_BILINEAR
bilinear filtering
@ SWS_ACCURATE_RND
Force bit-exact output.
static int ff_mutex_unlock(AVMutex *mutex)
static int ff_mutex_lock(AVMutex *mutex)
static int ff_mutex_destroy(AVMutex *mutex)
static int ff_mutex_init(AVMutex *mutex, const void *attr)
SwsLut3D * ff_sws_lut3d_alloc(void)
Allocates a refstruct.
Utility Preprocessor macros.
Memory handling functions.
static int ff_sws_enum_op_lists(SwsContext *ctx, void *opaque, const SwsLut3D *lut3d, enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt, int(*cb)(SwsContext *ctx, void *opaque, SwsOpList *ops))
Helper function to enumerate over all possible (optimized) operation lists, under the current set of ...
SwsOpList * ff_sws_op_list_duplicate(const SwsOpList *ops)
Returns a duplicate of ops, or NULL on OOM.
int ff_sws_compile_pass(SwsGraph *graph, const SwsOpBackend *backend, SwsOpList **pops, int flags, SwsPass *input, SwsPass **output)
Resolves an operation list to a graph pass.
@ SWS_OP_FLAG_SPLIT_MEMCPY
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
#define FF_ARRAY_ELEMS(a)
const struct Backend * backend
Main external API structure.
Filter graph, which represents a 'baked' pixel format conversion.
int8_t src[SWS_UOP_MOVE_MAX]
int8_t dst[SWS_UOP_MOVE_MAX]
Helper struct for representing a list of operations.
static const char pixel_types[SWS_PIXEL_TYPE_NB][32]
static int ref[MAX_W *MAX_W]
int ff_sws_ops_translate(SwsContext *ctx, const SwsOpList *ops, SwsUOpFlags flags, SwsUOpList *uops)
Translate a list of operations down to micro-ops, which can be further optimized and then directly ex...
#define UOP_NAME(OP, ABBR)
void ff_sws_uop_name(const SwsUOp *op, char buf[SWS_UOP_NAME_MAX])
SwsUOpList * ff_sws_uop_list_alloc(void)
void ff_sws_uop_list_free(SwsUOpList **p_ops)
static const struct @145311200363243152256244361015041277337174162300 uop_names[SWS_UOP_TYPE_NB]
@ SWS_UOP_READ_PLANAR_FV_FMA
static int ff_sws_uop_cmp_v(const void *a, const void *b)
@ SWS_UOP_FLAG_EXPAND_BIT
@ SWS_UOP_FLAG_READ_PALETTE
#define SWS_UOP_NAME_MAX
Generate a unique name for a SwsUOp.
#define UOPS_LIST(ENTRY)
This file is part of FFmpeg.
#define FMT_SUB(FIELD, VALUE,...)
static const SwsOpBackend backend_uops
static const SwsFlags flags_list[]
static int register_uops(SwsContext *ctx, const SwsOpList *ops, SwsCompiledOp *out)
static int register_uop(struct EnumPriv *s, const SwsUOp *uop)
static int register_flags(SwsContext *ctx, const SwsOpList *ops, SwsUOpFlags flags)
static int register_all_uops(SwsContext *ctx, void *graph, SwsOpList *ops)
static const Backend backends[]
static int generate_entry_nasm(void *opaque, void *key)
static const Backend * find_backend(const char *name)
static int free_uop_key(void *opaque, void *key)
static int print_macros(struct AVTreeNode *root, const Backend *backend, char **out_str)
Generate a set of boilerplate C preprocessor macros for describing and programmatically iterating ove...
#define FMT(FIELD, VALUE,...)
static int collect_uops(struct AVTreeNode **root, const Backend *backend)
Collect all unique SwsUOps used by backend into a newly allocated tree.
static int enum_type(void *opaque, void *elem)
static int generate_entry_struct(void *opaque, void *key)
static void print_params(AVBPrint *bp, const SwsUOp *uop, bool designated)
static void free_uops(struct AVTreeNode **root)
static int generate_entry_args(void *opaque, void *key)
static int print_nasm_macros(struct AVTreeNode *root, char **out_str)
Generate the equivalent NASM macros, as one DECL_<TYPE>_<UOP> macro per uop group.
static void copy(const float *p1, float *p2, const int length)