⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inter_pred_pipeline.v

📁 a H.264/AVC Baseline Decoder
💻 V
📖 第 1 页 / 共 3 页
字号:
			end		else			yOffsetL <= 0;		reg [2:0] xOffsetC,yOffsetC;	always @ (IsInterChroma or mv_below8x8_curr or blk4x4_rec_counter[0] or Inter_chroma2x2_counter[0])		if (IsInterChroma)			begin				if (mv_below8x8_curr == 1'b0)					xOffsetC <= (blk4x4_rec_counter[0] == 1'b0)? 3'd0:3'd4;				else 					case (blk4x4_rec_counter[0])						1'b0:xOffsetC <= (Inter_chroma2x2_counter[0] == 1'b1)? 3'd0:3'd2;						1'b1:xOffsetC <= (Inter_chroma2x2_counter[0] == 1'b1)? 3'd4:3'd6;					endcase			end		else			xOffsetC <= 0; 				always @ (IsInterChroma or mv_below8x8_curr or blk4x4_rec_counter[1] or Inter_chroma2x2_counter[1])		if (IsInterChroma)			begin				if (mv_below8x8_curr == 1'b0)					yOffsetC <= (blk4x4_rec_counter[1] == 1'b0)? 3'd0:3'd4;				else 					case (blk4x4_rec_counter[1])						1'b0:yOffsetC <= (Inter_chroma2x2_counter[1] == 1'b1)? 3'd0:3'd2;						1'b1:yOffsetC <= (Inter_chroma2x2_counter[1] == 1'b1)? 3'd4:3'd6;					endcase			end		else			yOffsetC <= 3'd0;	//----------------------------------------------------------------------------------------	//Integer position of each left-up-most pixel  of a 8x8/4x4/2x2 blk	//----------------------------------------------------------------------------------------			wire [8:0] xIntL_unclip,yIntL_unclip;	// 2's complement,bit[8] is the sign bit	wire [7:0] xIntC_unclip,yIntC_unclip;	// 2's complement,bit[7] is the sign bit	assign xIntL_unclip = (IsInterLuma)?   ({1'b0,mb_num_h,4'b0} + xOffsetL + {{3{Inter_blk_mvx[7]}},Inter_blk_mvx[7:2]}):0;	assign yIntL_unclip = (IsInterLuma)?   ({1'b0,mb_num_v,4'b0} + yOffsetL + {{3{Inter_blk_mvy[7]}},Inter_blk_mvy[7:2]}):0;	assign xIntC_unclip = (IsInterChroma)? ({1'b0,mb_num_h,3'b0} + xOffsetC + {{3{Inter_blk_mvx[7]}},Inter_blk_mvx[7:3]}):0;	assign yIntC_unclip = (IsInterChroma)? ({1'b0,mb_num_v,3'b0} + yOffsetC + {{3{Inter_blk_mvy[7]}},Inter_blk_mvy[7:3]}):0; 		wire [8:0] xInt_org_unclip;	wire [8:0] yInt_org_unclip;	assign xInt_org_unclip = (IsInterLuma)? xIntL_unclip:{xIntC_unclip[7],xIntC_unclip};	assign yInt_org_unclip = (IsInterLuma)? yIntL_unclip:{yIntC_unclip[7],yIntC_unclip};	assign xInt_org_unclip_1to0 = xInt_org_unclip[1:0];	//----------------------------------------------------------------------------------------	//Fractional motion vector for both luma and chroma	//----------------------------------------------------------------------------------------			wire [3:0] pos_FracL;	wire Is_InterChromaCopy;//If chroma is predicted by direct copy,calculate cycle would reduce							//from 16 cycles to 4 cycles		assign xFracL = (IsInterLuma)?   Inter_blk_mvx[1:0]:0;	assign yFracL = (IsInterLuma)?   Inter_blk_mvy[1:0]:0;	assign xFracC = (IsInterChroma)? Inter_blk_mvx[2:0]:0;	assign yFracC = (IsInterChroma)? Inter_blk_mvy[2:0]:0;	assign pos_FracL = {xFracL,yFracL};	assign Is_InterChromaCopy = (IsInterChroma && xFracC == 0 && yFracC == 0)? 1'b1:1'b0;		//----------------------------------------------------------------------------------------	//Inter prediction step control counter	//---------------------------------------------------------------------------------------- 	//1.Preload integer pels counter	//	If block partition equals 8x8 or above,preload only at first 4x4 block of each 8x8block	//  If block partition is 8x4,4x8 or 4x4,  preload at each 4x4 block	always @ (posedge clk)		if (reset_n == 1'b0)			blk4x4_inter_preload_counter <= 0;		//luma		else if (trigger_blk4x4_inter_pred && IsInterLuma)			begin				if (!mv_below8x8_curr && blk4x4_rec_counter[1:0] == 2'b00)					case (pos_FracL)						`pos_Int                          :blk4x4_inter_preload_counter <= (xInt_org_unclip[1:0] == 2'b00)? 6'd17:6'd25;						`pos_f,`pos_q,`pos_i,`pos_k,`pos_j:blk4x4_inter_preload_counter <= 6'd53;						`pos_d,`pos_h,`pos_n              :blk4x4_inter_preload_counter <= (xInt_org_unclip[1:0] == 2'b00)? 6'd27:6'd40;						`pos_a,`pos_b,`pos_c              :blk4x4_inter_preload_counter <= 6'd33;						`pos_e,`pos_g,`pos_p,`pos_r       :blk4x4_inter_preload_counter <= 6'd49;					endcase				else if (mv_below8x8_curr)	//partition below 8x8block					case (pos_FracL)						`pos_Int						              :blk4x4_inter_preload_counter <= (xInt_org_unclip[1:0] == 2'b00)? 6'd5:6'd9;						`pos_f,`pos_q,`pos_i,`pos_k,`pos_j:blk4x4_inter_preload_counter <= 6'd28;						`pos_d,`pos_h,`pos_n			        :blk4x4_inter_preload_counter <= (xInt_org_unclip[1:0] == 2'b00)? 6'd10:6'd19;						`pos_a,`pos_b,`pos_c			        :blk4x4_inter_preload_counter <= 6'd13;						`pos_e,`pos_g,`pos_p,`pos_r		    :blk4x4_inter_preload_counter <= 6'd24;					endcase				end		//chroma		else if (trigger_blk4x4_inter_pred && IsInterChroma && mv_below8x8_curr == 1'b0)			begin				if (xFracC == 0 && yFracC == 0)					blk4x4_inter_preload_counter <= (xInt_org_unclip[1:0] == 2'b00)? 6'd5:6'd9;				else					blk4x4_inter_preload_counter <= 6'd11;			end		else if (trigger_blk2x2_inter_pred && IsInterChroma && mv_below8x8_curr == 1'b1)			begin				if (xFracC == 0 && yFracC == 0)					blk4x4_inter_preload_counter <= (xInt_org_unclip[1:0] == 2'b11)? 6'd5:6'd3;				else					blk4x4_inter_preload_counter <= (xInt_org_unclip[1]   == 1'b0 )? 6'd4:6'd7;			end		else if (blk4x4_inter_preload_counter != 0)			blk4x4_inter_preload_counter <= blk4x4_inter_preload_counter - 1;			//2.Calculate counter	always @ (posedge clk)		if (reset_n == 1'b0)			blk4x4_inter_calculate_counter <= 0;		//luma		else if (IsInterLuma && ((!mv_below8x8_curr && (										(blk4x4_rec_counter[1:0] == 2'b00 && blk4x4_inter_preload_counter == 1) || 										(blk4x4_rec_counter[1:0] != 2'b00 && trigger_blk4x4_inter_pred))) ||								(mv_below8x8_curr && blk4x4_inter_preload_counter == 1))) 			case (pos_FracL)				`pos_j,`pos_f,`pos_q:blk4x4_inter_calculate_counter <= 4'd5;				`pos_i,`pos_k       :blk4x4_inter_calculate_counter <= 4'd8;				default             :blk4x4_inter_calculate_counter <= 4'd4;			endcase		//chroma		else if (blk4x4_inter_preload_counter == 1 && IsInterChroma == 1'b1)			case (mv_below8x8_curr)				1'b0:blk4x4_inter_calculate_counter <= 4'd4;				1'b1:blk4x4_inter_calculate_counter <= 4'd1;			endcase		else if (blk4x4_inter_calculate_counter != 0)			blk4x4_inter_calculate_counter <= blk4x4_inter_calculate_counter - 1;		assign end_of_one_blk4x4_inter = (blk4x4_inter_calculate_counter == 4'd1 &&	((IsInterChroma && mv_below8x8_curr && Inter_chroma2x2_counter == 2'b00) ||	!(IsInterChroma && mv_below8x8_curr)));	//----------------------------------------------------------------------------------------	//Inter prediction reference frame RAM read control	//----------------------------------------------------------------------------------------	assign ref_frame_RAM_rd = ((IsInterLuma || IsInterChroma) && blk4x4_inter_preload_counter != 6'd0 && blk4x4_inter_preload_counter != 6'd1);		//compared with blk4x4_inter_preload_counter,blk4x4_inter_preload_counter_m2 has some advantages	//during some pos_FracL for vertical memory address decoding	wire [5:0] blk4x4_inter_preload_counter_m2;		assign blk4x4_inter_preload_counter_m2 = (blk4x4_inter_preload_counter == 6'd0 || blk4x4_inter_preload_counter == 6'd1)?												6'd0:(blk4x4_inter_preload_counter - 2);					//xInt_curr_offset: offset from the left-upper most pixel of current block,ranging -2 ~ +10.	//After each preload cycle,xInt_curr_offset will increase 4	reg [4:0] xInt_curr_offset;	always @ (IsInterLuma or mv_below8x8_curr or pos_FracL or xFracC or yFracC 		or xInt_org_unclip[1:0] or blk4x4_inter_preload_counter_m2 or blk4x4_inter_preload_counter)		if (blk4x4_inter_preload_counter != 6'd0 && blk4x4_inter_preload_counter != 6'd1)			begin				if (IsInterLuma)					begin						if (!mv_below8x8_curr)							case (pos_FracL)								`pos_f,`pos_q,`pos_i,`pos_k,`pos_j:								case (blk4x4_inter_preload_counter_m2[1:0])									2'b00:xInt_curr_offset <= 5'b01010; //+10									2'b01:xInt_curr_offset <= 5'b00110; //+6									2'b10:xInt_curr_offset <= 5'b00010; //+2									2'b11:xInt_curr_offset <= 5'b11110; //-2								endcase								`pos_d,`pos_h,`pos_n:								if (xInt_org_unclip[1:0] == 2'b00)									xInt_curr_offset <= (blk4x4_inter_preload_counter_m2[0])? 4'b0:4'b0100; //+0 or +4								else									case (blk4x4_inter_preload_counter_m2)										6'd38,6'd35,6'd32,6'd29,6'd26,6'd23,6'd20,6'd17,6'd14,6'd11,6'd8,6'd5,6'd2:										xInt_curr_offset <= 5'b0; 			//+0										6'd37,6'd34,6'd31,6'd28,6'd25,6'd22,6'd19,6'd16,6'd13,6'd10,6'd7,6'd4,6'd1:										xInt_curr_offset <= 5'b00100;		//+4										default:xInt_curr_offset <= 5'b01000;//+8									endcase								`pos_a,`pos_b,`pos_c:								case (blk4x4_inter_preload_counter_m2[1:0])									2'b00:xInt_curr_offset <= 5'b01010; //+10									2'b01:xInt_curr_offset <= 5'b00110; //+6									2'b10:xInt_curr_offset <= 5'b00010; //+2									2'b11:xInt_curr_offset <= 5'b11110; //-2								endcase								`pos_Int:								if (xInt_org_unclip[1:0] == 2'b00)									xInt_curr_offset <= (blk4x4_inter_preload_counter_m2[0])? 5'b0:5'b0100; //+0 or +4								else									case (blk4x4_inter_preload_counter_m2)										6'd23,6'd20,6'd17,6'd14,6'd11,6'd8,6'd5,6'd2:										xInt_curr_offset <= 5'b00000;	   	//+0										6'd22,6'd19,6'd16,6'd13,6'd10,6'd7,6'd4,6'd1:										xInt_curr_offset <= 5'b00100;	   	//+4										default:xInt_curr_offset <= 5'b01000;//+8									endcase								`pos_e,`pos_g,`pos_p,`pos_r:								case (blk4x4_inter_preload_counter_m2)									6'd47,6'd44,6'd5,6'd2:									xInt_curr_offset <= 5'b00000;	//+0									6'd46,6'd43,6'd4,6'd1:									xInt_curr_offset <= 5'b00100;	//+4									6'd45,6'd42,6'd3,6'd0:									xInt_curr_offset <= 5'b01000;	//+8									default:									case (blk4x4_inter_preload_counter_m2[1:0])										2'b00:xInt_curr_offset <= 5'b00010; //+2										2'b01:xInt_curr_offset <= 5'b11110; //-2										2'b10:xInt_curr_offset <= 5'b01010; //+10										2'b11:xInt_curr_offset <= 5'b00110; //+6									endcase								endcase							endcase						else		//block partition below 8x8							case (pos_FracL)								`pos_f,`pos_q,`pos_i,`pos_k,`pos_j:								case (blk4x4_inter_preload_counter_m2)									6'd26,6'd23,6'd20,6'd17,6'd14,6'd11,6'd8,6'd5,6'd2:xInt_curr_offset <= 5'b11110;//-2									6'd25,6'd22,6'd19,6'd16,6'd13,6'd10,6'd7,6'd4,6'd1:xInt_curr_offset <= 5'b00010;//+2									default:xInt_curr_offset <= 5'b00110;											//+6								endcase								`pos_d,`pos_h,`pos_n:								if (xInt_org_unclip[1:0] == 2'b00)									xInt_curr_offset <= 5'b0;	//+0								else									xInt_curr_offset <= (blk4x4_inter_preload_counter_m2[0])? 5'b0:5'b00100;//+0 or +4								`pos_a,`pos_b,`pos_c:								case (blk4x4_inter_preload_counter_m2)									6'd11,6'd8,6'd5,6'd2:xInt_curr_offset <= 5'b11110;	//-2									6'd10,6'd7,6'd4,6'd1:xInt_curr_offset <= 5'b00010;	//+2									default:xInt_curr_offset <= 5'b00110;				//+6								endcase								`pos_Int:								if (xInt_org_unclip[1:0] == 2'b00)									xInt_curr_offset <= 5'b0;	//+0								else									xInt_curr_offset <= (blk4x4_inter_preload_counter_m2[0])? 5'b0:5'b00100;	//+0 or +4								`pos_e,`pos_g,`pos_p,`pos_r:								case (blk4x4_inter_preload_counter_m2)									6'd22,6'd20,6'd3,6'd1:xInt_curr_offset <= 5'b0;			//+0										6'd21,6'd19,6'd2,6'd0:xInt_curr_offset <= 5'b00100;		//+4 									6'd18,6'd15,6'd12,6'd9,6'd6:xInt_curr_offset <= 5'b11110;//-2									6'd17,6'd14,6'd11,6'd8,6'd5:xInt_curr_offset <= 5'b00010;//+2									6'd16,6'd13,6'd10,6'd7,6'd4:xInt_curr_offset <= 5'b00110;//+6									default:xInt_curr_offset <= 5'b0;								endcase							endcase					end				else	//IsInterChroma					begin						if (!mv_below8x8_curr)							begin								if (xFracC == 0 && yFracC == 0)									begin										if (xInt_org_unclip[1:0] == 2'b00)											xInt_curr_offset <= 5'b0;										else											xInt_curr_offset <= (blk4x4_inter_preload_counter_m2[0] == 1'b1)? 5'b0:5'b0100;									end								else									xInt_curr_offset <= (blk4x4_inter_preload_counter_m2[0] == 1'b1)? 5'b0:5'b0100;							end						else //mv_below8x8_curr == 1'b1							begin								if (xFracC == 0 && yFracC == 0)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -