Mercurial > mplayer.hg
comparison libmpcodecs/pullup.c @ 10730:67449e5936f3
fix 10l (computation based on uninitialized data which led to
incorrect field matching) and greatly improve selection logic. the
pullup core should be very accurate now, so try throwing tough samples
at it and report any failures! :)
author | rfelker |
---|---|
date | Sun, 31 Aug 2003 17:46:32 +0000 |
parents | d47ca466c97b |
children | af906af4cf18 |
comparison
equal
deleted
inserted
replaced
10729:07870312c054 | 10730:67449e5936f3 |
---|---|
319 l = f2->diffs[i] - f3->diffs[i]; | 319 l = f2->diffs[i] - f3->diffs[i]; |
320 if (l > max_l) max_l = l; | 320 if (l > max_l) max_l = l; |
321 if (-l > max_r) max_r = -l; | 321 if (-l > max_r) max_r = -l; |
322 } | 322 } |
323 /* Don't get tripped up when differences are mostly quant error */ | 323 /* Don't get tripped up when differences are mostly quant error */ |
324 if (max_l + max_r < 64) return; | 324 if (max_l + max_r < 256) return; |
325 if (max_l > 4*max_r) f1->breaks |= BREAK_LEFT; | 325 if (max_l > 4*max_r) f1->breaks |= BREAK_LEFT; |
326 if (max_r > 4*max_l) f2->breaks |= BREAK_RIGHT; | 326 if (max_r > 4*max_l) f2->breaks |= BREAK_RIGHT; |
327 //printf("max_l=%d max_r=%d\n", max_l, max_r); | 327 //printf("max_l=%d max_r=%d\n", max_l, max_r); |
328 } | 328 } |
329 | 329 |
330 static void compute_affinity(struct pullup_context *c, struct pullup_field *f) | 330 static void compute_affinity(struct pullup_context *c, struct pullup_field *f) |
331 { | 331 { |
332 int i; | 332 int i; |
333 int max_l=0, max_r=0, l; | 333 int max_l=0, max_r=0, l, t; |
334 if (f->flags & F_HAVE_AFFINITY) return; | 334 if (f->flags & F_HAVE_AFFINITY) return; |
335 f->flags |= F_HAVE_AFFINITY; | 335 f->flags |= F_HAVE_AFFINITY; |
336 for (i = 0; i < c->metric_len; i++) { | 336 for (i = 0; i < c->metric_len; i++) { |
337 l = f->licomb[i] - f->next->licomb[i]; | 337 l = f->licomb[i] - f->next->licomb[i]; |
338 if (l > max_l) max_l = l; | 338 if (l > max_l) max_l = l; |
339 if (-l > max_r) max_r = -l; | 339 if (-l > max_r) max_r = -l; |
340 } | 340 } |
341 if (max_l + max_r < 64) return; | 341 if (max_l + max_r < 256) return; |
342 if (max_r > 3*max_l) f->affinity = -1; | 342 if (max_r > 3*max_l) f->affinity = -1; |
343 else if (max_l > 3*max_r) f->affinity = 1; | 343 else if (max_l > 3*max_r) f->affinity = 1; |
344 else if (max_l + max_r > 2048) { | |
345 for (i = 0; i < c->metric_len; i++) { | |
346 l += f->licomb[i] - f->next->licomb[i]; | |
347 t += ABS(f->licomb[i] - f->next->licomb[i]); | |
348 } | |
349 if (-l*4 > t) f->affinity = -1; | |
350 else if (l*4 > t) f->affinity = 1; | |
351 //printf("affinity from avg: %d\n", f->affinity); | |
352 } | |
344 } | 353 } |
345 | 354 |
346 static void foo(struct pullup_context *c) | 355 static void foo(struct pullup_context *c) |
347 { | 356 { |
348 struct pullup_field *f = c->first; | 357 struct pullup_field *f = c->first; |
349 int i, n = queue_length(f, c->last); | 358 int i, n = queue_length(f, c->last); |
350 for (i = 0; i < n; i++) { | 359 for (i = 0; i < n-1; i++) { |
351 if (i < n-3) compute_breaks(c, f); | 360 if (i < n-3) compute_breaks(c, f); |
352 compute_affinity(c, f); | 361 compute_affinity(c, f); |
353 f = f->next; | 362 f = f->next; |
354 } | 363 } |
355 } | 364 } |
367 if (queue_length(c->first, c->last) < 6) return 0; | 376 if (queue_length(c->first, c->last) < 6) return 0; |
368 foo(c); | 377 foo(c); |
369 | 378 |
370 n = find_first_break(f0, 3); | 379 n = find_first_break(f0, 3); |
371 | 380 |
381 if (f0->affinity == -1) return 1; | |
382 | |
372 switch (n) { | 383 switch (n) { |
373 case 1: | 384 case 1: |
374 return 1; | 385 return 1; |
375 case 2: | 386 case 2: |
376 if (f0->affinity == -1 || f1->affinity == 1) return 1; | 387 if (f1->affinity == 1) return 1; |
377 else return 2; | 388 else return 2; |
378 case 3: | 389 case 3: |
379 if (f1->affinity == -1 && f2->affinity != -1) return 2; | 390 if (f1->affinity == -1) return 2; |
380 else if (f1->affinity == 1 && f0->affinity != 1) return 1; | 391 else if (f1->affinity == 1) return 1; |
381 else return 3; | 392 else return 3; |
382 default: | 393 default: |
383 if (f0->affinity == -1 && f1->affinity != -1) return 1; | 394 if (f1->affinity == 1) return 1; |
384 else if (f1->affinity == 1 && f2->affinity == -1) return 1; | 395 else if (f1->affinity == -1) return 2; |
396 else if (f2->affinity == 1) return 2; | |
397 else if (f0->affinity == 1 && f2->affinity == -1) return 3; | |
398 else if (f2->affinity == 0 && f3->affinity == 1) return 3; | |
385 else return 2; | 399 else return 2; |
386 } | 400 } |
387 } | 401 } |
388 | 402 |
389 | 403 |