Mercurial > libavcodec.hg
comparison motion_est.c @ 1422:efeed6e29f9b libavcodec
oooooops, having 2 Eterms open and doing cvs diff in one and cvs commit in the other sucks, especially if they are in different directories (MPlayer/main/libavcodec vs. ffmpeg/libavcodec)
author | michaelni |
---|---|
date | Mon, 25 Aug 2003 22:54:53 +0000 |
parents | 340c90faa1dc |
children | b0f89a7855aa |
comparison
equal
deleted
inserted
replaced
1421:340c90faa1dc | 1422:efeed6e29f9b |
---|---|
30 #include <stdio.h> | 30 #include <stdio.h> |
31 #include "avcodec.h" | 31 #include "avcodec.h" |
32 #include "dsputil.h" | 32 #include "dsputil.h" |
33 #include "mpegvideo.h" | 33 #include "mpegvideo.h" |
34 | 34 |
35 #undef NDEBUG | 35 //#undef NDEBUG |
36 #include <assert.h> | 36 //#include <assert.h> |
37 | 37 |
38 #define SQ(a) ((a)*(a)) | 38 #define SQ(a) ((a)*(a)) |
39 | 39 |
40 #define P_LEFT P[1] | 40 #define P_LEFT P[1] |
41 #define P_TOP P[2] | 41 #define P_TOP P[2] |
1672 } | 1672 } |
1673 xy++; | 1673 xy++; |
1674 } | 1674 } |
1675 } | 1675 } |
1676 } | 1676 } |
1677 #if 0 | |
1678 /** | |
1679 * estimates global motion and inits sprite_ref | |
1680 */ | |
1681 void ff_estimate_global_motion(MpegEncContext *s, int sprite_ref[3][2]){ | |
1682 int y; | |
1683 int num= 16<<s->f_code; | |
1684 int score[2][num]; | |
1685 int best_i[2]={0,0}; | |
1686 int best_score[2]={0,0}; | |
1687 | |
1688 memset(score, 0, 2*num*sizeof(int)); | |
1689 | |
1690 for(y=0; y<s->mb_height; y++){ | |
1691 int x; | |
1692 int xy= (y+1)* (s->mb_width+2)+1; | |
1693 int i= y*s->mb_width; | |
1694 for(x=0; x<s->mb_width; x++){ | |
1695 int mv[2]; | |
1696 | |
1697 if(!(s->mb_type[i]&MB_TYPE_INTER)) | |
1698 continue; | |
1699 | |
1700 mv[0]= s->p_mv_table[xy][0]; | |
1701 mv[1]= s->p_mv_table[xy][1]; | |
1702 | |
1703 if(mv[0]==0 && mv[1]==0) continue; | |
1704 | |
1705 score[0][mv[0] + num/2]++; | |
1706 score[1][mv[1] + num/2]++; | |
1707 } | |
1708 } | |
1709 | |
1710 for(n=0; n<2; n++){ | |
1711 for(i=1; i<num-1; i++){ | |
1712 int s= score[n][i-1] + score[n][i]*2 + score[n][i+1]; | |
1713 | |
1714 if(s > best_score[n]){ | |
1715 best_score[n]= s; | |
1716 best_i[n]= i; | |
1717 } | |
1718 } | |
1719 } | |
1720 | |
1721 sprite_ref[0][0]= best_i[0] - num/2; | |
1722 sprite_ref[0][1]= best_i[1] - num/2; | |
1723 | |
1724 // decide block type | |
1725 } | |
1726 #endif |