29 #define INPUT_CLEANSRC 1
64 #define OFFSET(x) offsetof(DecimateContext, x)
65 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
68 {
"cycle",
"set the number of frame from which one will be dropped",
OFFSET(cycle),
AV_OPT_TYPE_INT, {.i64 = 5}, 2, 25,
FLAGS },
71 {
"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 },
72 {
"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 },
73 {
"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 },
74 {
"chroma",
"set whether or not chroma is considered in the metric calculations",
OFFSET(chroma),
AV_OPT_TYPE_INT, {.i64=1}, 0, 1,
FLAGS },
84 int64_t *bdiffs = dm->
bdiffs;
87 memset(bdiffs, 0, dm->
bdiffsize *
sizeof(*bdiffs));
89 for (plane = 0; plane < (dm->
chroma && f1->
data[2] ? 3 : 1); plane++) {
91 const int linesize1 = f1->
linesize[plane];
92 const int linesize2 = f2->
linesize[plane];
97 int hblockx = dm->
blockx / 2;
98 int hblocky = dm->
blocky / 2;
101 hblockx >>= dm->
hsub;
102 hblocky >>= dm->
vsub;
105 for (y = 0; y <
height; y++) {
106 int ydest = y / hblocky;
109 #define CALC_DIFF(nbits) do { \
110 for (x = 0; x < width; x += hblockx) { \
112 int m = FFMIN(width, x + hblockx); \
113 for (xl = x; xl < m; xl++) \
114 acc += abs(((const uint##nbits##_t *)f1p)[xl] - \
115 ((const uint##nbits##_t *)f2p)[xl]); \
116 bdiffs[ydest * dm->nxblocks + xdest] += acc; \
128 for (i = 0; i < dm->
nyblocks - 1; i++) {
129 for (j = 0; j < dm->
nxblocks - 1; j++) {
130 int64_t tmp = bdiffs[ i * dm->
nxblocks + j ]
132 + bdiffs[(i + 1) * dm->
nxblocks + j ]
133 + bdiffs[(i + 1) * dm->
nxblocks + j + 1];
147 int scpos = -1, duppos = -1;
148 int drop = INT_MIN, i, lowest = 0,
ret;
180 for (i = 0; i < dm->
cycle; i++) {
188 drop = scpos >= 0 && duppos < 0 ? scpos : lowest;
197 i == scpos ?
" sc" :
"",
198 i == duppos ?
" dup" :
"",
199 i == lowest ?
" lowest" :
"",
200 i == drop ?
" [DROP]" :
"");
233 const int w = inlink->
w;
234 const int h = inlink->
h;
239 max_value = (1 << dm->
depth) - 1;
327 if ((dm->
eof & eof_mask) == eof_mask)
339 #define PF_NOALPHA(suf) AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
340 #define PF_ALPHA(suf) AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
341 #define PF(suf) PF_NOALPHA(suf), PF_ALPHA(suf)
359 if (!fps.
num || !fps.
den) {
361 "current rate of %d/%d is invalid\n", fps.
num, fps.
den);
371 outlink->
w = inlink->
w;
372 outlink->
h = inlink->
h;
395 .priv_class = &decimate_class,