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

📄 corr_kc.i

📁 H.264完整的C语言代码和DCT的代码
💻 I
字号:
#line 1 "D:\\working\\im_apps\\h264\\corr_kc.cpp"
#line 1 "D:/working/tools/isim/isimexe/blank_headers\\idb_kernelc.hpp"








#line 2 "D:\\working\\im_apps\\h264\\corr_kc.cpp"
#line 1 "D:\\working\\im_apps\\h264\\mpeg.hpp"




#line 1 "D:/working/tools/isim/isimexe/blank_headers\\idb_types.hpp"













#line 6 "D:\\working\\im_apps\\h264\\mpeg.hpp"
#line 1 "D:/working/tools/isim/isimexe/blank_headers\\idb_deftypes.hpp"




#line 7 "D:\\working\\im_apps\\h264\\mpeg.hpp"

#decl idxGen(ostream<uint>   indices,
              uc<int>&        uc_size,
              uc<int>&        uc_params);
;


#decl icolor(istream<ubyte4> datain,
              ostream<half2> Yout,
              ostream<half2> CrCbout);
;


#decl pcolor(istream<ubyte4> datain,
              ostream<ubyte4> Yout,
              ostream<half2> CrCbout);
;


#decl dct(istream<half2> datain,
           istream<uhalf2> consts,
           ostream<half2> out,
           uc<uhalf2>& uc_quantizer_scale);
;


#decl idct(istream<half2> datain,
            istream<uhalf2> consts,
            ostream<half2> out,
            uc<half2>& uc_quantizer_scale);
;


#decl rle(istream<half2> Yin,
           istream<half2> CrCbin,
           istream<int> indices,
           cistream<half2> motion,
           costream<half2> out,
           uc<uint>& pframe,
           uc<uint>& quant_scale);
;


#decl difference(istream<ubyte4> curryblks,
                  istream<half2> currcblks,
                  istream<ubyte4> refyblks,
                  istream<half2> refcblks,
                  ostream<half2> diffyblks,
                  ostream<half2> diffcblks);
;


#decl correlate(istream<half2> diffyblks,
                 istream<half2> diffcblks,
                 istream<ubyte4> refyblks,
                 istream<half2> refcblks,
                 ostream<ubyte4> newrefyblks,
                 ostream<half2> newrefcblks,
                 uc<uint>& uc_pframe);
;


#decl MV2idx(cistream<half2> motion,      
              ostream<uint>   yindices,    
              ostream<uint>   crcbindices, 
              uc<int>&        uc_offsets,  
              uc<int>&        uc_mblks,    
              uc<int>&        uc_mb_width);
;


#decl blocksearch(istream<ubyte4> row0,
                   istream<ubyte4> row1,
                   istream<ubyte4> row2,
                   istream<ubyte4> mblocks,
                   costream<half2> motions,
                   uc<int>& location);
;


#decl mb_encode(istream<byte4> datain,
                 istream<half2> consts,
                 ostream<half2> color_out,
                 ostream<half2> dct_out,
                 costream<int> out);
;



#line 1 "D:/working/tools/isim/isimexe/blank_headers\\idb_undeftypes.hpp"




#line 97 "D:\\working\\im_apps\\h264\\mpeg.hpp"

#line 99 "D:\\working\\im_apps\\h264\\mpeg.hpp"
#line 3 "D:\\working\\im_apps\\h264\\corr_kc.cpp"
#line 1 "D:/working/tools/isim/isimexe/blank_headers\\idb_kernelc2.hpp"






#line 4 "D:\\working\\im_apps\\h264\\corr_kc.cpp"

;




kernel correlate(istream<half2> diffyblks,
                 istream<half2> diffcblks,
                 istream<ubyte4> refyblks,
                 istream<half2> refcblks,
                 ostream<ubyte4> newrefyblks,
                 ostream<half2> newrefcblks,
                 uc<uint>& uc_pframe)
{
  
  uc<int> perm_a = 0x07654321;
  uc<int> perm_b = 0x10765432;
  uc<int> perm_c = 0x21076543;
  uc<int> perm_d = 0x32107654;
  uc<int> perm_e = 0x43210765;
  uc<int> perm_f = 0x54321076;
  uc<int> perm_g = 0x65432107;

  
  int idx0 = cid();
  int idx1 = (idx0 - 1) & 7;
  int idx2 = (idx1 - 1) & 7;
  int idx3 = (idx2 - 1) & 7;
  int idx4 = (idx3 - 1) & 7;
  int idx5 = (idx4 - 1) & 7;
  int idx6 = (idx5 - 1) & 7;
  int idx7 = (idx6 - 1) & 7;

  
  byte4 b32_to_lo = 0x88888823; 
                                
  byte4 b10_to_lo = 0x88888801; 
                                
  byte4 b32_to_hi = 0x88238888; 
                                
  byte4 b10_to_hi = 0x88018888; 
                                
  byte4 h2_to_b3  = 0x02888888; 
                                
  byte4 h2_to_b2  = 0x88028888; 
                                
  byte4 h2_to_b1  = 0x88880288; 
                                
  byte4 h2_to_b0  = 0x88888802; 
                                

  cc merge  = itocc(0x0000FFFF);
  cc pframe = itocc(commclperm(0x8, uint(0), uc_pframe));
                                   
  loop_stream(diffyblks) pipeline(1) {
    expand<half2> currc(8);
    expand<half2> refc(8);
    expand<half2> diffc(8);

    diffcblks >> diffc[0];
    diffcblks >> diffc[1];
    diffcblks >> diffc[2];
    diffcblks >> diffc[3];
    diffcblks >> diffc[4];
    diffcblks >> diffc[5];
    diffcblks >> diffc[6];
    diffcblks >> diffc[7];
    refcblks  >> refc[0];
    refcblks  >> refc[1];
    refcblks  >> refc[2];
    refcblks  >> refc[3];
    refcblks  >> refc[4];
    refcblks  >> refc[5];
    refcblks  >> refc[6];
    refcblks  >> refc[7];

    expand<half2> curry(8);
    expand<ubyte4> refy(8);
    expand<ubyte4> packedy(8);

    array<half2> diffy(8), diffy21(8), diffy43(8);

    diffyblks >> diffy21[0];
    diffyblks >> diffy21[1];
    diffyblks >> diffy21[2];
    diffyblks >> diffy21[3];
    diffyblks >> diffy21[4];
    diffyblks >> diffy21[5];
    diffyblks >> diffy21[6];
    diffyblks >> diffy21[7];
    diffyblks >> diffy43[0];
    diffyblks >> diffy43[1];
    diffyblks >> diffy43[2];
    diffyblks >> diffy43[3];
    diffyblks >> diffy43[4];
    diffyblks >> diffy43[5];
    diffyblks >> diffy43[6];
    diffyblks >> diffy43[7];
    refyblks  >> refy[0];
    refyblks  >> refy[1];
    refyblks  >> refy[2];
    refyblks  >> refy[3];
    refyblks  >> refy[4];
    refyblks  >> refy[5];
    refyblks  >> refy[6];
    refyblks  >> refy[7];

    currc[0] = diffc[0] + select(pframe, refc[0], 0);
    currc[1] = diffc[1] + select(pframe, refc[1], 0);
    currc[2] = diffc[2] + select(pframe, refc[2], 0);
    currc[3] = diffc[3] + select(pframe, refc[3], 0);
    currc[4] = diffc[4] + select(pframe, refc[4], 0);
    currc[5] = diffc[5] + select(pframe, refc[5], 0);
    currc[6] = diffc[6] + select(pframe, refc[6], 0);
    currc[7] = diffc[7] + select(pframe, refc[7], 0);

    newrefcblks << currc[0];
    newrefcblks << currc[1];
    newrefcblks << currc[2];
    newrefcblks << currc[3];
    newrefcblks << currc[4];
    newrefcblks << currc[5];
    newrefcblks << currc[6];
    newrefcblks << currc[7];

    
    
    
    
    diffy[idx0] = diffy21[idx0];
    diffy[idx7] = commucperm(perm_a, diffy21[idx1]);
    diffy[idx6] = commucperm(perm_b, diffy21[idx2]);
    diffy[idx5] = commucperm(perm_c, diffy21[idx3]);
    diffy[idx4] = commucperm(perm_d, diffy21[idx4]);
    diffy[idx3] = commucperm(perm_e, diffy21[idx5]);
    diffy[idx2] = commucperm(perm_f, diffy21[idx6]);
    diffy[idx1] = commucperm(perm_g, diffy21[idx7]);

    
    double<ubyte4> h0, h1, h2, h3, h4, h5, h6, h7;
    expand<half2> ref(8);

    h0 = shuffled(refy[0], b32_to_lo);
    h1 = shuffled(refy[0], b10_to_lo);
    h2 = shuffled(refy[2], b32_to_lo);
    h3 = shuffled(refy[2], b10_to_lo);
    h4 = shuffled(refy[4], b32_to_hi);
    h5 = shuffled(refy[4], b10_to_hi);
    h6 = shuffled(refy[6], b32_to_hi);
    h7 = shuffled(refy[6], b10_to_hi);

    ref[0] = half2(lo(h0) | lo(h4));
    ref[1] = half2(hi(h0) | hi(h4));
    ref[2] = half2(lo(h1) | lo(h5));
    ref[3] = half2(hi(h1) | hi(h5));
    ref[4] = half2(lo(h2) | lo(h6));
    ref[5] = half2(hi(h2) | hi(h6));
    ref[6] = half2(lo(h3) | lo(h7));
    ref[7] = half2(hi(h3) | hi(h7));
      
    curry[0] = diffy[0] + select(pframe, ref[0], 0);
    curry[1] = diffy[1] + select(pframe, ref[1], 0);
    curry[2] = diffy[2] + select(pframe, ref[2], 0);
    curry[3] = diffy[3] + select(pframe, ref[3], 0);
    curry[4] = diffy[4] + select(pframe, ref[4], 0);
    curry[5] = diffy[5] + select(pframe, ref[5], 0);
    curry[6] = diffy[6] + select(pframe, ref[6], 0);
    curry[7] = diffy[7] + select(pframe, ref[7], 0);

    
    double<half2> b3, b2, b1, b0;
    b3 = shuffled(curry[0], h2_to_b3);
    b2 = shuffled(curry[1], h2_to_b2);
    b1 = shuffled(curry[2], h2_to_b1);
    b0 = shuffled(curry[3], h2_to_b0);
      
    packedy[0] = ubyte4((hi(b3) | hi(b2)) | (hi(b1) | hi(b0)));
    packedy[4] = ubyte4((lo(b3) | lo(b2)) | (lo(b1) | lo(b0)));

    b3 = shuffled(curry[4], h2_to_b3);
    b2 = shuffled(curry[5], h2_to_b2);
    b1 = shuffled(curry[6], h2_to_b1);
    b0 = shuffled(curry[7], h2_to_b0);
    
    packedy[2] = ubyte4((hi(b3) | hi(b2)) | (hi(b1) | hi(b0)));
    packedy[6] = ubyte4((lo(b3) | lo(b2)) | (lo(b1) | lo(b0)));

    
    diffy[idx0] = diffy43[idx0];
    diffy[idx7] = commucperm(perm_a, diffy43[idx1]);
    diffy[idx6] = commucperm(perm_b, diffy43[idx2]);
    diffy[idx5] = commucperm(perm_c, diffy43[idx3]);
    diffy[idx4] = commucperm(perm_d, diffy43[idx4]);
    diffy[idx3] = commucperm(perm_e, diffy43[idx5]);
    diffy[idx2] = commucperm(perm_f, diffy43[idx6]);
    diffy[idx1] = commucperm(perm_g, diffy43[idx7]);

    
    h0 = shuffled(refy[1], b32_to_lo);
    h1 = shuffled(refy[1], b10_to_lo);
    h2 = shuffled(refy[3], b32_to_lo);
    h3 = shuffled(refy[3], b10_to_lo);
    h4 = shuffled(refy[5], b32_to_hi);
    h5 = shuffled(refy[5], b10_to_hi);
    h6 = shuffled(refy[7], b32_to_hi);
    h7 = shuffled(refy[7], b10_to_hi);

    ref[0] = half2(lo(h0) | lo(h4));
    ref[1] = half2(hi(h0) | hi(h4));
    ref[2] = half2(lo(h1) | lo(h5));
    ref[3] = half2(hi(h1) | hi(h5));
    ref[4] = half2(lo(h2) | lo(h6));
    ref[5] = half2(hi(h2) | hi(h6));
    ref[6] = half2(lo(h3) | lo(h7));
    ref[7] = half2(hi(h3) | hi(h7));
      
    curry[0] = diffy[0] + select(pframe, ref[0], 0); 
    curry[1] = diffy[1] + select(pframe, ref[1], 0); 
    curry[2] = diffy[2] + select(pframe, ref[2], 0);
    curry[3] = diffy[3] + select(pframe, ref[3], 0);
    curry[4] = diffy[4] + select(pframe, ref[4], 0);
    curry[5] = diffy[5] + select(pframe, ref[5], 0);
    curry[6] = diffy[6] + select(pframe, ref[6], 0);
    curry[7] = diffy[7] + select(pframe, ref[7], 0);

    
    b3 = shuffled(curry[0], h2_to_b3);
    b2 = shuffled(curry[1], h2_to_b2);
    b1 = shuffled(curry[2], h2_to_b1);
    b0 = shuffled(curry[3], h2_to_b0);
      
    packedy[1] = ubyte4((hi(b3) | hi(b2)) | (hi(b1) | hi(b0)));
    packedy[5] = ubyte4((lo(b3) | lo(b2)) | (lo(b1) | lo(b0)));

    b3 = shuffled(curry[4], h2_to_b3);
    b2 = shuffled(curry[5], h2_to_b2);
    b1 = shuffled(curry[6], h2_to_b1);
    b0 = shuffled(curry[7], h2_to_b0);
    
    packedy[3] = ubyte4((hi(b3) | hi(b2)) | (hi(b1) | hi(b0)));
    packedy[7] = ubyte4((lo(b3) | lo(b2)) | (lo(b1) | lo(b0)));

    newrefyblks << packedy[0];
    newrefyblks << packedy[1];
    newrefyblks << packedy[2];
    newrefyblks << packedy[3];
    newrefyblks << packedy[4];
    newrefyblks << packedy[5];
    newrefyblks << packedy[6];
    newrefyblks << packedy[7];
  }
}

⌨️ 快捷键说明

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