FFmpeg
Loading...
Searching...
No Matches
ops_internal.h
Go to the documentation of this file.
1/**
2 * Copyright (C) 2025 Niklas Haas
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_OPS_INTERNAL_H
22#define SWSCALE_OPS_INTERNAL_H
23
25
26#include "ops.h"
27#include "ops_dispatch.h"
28
29#define Q(N) ((AVRational64) { N, 1 })
30
32{
33 const int src = ff_sws_pixel_type_size(from);
34 const int dst = ff_sws_pixel_type_size(to);
35 if (src > dst)
36 return Q(0);
37 int scale = 1;
38 for (int i = 1; i < dst / src; i++)
39 scale = (scale << (src * 8)) | 1;
40 return Q(scale);
41}
42
43static inline void ff_sws_pack_op_decode(const SwsOp *op, uint64_t mask[4], int shift[4])
44{
45 int size = 0;
46 for (int i = 0; i < 4; i++)
47 size += op->pack.pattern[i];
48 for (int i = 0; i < 4; i++) {
49 const int bits = op->pack.pattern[i];
50 mask[i] = (UINT64_C(1) << bits) - 1;
51 shift[i] = (i ? shift[i - 1] : size) - bits;
52 }
53}
54
55/**
56 * Split an op list into two at the given index. The split will be mediated
57 * by a set of planar read/write operations, plus a swizzle (if necessary)
58 * to re-order only used components. If a split is performed, both output
59 * lists will be optimized before returning.
60 *
61 * @param ops1 The first part of the split op list. Will be modified in-place.
62 * @param ops2 The second part of the split op list will be returned here, or
63 * NULL if no split was necessary.
64 * @param index The index of the operation to split before. The operation
65 * itself will be absent from `ops1` and instead moved to the
66 * start of `ops2`.
67 *
68 * Returnse 0 or a negative error code.
69 */
70int ff_sws_op_list_split_at(SwsOpList *ops1, SwsOpList **ops2, int index);
71
72/**
73 * Reduce an op list into a reduced subset that operates only on a given
74 * subset of planes. No effect if the output is not planar, or if the plane
75 * mask is empty or equal to all planes.
76 *
77 * @param ops1 Updated in-place to contain only the selected planes.
78 * @param ops2 The removed remainder is returned here, or NULL if no-op.
79 * @param planes A mask of the plane indices to keep.
80 *
81 * Returns 0 or a negative error code.
82 */
84
85#endif /* SWSCALE_OPS_INTERNAL_H */
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
static const uint8_t bits[8]
Definition fastaudio.c:100
int index
Definition gxfenc.c:90
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition intra.c:278
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
Definition anm.c:76
static int shift(int a, int b)
Definition bonk.c:261
const char * from
Definition jacosubdec.c:64
const char * to
Definition webvttdec.c:36
static const struct @257111027162314367033347246032313251342043035002 planes[]
static const uint16_t mask[17]
Definition lzw.c:38
static AVRational64 ff_sws_pixel_expand(SwsPixelType from, SwsPixelType to)
int ff_sws_op_list_split_at(SwsOpList *ops1, SwsOpList **ops2, int index)
Split an op list into two at the given index.
static void ff_sws_pack_op_decode(const SwsOp *op, uint64_t mask[4], int shift[4])
int ff_sws_op_list_split_planes(SwsOpList *ops1, SwsOpList **ops2, SwsCompMask planes)
Reduce an op list into a reduced subset that operates only on a given subset of planes.
#define Q(N)
Copyright (C) 2025 Niklas Haas.
64-bit Rational number (pair of numerator and denominator).
Definition rational64.h:52
Helper struct for representing a list of operations.
Definition ops.h:293
Definition ops.h:237
#define src
Definition vp8dsp.c:248
int size
SwsPixelType
Definition uops.h:39
uint8_t SwsCompMask
Bit-mask of components.
Definition uops.h:93
static av_const int ff_sws_pixel_type_size(SwsPixelType type)
Definition uops.h:50