comparison motion_est.c @ 1162:8c15d82c1893 libavcodec

some static -> dynamic alloc & 16->8 bit
author michaelni
date Mon, 31 Mar 2003 11:13:14 +0000
parents 1e39f273ecd6
children fea03d2c4946
comparison
equal deleted inserted replaced
1161:556b5d0b5228 1162:8c15d82c1893
45 45
46 static inline int sad_hpel_motion_search(MpegEncContext * s, 46 static inline int sad_hpel_motion_search(MpegEncContext * s,
47 int *mx_ptr, int *my_ptr, int dmin, 47 int *mx_ptr, int *my_ptr, int dmin,
48 int xmin, int ymin, int xmax, int ymax, 48 int xmin, int ymin, int xmax, int ymax,
49 int pred_x, int pred_y, Picture *picture, 49 int pred_x, int pred_y, Picture *picture,
50 int n, int size, uint16_t * const mv_penalty); 50 int n, int size, uint8_t * const mv_penalty);
51 51
52 static inline int update_map_generation(MpegEncContext * s) 52 static inline int update_map_generation(MpegEncContext * s)
53 { 53 {
54 s->me.map_generation+= 1<<(ME_MAP_MV_BITS*2); 54 s->me.map_generation+= 1<<(ME_MAP_MV_BITS*2);
55 if(s->me.map_generation==0){ 55 if(s->me.map_generation==0){
655 655
656 static inline int sad_hpel_motion_search(MpegEncContext * s, 656 static inline int sad_hpel_motion_search(MpegEncContext * s,
657 int *mx_ptr, int *my_ptr, int dmin, 657 int *mx_ptr, int *my_ptr, int dmin,
658 int xmin, int ymin, int xmax, int ymax, 658 int xmin, int ymin, int xmax, int ymax,
659 int pred_x, int pred_y, Picture *picture, 659 int pred_x, int pred_y, Picture *picture,
660 int n, int size, uint16_t * const mv_penalty) 660 int n, int size, uint8_t * const mv_penalty)
661 { 661 {
662 uint8_t *ref_picture= picture->data[0]; 662 uint8_t *ref_picture= picture->data[0];
663 uint32_t *score_map= s->me.score_map; 663 uint32_t *score_map= s->me.score_map;
664 const int penalty_factor= s->me.sub_penalty_factor; 664 const int penalty_factor= s->me.sub_penalty_factor;
665 int mx, my, xx, yy, dminh; 665 int mx, my, xx, yy, dminh;
829 static inline int h263_mv4_search(MpegEncContext *s, int xmin, int ymin, int xmax, int ymax, int mx, int my, int shift) 829 static inline int h263_mv4_search(MpegEncContext *s, int xmin, int ymin, int xmax, int ymax, int mx, int my, int shift)
830 { 830 {
831 int block; 831 int block;
832 int P[10][2]; 832 int P[10][2];
833 int dmin_sum=0, mx4_sum=0, my4_sum=0; 833 int dmin_sum=0, mx4_sum=0, my4_sum=0;
834 uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; 834 uint8_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
835 835
836 for(block=0; block<4; block++){ 836 for(block=0; block<4; block++){
837 int mx4, my4; 837 int mx4, my4;
838 int pred_x4, pred_y4; 838 int pred_x4, pred_y4;
839 int dmin4; 839 int dmin4;
980 int P[10][2]; 980 int P[10][2];
981 const int shift= 1+s->quarter_sample; 981 const int shift= 1+s->quarter_sample;
982 int mb_type=0; 982 int mb_type=0;
983 uint8_t *ref_picture= s->last_picture.data[0]; 983 uint8_t *ref_picture= s->last_picture.data[0];
984 Picture * const pic= &s->current_picture; 984 Picture * const pic= &s->current_picture;
985 uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; 985 uint8_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
986 986
987 assert(s->quarter_sample==0 || s->quarter_sample==1); 987 assert(s->quarter_sample==0 || s->quarter_sample==1);
988 988
989 s->me.penalty_factor = get_penalty_factor(s, s->avctx->me_cmp); 989 s->me.penalty_factor = get_penalty_factor(s, s->avctx->me_cmp);
990 s->me.sub_penalty_factor= get_penalty_factor(s, s->avctx->me_sub_cmp); 990 s->me.sub_penalty_factor= get_penalty_factor(s, s->avctx->me_sub_cmp);
1149 int xmin, ymin, xmax, ymax; 1149 int xmin, ymin, xmax, ymax;
1150 int rel_xmin, rel_ymin, rel_xmax, rel_ymax; 1150 int rel_xmin, rel_ymin, rel_xmax, rel_ymax;
1151 int pred_x=0, pred_y=0; 1151 int pred_x=0, pred_y=0;
1152 int P[10][2]; 1152 int P[10][2];
1153 const int shift= 1+s->quarter_sample; 1153 const int shift= 1+s->quarter_sample;
1154 uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; 1154 uint8_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;
1155 const int mv_stride= s->mb_width + 2; 1155 const int mv_stride= s->mb_width + 2;
1156 const int xy= mb_x + 1 + (mb_y + 1)*mv_stride; 1156 const int xy= mb_x + 1 + (mb_y + 1)*mv_stride;
1157 1157
1158 assert(s->quarter_sample==0 || s->quarter_sample==1); 1158 assert(s->quarter_sample==0 || s->quarter_sample==1);
1159 1159
1211 int P[10][2]; 1211 int P[10][2];
1212 const int shift= 1+s->quarter_sample; 1212 const int shift= 1+s->quarter_sample;
1213 const int mot_stride = s->mb_width + 2; 1213 const int mot_stride = s->mb_width + 2;
1214 const int mot_xy = (mb_y + 1)*mot_stride + mb_x + 1; 1214 const int mot_xy = (mb_y + 1)*mot_stride + mb_x + 1;
1215 uint8_t * const ref_picture= picture->data[0]; 1215 uint8_t * const ref_picture= picture->data[0];
1216 uint16_t * const mv_penalty= s->me.mv_penalty[f_code] + MAX_MV; 1216 uint8_t * const mv_penalty= s->me.mv_penalty[f_code] + MAX_MV;
1217 int mv_scale; 1217 int mv_scale;
1218 1218
1219 s->me.penalty_factor = get_penalty_factor(s, s->avctx->me_cmp); 1219 s->me.penalty_factor = get_penalty_factor(s, s->avctx->me_cmp);
1220 s->me.sub_penalty_factor= get_penalty_factor(s, s->avctx->me_sub_cmp); 1220 s->me.sub_penalty_factor= get_penalty_factor(s, s->avctx->me_sub_cmp);
1221 s->me.mb_penalty_factor = get_penalty_factor(s, s->avctx->mb_cmp); 1221 s->me.mb_penalty_factor = get_penalty_factor(s, s->avctx->mb_cmp);
1308 int pred_bx, int pred_by) 1308 int pred_bx, int pred_by)
1309 { 1309 {
1310 //FIXME optimize? 1310 //FIXME optimize?
1311 //FIXME move into template? 1311 //FIXME move into template?
1312 //FIXME better f_code prediction (max mv & distance) 1312 //FIXME better f_code prediction (max mv & distance)
1313 uint16_t *mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame 1313 uint8_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame
1314 uint8_t *dest_y = s->me.scratchpad; 1314 uint8_t *dest_y = s->me.scratchpad;
1315 uint8_t *ptr; 1315 uint8_t *ptr;
1316 int dxy; 1316 int dxy;
1317 int src_x, src_y; 1317 int src_x, src_y;
1318 int fbmin; 1318 int fbmin;
1403 int dmin, i; 1403 int dmin, i;
1404 const int time_pp= s->pp_time; 1404 const int time_pp= s->pp_time;
1405 const int time_pb= s->pb_time; 1405 const int time_pb= s->pb_time;
1406 int mx, my, xmin, xmax, ymin, ymax; 1406 int mx, my, xmin, xmax, ymin, ymax;
1407 int16_t (*mv_table)[2]= s->b_direct_mv_table; 1407 int16_t (*mv_table)[2]= s->b_direct_mv_table;
1408 uint16_t * const mv_penalty= s->me.mv_penalty[1] + MAX_MV; 1408 uint8_t * const mv_penalty= s->me.mv_penalty[1] + MAX_MV;
1409 1409
1410 ymin= xmin=(-32)>>shift; 1410 ymin= xmin=(-32)>>shift;
1411 ymax= xmax= 31>>shift; 1411 ymax= xmax= 31>>shift;
1412 1412
1413 if(s->co_located_type_table[mb_x + mb_y*s->mb_width]==CO_LOCATED_TYPE_4MV){ 1413 if(s->co_located_type_table[mb_x + mb_y*s->mb_width]==CO_LOCATED_TYPE_4MV){