FFmpeg
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 
34 static 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 SwsOp structure,
45  * with the purpose of being straight-forward to implement and execute.
46  */
47 typedef struct SwsAArch64OpImplParams {
51  uint8_t block_size;
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 /* Compute number of vector registers needed to store all coefficients. */
68 {
69  int count = 0;
70  for (int i = 0; i < 4 * 5; i++)
71  if (!(params->par.lin.zero & (1ULL << i)))
72  count++;
73  return (count + 3) / 4;
74 }
75 
76 /**
77  * These values will be used by ops_asmgen to access fields inside of
78  * SwsOpExec and SwsOpImpl. The sizes are checked in aarch64/ops.c when
79  * compiling for AArch64 to make sure there is no mismatch.
80  */
81 #define offsetof_exec_in 0
82 #define offsetof_exec_out 32
83 #define offsetof_exec_in_bump 128
84 #define offsetof_exec_out_bump 160
85 #define offsetof_impl_cont 0
86 #define offsetof_impl_priv 16
87 #define sizeof_impl 32
88 
89 #endif /* SWSCALE_AARCH64_OPS_IMPL_H */
mask
int mask
Definition: mediacodecdec_common.c:154
SwsUOpParams
Definition: uops.h:246
SwsAArch64OpImplParams::uop
SwsUOpType uop
Definition: ops_impl.h:48
SwsCompMask
uint8_t SwsCompMask
Bit-mask of components.
Definition: uops.h:87
params
SwsAArch64OpImplParams params
Definition: ops.c:51
SwsAArch64OpImplParams::mask
SwsCompMask mask
Definition: ops_impl.h:49
SwsPixelType
SwsPixelType
Definition: uops.h:38
NIBBLE_SET
#define NIBBLE_SET(mask, idx, val)
Definition: ops_impl.h:32
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
SwsLinearUOp::zero
uint32_t zero
Definition: uops.h:223
SWS_COMP
#define SWS_COMP(X)
Definition: uops.h:96
SwsUOpType
SwsUOpType
Definition: uops.h:128
SwsUOpParams::lin
SwsLinearUOp lin
Definition: uops.h:253
ret
ret
Definition: filter_design.txt:187
SwsAArch64OpImplParams::par
SwsUOpParams par
Definition: ops_impl.h:52
SwsAArch64OpImplParams::block_size
uint8_t block_size
Definition: ops_impl.h:51
SwsAArch64OpImplParams
SwsAArch64OpImplParams describes the parameters for an SwsUOpType operation.
Definition: ops_impl.h:47
uops.h
nibble_mask
static uint16_t nibble_mask(SwsCompMask mask)
Definition: ops_impl.h:34
linear_num_vregs
static int linear_num_vregs(const SwsAArch64OpImplParams *params)
Definition: ops_impl.h:67
SwsAArch64OpImplParams::type
SwsPixelType type
Definition: ops_impl.h:50