28 #define HOUGH_MAX_OFFSET 90
29 #define MAX_FRAMERATE 60
33 #define DIR_PREV_END 2
34 #define DIR_NEXT_END 3
37 #define STATUS_END_REACHED 1
38 #define STATUS_BEGIN_REACHED 2
52 int i, j, tmp_i, tmp_j,count;
55 for (
i = 0, count = 0;
i < 242;
i++) {
56 for (j =
i + 1; j < 243; j++, count++) {
61 dist +=
FFABS((tmp_j % 3) - (tmp_i % 3));
64 }
while (tmp_i > 0 || tmp_j > 0);
73 for (
i = 0;
i < 28;
i += 4) {
75 (first[
i+1] & second[
i+1]) << 16 |
76 (first[
i+2] & second[
i+2]) << 8 |
77 (first[
i+3] & second[
i+3]) );
80 (first[29] & second[29]) << 8 |
81 (first[30] & second[30]) );
88 for (
i = 0;
i < 28;
i += 4) {
90 (first[
i+1] | second[
i+1]) << 16 |
91 (first[
i+2] | second[
i+2]) << 8 |
92 (first[
i+3] | second[
i+3]) );
95 (first[29] | second[29]) << 8 |
96 (first[30] | second[30]) );
103 unsigned int dist = 0;
107 if (first[
i] != second[
i]) {
112 dist += sc->
l1distlut[243*242/2 - (243-
s)*(242-
s)/2 +
f -
s - 1];
114 dist += sc->
l1distlut[243*242/2 - (243-
f)*(242-
f)/2 +
s -
f - 1];
127 int jaccarddist,
i, composdist = 0, cwthcount = 0;
128 for (
i = 0;
i < 5;
i++) {
133 if (++cwthcount > 2) {
138 composdist += jaccarddist;
154 if ((*second)->next) {
155 *second = (*second)->
next;
156 }
else if ((*first)->next) {
157 *second = secondstart;
158 *first = (*first)->
next;
169 if ((*second)->next) {
170 *second = (*second)->
next;
171 }
else if ((*first)->next) {
172 *second = secondstart;
173 *first = (*first)->
next;
187 size_t i, j, k, l, hmax = 0, score;
200 typedef struct hspace_elem {
214 hspace[
i][j].score = 0;
215 hspace[
i][j].dist = 99999;
222 pairs[
i].dist = 99999;
224 for (j = 0,
s = second; j <
COARSE_SIZE &&
s->next; j++,
s =
s->next) {
227 if (l1dist < sc->thl1) {
228 if (l1dist < pairs[
i].dist) {
230 pairs[
i].dist = l1dist;
231 pairs[
i].b_pos[0] = j;
233 }
else if (l1dist == pairs[
i].dist) {
234 pairs[
i].b[pairs[
i].size] =
s;
235 pairs[
i].b_pos[pairs[
i].size] = j;
242 if (
f->next ==
NULL) {
245 pairs[
i].dist = 99999;
251 for (j = 0; j < pairs[
i].size; j++) {
253 for (l = 0; l < pairs[k].size; l++) {
254 if (pairs[
i].
b[j] != pairs[k].
b[l]) {
256 m = (pairs[k].b_pos[l]-pairs[
i].b_pos[j]) / (k-
i);
261 if (pairs[
i].dist < pairs[k].dist) {
288 hmax = (
int) (0.7*hmax);
291 if (hmax < hspace[
i][j].score) {
308 c->framerateratio = (
i+1.0) / 30;
309 c->score = hspace[
i][j].score;
311 c->first = hspace[
i][j].a;
312 c->second = hspace[
i][j].b;
336 step = ((
int) 0.5 + fcount * frr)
337 -((
int) 0.5 + (fcount-1) * frr);
355 if ((*b)->next && (*b)->next->next) {
356 *
b = (*b)->next->next;
377 if ((*a)->next && (*a)->next->next) {
378 *
a = (*a)->next->next;
401 if ((*b)->prev && (*b)->prev->prev) {
402 *
b = (*b)->prev->prev;
423 if ((*a)->prev && (*a)->prev->prev) {
424 *
a = (*a)->prev->prev;
436 int dist, distsum = 0, bcount = 1, dir =
DIR_NEXT;
437 int fcount = 0, goodfcount = 0, gooda = 0, goodb = 0;
438 double meandist, minmeandist = bestmatch.
meandist;
439 int tolerancecount = 0;
443 for (; infos !=
NULL; infos = infos->
next) {
449 if (dist > sc->
thl1) {
450 if (
a->confidence >= 1 ||
b->confidence >= 1) {
455 if (tolerancecount > 2) {
476 if (
a->confidence < 1) gooda++;
477 if (
b->confidence < 1) goodb++;
495 if (sc->
thdi != 0 && bcount >= sc->
thdi) {
500 if (bcount < sc->thdi)
502 if ((
double) goodfcount / (
double) fcount < sc->thit)
504 if ((
double) goodfcount*0.5 <=
FFMAX(gooda, goodb))
507 meandist = (double) distsum / (
double) goodfcount;
509 if (meandist < minmeandist ||
512 minmeandist = meandist;
561 "indices of first frame: %"PRIu32
" and %"PRIu32
"\n",
567 for (
i = infos;
i !=
NULL;
i =
i->next) {
569 "ratio %f, offset %d\n",
i->first->index,
i->second->index,
570 i->framerateratio,
i->offset);
578 "ratio %f, offset %d, score %d, %d frames matching\n",
static double val(void *priv, double ch)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
mode
Use these values in ebur128_init (or'ed).
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
int av_log_get_level(void)
Get the current log level.
MPEG-7 video signature calculation and lookup filter.
static int iterate_frame(double frr, FineSignature **a, FineSignature **b, int fcount, int *bcount, int dir)
static int find_next_coarsecandidate(SignatureContext *sc, CoarseSignature *secondstart, CoarseSignature **first, CoarseSignature **second, int start)
step through the coarsesignatures as long as a good candidate is found
static void sll_free(MatchingInfo **sll)
static MatchingInfo * get_matching_parameters(AVFilterContext *ctx, SignatureContext *sc, FineSignature *first, FineSignature *second)
compares framesignatures and sorts out signatures with a l1 distance above a given threshold.
static unsigned int union_word(const uint8_t *first, const uint8_t *second)
static MatchingInfo evaluate_parameters(AVFilterContext *ctx, SignatureContext *sc, MatchingInfo *infos, MatchingInfo bestmatch, int mode)
static unsigned int intersection_word(const uint8_t *first, const uint8_t *second)
#define STATUS_BEGIN_REACHED
#define STATUS_END_REACHED
static MatchingInfo lookup_signatures(AVFilterContext *ctx, SignatureContext *sc, StreamContext *first, StreamContext *second, int mode)
static void fill_l1distlut(uint8_t lut[])
static unsigned int get_l1dist(AVFilterContext *ctx, SignatureContext *sc, const uint8_t *first, const uint8_t *second)
static int get_jaccarddist(SignatureContext *sc, CoarseSignature *first, CoarseSignature *second)
calculates the jaccard distance and evaluates a pair of coarse signatures as good
struct FineSignature * first
struct CoarseSignature * next
struct MatchingInfo * next
struct FineSignature * second
struct FineSignature * first
uint8_t l1distlut[243 *242/2]
CoarseSignature * coarsesiglist
#define av_malloc_array(a, b)
static void error(const char *err)
static const uint8_t offset[127][2]