| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | 413 | static inline uint16_t nibble_mask(SwsCompMask mask) | |
| 35 | { | ||
| 36 | 413 | uint16_t ret = 0; | |
| 37 |
2/2✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 413 times.
|
2065 | for (int i = 0; i < 4; i++) |
| 38 | 1652 | NIBBLE_SET(ret, i, !!(mask & SWS_COMP(i))); | |
| 39 | 413 | 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 { | ||
| 48 | SwsUOpType uop; | ||
| 49 | SwsCompMask mask; | ||
| 50 | SwsPixelType type; | ||
| 51 | uint8_t block_size; | ||
| 52 | SwsUOpParams par; | ||
| 53 | } SwsAArch64OpImplParams; | ||
| 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. */ | ||
| 67 | static inline int linear_num_vregs(const SwsAArch64OpImplParams *params) | ||
| 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 */ | ||
| 90 |