module datainput(DVAL,LVAL,FVAL,in,clk_m,Y_data,C_data); input LVAL; input clk_m; input FVAL; input DVAL; input [23:0] in; output reg [7:0] Y_data,C_data; reg [7:0] POARTA,POARTB; reg [11:0] cnt_lval_low,cnt_lval_high_pix; reg [10:0] LVALcnt; reg [9:0] y1, cr1, cb1; reg [7:0] y,cr,cb; reg [7:0] R,G,B; reg [7:0] Ytmp0,Cbtmp0,Crtmp0; /*------------------------------------------------*/ parameter BLANKC = 8'b10000000; parameter BLANKY = 8'b00010000; parameter BLANKEAV = 8'b10110110; parameter BLANKSAV = 8'b10101011; parameter VALEAV = 8'b10011101; parameter VALSAV = 8'b10000000; parameter DFF = 8'b11111111; parameter D00 = 8'b00000000; /*------------------------------------------------*/ always @ (posedge clk_m ) begin R <= in[23:16]; end always @ (posedge clk_m ) begin G <= in[15:8]; end always @ (posedge clk_m ) begin B <= in[7:0]; end //============================================================== always@(posedge clk_m) begin y1 = (66*R + 129*G + 25*B+4096)>>8; y <= (y1[9:8]==2'b00) ? y1[7:0] : (y1[9]==0) ? 8'b11101011 : y1[9:2]; end //================================================================ always@(posedge clk_m) begin cb1 = (112*B-38*R - 75*G+32768)>>8; cb <= (cb1[9:8]==2'b00) ? cb1[7:0] : (cb1[9]==0) ? 8'b11110000 : cb1[9:2]; end //================================================================ always@(posedge clk_m) begin cr1 = (112*R - 94*G - 18*B+32768)>>8 ; cr <= (cr1[9:8]==2'b00) ? cr1[7:0] : (cr1[9]==0) ? 8'b11110000 : cr1[9:2]; end /*------------------------------------------------*/ /*------------------------------------------------*/ always@(posedge clk_m) begin if(!FVAL) LVALcnt = 0; else if(LVAL) begin cnt_lval_high_pix=cnt_lval_high_pix+1'b1; if(cnt_lval_high_pix==2153) LVALcnt = LVALcnt + 1'b1; end else cnt_lval_high_pix=0; end /*------------------------------------------------*/ always @(posedge clk_m) begin Ytmp0 <= y; Cbtmp0 <=cb; Crtmp0 <=cr; end /*-----------------------------------------------------------------------------------*/ always@(posedge clk_m) begin if( (LVAL) && (LVALcnt == 16)) begin case(cnt_lval_high_pix) 126,2056: begin Y_data<=DFF; C_data<=DFF; end 127,128,2057,2058:begin Y_data<=D00; C_data<=D00; end 129: begin Y_data<=BLANKSAV; C_data<=BLANKSAV; end 2059: begin Y_data<=VALEAV; C_data<=VALEAV; end default: begin Y_data<= BLANKY; C_data<= BLANKC; end endcase end else if((LVAL) && (LVALcnt == 1096)) begin case(cnt_lval_high_pix) 126,2056: begin Y_data<=DFF; C_data<=DFF; end 127,128,2057,2058:begin Y_data<=D00; C_data<=D00; end 129: begin Y_data<=VALSAV; C_data<=VALSAV; end 2059: begin Y_data<=BLANKEAV; C_data<=BLANKEAV; end default: begin Y_data<= BLANKY; C_data<= BLANKC; end endcase end else if((LVAL) && (LVALcnt<=1095)&&(LVALcnt>=17)) begin case(cnt_lval_high_pix) 126,2056: begin Y_data<=DFF; C_data<=DFF; end 127,128,2057,2058:begin Y_data<=D00; C_data<=D00; end 129: begin Y_data<=VALSAV; C_data<=VALSAV; end 2059: begin Y_data<=VALEAV; C_data<=VALEAV; end default: begin Y_data <= Ytmp0; if(!cnt_lval_high_pix[0]) C_data <= Cbtmp0; else C_data <= Crtmp0; end endcase end /*-----------------------------------------------------------------------------------*/ else begin case(cnt_lval_high_pix) 126,2056: begin Y_data<=DFF; C_data<=DFF; end 127,128,2057,2058:begin Y_data<=D00; C_data<=D00; end 129: begin Y_data<=BLANKSAV; C_data<=BLANKSAV; end 2059: begin Y_data<=BLANKEAV; C_data<=BLANKEAV; end default: begin Y_data<= BLANKY; C_data<= BLANKC; end endcase end /*------------------------------------------------*/ end endmodule
先将RGB888转换成YCBCR,再将YCBCR转换成BT1120。
当 cnt_lval_high_pix 计数到2153时,LVAL翻转:
定时基准码插入:
局部放大图: