// The MIT License
|
// The MIT License
|
|
|
// Copyright (c) 2006-2007 Massachusetts Institute of Technology
|
// Copyright (c) 2006-2007 Massachusetts Institute of Technology
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
// in the Software without restriction, including without limitation the rights
|
// in the Software without restriction, including without limitation the rights
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
// copies of the Software, and to permit persons to whom the Software is
|
// copies of the Software, and to permit persons to whom the Software is
|
// furnished to do so, subject to the following conditions:
|
// furnished to do so, subject to the following conditions:
|
|
|
// The above copyright notice and this permission notice shall be included in
|
// The above copyright notice and this permission notice shall be included in
|
// all copies or substantial portions of the Software.
|
// all copies or substantial portions of the Software.
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// THE SOFTWARE.
|
// THE SOFTWARE.
|
//**********************************************************************
|
//**********************************************************************
|
// Deblocking Filter
|
// Deblocking Filter
|
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
//
|
//
|
//
|
//
|
|
|
package mkDeblockFilter;
|
package mkDeblockFilter;
|
|
|
import H264Types::*;
|
import H264Types::*;
|
|
|
import IDeblockFilter::*;
|
import IDeblockFilter::*;
|
import FIFO::*;
|
import FIFO::*;
|
import Vector::*;
|
import Vector::*;
|
|
|
import Connectable::*;
|
import Connectable::*;
|
import GetPut::*;
|
import GetPut::*;
|
import ClientServer::*;
|
import ClientServer::*;
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Local Datatypes
|
// Local Datatypes
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
|
|
|
|
typedef union tagged
|
typedef union tagged
|
{
|
{
|
void Passing; //not working on anything in particular
|
void Passing; //not working on anything in particular
|
void Initialize;
|
void Initialize;
|
void Horizontal;
|
void Horizontal;
|
void Vertical;
|
void Vertical;
|
void Cleanup;
|
void Cleanup;
|
}
|
}
|
Process deriving(Eq,Bits);
|
Process deriving(Eq,Bits);
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Helper functions
|
// Helper functions
|
|
|
|
|
function Bit#(8) absdiff8(Bit#(8) in0, Bit#(8) in1);
|
function Bit#(8) absdiff8(Bit#(8) in0, Bit#(8) in1);
|
return (in1>=in0 ? in1-in0 : in0-in1);
|
return (in1>=in0 ? in1-in0 : in0-in1);
|
endfunction
|
endfunction
|
|
|
|
|
function Bool filter_test(Bit#(32) in_pixels, Bit#(8) alpha, Bit#(5) beta);
|
function Bool filter_test(Bit#(32) in_pixels, Bit#(8) alpha, Bit#(5) beta);
|
Bit#(8) p1 = in_pixels[7:0];
|
Bit#(8) p1 = in_pixels[7:0];
|
Bit#(8) p0 = in_pixels[15:8];
|
Bit#(8) p0 = in_pixels[15:8];
|
Bit#(8) q0 = in_pixels[23:16];
|
Bit#(8) q0 = in_pixels[23:16];
|
Bit#(8) q1 = in_pixels[31:24];
|
Bit#(8) q1 = in_pixels[31:24];
|
return((absdiff8(p0,q0) < alpha) &&
|
return((absdiff8(p0,q0) < alpha) &&
|
(absdiff8(p0,p1) < zeroExtend(beta)) &&
|
(absdiff8(p0,p1) < zeroExtend(beta)) &&
|
(absdiff8(q0,q1) < zeroExtend(beta)));
|
(absdiff8(q0,q1) < zeroExtend(beta)));
|
endfunction
|
endfunction
|
|
|
|
|
function Bit#(6) clip3symmetric9to6(Bit#(9) val, Bit#(5) bound);
|
function Bit#(6) clip3symmetric9to6(Bit#(9) val, Bit#(5) bound);
|
Int#(9) intval = unpack(val);
|
Int#(9) intval = unpack(val);
|
Int#(6) intbound = unpack({1'b0,bound});
|
Int#(6) intbound = unpack({1'b0,bound});
|
Int#(6) intout = (intvalsignExtend(intbound) ? intbound : truncate(intval)));
|
Int#(6) intout = (intvalsignExtend(intbound) ? intbound : truncate(intval)));
|
return pack(intout);
|
return pack(intout);
|
endfunction
|
endfunction
|
|
|
|
|
function Bit#(64) filter_input(Bit#(64) in_pixels, Bool chroma_flag, Bit#(3) bs, Bit#(8) alpha, Bit#(5) beta, Vector#(3,Bit#(5)) tc0_vector);
|
function Bit#(64) filter_input(Bit#(64) in_pixels, Bool chroma_flag, Bit#(3) bs, Bit#(8) alpha, Bit#(5) beta, Vector#(3,Bit#(5)) tc0_vector);
|
Bit#(8) p[4];
|
Bit#(8) p[4];
|
Bit#(8) q[4];
|
Bit#(8) q[4];
|
p[3] = in_pixels[7:0];
|
p[3] = in_pixels[7:0];
|
p[2] = in_pixels[15:8];
|
p[2] = in_pixels[15:8];
|
p[1] = in_pixels[23:16];
|
p[1] = in_pixels[23:16];
|
p[0] = in_pixels[31:24];
|
p[0] = in_pixels[31:24];
|
q[0] = in_pixels[39:32];
|
q[0] = in_pixels[39:32];
|
q[1] = in_pixels[47:40];
|
q[1] = in_pixels[47:40];
|
q[2] = in_pixels[55:48];
|
q[2] = in_pixels[55:48];
|
q[3] = in_pixels[63:56];
|
q[3] = in_pixels[63:56];
|
Bit#(8) p_out[4];
|
Bit#(8) p_out[4];
|
Bit#(8) q_out[4];
|
Bit#(8) q_out[4];
|
Bool a_p_test = absdiff8(p[2],p[0]) < zeroExtend(beta);
|
Bool a_p_test = absdiff8(p[2],p[0]) < zeroExtend(beta);
|
Bool a_q_test = absdiff8(q[2],q[0]) < zeroExtend(beta);
|
Bool a_q_test = absdiff8(q[2],q[0]) < zeroExtend(beta);
|
Bit#(9) p0q0 = zeroExtend(p[0])+zeroExtend(q[0]);
|
Bit#(9) p0q0 = zeroExtend(p[0])+zeroExtend(q[0]);
|
if (bs == 4)
|
if (bs == 4)
|
begin
|
begin
|
Bool small_gap_test = absdiff8(p[0],q[0]) < (alpha >> 2)+2;
|
Bool small_gap_test = absdiff8(p[0],q[0]) < (alpha >> 2)+2;
|
Bit#(11) p_outtemp[3];
|
Bit#(11) p_outtemp[3];
|
Bit#(11) q_outtemp[3];
|
Bit#(11) q_outtemp[3];
|
if (!chroma_flag && a_p_test && small_gap_test)
|
if (!chroma_flag && a_p_test && small_gap_test)
|
begin
|
begin
|
Bit#(11) sum = zeroExtend(p[1])+zeroExtend(p0q0);
|
Bit#(11) sum = zeroExtend(p[1])+zeroExtend(p0q0);
|
p_outtemp[0] = (zeroExtend(p[2]) + (sum<<1) + zeroExtend(q[1]) + 4) >> 3;
|
p_outtemp[0] = (zeroExtend(p[2]) + (sum<<1) + zeroExtend(q[1]) + 4) >> 3;
|
p_outtemp[1] = (zeroExtend(p[2]) + sum + 2) >> 2;
|
p_outtemp[1] = (zeroExtend(p[2]) + sum + 2) >> 2;
|
p_outtemp[2] = (((zeroExtend(p[3])+zeroExtend(p[2]))<<1) + zeroExtend(p[2]) + sum + 4) >> 3;
|
p_outtemp[2] = (((zeroExtend(p[3])+zeroExtend(p[2]))<<1) + zeroExtend(p[2]) + sum + 4) >> 3;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
p_outtemp[0] = ((zeroExtend(p[1])<<1) + zeroExtend(p[0]) + zeroExtend(q[1]) + 2) >> 2;
|
p_outtemp[0] = ((zeroExtend(p[1])<<1) + zeroExtend(p[0]) + zeroExtend(q[1]) + 2) >> 2;
|
p_outtemp[1] = zeroExtend(p[1]);
|
p_outtemp[1] = zeroExtend(p[1]);
|
p_outtemp[2] = zeroExtend(p[2]);
|
p_outtemp[2] = zeroExtend(p[2]);
|
end
|
end
|
if (!chroma_flag && a_q_test && small_gap_test)
|
if (!chroma_flag && a_q_test && small_gap_test)
|
begin
|
begin
|
Bit#(11) sum = zeroExtend(q[1])+zeroExtend(p0q0);
|
Bit#(11) sum = zeroExtend(q[1])+zeroExtend(p0q0);
|
q_outtemp[0] = (zeroExtend(p[1]) + (sum<<1) + zeroExtend(q[2]) + 4) >> 3;
|
q_outtemp[0] = (zeroExtend(p[1]) + (sum<<1) + zeroExtend(q[2]) + 4) >> 3;
|
q_outtemp[1] = (zeroExtend(q[2]) + sum + 2) >> 2;
|
q_outtemp[1] = (zeroExtend(q[2]) + sum + 2) >> 2;
|
q_outtemp[2] = (((zeroExtend(q[3])+zeroExtend(q[2]))<<1) + zeroExtend(q[2]) + sum + 4) >> 3;
|
q_outtemp[2] = (((zeroExtend(q[3])+zeroExtend(q[2]))<<1) + zeroExtend(q[2]) + sum + 4) >> 3;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
q_outtemp[0] = ((zeroExtend(q[1])<<1) + zeroExtend(q[0]) + zeroExtend(p[1]) + 2) >> 2;
|
q_outtemp[0] = ((zeroExtend(q[1])<<1) + zeroExtend(q[0]) + zeroExtend(p[1]) + 2) >> 2;
|
q_outtemp[1] = zeroExtend(q[1]);
|
q_outtemp[1] = zeroExtend(q[1]);
|
q_outtemp[2] = zeroExtend(q[2]);
|
q_outtemp[2] = zeroExtend(q[2]);
|
end
|
end
|
p_out[0] = truncate(p_outtemp[0]);
|
p_out[0] = truncate(p_outtemp[0]);
|
p_out[1] = truncate(p_outtemp[1]);
|
p_out[1] = truncate(p_outtemp[1]);
|
p_out[2] = truncate(p_outtemp[2]);
|
p_out[2] = truncate(p_outtemp[2]);
|
q_out[0] = truncate(q_outtemp[0]);
|
q_out[0] = truncate(q_outtemp[0]);
|
q_out[1] = truncate(q_outtemp[1]);
|
q_out[1] = truncate(q_outtemp[1]);
|
q_out[2] = truncate(q_outtemp[2]);
|
q_out[2] = truncate(q_outtemp[2]);
|
end
|
end
|
else if(bs > 0)
|
else if(bs > 0)
|
begin
|
begin
|
Bit#(5) t_c0 = tc0_vector[bs-1];
|
Bit#(5) t_c0 = tc0_vector[bs-1];
|
Bit#(5) t_c = chroma_flag ? t_c0+1 : t_c0 + (a_p_test ? 1:0) + (a_q_test ? 1:0);
|
Bit#(5) t_c = chroma_flag ? t_c0+1 : t_c0 + (a_p_test ? 1:0) + (a_q_test ? 1:0);
|
Bit#(12) deltatemp = (((zeroExtend(q[0])-zeroExtend(p[0]))<<2)+zeroExtend(p[1])-zeroExtend(q[1])+4);
|
Bit#(12) deltatemp = (((zeroExtend(q[0])-zeroExtend(p[0]))<<2)+zeroExtend(p[1])-zeroExtend(q[1])+4);
|
Bit#(6) delta = clip3symmetric9to6(deltatemp[11:3],t_c);
|
Bit#(6) delta = clip3symmetric9to6(deltatemp[11:3],t_c);
|
|
|
Bit#(10) p_out0temp = zeroExtend(p[0]) + signExtend(delta);
|
Bit#(10) p_out0temp = zeroExtend(p[0]) + signExtend(delta);
|
p_out[0] = (p_out0temp[9]==1 ? 0 : (p_out0temp[8]==1 ? 255 : p_out0temp[7:0]));
|
p_out[0] = (p_out0temp[9]==1 ? 0 : (p_out0temp[8]==1 ? 255 : p_out0temp[7:0]));
|
Bit#(10) q_out0temp = zeroExtend(q[0]) - signExtend(delta);
|
Bit#(10) q_out0temp = zeroExtend(q[0]) - signExtend(delta);
|
q_out[0] = (q_out0temp[9]==1 ? 0 : (q_out0temp[8]==1 ? 255 : q_out0temp[7:0]));
|
q_out[0] = (q_out0temp[9]==1 ? 0 : (q_out0temp[8]==1 ? 255 : q_out0temp[7:0]));
|
|
|
Bit#(9) p0q0PLUS1 = p0q0+1;
|
Bit#(9) p0q0PLUS1 = p0q0+1;
|
Bit#(8) p0q0_av = p0q0PLUS1[8:1];
|
Bit#(8) p0q0_av = p0q0PLUS1[8:1];
|
if (!chroma_flag && a_p_test)
|
if (!chroma_flag && a_p_test)
|
begin
|
begin
|
Bit#(10) p_out1temp = zeroExtend(p[2]) + zeroExtend(p0q0_av) - (zeroExtend(p[1])<<1);
|
Bit#(10) p_out1temp = zeroExtend(p[2]) + zeroExtend(p0q0_av) - (zeroExtend(p[1])<<1);
|
p_out[1] = p[1]+signExtend(clip3symmetric9to6(p_out1temp[9:1],t_c0));
|
p_out[1] = p[1]+signExtend(clip3symmetric9to6(p_out1temp[9:1],t_c0));
|
end
|
end
|
else
|
else
|
p_out[1] = p[1];
|
p_out[1] = p[1];
|
|
|
if (!chroma_flag && a_q_test)
|
if (!chroma_flag && a_q_test)
|
begin
|
begin
|
Bit#(10) q_out1temp = zeroExtend(q[2]) + zeroExtend(p0q0_av) - (zeroExtend(q[1])<<1);
|
Bit#(10) q_out1temp = zeroExtend(q[2]) + zeroExtend(p0q0_av) - (zeroExtend(q[1])<<1);
|
q_out[1] = q[1]+signExtend(clip3symmetric9to6(q_out1temp[9:1],t_c0));
|
q_out[1] = q[1]+signExtend(clip3symmetric9to6(q_out1temp[9:1],t_c0));
|
end
|
end
|
else
|
else
|
q_out[1] = q[1];
|
q_out[1] = q[1];
|
|
|
p_out[2] = p[2];
|
p_out[2] = p[2];
|
q_out[2] = q[2];
|
q_out[2] = q[2];
|
end
|
end
|
else
|
else
|
begin
|
begin
|
p_out[0] = p[0];
|
p_out[0] = p[0];
|
q_out[0] = q[0];
|
q_out[0] = q[0];
|
p_out[1] = p[1];
|
p_out[1] = p[1];
|
q_out[1] = q[1];
|
q_out[1] = q[1];
|
p_out[2] = p[2];
|
p_out[2] = p[2];
|
q_out[2] = q[2];
|
q_out[2] = q[2];
|
end
|
end
|
p_out[3] = p[3];
|
p_out[3] = p[3];
|
q_out[3] = q[3];
|
q_out[3] = q[3];
|
return({q_out[3], q_out[2], q_out[1], q_out[0], p_out[0], p_out[1], p_out[2], p_out[3]});
|
return({q_out[3], q_out[2], q_out[1], q_out[0], p_out[0], p_out[1], p_out[2], p_out[3]});
|
endfunction
|
endfunction
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Deblocking Filter Module
|
// Deblocking Filter Module
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
|
|
|
|
(* synthesize *)
|
(* synthesize *)
|
module mkDeblockFilter( IDeblockFilter );
|
module mkDeblockFilter( IDeblockFilter );
|
|
|
FIFO#(EntropyDecOT) infifo <- mkSizedFIFO(deblockFilter_infifo_size);
|
FIFO#(EntropyDecOT) infifo <- mkSizedFIFO(deblockFilter_infifo_size);
|
FIFO#(DeblockFilterOT) outfifo <- mkFIFO();
|
FIFO#(DeblockFilterOT) outfifo <- mkFIFO();
|
|
|
FIFO#(MemReq#(TAdd#(PicWidthSz,5),32)) dataMemReqQ <- mkFIFO;
|
FIFO#(MemReq#(TAdd#(PicWidthSz,5),32)) dataMemReqQ <- mkFIFO;
|
FIFO#(MemReq#(PicWidthSz,13)) parameterMemReqQ <- mkFIFO;
|
FIFO#(MemReq#(PicWidthSz,13)) parameterMemReqQ <- mkFIFO;
|
FIFO#(MemResp#(32)) dataMemRespQ <- mkFIFO;
|
FIFO#(MemResp#(32)) dataMemRespQ <- mkFIFO;
|
FIFO#(MemResp#(13)) parameterMemRespQ <- mkFIFO;
|
FIFO#(MemResp#(13)) parameterMemRespQ <- mkFIFO;
|
|
|
Reg#(Process) process <- mkReg(Passing);
|
Reg#(Process) process <- mkReg(Passing);
|
Reg#(Bit#(1)) chromaFlag <- mkReg(0);
|
Reg#(Bit#(1)) chromaFlag <- mkReg(0);
|
Reg#(Bit#(5)) dataReqCount <- mkReg(0);
|
Reg#(Bit#(5)) dataReqCount <- mkReg(0);
|
Reg#(Bit#(5)) dataRespCount <- mkReg(0);
|
Reg#(Bit#(5)) dataRespCount <- mkReg(0);
|
Reg#(Bit#(4)) blockNum <- mkReg(0);
|
Reg#(Bit#(4)) blockNum <- mkReg(0);
|
Reg#(Bit#(4)) pixelNum <- mkReg(0);
|
Reg#(Bit#(4)) pixelNum <- mkReg(0);
|
|
|
Reg#(Bool) filterTopMbEdgeFlag <- mkReg(False);
|
Reg#(Bool) filterTopMbEdgeFlag <- mkReg(False);
|
Reg#(Bool) filterLeftMbEdgeFlag <- mkReg(False);
|
Reg#(Bool) filterLeftMbEdgeFlag <- mkReg(False);
|
Reg#(Bool) filterInternalEdgesFlag <- mkReg(False);
|
Reg#(Bool) filterInternalEdgesFlag <- mkReg(False);
|
|
|
Reg#(Bit#(PicWidthSz)) picWidth <- mkReg(maxPicWidthInMB);
|
Reg#(Bit#(PicWidthSz)) picWidth <- mkReg(maxPicWidthInMB);
|
Reg#(Bit#(PicHeightSz)) picHeight <- mkReg(0);
|
Reg#(Bit#(PicHeightSz)) picHeight <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) firstMb <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) firstMb <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) currMb <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) currMb <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) currMbHor <- mkReg(0);//horizontal position of currMb
|
Reg#(Bit#(PicAreaSz)) currMbHor <- mkReg(0);//horizontal position of currMb
|
Reg#(Bit#(PicHeightSz)) currMbVer <- mkReg(0);//vertical position of currMb
|
Reg#(Bit#(PicHeightSz)) currMbVer <- mkReg(0);//vertical position of currMb
|
|
|
Reg#(Bit#(2)) disable_deblocking_filter_idc <- mkReg(0);
|
Reg#(Bit#(2)) disable_deblocking_filter_idc <- mkReg(0);
|
Reg#(Bit#(5)) slice_alpha_c0_offset <- mkReg(0);
|
Reg#(Bit#(5)) slice_alpha_c0_offset <- mkReg(0);
|
Reg#(Bit#(5)) slice_beta_offset <- mkReg(0);
|
Reg#(Bit#(5)) slice_beta_offset <- mkReg(0);
|
|
|
Reg#(Bit#(6)) curr_qpy <- mkReg(0);
|
Reg#(Bit#(6)) curr_qpy <- mkReg(0);
|
Reg#(Bit#(6)) left_qpy <- mkReg(0);
|
Reg#(Bit#(6)) left_qpy <- mkReg(0);
|
Reg#(Bit#(6)) top_qpy <- mkReg(0);
|
Reg#(Bit#(6)) top_qpy <- mkReg(0);
|
Reg#(Bit#(6)) curr_qpc <- mkReg(0);
|
Reg#(Bit#(6)) curr_qpc <- mkReg(0);
|
Reg#(Bit#(6)) left_qpc <- mkReg(0);
|
Reg#(Bit#(6)) left_qpc <- mkReg(0);
|
Reg#(Bit#(6)) top_qpc <- mkReg(0);
|
Reg#(Bit#(6)) top_qpc <- mkReg(0);
|
Reg#(Bit#(1)) curr_intra <- mkReg(0);
|
Reg#(Bit#(1)) curr_intra <- mkReg(0);
|
Reg#(Bit#(1)) left_intra <- mkReg(0);
|
Reg#(Bit#(1)) left_intra <- mkReg(0);
|
Reg#(Bit#(1)) top_intra <- mkReg(0);
|
Reg#(Bit#(1)) top_intra <- mkReg(0);
|
|
|
Reg#(Bit#(8)) alphaMbEdge <- mkReg(0);
|
Reg#(Bit#(8)) alphaMbEdge <- mkReg(0);
|
Reg#(Bit#(8)) alphaInternal <- mkReg(0);
|
Reg#(Bit#(8)) alphaInternal <- mkReg(0);
|
Reg#(Bit#(5)) betaMbEdge <- mkReg(0);
|
Reg#(Bit#(5)) betaMbEdge <- mkReg(0);
|
Reg#(Bit#(5)) betaInternal <- mkReg(0);
|
Reg#(Bit#(5)) betaInternal <- mkReg(0);
|
Reg#(Vector#(3,Bit#(5))) tc0MbEdge <- mkRegU();
|
Reg#(Vector#(3,Bit#(5))) tc0MbEdge <- mkRegU();
|
Reg#(Vector#(3,Bit#(5))) tc0Internal <- mkRegU();
|
Reg#(Vector#(3,Bit#(5))) tc0Internal <- mkRegU();
|
|
|
Bit#(8) alpha_table[52] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
Bit#(8) alpha_table[52] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 4, 4, 5, 6,
|
0, 0, 0, 0, 0, 0, 4, 4, 5, 6,
|
7, 8, 9, 10, 12, 13, 15, 17, 20, 22,
|
7, 8, 9, 10, 12, 13, 15, 17, 20, 22,
|
25, 28, 32, 36, 40, 45, 50, 56, 63, 71,
|
25, 28, 32, 36, 40, 45, 50, 56, 63, 71,
|
80, 90,101,113,127,144,162,182,203,226,
|
80, 90,101,113,127,144,162,182,203,226,
|
255,255};
|
255,255};
|
Bit#(5) beta_table[52] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
Bit#(5) beta_table[52] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 2, 2, 2, 3,
|
0, 0, 0, 0, 0, 0, 2, 2, 2, 3,
|
3, 3, 3, 4, 4, 4, 6, 6, 7, 7,
|
3, 3, 3, 4, 4, 4, 6, 6, 7, 7,
|
8, 8, 9, 9, 10, 10, 11, 11, 12, 12,
|
8, 8, 9, 9, 10, 10, 11, 11, 12, 12,
|
13, 13, 14, 14, 15, 15, 16, 16, 17, 17,
|
13, 13, 14, 14, 15, 15, 16, 16, 17, 17,
|
18, 18};
|
18, 18};
|
Bit#(5) tc0_table[52][3] = {{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },
|
Bit#(5) tc0_table[52][3] = {{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },
|
{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },
|
{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },
|
{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 1 },
|
{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 1 },
|
{ 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 1, 1 }, { 0, 1, 1 }, { 1, 1, 1 },
|
{ 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 1, 1 }, { 0, 1, 1 }, { 1, 1, 1 },
|
{ 1, 1, 1 }, { 1, 1, 1 }, { 1, 1, 1 }, { 1, 1, 2 }, { 1, 1, 2 }, { 1, 1, 2 },
|
{ 1, 1, 1 }, { 1, 1, 1 }, { 1, 1, 1 }, { 1, 1, 2 }, { 1, 1, 2 }, { 1, 1, 2 },
|
{ 1, 1, 2 }, { 1, 2, 3 }, { 1, 2, 3 }, { 2, 2, 3 }, { 2, 2, 4 }, { 2, 3, 4 },
|
{ 1, 1, 2 }, { 1, 2, 3 }, { 1, 2, 3 }, { 2, 2, 3 }, { 2, 2, 4 }, { 2, 3, 4 },
|
{ 2, 3, 4 }, { 3, 3, 5 }, { 3, 4, 6 }, { 3, 4, 6 }, { 4, 5, 7 }, { 4, 5, 8 },
|
{ 2, 3, 4 }, { 3, 3, 5 }, { 3, 4, 6 }, { 3, 4, 6 }, { 4, 5, 7 }, { 4, 5, 8 },
|
{ 4, 6, 9 }, { 5, 7,10 }, { 6, 8,11 }, { 6, 8,13 }, { 7,10,14 }, { 8,11,16 },
|
{ 4, 6, 9 }, { 5, 7,10 }, { 6, 8,11 }, { 6, 8,13 }, { 7,10,14 }, { 8,11,16 },
|
{ 9,12,18 }, {10,13,20 }, {11,15,23 }, {13,17,25 }};
|
{ 9,12,18 }, {10,13,20 }, {11,15,23 }, {13,17,25 }};
|
|
|
Reg#(Vector#(64,Bit#(32))) workVector <- mkRegU();
|
Reg#(Vector#(64,Bit#(32))) workVector <- mkRegU();
|
Reg#(Vector#(96,Bit#(32))) leftVector <- mkRegU();
|
Reg#(Vector#(96,Bit#(32))) leftVector <- mkRegU();
|
Reg#(Vector#(16,Bit#(32))) topVector <- mkRegU();
|
Reg#(Vector#(16,Bit#(32))) topVector <- mkRegU();
|
|
|
Reg#(Bool) startLastOutput <- mkReg(False);
|
Reg#(Bool) startLastOutput <- mkReg(False);
|
Reg#(Bool) outputingFinished <- mkReg(False);
|
Reg#(Bool) outputingFinished <- mkReg(False);
|
Reg#(Bit#(2)) colNum <- mkReg(0);
|
Reg#(Bit#(2)) colNum <- mkReg(0);
|
Reg#(Bit#(2)) rowNum <- mkReg(0);
|
Reg#(Bit#(2)) rowNum <- mkReg(0);
|
|
|
RFile1#(Bit#(4),Tuple2#(Bit#(3),Bit#(3))) bSfile <- mkRFile1Full();
|
RFile1#(Bit#(4),Tuple2#(Bit#(3),Bit#(3))) bSfile <- mkRFile1Full();
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Rules
|
// Rules
|
|
|
rule passing ( process matches Passing );
|
rule passing ( process matches Passing );
|
case (infifo.first()) matches
|
case (infifo.first()) matches
|
tagged NewUnit . xdata :
|
tagged NewUnit . xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifo.enq(EDOT infifo.first());
|
outfifo.enq(EDOT infifo.first());
|
$display("ccl5newunit");
|
$display("ccl5newunit");
|
$display("ccl5rbspbyte %h", xdata);
|
$display("ccl5rbspbyte %h", xdata);
|
end
|
end
|
tagged SPSpic_width_in_mbs .xdata :
|
tagged SPSpic_width_in_mbs .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifo.enq(EDOT infifo.first());
|
outfifo.enq(EDOT infifo.first());
|
picWidth <= xdata;
|
picWidth <= xdata;
|
end
|
end
|
tagged SPSpic_height_in_map_units .xdata :
|
tagged SPSpic_height_in_map_units .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifo.enq(EDOT infifo.first());
|
outfifo.enq(EDOT infifo.first());
|
picHeight <= xdata;
|
picHeight <= xdata;
|
end
|
end
|
tagged PPSdeblocking_filter_control_present_flag .xdata :
|
tagged PPSdeblocking_filter_control_present_flag .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
if (xdata == 0)
|
if (xdata == 0)
|
begin
|
begin
|
disable_deblocking_filter_idc <= 0;
|
disable_deblocking_filter_idc <= 0;
|
slice_alpha_c0_offset <= 0;
|
slice_alpha_c0_offset <= 0;
|
slice_beta_offset <= 0;
|
slice_beta_offset <= 0;
|
end
|
end
|
end
|
end
|
tagged SHfirst_mb_in_slice .xdata :
|
tagged SHfirst_mb_in_slice .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifo.enq(EDOT infifo.first());
|
outfifo.enq(EDOT infifo.first());
|
firstMb <= xdata;
|
firstMb <= xdata;
|
currMb <= xdata;
|
currMb <= xdata;
|
currMbHor <= xdata;
|
currMbHor <= xdata;
|
currMbVer <= 0;
|
currMbVer <= 0;
|
end
|
end
|
tagged SHdisable_deblocking_filter_idc .xdata :
|
tagged SHdisable_deblocking_filter_idc .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
disable_deblocking_filter_idc <= xdata;
|
disable_deblocking_filter_idc <= xdata;
|
end
|
end
|
tagged SHslice_alpha_c0_offset .xdata :
|
tagged SHslice_alpha_c0_offset .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
slice_alpha_c0_offset <= xdata;
|
slice_alpha_c0_offset <= xdata;
|
end
|
end
|
tagged SHslice_beta_offset .xdata :
|
tagged SHslice_beta_offset .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
slice_beta_offset <= xdata;
|
slice_beta_offset <= xdata;
|
end
|
end
|
tagged IBTmb_qp .xdata :
|
tagged IBTmb_qp .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
curr_qpy <= xdata.qpy;
|
curr_qpy <= xdata.qpy;
|
curr_qpc <= xdata.qpc;
|
curr_qpc <= xdata.qpc;
|
end
|
end
|
tagged PBbS .xdata :
|
tagged PBbS .xdata :
|
begin
|
begin
|
process <= Initialize;
|
process <= Initialize;
|
end
|
end
|
tagged PBoutput .xdata :
|
tagged PBoutput .xdata :
|
begin
|
begin
|
$display( "ERROR Deblocking Filter: passing PBoutput");
|
$display( "ERROR Deblocking Filter: passing PBoutput");
|
end
|
end
|
tagged EndOfFile :
|
tagged EndOfFile :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifo.enq(EDOT infifo.first());
|
outfifo.enq(EDOT infifo.first());
|
$display( "ccl5: EndOfFile reached");
|
$display( "ccl5: EndOfFile reached");
|
//$finish(0);
|
//$finish(0);
|
end
|
end
|
default:
|
default:
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifo.enq(EDOT infifo.first());
|
outfifo.enq(EDOT infifo.first());
|
end
|
end
|
endcase
|
endcase
|
endrule
|
endrule
|
|
|
|
|
rule currMbHorUpdate( !(currMbHor
|
rule currMbHorUpdate( !(currMbHor
|
Bit#(PicAreaSz) temp = zeroExtend(picWidth);
|
Bit#(PicAreaSz) temp = zeroExtend(picWidth);
|
if((currMbHor >> 3) >= temp)
|
if((currMbHor >> 3) >= temp)
|
begin
|
begin
|
currMbHor <= currMbHor - (temp << 3);
|
currMbHor <= currMbHor - (temp << 3);
|
currMbVer <= currMbVer + 8;
|
currMbVer <= currMbVer + 8;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
currMbHor <= currMbHor - temp;
|
currMbHor <= currMbHor - temp;
|
currMbVer <= currMbVer + 1;
|
currMbVer <= currMbVer + 1;
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
rule initialize ( process==Initialize && currMbHor
|
rule initialize ( process==Initialize && currMbHor
|
//$display( "TRACE Deblocking Filter: initialize %0d", currMb);
|
//$display( "TRACE Deblocking Filter: initialize %0d", currMb);
|
process <= Horizontal;
|
process <= Horizontal;
|
dataReqCount <= 1;
|
dataReqCount <= 1;
|
dataRespCount <= 1;
|
dataRespCount <= 1;
|
filterTopMbEdgeFlag <= !(currMb
|
filterTopMbEdgeFlag <= !(currMb
|
filterLeftMbEdgeFlag <= !(currMbHor==0 || disable_deblocking_filter_idc==1 || (disable_deblocking_filter_idc==2 && currMb==firstMb));
|
filterLeftMbEdgeFlag <= !(currMbHor==0 || disable_deblocking_filter_idc==1 || (disable_deblocking_filter_idc==2 && currMb==firstMb));
|
filterInternalEdgesFlag <= !(disable_deblocking_filter_idc==1);
|
filterInternalEdgesFlag <= !(disable_deblocking_filter_idc==1);
|
blockNum <= 0;
|
blockNum <= 0;
|
pixelNum <= 0;
|
pixelNum <= 0;
|
Bit#(6) curr_qp = (chromaFlag==0 ? curr_qpy : curr_qpc);
|
Bit#(6) curr_qp = (chromaFlag==0 ? curr_qpy : curr_qpc);
|
Bit#(6) left_qp = (chromaFlag==0 ? left_qpy : left_qpc);
|
Bit#(6) left_qp = (chromaFlag==0 ? left_qpy : left_qpc);
|
Bit#(7) qpavtemp = zeroExtend(curr_qp)+zeroExtend(left_qp)+1;
|
Bit#(7) qpavtemp = zeroExtend(curr_qp)+zeroExtend(left_qp)+1;
|
Bit#(6) qpav = qpavtemp[6:1];
|
Bit#(6) qpav = qpavtemp[6:1];
|
Bit#(8) indexAtemp = zeroExtend(qpav)+signExtend(slice_alpha_c0_offset);
|
Bit#(8) indexAtemp = zeroExtend(qpav)+signExtend(slice_alpha_c0_offset);
|
Bit#(8) indexBtemp = zeroExtend(qpav)+signExtend(slice_beta_offset);
|
Bit#(8) indexBtemp = zeroExtend(qpav)+signExtend(slice_beta_offset);
|
Bit#(6) indexA = (indexAtemp[7]==1 ? 0 : (indexAtemp[6:0]>51 ? 51 : indexAtemp[5:0]));
|
Bit#(6) indexA = (indexAtemp[7]==1 ? 0 : (indexAtemp[6:0]>51 ? 51 : indexAtemp[5:0]));
|
Bit#(6) indexB = (indexBtemp[7]==1 ? 0 : (indexBtemp[6:0]>51 ? 51 : indexBtemp[5:0]));
|
Bit#(6) indexB = (indexBtemp[7]==1 ? 0 : (indexBtemp[6:0]>51 ? 51 : indexBtemp[5:0]));
|
alphaMbEdge <= alpha_table[indexA];
|
alphaMbEdge <= alpha_table[indexA];
|
betaMbEdge <= beta_table[indexB];
|
betaMbEdge <= beta_table[indexB];
|
Vector#(3,Bit#(5)) tc0temp = arrayToVector(tc0_table[indexA]);
|
Vector#(3,Bit#(5)) tc0temp = arrayToVector(tc0_table[indexA]);
|
tc0MbEdge <= tc0temp;
|
tc0MbEdge <= tc0temp;
|
endrule
|
endrule
|
|
|
|
|
rule dataSendReq ( dataReqCount>0 && currMbHor
|
rule dataSendReq ( dataReqCount>0 && currMbHor
|
//$display( "TRACE Deblocking Filter: dataSendReq %0d", dataReqCount);
|
//$display( "TRACE Deblocking Filter: dataSendReq %0d", dataReqCount);
|
Bit#(PicWidthSz) temp = truncate(currMbHor);
|
Bit#(PicWidthSz) temp = truncate(currMbHor);
|
if(currMb
|
if(currMb
|
dataReqCount <= 0;
|
dataReqCount <= 0;
|
else
|
else
|
begin
|
begin
|
if(dataReqCount==1)
|
if(dataReqCount==1)
|
parameterMemReqQ.enq(LoadReq temp);
|
parameterMemReqQ.enq(LoadReq temp);
|
Bit#(4) temp2 = truncate(dataReqCount-1);
|
Bit#(4) temp2 = truncate(dataReqCount-1);
|
let temp3 = {temp,chromaFlag,temp2};
|
let temp3 = {temp,chromaFlag,temp2};
|
dataMemReqQ.enq(LoadReq temp3);
|
dataMemReqQ.enq(LoadReq temp3);
|
if(dataReqCount==16)
|
if(dataReqCount==16)
|
dataReqCount <= 0;
|
dataReqCount <= 0;
|
else
|
else
|
dataReqCount <= dataReqCount+1;
|
dataReqCount <= dataReqCount+1;
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
rule dataReceiveNoResp ( dataRespCount>0 && currMb
|
rule dataReceiveNoResp ( dataRespCount>0 && currMb
|
//$display( "TRACE Deblocking Filter: dataReceiveNoResp");
|
//$display( "TRACE Deblocking Filter: dataReceiveNoResp");
|
dataRespCount <= 0;
|
dataRespCount <= 0;
|
endrule
|
endrule
|
|
|
|
|
rule dataReceiveResp ( dataRespCount>0 && !(currMb
|
rule dataReceiveResp ( dataRespCount>0 && !(currMb
|
//$display( "TRACE Deblocking Filter: dataReceiveResp %0d", dataRespCount);
|
//$display( "TRACE Deblocking Filter: dataReceiveResp %0d", dataRespCount);
|
Bit#(4) temp = truncate(dataRespCount-1);
|
Bit#(4) temp = truncate(dataRespCount-1);
|
Vector#(16,Bit#(32)) topVectorNext = topVector;
|
Vector#(16,Bit#(32)) topVectorNext = topVector;
|
if(dataRespCount==1)
|
if(dataRespCount==1)
|
begin
|
begin
|
Bit#(13) tempParameters=0;
|
Bit#(13) tempParameters=0;
|
if(parameterMemRespQ.first() matches tagged LoadResp .xdata)
|
if(parameterMemRespQ.first() matches tagged LoadResp .xdata)
|
tempParameters = xdata;
|
tempParameters = xdata;
|
top_qpy <= tempParameters[5:0];
|
top_qpy <= tempParameters[5:0];
|
top_qpc <= tempParameters[11:6];
|
top_qpc <= tempParameters[11:6];
|
top_intra <= tempParameters[12];
|
top_intra <= tempParameters[12];
|
parameterMemRespQ.deq();
|
parameterMemRespQ.deq();
|
end
|
end
|
if(dataRespCount==16)
|
if(dataRespCount==16)
|
dataRespCount <= 0;
|
dataRespCount <= 0;
|
else
|
else
|
dataRespCount <= dataRespCount+1;
|
dataRespCount <= dataRespCount+1;
|
if(dataMemRespQ.first() matches tagged LoadResp .xdata)
|
if(dataMemRespQ.first() matches tagged LoadResp .xdata)
|
topVectorNext[temp] = xdata;
|
topVectorNext[temp] = xdata;
|
dataMemRespQ.deq();
|
dataMemRespQ.deq();
|
topVector <= topVectorNext;
|
topVector <= topVectorNext;
|
//$display( "TRACE Deblocking Filter: dataReceiveResp topVector %h %h %h %h %h %h %h %h %h %h %h %h %h %h %h %h", topVector[0], topVector[1], topVector[2], topVector[3], topVector[4], topVector[5], topVector[6], topVector[7], topVector[8], topVector[9], topVector[10], topVector[11], topVector[12], topVector[13], topVector[14], topVector[15]);
|
//$display( "TRACE Deblocking Filter: dataReceiveResp topVector %h %h %h %h %h %h %h %h %h %h %h %h %h %h %h %h", topVector[0], topVector[1], topVector[2], topVector[3], topVector[4], topVector[5], topVector[6], topVector[7], topVector[8], topVector[9], topVector[10], topVector[11], topVector[12], topVector[13], topVector[14], topVector[15]);
|
endrule
|
endrule
|
|
|
|
|
rule horizontal ( process==Horizontal && currMbHor
|
rule horizontal ( process==Horizontal && currMbHor
|
//$display( "TRACE Deblocking Filter: horizontal %0d %0d %0d", blockNum, pixelNum, infifo.first());
|
//$display( "TRACE Deblocking Filter: horizontal %0d %0d %0d", blockNum, pixelNum, infifo.first());
|
Bit#(2) blockHor = {blockNum[2],blockNum[0]};
|
Bit#(2) blockHor = {blockNum[2],blockNum[0]};
|
Bit#(2) blockVer = {blockNum[3],blockNum[1]};
|
Bit#(2) blockVer = {blockNum[3],blockNum[1]};
|
Bit#(2) pixelVer = {pixelNum[3],pixelNum[2]};
|
Bit#(2) pixelVer = {pixelNum[3],pixelNum[2]};
|
Vector#(96,Bit#(32)) leftVectorNext = leftVector;
|
Vector#(96,Bit#(32)) leftVectorNext = leftVector;
|
Vector#(64,Bit#(32)) workVectorNext = workVector;
|
Vector#(64,Bit#(32)) workVectorNext = workVector;
|
Bool leftEdge = (blockNum[0]==0 && (blockNum[2]==0 || chromaFlag==1));
|
Bool leftEdge = (blockNum[0]==0 && (blockNum[2]==0 || chromaFlag==1));
|
if(blockNum==0 && pixelNum==0)
|
if(blockNum==0 && pixelNum==0)
|
begin
|
begin
|
Bit#(6) qpav = (chromaFlag==0 ? curr_qpy : curr_qpc);
|
Bit#(6) qpav = (chromaFlag==0 ? curr_qpy : curr_qpc);
|
Bit#(8) indexAtemp = zeroExtend(qpav)+signExtend(slice_alpha_c0_offset);
|
Bit#(8) indexAtemp = zeroExtend(qpav)+signExtend(slice_alpha_c0_offset);
|
Bit#(8) indexBtemp = zeroExtend(qpav)+signExtend(slice_beta_offset);
|
Bit#(8) indexBtemp = zeroExtend(qpav)+signExtend(slice_beta_offset);
|
Bit#(6) indexA = (indexAtemp[7]==1 ? 0 : (indexAtemp[6:0]>51 ? 51 : indexAtemp[5:0]));
|
Bit#(6) indexA = (indexAtemp[7]==1 ? 0 : (indexAtemp[6:0]>51 ? 51 : indexAtemp[5:0]));
|
Bit#(6) indexB = (indexBtemp[7]==1 ? 0 : (indexBtemp[6:0]>51 ? 51 : indexBtemp[5:0]));
|
Bit#(6) indexB = (indexBtemp[7]==1 ? 0 : (indexBtemp[6:0]>51 ? 51 : indexBtemp[5:0]));
|
alphaInternal <= alpha_table[indexA];
|
alphaInternal <= alpha_table[indexA];
|
betaInternal <= beta_table[indexB];
|
betaInternal <= beta_table[indexB];
|
Vector#(3,Bit#(5)) tc0temp = arrayToVector(tc0_table[indexA]);
|
Vector#(3,Bit#(5)) tc0temp = arrayToVector(tc0_table[indexA]);
|
tc0Internal <= tc0temp;
|
tc0Internal <= tc0temp;
|
end
|
end
|
case (infifo.first()) matches
|
case (infifo.first()) matches
|
tagged PBbS .xdata :
|
tagged PBbS .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
bSfile.upd(blockNum,tuple2(xdata.bShor,xdata.bSver));
|
bSfile.upd(blockNum,tuple2(xdata.bShor,xdata.bSver));
|
end
|
end
|
tagged PBoutput .xdata :
|
tagged PBoutput .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
Bit#(6) addrq = {blockHor,blockVer,pixelVer};
|
Bit#(6) addrq = {blockHor,blockVer,pixelVer};
|
Bit#(7) addrpLeft = (chromaFlag==0 ? {3'b011,blockVer,pixelVer} : {2'b10,blockHor[1],1'b1,blockVer[0],pixelVer});
|
Bit#(7) addrpLeft = (chromaFlag==0 ? {3'b011,blockVer,pixelVer} : {2'b10,blockHor[1],1'b1,blockVer[0],pixelVer});
|
Bit#(6) addrpCurr = {(blockHor-1),blockVer,pixelVer};
|
Bit#(6) addrpCurr = {(blockHor-1),blockVer,pixelVer};
|
Bit#(32) pixelq = {xdata[3],xdata[2],xdata[1],xdata[0]};
|
Bit#(32) pixelq = {xdata[3],xdata[2],xdata[1],xdata[0]};
|
Bit#(32) pixelp;
|
Bit#(32) pixelp;
|
if(leftEdge)
|
if(leftEdge)
|
pixelp = leftVector[addrpLeft];
|
pixelp = leftVector[addrpLeft];
|
else
|
else
|
pixelp = workVector[addrpCurr];
|
pixelp = workVector[addrpCurr];
|
Bit#(64) result = {pixelq,pixelp};
|
Bit#(64) result = {pixelq,pixelp};
|
if(leftEdge && filterLeftMbEdgeFlag)
|
if(leftEdge && filterLeftMbEdgeFlag)
|
begin
|
begin
|
if(filter_test({pixelq[15:0],pixelp[31:16]},alphaMbEdge,betaMbEdge))
|
if(filter_test({pixelq[15:0],pixelp[31:16]},alphaMbEdge,betaMbEdge))
|
result = filter_input({pixelq,pixelp},chromaFlag==1,tpl_1(bSfile.sub((chromaFlag==0?blockNum:{blockNum[1:0],pixelVer[1],1'b0}))),alphaMbEdge,betaMbEdge,tc0MbEdge);
|
result = filter_input({pixelq,pixelp},chromaFlag==1,tpl_1(bSfile.sub((chromaFlag==0?blockNum:{blockNum[1:0],pixelVer[1],1'b0}))),alphaMbEdge,betaMbEdge,tc0MbEdge);
|
end
|
end
|
else if(!leftEdge && filterInternalEdgesFlag)
|
else if(!leftEdge && filterInternalEdgesFlag)
|
begin
|
begin
|
if(filter_test({pixelq[15:0],pixelp[31:16]},alphaInternal,betaInternal))
|
if(filter_test({pixelq[15:0],pixelp[31:16]},alphaInternal,betaInternal))
|
result = filter_input({pixelq,pixelp},chromaFlag==1,tpl_1(bSfile.sub((chromaFlag==0?blockNum:{blockNum[1:0],pixelVer[1],1'b0}))),alphaInternal,betaInternal,tc0Internal);
|
result = filter_input({pixelq,pixelp},chromaFlag==1,tpl_1(bSfile.sub((chromaFlag==0?blockNum:{blockNum[1:0],pixelVer[1],1'b0}))),alphaInternal,betaInternal,tc0Internal);
|
end
|
end
|
if(leftEdge)
|
if(leftEdge)
|
leftVectorNext[addrpLeft] = result[31:0];
|
leftVectorNext[addrpLeft] = result[31:0];
|
else
|
else
|
workVectorNext[addrpCurr] = result[31:0];
|
workVectorNext[addrpCurr] = result[31:0];
|
workVectorNext[addrq] = result[63:32];
|
workVectorNext[addrq] = result[63:32];
|
leftVector <= leftVectorNext;
|
leftVector <= leftVectorNext;
|
workVector <= workVectorNext;
|
workVector <= workVectorNext;
|
if(pixelNum==12 && (blockNum==15 || (blockNum==7 && chromaFlag==1)))
|
if(pixelNum==12 && (blockNum==15 || (blockNum==7 && chromaFlag==1)))
|
begin
|
begin
|
blockNum <= 0;
|
blockNum <= 0;
|
process <= Vertical;
|
process <= Vertical;
|
startLastOutput <= False;
|
startLastOutput <= False;
|
outputingFinished <= False;
|
outputingFinished <= False;
|
colNum <= 0;
|
colNum <= 0;
|
if(filterTopMbEdgeFlag)
|
if(filterTopMbEdgeFlag)
|
rowNum <= 0;
|
rowNum <= 0;
|
else
|
else
|
rowNum <= 1;
|
rowNum <= 1;
|
Bit#(6) curr_qp = (chromaFlag==0 ? curr_qpy : curr_qpc);
|
Bit#(6) curr_qp = (chromaFlag==0 ? curr_qpy : curr_qpc);
|
Bit#(6) top_qp = (chromaFlag==0 ? top_qpy : top_qpc);
|
Bit#(6) top_qp = (chromaFlag==0 ? top_qpy : top_qpc);
|
Bit#(7) qpavtemp = zeroExtend(curr_qp)+zeroExtend(top_qp)+1;
|
Bit#(7) qpavtemp = zeroExtend(curr_qp)+zeroExtend(top_qp)+1;
|
Bit#(6) qpav = qpavtemp[6:1];
|
Bit#(6) qpav = qpavtemp[6:1];
|
Bit#(8) indexAtemp = zeroExtend(qpav)+signExtend(slice_alpha_c0_offset);
|
Bit#(8) indexAtemp = zeroExtend(qpav)+signExtend(slice_alpha_c0_offset);
|
Bit#(8) indexBtemp = zeroExtend(qpav)+signExtend(slice_beta_offset);
|
Bit#(8) indexBtemp = zeroExtend(qpav)+signExtend(slice_beta_offset);
|
Bit#(6) indexA = (indexAtemp[7]==1 ? 0 : (indexAtemp[6:0]>51 ? 51 : indexAtemp[5:0]));
|
Bit#(6) indexA = (indexAtemp[7]==1 ? 0 : (indexAtemp[6:0]>51 ? 51 : indexAtemp[5:0]));
|
Bit#(6) indexB = (indexBtemp[7]==1 ? 0 : (indexBtemp[6:0]>51 ? 51 : indexBtemp[5:0]));
|
Bit#(6) indexB = (indexBtemp[7]==1 ? 0 : (indexBtemp[6:0]>51 ? 51 : indexBtemp[5:0]));
|
alphaMbEdge <= alpha_table[indexA];
|
alphaMbEdge <= alpha_table[indexA];
|
betaMbEdge <= beta_table[indexB];
|
betaMbEdge <= beta_table[indexB];
|
Vector#(3,Bit#(5)) tc0temp = arrayToVector(tc0_table[indexA]);
|
Vector#(3,Bit#(5)) tc0temp = arrayToVector(tc0_table[indexA]);
|
tc0MbEdge <= tc0temp;
|
tc0MbEdge <= tc0temp;
|
end
|
end
|
else if(pixelNum==12)
|
else if(pixelNum==12)
|
blockNum <= blockNum+1;
|
blockNum <= blockNum+1;
|
pixelNum <= pixelNum+4;
|
pixelNum <= pixelNum+4;
|
end
|
end
|
//default: $display( "ERROR Deblocking Filter: horizontal non-PBoutput input");
|
//default: $display( "ERROR Deblocking Filter: horizontal non-PBoutput input");
|
endcase
|
endcase
|
endrule
|
endrule
|
|
|
|
|
rule vertical ( process==Vertical && !startLastOutput && dataRespCount==0 && currMbHor
|
rule vertical ( process==Vertical && !startLastOutput && dataRespCount==0 && currMbHor
|
//$display( "TRACE Deblocking Filter: vertical %0d %0d", colNum, rowNum);
|
//$display( "TRACE Deblocking Filter: vertical %0d %0d", colNum, rowNum);
|
//$display( "TRACE Deblocking Filter: vertical topVector %h %h %h %h %h %h %h %h %h %h %h %h %h %h %h %h", topVector[0], topVector[1], topVector[2], topVector[3], topVector[4], topVector[5], topVector[6], topVector[7], topVector[8], topVector[9], topVector[10], topVector[11], topVector[12], topVector[13], topVector[14], topVector[15]);
|
//$display( "TRACE Deblocking Filter: vertical topVector %h %h %h %h %h %h %h %h %h %h %h %h %h %h %h %h", topVector[0], topVector[1], topVector[2], topVector[3], topVector[4], topVector[5], topVector[6], topVector[7], topVector[8], topVector[9], topVector[10], topVector[11], topVector[12], topVector[13], topVector[14], topVector[15]);
|
Bool topEdge = (rowNum==0);
|
Bool topEdge = (rowNum==0);
|
Vector#(64,Bit#(32)) workVectorNext = workVector;
|
Vector#(64,Bit#(32)) workVectorNext = workVector;
|
Vector#(16,Bit#(32)) topVectorNext = topVector;
|
Vector#(16,Bit#(32)) topVectorNext = topVector;
|
Vector#(64,Bit#(32)) workV = workVector;
|
Vector#(64,Bit#(32)) workV = workVector;
|
Vector#(4,Bit#(32)) tempV = replicate(0);
|
Vector#(4,Bit#(32)) tempV = replicate(0);
|
Vector#(4,Bit#(64)) resultV = replicate(0);
|
Vector#(4,Bit#(64)) resultV = replicate(0);
|
Bit#(8) alpha;
|
Bit#(8) alpha;
|
Bit#(5) beta;
|
Bit#(5) beta;
|
Vector#(3,Bit#(5)) tc0;
|
Vector#(3,Bit#(5)) tc0;
|
Bit#(4) crNum = {colNum,rowNum};
|
Bit#(4) crNum = {colNum,rowNum};
|
if(topEdge)
|
if(topEdge)
|
begin
|
begin
|
tempV[0] = topVector[{colNum,2'b00}];
|
tempV[0] = topVector[{colNum,2'b00}];
|
tempV[1] = topVector[{colNum,2'b01}];
|
tempV[1] = topVector[{colNum,2'b01}];
|
tempV[2] = topVector[{colNum,2'b10}];
|
tempV[2] = topVector[{colNum,2'b10}];
|
tempV[3] = topVector[{colNum,2'b11}];
|
tempV[3] = topVector[{colNum,2'b11}];
|
alpha = alphaMbEdge;
|
alpha = alphaMbEdge;
|
beta = betaMbEdge;
|
beta = betaMbEdge;
|
tc0 = tc0MbEdge;
|
tc0 = tc0MbEdge;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
tempV[0] = workV[{(crNum-1),2'b00}];
|
tempV[0] = workV[{(crNum-1),2'b00}];
|
tempV[1] = workV[{(crNum-1),2'b01}];
|
tempV[1] = workV[{(crNum-1),2'b01}];
|
tempV[2] = workV[{(crNum-1),2'b10}];
|
tempV[2] = workV[{(crNum-1),2'b10}];
|
tempV[3] = workV[{(crNum-1),2'b11}];
|
tempV[3] = workV[{(crNum-1),2'b11}];
|
alpha = alphaInternal;
|
alpha = alphaInternal;
|
beta = betaInternal;
|
beta = betaInternal;
|
tc0 = tc0Internal;
|
tc0 = tc0Internal;
|
end
|
end
|
resultV[0] = {workV[{crNum,2'b11}][7:0],workV[{crNum,2'b10}][7:0],workV[{crNum,2'b01}][7:0],workV[{crNum,2'b00}][7:0],tempV[3][7:0],tempV[2][7:0],tempV[1][7:0],tempV[0][7:0]};
|
resultV[0] = {workV[{crNum,2'b11}][7:0],workV[{crNum,2'b10}][7:0],workV[{crNum,2'b01}][7:0],workV[{crNum,2'b00}][7:0],tempV[3][7:0],tempV[2][7:0],tempV[1][7:0],tempV[0][7:0]};
|
resultV[1] = {workV[{crNum,2'b11}][15:8],workV[{crNum,2'b10}][15:8],workV[{crNum,2'b01}][15:8],workV[{crNum,2'b00}][15:8],tempV[3][15:8],tempV[2][15:8],tempV[1][15:8],tempV[0][15:8]};
|
resultV[1] = {workV[{crNum,2'b11}][15:8],workV[{crNum,2'b10}][15:8],workV[{crNum,2'b01}][15:8],workV[{crNum,2'b00}][15:8],tempV[3][15:8],tempV[2][15:8],tempV[1][15:8],tempV[0][15:8]};
|
resultV[2] = {workV[{crNum,2'b11}][23:16],workV[{crNum,2'b10}][23:16],workV[{crNum,2'b01}][23:16],workV[{crNum,2'b00}][23:16],tempV[3][23:16],tempV[2][23:16],tempV[1][23:16],tempV[0][23:16]};
|
resultV[2] = {workV[{crNum,2'b11}][23:16],workV[{crNum,2'b10}][23:16],workV[{crNum,2'b01}][23:16],workV[{crNum,2'b00}][23:16],tempV[3][23:16],tempV[2][23:16],tempV[1][23:16],tempV[0][23:16]};
|
resultV[3] = {workV[{crNum,2'b11}][31:24],workV[{crNum,2'b10}][31:24],workV[{crNum,2'b01}][31:24],workV[{crNum,2'b00}][31:24],tempV[3][31:24],tempV[2][31:24],tempV[1][31:24],tempV[0][31:24]};
|
resultV[3] = {workV[{crNum,2'b11}][31:24],workV[{crNum,2'b10}][31:24],workV[{crNum,2'b01}][31:24],workV[{crNum,2'b00}][31:24],tempV[3][31:24],tempV[2][31:24],tempV[1][31:24],tempV[0][31:24]};
|
if(filter_test({workV[{crNum,2'b01}][7:0],workV[{crNum,2'b00}][7:0],tempV[3][7:0],tempV[2][7:0]},alpha,beta))
|
if(filter_test({workV[{crNum,2'b01}][7:0],workV[{crNum,2'b00}][7:0],tempV[3][7:0],tempV[2][7:0]},alpha,beta))
|
resultV[0] = filter_input(resultV[0],chromaFlag==1,tpl_2(bSfile.sub((chromaFlag==0?{rowNum[1],colNum[1],rowNum[0],colNum[0]}:{rowNum[0],colNum[0],2'b00}))),alpha,beta,tc0);
|
resultV[0] = filter_input(resultV[0],chromaFlag==1,tpl_2(bSfile.sub((chromaFlag==0?{rowNum[1],colNum[1],rowNum[0],colNum[0]}:{rowNum[0],colNum[0],2'b00}))),alpha,beta,tc0);
|
if(filter_test({workV[{crNum,2'b01}][15:8],workV[{crNum,2'b00}][15:8],tempV[3][15:8],tempV[2][15:8]},alpha,beta))
|
if(filter_test({workV[{crNum,2'b01}][15:8],workV[{crNum,2'b00}][15:8],tempV[3][15:8],tempV[2][15:8]},alpha,beta))
|
resultV[1] = filter_input(resultV[1],chromaFlag==1,tpl_2(bSfile.sub((chromaFlag==0?{rowNum[1],colNum[1],rowNum[0],colNum[0]}:{rowNum[0],colNum[0],2'b00}))),alpha,beta,tc0);
|
resultV[1] = filter_input(resultV[1],chromaFlag==1,tpl_2(bSfile.sub((chromaFlag==0?{rowNum[1],colNum[1],rowNum[0],colNum[0]}:{rowNum[0],colNum[0],2'b00}))),alpha,beta,tc0);
|
if(filter_test({workV[{crNum,2'b01}][23:16],workV[{crNum,2'b00}][23:16],tempV[3][23:16],tempV[2][23:16]},alpha,beta))
|
if(filter_test({workV[{crNum,2'b01}][23:16],workV[{crNum,2'b00}][23:16],tempV[3][23:16],tempV[2][23:16]},alpha,beta))
|
resultV[2] = filter_input(resultV[2],chromaFlag==1,tpl_2(bSfile.sub((chromaFlag==0?{rowNum[1],colNum[1],rowNum[0],colNum[0]}:{rowNum[0],colNum[0],2'b01}))),alpha,beta,tc0);
|
resultV[2] = filter_input(resultV[2],chromaFlag==1,tpl_2(bSfile.sub((chromaFlag==0?{rowNum[1],colNum[1],rowNum[0],colNum[0]}:{rowNum[0],colNum[0],2'b01}))),alpha,beta,tc0);
|
if(filter_test({workV[{crNum,2'b01}][31:24],workV[{crNum,2'b00}][31:24],tempV[3][31:24],tempV[2][31:24]},alpha,beta))
|
if(filter_test({workV[{crNum,2'b01}][31:24],workV[{crNum,2'b00}][31:24],tempV[3][31:24],tempV[2][31:24]},alpha,beta))
|
resultV[3] = filter_input(resultV[3],chromaFlag==1,tpl_2(bSfile.sub((chromaFlag==0?{rowNum[1],colNum[1],rowNum[0],colNum[0]}:{rowNum[0],colNum[0],2'b01}))),alpha,beta,tc0);
|
resultV[3] = filter_input(resultV[3],chromaFlag==1,tpl_2(bSfile.sub((chromaFlag==0?{rowNum[1],colNum[1],rowNum[0],colNum[0]}:{rowNum[0],colNum[0],2'b01}))),alpha,beta,tc0);
|
if(topEdge)
|
if(topEdge)
|
begin
|
begin
|
topVectorNext[{colNum,2'b00}] = {resultV[3][7:0],resultV[2][7:0],resultV[1][7:0],resultV[0][7:0]};
|
topVectorNext[{colNum,2'b00}] = {resultV[3][7:0],resultV[2][7:0],resultV[1][7:0],resultV[0][7:0]};
|
topVectorNext[{colNum,2'b01}] = {resultV[3][15:8],resultV[2][15:8],resultV[1][15:8],resultV[0][15:8]};
|
topVectorNext[{colNum,2'b01}] = {resultV[3][15:8],resultV[2][15:8],resultV[1][15:8],resultV[0][15:8]};
|
topVectorNext[{colNum,2'b10}] = {resultV[3][23:16],resultV[2][23:16],resultV[1][23:16],resultV[0][23:16]};
|
topVectorNext[{colNum,2'b10}] = {resultV[3][23:16],resultV[2][23:16],resultV[1][23:16],resultV[0][23:16]};
|
topVectorNext[{colNum,2'b11}] = {resultV[3][31:24],resultV[2][31:24],resultV[1][31:24],resultV[0][31:24]};
|
topVectorNext[{colNum,2'b11}] = {resultV[3][31:24],resultV[2][31:24],resultV[1][31:24],resultV[0][31:24]};
|
end
|
end
|
else
|
else
|
begin
|
begin
|
workVectorNext[{(crNum-1),2'b00}] = {resultV[3][7:0],resultV[2][7:0],resultV[1][7:0],resultV[0][7:0]};
|
workVectorNext[{(crNum-1),2'b00}] = {resultV[3][7:0],resultV[2][7:0],resultV[1][7:0],resultV[0][7:0]};
|
workVectorNext[{(crNum-1),2'b01}] = {resultV[3][15:8],resultV[2][15:8],resultV[1][15:8],resultV[0][15:8]};
|
workVectorNext[{(crNum-1),2'b01}] = {resultV[3][15:8],resultV[2][15:8],resultV[1][15:8],resultV[0][15:8]};
|
workVectorNext[{(crNum-1),2'b10}] = {resultV[3][23:16],resultV[2][23:16],resultV[1][23:16],resultV[0][23:16]};
|
workVectorNext[{(crNum-1),2'b10}] = {resultV[3][23:16],resultV[2][23:16],resultV[1][23:16],resultV[0][23:16]};
|
workVectorNext[{(crNum-1),2'b11}] = {resultV[3][31:24],resultV[2][31:24],resultV[1][31:24],resultV[0][31:24]};
|
workVectorNext[{(crNum-1),2'b11}] = {resultV[3][31:24],resultV[2][31:24],resultV[1][31:24],resultV[0][31:24]};
|
end
|
end
|
workVectorNext[{crNum,2'b00}] = {resultV[3][39:32],resultV[2][39:32],resultV[1][39:32],resultV[0][39:32]};
|
workVectorNext[{crNum,2'b00}] = {resultV[3][39:32],resultV[2][39:32],resultV[1][39:32],resultV[0][39:32]};
|
workVectorNext[{crNum,2'b01}] = {resultV[3][47:40],resultV[2][47:40],resultV[1][47:40],resultV[0][47:40]};
|
workVectorNext[{crNum,2'b01}] = {resultV[3][47:40],resultV[2][47:40],resultV[1][47:40],resultV[0][47:40]};
|
workVectorNext[{crNum,2'b10}] = {resultV[3][55:48],resultV[2][55:48],resultV[1][55:48],resultV[0][55:48]};
|
workVectorNext[{crNum,2'b10}] = {resultV[3][55:48],resultV[2][55:48],resultV[1][55:48],resultV[0][55:48]};
|
workVectorNext[{crNum,2'b11}] = {resultV[3][63:56],resultV[2][63:56],resultV[1][63:56],resultV[0][63:56]};
|
workVectorNext[{crNum,2'b11}] = {resultV[3][63:56],resultV[2][63:56],resultV[1][63:56],resultV[0][63:56]};
|
if(topEdge)
|
if(topEdge)
|
topVector <= topVectorNext;
|
topVector <= topVectorNext;
|
workVector <= workVectorNext;
|
workVector <= workVectorNext;
|
if(rowNum==3 || (chromaFlag==1 && rowNum==1))
|
if(rowNum==3 || (chromaFlag==1 && rowNum==1))
|
begin
|
begin
|
if(colNum==3)
|
if(colNum==3)
|
startLastOutput <= True;
|
startLastOutput <= True;
|
else
|
else
|
begin
|
begin
|
if(filterTopMbEdgeFlag)
|
if(filterTopMbEdgeFlag)
|
rowNum <= 0;
|
rowNum <= 0;
|
else
|
else
|
rowNum <= 1;
|
rowNum <= 1;
|
end
|
end
|
colNum <= colNum+1;
|
colNum <= colNum+1;
|
end
|
end
|
else
|
else
|
rowNum <= rowNum+1;
|
rowNum <= rowNum+1;
|
endrule
|
endrule
|
|
|
|
|
rule outputing ( process==Vertical && !outputingFinished && currMbHor
|
rule outputing ( process==Vertical && !outputingFinished && currMbHor
|
//$display( "TRACE Deblocking Filter: outputting %0d %0d", blockNum, pixelNum);
|
//$display( "TRACE Deblocking Filter: outputting %0d %0d", blockNum, pixelNum);
|
Bit#(2) blockHor = pixelNum[1:0];
|
Bit#(2) blockHor = pixelNum[1:0];
|
Bit#(2) blockVer = blockNum[1:0];
|
Bit#(2) blockVer = blockNum[1:0];
|
Bit#(2) pixelVer = pixelNum[3:2];
|
Bit#(2) pixelVer = pixelNum[3:2];
|
Bit#(PicWidthSz) currMbHorT = truncate(currMbHor);
|
Bit#(PicWidthSz) currMbHorT = truncate(currMbHor);
|
Bool stalling = False;
|
Bool stalling = False;
|
if(currMb==0)
|
if(currMb==0)
|
begin
|
begin
|
if(startLastOutput)
|
if(startLastOutput)
|
outputingFinished <= True;
|
outputingFinished <= True;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Bit#(7) leftAddr;
|
Bit#(7) leftAddr;
|
if(chromaFlag==0)
|
if(chromaFlag==0)
|
leftAddr = {1'b0,blockHor,blockVer,pixelVer};
|
leftAddr = {1'b0,blockHor,blockVer,pixelVer};
|
else
|
else
|
leftAddr = {2'b10,blockHor,blockVer[0],pixelVer};
|
leftAddr = {2'b10,blockHor,blockVer[0],pixelVer};
|
Bit#(32) leftData = leftVector[leftAddr];
|
Bit#(32) leftData = leftVector[leftAddr];
|
if(!(blockNum==3 || (blockNum==1 && chromaFlag==1)))
|
if(!(blockNum==3 || (blockNum==1 && chromaFlag==1)))
|
begin
|
begin
|
if(chromaFlag==0)
|
if(chromaFlag==0)
|
outfifo.enq(DFBLuma {ver:{(currMbHorT==0 ? currMbVer-1 : currMbVer),blockVer,pixelVer},hor:{(currMbHorT==0 ? picWidth-1 : currMbHorT-1),blockHor},data:leftData});
|
outfifo.enq(DFBLuma {ver:{(currMbHorT==0 ? currMbVer-1 : currMbVer),blockVer,pixelVer},hor:{(currMbHorT==0 ? picWidth-1 : currMbHorT-1),blockHor},data:leftData});
|
else
|
else
|
outfifo.enq(DFBChroma {uv:blockHor[1],ver:{(currMbHorT==0 ? currMbVer-1 : currMbVer),blockVer[0],pixelVer},hor:{(currMbHorT==0 ? picWidth-1 : currMbHorT-1),blockHor[0]},data:leftData});
|
outfifo.enq(DFBChroma {uv:blockHor[1],ver:{(currMbHorT==0 ? currMbVer-1 : currMbVer),blockVer[0],pixelVer},hor:{(currMbHorT==0 ? picWidth-1 : currMbHorT-1),blockHor[0]},data:leftData});
|
end
|
end
|
else if(startLastOutput)
|
else if(startLastOutput)
|
begin
|
begin
|
Bit#(PicWidthSz) temp = ((currMbHor==0) ? (picWidth-1) : truncate(currMbHor-1));
|
Bit#(PicWidthSz) temp = ((currMbHor==0) ? (picWidth-1) : truncate(currMbHor-1));
|
dataMemReqQ.enq(StoreReq {addr:{temp,chromaFlag,blockHor,pixelVer},data:leftData});
|
dataMemReqQ.enq(StoreReq {addr:{temp,chromaFlag,blockHor,pixelVer},data:leftData});
|
if(currMbVer > 0)
|
if(currMbVer > 0)
|
begin
|
begin
|
//$display( "TRACE Deblocking Filter: outputting last output %0d %0d %h", blockHor, pixelVer, topVector[{blockHor,pixelVer}]);
|
//$display( "TRACE Deblocking Filter: outputting last output %0d %0d %h", blockHor, pixelVer, topVector[{blockHor,pixelVer}]);
|
Bit#(32) topData = topVector[{blockHor,pixelVer}];
|
Bit#(32) topData = topVector[{blockHor,pixelVer}];
|
if(chromaFlag==0)
|
if(chromaFlag==0)
|
outfifo.enq(DFBLuma {ver:{currMbVer-1,2'b11,pixelVer},hor:{currMbHorT,blockHor},data:topData});
|
outfifo.enq(DFBLuma {ver:{currMbVer-1,2'b11,pixelVer},hor:{currMbHorT,blockHor},data:topData});
|
else
|
else
|
outfifo.enq(DFBChroma {uv:blockHor[1],ver:{currMbVer-1,1'b1,pixelVer},hor:{currMbHorT,blockHor[0]},data:topData});
|
outfifo.enq(DFBChroma {uv:blockHor[1],ver:{currMbVer-1,1'b1,pixelVer},hor:{currMbHorT,blockHor[0]},data:topData});
|
end
|
end
|
end
|
end
|
else
|
else
|
stalling = True;
|
stalling = True;
|
if(!stalling)
|
if(!stalling)
|
begin
|
begin
|
if(pixelNum==15)
|
if(pixelNum==15)
|
begin
|
begin
|
if(blockNum==3 || (chromaFlag==1 && blockNum==1))
|
if(blockNum==3 || (chromaFlag==1 && blockNum==1))
|
begin
|
begin
|
if(currMbVer==picHeight-1)
|
if(currMbVer==picHeight-1)
|
blockNum <= (chromaFlag==0 ? 3 : 1);
|
blockNum <= (chromaFlag==0 ? 3 : 1);
|
else
|
else
|
blockNum <= 0;
|
blockNum <= 0;
|
outputingFinished <= True;
|
outputingFinished <= True;
|
end
|
end
|
else
|
else
|
blockNum <= blockNum+1;
|
blockNum <= blockNum+1;
|
end
|
end
|
pixelNum <= pixelNum+1;
|
pixelNum <= pixelNum+1;
|
end
|
end
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
rule verticaltocleanup ( process==Vertical && startLastOutput && outputingFinished);
|
rule verticaltocleanup ( process==Vertical && startLastOutput && outputingFinished);
|
process <= Cleanup;
|
process <= Cleanup;
|
startLastOutput <= False;
|
startLastOutput <= False;
|
outputingFinished <= False;
|
outputingFinished <= False;
|
endrule
|
endrule
|
|
|
|
|
rule cleanup ( process==Cleanup && currMbHor
|
rule cleanup ( process==Cleanup && currMbHor
|
//$display( "TRACE Deblocking Filter: cleanup %0d %0d", blockNum, pixelNum);
|
//$display( "TRACE Deblocking Filter: cleanup %0d %0d", blockNum, pixelNum);
|
Bit#(2) blockHor = pixelNum[1:0];
|
Bit#(2) blockHor = pixelNum[1:0];
|
Bit#(2) blockVer = blockNum[1:0];
|
Bit#(2) blockVer = blockNum[1:0];
|
Bit#(2) pixelVer = pixelNum[3:2];
|
Bit#(2) pixelVer = pixelNum[3:2];
|
Bit#(PicWidthSz) currMbHorT = truncate(currMbHor);
|
Bit#(PicWidthSz) currMbHorT = truncate(currMbHor);
|
Vector#(96,Bit#(32)) leftVectorNext = leftVector;
|
Vector#(96,Bit#(32)) leftVectorNext = leftVector;
|
if(blockNum==0)
|
if(blockNum==0)
|
begin
|
begin
|
if(chromaFlag==0)
|
if(chromaFlag==0)
|
begin
|
begin
|
for(Integer ii=0; ii<64; ii=ii+1)
|
for(Integer ii=0; ii<64; ii=ii+1)
|
leftVectorNext[fromInteger(ii)] = workVector[fromInteger(ii)];
|
leftVectorNext[fromInteger(ii)] = workVector[fromInteger(ii)];
|
chromaFlag <= 1;
|
chromaFlag <= 1;
|
process <= Initialize;
|
process <= Initialize;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
for(Integer ii=0; ii<32; ii=ii+1)
|
for(Integer ii=0; ii<32; ii=ii+1)
|
begin
|
begin
|
Bit#(5) tempAddr = fromInteger(ii);
|
Bit#(5) tempAddr = fromInteger(ii);
|
leftVectorNext[{2'b10,tempAddr}] = workVector[{tempAddr[4:3],1'b0,tempAddr[2:0]}];
|
leftVectorNext[{2'b10,tempAddr}] = workVector[{tempAddr[4:3],1'b0,tempAddr[2:0]}];
|
end
|
end
|
chromaFlag <= 0;
|
chromaFlag <= 0;
|
process <= Passing;
|
process <= Passing;
|
Bit#(PicWidthSz) temp = truncate(currMbHor);
|
Bit#(PicWidthSz) temp = truncate(currMbHor);
|
parameterMemReqQ.enq(StoreReq {addr:temp,data:{curr_intra,curr_qpc,curr_qpy}});
|
parameterMemReqQ.enq(StoreReq {addr:temp,data:{curr_intra,curr_qpc,curr_qpy}});
|
left_intra <= curr_intra;
|
left_intra <= curr_intra;
|
left_qpc <= curr_qpc;
|
left_qpc <= curr_qpc;
|
left_qpy <= curr_qpy;
|
left_qpy <= curr_qpy;
|
currMb <= currMb+1;
|
currMb <= currMb+1;
|
currMbHor <= currMbHor+1;
|
currMbHor <= currMbHor+1;
|
if(currMbVer==picHeight-1 && currMbHor==zeroExtend(picWidth-1))
|
if(currMbVer==picHeight-1 && currMbHor==zeroExtend(picWidth-1))
|
outfifo.enq(EndOfFrame);
|
outfifo.enq(EndOfFrame);
|
end
|
end
|
leftVector <= leftVectorNext;
|
leftVector <= leftVectorNext;
|
end
|
end
|
else if(blockNum < 8)
|
else if(blockNum < 8)
|
begin
|
begin
|
Bit#(7) leftAddr;
|
Bit#(7) leftAddr;
|
if(chromaFlag==0)
|
if(chromaFlag==0)
|
leftAddr = {1'b0,blockHor,blockVer,pixelVer};
|
leftAddr = {1'b0,blockHor,blockVer,pixelVer};
|
else
|
else
|
leftAddr = {2'b10,blockHor,blockVer[0],pixelVer};
|
leftAddr = {2'b10,blockHor,blockVer[0],pixelVer};
|
Bit#(32) leftData = leftVector[leftAddr];
|
Bit#(32) leftData = leftVector[leftAddr];
|
if(chromaFlag==0)
|
if(chromaFlag==0)
|
outfifo.enq(DFBLuma {ver:{(currMbHorT==0 ? currMbVer-1 : currMbVer),blockVer,pixelVer},hor:{(currMbHorT==0 ? picWidth-1 : currMbHorT-1),blockHor},data:leftData});
|
outfifo.enq(DFBLuma {ver:{(currMbHorT==0 ? currMbVer-1 : currMbVer),blockVer,pixelVer},hor:{(currMbHorT==0 ? picWidth-1 : currMbHorT-1),blockHor},data:leftData});
|
else
|
else
|
outfifo.enq(DFBChroma {uv:blockHor[1],ver:{(currMbHorT==0 ? currMbVer-1 : currMbVer),blockVer[0],pixelVer},hor:{(currMbHorT==0 ? picWidth-1 : currMbHorT-1),blockHor[0]},data:leftData});
|
outfifo.enq(DFBChroma {uv:blockHor[1],ver:{(currMbHorT==0 ? currMbVer-1 : currMbVer),blockVer[0],pixelVer},hor:{(currMbHorT==0 ? picWidth-1 : currMbHorT-1),blockHor[0]},data:leftData});
|
if(pixelNum==15)
|
if(pixelNum==15)
|
begin
|
begin
|
if(currMbHor==zeroExtend(picWidth-1))
|
if(currMbHor==zeroExtend(picWidth-1))
|
blockNum <= 8;
|
blockNum <= 8;
|
else
|
else
|
blockNum <= 0;
|
blockNum <= 0;
|
end
|
end
|
pixelNum <= pixelNum+1;
|
pixelNum <= pixelNum+1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Bit#(6) currAddr = {blockHor,blockVer,pixelVer};
|
Bit#(6) currAddr = {blockHor,blockVer,pixelVer};
|
Bit#(32) currData = workVector[currAddr];
|
Bit#(32) currData = workVector[currAddr];
|
if(chromaFlag==0)
|
if(chromaFlag==0)
|
outfifo.enq(DFBLuma {ver:{currMbVer,blockVer,pixelVer},hor:{currMbHorT,blockHor},data:currData});
|
outfifo.enq(DFBLuma {ver:{currMbVer,blockVer,pixelVer},hor:{currMbHorT,blockHor},data:currData});
|
else
|
else
|
outfifo.enq(DFBChroma {uv:blockHor[1],ver:{currMbVer,blockVer[0],pixelVer},hor:{currMbHorT,blockHor[0]},data:currData});
|
outfifo.enq(DFBChroma {uv:blockHor[1],ver:{currMbVer,blockVer[0],pixelVer},hor:{currMbHorT,blockHor[0]},data:currData});
|
if(pixelNum==15)
|
if(pixelNum==15)
|
begin
|
begin
|
if(blockNum[1:0]==3 || (blockNum[1:0]==1 && chromaFlag==1))
|
if(blockNum[1:0]==3 || (blockNum[1:0]==1 && chromaFlag==1))
|
blockNum <= 0;
|
blockNum <= 0;
|
else
|
else
|
blockNum <= blockNum+1;
|
blockNum <= blockNum+1;
|
end
|
end
|
pixelNum <= pixelNum+1;
|
pixelNum <= pixelNum+1;
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
|
|
|
|
|
|
|
|
interface Client mem_client_data;
|
interface Client mem_client_data;
|
interface Get request = fifoToGet(dataMemReqQ);
|
interface Get request = fifoToGet(dataMemReqQ);
|
interface Put response = fifoToPut(dataMemRespQ);
|
interface Put response = fifoToPut(dataMemRespQ);
|
endinterface
|
endinterface
|
|
|
interface Client mem_client_parameter;
|
interface Client mem_client_parameter;
|
interface Get request = fifoToGet(parameterMemReqQ);
|
interface Get request = fifoToGet(parameterMemReqQ);
|
interface Put response = fifoToPut(parameterMemRespQ);
|
interface Put response = fifoToPut(parameterMemRespQ);
|
endinterface
|
endinterface
|
|
|
interface Put ioin = fifoToPut(infifo);
|
interface Put ioin = fifoToPut(infifo);
|
interface Get ioout = fifoToGet(outfifo);
|
interface Get ioout = fifoToGet(outfifo);
|
|
|
endmodule
|
endmodule
|
|
|
endpackage
|
endpackage
|
|
|