FFmpeg
Loading...
Searching...
No Matches
ops_impl.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Ramiro Polla
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef SWSCALE_AARCH64_OPS_IMPL_H
22#define SWSCALE_AARCH64_OPS_IMPL_H
23
24#include <assert.h>
25#include <stddef.h>
26#include <stdint.h>
27
28#include "libswscale/uops.h"
29
30/* Each nibble in the mask corresponds to one component. */
31#define NIBBLE_GET(mask, idx) (((mask) >> ((idx) << 2)) & 0xf)
32#define NIBBLE_SET(mask, idx, val) do { (mask) |= (((val) & 0xf) << ((idx) << 2)); } while (0)
33
34static inline uint16_t nibble_mask(SwsCompMask mask)
35{
36 uint16_t ret = 0;
37 for (int i = 0; i < 4; i++)
38 NIBBLE_SET(ret, i, !!(mask & SWS_COMP(i)));
39 return ret;
40}
41
42/**
43 * SwsAArch64OpImplParams describes the parameters for an SwsUOpType
44 * operation. It consists of simplified parameters from the SwsUOp structure,
45 * with the purpose of being straight-forward to implement and execute.
46 */
54
55/* SwsCompMask-related helpers. */
56#define LOOP(mask, idx) \
57 for (int idx = 0; idx < 4; idx++) \
58 if (mask & SWS_COMP(idx))
59#define LOOP_BWD(mask, idx) \
60 for (int idx = 3; idx >= 0; idx--) \
61 if (mask & SWS_COMP(idx))
62
63#define LOOP_MASK(p, idx) LOOP(p->mask, idx)
64#define LOOP_MASK_BWD(p, idx) LOOP_BWD(p->mask, idx)
65
66/* Number of elements in each linear coefficient vector register. */
68{
69 return 16 / ff_sws_pixel_type_size(type);
70}
71
72/* Compute number of vector registers needed to store all coefficients. */
74{
75 int count = 0;
77 for (int j = 0; j < 5; j++)
78 if (!(params->par.lin.zero & SWS_MASK(i, j)))
79 count++;
80 }
81 const int nelems = linear_vreg_nelems(params->type);
82 return (count + nelems - 1) / nelems;
83}
84
85/**
86 * Number of bytes of private data consumed by each kernel; must match what
87 * aarch64_setup() packs.
88 */
90{
91 switch (params->uop) {
94 case SWS_UOP_CLEAR:
95 case SWS_UOP_ADD:
96 case SWS_UOP_MIN:
97 case SWS_UOP_MAX:
98 return 16; /* one full vector register */
99 case SWS_UOP_SCALE:
100 return ff_sws_pixel_type_size(params->type);
101 case SWS_UOP_LINEAR:
103 return 16 * linear_num_vregs(params); /* packed coefficients */
104 case SWS_UOP_DITHER:
105 return 8; /* pointer */
106 default:
107 return 0;
108 }
109}
110
111/**
112 * These values will be used by ops_asmgen to access fields inside of
113 * SwsOpExec and SwsOpImpl. The sizes are checked in aarch64/ops.c when
114 * compiling for AArch64 to make sure there is no mismatch.
115 */
116#define offsetof_exec_in 0
117#define offsetof_exec_out 32
118#define offsetof_exec_in_bump 128
119#define offsetof_exec_out_bump 160
120#define offsetof_impl_func 0
121#define offsetof_impl_priv 8
122#define alignof_impl 8
123
124#endif /* SWSCALE_AARCH64_OPS_IMPL_H */
SwsAArch64OpImplParams params
Definition ops.c:52
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
int ret
Definition ffplay.c:391
enum MPFType type
Definition jpegmpfenc.c:55
static const uint16_t mask[17]
Definition lzw.c:38
static uint16_t nibble_mask(SwsCompMask mask)
Definition ops_impl.h:34
static int linear_vreg_nelems(SwsPixelType type)
Definition ops_impl.h:67
static int linear_num_vregs(const SwsAArch64OpImplParams *params)
Definition ops_impl.h:73
#define NIBBLE_SET(mask, idx, val)
Definition ops_impl.h:32
#define LOOP_MASK(p, idx)
Definition ops_impl.h:63
static int aarch64_priv_size(const SwsAArch64OpImplParams *params)
Number of bytes of private data consumed by each kernel; must match what aarch64_setup() packs.
Definition ops_impl.h:89
SwsAArch64OpImplParams describes the parameters for an SwsUOpType operation.
Definition ops_impl.h:47
SwsUOpParams par
Definition ops_impl.h:52
SwsPixelType type
Definition ops_impl.h:50
SwsPixelType
Definition uops.h:40
#define SWS_COMP(X)
Definition uops.h:133
#define SWS_MASK(I, J)
Definition uops.h:275
SwsUOpType
Definition uops.h:169
@ SWS_UOP_MAX
Definition uops.h:208
@ SWS_UOP_READ_BIT
Definition uops.h:179
@ SWS_UOP_MIN
Definition uops.h:207
@ SWS_UOP_LINEAR
Definition uops.h:216
@ SWS_UOP_LINEAR_FMA
Definition uops.h:217
@ SWS_UOP_SCALE
Definition uops.h:205
@ SWS_UOP_WRITE_BIT
Definition uops.h:185
@ SWS_UOP_DITHER
Definition uops.h:218
@ SWS_UOP_ADD
Definition uops.h:206
@ SWS_UOP_CLEAR
Definition uops.h:215
uint8_t SwsCompMask
Bit-mask of components.
Definition uops.h:129
static av_const int ff_sws_pixel_type_size(SwsPixelType type)
Definition uops.h:51