Mercurial > libavcodec.hg
comparison motion_est.c @ 7230:6aa2f54e6c98 libavcodec
Remove ancient code that hasnt worked in many years.
author | michael |
---|---|
date | Wed, 09 Jul 2008 19:21:08 +0000 |
parents | 167bd4bec8d1 |
children | 72d421816e07 |
comparison
equal
deleted
inserted
replaced
7229:f03d29b6fefe | 7230:6aa2f54e6c98 |
---|---|
336 { | 336 { |
337 *mx_ptr = 16 * s->mb_x; | 337 *mx_ptr = 16 * s->mb_x; |
338 *my_ptr = 16 * s->mb_y; | 338 *my_ptr = 16 * s->mb_y; |
339 } | 339 } |
340 | 340 |
341 #if 0 /* the use of these functions is inside #if 0 */ | |
342 static int full_motion_search(MpegEncContext * s, | |
343 int *mx_ptr, int *my_ptr, int range, | |
344 int xmin, int ymin, int xmax, int ymax, uint8_t *ref_picture) | |
345 { | |
346 int x1, y1, x2, y2, xx, yy, x, y; | |
347 int mx, my, dmin, d; | |
348 uint8_t *pix; | |
349 | |
350 xx = 16 * s->mb_x; | |
351 yy = 16 * s->mb_y; | |
352 x1 = xx - range + 1; /* we loose one pixel to avoid boundary pb with half pixel pred */ | |
353 if (x1 < xmin) | |
354 x1 = xmin; | |
355 x2 = xx + range - 1; | |
356 if (x2 > xmax) | |
357 x2 = xmax; | |
358 y1 = yy - range + 1; | |
359 if (y1 < ymin) | |
360 y1 = ymin; | |
361 y2 = yy + range - 1; | |
362 if (y2 > ymax) | |
363 y2 = ymax; | |
364 pix = s->new_picture.data[0] + (yy * s->linesize) + xx; | |
365 dmin = 0x7fffffff; | |
366 mx = 0; | |
367 my = 0; | |
368 for (y = y1; y <= y2; y++) { | |
369 for (x = x1; x <= x2; x++) { | |
370 d = s->dsp.pix_abs[0][0](NULL, pix, ref_picture + (y * s->linesize) + x, | |
371 s->linesize, 16); | |
372 if (d < dmin || | |
373 (d == dmin && | |
374 (abs(x - xx) + abs(y - yy)) < | |
375 (abs(mx - xx) + abs(my - yy)))) { | |
376 dmin = d; | |
377 mx = x; | |
378 my = y; | |
379 } | |
380 } | |
381 } | |
382 | |
383 *mx_ptr = mx; | |
384 *my_ptr = my; | |
385 | |
386 #if 0 | |
387 if (*mx_ptr < -(2 * range) || *mx_ptr >= (2 * range) || | |
388 *my_ptr < -(2 * range) || *my_ptr >= (2 * range)) { | |
389 av_log(NULL, AV_LOG_ERROR, "error %d %d\n", *mx_ptr, *my_ptr); | |
390 } | |
391 #endif | |
392 return dmin; | |
393 } | |
394 | |
395 | |
396 static int log_motion_search(MpegEncContext * s, | |
397 int *mx_ptr, int *my_ptr, int range, | |
398 int xmin, int ymin, int xmax, int ymax, uint8_t *ref_picture) | |
399 { | |
400 int x1, y1, x2, y2, xx, yy, x, y; | |
401 int mx, my, dmin, d; | |
402 uint8_t *pix; | |
403 | |
404 xx = s->mb_x << 4; | |
405 yy = s->mb_y << 4; | |
406 | |
407 /* Left limit */ | |
408 x1 = xx - range; | |
409 if (x1 < xmin) | |
410 x1 = xmin; | |
411 | |
412 /* Right limit */ | |
413 x2 = xx + range; | |
414 if (x2 > xmax) | |
415 x2 = xmax; | |
416 | |
417 /* Upper limit */ | |
418 y1 = yy - range; | |
419 if (y1 < ymin) | |
420 y1 = ymin; | |
421 | |
422 /* Lower limit */ | |
423 y2 = yy + range; | |
424 if (y2 > ymax) | |
425 y2 = ymax; | |
426 | |
427 pix = s->new_picture.data[0] + (yy * s->linesize) + xx; | |
428 dmin = 0x7fffffff; | |
429 mx = 0; | |
430 my = 0; | |
431 | |
432 do { | |
433 for (y = y1; y <= y2; y += range) { | |
434 for (x = x1; x <= x2; x += range) { | |
435 d = s->dsp.pix_abs[0][0](NULL, pix, ref_picture + (y * s->linesize) + x, s->linesize, 16); | |
436 if (d < dmin || (d == dmin && (abs(x - xx) + abs(y - yy)) < (abs(mx - xx) + abs(my - yy)))) { | |
437 dmin = d; | |
438 mx = x; | |
439 my = y; | |
440 } | |
441 } | |
442 } | |
443 | |
444 range = range >> 1; | |
445 | |
446 x1 = mx - range; | |
447 if (x1 < xmin) | |
448 x1 = xmin; | |
449 | |
450 x2 = mx + range; | |
451 if (x2 > xmax) | |
452 x2 = xmax; | |
453 | |
454 y1 = my - range; | |
455 if (y1 < ymin) | |
456 y1 = ymin; | |
457 | |
458 y2 = my + range; | |
459 if (y2 > ymax) | |
460 y2 = ymax; | |
461 | |
462 } while (range >= 1); | |
463 | |
464 #ifdef DEBUG | |
465 av_log(s->avctx, AV_LOG_DEBUG, "log - MX: %d\tMY: %d\n", mx, my); | |
466 #endif | |
467 *mx_ptr = mx; | |
468 *my_ptr = my; | |
469 return dmin; | |
470 } | |
471 | |
472 static int phods_motion_search(MpegEncContext * s, | |
473 int *mx_ptr, int *my_ptr, int range, | |
474 int xmin, int ymin, int xmax, int ymax, uint8_t *ref_picture) | |
475 { | |
476 int x1, y1, x2, y2, xx, yy, x, y, lastx, d; | |
477 int mx, my, dminx, dminy; | |
478 uint8_t *pix; | |
479 | |
480 xx = s->mb_x << 4; | |
481 yy = s->mb_y << 4; | |
482 | |
483 /* Left limit */ | |
484 x1 = xx - range; | |
485 if (x1 < xmin) | |
486 x1 = xmin; | |
487 | |
488 /* Right limit */ | |
489 x2 = xx + range; | |
490 if (x2 > xmax) | |
491 x2 = xmax; | |
492 | |
493 /* Upper limit */ | |
494 y1 = yy - range; | |
495 if (y1 < ymin) | |
496 y1 = ymin; | |
497 | |
498 /* Lower limit */ | |
499 y2 = yy + range; | |
500 if (y2 > ymax) | |
501 y2 = ymax; | |
502 | |
503 pix = s->new_picture.data[0] + (yy * s->linesize) + xx; | |
504 mx = 0; | |
505 my = 0; | |
506 | |
507 x = xx; | |
508 y = yy; | |
509 do { | |
510 dminx = 0x7fffffff; | |
511 dminy = 0x7fffffff; | |
512 | |
513 lastx = x; | |
514 for (x = x1; x <= x2; x += range) { | |
515 d = s->dsp.pix_abs[0][0](NULL, pix, ref_picture + (y * s->linesize) + x, s->linesize, 16); | |
516 if (d < dminx || (d == dminx && (abs(x - xx) + abs(y - yy)) < (abs(mx - xx) + abs(my - yy)))) { | |
517 dminx = d; | |
518 mx = x; | |
519 } | |
520 } | |
521 | |
522 x = lastx; | |
523 for (y = y1; y <= y2; y += range) { | |
524 d = s->dsp.pix_abs[0][0](NULL, pix, ref_picture + (y * s->linesize) + x, s->linesize, 16); | |
525 if (d < dminy || (d == dminy && (abs(x - xx) + abs(y - yy)) < (abs(mx - xx) + abs(my - yy)))) { | |
526 dminy = d; | |
527 my = y; | |
528 } | |
529 } | |
530 | |
531 range = range >> 1; | |
532 | |
533 x = mx; | |
534 y = my; | |
535 x1 = mx - range; | |
536 if (x1 < xmin) | |
537 x1 = xmin; | |
538 | |
539 x2 = mx + range; | |
540 if (x2 > xmax) | |
541 x2 = xmax; | |
542 | |
543 y1 = my - range; | |
544 if (y1 < ymin) | |
545 y1 = ymin; | |
546 | |
547 y2 = my + range; | |
548 if (y2 > ymax) | |
549 y2 = ymax; | |
550 | |
551 } while (range >= 1); | |
552 | |
553 #ifdef DEBUG | |
554 av_log(s->avctx, AV_LOG_DEBUG, "phods - MX: %d\tMY: %d\n", mx, my); | |
555 #endif | |
556 | |
557 /* half pixel search */ | |
558 *mx_ptr = mx; | |
559 *my_ptr = my; | |
560 return dminy; | |
561 } | |
562 #endif /* 0 */ | |
563 | |
564 #define Z_THRESHOLD 256 | 341 #define Z_THRESHOLD 256 |
565 | 342 |
566 #define CHECK_SAD_HALF_MV(suffix, x, y) \ | 343 #define CHECK_SAD_HALF_MV(suffix, x, y) \ |
567 {\ | 344 {\ |
568 d= s->dsp.pix_abs[size][(x?1:0)+(y?2:0)](NULL, pix, ptr+((x)>>1), stride, h);\ | 345 d= s->dsp.pix_abs[size][(x?1:0)+(y?2:0)](NULL, pix, ptr+((x)>>1), stride, h);\ |
1223 no_motion_search(s, &mx, &my); | 1000 no_motion_search(s, &mx, &my); |
1224 mx-= mb_x*16; | 1001 mx-= mb_x*16; |
1225 my-= mb_y*16; | 1002 my-= mb_y*16; |
1226 dmin = 0; | 1003 dmin = 0; |
1227 break; | 1004 break; |
1228 #if 0 | |
1229 case ME_FULL: | |
1230 dmin = full_motion_search(s, &mx, &my, range, ref_picture); | |
1231 mx-= mb_x*16; | |
1232 my-= mb_y*16; | |
1233 break; | |
1234 case ME_LOG: | |
1235 dmin = log_motion_search(s, &mx, &my, range / 2, ref_picture); | |
1236 mx-= mb_x*16; | |
1237 my-= mb_y*16; | |
1238 break; | |
1239 case ME_PHODS: | |
1240 dmin = phods_motion_search(s, &mx, &my, range / 2, ref_picture); | |
1241 mx-= mb_x*16; | |
1242 my-= mb_y*16; | |
1243 break; | |
1244 #endif | |
1245 case ME_X1: | 1005 case ME_X1: |
1246 case ME_EPZS: | 1006 case ME_EPZS: |
1247 { | 1007 { |
1248 const int mot_stride = s->b8_stride; | 1008 const int mot_stride = s->b8_stride; |
1249 const int mot_xy = s->block_index[0]; | 1009 const int mot_xy = s->block_index[0]; |
1511 no_motion_search(s, &mx, &my); | 1271 no_motion_search(s, &mx, &my); |
1512 dmin = 0; | 1272 dmin = 0; |
1513 mx-= mb_x*16; | 1273 mx-= mb_x*16; |
1514 my-= mb_y*16; | 1274 my-= mb_y*16; |
1515 break; | 1275 break; |
1516 #if 0 | |
1517 case ME_FULL: | |
1518 dmin = full_motion_search(s, &mx, &my, range, ref_picture); | |
1519 mx-= mb_x*16; | |
1520 my-= mb_y*16; | |
1521 break; | |
1522 case ME_LOG: | |
1523 dmin = log_motion_search(s, &mx, &my, range / 2, ref_picture); | |
1524 mx-= mb_x*16; | |
1525 my-= mb_y*16; | |
1526 break; | |
1527 case ME_PHODS: | |
1528 dmin = phods_motion_search(s, &mx, &my, range / 2, ref_picture); | |
1529 mx-= mb_x*16; | |
1530 my-= mb_y*16; | |
1531 break; | |
1532 #endif | |
1533 case ME_X1: | 1276 case ME_X1: |
1534 case ME_EPZS: | 1277 case ME_EPZS: |
1535 { | 1278 { |
1536 P_LEFT[0] = mv_table[mot_xy - 1][0]; | 1279 P_LEFT[0] = mv_table[mot_xy - 1][0]; |
1537 P_LEFT[1] = mv_table[mot_xy - 1][1]; | 1280 P_LEFT[1] = mv_table[mot_xy - 1][1]; |