24 int srcStride[],
int srcSliceY,
int srcSliceH,
25 uint8_t *dst[],
int dstStride[])
34 unsigned max = (1<<
shift) - 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 (y = srcSliceY >> y_subsample; y <
FF_CEIL_RSHIFT(srcSliceH, y_subsample); y++) {
54 if (x_subsample || y_subsample) {
58 ptrdiff_t alpha_step = srcStride[plane_count] >> 1;
59 const uint16_t *
s = (
const uint16_t *)(src[plane ] + srcStride[plane ] * y);
60 const uint16_t *
a = (
const uint16_t *)(src[plane_count] + (srcStride[plane_count] * y << y_subsample));
61 uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
63 for (x = 0; x < w; x++) {
65 alpha = (a[2*x] + a[2*x + 1] + 2 +
66 a[2*x + alpha_step] + a[2*x + alpha_step + 1]) >> 2;
68 alpha = (a[2*x] + a[2*x + 1]) >> 1;
69 u = s[x]*alpha + target_table[((x^
y)>>5)&1][
plane]*(max-
alpha) + off;
70 d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);
73 for (x = 0; x < w; x++) {
80 d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);
84 ptrdiff_t alpha_step = srcStride[plane_count];
86 const uint8_t *
a = src[plane_count] + (srcStride[plane_count] * y << y_subsample);
88 for (x = 0; x < w; x++) {
90 alpha = (a[2*x] + a[2*x + 1] + 2 +
91 a[2*x + alpha_step] + a[2*x + alpha_step + 1]) >> 2;
93 alpha = (a[2*x] + a[2*x + 1]) >> 1;
94 u = s[x]*alpha + target_table[((x^
y)>>5)&1][
plane]*(255-
alpha) + 128;
100 const uint16_t *
s = (
const uint16_t *)(src[plane ] + srcStride[plane ] * y);
101 const uint16_t *
a = (
const uint16_t *)(src[plane_count] + srcStride[plane_count] * y);
102 uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
104 for (x = 0; x < w; x++) {
105 unsigned u = s[x]*a[x] + target_table[((x^
y)>>5)&1][
plane]*(max-a[x]) + off;
106 d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);
109 for (x = 0; x < w; x++) {
111 unsigned u =
av_bswap16(s[x])*aswap + target_table[((x^
y)>>5)&1][
plane]*(max-aswap) + off;
112 d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);
117 const uint8_t *
a = src[plane_count] + srcStride[plane_count] *
y;
119 for (x = 0; x < w; x++) {
120 unsigned u = s[x]*a[x] + target_table[((x^
y)>>5)&1][
plane]*(255-a[x]) + 128;
121 d[x] = (257*
u) >> 16;
130 for (y = srcSliceY; y < srcSliceH; y++) {
132 const uint16_t *
s = (
const uint16_t *)(src[0] + srcStride[0] * y + 2*!alpha_pos);
133 const uint16_t *
a = (
const uint16_t *)(src[0] + srcStride[0] * y + alpha_pos);
134 uint16_t *d = ( uint16_t *)(dst[0] + dstStride[0] * y);
136 for (x = 0; x < w; x++) {
137 for (plane = 0; plane < plane_count; plane++) {
138 int x_index = (plane_count + 1) * x;
139 unsigned u = s[x_index +
plane]*a[x_index] + target_table[((x^
y)>>5)&1][
plane]*(max-a[x_index]) + off;
140 d[plane_count*x +
plane] = av_clip((u + (u >> shift)) >> shift, 0, max);
144 for (x = 0; x < w; x++) {
145 for (plane = 0; plane < plane_count; plane++) {
146 int x_index = (plane_count + 1) * x;
148 unsigned u =
av_bswap16(s[x_index + plane])*aswap + target_table[((x^
y)>>5)&1][
plane]*(max-aswap) + off;
149 d[plane_count*x +
plane] = av_clip((u + (u >> shift)) >> shift, 0, max);
154 const uint8_t *
s = src[0] + srcStride[0] * y + !alpha_pos;
155 const uint8_t *
a = src[0] + srcStride[0] * y + alpha_pos;
156 uint8_t *d = dst[0] + dstStride[0] *
y;
157 for (x = 0; x < w; x++) {
158 for (plane = 0; plane < plane_count; plane++) {
159 int x_index = (plane_count + 1) * x;
160 unsigned u = s[x_index +
plane]*a[x_index] + target_table[((x^
y)>>5)&1][
plane]*(255-a[x_index]) + 128;
161 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.
int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
uint16_t depth_minus1
Number of bits in the component minus 1.
static double alpha(void *priv, double x, double y)
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).
uint8_t nb_components
The number of components each pixel has, (1-4)
#define FF_CEIL_RSHIFT(a, b)
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...
enum AVPixelFormat srcFormat
Source pixel format.
uint16_t offset_plus1
Number of elements before the component of the first pixel plus 1.
int chrSrcW
Width of source chroma planes.
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.