54 *iter = (
void*)(uintptr_t)
c;
61 return prev ?
NULL :
s->dct;
64 #define OFFSET(x) offsetof(SPPContext, x)
65 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
66 #define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
89 { 0, 48, 12, 60, 3, 51, 15, 63 },
90 { 32, 16, 44, 28, 35, 19, 47, 31 },
91 { 8, 56, 4, 52, 11, 59, 7, 55 },
92 { 40, 24, 36, 20, 43, 27, 39, 23 },
93 { 2, 50, 14, 62, 1, 49, 13, 61 },
94 { 34, 18, 46, 30, 33, 17, 45, 29 },
95 { 10, 58, 6, 54, 9, 57, 5, 53 },
96 { 42, 26, 38, 22, 41, 25, 37, 21 },
99 static const uint8_t
offset[128][2] = {
103 {0,0}, {2,2}, {6,4}, {4,6},
104 {0,0}, {5,1}, {2,2}, {7,3}, {4,4}, {1,5}, {6,6}, {3,7},
106 {0,0}, {4,0}, {1,1}, {5,1}, {3,2}, {7,2}, {2,3}, {6,3},
107 {0,4}, {4,4}, {1,5}, {5,5}, {3,6}, {7,6}, {2,7}, {6,7},
109 {0,0}, {0,2}, {0,4}, {0,6}, {1,1}, {1,3}, {1,5}, {1,7},
110 {2,0}, {2,2}, {2,4}, {2,6}, {3,1}, {3,3}, {3,5}, {3,7},
111 {4,0}, {4,2}, {4,4}, {4,6}, {5,1}, {5,3}, {5,5}, {5,7},
112 {6,0}, {6,2}, {6,4}, {6,6}, {7,1}, {7,3}, {7,5}, {7,7},
114 {0,0}, {4,4}, {0,4}, {4,0}, {2,2}, {6,6}, {2,6}, {6,2},
115 {0,2}, {4,6}, {0,6}, {4,2}, {2,0}, {6,4}, {2,4}, {6,0},
116 {1,1}, {5,5}, {1,5}, {5,1}, {3,3}, {7,7}, {3,7}, {7,3},
117 {1,3}, {5,7}, {1,7}, {5,3}, {3,1}, {7,5}, {3,5}, {7,1},
118 {0,1}, {4,5}, {0,5}, {4,1}, {2,3}, {6,7}, {2,7}, {6,3},
119 {0,3}, {4,7}, {0,7}, {4,3}, {2,1}, {6,5}, {2,5}, {6,1},
120 {1,0}, {5,4}, {1,4}, {5,0}, {3,2}, {7,6}, {3,6}, {7,2},
121 {1,2}, {5,6}, {1,6}, {5,2}, {3,0}, {7,4}, {3,4}, {7,0},
125 int qp,
const uint8_t *permutation)
130 unsigned threshold1 = qp * ((1<<4) -
bias) - 1;
131 unsigned threshold2 = threshold1 << 1;
133 memset(dst, 0, 64 *
sizeof(dst[0]));
134 dst[0] = (
src[0] + 4) >> 3;
136 for (
i = 1;
i < 64;
i++) {
138 if (((
unsigned)(
level + threshold1)) > threshold2) {
139 const int j = permutation[
i];
140 dst[j] = (
level + 4) >> 3;
146 int qp,
const uint8_t *permutation)
151 unsigned threshold1 = qp * ((1<<4) -
bias) - 1;
152 unsigned threshold2 = threshold1 << 1;
154 memset(dst, 0, 64 *
sizeof(dst[0]));
155 dst[0] = (
src[0] + 4) >> 3;
157 for (
i = 1;
i < 64;
i++) {
159 if (((
unsigned)(
level + threshold1)) > threshold2) {
160 const int j = permutation[
i];
161 if (
level > 0) dst[j] = (
level - threshold1 + 4) >> 3;
162 else dst[j] = (
level + threshold1 + 4) >> 3;
168 int dst_linesize,
int src_linesize,
170 const uint8_t
dither[8][8])
174 #define STORE(pos) do { \
175 temp = (src[x + y*src_linesize + pos] * (1 << log2_scale) + d[pos]) >> 6;\
177 temp = ~(temp >> 31); \
178 dst[x + y*dst_linesize + pos] = temp; \
181 for (y = 0; y <
height; y++) {
183 for (x = 0; x <
width; x += 8) {
198 int dst_linesize,
int src_linesize,
200 const uint8_t
dither[8][8],
int depth)
203 unsigned int mask = -1<<depth;
205 #define STORE16(pos) do { \
206 temp = (src[x + y*src_linesize + pos] * (1 << log2_scale) + (d[pos]>>1)) >> 5; \
208 temp = ~(temp >> 31); \
209 dst[x + y*dst_linesize + pos] = temp; \
212 for (y = 0; y <
height; y++) {
214 for (x = 0; x <
width; x += 8) {
228 static inline void add_block(uint16_t *dst,
int linesize,
const int16_t
block[64])
232 for (y = 0; y < 8; y++) {
233 dst[0 + y*linesize] +=
block[0 + y*8];
234 dst[1 + y*linesize] +=
block[1 + y*8];
235 dst[2 + y*linesize] +=
block[2 + y*8];
236 dst[3 + y*linesize] +=
block[3 + y*8];
237 dst[4 + y*linesize] +=
block[4 + y*8];
238 dst[5 + y*linesize] +=
block[5 + y*8];
239 dst[6 + y*linesize] +=
block[6 + y*8];
240 dst[7 + y*linesize] +=
block[7 + y*8];
245 int dst_linesize,
int src_linesize,
int width,
int height,
246 const uint8_t *qp_table,
int qp_stride,
int is_luma,
int depth)
252 int16_t *
block = (int16_t *)block_align;
253 int16_t *block2 = (int16_t *)(block_align + 16);
254 uint16_t *psrc16 = (uint16_t*)p->
src;
255 const int sample_bytes = (depth+7) / 8;
257 for (y = 0; y <
height; y++) {
258 int index = 8 + 8*linesize + y*linesize;
259 memcpy(p->
src +
index*sample_bytes,
src + y*src_linesize,
width*sample_bytes);
260 if (sample_bytes == 1) {
261 for (x = 0; x < 8; x++) {
266 for (x = 0; x < 8; x++) {
272 for (y = 0; y < 8; y++) {
273 memcpy(p->
src + ( 7-y)*linesize * sample_bytes, p->
src + ( y+8)*linesize * sample_bytes, linesize * sample_bytes);
274 memcpy(p->
src + (
height+8+y)*linesize * sample_bytes, p->
src + (
height-y+7)*linesize * sample_bytes, linesize * sample_bytes);
277 for (y = 0; y <
height + 8; y += 8) {
278 memset(p->
temp + (8 + y) * linesize, 0, 8 * linesize *
sizeof(*p->
temp));
279 for (x = 0; x <
width + 8; x += 8) {
285 const int qps = 3 + is_luma;
289 for (
i = 0;
i < count;
i++) {
290 const int x1 = x +
offset[
i + count][0];
291 const int y1 = y +
offset[
i + count][1];
292 const int index = x1 + y1*linesize;
301 if (sample_bytes == 1) {
303 dst_linesize, linesize,
width,
308 dst_linesize/2, linesize,
width,
338 const int bps =
desc->comp[0].depth;
353 s->hsub =
desc->log2_chroma_w;
354 s->vsub =
desc->log2_chroma_h;
359 if (!
s->temp || !
s->src)
371 int8_t *qp_table =
NULL;
373 const int depth =
desc->comp[0].depth;
389 s->non_b_qp_table = qp_table;
390 s->non_b_qp_stride = qp_stride;
394 if (
s->log2_count && !
ctx->is_disabled) {
395 if (!
s->use_bframe_qp &&
s->non_b_qp_table) {
396 qp_table =
s->non_b_qp_table;
397 qp_stride =
s->non_b_qp_stride;
400 if (qp_table ||
s->qp) {
421 filter(
s,
out->data[0], in->
data[0],
out->linesize[0], in->
linesize[0],
inlink->w,
inlink->h, qp_table, qp_stride, 1, depth);
424 filter(
s,
out->data[1], in->
data[1],
out->linesize[1], in->
linesize[1], cw, ch, qp_table, qp_stride, 0, depth);
425 filter(
s,
out->data[2], in->
data[2],
out->linesize[2], in->
linesize[2], cw, ch, qp_table, qp_stride, 0, depth);
440 if (qp_table !=
s->non_b_qp_table)
446 char *res,
int res_len,
int flags)
450 if (!strcmp(cmd,
"level") || !strcmp(cmd,
"quality")) {
451 if (!strcmp(args,
"max"))