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

📄 mv2idx_kc.i

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








#line 2 "D:\\working\\im_apps\\h264\\mv2idx_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 mb_encode(istream<byte4> datain,
                 istream<half2> consts,
                 ostream<half2> color_out,
                 ostream<half2> dct_out,
                 costream<int> out);
;





#decl me_fast(istream<ubyte4> row0,
               istream<ubyte4> row1,
               istream<ubyte4> row2,
               istream<ubyte4> mblocks,
               costream<half2> motions_out,
               ostream<ubyte4> refyblks,
               ostream<uint>   crcbindices,
               uc<int>& uc_margin,
               uc<int>& uc_offsets,
               uc<int>& uc_mblks,
               uc<int>& uc_mb_width);
;


#decl me_fast_search4(istream<ubyte4> row0,
                       istream<ubyte4> row1,
                       istream<ubyte4> row2,
                       istream<ubyte4> mblocks,
                       costream<half2> motions_out,
                       uc<int>& uc_margin,
                       uc<int>& uc_mblks);
;


#decl me_fast_jitter2(istream<ubyte4> row0,
                       istream<ubyte4> row1,
                       istream<ubyte4> row2,
                       istream<ubyte4> mblocks,
                       cistream<half2> motions_in,
                       costream<half2> motions_out,
                       uc<int>& uc_margin,
                       uc<int>& uc_mblks);
;


#decl me_fast_jitter1(istream<ubyte4> row0,
                       istream<ubyte4> row1,
                       istream<ubyte4> row2,
                       istream<ubyte4> mblocks,
                       cistream<half2> motions_in,
                       costream<half2> motions_out,
                       ostream<ubyte4> refyblks,
                       ostream<uint>   crcbindices,
                       uc<int>& uc_margin,
                       uc<int>& uc_offsets,
                       uc<int>& uc_mblks,
                       uc<int>& uc_mb_width);
;






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




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

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






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

;



kernel MV2idx(cistream<half2> motion,      
              ostream<uint>   yindices,    
              ostream<uint>   crcbindices, 
              uc<int>&        uc_offsets,  
              uc<int>&        uc_mblks,    
              uc<int>&        uc_mb_width) 
{
  uint fetchaddress;
  uint fetchx, fetchy;
  int yrefx, yrefy;
  int crefx, crefy;

  uint yout0, yout1, yout2, yout3, yout4, yout5, yout6, yout7;
  uint cout0, cout1, cout2, cout3, cout4, cout5, cout6, cout7;

  int offsets    = commclperm(0x8, 0, uc_offsets);
  int xoffset    = offsets & 0xffff;
  int yoffset    = shift(offsets, -16);
  uint mb_width  = uint(commclperm(0x8, 0, uc_mb_width));
  uint rowlen    = shift(mb_width, 2);
  uint crowlen   = shift(mb_width, 6);

  yrefx = xoffset;
  yrefy = yoffset + cid();

  crefx = shift(xoffset, -1) + cid();
  crefy = shift(yoffset, -1);


  
  byte4 unpackmv = 0x57571302; 
                               

  cc ccin = itocc (cid() == 0);
  cc ccend = itocc(0);

  

  half2 dxdy, bestval;
  loop_count(uc_mblks) pipeline(1) {
    
    double<half2> dxdy2;
    int dx, dy;

    motion(ccin, ccend) >> dxdy >> bestval;

    
    dxdy = shifta(dxdy, -1);

    
    dxdy = commclperm(0, dxdy);
    dxdy2 = shuffled(dxdy, unpackmv);
    dx = int(hi(dxdy2));
    dy = int(lo(dxdy2));

    
    fetchx = uint(yrefx + dx);
    fetchy = uint(yrefy + dy);

    expand<uint> fetchxoffsets(4), fetchyoffsets(8);

    fetchyoffsets[0] = shift(lo(shift(fetchy, -4) * rowlen), 4)
      + (fetchy & 0xf);
    fetchy = fetchy + 8;
    fetchyoffsets[1] = shift(lo(shift(fetchy, -4) * rowlen), 4)
      + (fetchy & 0xf);

    fetchxoffsets[0] = shift(shift(fetchx, -4), 6)
      + shift(shift(fetchx & 0xf, -2), 4);
    fetchx = fetchx + 4;
    fetchxoffsets[1] = shift(shift(fetchx, -4), 6)
      + shift(shift(fetchx & 0xf, -2), 4);
    fetchx = fetchx + 4;
    fetchxoffsets[2] = shift(shift(fetchx, -4), 6)
      + shift(shift(fetchx & 0xf, -2), 4);
    fetchx = fetchx + 4;
    fetchxoffsets[3] = shift(shift(fetchx, -4), 6)
      + shift(shift(fetchx & 0xf, -2), 4);

    yout0 = fetchyoffsets[0] + fetchxoffsets[0];
    yout1 = fetchyoffsets[1] + fetchxoffsets[0];
    yout2 = fetchyoffsets[0] + fetchxoffsets[1];
    yout3 = fetchyoffsets[1] + fetchxoffsets[1];
    yout4 = fetchyoffsets[0] + fetchxoffsets[2];
    yout5 = fetchyoffsets[1] + fetchxoffsets[2];
    yout6 = fetchyoffsets[0] + fetchxoffsets[3];
    yout7 = fetchyoffsets[1] + fetchxoffsets[3];

    yindices << yout0 << yout1 << yout2 << yout3;
    yindices << yout4 << yout5 << yout6 << yout7;

    
    
    
    dx = dx + select(itocc(dx < 0), 1, 0);
    dy = dy + select(itocc(dy < 0), 1, 0);
    fetchx = uint(crefx + shifta(int(dx), -1));
    fetchy = uint(crefy + shifta(int(dy), -1));

    uint fetchxoffset = shift(shift(fetchx, -3), 6) + (fetchx & 0x7);

    fetchyoffsets[0] = lo(shift(fetchy, -3) * crowlen)
      + shift(fetchy & 0x7, 3);
    fetchy = fetchy + 1;
    fetchyoffsets[1] = lo(shift(fetchy, -3) * crowlen)
      + shift(fetchy & 0x7, 3);
    fetchy = fetchy + 1;
    fetchyoffsets[2] = lo(shift(fetchy, -3) * crowlen)
      + shift(fetchy & 0x7, 3);
    fetchy = fetchy + 1;
    fetchyoffsets[3] = lo(shift(fetchy, -3) * crowlen)
      + shift(fetchy & 0x7, 3);
    fetchy = fetchy + 1;
    fetchyoffsets[4] = lo(shift(fetchy, -3) * crowlen)
      + shift(fetchy & 0x7, 3);
    fetchy = fetchy + 1;
    fetchyoffsets[5] = lo(shift(fetchy, -3) * crowlen)
      + shift(fetchy & 0x7, 3);
    fetchy = fetchy + 1;
    fetchyoffsets[6] = lo(shift(fetchy, -3) * crowlen)
      + shift(fetchy & 0x7, 3);
    fetchy = fetchy + 1;
    fetchyoffsets[7] = lo(shift(fetchy, -3) * crowlen)
      + shift(fetchy & 0x7, 3);

    cout0 = fetchxoffset + fetchyoffsets[0];
    cout1 = fetchxoffset + fetchyoffsets[1];
    cout2 = fetchxoffset + fetchyoffsets[2];
    cout3 = fetchxoffset + fetchyoffsets[3];
    cout4 = fetchxoffset + fetchyoffsets[4];
    cout5 = fetchxoffset + fetchyoffsets[5];
    cout6 = fetchxoffset + fetchyoffsets[6];
    cout7 = fetchxoffset + fetchyoffsets[7];

    crcbindices << cout0 << cout1 << cout2 << cout3;
    crcbindices << cout4 << cout5 << cout6 << cout7;

    yrefx = yrefx + 16;
    crefx = crefx + 8;
  }

  cc always = itocc( 0xffffffff );

  loop_until_any(ccend) {
    motion( always, ccend) >> dxdy >> bestval;
  }
}

⌨️ 快捷键说明

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