Mercurial > libavcodec.hg
comparison motion_est_template.c @ 1708:dea5b2946999 libavcodec
interlaced motion estimation
interlaced mpeg2 encoding
P & B frames
rate distored interlaced mb decission
alternate scantable support
4mv encoding fixes (thats also why the regression tests change)
passing height to most dsp functions
interlaced mpeg4 encoding (no direct mode MBs yet)
various related cleanups
disabled old motion estimaton algorithms (log, full, ...) they will either be fixed or removed
author | michael |
---|---|
date | Tue, 30 Dec 2003 16:07:57 +0000 |
parents | a7a9df478e46 |
children | 07a484280a82 |
comparison
equal
deleted
inserted
replaced
1707:027545a2fdbe | 1708:dea5b2946999 |
---|---|
20 | 20 |
21 /** | 21 /** |
22 * @file motion_est_template.c | 22 * @file motion_est_template.c |
23 * Motion estimation template. | 23 * Motion estimation template. |
24 */ | 24 */ |
25 | 25 //FIXME ref2_y next_pic? |
26 //lets hope gcc will remove the unused vars ...(gcc 3.2.2 seems to do it ...) | 26 //lets hope gcc will remove the unused vars ...(gcc 3.2.2 seems to do it ...) |
27 //Note, the last line is there to kill these ugly unused var warnings | 27 //Note, the last line is there to kill these ugly unused var warnings |
28 #define LOAD_COMMON(x, y)\ | 28 #define LOAD_COMMON\ |
29 uint32_t * const score_map= s->me.score_map;\ | 29 uint32_t * const score_map= s->me.score_map;\ |
30 const int stride= s->linesize;\ | |
31 const int uvstride= s->uvlinesize;\ | |
32 const int time_pp= s->pp_time;\ | 30 const int time_pp= s->pp_time;\ |
33 const int time_pb= s->pb_time;\ | 31 const int time_pb= s->pb_time;\ |
34 uint8_t * const src_y= s->new_picture.data[0] + ((y) * stride) + (x);\ | 32 const int xmin= s->me.xmin;\ |
35 uint8_t * const src_u= s->new_picture.data[1] + (((y)>>1) * uvstride) + ((x)>>1);\ | 33 const int ymin= s->me.ymin;\ |
36 uint8_t * const src_v= s->new_picture.data[2] + (((y)>>1) * uvstride) + ((x)>>1);\ | 34 const int xmax= s->me.xmax;\ |
37 uint8_t * const ref_y= ref_picture->data[0] + ((y) * stride) + (x);\ | 35 const int ymax= s->me.ymax;\ |
38 uint8_t * const ref_u= ref_picture->data[1] + (((y)>>1) * uvstride) + ((x)>>1);\ | 36 uint8_t * const src_y= src_data[0];\ |
39 uint8_t * const ref_v= ref_picture->data[2] + (((y)>>1) * uvstride) + ((x)>>1);\ | 37 uint8_t * const src_u= src_data[1];\ |
40 uint8_t * const ref2_y= s->next_picture.data[0] + ((y) * stride) + (x);\ | 38 uint8_t * const src_v= src_data[2];\ |
39 uint8_t * const ref_y= ref_data[0];\ | |
40 uint8_t * const ref_u= ref_data[1];\ | |
41 uint8_t * const ref_v= ref_data[2];\ | |
41 op_pixels_func (*hpel_put)[4];\ | 42 op_pixels_func (*hpel_put)[4];\ |
42 op_pixels_func (*hpel_avg)[4]= &s->dsp.avg_pixels_tab[size];\ | 43 op_pixels_func (*hpel_avg)[4]= &s->dsp.avg_pixels_tab[size];\ |
43 op_pixels_func (*chroma_hpel_put)[4];\ | 44 op_pixels_func (*chroma_hpel_put)[4];\ |
44 qpel_mc_func (*qpel_put)[16];\ | 45 qpel_mc_func (*qpel_put)[16];\ |
45 qpel_mc_func (*qpel_avg)[16]= &s->dsp.avg_qpel_pixels_tab[size];\ | 46 qpel_mc_func (*qpel_avg)[16]= &s->dsp.avg_qpel_pixels_tab[size];\ |
46 const __attribute__((unused)) int unu= time_pp + time_pb + (size_t)src_u + (size_t)src_v + (size_t)ref_u + (size_t)ref_v\ | 47 const __attribute__((unused)) int unu= time_pp + time_pb + (size_t)src_u + (size_t)src_v + (size_t)ref_u + (size_t)ref_v\ |
47 + (size_t)ref2_y + (size_t)hpel_avg + (size_t)qpel_avg + (size_t)score_map;\ | 48 + (size_t)hpel_avg + (size_t)qpel_avg + (size_t)score_map\ |
49 + xmin + xmax + ymin + ymax;\ | |
48 if(s->no_rounding /*FIXME b_type*/){\ | 50 if(s->no_rounding /*FIXME b_type*/){\ |
49 hpel_put= &s->dsp.put_no_rnd_pixels_tab[size];\ | 51 hpel_put= &s->dsp.put_no_rnd_pixels_tab[size];\ |
50 chroma_hpel_put= &s->dsp.put_no_rnd_pixels_tab[size+1];\ | 52 chroma_hpel_put= &s->dsp.put_no_rnd_pixels_tab[size+1];\ |
51 qpel_put= &s->dsp.put_no_rnd_qpel_pixels_tab[size];\ | 53 qpel_put= &s->dsp.put_no_rnd_qpel_pixels_tab[size];\ |
52 }else{\ | 54 }else{\ |
68 } | 70 } |
69 | 71 |
70 #if 0 | 72 #if 0 |
71 static int RENAME(hpel_motion_search)(MpegEncContext * s, | 73 static int RENAME(hpel_motion_search)(MpegEncContext * s, |
72 int *mx_ptr, int *my_ptr, int dmin, | 74 int *mx_ptr, int *my_ptr, int dmin, |
73 int xmin, int ymin, int xmax, int ymax, | 75 int pred_x, int pred_y, uint8_t *ref_data[3], |
74 int pred_x, int pred_y, Picture *ref_picture, | 76 int size, uint8_t * const mv_penalty) |
75 int n, int size, uint8_t * const mv_penalty) | |
76 { | 77 { |
77 const int xx = 16 * s->mb_x + 8*(n&1); | 78 const int xx = 16 * s->mb_x + 8*(n&1); |
78 const int yy = 16 * s->mb_y + 8*(n>>1); | 79 const int yy = 16 * s->mb_y + 8*(n>>1); |
79 const int mx = *mx_ptr; | 80 const int mx = *mx_ptr; |
80 const int my = *my_ptr; | 81 const int my = *my_ptr; |
81 const int penalty_factor= s->me.sub_penalty_factor; | 82 const int penalty_factor= s->me.sub_penalty_factor; |
82 | 83 |
83 LOAD_COMMON(xx, yy); | 84 LOAD_COMMON |
84 | 85 |
85 // INIT; | 86 // INIT; |
86 //FIXME factorize | 87 //FIXME factorize |
87 me_cmp_func cmp, chroma_cmp, cmp_sub, chroma_cmp_sub; | 88 me_cmp_func cmp, chroma_cmp, cmp_sub, chroma_cmp_sub; |
88 | 89 |
137 } | 138 } |
138 | 139 |
139 #else | 140 #else |
140 static int RENAME(hpel_motion_search)(MpegEncContext * s, | 141 static int RENAME(hpel_motion_search)(MpegEncContext * s, |
141 int *mx_ptr, int *my_ptr, int dmin, | 142 int *mx_ptr, int *my_ptr, int dmin, |
142 int xmin, int ymin, int xmax, int ymax, | 143 int pred_x, int pred_y, uint8_t *src_data[3], |
143 int pred_x, int pred_y, Picture *ref_picture, | 144 uint8_t *ref_data[3], int stride, int uvstride, |
144 int n, int size, uint8_t * const mv_penalty) | 145 int size, int h, uint8_t * const mv_penalty) |
145 { | 146 { |
146 const int xx = 16 * s->mb_x + 8*(n&1); | |
147 const int yy = 16 * s->mb_y + 8*(n>>1); | |
148 const int mx = *mx_ptr; | 147 const int mx = *mx_ptr; |
149 const int my = *my_ptr; | 148 const int my = *my_ptr; |
150 const int penalty_factor= s->me.sub_penalty_factor; | 149 const int penalty_factor= s->me.sub_penalty_factor; |
151 me_cmp_func cmp_sub, chroma_cmp_sub; | 150 me_cmp_func cmp_sub, chroma_cmp_sub; |
152 int bx=2*mx, by=2*my; | 151 int bx=2*mx, by=2*my; |
153 | 152 |
154 LOAD_COMMON(xx, yy); | 153 LOAD_COMMON |
155 | 154 |
156 //FIXME factorize | 155 //FIXME factorize |
157 | 156 |
158 cmp_sub= s->dsp.me_sub_cmp[size]; | 157 cmp_sub= s->dsp.me_sub_cmp[size]; |
159 chroma_cmp_sub= s->dsp.me_sub_cmp[size+1]; | 158 chroma_cmp_sub= s->dsp.me_sub_cmp[size+1]; |
245 | 244 |
246 return dmin; | 245 return dmin; |
247 } | 246 } |
248 #endif | 247 #endif |
249 | 248 |
250 static int RENAME(hpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pred_x, int pred_y, Picture *ref_picture, | 249 static int RENAME(hpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pred_x, int pred_y, uint8_t *src_data[3], |
250 uint8_t *ref_data[3], int stride, int uvstride, | |
251 uint8_t * const mv_penalty) | 251 uint8_t * const mv_penalty) |
252 { | 252 { |
253 // const int check_luma= s->dsp.me_sub_cmp != s->dsp.mb_cmp; | 253 // const int check_luma= s->dsp.me_sub_cmp != s->dsp.mb_cmp; |
254 const int size= 0; | 254 const int size= 0; |
255 const int xx = 16 * s->mb_x; | 255 const int h= 16; |
256 const int yy = 16 * s->mb_y; | |
257 const int penalty_factor= s->me.mb_penalty_factor; | 256 const int penalty_factor= s->me.mb_penalty_factor; |
258 const int xmin= -256*256, ymin= -256*256, xmax= 256*256, ymax= 256*256; //assume that the caller checked these | |
259 const __attribute__((unused)) int unu2= xmin + xmax +ymin + ymax; //no unused warning shit | |
260 me_cmp_func cmp_sub, chroma_cmp_sub; | 257 me_cmp_func cmp_sub, chroma_cmp_sub; |
261 int d; | 258 int d; |
262 | 259 |
263 LOAD_COMMON(xx, yy); | 260 LOAD_COMMON |
264 | 261 |
265 //FIXME factorize | 262 //FIXME factorize |
266 | 263 |
267 cmp_sub= s->dsp.mb_cmp[size]; | 264 cmp_sub= s->dsp.mb_cmp[size]; |
268 chroma_cmp_sub= s->dsp.mb_cmp[size+1]; | 265 chroma_cmp_sub= s->dsp.mb_cmp[size+1]; |
293 COPY3_IF_LT(dmin, d, bx, hx, by, hy)\ | 290 COPY3_IF_LT(dmin, d, bx, hx, by, hy)\ |
294 } | 291 } |
295 | 292 |
296 static int RENAME(qpel_motion_search)(MpegEncContext * s, | 293 static int RENAME(qpel_motion_search)(MpegEncContext * s, |
297 int *mx_ptr, int *my_ptr, int dmin, | 294 int *mx_ptr, int *my_ptr, int dmin, |
298 int xmin, int ymin, int xmax, int ymax, | 295 int pred_x, int pred_y, uint8_t *src_data[3], |
299 int pred_x, int pred_y, Picture *ref_picture, | 296 uint8_t *ref_data[3], int stride, int uvstride, |
300 int n, int size, uint8_t * const mv_penalty) | 297 int size, int h, uint8_t * const mv_penalty) |
301 { | 298 { |
302 const int xx = 16 * s->mb_x + 8*(n&1); | |
303 const int yy = 16 * s->mb_y + 8*(n>>1); | |
304 const int mx = *mx_ptr; | 299 const int mx = *mx_ptr; |
305 const int my = *my_ptr; | 300 const int my = *my_ptr; |
306 const int penalty_factor= s->me.sub_penalty_factor; | 301 const int penalty_factor= s->me.sub_penalty_factor; |
307 const int map_generation= s->me.map_generation; | 302 const int map_generation= s->me.map_generation; |
308 const int subpel_quality= s->avctx->me_subpel_quality; | 303 const int subpel_quality= s->avctx->me_subpel_quality; |
309 uint32_t *map= s->me.map; | 304 uint32_t *map= s->me.map; |
310 me_cmp_func cmp, chroma_cmp; | 305 me_cmp_func cmp, chroma_cmp; |
311 me_cmp_func cmp_sub, chroma_cmp_sub; | 306 me_cmp_func cmp_sub, chroma_cmp_sub; |
312 | 307 |
313 LOAD_COMMON(xx, yy); | 308 LOAD_COMMON |
314 | 309 |
315 cmp= s->dsp.me_cmp[size]; | 310 cmp= s->dsp.me_cmp[size]; |
316 chroma_cmp= s->dsp.me_cmp[size+1]; //factorize FIXME | 311 chroma_cmp= s->dsp.me_cmp[size+1]; //factorize FIXME |
317 //FIXME factorize | 312 //FIXME factorize |
318 | 313 |
512 } | 507 } |
513 | 508 |
514 return dmin; | 509 return dmin; |
515 } | 510 } |
516 | 511 |
517 static int RENAME(qpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pred_x, int pred_y, Picture *ref_picture, | 512 static int RENAME(qpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pred_x, int pred_y, uint8_t *src_data[3], |
513 uint8_t *ref_data[3], int stride, int uvstride, | |
518 uint8_t * const mv_penalty) | 514 uint8_t * const mv_penalty) |
519 { | 515 { |
520 const int size= 0; | 516 const int size= 0; |
521 const int xx = 16 * s->mb_x; | 517 const int h= 16; |
522 const int yy = 16 * s->mb_y; | |
523 const int penalty_factor= s->me.mb_penalty_factor; | 518 const int penalty_factor= s->me.mb_penalty_factor; |
524 const int xmin= -256*256, ymin= -256*256, xmax= 256*256, ymax= 256*256; //assume that the caller checked these | |
525 const __attribute__((unused)) int unu2= xmin + xmax +ymin + ymax; //no unused warning shit | |
526 me_cmp_func cmp_sub, chroma_cmp_sub; | 519 me_cmp_func cmp_sub, chroma_cmp_sub; |
527 int d; | 520 int d; |
528 | 521 |
529 LOAD_COMMON(xx, yy); | 522 LOAD_COMMON |
530 | 523 |
531 //FIXME factorize | 524 //FIXME factorize |
532 | 525 |
533 cmp_sub= s->dsp.mb_cmp[size]; | 526 cmp_sub= s->dsp.mb_cmp[size]; |
534 chroma_cmp_sub= s->dsp.mb_cmp[size+1]; | 527 chroma_cmp_sub= s->dsp.mb_cmp[size+1]; |
595 if( (y)<(ymin<<(S)) ) printf("%d %d %d %d %d ymin" #v, ymin, (x), (y), s->mb_x, s->mb_y);\ | 588 if( (y)<(ymin<<(S)) ) printf("%d %d %d %d %d ymin" #v, ymin, (x), (y), s->mb_x, s->mb_y);\ |
596 if( (y)>(ymax<<(S)) ) printf("%d %d %d %d %d ymax" #v, ymax, (x), (y), s->mb_x, s->mb_y);\ | 589 if( (y)>(ymax<<(S)) ) printf("%d %d %d %d %d ymax" #v, ymax, (x), (y), s->mb_x, s->mb_y);\ |
597 | 590 |
598 | 591 |
599 static inline int RENAME(small_diamond_search)(MpegEncContext * s, int *best, int dmin, | 592 static inline int RENAME(small_diamond_search)(MpegEncContext * s, int *best, int dmin, |
600 Picture *ref_picture, | 593 uint8_t *src_data[3], |
594 uint8_t *ref_data[3], int stride, int uvstride, | |
601 int const pred_x, int const pred_y, int const penalty_factor, | 595 int const pred_x, int const pred_y, int const penalty_factor, |
602 int const xmin, int const ymin, int const xmax, int const ymax, int const shift, | 596 int const shift, |
603 uint32_t *map, int map_generation, int size, uint8_t * const mv_penalty | 597 uint32_t *map, int map_generation, int size, int h, uint8_t * const mv_penalty |
604 ) | 598 ) |
605 { | 599 { |
606 me_cmp_func cmp, chroma_cmp; | 600 me_cmp_func cmp, chroma_cmp; |
607 int next_dir=-1; | 601 int next_dir=-1; |
608 LOAD_COMMON(s->mb_x*16, s->mb_y*16); | 602 LOAD_COMMON |
609 | 603 |
610 cmp= s->dsp.me_cmp[size]; | 604 cmp= s->dsp.me_cmp[size]; |
611 chroma_cmp= s->dsp.me_cmp[size+1]; | 605 chroma_cmp= s->dsp.me_cmp[size+1]; |
612 | 606 |
613 { /* ensure that the best point is in the MAP as h/qpel refinement needs it */ | 607 { /* ensure that the best point is in the MAP as h/qpel refinement needs it */ |
637 } | 631 } |
638 } | 632 } |
639 } | 633 } |
640 | 634 |
641 static inline int RENAME(funny_diamond_search)(MpegEncContext * s, int *best, int dmin, | 635 static inline int RENAME(funny_diamond_search)(MpegEncContext * s, int *best, int dmin, |
642 Picture *ref_picture, | 636 uint8_t *src_data[3], |
637 uint8_t *ref_data[3], int stride, int uvstride, | |
643 int const pred_x, int const pred_y, int const penalty_factor, | 638 int const pred_x, int const pred_y, int const penalty_factor, |
644 int const xmin, int const ymin, int const xmax, int const ymax, int const shift, | 639 int const shift, |
645 uint32_t *map, int map_generation, int size, uint8_t * const mv_penalty | 640 uint32_t *map, int map_generation, int size, int h, uint8_t * const mv_penalty |
646 ) | 641 ) |
647 { | 642 { |
648 me_cmp_func cmp, chroma_cmp; | 643 me_cmp_func cmp, chroma_cmp; |
649 int dia_size; | 644 int dia_size; |
650 LOAD_COMMON(s->mb_x*16, s->mb_y*16); | 645 LOAD_COMMON |
651 | 646 |
652 cmp= s->dsp.me_cmp[size]; | 647 cmp= s->dsp.me_cmp[size]; |
653 chroma_cmp= s->dsp.me_cmp[size+1]; | 648 chroma_cmp= s->dsp.me_cmp[size+1]; |
654 | 649 |
655 for(dia_size=1; dia_size<=4; dia_size++){ | 650 for(dia_size=1; dia_size<=4; dia_size++){ |
728 }\ | 723 }\ |
729 } | 724 } |
730 | 725 |
731 #define MAX_SAB_SIZE 16 | 726 #define MAX_SAB_SIZE 16 |
732 static inline int RENAME(sab_diamond_search)(MpegEncContext * s, int *best, int dmin, | 727 static inline int RENAME(sab_diamond_search)(MpegEncContext * s, int *best, int dmin, |
733 Picture *ref_picture, | 728 uint8_t *src_data[3], |
729 uint8_t *ref_data[3], int stride, int uvstride, | |
734 int const pred_x, int const pred_y, int const penalty_factor, | 730 int const pred_x, int const pred_y, int const penalty_factor, |
735 int const xmin, int const ymin, int const xmax, int const ymax, int const shift, | 731 int const shift, |
736 uint32_t *map, int map_generation, int size, uint8_t * const mv_penalty | 732 uint32_t *map, int map_generation, int size, int h, uint8_t * const mv_penalty |
737 ) | 733 ) |
738 { | 734 { |
739 me_cmp_func cmp, chroma_cmp; | 735 me_cmp_func cmp, chroma_cmp; |
740 Minima minima[MAX_SAB_SIZE]; | 736 Minima minima[MAX_SAB_SIZE]; |
741 const int minima_count= ABS(s->me.dia_size); | 737 const int minima_count= ABS(s->me.dia_size); |
742 int i, j; | 738 int i, j; |
743 LOAD_COMMON(s->mb_x*16, s->mb_y*16); | 739 LOAD_COMMON |
744 | 740 |
745 cmp= s->dsp.me_cmp[size]; | 741 cmp= s->dsp.me_cmp[size]; |
746 chroma_cmp= s->dsp.me_cmp[size+1]; | 742 chroma_cmp= s->dsp.me_cmp[size+1]; |
747 | 743 |
748 for(j=i=0; i<ME_MAP_SIZE; i++){ | 744 for(j=i=0; i<ME_MAP_SIZE; i++){ |
808 } | 804 } |
809 return dmin; | 805 return dmin; |
810 } | 806 } |
811 | 807 |
812 static inline int RENAME(var_diamond_search)(MpegEncContext * s, int *best, int dmin, | 808 static inline int RENAME(var_diamond_search)(MpegEncContext * s, int *best, int dmin, |
813 Picture *ref_picture, | 809 uint8_t *src_data[3], |
810 uint8_t *ref_data[3], int stride, int uvstride, | |
814 int const pred_x, int const pred_y, int const penalty_factor, | 811 int const pred_x, int const pred_y, int const penalty_factor, |
815 int const xmin, int const ymin, int const xmax, int const ymax, int const shift, | 812 int const shift, |
816 uint32_t *map, int map_generation, int size, uint8_t * const mv_penalty | 813 uint32_t *map, int map_generation, int size, int h, uint8_t * const mv_penalty |
817 ) | 814 ) |
818 { | 815 { |
819 me_cmp_func cmp, chroma_cmp; | 816 me_cmp_func cmp, chroma_cmp; |
820 int dia_size; | 817 int dia_size; |
821 LOAD_COMMON(s->mb_x*16, s->mb_y*16); | 818 LOAD_COMMON |
822 | 819 |
823 cmp= s->dsp.me_cmp[size]; | 820 cmp= s->dsp.me_cmp[size]; |
824 chroma_cmp= s->dsp.me_cmp[size+1]; | 821 chroma_cmp= s->dsp.me_cmp[size+1]; |
825 | 822 |
826 for(dia_size=1; dia_size<=s->me.dia_size; dia_size++){ | 823 for(dia_size=1; dia_size<=s->me.dia_size; dia_size++){ |
884 #endif | 881 #endif |
885 } | 882 } |
886 return dmin; | 883 return dmin; |
887 } | 884 } |
888 | 885 |
889 static int RENAME(epzs_motion_search)(MpegEncContext * s, int block, | 886 static int RENAME(epzs_motion_search)(MpegEncContext * s, |
890 int *mx_ptr, int *my_ptr, | 887 int *mx_ptr, int *my_ptr, |
891 int P[10][2], int pred_x, int pred_y, | 888 int P[10][2], int pred_x, int pred_y, uint8_t *src_data[3], |
892 int xmin, int ymin, int xmax, int ymax, Picture *ref_picture, int16_t (*last_mv)[2], | 889 uint8_t *ref_data[3], int stride, int uvstride, int16_t (*last_mv)[2], |
893 int ref_mv_scale, uint8_t * const mv_penalty) | 890 int ref_mv_scale, uint8_t * const mv_penalty) |
894 { | 891 { |
895 int best[2]={0, 0}; | 892 int best[2]={0, 0}; |
896 int d, dmin; | 893 int d, dmin; |
897 const int shift= 1+s->quarter_sample; | 894 const int shift= 1+s->quarter_sample; |
898 uint32_t *map= s->me.map; | 895 uint32_t *map= s->me.map; |
899 int map_generation; | 896 int map_generation; |
900 const int penalty_factor= s->me.penalty_factor; | 897 const int penalty_factor= s->me.penalty_factor; |
901 const int size=0; | 898 const int size=0; |
902 const int ref_mv_stride= s->mb_stride; | 899 const int h=16; |
903 const int ref_mv_xy= s->mb_x + s->mb_y*ref_mv_stride; | 900 const int ref_mv_stride= s->mb_stride; //pass as arg FIXME |
901 const int ref_mv_xy= s->mb_x + s->mb_y*ref_mv_stride; //add to last_mv beforepassing FIXME | |
904 me_cmp_func cmp, chroma_cmp; | 902 me_cmp_func cmp, chroma_cmp; |
905 LOAD_COMMON(s->mb_x*16, s->mb_y*16); | 903 LOAD_COMMON |
906 | 904 |
907 cmp= s->dsp.me_cmp[size]; | 905 cmp= s->dsp.me_cmp[size]; |
908 chroma_cmp= s->dsp.me_cmp[size+1]; | 906 chroma_cmp= s->dsp.me_cmp[size+1]; |
909 | 907 |
910 map_generation= update_map_generation(s); | 908 map_generation= update_map_generation(s); |
971 } | 969 } |
972 } | 970 } |
973 | 971 |
974 //check(best[0],best[1],0, b0) | 972 //check(best[0],best[1],0, b0) |
975 if(s->me.dia_size==-1) | 973 if(s->me.dia_size==-1) |
976 dmin= RENAME(funny_diamond_search)(s, best, dmin, ref_picture, | 974 dmin= RENAME(funny_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, |
977 pred_x, pred_y, penalty_factor, xmin, ymin, xmax, ymax, | 975 pred_x, pred_y, penalty_factor, |
978 shift, map, map_generation, size, mv_penalty); | 976 shift, map, map_generation, size, h, mv_penalty); |
979 else if(s->me.dia_size<-1) | 977 else if(s->me.dia_size<-1) |
980 dmin= RENAME(sab_diamond_search)(s, best, dmin, ref_picture, | 978 dmin= RENAME(sab_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, |
981 pred_x, pred_y, penalty_factor, xmin, ymin, xmax, ymax, | 979 pred_x, pred_y, penalty_factor, |
982 shift, map, map_generation, size, mv_penalty); | 980 shift, map, map_generation, size, h, mv_penalty); |
983 else if(s->me.dia_size<2) | 981 else if(s->me.dia_size<2) |
984 dmin= RENAME(small_diamond_search)(s, best, dmin, ref_picture, | 982 dmin= RENAME(small_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, |
985 pred_x, pred_y, penalty_factor, xmin, ymin, xmax, ymax, | 983 pred_x, pred_y, penalty_factor, |
986 shift, map, map_generation, size, mv_penalty); | 984 shift, map, map_generation, size, h, mv_penalty); |
987 else | 985 else |
988 dmin= RENAME(var_diamond_search)(s, best, dmin, ref_picture, | 986 dmin= RENAME(var_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, |
989 pred_x, pred_y, penalty_factor, xmin, ymin, xmax, ymax, | 987 pred_x, pred_y, penalty_factor, |
990 shift, map, map_generation, size, mv_penalty); | 988 shift, map, map_generation, size, h, mv_penalty); |
991 | 989 |
992 //check(best[0],best[1],0, b1) | 990 //check(best[0],best[1],0, b1) |
993 *mx_ptr= best[0]; | 991 *mx_ptr= best[0]; |
994 *my_ptr= best[1]; | 992 *my_ptr= best[1]; |
995 | 993 |
996 // printf("%d %d %d \n", best[0], best[1], dmin); | 994 // printf("%d %d %d \n", best[0], best[1], dmin); |
997 return dmin; | 995 return dmin; |
998 } | 996 } |
999 | 997 |
1000 #ifndef CMP_DIRECT /* no 4mv search needed in direct mode */ | 998 #ifndef CMP_DIRECT /* no 4mv search needed in direct mode */ |
1001 static int RENAME(epzs_motion_search4)(MpegEncContext * s, int block, | 999 static int RENAME(epzs_motion_search4)(MpegEncContext * s, |
1002 int *mx_ptr, int *my_ptr, | 1000 int *mx_ptr, int *my_ptr, |
1003 int P[10][2], int pred_x, int pred_y, | 1001 int P[10][2], int pred_x, int pred_y, |
1004 int xmin, int ymin, int xmax, int ymax, Picture *ref_picture, int16_t (*last_mv)[2], | 1002 uint8_t *src_data[3], |
1003 uint8_t *ref_data[3], int stride, int uvstride, int16_t (*last_mv)[2], | |
1005 int ref_mv_scale, uint8_t * const mv_penalty) | 1004 int ref_mv_scale, uint8_t * const mv_penalty) |
1006 { | 1005 { |
1007 int best[2]={0, 0}; | 1006 int best[2]={0, 0}; |
1008 int d, dmin; | 1007 int d, dmin; |
1009 const int shift= 1+s->quarter_sample; | 1008 const int shift= 1+s->quarter_sample; |
1010 uint32_t *map= s->me.map; | 1009 uint32_t *map= s->me.map; |
1011 int map_generation; | 1010 int map_generation; |
1012 const int penalty_factor= s->me.penalty_factor; | 1011 const int penalty_factor= s->me.penalty_factor; |
1013 const int size=1; | 1012 const int size=1; |
1013 const int h=8; | |
1014 const int ref_mv_stride= s->mb_stride; | 1014 const int ref_mv_stride= s->mb_stride; |
1015 const int ref_mv_xy= s->mb_x + s->mb_y *ref_mv_stride; | 1015 const int ref_mv_xy= s->mb_x + s->mb_y *ref_mv_stride; |
1016 me_cmp_func cmp, chroma_cmp; | 1016 me_cmp_func cmp, chroma_cmp; |
1017 LOAD_COMMON((s->mb_x*2 + (block&1))*8, (s->mb_y*2 + (block>>1))*8); | 1017 LOAD_COMMON |
1018 | 1018 |
1019 cmp= s->dsp.me_cmp[size]; | 1019 cmp= s->dsp.me_cmp[size]; |
1020 chroma_cmp= s->dsp.me_cmp[size+1]; | 1020 chroma_cmp= s->dsp.me_cmp[size+1]; |
1021 | 1021 |
1022 map_generation= update_map_generation(s); | 1022 map_generation= update_map_generation(s); |
1023 | 1023 |
1024 dmin = 1000000; | 1024 dmin = 1000000; |
1025 //printf("%d %d %d %d //",xmin, ymin, xmax, ymax); | 1025 //printf("%d %d %d %d //",xmin, ymin, xmax, ymax); |
1026 /* first line */ | 1026 /* first line */ |
1027 if (s->mb_y == 0 && block<2) { | 1027 if (s->mb_y == 0/* && block<2*/) { |
1028 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift) | 1028 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift) |
1029 CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, | 1029 CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, |
1030 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16) | 1030 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16) |
1031 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift) | 1031 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift) |
1032 }else{ | 1032 }else{ |
1047 CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, | 1047 CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, |
1048 (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16) | 1048 (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16) |
1049 } | 1049 } |
1050 | 1050 |
1051 if(s->me.dia_size==-1) | 1051 if(s->me.dia_size==-1) |
1052 dmin= RENAME(funny_diamond_search)(s, best, dmin, ref_picture, | 1052 dmin= RENAME(funny_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, |
1053 pred_x, pred_y, penalty_factor, xmin, ymin, xmax, ymax, | 1053 pred_x, pred_y, penalty_factor, |
1054 shift, map, map_generation, size, mv_penalty); | 1054 shift, map, map_generation, size, h, mv_penalty); |
1055 else if(s->me.dia_size<-1) | 1055 else if(s->me.dia_size<-1) |
1056 dmin= RENAME(sab_diamond_search)(s, best, dmin, ref_picture, | 1056 dmin= RENAME(sab_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, |
1057 pred_x, pred_y, penalty_factor, xmin, ymin, xmax, ymax, | 1057 pred_x, pred_y, penalty_factor, |
1058 shift, map, map_generation, size, mv_penalty); | 1058 shift, map, map_generation, size, h, mv_penalty); |
1059 else if(s->me.dia_size<2) | 1059 else if(s->me.dia_size<2) |
1060 dmin= RENAME(small_diamond_search)(s, best, dmin, ref_picture, | 1060 dmin= RENAME(small_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, |
1061 pred_x, pred_y, penalty_factor, xmin, ymin, xmax, ymax, | 1061 pred_x, pred_y, penalty_factor, |
1062 shift, map, map_generation, size, mv_penalty); | 1062 shift, map, map_generation, size, h, mv_penalty); |
1063 else | 1063 else |
1064 dmin= RENAME(var_diamond_search)(s, best, dmin, ref_picture, | 1064 dmin= RENAME(var_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, |
1065 pred_x, pred_y, penalty_factor, xmin, ymin, xmax, ymax, | 1065 pred_x, pred_y, penalty_factor, |
1066 shift, map, map_generation, size, mv_penalty); | 1066 shift, map, map_generation, size, h, mv_penalty); |
1067 | |
1067 | 1068 |
1068 *mx_ptr= best[0]; | 1069 *mx_ptr= best[0]; |
1069 *my_ptr= best[1]; | 1070 *my_ptr= best[1]; |
1070 | 1071 |
1071 // printf("%d %d %d \n", best[0], best[1], dmin); | 1072 // printf("%d %d %d \n", best[0], best[1], dmin); |
1072 return dmin; | 1073 return dmin; |
1073 } | 1074 } |
1075 | |
1076 //try to merge with above FIXME (needs PSNR test) | |
1077 static int RENAME(epzs_motion_search2)(MpegEncContext * s, | |
1078 int *mx_ptr, int *my_ptr, | |
1079 int P[10][2], int pred_x, int pred_y, | |
1080 uint8_t *src_data[3], | |
1081 uint8_t *ref_data[3], int stride, int uvstride, int16_t (*last_mv)[2], | |
1082 int ref_mv_scale, uint8_t * const mv_penalty) | |
1083 { | |
1084 int best[2]={0, 0}; | |
1085 int d, dmin; | |
1086 const int shift= 1+s->quarter_sample; | |
1087 uint32_t *map= s->me.map; | |
1088 int map_generation; | |
1089 const int penalty_factor= s->me.penalty_factor; | |
1090 const int size=0; //FIXME pass as arg | |
1091 const int h=8; | |
1092 const int ref_mv_stride= s->mb_stride; | |
1093 const int ref_mv_xy= s->mb_x + s->mb_y *ref_mv_stride; | |
1094 me_cmp_func cmp, chroma_cmp; | |
1095 LOAD_COMMON | |
1096 | |
1097 cmp= s->dsp.me_cmp[size]; | |
1098 chroma_cmp= s->dsp.me_cmp[size+1]; | |
1099 | |
1100 map_generation= update_map_generation(s); | |
1101 | |
1102 dmin = 1000000; | |
1103 //printf("%d %d %d %d //",xmin, ymin, xmax, ymax); | |
1104 /* first line */ | |
1105 if (s->mb_y == 0) { | |
1106 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift) | |
1107 CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, | |
1108 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16) | |
1109 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift) | |
1110 }else{ | |
1111 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift) | |
1112 //FIXME try some early stop | |
1113 if(dmin>64*2){ | |
1114 CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift) | |
1115 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift) | |
1116 CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift) | |
1117 CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift) | |
1118 CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, | |
1119 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16) | |
1120 } | |
1121 } | |
1122 if(dmin>64*4){ | |
1123 CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16, | |
1124 (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16) | |
1125 CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, | |
1126 (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16) | |
1127 } | |
1128 | |
1129 if(s->me.dia_size==-1) | |
1130 dmin= RENAME(funny_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, | |
1131 pred_x, pred_y, penalty_factor, | |
1132 shift, map, map_generation, size, h, mv_penalty); | |
1133 else if(s->me.dia_size<-1) | |
1134 dmin= RENAME(sab_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, | |
1135 pred_x, pred_y, penalty_factor, | |
1136 shift, map, map_generation, size, h, mv_penalty); | |
1137 else if(s->me.dia_size<2) | |
1138 dmin= RENAME(small_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, | |
1139 pred_x, pred_y, penalty_factor, | |
1140 shift, map, map_generation, size, h, mv_penalty); | |
1141 else | |
1142 dmin= RENAME(var_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride, | |
1143 pred_x, pred_y, penalty_factor, | |
1144 shift, map, map_generation, size, h, mv_penalty); | |
1145 | |
1146 | |
1147 *mx_ptr= best[0]; | |
1148 *my_ptr= best[1]; | |
1149 | |
1150 // printf("%d %d %d \n", best[0], best[1], dmin); | |
1151 return dmin; | |
1152 } | |
1074 #endif /* !CMP_DIRECT */ | 1153 #endif /* !CMP_DIRECT */ |