src/main/java/org/jcodec/codecs/h264/decode/BlockInterpolator.java
static void getLuma20UnsafeNoRound(byte[] pic, int picW, int picH, int[] blk, int blkOff, int blkStride, int x,
            int y, int blkW, int blkH) {
        int maxW = picW - 1;
        int maxH = picH - 1;

        for (int i = 0; i < blkW; i++) {
            int ipos_m2 = clip(x + i - 2, 0, maxW);
            int ipos_m1 = clip(x + i - 1, 0, maxW);
            int ipos = clip(x + i, 0, maxW);
            int ipos_p1 = clip(x + i + 1, 0, maxW);
            int ipos_p2 = clip(x + i + 2, 0, maxW);
            int ipos_p3 = clip(x + i + 3, 0, maxW);

            int boff = blkOff;
            for (int j = 0; j < blkH; j++) {
                int lineStart = clip(j + y, 0, maxH) * picW;

                int a = pic[lineStart + ipos_m2] + pic[lineStart + ipos_p3];
                int b = pic[lineStart + ipos_m1] + pic[lineStart + ipos_p2];
                int c = pic[lineStart + ipos] + pic[lineStart + ipos_p1];

                blk[boff + i] = a + 5 * ((c << 2) - b);

                boff += blkStride;
            }
        }
    }
static void getLuma20UnsafeNoRound(byte[] pic, int picW, int picH, int[] blk, int blkOff, int blkStride, int x,
            int y, int blkW, int blkH) {
        int maxW = picW - 1;
        int maxH = picH - 1;

        for (int i = 0; i < blkW; i++) {
            int ipos_m2 = clip(x + i - 2, 0, maxW);
            int ipos_m1 = clip(x + i - 1, 0, maxW);
            int ipos = clip(x + i, 0, maxW);
            int ipos_p1 = clip(x + i + 1, 0, maxW);
            int ipos_p2 = clip(x + i + 2, 0, maxW);
            int ipos_p3 = clip(x + i + 3, 0, maxW);

            int boff = blkOff;
            for (int j = 0; j < blkH; j++) {
                int lineStart = clip(j + y, 0, maxH) * picW;

                int a = pic[lineStart + ipos_m2] + pic[lineStart + ipos_p3];
                int b = pic[lineStart + ipos_m1] + pic[lineStart + ipos_p2];
                int c = pic[lineStart + ipos] + pic[lineStart + ipos_p1];

                blk[boff + i] = a + 5 * ((c << 2) - b);

                boff += blkStride;
            }
        }
    }
static void getLuma20UnsafeNoRound ( byte [ ] pic , int picW , int picH , int [ ] blk , int blkOff , int blkStride , int x , int y , int blkW , int blkH ) { int maxW = picW - 1 ; int maxH = picH - 1 ; for ( int i = 0 ; i < blkW ; i ++ ) { int ipos_m2 = clip ( x + i - 2 , 0 , maxW ) ; int ipos_m1 = clip ( x + i - 1 , 0 , maxW ) ; int ipos = clip ( x + i , 0 , maxW ) ; int ipos_p1 = clip ( x + i + 1 , 0 , maxW ) ; int ipos_p2 = clip ( x + i + 2 , 0 , maxW ) ; int ipos_p3 = clip ( x + i + 3 , 0 , maxW ) ; int boff = blkOff ; for ( int j = 0 ; j < blkH ; j ++ ) { int lineStart = clip ( j + y , 0 , maxH ) * picW ; int a = pic [ lineStart + ipos_m2 ] + pic [ lineStart + ipos_p3 ] ; int b = pic [ lineStart + ipos_m1 ] + pic [ lineStart + ipos_p2 ] ; int c = pic [ lineStart + ipos ] + pic [ lineStart + ipos_p1 ] ; blk [ boff + i ] = a + 5 * ( ( c << 2 ) - b ) ; boff += blkStride ; } } }
Halfpel (2, 0) horizontal unsafe
Halfpel ( 2 0 ) horizontal unsafe