OpenCores
URL https://opencores.org/ocsvn/bluespec-h264/bluespec-h264/trunk

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src/] [mkDeblockFilter.bsv] - Diff between revs 10 and 11

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 10 Rev 11
Line 224... Line 224...
  RFile1#(Bit#(4),Bit#(32)) topVector <- mkRFile1Full();
  RFile1#(Bit#(4),Bit#(32)) topVector <- mkRFile1Full();
  method sub = topVector.sub;
  method sub = topVector.sub;
  method upd = topVector.upd;
  method upd = topVector.upd;
endmodule
endmodule
 
 
 
interface IbSVector;
 
  method ActionValue#(Bit#(3)) sub(Bit#(4) addr);
 
  method Action upd(Bit#(4) addr, Bit#(3) data);
 
endinterface
 
 
 
(*synthesize*)
 
module mkbSVector(IbSVector);
 
  RFile1#(Bit#(4),Bit#(3)) bsVector <- mkRFile1Full();
 
  method sub = bsVector.sub;
 
  method upd = bsVector.upd;
 
endmodule
 
 
 
 
 
 
 
 
 
 
(* synthesize *)
(* synthesize *)
module mkDeblockFilter( IDeblockFilter );
module mkDeblockFilter( IDeblockFilter );
Line 305... Line 318...
   IWorkVectorVer workVectorCols <- mkWorkVectorVer();
   IWorkVectorVer workVectorCols <- mkWorkVectorVer();
   ILeftVector leftVector <- mkLeftVector();
   ILeftVector leftVector <- mkLeftVector();
   ITopVector  topVector  <- mkTopVector();
   ITopVector  topVector  <- mkTopVector();
   Reg#(Bit#(16)) topVectorValidBits <- mkReg(0);
   Reg#(Bit#(16)) topVectorValidBits <- mkReg(0);
 
 
 
   IbSVector bSfileHor <- mkbSVector();
   RegFile#(Bit#(4),Tuple2#(Bit#(3),Bit#(3))) bSfile <- mkRegFileFull();
   IbSVector bSfileVer <- mkbSVector();
 
 
   Reg#(Bit#(6)) cleanup_state <- mkReg(0);
   Reg#(Bit#(6)) cleanup_state <- mkReg(0);
 
 
   Vector#(4, FIFO#(Bit#(32))) rowToColumnStore <- replicateM(mkFIFO);
   Vector#(4, FIFO#(Bit#(32))) rowToColumnStore <- replicateM(mkFIFO);
   Reg#(Bit#(2)) rowToColumnState <- mkReg(0);
   Reg#(Bit#(2)) rowToColumnState <- mkReg(0);
Line 485... Line 498...
     // Check to see if we're even filtering the top edge
     // Check to see if we're even filtering the top edge
     Bit#(2) blockVer = {tpl_1(rowToColumnStoreBlock.first())[3],tpl_1(rowToColumnStoreBlock.first())[1]};
     Bit#(2) blockVer = {tpl_1(rowToColumnStoreBlock.first())[3],tpl_1(rowToColumnStoreBlock.first())[1]};
     Bit#(2) blockHor = {tpl_1(rowToColumnStoreBlock.first())[2],tpl_1(rowToColumnStoreBlock.first())[0]};
     Bit#(2) blockHor = {tpl_1(rowToColumnStoreBlock.first())[2],tpl_1(rowToColumnStoreBlock.first())[0]};
     Bool storeBottomRightBlock = tpl_2(rowToColumnStoreBlock.first()) == 1;
     Bool storeBottomRightBlock = tpl_2(rowToColumnStoreBlock.first()) == 1;
 
 
     if(storeBottomRightBlock) // The right bottom block is not complete until the top filtering has occured
 
                               // It has to be rotated to the column major ordering used in the top vector
 
                               // memory
 
       begin
 
         rowToColumnState  <= rowToColumnState + 1;
         rowToColumnState  <= rowToColumnState + 1;
         Bit#(32) data_out = 0;
         Bit#(32) data_out = 0;
         Bit#(PicWidthSz) adjustedMbHor = ((currMbHor==0) ? (picWidth-1) : truncate(currMbHor-1));
         Bit#(PicWidthSz) adjustedMbHor = ((currMbHor==0) ? (picWidth-1) : truncate(currMbHor-1));
 
 
         case(rowToColumnState)
         case(rowToColumnState)
Line 510... Line 519...
                                (rowToColumnStore[1].first())[31:24], (rowToColumnStore[0].first())[31:24]};
                                (rowToColumnStore[1].first())[31:24], (rowToColumnStore[0].first())[31:24]};
                    mapM_(deque, rowToColumnStore); // Deq the vector elements
                    mapM_(deque, rowToColumnStore); // Deq the vector elements
                    rowToColumnStoreBlock.deq();
                    rowToColumnStoreBlock.deq();
                  end
                  end
         endcase
         endcase
 
 
 
     if(storeBottomRightBlock) // The right bottom block is not complete until the top filtering has occured
 
                               // It has to be rotated to the column major ordering used in the top vector
 
                               // memory
 
       begin
          $display( "TRACE Deblocking Filter: rowToColumnRotate rotating block (%0d, %0d) rowtoColumnState: %d bottomRightBlock: %d, data: %h", blockHor, blockVer, rowToColumnState, storeBottomRightBlock, data_out);
          $display( "TRACE Deblocking Filter: rowToColumnRotate rotating block (%0d, %0d) rowtoColumnState: %d bottomRightBlock: %d, data: %h", blockHor, blockVer, rowToColumnState, storeBottomRightBlock, data_out);
         // The block hor calculation may be questionable... between U and V.
         // The block hor calculation may be questionable... between U and V.
         if(chromaFlag == 0)
         if(chromaFlag == 0)
           begin
           begin
             dataMemReqQ.enq(StoreReq {addr:{adjustedMbHor,chromaFlag,2'b11,rowToColumnState},data:data_out});
             dataMemReqQ.enq(StoreReq {addr:{adjustedMbHor,chromaFlag,2'b11,rowToColumnState},data:data_out});
Line 524... Line 538...
           end
           end
 
 
       end
       end
     else // pass data along to vertical filter
     else // pass data along to vertical filter
       begin
       begin
         rowToColumnState  <= rowToColumnState + 1;
         verticalFilterBlock.enq(tuple2(tpl_1(rowToColumnStoreBlock.first()),data_out));
         Bit#(32) data_out = 0;
 
         case(rowToColumnState)
 
           2'b00: data_out = {(rowToColumnStore[3].first())[7:0],
 
                              (rowToColumnStore[2].first())[7:0],
 
                              (rowToColumnStore[1].first())[7:0],
 
                              (rowToColumnStore[0].first())[7:0]};
 
 
 
           2'b01: data_out = {(rowToColumnStore[3].first())[15:8],
 
                              (rowToColumnStore[2].first())[15:8],
 
                              (rowToColumnStore[1].first())[15:8],
 
                              (rowToColumnStore[0].first())[15:8]};
 
 
 
           2'b10: data_out = {(rowToColumnStore[3].first())[23:16],
 
                              (rowToColumnStore[2].first())[23:16],
 
                              (rowToColumnStore[1].first())[23:16],
 
                              (rowToColumnStore[0].first())[23:16]};
 
 
 
           2'b11: begin
 
                    data_out = {(rowToColumnStore[3].first())[31:24],
 
                                (rowToColumnStore[2].first())[31:24],
 
                                (rowToColumnStore[1].first())[31:24],
 
                                (rowToColumnStore[0].first())[31:24]};
 
                    mapM_(deque, rowToColumnStore); // Deq the vector elements
 
                    rowToColumnStoreBlock.deq();
 
                  end
 
         endcase
 
         verticalFilterBlock.enq(tuple2(tpl_1(rowToColumnStoreBlock.first()),
 
                                        data_out));
 
 
 
          $display( "TRACE Deblocking Filter: rowToColumnRotate rotating block (%0d, %0d) rowtoColumnState: %d bottomRightBlock: %d, data: %h", blockHor, blockVer, rowToColumnState, storeBottomRightBlock, data_out);
          $display( "TRACE Deblocking Filter: rowToColumnRotate rotating block (%0d, %0d) rowtoColumnState: %d bottomRightBlock: %d, data: %h", blockHor, blockVer, rowToColumnState, storeBottomRightBlock, data_out);
       end
       end
   endrule
   endrule
 
 
Line 714... Line 700...
         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));
               bSfileHor.upd(blockNum, xdata.bShor);
 
               bSfileVer.upd(blockNum, xdata.bSver);
               $display( "TRACE Deblocking Filter: horizontal bsFIFO data: %d, subblock(%0d, %0d) row: %0d, ",infifo.first(), blockHor, blockVer, pixelNum);
               $display( "TRACE Deblocking Filter: horizontal bsFIFO data: %d, subblock(%0d, %0d) row: %0d, ",infifo.first(), blockHor, blockVer, pixelNum);
            end
            end
         tagged PBoutput .xdata :
         tagged PBoutput .xdata :
            begin
            begin
               $display( "TRACE Deblocking Filter: horizontal subblock(%0d, %0d) row: %0d, data: %h", blockHor, blockVer, pixelNum, xdata);
               $display( "TRACE Deblocking Filter: horizontal subblock(%0d, %0d) row: %0d, data: %h", blockHor, blockVer, pixelNum, xdata);
Line 752... Line 739...
                    Bit#(8) alphaMbLeft = alpha_table[indexA];
                    Bit#(8) alphaMbLeft = alpha_table[indexA];
                    Bit#(5) betaMbLeft = beta_table[indexB];
                    Bit#(5) betaMbLeft = beta_table[indexB];
                    Vector#(3,Bit#(5)) tc0MbLeft = arrayToVector(tc0_table[indexA]);
                    Vector#(3,Bit#(5)) tc0MbLeft = arrayToVector(tc0_table[indexA]);
                    if(filter_test({pixelq[15:0],pixelp[31:16]},alphaMbLeft,betaMbLeft))
                    if(filter_test({pixelq[15:0],pixelp[31:16]},alphaMbLeft,betaMbLeft))
                      begin
                      begin
                         let bsData = bSfile.sub((chromaFlag==0?blockNum:{blockNum[1:0],pixelVer[1],1'b0}));
                         Bit#(3) bsData <- bSfileHor.sub((chromaFlag==0?blockNum:{blockNum[1:0],pixelVer[1],1'b0}));
                         result = filter_input({pixelq,pixelp},chromaFlag==1,tpl_1(bsData),alphaMbLeft,betaMbLeft,tc0MbLeft);
                         result = filter_input({pixelq,pixelp},chromaFlag==1,bsData,alphaMbLeft,betaMbLeft,tc0MbLeft);
                       end
                       end
                  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))
                       begin
                       begin
                         let bSData = bSfile.sub((chromaFlag==0?blockNum:{blockNum[1:0],pixelVer[1],1'b0}));
                         Bit#(3) bSData <- bSfileHor.sub((chromaFlag==0?blockNum:{blockNum[1:0],pixelVer[1],1'b0}));
                         result = filter_input({pixelq,pixelp},chromaFlag==1,tpl_1(bSData),alphaInternal,betaInternal,tc0Internal);
                         result = filter_input({pixelq,pixelp},chromaFlag==1,bSData,alphaInternal,betaInternal,tc0Internal);
                       end
                       end
                  end
                  end
               Bit#(PicWidthSz) currMbHorT = truncate(currMbHor);
               Bit#(PicWidthSz) currMbHorT = truncate(currMbHor);
 
 
               if(leftEdge)
               if(leftEdge)
Line 941... Line 928...
 
 
      // Apply filter, only if filter test passes, and we are either filtering the top edge, or we aren't on the top edge
      // Apply filter, only if filter test passes, and we are either filtering the top edge, or we aren't on the top edge
      $display( "TRACE Deblocking Filter: vertical Filter test: P1P0Q0Q1: %h",{workV[15:8],workV[7:0],tempV[31:24],tempV[23:16]});
      $display( "TRACE Deblocking Filter: vertical Filter test: P1P0Q0Q1: %h",{workV[15:8],workV[7:0],tempV[31:24],tempV[23:16]});
      if((filter_test({workV[15:8],workV[7:0],tempV[31:24],tempV[23:16]},alpha,beta)) && (!topEdge || filterTopMbEdgeFlag))
      if((filter_test({workV[15:8],workV[7:0],tempV[31:24],tempV[23:16]},alpha,beta)) && (!topEdge || filterTopMbEdgeFlag))
        begin
        begin
        //let bsData = bSfile.sub(blockNumCols & {1'b1,~chromaFlag,2'b11});
        Bit#(3) bsData <- bSfileVer.sub((chromaFlag==0?blockNumCols:{blockVer[0],blockHor[0],1'b0,columnNumber[1]}));
        let bsData = bSfile.sub((chromaFlag==0?blockNumCols:{blockVer[0],blockHor[0],1'b0,columnNumber[1]}));
         resultV = filter_input(resultV,chromaFlag==1,bsData,alpha,beta,tc0);
         resultV = filter_input(resultV,chromaFlag==1,tpl_2(bsData),alpha,beta,tc0);
 
        end
        end
      //Write out the result data  31:0 are the done q values
      //Write out the result data  31:0 are the done q values
      if(topEdge)
      if(topEdge)
         begin
         begin
            // We really need to just output these values -> need to shove them to the rotation unit, but only if the
            // We really need to just output these values -> need to shove them to the rotation unit, but only if the

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.