24 const int srcStride[],
int srcSliceY,
int srcSliceH,
25 uint8_t *
const dst[],
const int dstStride[])
28 const int lum_w =
c->opts.src_w;
29 const int lum_h =
c->opts.src_h;
30 int nb_components =
desc->nb_components;
32 int plane_count =
isGray(
c->opts.src_format) ? 1 : 3;
33 int sixteen_bits =
desc->comp[0].depth >= 9;
34 unsigned off = 1<<(
desc->comp[0].depth - 1);
37 int target_table[2][3];
39 for (plane = 0; plane < plane_count; plane++) {
42 a = (1<<(
desc->comp[0].depth - 1))/2;
43 b = 3*(1<<(
desc->comp[0].depth-1))/2;
51 for (plane = 0; plane < plane_count; plane++) {
52 int w = plane ?
c->chrSrcW :
c->opts.src_w;
53 int x_subsample = plane ?
desc->log2_chroma_w: 0;
54 int y_subsample = plane ?
desc->log2_chroma_h: 0;
55 for (ysrc = 0; ysrc <
AV_CEIL_RSHIFT(srcSliceH, y_subsample); ysrc++) {
56 int y = ysrc + (srcSliceY >> y_subsample);
57 int subsample_row = y_subsample && (y << y_subsample) + 1 < lum_h;
58 if (x_subsample || subsample_row) {
62 ptrdiff_t alpha_step = srcStride[plane_count] >> 1;
63 const uint16_t *
s = (
const uint16_t *)(
src[plane ] + srcStride[plane ] * ysrc);
64 const uint16_t *
a = (
const uint16_t *)(
src[plane_count] + (srcStride[plane_count] * ysrc << y_subsample));
65 uint16_t *d = ( uint16_t *)(
dst[plane ] + dstStride[plane ] * y);
66 if ((!
isBE(
c->opts.src_format)) == !HAVE_BIGENDIAN) {
67 for (x = 0; x <
w; x++) {
68 const int xnext =
FFMIN(2*x + 1, lum_w - 1);
70 alpha = (
a[2*x] +
a[xnext] + 2 +
71 a[2*x + alpha_step] +
a[xnext + alpha_step]) >> 2;
73 alpha = (
a[2*x] +
a[xnext]) >> 1;
78 for (x = 0; x <
w; x++) {
79 const int xnext =
FFMIN(2*x + 1, lum_w - 1);
90 ptrdiff_t alpha_step = srcStride[plane_count];
91 const uint8_t *
s =
src[plane ] + srcStride[plane] * ysrc;
92 const uint8_t *
a =
src[plane_count] + (srcStride[plane_count] * ysrc << y_subsample);
93 uint8_t *d =
dst[plane ] + dstStride[plane] * y;
94 for (x = 0; x <
w; x++) {
95 const int xnext =
FFMIN(2*x + 1, lum_w - 1);
97 alpha = (
a[2*x] +
a[xnext] + 2 +
98 a[2*x + alpha_step] +
a[xnext + alpha_step]) >> 2;
100 alpha = (
a[2*x] +
a[xnext]) >> 1;
101 u =
s[x]*
alpha + target_table[((x^y)>>5)&1][plane]*(255-
alpha) + 128;
102 d[x] = (257*
u) >> 16;
107 const uint16_t *
s = (
const uint16_t *)(
src[plane ] + srcStride[plane ] * ysrc);
108 const uint16_t *
a = (
const uint16_t *)(
src[plane_count] + srcStride[plane_count] * ysrc);
109 uint16_t *d = ( uint16_t *)(
dst[plane ] + dstStride[plane ] * y);
110 if ((!
isBE(
c->opts.src_format)) == !HAVE_BIGENDIAN) {
111 for (x = 0; x <
w; x++) {
112 unsigned u =
s[x]*
a[x] + target_table[((x^y)>>5)&1][plane]*(
max-
a[x]) + off;
116 for (x = 0; x <
w; x++) {
118 unsigned u =
av_bswap16(
s[x])*aswap + target_table[((x^y)>>5)&1][plane]*(
max-aswap) + off;
123 const uint8_t *
s =
src[plane ] + srcStride[plane] * ysrc;
124 const uint8_t *
a =
src[plane_count] + srcStride[plane_count] * ysrc;
125 uint8_t *d =
dst[plane ] + dstStride[plane] * y;
126 for (x = 0; x <
w; x++) {
127 unsigned u =
s[x]*
a[x] + target_table[((x^y)>>5)&1][plane]*(255-
a[x]) + 128;
128 d[x] = (257*
u) >> 16;
135 int alpha_pos =
desc->comp[plane_count].offset;
136 int w =
c->opts.src_w;
137 for (ysrc = 0; ysrc < srcSliceH; ysrc++) {
138 int y = ysrc + srcSliceY;
140 const uint16_t *
s = (
const uint16_t *)(
src[0] + srcStride[0] * ysrc + 2*!alpha_pos);
141 const uint16_t *
a = (
const uint16_t *)(
src[0] + srcStride[0] * ysrc + alpha_pos);
142 uint16_t *d = ( uint16_t *)(
dst[0] + dstStride[0] * y);
143 if ((!
isBE(
c->opts.src_format)) == !HAVE_BIGENDIAN) {
144 for (x = 0; x <
w; x++) {
145 for (plane = 0; plane < plane_count; plane++) {
146 int x_index = (plane_count + 1) * x;
147 unsigned u =
s[x_index + plane]*
a[x_index] + target_table[((x^y)>>5)&1][plane]*(
max-
a[x_index]) + off;
152 for (x = 0; x <
w; x++) {
153 for (plane = 0; plane < plane_count; plane++) {
154 int x_index = (plane_count + 1) * x;
156 unsigned u =
av_bswap16(
s[x_index + plane])*aswap + target_table[((x^y)>>5)&1][plane]*(
max-aswap) + off;
162 const uint8_t *
s =
src[0] + srcStride[0] * ysrc + !alpha_pos;
163 const uint8_t *
a =
src[0] + srcStride[0] * ysrc + alpha_pos;
164 uint8_t *d =
dst[0] + dstStride[0] * y;
165 for (x = 0; x <
w; x++) {
166 for (plane = 0; plane < plane_count; plane++) {
167 int x_index = (plane_count + 1) * x;
168 unsigned u =
s[x_index + plane]*
a[x_index] + target_table[((x^y)>>5)&1][plane]*(255-
a[x_index]) + 128;
169 d[plane_count*x + plane] = (257*
u) >> 16;