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;
76 for (int i = 0; i < 4 * 5; i++)
77 if (!(params->par.lin.zero & (1ULL << i)))
78 count++;
79 const int nelems = linear_vreg_nelems(params->type);
80 return (count + nelems - 1) / nelems;
81}
82
83/**
84 * These values will be used by ops_asmgen to access fields inside of
85 * SwsOpExec and SwsOpImpl. The sizes are checked in aarch64/ops.c when
86 * compiling for AArch64 to make sure there is no mismatch.
87 */
88#define offsetof_exec_in 0
89#define offsetof_exec_out 32
90#define offsetof_exec_in_bump 128
91#define offsetof_exec_out_bump 160
92#define offsetof_impl_cont 0
93#define offsetof_impl_priv 16
94#define sizeof_impl 32
95
96#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
uint32_t type
Definition jpegmpfenc.c:80
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
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:122
SwsUOpType
Definition uops.h:157
uint8_t SwsCompMask
Bit-mask of components.
Definition uops.h:118
static av_const int ff_sws_pixel_type_size(SwsPixelType type)
Definition uops.h:51