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 
   42     int i, j, tmp_i, tmp_j,
count;
 
   45     for (i = 0, count = 0; i < 242; i++) {
 
   46         for (j = i + 1; j < 243; j++, count++) {
 
   51                 dist += 
FFABS((tmp_j % 3) - (tmp_i % 3));
 
   54             } 
while (tmp_i > 0 || tmp_j > 0);
 
   63     for (i = 0; i < 28; i += 4) {
 
   64         val += av_popcount( (first[i]   & second[i]  ) << 24 |
 
   65                             (first[i+1] & second[i+1]) << 16 |
 
   66                             (first[i+2] & second[i+2]) << 8  |
 
   67                             (first[i+3] & second[i+3]) );
 
   69     val += av_popcount( (first[28] & second[28]) << 16 |
 
   70                         (first[29] & second[29]) << 8  |
 
   71                         (first[30] & second[30]) );
 
   78     for (i = 0; i < 28; i += 4) {
 
   79         val += av_popcount( (first[i]   | second[i]  ) << 24 |
 
   80                             (first[i+1] | second[i+1]) << 16 |
 
   81                             (first[i+2] | second[i+2]) << 8  |
 
   82                             (first[i+3] | second[i+3]) );
 
   84     val += av_popcount( (first[28] | second[28]) << 16 |
 
   85                         (first[29] | second[29]) << 8  |
 
   86                         (first[30] | second[30]) );
 
   93     unsigned int dist = 0;
 
   97         if (first[i] != second[i]) {
 
  102                 dist += sc->
l1distlut[243*242/2 - (243-
s)*(242-s)/2 + f - s - 1];
 
  104                 dist += sc->
l1distlut[243*242/2 - (243-
f)*(242-f)/2 + s - f - 1];
 
  117     int jaccarddist, i, composdist = 0, cwthcount = 0;
 
  118     for (i = 0; i < 5; i++) {
 
  123             if (++cwthcount > 2) {
 
  128         composdist += jaccarddist;
 
  144         if ((*second)->next) {
 
  145             *second = (*second)->
next;
 
  146         } 
else if ((*first)->next) {
 
  147             *second = secondstart;
 
  148             *first = (*first)->
next;
 
  159         if ((*second)->next) {
 
  160             *second = (*second)->
next;
 
  161         } 
else if ((*first)->next) {
 
  162             *second = secondstart;
 
  163             *first = (*first)->
next;
 
  177     size_t i, j, k, l, hmax = 0, score;
 
  178     int framerate, 
offset, l1dist;
 
  190     typedef struct hspace_elem {
 
  204             hspace[i][j].score = 0;
 
  205             hspace[i][j].dist = 99999;
 
  212         pairs[i].dist = 99999;
 
  216             l1dist = 
get_l1dist(ctx, sc, f->framesig, s->framesig);
 
  217             if (l1dist < sc->thl1) {
 
  218                 if (l1dist < pairs[i].dist) {
 
  220                     pairs[i].dist = l1dist;
 
  221                     pairs[i].b_pos[0] = j;
 
  223                 } 
else if (l1dist == pairs[i].dist) {
 
  224                     pairs[i].b[pairs[i].size] = 
s;
 
  225                     pairs[i].b_pos[pairs[i].size] = j;
 
  232     if (f->next == 
NULL) {
 
  235             pairs[i].dist = 99999;
 
  241         for (j = 0; j < pairs[i].size; j++) {
 
  243                 for (l = 0; l < pairs[k].size; l++) {
 
  244                     if (pairs[i].
b[j] != pairs[k].
b[l]) {
 
  246                         m = (pairs[k].b_pos[l]-pairs[i].b_pos[j]) / (k-i); 
 
  247                         framerate = (
int) m*30 + 0.5; 
 
  248                         if (framerate>0 && framerate <= MAX_FRAMERATE) {
 
  249                             offset = pairs[i].b_pos[j] - ((
int) m*i + 0.5); 
 
  251                                 if (pairs[i].dist < pairs[k].dist) {
 
  278         hmax = (
int) (0.7*hmax);
 
  281                 if (hmax < hspace[i][j].score) {
 
  293                     c->framerateratio = (i+1.0) / 30;
 
  294                     c->score = hspace[i][j].score;
 
  296                     c->first = hspace[i][j].a;
 
  297                     c->second = hspace[i][j].b;
 
  320     step = ((
int) 0.5 + fcount     * frr) 
 
  321           -((
int) 0.5 + (fcount-1) * frr);
 
  339                 if ((*b)->next && (*b)->next->next) {
 
  361                 if ((*a)->next && (*a)->next->next) {
 
  385                 if ((*b)->prev && (*b)->prev->prev) {
 
  407                 if ((*a)->prev && (*a)->prev->prev) {
 
  420     int dist, distsum = 0, bcount = 1, dir = 
DIR_NEXT;
 
  421     int fcount = 0, goodfcount = 0, gooda = 0, goodb = 0;
 
  422     double meandist, minmeandist = bestmatch.
meandist;
 
  423     int tolerancecount = 0;
 
  427     for (; infos != 
NULL; infos = infos->
next) {
 
  433             if (dist > sc->
thl1) {
 
  439                 if (tolerancecount > 2) {
 
  479             if (sc->
thdi != 0 && bcount >= sc->
thdi) {
 
  484         if (bcount < sc->thdi)
 
  486         if ((
double) goodfcount / (
double) fcount < sc->thit)
 
  488         if ((
double) goodfcount*0.5 < 
FFMAX(gooda, goodb))
 
  491         meandist = (double) goodfcount / (
double) distsum;
 
  493         if (meandist < minmeandist ||
 
  496             minmeandist = meandist;
 
  555                "indices of first frame: %"PRIu32
" and %"PRIu32
"\n",
 
  561             for (i = infos; i != 
NULL; i = i->
next) {
 
  572                    "ratio %f, offset %d, score %d, %d frames matching\n",
 
uint8_t l1distlut[243 *242/2]
static unsigned int union_word(const uint8_t *first, const uint8_t *second)
const char const char void * val
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 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 
struct FineSignature * next
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
static void fill_l1distlut(uint8_t lut[])
#define STATUS_END_REACHED
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers. 
int av_log_get_level(void)
Get the current log level. 
static const uint8_t offset[127][2]
static MatchingInfo lookup_signatures(AVFilterContext *ctx, SignatureContext *sc, StreamContext *first, StreamContext *second, int mode)
struct FineSignature * second
static void sll_free(MatchingInfo *sll)
MPEG-7 video signature calculation and lookup filter. 
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
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)
static unsigned int get_l1dist(AVFilterContext *ctx, SignatureContext *sc, const uint8_t *first, const uint8_t *second)
#define STATUS_BEGIN_REACHED
static int iterate_frame(double frr, FineSignature **a, FineSignature **b, int fcount, int *bcount, int dir)
struct CoarseSignature * next
CoarseSignature * coarsesiglist
struct FineSignature * first
struct FineSignature * prev
#define AV_LOG_FATAL
Something went wrong and recovery is not possible. 
#define av_malloc_array(a, b)
mode
Use these values in ebur128_init (or'ed). 
struct MatchingInfo * next
uint8_t framesig[SIGELEM_SIZE/5]