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 SwsOp 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/* 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 */
SwsAArch64OpImplParams params
Definition ops.c:51
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
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_num_vregs(const SwsAArch64OpImplParams *params)
Definition ops_impl.h:67
#define NIBBLE_SET(mask, idx, val)
Definition ops_impl.h:32
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:39
#define SWS_COMP(X)
Definition uops.h:97
SwsUOpType
Definition uops.h:129
uint8_t SwsCompMask
Bit-mask of components.
Definition uops.h:93