fix offset bug
This commit is contained in:
		@@ -66,9 +66,9 @@ module crop #(
 | 
			
		||||
                        end
 | 
			
		||||
                    end
 | 
			
		||||
 | 
			
		||||
                    if (cnt_x >= IN_WIDTH - 1) begin
 | 
			
		||||
                    if (cnt_x >= IN_WIDTH - 3) begin
 | 
			
		||||
                        cnt_x <= 0;
 | 
			
		||||
                        if (cnt_y >= IN_HEIGHT - 1) begin
 | 
			
		||||
                        if (cnt_y >= IN_HEIGHT - 3) begin
 | 
			
		||||
                            cnt_y <= 0;
 | 
			
		||||
                        end
 | 
			
		||||
                        else begin
 | 
			
		||||
 
 | 
			
		||||
@@ -154,12 +154,17 @@ module demosaic2 #(
 | 
			
		||||
                            pos_y <= 0;
 | 
			
		||||
                        end
 | 
			
		||||
                        // 换行后切换Bayer格式
 | 
			
		||||
                        case (RAW_TYPE)
 | 
			
		||||
                            0: raw_type <= 2;
 | 
			
		||||
                            1: raw_type <= 3;
 | 
			
		||||
                            2: raw_type <= 0;
 | 
			
		||||
                            3: raw_type <= 1;
 | 
			
		||||
                        endcase
 | 
			
		||||
                        if (pos_y % 2 == 1) begin
 | 
			
		||||
                            raw_type <= RAW_TYPE;
 | 
			
		||||
                        end
 | 
			
		||||
                        else begin
 | 
			
		||||
                            case (RAW_TYPE)
 | 
			
		||||
                                0: raw_type <= 2;
 | 
			
		||||
                                1: raw_type <= 3;
 | 
			
		||||
                                2: raw_type <= 0;
 | 
			
		||||
                                3: raw_type <= 1;
 | 
			
		||||
                            endcase
 | 
			
		||||
                        end
 | 
			
		||||
                    end
 | 
			
		||||
                    else begin
 | 
			
		||||
                        cnt_data <= 2;
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ module chanels_to_RGB #(
 | 
			
		||||
    localparam SEND_DATA = 1;
 | 
			
		||||
 | 
			
		||||
    reg [1:0] state, nextState;
 | 
			
		||||
    reg [31:0] data_cal [2:0]; // 用于保存运算结果,防止溢出
 | 
			
		||||
    reg [15:0] data_cal [2:0]; // 用于保存运算结果,防止溢出
 | 
			
		||||
    reg fifo_en;
 | 
			
		||||
    reg [3 * OUT_DEPTH - 1:0] fifo_in; // 输入fifo中缓存
 | 
			
		||||
    wire fifo_empty, fifo_que;
 | 
			
		||||
@@ -56,9 +56,9 @@ module chanels_to_RGB #(
 | 
			
		||||
                    fifo_en <= 0;
 | 
			
		||||
 | 
			
		||||
                    if (in_en) begin
 | 
			
		||||
                        data_cal[0] <= data_in[0] * OUT_DEPTH / IN_DEPTH;
 | 
			
		||||
                        data_cal[1] <= data_in[1] * OUT_DEPTH / IN_DEPTH;
 | 
			
		||||
                        data_cal[2] <= data_in[2] * OUT_DEPTH / IN_DEPTH;
 | 
			
		||||
                        data_cal[0] <= data_in[0] >> (IN_DEPTH - OUT_DEPTH);
 | 
			
		||||
                        data_cal[1] <= data_in[1] >> (IN_DEPTH - OUT_DEPTH);
 | 
			
		||||
                        data_cal[2] <= data_in[2] >> (IN_DEPTH - OUT_DEPTH);
 | 
			
		||||
 | 
			
		||||
                    end
 | 
			
		||||
                end 
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,8 @@ const int IN_SIZE = IN_WIDTH * IN_HEIGHT;
 | 
			
		||||
const int OUT_WIDTH = 1280;
 | 
			
		||||
const int OUT_HEIGHT = 720;
 | 
			
		||||
const int OUT_SIZE = OUT_WIDTH * OUT_HEIGHT;
 | 
			
		||||
const int RAW_TYPE = 3;
 | 
			
		||||
const int RAW_TYPE = 1;
 | 
			
		||||
const int COLOR_DEPTH = 10;
 | 
			
		||||
 | 
			
		||||
int main() {
 | 
			
		||||
    std::ifstream in_image;
 | 
			
		||||
@@ -22,7 +23,7 @@ int main() {
 | 
			
		||||
            uint8_t buf[2] = {0};
 | 
			
		||||
            in_image.read((char*)buf, sizeof(buf));
 | 
			
		||||
 | 
			
		||||
            image[y][x] = buf[0] + (buf[1] << 8);
 | 
			
		||||
            image[y][x] = buf[0] + ((uint16_t)buf[1] << 8);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    int raw_type = RAW_TYPE;
 | 
			
		||||
@@ -91,12 +92,9 @@ int main() {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            // data[index + 0] = red * 8 / 12;    // R
 | 
			
		||||
            data[index + 1] = green * 8 / 12;  // G
 | 
			
		||||
            // data[index + 2] = blue * 8 / 12;   // B
 | 
			
		||||
            data[index + 0] = 0;    // R
 | 
			
		||||
            // data[index + 1] = 0;  // G
 | 
			
		||||
            data[index + 2] = 0;   // B
 | 
			
		||||
            data[index + 0] = red >> (COLOR_DEPTH - 8);    // R
 | 
			
		||||
            data[index + 1] = green  >> (COLOR_DEPTH - 8);  // G
 | 
			
		||||
            data[index + 2] = blue  >> (COLOR_DEPTH - 8);   // B
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (y % 2) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user