24 int srcStride[],
int srcSliceY,
int srcSliceH,
25 uint8_t *dst[],
int dstStride[])
31 int sixteen_bits = desc->
comp[0].
depth >= 9;
32 unsigned off = 1<<(desc->
comp[0].
depth - 1);
35 int target_table[2][3];
37 for (plane = 0; plane < plane_count; plane++) {
49 for (plane = 0; plane < plane_count; plane++) {
53 for (ysrc = 0; ysrc <
AV_CEIL_RSHIFT(srcSliceH, y_subsample); ysrc++) {
54 int y = ysrc + (srcSliceY >> y_subsample);
55 if (x_subsample || y_subsample) {
59 ptrdiff_t alpha_step = srcStride[plane_count] >> 1;
60 const uint16_t *
s = (
const uint16_t *)(src[plane ] + srcStride[plane ] * ysrc);
61 const uint16_t *
a = (
const uint16_t *)(src[plane_count] + (srcStride[plane_count] * ysrc << y_subsample));
62 uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
64 for (x = 0; x <
w; x++) {
66 alpha = (a[2*x] + a[2*x + 1] + 2 +
67 a[2*x + alpha_step] + a[2*x + alpha_step + 1]) >> 2;
69 alpha = (a[2*x] + a[2*x + 1]) >> 1;
70 u = s[x]*alpha + target_table[((x^y)>>5)&1][plane]*(max-
alpha) + off;
71 d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);
74 for (x = 0; x <
w; x++) {
80 u =
av_bswap16(s[x])*alpha + target_table[((x^y)>>5)&1][plane]*(max-
alpha) + off;
81 d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);
85 ptrdiff_t alpha_step = srcStride[plane_count];
86 const uint8_t *
s = src[plane ] + srcStride[plane] * ysrc;
87 const uint8_t *
a = src[plane_count] + (srcStride[plane_count] * ysrc << y_subsample);
88 uint8_t *d = dst[plane ] + dstStride[plane] * y;
89 for (x = 0; x <
w; x++) {
91 alpha = (a[2*x] + a[2*x + 1] + 2 +
92 a[2*x + alpha_step] + a[2*x + alpha_step + 1]) >> 2;
94 alpha = (a[2*x] + a[2*x + 1]) >> 1;
95 u = s[x]*alpha + target_table[((x^y)>>5)&1][plane]*(255-
alpha) + 128;
101 const uint16_t *
s = (
const uint16_t *)(src[plane ] + srcStride[plane ] * ysrc);
102 const uint16_t *
a = (
const uint16_t *)(src[plane_count] + srcStride[plane_count] * ysrc);
103 uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
105 for (x = 0; x <
w; x++) {
106 unsigned u = s[x]*a[x] + target_table[((x^y)>>5)&1][plane]*(max-a[x]) + off;
107 d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);
110 for (x = 0; x <
w; x++) {
112 unsigned u =
av_bswap16(s[x])*aswap + target_table[((x^y)>>5)&1][plane]*(max-aswap) + off;
113 d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);
117 const uint8_t *
s = src[plane ] + srcStride[plane] * ysrc;
118 const uint8_t *
a = src[plane_count] + srcStride[plane_count] * ysrc;
119 uint8_t *d = dst[plane ] + dstStride[plane] * y;
120 for (x = 0; x <
w; x++) {
121 unsigned u = s[x]*a[x] + target_table[((x^y)>>5)&1][plane]*(255-a[x]) + 128;
122 d[x] = (257*
u) >> 16;
129 int alpha_pos = desc->
comp[plane_count].
offset;
131 for (ysrc = 0; ysrc <
srcSliceH; ysrc++) {
132 int y = ysrc + srcSliceY;
134 const uint16_t *
s = (
const uint16_t *)(src[0] + srcStride[0] * ysrc + 2*!alpha_pos);
135 const uint16_t *
a = (
const uint16_t *)(src[0] + srcStride[0] * ysrc + alpha_pos);
136 uint16_t *d = ( uint16_t *)(dst[0] + dstStride[0] * y);
138 for (x = 0; x <
w; x++) {
139 for (plane = 0; plane < plane_count; plane++) {
140 int x_index = (plane_count + 1) * x;
141 unsigned u = s[x_index + plane]*a[x_index] + target_table[((x^y)>>5)&1][plane]*(max-a[x_index]) + off;
142 d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max);
146 for (x = 0; x <
w; x++) {
147 for (plane = 0; plane < plane_count; plane++) {
148 int x_index = (plane_count + 1) * x;
150 unsigned u =
av_bswap16(s[x_index + plane])*aswap + target_table[((x^y)>>5)&1][plane]*(max-aswap) + off;
151 d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max);
156 const uint8_t *
s = src[0] + srcStride[0] * ysrc + !alpha_pos;
157 const uint8_t *
a = src[0] + srcStride[0] * ysrc + alpha_pos;
158 uint8_t *d = dst[0] + dstStride[0] * y;
159 for (x = 0; x <
w; x++) {
160 for (plane = 0; plane < plane_count; plane++) {
161 int x_index = (plane_count + 1) * x;
162 unsigned u = s[x_index + plane]*a[x_index] + target_table[((x^y)>>5)&1][plane]*(255-a[x_index]) + 128;
163 d[plane_count*x + plane] = (257*
u) >> 16;
static int shift(int a, int b)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
#define u(width, name, range_min, range_max)
int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
uint8_t nb_components
The number of components each pixel has, (1-4)
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const int16_t alpha[]
int offset
Number of elements before the component of the first pixel.
enum AVPixelFormat srcFormat
Source pixel format.
int chrSrcW
Width of source chroma planes.
int depth
Number of bits in the component.
int srcW
Width of source luma/alpha planes.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_CEIL_RSHIFT(a, b)