FFmpeg
Data Structures | Macros | Functions | Variables
ops_static.c File Reference
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libavutil/dynarray.h"
#include "libavutil/bprint.c"
#include "rasm.c"
#include "rasm_print.c"
#include "ops_impl.h"
#include "ops_entries.c"
#include "ops_asmgen.c"

Go to the source code of this file.

Data Structures

struct  SwsAArch64OpEntry
 Implementation parameters for all exported functions. More...
 

Macros

#define AVUTIL_AVASSERT_H
 This file is compiled as a standalone build-time tool and must not depend on internal FFmpeg libraries. More...
 
#define AVUTIL_LOG_H
 
#define AVUTIL_MACROS_H
 
#define AVUTIL_MEM_H
 
#define av_assert0(cond)   assert(cond)
 
#define av_malloc(s)   malloc(s)
 
#define av_mallocz(s)   calloc(1, s)
 
#define av_realloc(p, s)   realloc(p, s)
 
#define av_strdup(s)   strdup(s)
 
#define av_free(p)   free(p)
 
#define FFMAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define FFMIN(a, b)   ((a) > (b) ? (b) : (a))
 
#define FF_ARRAY_ELEMS(a)   (sizeof(a) / sizeof((a)[0]))
 
#define MKTAG(a, b, c, d)   ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
 
#define ENTRY(fname, ...)   { .name = #fname, .params = __VA_ARGS__ },
 
#define IMPL_PRIV(s)   a64op_off(s->impl, offsetof_impl_priv)
 

Functions

static void av_freep (void *ptr)
 
static void * av_memdup (const void *p, size_t size)
 
static void * av_dynarray2_add (void **tab_ptr, int *nb_ptr, size_t elem_size, const uint8_t *elem_data)
 
static void asmgen_set_load_cont_node (SwsAArch64Context *s)
 Set node where the continuation address will be loaded and impl will be incremented. More...
 
static void asmgen_setup_read_bit (SwsAArch64Context *s, const SwsAArch64OpImplParams *p, SwsAArch64OpRegs *regs)
 
static void asmgen_setup_read_nibble (SwsAArch64Context *s, const SwsAArch64OpImplParams *p, SwsAArch64OpRegs *regs)
 
static void asmgen_setup_write_bit (SwsAArch64Context *s, const SwsAArch64OpImplParams *p, SwsAArch64OpRegs *regs)
 
static void asmgen_setup_unpack (SwsAArch64Context *s, const SwsAArch64OpImplParams *p, SwsAArch64OpRegs *regs)
 
static void asmgen_setup_clear (SwsAArch64Context *s, const SwsAArch64OpImplParams *p, SwsAArch64OpRegs *regs)
 
static void asmgen_setup_min (SwsAArch64Context *s, const SwsAArch64OpImplParams *p, SwsAArch64OpRegs *regs)
 
static void asmgen_setup_max (SwsAArch64Context *s, const SwsAArch64OpImplParams *p, SwsAArch64OpRegs *regs)
 
static void asmgen_setup_scale (SwsAArch64Context *s, const SwsAArch64OpImplParams *p, SwsAArch64OpRegs *regs)
 
static void asmgen_setup_linear (SwsAArch64Context *s, const SwsAArch64OpImplParams *p, SwsAArch64OpRegs *regs)
 
static void asmgen_setup_dither (SwsAArch64Context *s, const SwsAArch64OpImplParams *p, SwsAArch64OpRegs *regs)
 
static void asmgen_common_frame (SwsAArch64Context *s, SwsCompMask imask, SwsCompMask omask)
 
static void asmgen_process_frame (SwsAArch64Context *s, SwsCompMask imask, SwsCompMask omask)
 
static void asmgen_op_frame (SwsAArch64Context *s, SwsCompMask imask, SwsCompMask omask)
 
static void init_vectors_cps (SwsAArch64Context *s, SwsAArch64OpRegs *regs)
 
static void asmgen_process_cps (SwsAArch64Context *s, SwsCompMask mask)
 
static void asmgen_op_cps (SwsAArch64Context *s, const SwsAArch64OpEntry *entry)
 
static int asmgen (void)
 
int main (int argc, char *argv[])
 

Variables

static const SwsAArch64OpEntry ops_entries []
 
static const int rw_gprs []
 Register assignment for CPS functions. More...
 

Macro Definition Documentation

◆ AVUTIL_AVASSERT_H

#define AVUTIL_AVASSERT_H

This file is compiled as a standalone build-time tool and must not depend on internal FFmpeg libraries.

The necessary utils are redefined below using standard C equivalents.

Definition at line 39 of file ops_static.c.

◆ AVUTIL_LOG_H

#define AVUTIL_LOG_H

Definition at line 40 of file ops_static.c.

◆ AVUTIL_MACROS_H

#define AVUTIL_MACROS_H

Definition at line 41 of file ops_static.c.

◆ AVUTIL_MEM_H

#define AVUTIL_MEM_H

Definition at line 42 of file ops_static.c.

◆ av_assert0

#define av_assert0 (   cond)    assert(cond)

Definition at line 43 of file ops_static.c.

◆ av_malloc

#define av_malloc (   s)    malloc(s)
Examples
avio_read_callback.c, hw_decode.c, and qsv_transcode.c.

Definition at line 44 of file ops_static.c.

◆ av_mallocz

#define av_mallocz (   s)    calloc(1, s)

Definition at line 45 of file ops_static.c.

◆ av_realloc

#define av_realloc (   p,
  s 
)    realloc(p, s)

Definition at line 46 of file ops_static.c.

◆ av_strdup

#define av_strdup (   s)    strdup(s)

◆ av_free

#define av_free (   p)    free(p)

Definition at line 48 of file ops_static.c.

◆ FFMAX

#define FFMAX (   a,
  b 
)    ((a) > (b) ? (a) : (b))

Definition at line 49 of file ops_static.c.

◆ FFMIN

#define FFMIN (   a,
  b 
)    ((a) > (b) ? (b) : (a))

Definition at line 50 of file ops_static.c.

◆ FF_ARRAY_ELEMS

#define FF_ARRAY_ELEMS (   a)    (sizeof(a) / sizeof((a)[0]))

Definition at line 51 of file ops_static.c.

◆ MKTAG

#define MKTAG (   a,
  b,
  c,
 
)    ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))

Definition at line 52 of file ops_static.c.

◆ ENTRY

#define ENTRY (   fname,
  ... 
)    { .name = #fname, .params = __VA_ARGS__ },

◆ IMPL_PRIV

#define IMPL_PRIV (   s)    a64op_off(s->impl, offsetof_impl_priv)

Definition at line 123 of file ops_static.c.

Function Documentation

◆ av_freep()

static void av_freep ( void *  ptr)
static

Definition at line 54 of file ops_static.c.

Referenced by av_dynarray2_add().

◆ av_memdup()

static void* av_memdup ( const void *  p,
size_t  size 
)
static

Definition at line 65 of file ops_static.c.

◆ av_dynarray2_add()

static void* av_dynarray2_add ( void **  tab_ptr,
int *  nb_ptr,
size_t  elem_size,
const uint8_t *  elem_data 
)
static

Definition at line 78 of file ops_static.c.

◆ asmgen_set_load_cont_node()

static void asmgen_set_load_cont_node ( SwsAArch64Context s)
static

Set node where the continuation address will be loaded and impl will be incremented.

This should be done right after impl->priv has been used.

Definition at line 130 of file ops_static.c.

Referenced by asmgen_op_cps(), asmgen_setup_clear(), asmgen_setup_dither(), asmgen_setup_linear(), asmgen_setup_max(), asmgen_setup_min(), asmgen_setup_read_bit(), asmgen_setup_scale(), and asmgen_setup_write_bit().

◆ asmgen_setup_read_bit()

static void asmgen_setup_read_bit ( SwsAArch64Context s,
const SwsAArch64OpImplParams p,
SwsAArch64OpRegs regs 
)
static

Definition at line 143 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_setup_read_nibble()

static void asmgen_setup_read_nibble ( SwsAArch64Context s,
const SwsAArch64OpImplParams p,
SwsAArch64OpRegs regs 
)
static

Definition at line 160 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_setup_write_bit()

static void asmgen_setup_write_bit ( SwsAArch64Context s,
const SwsAArch64OpImplParams p,
SwsAArch64OpRegs regs 
)
static

Definition at line 170 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_setup_unpack()

static void asmgen_setup_unpack ( SwsAArch64Context s,
const SwsAArch64OpImplParams p,
SwsAArch64OpRegs regs 
)
static

All-one values in movi only work up to 8-bit, and then at full 16- or 32-bit, but not for intermediate values like 10-bit. In those cases, we use mov + dup instead.

Definition at line 181 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_setup_clear()

static void asmgen_setup_clear ( SwsAArch64Context s,
const SwsAArch64OpImplParams p,
SwsAArch64OpRegs regs 
)
static

TODO

  • pack elements in impl->priv and perform smaller loads
  • if only 1 element and not vh, load directly with ld1r

Definition at line 218 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_setup_min()

static void asmgen_setup_min ( SwsAArch64Context s,
const SwsAArch64OpImplParams p,
SwsAArch64OpRegs regs 
)
static

Definition at line 241 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_setup_max()

static void asmgen_setup_max ( SwsAArch64Context s,
const SwsAArch64OpImplParams p,
SwsAArch64OpRegs regs 
)
static

Definition at line 253 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_setup_scale()

static void asmgen_setup_scale ( SwsAArch64Context s,
const SwsAArch64OpImplParams p,
SwsAArch64OpRegs regs 
)
static

Definition at line 265 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_setup_linear()

static void asmgen_setup_linear ( SwsAArch64Context s,
const SwsAArch64OpImplParams p,
SwsAArch64OpRegs regs 
)
static

Populate operands matrix from packed data into linear_vcoeff matrix and compute mask for rows that must be saved before being overwritten.

Save rows that need to be used as input after they have been already written to.

Definition at line 277 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_setup_dither()

static void asmgen_setup_dither ( SwsAArch64Context s,
const SwsAArch64OpImplParams p,
SwsAArch64OpRegs regs 
)
static

Definition at line 337 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_common_frame()

static void asmgen_common_frame ( SwsAArch64Context s,
SwsCompMask  imask,
SwsCompMask  omask 
)
static

Definition at line 391 of file ops_static.c.

Referenced by asmgen_op_frame(), and asmgen_process_frame().

◆ asmgen_process_frame()

static void asmgen_process_frame ( SwsAArch64Context s,
SwsCompMask  imask,
SwsCompMask  omask 
)
static

Definition at line 406 of file ops_static.c.

Referenced by asmgen_process_cps().

◆ asmgen_op_frame()

static void asmgen_op_frame ( SwsAArch64Context s,
SwsCompMask  imask,
SwsCompMask  omask 
)
static

Definition at line 427 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ init_vectors_cps()

static void init_vectors_cps ( SwsAArch64Context s,
SwsAArch64OpRegs regs 
)
static

Definition at line 438 of file ops_static.c.

Referenced by asmgen_op_cps().

◆ asmgen_process_cps()

static void asmgen_process_cps ( SwsAArch64Context s,
SwsCompMask  mask 
)
static

Definition at line 475 of file ops_static.c.

Referenced by asmgen().

◆ asmgen_op_cps()

static void asmgen_op_cps ( SwsAArch64Context s,
const SwsAArch64OpEntry entry 
)
static

Set up vector register dimensions and reshape all vectors accordingly.

Definition at line 499 of file ops_static.c.

Referenced by asmgen().

◆ asmgen()

static int asmgen ( void  )
static

Definition at line 615 of file ops_static.c.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 658 of file ops_static.c.

Variable Documentation

◆ ops_entries

const SwsAArch64OpEntry ops_entries[]
static
Initial value:
= {
#define ENTRY(fname, ...)
{ NULL }
}

Definition at line 113 of file ops_static.c.

Referenced by asmgen().

◆ rw_gprs

const int rw_gprs[]
static
Initial value:
= {
9, 10, 11, 12,
13, 14, 15, 19,
20, 21, 22, 23,
24, 25, 26, 27,
}

Register assignment for CPS functions.

The entry point of the SwsOpFunc is the process function. The first kernel function is called from process, and subsequent kernel functions are chained by directly branching to the next operation, using a continuation-passing style design. The last operation must be a write operation, which returns from the call to the process function.

The GPRs used by the entire call-chain are listed below.

Function arguments are passed in r0-r5. After the parameters from exec have been read, r0 is reused to branch to the continuation functions. After the original parameters from impl have been computed, r1 is reused as the impl pointer for each operation.

Loop iterators are r6 for bx and r3 for y, reused from y_start, which doesn't need to be preserved.

The intra-procedure-call temporary registers (r16 and r17) are used as scratch registers. They may be used by call veneers and PLT code inserted by the linker, so we cannot expect them to persist across branches between functions.

The Platform Register (r18) is not used.

The read/write data pointers and padding values first use up the remaining free caller-saved registers, and only then are the callee-saved registers (r19-r29) used.

The Link Register (r30) is used when calling the first kernel, so it must be saved.

Definition at line 384 of file ops_static.c.

Referenced by asmgen_common_frame(), and asmgen_process_frame().

NULL
#define NULL
Definition: coverity.c:32