位移符號錯誤記錄

在進行nv21旋轉的時候遇到將*2替換成<<1時超出數組範圍的錯誤,在此記錄一下

    private static byte[] rote(byte[] nv21, int width, int height) {
        int ySize = width * height;
        byte[] ret = new byte[ySize * 3 >> 1];
        for (int y = 0; y < width; ++y) {
            for (int x = 0; x < height; ++x) {
                ret[y * height + x] = nv21[x * width + width - y];
                ret[ySize + (y >> 1) * height + (x >> 1) * 2] = nv21[ySize + (x >> 1) * width + ((width - y - 1) >> 1) * 2];
                ret[ySize + (y >> 1) * height + (x >> 1) * 2 + 1] = nv21[ySize + (x >> 1) * width + ((width - y - 1) >> 1) * 2 + 1];
            }
        }
        return ret;
    }


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章