43 #define P_TOPRIGHT P[3]
47 #define ME_MAP_SHIFT 3
48 #define ME_MAP_MV_BITS 11
51 int *mx_ptr,
int *my_ptr,
int dmin,
52 int src_index,
int ref_index,
58 if(
c->map_generation==0){
62 return c->map_generation;
86 ((y*
c->uvstride + x)>>1),
87 ((y*
c->uvstride + x)>>1),
108 const int size,
const int h,
int ref_index,
int src_index,
112 const int hx = subx + x * (1 << (1 + qpel));
113 const int hy = suby + y * (1 << (1 + qpel));
118 av_assert2(x >=
c->xmin && hx <= c->xmax<<(qpel+1) && y >=
c->ymin && hy <= c->ymax<<(qpel+1));
119 if(x >=
c->xmin && hx <= c->xmax<<(qpel+1) && y >=
c->ymin && hy <= c->ymax<<(qpel+1)){
120 const int time_pp=
s->pp_time;
121 const int time_pb=
s->pb_time;
122 const int mask= 2*qpel+1;
126 int fx =
c->direct_basis_mv[
i][0] + hx;
127 int fy =
c->direct_basis_mv[
i][1] + hy;
128 int bx = hx ? fx -
c->co_located_mv[
i][0] :
c->co_located_mv[
i][0]*(time_pb - time_pp)/time_pp + ((
i &1)<<(qpel+4));
129 int by = hy ? fy -
c->co_located_mv[
i][1] :
c->co_located_mv[
i][1]*(time_pb - time_pp)/time_pp + ((
i>>1)<<(qpel+4));
130 int fxy= (fx&
mask) + ((fy&
mask)<<(qpel+1));
131 int bxy= (bx&
mask) + ((by&
mask)<<(qpel+1));
143 int fx =
c->direct_basis_mv[0][0] + hx;
144 int fy =
c->direct_basis_mv[0][1] + hy;
145 int bx = hx ? fx -
c->co_located_mv[0][0] : (
c->co_located_mv[0][0]*(time_pb - time_pp)/time_pp);
146 int by = hy ? fy -
c->co_located_mv[0][1] : (
c->co_located_mv[0][1]*(time_pb - time_pp)/time_pp);
147 int fxy= (fx&
mask) + ((fy&
mask)<<(qpel+1));
148 int bxy= (bx&
mask) + ((by&
mask)<<(qpel+1));
152 c->qpel_put[1][fxy](
c->temp + 8 ,
ref[0] + (fx>>2) + (fy>>2)*
stride + 8 ,
stride);
156 c->qpel_avg[1][bxy](
c->temp + 8 ,
ref[8] + (bx>>2) + (by>>2)*
stride + 8 ,
stride);
180 const int size,
const int h,
int ref_index,
int src_index,
184 const int uvstride=
c->uvstride;
185 const int dxy= subx + (suby<<(1+qpel));
186 const int hx= subx + x*(1<<(1+qpel));
187 const int hy= suby + y*(1<<(1+qpel));
195 if (
h <<
size == 16) {
197 }
else if (
size == 0 &&
h == 8) {
207 uvdxy= (cx&1) + 2*(cy&1);
213 uvdxy= dxy | (x&1) | (2*(y&1));
219 uvdxy= (x&1) + 2*(y&1);
223 c->hpel_put[
size+1][uvdxy](uvtemp ,
ref[1] + (x>>1) + (y>>1)*uvstride, uvstride,
h>>1);
224 c->hpel_put[
size+1][uvdxy](uvtemp+8,
ref[2] + (x>>1) + (y>>1)*uvstride, uvstride,
h>>1);
225 d += chroma_cmp_func(
s, uvtemp ,
src[1], uvstride,
h>>1);
226 d += chroma_cmp_func(
s, uvtemp+8,
src[2], uvstride,
h>>1);
232 int ref_index,
int src_index,
234 return cmp_inline(
s,x,y,0,0,0,16,ref_index,src_index,
cmp_func, chroma_cmp_func, 0, 0);
238 const int size,
const int h,
int ref_index,
int src_index,
241 return cmp_direct_inline(
s,x,y,0,0,
size,
h,ref_index,src_index,
cmp_func, chroma_cmp_func,
flags&
FLAG_QPEL);
243 return cmp_inline(
s,x,y,0,0,
size,
h,ref_index,src_index,
cmp_func, chroma_cmp_func, 0,
flags&
FLAG_CHROMA);
248 const int size,
const int h,
int ref_index,
int src_index,
251 return cmp_direct_inline(
s,x,y,subx,suby,
size,
h,ref_index,src_index,
cmp_func, chroma_cmp_func,
flags&
FLAG_QPEL);
253 return cmp_inline(
s,x,y,subx,suby,
size,
h,ref_index,src_index,
cmp_func, chroma_cmp_func,
flags&
FLAG_QPEL,
flags&
FLAG_CHROMA);
261 const int size,
const int h,
int ref_index,
int src_index,
265 &&
flags==0 &&
h==16 &&
size==0 && subx==0 && suby==0){
268 && subx==0 && suby==0){
271 return cmp_internal(
s,x,y,subx,suby,
size,
h,ref_index,src_index,
cmp_func, chroma_cmp_func,
flags);
276 const int size,
const int h,
int ref_index,
int src_index,
279 return cmp_direct_inline(
s,x,y,subx,suby,
size,
h,ref_index,src_index,
cmp_func, chroma_cmp_func, 0);
281 return cmp_inline(
s,x,y,subx,suby,
size,
h,ref_index,src_index,
cmp_func, chroma_cmp_func, 0,
flags&
FLAG_CHROMA);
286 const int size,
const int h,
int ref_index,
int src_index,
289 return cmp_direct_inline(
s,x,y,subx,suby,
size,
h,ref_index,src_index,
cmp_func, chroma_cmp_func, 1);
291 return cmp_inline(
s,x,y,subx,suby,
size,
h,ref_index,src_index,
cmp_func, chroma_cmp_func, 1,
flags&
FLAG_CHROMA);
309 int dia_size=
FFMAX(
FFABS(
s->avctx->dia_size)&255,
FFABS(
s->avctx->pre_dia_size)&255);
320 c->avctx->me_sub_cmp =
c->avctx->me_cmp;
322 if(cache_size < 2*dia_size && !c->
stride){
323 av_log(
s->avctx,
AV_LOG_INFO,
"ME_MAP size may be a little small for the selected diamond size\n");
326 ret =
ff_set_cmp(&
s->mecc,
s->mecc.me_pre_cmp,
c->avctx->me_pre_cmp);
327 ret |=
ff_set_cmp(&
s->mecc,
s->mecc.me_cmp,
c->avctx->me_cmp);
328 ret |=
ff_set_cmp(&
s->mecc,
s->mecc.me_sub_cmp,
c->avctx->me_sub_cmp);
329 ret |=
ff_set_cmp(&
s->mecc,
s->mecc.mb_cmp,
c->avctx->mb_cmp);
340 c->qpel_avg =
s->qdsp.avg_qpel_pixels_tab;
342 c->qpel_put =
s->qdsp.put_no_rnd_qpel_pixels_tab;
344 c->qpel_put =
s->qdsp.put_qpel_pixels_tab;
355 c->hpel_avg =
s->hdsp.avg_pixels_tab;
357 c->hpel_put =
s->hdsp.put_no_rnd_pixels_tab;
359 c->hpel_put =
s->hdsp.put_pixels_tab;
362 c->stride =
s->linesize;
363 c->uvstride=
s->uvlinesize;
365 c->stride = 16*
s->mb_width + 32;
366 c->uvstride= 8*
s->mb_width + 16;
377 c->hpel_put[2][0]=
c->hpel_put[2][1]=
388 #define CHECK_SAD_HALF_MV(suffix, x, y) \
390 d = s->mecc.pix_abs[size][(x ? 1 : 0) + (y ? 2 : 0)](NULL, pix, ptr + ((x) >> 1), stride, h); \
391 d += (mv_penalty[pen_x + x] + mv_penalty[pen_y + y])*penalty_factor;\
392 COPY3_IF_LT(dminh, d, dx, x, dy, y)\
396 int *mx_ptr,
int *my_ptr,
int dmin,
397 int src_index,
int ref_index,
401 const int penalty_factor=
c->sub_penalty_factor;
415 pix =
c->src[src_index][0];
419 ptr =
c->ref[ref_index][0] + (my *
stride) + mx;
423 if (mx > xmin && mx < xmax &&
424 my > ymin && my < ymax) {
502 const int xy=
s->mb_x +
s->mb_y*
s->mb_stride;
504 s->p_mv_table[xy][0] = mx;
505 s->p_mv_table[xy][1] = my;
509 int mot_xy=
s->block_index[0];
511 s->current_picture.motion_val[0][mot_xy ][0] = mx;
512 s->current_picture.motion_val[0][mot_xy ][1] = my;
513 s->current_picture.motion_val[0][mot_xy + 1][0] = mx;
514 s->current_picture.motion_val[0][mot_xy + 1][1] = my;
516 mot_xy +=
s->b8_stride;
517 s->current_picture.motion_val[0][mot_xy ][0] = mx;
518 s->current_picture.motion_val[0][mot_xy ][1] = my;
519 s->current_picture.motion_val[0][mot_xy + 1][0] = mx;
520 s->current_picture.motion_val[0][mot_xy + 1][1] = my;
530 int range=
c->avctx->me_range >> (1 + !!(
c->flags&
FLAG_QPEL));
536 if (
s->unrestricted_mv) {
539 c->xmax = - x +
s->width;
540 c->ymax = - y +
s->height;
543 c->xmin = (x > 15) ? - 15 : 0;
544 c->ymin = (y > 15) ? - 15 : 0;
545 c->xmax = (x <
s->mb_width * 16 - 16) ? 15 : 0;
546 c->ymax = (y <
s->mb_height * 16 - 16) ? 15 : 0;
550 c->xmax = - x +
s->mb_width *16 - 16;
551 c->ymax = - y +
s->mb_height*16 - 16;
553 if(!range || range > max_range)
556 c->xmin =
FFMAX(
c->xmin,-range);
557 c->xmax =
FFMIN(
c->xmax, range);
558 c->ymin =
FFMAX(
c->ymin,-range);
559 c->ymax =
FFMIN(
c->ymax, range);
566 c->ref[1][0] =
c->ref[0][0] + 8;
567 c->ref[2][0] =
c->ref[0][0] + 8*
stride;
568 c->ref[3][0] =
c->ref[2][0] + 8;
569 c->src[1][0] =
c->src[0][0] + 8;
570 c->src[2][0] =
c->src[0][0] + 8*
stride;
571 c->src[3][0] =
c->src[2][0] + 8;
581 int dmin_sum=0, mx4_sum=0, my4_sum=0,
i;
585 int safety_clipping=
s->unrestricted_mv && (
s->width&15) && (
s->height&15);
591 int pred_x4, pred_y4;
593 static const int off[4]= {2, 1, 1, -1};
594 const int mot_stride =
s->b8_stride;
595 const int mot_xy =
s->block_index[
block];
598 c->xmax = - 16*
s->mb_x +
s->width - 8*(
block &1);
599 c->ymax = - 16*
s->mb_y +
s->height - 8*(
block>>1);
602 P_LEFT[0] =
s->current_picture.motion_val[0][mot_xy - 1][0];
603 P_LEFT[1] =
s->current_picture.motion_val[0][mot_xy - 1][1];
608 if (
s->first_slice_line &&
block<2) {
612 P_TOP[0] =
s->current_picture.motion_val[0][mot_xy - mot_stride ][0];
613 P_TOP[1] =
s->current_picture.motion_val[0][mot_xy - mot_stride ][1];
614 P_TOPRIGHT[0] =
s->current_picture.motion_val[0][mot_xy - mot_stride + off[
block]][0];
615 P_TOPRIGHT[1] =
s->current_picture.motion_val[0][mot_xy - mot_stride + off[
block]][1];
631 if (
s->first_slice_line && block<2 && i>1 &&
i<9)
643 if (
s->mecc.me_sub_cmp[0] !=
s->mecc.mb_cmp[0]) {
647 if(
s->quarter_sample){
649 dxy = ((my4 & 3) << 2) | (mx4 & 3);
652 s->qdsp.put_no_rnd_qpel_pixels_tab[1][dxy](dest_y,
ref,
stride);
654 s->qdsp.put_qpel_pixels_tab[1][dxy](dest_y,
ref,
stride);
657 dxy = ((my4 & 1) << 1) | (mx4 & 1);
660 s->hdsp.put_no_rnd_pixels_tab[1][dxy](dest_y ,
ref ,
stride,
h);
662 s->hdsp.put_pixels_tab [1][dxy](dest_y ,
ref ,
stride,
h);
668 if(
s->quarter_sample){
676 s->current_picture.motion_val[0][
s->block_index[
block]][0] = mx4;
677 s->current_picture.motion_val[0][
s->block_index[
block]][1] = my4;
679 if(mx4 != mx || my4 != my) same=0;
685 if (
s->mecc.me_sub_cmp[0] !=
s->mecc.mb_cmp[0]) {
686 dmin_sum +=
s->mecc.mb_cmp[0](
s,
687 s->new_picture.f->data[0] +
688 s->mb_x * 16 +
s->mb_y * 16 *
stride,
699 dxy = ((my & 1) << 1) | (mx & 1);
701 offset= (
s->mb_x*8 + (mx>>1)) + (
s->mb_y*8 + (my>>1))*
s->uvlinesize;
704 s->hdsp.put_no_rnd_pixels_tab[1][dxy](
c->scratchpad ,
s->last_picture.f->data[1] +
offset,
s->uvlinesize, 8);
705 s->hdsp.put_no_rnd_pixels_tab[1][dxy](
c->scratchpad + 8,
s->last_picture.f->data[2] +
offset,
s->uvlinesize, 8);
707 s->hdsp.put_pixels_tab [1][dxy](
c->scratchpad ,
s->last_picture.f->data[1] +
offset,
s->uvlinesize, 8);
708 s->hdsp.put_pixels_tab [1][dxy](
c->scratchpad + 8,
s->last_picture.f->data[2] +
offset,
s->uvlinesize, 8);
711 dmin_sum +=
s->mecc.mb_cmp[1](
s,
s->new_picture.f->data[1] +
s->mb_x * 8 +
s->mb_y * 8 *
s->uvlinesize,
c->scratchpad,
s->uvlinesize, 8);
712 dmin_sum +=
s->mecc.mb_cmp[1](
s,
s->new_picture.f->data[2] +
s->mb_x * 8 +
s->mb_y * 8 *
s->uvlinesize,
c->scratchpad + 8,
s->uvlinesize, 8);
718 switch(
c->avctx->mb_cmp&0xFF){
724 return dmin_sum+ 11*
c->mb_penalty_factor;
731 c->ref[1+ref_index][0] =
c->ref[0+ref_index][0] +
s->linesize;
732 c->src[1][0] =
c->src[0][0] +
s->linesize;
734 c->ref[1+ref_index][1] =
c->ref[0+ref_index][1] +
s->uvlinesize;
735 c->ref[1+ref_index][2] =
c->ref[0+ref_index][2] +
s->uvlinesize;
736 c->src[1][1] =
c->src[0][1] +
s->uvlinesize;
737 c->src[1][2] =
c->src[0][2] +
s->uvlinesize;
742 int16_t (*mv_tables[2][2])[2],
uint8_t *field_select_tables[2],
int mx,
int my,
int user_field_select)
751 const int stride= 2*
s->linesize;
753 const int mot_stride=
s->mb_stride;
754 const int xy=
s->mb_x +
s->mb_y*mot_stride;
764 int best_dmin= INT_MAX;
767 for(field_select=0; field_select<2; field_select++){
768 int dmin, mx_i, my_i;
769 int16_t (*mv_table)[2]= mv_tables[
block][field_select];
771 if(user_field_select){
772 av_assert1(field_select==0 || field_select==1);
774 if(field_select_tables[
block][xy] != field_select)
778 P_LEFT[0] = mv_table[xy - 1][0];
779 P_LEFT[1] = mv_table[xy - 1][1];
785 if(!
s->first_slice_line){
786 P_TOP[0] = mv_table[xy - mot_stride][0];
787 P_TOP[1] = mv_table[xy - mot_stride][1];
788 P_TOPRIGHT[0] = mv_table[xy - mot_stride + 1][0];
789 P_TOPRIGHT[1] = mv_table[xy - mot_stride + 1][1];
803 dmin=
c->sub_motion_search(
s, &mx_i, &my_i, dmin,
block, field_select+ref_index,
size,
h);
805 mv_table[xy][0]= mx_i;
806 mv_table[xy][1]= my_i;
808 if (
s->mecc.me_sub_cmp[0] !=
s->mecc.mb_cmp[0]) {
813 dxy = ((my_i & 1) << 1) | (mx_i & 1);
823 dmin+=
c->mb_penalty_factor;
825 dmin += field_select !=
block;
827 if(dmin < best_dmin){
829 best_field= field_select;
833 int16_t (*mv_table)[2]= mv_tables[
block][best_field];
835 if(mv_table[xy][0] != mx) same=0;
836 if(mv_table[xy][1]&1) same=0;
837 if(mv_table[xy][1]*2 != my) same=0;
838 if(best_field !=
block) same=0;
841 field_select_tables[
block][xy]= best_field;
842 dmin_sum += best_dmin;
853 switch(
c->avctx->mb_cmp&0xFF){
859 return dmin_sum+ 11*
c->mb_penalty_factor;
893 int sum, mx = 0, my = 0, dmin = 0;
897 const int shift= 1+
s->quarter_sample;
899 Picture *
const pic= &
s->current_picture;
901 init_ref(
c,
s->new_picture.f->data,
s->last_picture.f->data,
NULL, 16*mb_x, 16*mb_y, 0);
903 av_assert0(
s->quarter_sample==0 ||
s->quarter_sample==1);
910 c->current_mv_penalty=
c->mv_penalty[
s->f_code] +
MAX_DMV;
917 sum =
s->mpvencdsp.pix_sum(pix,
s->linesize);
918 varc =
s->mpvencdsp.pix_norm1(pix,
s->linesize) -
919 (((unsigned) sum * sum) >> 8) + 500;
921 pic->
mb_mean[
s->mb_stride * mb_y + mb_x] = (sum+128)>>8;
922 pic->
mb_var [
s->mb_stride * mb_y + mb_x] = (varc+128)>>8;
923 c->mb_var_sum_temp += (varc+128)>>8;
926 const int mot_stride =
s->b8_stride;
927 const int mot_xy =
s->block_index[0];
929 P_LEFT[0] =
s->current_picture.motion_val[0][mot_xy - 1][0];
930 P_LEFT[1] =
s->current_picture.motion_val[0][mot_xy - 1][1];
935 if (!
s->first_slice_line) {
936 P_TOP[0] =
s->current_picture.motion_val[0][mot_xy - mot_stride ][0];
937 P_TOP[1] =
s->current_picture.motion_val[0][mot_xy - mot_stride ][1];
938 P_TOPRIGHT[0] =
s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0];
939 P_TOPRIGHT[1] =
s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1];
965 ppix =
c->ref[0][0] + (my *
s->linesize) + mx;
967 vard =
s->mecc.sse[0](
NULL, pix, ppix,
s->linesize, 16);
969 pic->
mc_mb_var[
s->mb_stride * mb_y + mb_x] = (vard+128)>>8;
970 c->mc_mb_var_sum_temp += (vard+128)>>8;
977 if (vard*2 + 200*256 > varc && !
s->intra_penalty)
979 if (varc*2 + 200*256 > vard ||
s->qscale > 24){
982 c->sub_motion_search(
s, &mx, &my, dmin, 0, 0, 0, 16);
991 && !
c->skip && varc>50<<8 && vard>10<<8){
1007 dmin=
c->sub_motion_search(
s, &mx, &my, dmin, 0, 0, 0, 16);
1008 if(
c->avctx->me_sub_cmp !=
c->avctx->mb_cmp && !
c->skip)
1012 && !
c->skip && varc>50<<8 && vard>10<<8){
1032 intra_score= varc - 500;
1034 unsigned mean = (sum+128)>>8;
1037 for(
i=0;
i<16;
i++){
1038 *(uint32_t*)(&
c->scratchpad[
i*
s->linesize+ 0]) =
mean;
1039 *(uint32_t*)(&
c->scratchpad[
i*
s->linesize+ 4]) =
mean;
1040 *(uint32_t*)(&
c->scratchpad[
i*
s->linesize+ 8]) =
mean;
1041 *(uint32_t*)(&
c->scratchpad[
i*
s->linesize+12]) =
mean;
1044 intra_score=
s->mecc.mb_cmp[0](
s,
c->scratchpad, pix,
s->linesize, 16);
1046 intra_score +=
c->mb_penalty_factor*16 +
s->intra_penalty;
1048 if(intra_score < dmin){
1052 s->current_picture.mb_type[mb_y*
s->mb_stride + mb_x] = 0;
1061 s->mb_type[mb_y*
s->mb_stride + mb_x]= mb_type;
1070 const int shift= 1+
s->quarter_sample;
1071 const int xy= mb_x + mb_y*
s->mb_stride;
1072 init_ref(
c,
s->new_picture.f->data,
s->last_picture.f->data,
NULL, 16*mb_x, 16*mb_y, 0);
1074 av_assert0(
s->quarter_sample==0 ||
s->quarter_sample==1);
1077 c->current_mv_penalty=
c->mv_penalty[
s->f_code] +
MAX_DMV;
1083 P_LEFT[1] =
s->p_mv_table[xy + 1][1];
1086 if (
s->first_slice_line) {
1092 P_TOP[0] =
s->p_mv_table[xy +
s->mb_stride ][0];
1093 P_TOP[1] =
s->p_mv_table[xy +
s->mb_stride ][1];
1094 P_TOPRIGHT[0] =
s->p_mv_table[xy +
s->mb_stride - 1][0];
1095 P_TOPRIGHT[1] =
s->p_mv_table[xy +
s->mb_stride - 1][1];
1109 s->p_mv_table[xy][0] = mx<<
shift;
1110 s->p_mv_table[xy][1] = my<<
shift;
1116 int16_t (*mv_table)[2],
int ref_index,
int f_code)
1119 int mx = 0, my = 0, dmin = 0;
1121 const int shift= 1+
s->quarter_sample;
1122 const int mot_stride =
s->mb_stride;
1123 const int mot_xy = mb_y*mot_stride + mb_x;
1136 P_LEFT[0] = mv_table[mot_xy - 1][0];
1137 P_LEFT[1] = mv_table[mot_xy - 1][1];
1142 if (!
s->first_slice_line) {
1143 P_TOP[0] = mv_table[mot_xy - mot_stride ][0];
1144 P_TOP[1] = mv_table[mot_xy - mot_stride ][1];
1145 P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1][0];
1146 P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1][1];
1157 pp =
s->next_picture_ptr->f->pts -
s->last_picture_ptr->f->pts;
1158 pb =
s->current_picture_ptr->f->pts -
s->last_picture_ptr->f->pts;
1159 if (mv_table ==
s->b_forw_mv_table)
1167 dmin=
c->sub_motion_search(
s, &mx, &my, dmin, 0, ref_index, 0, 16);
1169 if(
c->avctx->me_sub_cmp !=
c->avctx->mb_cmp && !
c->skip)
1173 mv_table[mot_xy][0]= mx;
1174 mv_table[mot_xy][1]= my;
1180 int motion_fx,
int motion_fy,
1181 int motion_bx,
int motion_by,
1182 int pred_fx,
int pred_fy,
1183 int pred_bx,
int pred_by,
1202 if(
s->quarter_sample){
1203 dxy = ((motion_fy & 3) << 2) | (motion_fx & 3);
1204 src_x = motion_fx >> 2;
1205 src_y = motion_fy >> 2;
1207 ptr = ref_data[0] + (src_y *
stride) + src_x;
1208 s->qdsp.put_qpel_pixels_tab[0][dxy](dest_y, ptr,
stride);
1210 dxy = ((motion_by & 3) << 2) | (motion_bx & 3);
1211 src_x = motion_bx >> 2;
1212 src_y = motion_by >> 2;
1214 ptr = ref2_data[0] + (src_y *
stride) + src_x;
1215 s->qdsp.avg_qpel_pixels_tab[
size][dxy](dest_y, ptr,
stride);
1217 dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);
1218 src_x = motion_fx >> 1;
1219 src_y = motion_fy >> 1;
1221 ptr = ref_data[0] + (src_y *
stride) + src_x;
1222 s->hdsp.put_pixels_tab[
size][dxy](dest_y , ptr ,
stride,
h);
1224 dxy = ((motion_by & 1) << 1) | (motion_bx & 1);
1225 src_x = motion_bx >> 1;
1226 src_y = motion_by >> 1;
1228 ptr = ref2_data[0] + (src_y *
stride) + src_x;
1229 s->hdsp.avg_pixels_tab[
size][dxy](dest_y , ptr ,
stride,
h);
1232 fbmin = (mv_penalty_f[motion_fx-pred_fx] + mv_penalty_f[motion_fy-pred_fy])*
c->mb_penalty_factor
1233 +(mv_penalty_b[motion_bx-pred_bx] + mv_penalty_b[motion_by-pred_by])*
c->mb_penalty_factor
1247 const int mot_stride =
s->mb_stride;
1248 const int xy = mb_y *mot_stride + mb_x;
1250 int pred_fx=
s->b_bidir_forw_mv_table[xy-1][0];
1251 int pred_fy=
s->b_bidir_forw_mv_table[xy-1][1];
1252 int pred_bx=
s->b_bidir_back_mv_table[xy-1][0];
1253 int pred_by=
s->b_bidir_back_mv_table[xy-1][1];
1254 int motion_fx=
s->b_bidir_forw_mv_table[xy][0]=
s->b_forw_mv_table[xy][0];
1255 int motion_fy=
s->b_bidir_forw_mv_table[xy][1]=
s->b_forw_mv_table[xy][1];
1256 int motion_bx=
s->b_bidir_back_mv_table[xy][0]=
s->b_back_mv_table[xy][0];
1257 int motion_by=
s->b_bidir_back_mv_table[xy][1]=
s->b_back_mv_table[xy][1];
1258 const int flags=
c->sub_flags;
1260 const int shift= 1+qpel;
1261 const int xmin=
c->xmin * (1 <<
shift);
1262 const int ymin=
c->ymin * (1 <<
shift);
1263 const int xmax=
c->xmax<<
shift;
1264 const int ymax=
c->ymax<<
shift;
1265 #define HASH(fx,fy,bx,by) ((fx)+17*(fy)+63*(bx)+117*(by))
1266 #define HASH8(fx,fy,bx,by) ((uint8_t)HASH(fx,fy,bx,by))
1267 int hashidx=
HASH(motion_fx,motion_fy, motion_bx, motion_by);
1270 map[hashidx&255] = 1;
1273 motion_bx, motion_by,
1278 if(
s->avctx->bidir_refine){
1280 static const uint8_t limittab[5]={0,8,32,64,80};
1281 const int limit= limittab[
s->avctx->bidir_refine];
1282 static const int8_t vect[][4]={
1283 { 0, 0, 0, 1}, { 0, 0, 0,-1}, { 0, 0, 1, 0}, { 0, 0,-1, 0}, { 0, 1, 0, 0}, { 0,-1, 0, 0}, { 1, 0, 0, 0}, {-1, 0, 0, 0},
1285 { 0, 0, 1, 1}, { 0, 0,-1,-1}, { 0, 1, 1, 0}, { 0,-1,-1, 0}, { 1, 1, 0, 0}, {-1,-1, 0, 0}, { 1, 0, 0, 1}, {-1, 0, 0,-1},
1286 { 0, 1, 0, 1}, { 0,-1, 0,-1}, { 1, 0, 1, 0}, {-1, 0,-1, 0},
1287 { 0, 0,-1, 1}, { 0, 0, 1,-1}, { 0,-1, 1, 0}, { 0, 1,-1, 0}, {-1, 1, 0, 0}, { 1,-1, 0, 0}, { 1, 0, 0,-1}, {-1, 0, 0, 1},
1288 { 0,-1, 0, 1}, { 0, 1, 0,-1}, {-1, 0, 1, 0}, { 1, 0,-1, 0},
1290 { 0, 1, 1, 1}, { 0,-1,-1,-1}, { 1, 1, 1, 0}, {-1,-1,-1, 0}, { 1, 1, 0, 1}, {-1,-1, 0,-1}, { 1, 0, 1, 1}, {-1, 0,-1,-1},
1291 { 0,-1, 1, 1}, { 0, 1,-1,-1}, {-1, 1, 1, 0}, { 1,-1,-1, 0}, { 1, 1, 0,-1}, {-1,-1, 0, 1}, { 1, 0,-1, 1}, {-1, 0, 1,-1},
1292 { 0, 1,-1, 1}, { 0,-1, 1,-1}, { 1,-1, 1, 0}, {-1, 1,-1, 0}, {-1, 1, 0, 1}, { 1,-1, 0,-1}, { 1, 0, 1,-1}, {-1, 0,-1, 1},
1293 { 0, 1, 1,-1}, { 0,-1,-1, 1}, { 1, 1,-1, 0}, {-1,-1, 1, 0}, { 1,-1, 0, 1}, {-1, 1, 0,-1}, {-1, 0, 1, 1}, { 1, 0,-1,-1},
1295 { 1, 1, 1, 1}, {-1,-1,-1,-1},
1296 { 1, 1, 1,-1}, {-1,-1,-1, 1}, { 1, 1,-1, 1}, {-1,-1, 1,-1}, { 1,-1, 1, 1}, {-1, 1,-1,-1}, {-1, 1, 1, 1}, { 1,-1,-1,-1},
1297 { 1, 1,-1,-1}, {-1,-1, 1, 1}, { 1,-1,-1, 1}, {-1, 1, 1,-1}, { 1,-1, 1,-1}, {-1, 1,-1, 1},
1300 HASH8( 0, 0, 0, 1),
HASH8( 0, 0, 0,-1),
HASH8( 0, 0, 1, 0),
HASH8( 0, 0,-1, 0),
HASH8( 0, 1, 0, 0),
HASH8( 0,-1, 0, 0),
HASH8( 1, 0, 0, 0),
HASH8(-1, 0, 0, 0),
1302 HASH8( 0, 0, 1, 1),
HASH8( 0, 0,-1,-1),
HASH8( 0, 1, 1, 0),
HASH8( 0,-1,-1, 0),
HASH8( 1, 1, 0, 0),
HASH8(-1,-1, 0, 0),
HASH8( 1, 0, 0, 1),
HASH8(-1, 0, 0,-1),
1303 HASH8( 0, 1, 0, 1),
HASH8( 0,-1, 0,-1),
HASH8( 1, 0, 1, 0),
HASH8(-1, 0,-1, 0),
1304 HASH8( 0, 0,-1, 1),
HASH8( 0, 0, 1,-1),
HASH8( 0,-1, 1, 0),
HASH8( 0, 1,-1, 0),
HASH8(-1, 1, 0, 0),
HASH8( 1,-1, 0, 0),
HASH8( 1, 0, 0,-1),
HASH8(-1, 0, 0, 1),
1305 HASH8( 0,-1, 0, 1),
HASH8( 0, 1, 0,-1),
HASH8(-1, 0, 1, 0),
HASH8( 1, 0,-1, 0),
1307 HASH8( 0, 1, 1, 1),
HASH8( 0,-1,-1,-1),
HASH8( 1, 1, 1, 0),
HASH8(-1,-1,-1, 0),
HASH8( 1, 1, 0, 1),
HASH8(-1,-1, 0,-1),
HASH8( 1, 0, 1, 1),
HASH8(-1, 0,-1,-1),
1308 HASH8( 0,-1, 1, 1),
HASH8( 0, 1,-1,-1),
HASH8(-1, 1, 1, 0),
HASH8( 1,-1,-1, 0),
HASH8( 1, 1, 0,-1),
HASH8(-1,-1, 0, 1),
HASH8( 1, 0,-1, 1),
HASH8(-1, 0, 1,-1),
1309 HASH8( 0, 1,-1, 1),
HASH8( 0,-1, 1,-1),
HASH8( 1,-1, 1, 0),
HASH8(-1, 1,-1, 0),
HASH8(-1, 1, 0, 1),
HASH8( 1,-1, 0,-1),
HASH8( 1, 0, 1,-1),
HASH8(-1, 0,-1, 1),
1310 HASH8( 0, 1, 1,-1),
HASH8( 0,-1,-1, 1),
HASH8( 1, 1,-1, 0),
HASH8(-1,-1, 1, 0),
HASH8( 1,-1, 0, 1),
HASH8(-1, 1, 0,-1),
HASH8(-1, 0, 1, 1),
HASH8( 1, 0,-1,-1),
1313 HASH8( 1, 1, 1,-1),
HASH8(-1,-1,-1, 1),
HASH8( 1, 1,-1, 1),
HASH8(-1,-1, 1,-1),
HASH8( 1,-1, 1, 1),
HASH8(-1, 1,-1,-1),
HASH8(-1, 1, 1, 1),
HASH8( 1,-1,-1,-1),
1314 HASH8( 1, 1,-1,-1),
HASH8(-1,-1, 1, 1),
HASH8( 1,-1,-1, 1),
HASH8(-1, 1, 1,-1),
HASH8( 1,-1, 1,-1),
HASH8(-1, 1,-1, 1),
1317 #define CHECK_BIDIR(fx,fy,bx,by)\
1318 if( !map[(hashidx+HASH(fx,fy,bx,by))&255]\
1319 &&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\
1320 &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\
1322 map[(hashidx+HASH(fx,fy,bx,by))&255] = 1;\
1323 score= check_bidir_mv(s, motion_fx+fx, motion_fy+fy, motion_bx+bx, motion_by+by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);\
1325 hashidx += HASH(fx,fy,bx,by);\
1334 #define CHECK_BIDIR2(a,b,c,d)\
1335 CHECK_BIDIR(a,b,c,d)\
1336 CHECK_BIDIR(-(a),-(b),-(c),-(d))
1348 for(
i=8;
i<limit;
i++){
1349 int fx= motion_fx+vect[
i][0];
1350 int fy= motion_fy+vect[
i][1];
1351 int bx= motion_bx+vect[
i][2];
1352 int by= motion_by+vect[
i][3];
1354 int a= (xmax -
FFMAX(fx,bx))|(
FFMIN(fx,bx) - xmin);
1355 int b= (ymax -
FFMAX(fy,by))|(
FFMIN(fy,by) - ymin);
1362 score=
check_bidir_mv(
s, fx, fy, bx, by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);
1383 s->b_bidir_forw_mv_table[xy][0]= motion_fx;
1384 s->b_bidir_forw_mv_table[xy][1]= motion_fy;
1385 s->b_bidir_back_mv_table[xy][0]= motion_bx;
1386 s->b_bidir_back_mv_table[xy][1]= motion_by;
1395 const int mot_stride =
s->mb_stride;
1396 const int mot_xy = mb_y*mot_stride + mb_x;
1397 const int shift= 1+
s->quarter_sample;
1399 const int time_pp=
s->pp_time;
1400 const int time_pb=
s->pb_time;
1401 int mx, my, xmin, xmax, ymin, ymax;
1402 int16_t (*mv_table)[2]=
s->b_direct_mv_table;
1404 c->current_mv_penalty=
c->mv_penalty[1] +
MAX_DMV;
1405 ymin= xmin=(-32)>>
shift;
1406 ymax= xmax= 31>>
shift;
1408 if (
IS_8X8(
s->next_picture.mb_type[mot_xy])) {
1418 c->co_located_mv[
i][0] =
s->next_picture.motion_val[0][
index][0];
1419 c->co_located_mv[
i][1] =
s->next_picture.motion_val[0][
index][1];
1420 c->direct_basis_mv[
i][0]=
c->co_located_mv[
i][0]*time_pb/time_pp + ((
i& 1)<<(
shift+3));
1421 c->direct_basis_mv[
i][1]=
c->co_located_mv[
i][1]*time_pb/time_pp + ((
i>>1)<<(
shift+3));
1425 max=
FFMAX(
c->direct_basis_mv[
i][0],
c->direct_basis_mv[
i][0] -
c->co_located_mv[
i][0])>>
shift;
1426 min=
FFMIN(
c->direct_basis_mv[
i][0],
c->direct_basis_mv[
i][0] -
c->co_located_mv[
i][0])>>
shift;
1432 max=
FFMAX(
c->direct_basis_mv[
i][1],
c->direct_basis_mv[
i][1] -
c->co_located_mv[
i][1])>>
shift;
1433 min=
FFMIN(
c->direct_basis_mv[
i][1],
c->direct_basis_mv[
i][1] -
c->co_located_mv[
i][1])>>
shift;
1442 av_assert2(xmax <= 15 && ymax <= 15 && xmin >= -16 && ymin >= -16);
1444 if(xmax < 0 || xmin >0 || ymax < 0 || ymin > 0){
1445 s->b_direct_mv_table[mot_xy][0]= 0;
1446 s->b_direct_mv_table[mot_xy][1]= 0;
1448 return 256*256*256*64-1;
1464 if (!
s->first_slice_line) {
1480 if(
c->avctx->me_sub_cmp !=
c->avctx->mb_cmp && !
c->skip)
1485 mv_table[mot_xy][0]= mx;
1486 mv_table[mot_xy][1]= my;
1497 const int penalty_factor=
c->mb_penalty_factor;
1498 int fmin, bmin, dmin, fbmin, bimin, fimin;
1500 const int xy = mb_y*
s->mb_stride + mb_x;
1501 init_ref(
c,
s->new_picture.f->data,
s->last_picture.f->data,
1502 s->next_picture.f->data, 16 * mb_x, 16 * mb_y, 2);
1511 score= ((unsigned)(score*score + 128*256))>>16;
1512 c->mc_mb_var_sum_temp += score;
1513 s->current_picture.mc_mb_var[mb_y*
s->mb_stride + mb_x] = score;
1531 ff_dlog(
s,
" %d %d ",
s->b_forw_mv_table[xy][0],
s->b_forw_mv_table[xy][1]);
1540 c->current_mv_penalty=
c->mv_penalty[
s->f_code] +
MAX_DMV;
1542 s->b_field_mv_table[0],
s->b_field_select_table[0],
1543 s->b_forw_mv_table[xy][0],
s->b_forw_mv_table[xy][1], 0);
1544 c->current_mv_penalty=
c->mv_penalty[
s->b_code] +
MAX_DMV;
1546 s->b_field_mv_table[1],
s->b_field_select_table[1],
1547 s->b_back_mv_table[xy][0],
s->b_back_mv_table[xy][1], 0);
1549 fimin= bimin= INT_MAX;
1576 score= ((unsigned)(score*score + 128*256))>>16;
1577 c->mc_mb_var_sum_temp += score;
1578 s->current_picture.mc_mb_var[mb_y*
s->mb_stride + mb_x] = score;
1587 if(fimin < INT_MAX && bimin < INT_MAX){
1597 s->mb_type[mb_y*
s->mb_stride + mb_x]=
type;
1605 int i, y, range=
s->avctx->me_range ?
s->avctx->me_range : (INT_MAX/2);
1608 int best_score=-10000000;
1610 if(
s->msmpeg4_version)
1611 range=
FFMIN(range, 16);
1613 range=
FFMIN(range, 256);
1615 for(
i=0;
i<8;
i++) score[
i]=
s->mb_num*(8-
i);
1617 for(y=0; y<
s->mb_height; y++){
1619 int xy= y*
s->mb_stride;
1620 for(x=0; x<
s->mb_width; x++, xy++){
1621 if(
s->mb_type[xy] &
type){
1622 int mx= mv_table[xy][0];
1623 int my= mv_table[xy][1];
1628 if (mx >= range || mx < -range ||
1629 my >= range || my < -range)
1632 for(j=0; j<fcode && j<8; j++){
1633 if(
s->pict_type==
AV_PICTURE_TYPE_B ||
s->current_picture.mc_mb_var[xy] <
s->current_picture.mb_var[xy])
1641 if(score[
i] > best_score){
1642 best_score= score[
i];
1656 const int f_code=
s->f_code;
1660 range = (((
s->out_format ==
FMT_MPEG1 ||
s->msmpeg4_version) ? 8 : 16) << f_code);
1662 av_assert0(range <= 16 || !s->msmpeg4_version);
1665 if(
c->avctx->me_range && range >
c->avctx->me_range) range=
c->avctx->me_range;
1668 const int wrap=
s->b8_stride;
1671 for(y=0; y<
s->mb_height; y++){
1673 int i= y*
s->mb_stride;
1676 for(x=0; x<
s->mb_width; x++){
1681 int mx =
s->current_picture.motion_val[0][ xy + off ][0];
1682 int my =
s->current_picture.motion_val[0][ xy + off ][1];
1684 if( mx >=range || mx <-range
1685 || my >=range || my <-range){
1688 s->current_picture.mb_type[
i] =
type;
1703 int16_t (*mv_table)[2],
int f_code,
int type,
int truncate)
1706 int y, h_range, v_range;
1709 int range = (((
s->out_format ==
FMT_MPEG1 ||
s->msmpeg4_version) ? 8 : 16) << f_code);
1711 if(
c->avctx->me_range && range >
c->avctx->me_range) range=
c->avctx->me_range;
1714 v_range= field_select_table ? range>>1 : range;
1717 for(y=0; y<
s->mb_height; y++){
1719 int xy= y*
s->mb_stride;
1720 for(x=0; x<
s->mb_width; x++){
1721 if (
s->mb_type[xy] &
type){
1722 if (!field_select_table || field_select_table[xy] == field_select) {
1723 if( mv_table[xy][0] >=h_range || mv_table[xy][0] <-h_range
1724 || mv_table[xy][1] >=v_range || mv_table[xy][1] <-v_range){
1727 if (mv_table[xy][0] > h_range-1) mv_table[xy][0]= h_range-1;
1728 else if(mv_table[xy][0] < -h_range ) mv_table[xy][0]= -h_range;
1729 if (mv_table[xy][1] > v_range-1) mv_table[xy][1]= v_range-1;
1730 else if(mv_table[xy][1] < -v_range ) mv_table[xy][1]= -v_range;
1732 s->mb_type[xy] &= ~
type;
#define av_builtin_constant_p
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define FF_COMPLIANCE_NORMAL
#define FF_MB_DECISION_SIMPLE
uses mb_cmp
#define FF_CMP_MEDIAN_SAD
#define flags(name, subs,...)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
double fmin(double, double)
#define AV_CODEC_FLAG_QPEL
Use qpel MC.
#define AV_CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
#define AV_CODEC_FLAG_4MV
4 MV per MB allowed / advanced prediction for H.263.
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
static av_always_inline void mv_scale(Mv *dst, Mv *src, int td, int tb)
const VDPAUPixFmtMap * map
static uint8_t fcode_tab[MAX_MV *2+1]
Minimal fcode that a motion vector component would need.
static uint8_t mv_penalty[MAX_FCODE+1][MAX_DMV *2+1]
Table of number of bits a motion vector component needs.
static void direct(const float *in, const FFTComplex *ir, int len, float *out)
common internal API header
#define FF_PTR_ADD(ptr, off)
static const uint16_t mask[17]
int ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type)
int(* me_cmp_func)(struct MpegEncContext *c, uint8_t *blk1, uint8_t *blk2, ptrdiff_t stride, int h)
static int minima_cmp(const void *a, const void *b)
static av_always_inline int cmp_direct_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel)
static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel, int chroma)
static int get_penalty_factor(int lambda, int lambda2, int type)
void ff_estimate_p_frame_motion(MpegEncContext *s, int mb_x, int mb_y)
#define CHECK_SAD_HALF_MV(suffix, x, y)
static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y, int16_t(*mv_table)[2], int ref_index, int f_code)
void ff_fix_long_p_mvs(MpegEncContext *s, int type)
int ff_init_me(MpegEncContext *s)
static void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index)
static void set_p_mv_tables(MpegEncContext *s, int mx, int my, int mv4)
void ff_fix_long_mvs(MpegEncContext *s, uint8_t *field_select_table, int field_select, int16_t(*mv_table)[2], int f_code, int type, int truncate)
static int cmp_fpel_internal(MpegEncContext *s, const int x, const int y, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags)
static int cmp_internal(MpegEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags)
static int get_flags(MotionEstContext *c, int direct, int chroma)
static int interlaced_search(MpegEncContext *s, int ref_index, int16_t(*mv_tables[2][2])[2], uint8_t *field_select_tables[2], int mx, int my, int user_field_select)
static int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
static int cmp_hpel(MpegEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags)
static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b, ptrdiff_t stride, int h)
#define HASH8(fx, fy, bx, by)
static void get_limits(MpegEncContext *s, int x, int y)
get fullpel ME search limits.
static int check_bidir_mv(MpegEncContext *s, int motion_fx, int motion_fy, int motion_bx, int motion_by, int pred_fx, int pred_fy, int pred_bx, int pred_by, int size, int h)
static int sad_hpel_motion_search(MpegEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h)
#define CHECK_BIDIR2(a, b, c, d)
static void init_mv4_ref(MotionEstContext *c)
int ff_pre_estimate_p_frame_motion(MpegEncContext *s, int mb_x, int mb_y)
static int cmp_qpel(MpegEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags)
#define HASH(fx, fy, bx, by)
static unsigned update_map_generation(MotionEstContext *c)
static av_always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags)
compares a block (either a full macroblock or a partition thereof) against a proposed motion-compensa...
static int cmp_simple(MpegEncContext *s, const int x, const int y, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func)
static int bidir_refine(MpegEncContext *s, int mb_x, int mb_y)
int ff_get_best_fcode(MpegEncContext *s, int16_t(*mv_table)[2], int type)
static int direct_search(MpegEncContext *s, int mb_x, int mb_y)
void ff_estimate_b_frame_motion(MpegEncContext *s, int mb_x, int mb_y)
static void zero_hpel(uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h)
static void init_interlaced_ref(MpegEncContext *s, int ref_index)
int ff_epzs_motion_search(struct MpegEncContext *s, int *mx_ptr, int *my_ptr, int P[10][2], int src_index, int ref_index, int16_t(*last_mv)[2], int ref_mv_scale, int size, int h)
static int ff_h263_round_chroma(int x)
Motion estimation template.
static int hpel_motion_search(MpegEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h)
static int get_mb_score(MpegEncContext *s, int mx, int my, int src_index, int ref_index, int size, int h, int add_rate)
static int qpel_motion_search(MpegEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h)
static int epzs_motion_search2(MpegEncContext *s, int *mx_ptr, int *my_ptr, int P[10][2], int src_index, int ref_index, int16_t(*last_mv)[2], int ref_mv_scale, const int size)
static int no_sub_motion_search(MpegEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h)
#define CANDIDATE_MB_TYPE_INTRA
#define CANDIDATE_MB_TYPE_BACKWARD
#define CANDIDATE_MB_TYPE_FORWARD_I
#define CANDIDATE_MB_TYPE_INTER_I
#define CANDIDATE_MB_TYPE_BIDIR_I
#define CANDIDATE_MB_TYPE_BACKWARD_I
#define CANDIDATE_MB_TYPE_SKIPPED
#define CANDIDATE_MB_TYPE_INTER
#define CANDIDATE_MB_TYPE_DIRECT
#define CANDIDATE_MB_TYPE_BIDIR
#define CANDIDATE_MB_TYPE_FORWARD
#define CANDIDATE_MB_TYPE_INTER4V
#define CANDIDATE_MB_TYPE_DIRECT0
#define MV_TYPE_8X8
4 vectors (H.263, MPEG-4 4MV)
#define MV_TYPE_16X16
1 vector for the whole mb
static int shift(int a, int b)
Motion estimation context.
uint8_t * mb_mean
Table for MB luminance.
uint16_t * mc_mb_var
Table for motion compensated MB variances.
uint16_t * mb_var
Table for MB variances.
static int ref[MAX_W *MAX_W]
static float mean(const float *input, int size)
int(* cmp_func)(const void *, const void *)
static const uint8_t offset[127][2]