Revision c6c36725

View differences:

libavcodec/motion_est.c
1786 1786
    P_LEFT[1]        = clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift);
1787 1787

  
1788 1788
    /* special case for first line */
1789
    if (!s->first_slice_line) { //FIXME maybe allow this over thread boundary as its cliped
1789
    if (!s->first_slice_line) { //FIXME maybe allow this over thread boundary as its clipped
1790 1790
        P_TOP[0]      = clip(mv_table[mot_xy - mot_stride             ][0], xmin<<shift, xmax<<shift);
1791 1791
        P_TOP[1]      = clip(mv_table[mot_xy - mot_stride             ][1], ymin<<shift, ymax<<shift);
1792 1792
        P_TOPRIGHT[0] = clip(mv_table[mot_xy - mot_stride + 1         ][0], xmin<<shift, xmax<<shift);
libavcodec/motion_est_template.c
515 515
    }\
516 516
}
517 517

  
518
#define CHECK_CLIPED_MV(ax,ay)\
518
#define CHECK_CLIPPED_MV(ax,ay)\
519 519
{\
520 520
    const int Lx= ax;\
521 521
    const int Ly= ay;\
......
678 678
            x= best[0];
679 679
            y= best[1];
680 680
            for(i=0; i<6; i++){
681
                CHECK_CLIPED_MV(x+hex[i][0]*dia_size, y+hex[i][1]*dia_size);
681
                CHECK_CLIPPED_MV(x+hex[i][0]*dia_size, y+hex[i][1]*dia_size);
682 682
            }
683 683
        }while(best[0] != x || best[1] != y);
684 684
    }
......
686 686
    do{
687 687
        x= best[0];
688 688
        y= best[1];
689
        CHECK_CLIPED_MV(x+1, y);
690
        CHECK_CLIPED_MV(x, y+1);
691
        CHECK_CLIPED_MV(x-1, y);
692
        CHECK_CLIPED_MV(x, y-1);
689
        CHECK_CLIPPED_MV(x+1, y);
690
        CHECK_CLIPPED_MV(x, y+1);
691
        CHECK_CLIPPED_MV(x-1, y);
692
        CHECK_CLIPPED_MV(x, y-1);
693 693
    }while(best[0] != x || best[1] != y);
694 694

  
695 695
    return dmin;
......
716 716
            x= best[0];
717 717
            y= best[1];
718 718
            for(i=0; i<8; i++){
719
                CHECK_CLIPED_MV(x+hex[i][0]*dia_size, y+hex[i][1]*dia_size);
719
                CHECK_CLIPPED_MV(x+hex[i][0]*dia_size, y+hex[i][1]*dia_size);
720 720
            }
721 721
        }while(best[0] != x || best[1] != y);
722 722
    }
723 723

  
724 724
    x= best[0];
725 725
    y= best[1];
726
    CHECK_CLIPED_MV(x+1, y);
727
    CHECK_CLIPED_MV(x, y+1);
728
    CHECK_CLIPED_MV(x-1, y);
729
    CHECK_CLIPED_MV(x, y-1);
726
    CHECK_CLIPPED_MV(x+1, y);
727
    CHECK_CLIPPED_MV(x, y+1);
728
    CHECK_CLIPPED_MV(x-1, y);
729
    CHECK_CLIPPED_MV(x, y-1);
730 730

  
731 731
    return dmin;
732 732
}
......
771 771

  
772 772
    for(j=1; j<=dia_size/4; j++){
773 773
        for(i=0; i<16; i++){
774
            CHECK_CLIPED_MV(x+hex[i][0]*j, y+hex[i][1]*j);
774
            CHECK_CLIPPED_MV(x+hex[i][0]*j, y+hex[i][1]*j);
775 775
        }
776 776
    }
777 777

  
......
1021 1021
    /* first line */
1022 1022
    if (s->first_slice_line) {
1023 1023
        CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
1024
        CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1024
        CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1025 1025
                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1026 1026
    }else{
1027 1027
        if(dmin<((h*h*s->avctx->mv0_threshold)>>8)
......
1034 1034
            return dmin;
1035 1035
        }
1036 1036
        CHECK_MV(    P_MEDIAN[0] >>shift ,    P_MEDIAN[1] >>shift)
1037
        CHECK_CLIPED_MV((P_MEDIAN[0]>>shift)  , (P_MEDIAN[1]>>shift)-1)
1038
        CHECK_CLIPED_MV((P_MEDIAN[0]>>shift)  , (P_MEDIAN[1]>>shift)+1)
1039
        CHECK_CLIPED_MV((P_MEDIAN[0]>>shift)-1, (P_MEDIAN[1]>>shift)  )
1040
        CHECK_CLIPED_MV((P_MEDIAN[0]>>shift)+1, (P_MEDIAN[1]>>shift)  )
1041
        CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1037
        CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift)  , (P_MEDIAN[1]>>shift)-1)
1038
        CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift)  , (P_MEDIAN[1]>>shift)+1)
1039
        CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift)-1, (P_MEDIAN[1]>>shift)  )
1040
        CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift)+1, (P_MEDIAN[1]>>shift)  )
1041
        CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1042 1042
                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1043 1043
        CHECK_MV(P_LEFT[0]    >>shift, P_LEFT[1]    >>shift)
1044 1044
        CHECK_MV(P_TOP[0]     >>shift, P_TOP[1]     >>shift)
......
1046 1046
    }
1047 1047
    if(dmin>h*h*4){
1048 1048
        if(c->pre_pass){
1049
            CHECK_CLIPED_MV((last_mv[ref_mv_xy-1][0]*ref_mv_scale + (1<<15))>>16,
1049
            CHECK_CLIPPED_MV((last_mv[ref_mv_xy-1][0]*ref_mv_scale + (1<<15))>>16,
1050 1050
                            (last_mv[ref_mv_xy-1][1]*ref_mv_scale + (1<<15))>>16)
1051 1051
            if(!s->first_slice_line)
1052
                CHECK_CLIPED_MV((last_mv[ref_mv_xy-ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1052
                CHECK_CLIPPED_MV((last_mv[ref_mv_xy-ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1053 1053
                                (last_mv[ref_mv_xy-ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
1054 1054
        }else{
1055
            CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
1055
            CHECK_CLIPPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
1056 1056
                            (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
1057 1057
            if(s->mb_y+1<s->end_mb_y)  //FIXME replace at least with last_slice_line
1058
                CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1058
                CHECK_CLIPPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1059 1059
                                (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
1060 1060
        }
1061 1061
    }
......
1137 1137
    /* first line */
1138 1138
    if (s->first_slice_line) {
1139 1139
        CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
1140
        CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1140
        CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1141 1141
                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1142 1142
        CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
1143 1143
    }else{
......
1147 1147
        CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
1148 1148
        CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
1149 1149
        CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
1150
        CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1150
        CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1151 1151
                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1152 1152
    }
1153 1153
    if(dmin>64*4){
1154
        CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
1154
        CHECK_CLIPPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
1155 1155
                        (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
1156 1156
        if(s->mb_y+1<s->end_mb_y)  //FIXME replace at least with last_slice_line
1157
            CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1157
            CHECK_CLIPPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1158 1158
                            (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
1159 1159
    }
1160 1160

  
......
1197 1197
    /* first line */
1198 1198
    if (s->first_slice_line) {
1199 1199
        CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
1200
        CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1200
        CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1201 1201
                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1202 1202
        CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
1203 1203
    }else{
......
1207 1207
        CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
1208 1208
        CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
1209 1209
        CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
1210
        CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1210
        CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1211 1211
                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1212 1212
    }
1213 1213
    if(dmin>64*4){
1214
        CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
1214
        CHECK_CLIPPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
1215 1215
                        (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
1216 1216
        if(s->mb_y+1<s->end_mb_y)  //FIXME replace at least with last_slice_line
1217
            CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1217
            CHECK_CLIPPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1218 1218
                            (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
1219 1219
    }
1220 1220

  
libavutil/common.h
264 264
 * @param a value to clip
265 265
 * @param amin minimum value of the clip range
266 266
 * @param amax maximum value of the clip range
267
 * @return cliped value
267
 * @return clipped value
268 268
 */
269 269
static inline int clip(int a, int amin, int amax)
270 270
{
......
276 276
/**
277 277
 * clip a signed integer value into the 0-255 range
278 278
 * @param a value to clip
279
 * @return cliped value
279
 * @return clipped value
280 280
 */
281 281
static inline uint8_t clip_uint8(int a)
282 282
{

Also available in: Unified diff