29 #define INPUT_CLEANSRC 1
65 #define OFFSET(x) offsetof(DecimateContext, x)
66 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
69 {
"cycle",
"set the number of frame from which one will be dropped",
OFFSET(cycle),
AV_OPT_TYPE_INT, {.i64 = 5}, 2, 25,
FLAGS },
72 {
"blockx",
"set the size of the x-axis blocks used during metric calculations",
OFFSET(blockx),
AV_OPT_TYPE_INT, {.i64 = 32}, 4, 1<<9,
FLAGS },
73 {
"blocky",
"set the size of the y-axis blocks used during metric calculations",
OFFSET(blocky),
AV_OPT_TYPE_INT, {.i64 = 32}, 4, 1<<9,
FLAGS },
74 {
"ppsrc",
"mark main input as a pre-processed input and activate clean source input stream",
OFFSET(ppsrc),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1,
FLAGS },
75 {
"chroma",
"set whether or not chroma is considered in the metric calculations",
OFFSET(chroma),
AV_OPT_TYPE_INT, {.i64=1}, 0, 1,
FLAGS },
85 int64_t *bdiffs = dm->
bdiffs;
88 memset(bdiffs, 0, dm->
bdiffsize *
sizeof(*bdiffs));
90 for (plane = 0; plane < (dm->
chroma && f1->
data[2] ? 3 : 1); plane++) {
92 const int linesize1 = f1->
linesize[plane];
93 const int linesize2 = f2->
linesize[plane];
98 int hblockx = dm->
blockx / 2;
99 int hblocky = dm->
blocky / 2;
102 hblockx >>= dm->
hsub;
103 hblocky >>= dm->
vsub;
106 for (y = 0; y <
height; y++) {
107 int ydest = y / hblocky;
110 #define CALC_DIFF(nbits) do { \
111 for (x = 0; x < width; x += hblockx) { \
113 int m = FFMIN(width, x + hblockx); \
114 for (xl = x; xl < m; xl++) \
115 acc += abs(((const uint##nbits##_t *)f1p)[xl] - \
116 ((const uint##nbits##_t *)f2p)[xl]); \
117 bdiffs[ydest * dm->nxblocks + xdest] += acc; \
129 for (i = 0; i < dm->
nyblocks - 1; i++) {
130 for (j = 0; j < dm->
nxblocks - 1; j++) {
131 int64_t tmp = bdiffs[ i * dm->
nxblocks + j ]
133 + bdiffs[(i + 1) * dm->
nxblocks + j ]
134 + bdiffs[(i + 1) * dm->
nxblocks + j + 1];
148 int scpos = -1, duppos = -1;
149 int drop = INT_MIN, i, lowest = 0,
ret;
181 for (i = 0; i < dm->
cycle; i++) {
189 drop = scpos >= 0 && duppos < 0 ? scpos : lowest;
198 i == scpos ?
" sc" :
"",
199 i == duppos ?
" dup" :
"",
200 i == lowest ?
" lowest" :
"",
201 i == drop ?
" [DROP]" :
"");
237 const int w = inlink->
w;
238 const int h = inlink->
h;
243 max_value = (1 << dm->
depth) - 1;
333 if ((dm->
eof & eof_mask) == eof_mask)
345 #define PF_NOALPHA(suf) AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
346 #define PF_ALPHA(suf) AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
347 #define PF(suf) PF_NOALPHA(suf), PF_ALPHA(suf)
365 if (!fps.
num || !fps.
den) {
367 "current rate of %d/%d is invalid\n", fps.
num, fps.
den);
377 outlink->
w = inlink->
w;
378 outlink->
h = inlink->
h;
401 .priv_class = &decimate_class,