45 #define OFFSET(x) offsetof(FSPPContext, x)
46 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
58 { 0, 48, 12, 60, 3, 51, 15, 63, },
59 { 32, 16, 44, 28, 35, 19, 47, 31, },
60 { 8, 56, 4, 52, 11, 59, 7, 55, },
61 { 40, 24, 36, 20, 43, 27, 39, 23, },
62 { 2, 50, 14, 62, 1, 49, 13, 61, },
63 { 34, 18, 46, 30, 33, 17, 45, 29, },
64 { 10, 58, 6, 54, 9, 57, 5, 53, },
65 { 42, 26, 38, 22, 41, 25, 37, 21, },
72 71, 296, 295, 237, 71, 40, 38, 19,
73 245, 193, 185, 121, 102, 73, 53, 27,
74 158, 129, 141, 107, 97, 73, 50, 26,
75 102, 116, 109, 98, 82, 66, 45, 23,
76 71, 94, 95, 81, 70, 56, 38, 20,
77 56, 77, 74, 66, 56, 44, 30, 15,
78 38, 53, 50, 45, 38, 30, 21, 11,
79 20, 27, 26, 23, 20, 15, 11, 5
84 ptrdiff_t dst_stride, ptrdiff_t src_stride,
85 ptrdiff_t
width, ptrdiff_t
height, ptrdiff_t log2_scale)
89 temp = (src[x + pos] + (d[pos] >> log2_scale)) >> (6 - log2_scale); \
90 src[x + pos] = src[x + pos - 8 * src_stride] = 0; \
91 if (temp & 0x100) temp = ~(temp >> 31); \
94 for (y = 0; y <
height; y++) {
96 for (x = 0; x <
width; x += 8) {
114 ptrdiff_t dst_stride, ptrdiff_t src_stride,
115 ptrdiff_t
width, ptrdiff_t
height, ptrdiff_t log2_scale)
118 #define STORE2(pos) \
119 temp = (src[x + pos] + src[x + pos + 16 * src_stride] + (d[pos] >> log2_scale)) >> (6 - log2_scale); \
120 src[x + pos + 16 * src_stride] = 0; \
121 if (temp & 0x100) temp = ~(temp >> 31); \
124 for (y = 0; y <
height; y++) {
126 for (x = 0; x <
width; x += 8) {
142 static void mul_thrmat_c(int16_t *thr_adr_noq, int16_t *thr_adr,
int q)
145 for (a = 0; a < 64; a++)
146 thr_adr[a] = q * thr_adr_noq[a];
150 int dst_stride,
int src_stride,
152 uint8_t *qp_store,
int qp_stride,
int is_luma)
154 int x, x0,
y, es, qy, t;
158 const int qpsh = 4 - p->
hsub * !is_luma;
159 const int qpsv = 4 - p->
vsub * !is_luma;
162 int16_t *
block = (int16_t *)block_align;
163 int16_t *block3 = (int16_t *)(block_align + 4 * 8 *
BLOCKSZ);
165 memset(block3, 0, 4 * 8 *
BLOCKSZ);
167 if (!src || !dst)
return;
169 for (y = 0; y <
height; y++) {
170 int index = 8 + 8 * stride + y * stride;
171 memcpy(p->
src + index, src + y * src_stride, width);
172 for (x = 0; x < 8; x++) {
173 p->
src[index - x - 1] = p->
src[index + x ];
174 p->
src[index + width + x ] = p->
src[index + width - x - 1];
178 for (y = 0; y < 8; y++) {
179 memcpy(p->
src + ( 7 - y ) * stride, p->
src + ( y + 8 ) * stride, stride);
180 memcpy(p->
src + (height + 8 + y) * stride, p->
src + (height - y + 7) * stride, stride);
184 for (y = 8; y < 24; y++)
185 memset(p->
temp + 8 + y * stride, 0, width *
sizeof(int16_t));
187 for (y = step; y < height + 8; y += step) {
188 const int y1 = y - 8 + step;
191 if (qy > height - 1) qy = height - 1;
194 qy = (qy >> qpsv) * qp_stride;
195 p->
row_fdct(block, p->
src + y * stride + 2 - (y&1), stride, 2);
197 for (x0 = 0; x0 < width + 8 - 8 * (
BLOCKSZ - 1); x0 += 8 * (
BLOCKSZ - 1)) {
198 p->
row_fdct(block + 8 * 8, p->
src + y * stride + 8 + x0 + 2 - (y&1), stride, 2 * (
BLOCKSZ - 1));
203 for (x = 0; x < 8 * (
BLOCKSZ - 1); x += 8) {
208 t = qp_store[qy + (t >> qpsh)];
214 p->
row_idct(block3 + 0 * 8, p->
temp + (y & 15) * stride + x0 + 2 - (y & 1), stride, 2 * (
BLOCKSZ - 1));
215 memmove(block, block + (
BLOCKSZ - 1) * 64, 8 * 8 *
sizeof(int16_t));
216 memmove(block3, block3 + (
BLOCKSZ - 1) * 64, 6 * 8 *
sizeof(int16_t));
221 p->
row_fdct(block + 8 * 8, p->
src + y * stride + 8 + x0 + 2 - (y & 1), stride, (es - 4) >> 2);
225 p->
row_idct(block3 + 0 * 8, p->
temp + (y & 15) * stride + x0 + 2 - (y & 1), stride, es >> 2);
227 if (!(y1 & 7) && y1) {
230 dst_stride, stride, width, 8, 5 - p->
log2_count);
233 dst_stride, stride, width, 8, 5 - p->
log2_count);
239 p->
store_slice(dst + ((y - 8) & ~7) * dst_stride, p->
temp + 8 + 8 * stride,
240 dst_stride, stride, width, y&7, 5 - p->
log2_count);
242 p->
store_slice2(dst + ((y - 8) & ~7) * dst_stride, p->
temp + 8 + 0 * stride,
243 dst_stride, stride, width, y&7, 5 - p->
log2_count);
249 int_simd16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
262 for (; cnt > 0; cnt -= 2) {
263 threshold = (int16_t *)thr_adr;
264 for (ctr =
DCTSIZE; ctr > 0; ctr--) {
299 tmp10 = (tmp0 + tmp2) >> 2;
300 tmp11 = (tmp0 - tmp2) >> 2;
302 tmp13 = (tmp1 + tmp3) >>2;
305 tmp0 = tmp10 + tmp13;
306 tmp3 = tmp10 - tmp13;
307 tmp1 = tmp11 + tmp12;
308 tmp2 = tmp11 - tmp12;
338 z10 = (tmp6 - tmp5) << 1;
340 z12 = (tmp4 - tmp7) << 1;
342 tmp7 = (z11 + z13) >> 2;
352 wsptr[
DCTSIZE * 0] += (tmp0 + tmp7);
353 wsptr[
DCTSIZE * 1] += (tmp1 + tmp6);
354 wsptr[
DCTSIZE * 2] += (tmp2 + tmp5);
355 wsptr[
DCTSIZE * 3] += (tmp3 - tmp4);
356 wsptr[
DCTSIZE * 4] += (tmp3 + tmp4);
357 wsptr[
DCTSIZE * 5] += (tmp2 - tmp5);
358 wsptr[
DCTSIZE * 6] = (tmp1 - tmp6);
359 wsptr[
DCTSIZE * 7] = (tmp0 - tmp7);
370 static void row_idct_c(int16_t *workspace, int16_t *output_adr, ptrdiff_t output_stride,
int cnt)
372 int_simd16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
381 for (; cnt > 0; cnt--) {
384 tmp10 = wsptr[2] + wsptr[3];
385 tmp11 = wsptr[2] - wsptr[3];
387 tmp13 = wsptr[0] + wsptr[1];
390 tmp0 = tmp10 + tmp13;
391 tmp3 = tmp10 - tmp13;
392 tmp1 = tmp11 + tmp12;
393 tmp2 = tmp11 - tmp12;
401 z13 = wsptr[4] + wsptr[5];
402 z10 = wsptr[4] - wsptr[5];
403 z11 = wsptr[6] + wsptr[7];
404 z12 = wsptr[6] - wsptr[7];
413 tmp6 = (tmp12 << 3) - tmp7;
414 tmp5 = (tmp11 << 3) - tmp6;
415 tmp4 = (tmp10 << 3) + tmp5;
418 outptr[0 * output_stride] +=
DESCALE(tmp0 + tmp7, 3);
419 outptr[1 * output_stride] +=
DESCALE(tmp1 + tmp6, 3);
420 outptr[2 * output_stride] +=
DESCALE(tmp2 + tmp5, 3);
421 outptr[3 * output_stride] +=
DESCALE(tmp3 - tmp4, 3);
422 outptr[4 * output_stride] +=
DESCALE(tmp3 + tmp4, 3);
423 outptr[5 * output_stride] +=
DESCALE(tmp2 - tmp5, 3);
424 outptr[6 * output_stride] +=
DESCALE(tmp1 - tmp6, 3);
425 outptr[7 * output_stride] +=
DESCALE(tmp0 - tmp7, 3);
434 int_simd16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
443 for (; cnt > 0; cnt--) {
444 tmp0 = pixels[line_size * 0] + pixels[line_size * 7];
445 tmp7 = pixels[line_size * 0] - pixels[line_size * 7];
446 tmp1 = pixels[line_size * 1] + pixels[line_size * 6];
447 tmp6 = pixels[line_size * 1] - pixels[line_size * 6];
448 tmp2 = pixels[line_size * 2] + pixels[line_size * 5];
449 tmp5 = pixels[line_size * 2] - pixels[line_size * 5];
450 tmp3 = pixels[line_size * 3] + pixels[line_size * 4];
451 tmp4 = pixels[line_size * 3] - pixels[line_size * 4];
462 dataptr[2] = tmp10 + tmp11;
463 dataptr[3] = tmp10 - tmp11;
466 dataptr[0] = tmp13 + z1;
467 dataptr[1] = tmp13 - z1;
471 tmp10 = (tmp4 + tmp5) << 2;
472 tmp11 = (tmp5 + tmp6) << 2;
473 tmp12 = (tmp6 + tmp7) << 2;
483 dataptr[4] = z13 + z2;
484 dataptr[5] = z13 - z2;
485 dataptr[6] = z11 + z4;
486 dataptr[7] = z11 - z4;
512 const int h =
FFALIGN(inlink->
h + 16, 16);
555 int custom_threshold_m[64];
559 for (i = 0; i < 64; i++)
562 for (i = 0; i < 8; i++) {
564 |(((uint64_t)custom_threshold_m[i * 8 + 6]) << 16)
565 |(((uint64_t)custom_threshold_m[i * 8 + 0]) << 32)
566 |(((uint64_t)custom_threshold_m[i * 8 + 4]) << 48);
569 |(((uint64_t)custom_threshold_m[i * 8 + 3]) << 16)
570 |(((uint64_t)custom_threshold_m[i * 8 + 1]) << 32)
571 |(((uint64_t)custom_threshold_m[i * 8 + 7]) << 48);
605 av_assert0(w * h <= fspp->non_b_qp_alloc_size);
614 if (qp_table || fspp->
qp) {
621 const int aligned_w =
FFALIGN(inlink->
w, 8);
622 const int aligned_h =
FFALIGN(inlink->
h, 8);
635 inlink->
w, inlink->
h, qp_table, qp_stride, 1);
637 cw, ch, qp_table, qp_stride, 0);
639 cw, ch, qp_table, qp_stride, 0);
648 inlink->
w, inlink->
h);
688 .priv_class = &fspp_class,