- int xy, wrap;
- int16_t *A, *B, *C, *mot_val;
- static const int off[4]= {2, 1, 1, -1};
-
- wrap = s->block_wrap[0];
- xy = s->block_index[block];
-
- mot_val = s->current_picture.motion_val[0][xy];
-
- A = s->current_picture.motion_val[0][xy - 1];
- /* special case for first (slice) line */
- if (s->first_slice_line && block<3) {
- // we cant just change some MVs to simulate that as we need them for the B frames (and ME)
- // and if we ever support non rectangular objects than we need to do a few ifs here anyway :(
- if(block==0){ //most common case
- if(s->mb_x == s->resync_mb_x){ //rare
- *px= *py = 0;
- }else if(s->mb_x + 1 == s->resync_mb_x && s->h263_pred){ //rare
- C = s->current_picture.motion_val[0][xy + off[block] - wrap];
- if(s->mb_x==0){
- *px = C[0];
- *py = C[1];
- }else{
- *px = mid_pred(A[0], 0, C[0]);
- *py = mid_pred(A[1], 0, C[1]);
- }
- }else{
- *px = A[0];
- *py = A[1];
- }
- }else if(block==1){
- if(s->mb_x + 1 == s->resync_mb_x && s->h263_pred){ //rare
- C = s->current_picture.motion_val[0][xy + off[block] - wrap];
- *px = mid_pred(A[0], 0, C[0]);
- *py = mid_pred(A[1], 0, C[1]);
- }else{
- *px = A[0];
- *py = A[1];
- }
- }else{ /* block==2*/
- B = s->current_picture.motion_val[0][xy - wrap];
- C = s->current_picture.motion_val[0][xy + off[block] - wrap];
- if(s->mb_x == s->resync_mb_x) //rare
- A[0]=A[1]=0;
-
- *px = mid_pred(A[0], B[0], C[0]);
- *py = mid_pred(A[1], B[1], C[1]);
- }
- } else {
- B = s->current_picture.motion_val[0][xy - wrap];
- C = s->current_picture.motion_val[0][xy + off[block] - wrap];
- *px = mid_pred(A[0], B[0], C[0]);
- *py = mid_pred(A[1], B[1], C[1]);
- }
- return mot_val;
-}
-
-// identical to above but with s->current_picture->motion_val, the above one will be removed, and this renamed to it
-int16_t *h263_pred_motion2(MpegEncContext * s, int block, int dir,
- int *px, int *py)
-{
- int xy, wrap;