亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? skl_mpg4_enc.cpp

?? mpeg4編解碼器
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
/******************************************************** * Some code. Copyright (C) 2003 by Pascal Massimino.   * * All Rights Reserved.      (http://skal.planet-d.net) * * For Educational/Academic use ONLY. See 'LICENSE.TXT'.* ********************************************************//* * skl_mpg4_enc.cpp * * MPEG4 encoder ********************************************************/#include "./skl_mpg4i.h"#include "skl_syst/skl_exception.h"static const char * const ID_STRING = "sklmp4 004";//////////////////////////////////////////////////////////#define ABS(x)  (((x)<0) ? -(x) : (x))#define DIV_ROUND(x,y)  ( (x)>=0 ? ((x)+((y)>>1))/(y) : ((x)-((y)>>1))/(y) )//////////////////////////////////////////////////////////// Encoding tables//////////////////////////////////////////////////////////struct SKL_VLC { SKL_INT16 Val, Len; };  // Table B-12static const SKL_VLC MV_B12_Tab[32+1+32] = {  { 5, 13}, { 7, 13}, { 5, 12}, { 7, 12}, { 9, 12}, {11, 12}, {13, 12}, {15, 12}, { 9, 11}, {11, 11}, {13, 11}, {15, 11}, {17, 11}, {19, 11}, {21, 11}, {23, 11}, {25, 11}, {27, 11}, {29, 11}, {31, 11}, {33, 11}, {35, 11}, {19, 10}, {21, 10}, {23, 10}, { 7,  8}, { 9,  8}, {11,  8}, { 7,  7}, { 3,  5}, { 3,  4}, { 3,  3}, { 1,  1}, { 2,  3}, { 2,  4}, { 2,  5}, { 6,  7}, {10,  8}, { 8,  8}, { 6,  8}, {22, 10}, {20, 10}, {18, 10}, {34, 11}, {32, 11}, {30, 11}, {28, 11}, {26, 11}, {24, 11}, {22, 11}, {20, 11}, {18, 11}, {16, 11}, {14, 11}, {12, 11}, {10, 11}, { 8, 11}, {14, 12}, {12, 12}, {10, 12}, { 8, 12}, { 6, 12}, { 4, 12}, { 6, 13}, { 4, 13}};  // Table B-6static const SKL_VLC MCBPC_Intra_B6[2][4] = {  // index: [MB_Type-3][Cbpc]  { {1, 1}, {1, 3}, {2, 3}, {3, 3} }    // MB_Type = 3, Cbpc=00 .. 11, { {1, 4}, {1, 6}, {2, 6}, {3, 6} }    // MB_Type = 4, Cbpc=00 .. 11};  // Table B-7static const SKL_VLC MCBPC_Inter_B7[5][4] = {  // index: [MB_Type][Cbpc]  { {1, 1}, {3, 4}, {2, 4}, {5, 6} }, { {3, 3}, {7, 7}, {6, 7}, {5, 9} }, { {2, 3}, {5, 7}, {4, 7}, {5, 8} }, { {3, 5}, {4, 8}, {3, 8}, {3, 7} }, { {4, 6}, {4, 9}, {3, 9}, {2, 9} }};static const SKL_VLC CBPY_B8[16] = {   // index: Cbpy  {3, 4}, {5, 5}, {4, 5}, { 9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4}, {2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, { 3, 2}}; // Table B13/B14: DC-diff code, indexed by [size-1].  // Bits for |DC| are blanked.  // Final Marker bit included for Size>8static const SKL_VLC DCY_Tab_B13[12] = {  { 6,  3}, { 8,  4}, {16,  6}, {16,  7},  {32,  9}, {64, 11}, {128, 13}, {256, 15},  {1025, 18}, {4097, 21}, {8193, 23}, {8193, 24}};  static const SKL_VLC DCC_Tab_B14[12] = {  { 4,  3}, { 4,  4}, { 8,  6}, {16,  8}, {32, 10}, {64, 12}, {128, 14}, {256, 16}, {1025, 19}, {2049, 21}, {4097, 23}, {8193, 25}};  // Table 6-27static const int DQuant_Tab[5] = { 1, 0, -1 /*error*/, 2, 3 };  // Table 6-33static const SKL_VLC Spr_Tab_B33[15] = {  {   0, 2}, {   2, 3}, {   3, 3}, {  4, 3}, {   5, 3}, {   6, 3}, {  14, 4}, { 30, 5}, {  62, 6}, { 126, 7}, { 254, 8}, {510, 9}, {1022,10}, {2046,11}, {4094,12}};  //////////////////////////////////////////////////////////// MV coding//////////////////////////////////////////////////////////static void Write_Vector_Comp(SKL_FBB * const Bits, SKL_INT16 Val, SKL_INT32 Fix){  const int High = 16 << Fix;  SKL_ASSERT(Val>=-2*High && Val<2*High);  if      (Val < -High) Val += 2*High;  else if (Val >= High) Val -= 2*High;  if (!Val)    Bits->Put_Bits(1, 1); // 0 case hardcoded  else {    if (--Fix) {      const SKL_UINT32 Sign = (Val<0);      if (Sign) Val ^= -1;      else      Val -= 1;      const int Residue = Val & SKL_BMASKS::And[Fix];      Val >>= Fix;      SKL_ASSERT(Val>=0 && Val<=31);      Bits->Put_Bits( MV_B12_Tab[33+Val].Val | Sign, MV_B12_Tab[33+Val].Len );      Bits->Put_Bits( Residue, Fix );    }    else {      SKL_ASSERT(Val>=-32 && Val<=32);      Bits->Put_Bits( MV_B12_Tab[Val+32].Val, MV_B12_Tab[Val+32].Len );    }  }  }static void Write_Vector(SKL_FBB * const Bits, const SKL_MV MV, SKL_INT32 Fix){  Write_Vector_Comp(Bits, MV[0], Fix);  Write_Vector_Comp(Bits, MV[1], Fix);}////////////////////////////////////////////////////////////   AC coeff coding. //// Description of the matrices Code[Run][Level]://  Codable {run,level} combinaisons ('x') are packed on the//  upper left corner. Actually, the matrix looks like://    +-----------------[level]//    |xxxxxxxxxxx...... <-//    |xxxxxxxx......... <- max_level[run]//    |xxxx............. <-//    |xx...............//    |x................//    |x................//    |.................//    |.................//[run]^^^^___ max_run[level]////  Uncharted coeffs ('.') need being coded with escape code.// If you use Esc-1 coding, you will jump on the left by// max_level[run] steps, in hope you fall on a 'x' coded// combinaison. With Esc-2 coding, you will move up by// max_run[level]+1 steps. If neither works, you have to// fall back to expensive Esc-3 coding.//////////////////////////////////////////////////////////#include "./skl_mpg4_enc_tbl.h"static inline void Write_DC_Coeff(SKL_FBB * const Bits,                                  SKL_INT16 DC,                                  const int Lum){  if (DC) {    const int Sign = (DC<0);    if (Sign) DC = -DC;    int Size = SKL_BMASKS::Log2(DC);    SKL_ASSERT(Size>=1 && Size<=12);    if (Sign) DC ^= SKL_BMASKS::And[Size];    const SKL_VLC *VLC = Lum ? &DCY_Tab_B13[Size-1] : &DCC_Tab_B14[Size-1];    if (Size>8) DC <<= 1;     // make room for marker bit    Bits->Put_Bits( VLC->Val | DC, VLC->Len );  }  else {    if (Lum) Bits->Put_Bits( 3, 3 );    else     Bits->Put_Bits( 3, 2 );  }}static inline void Encode_Coeff(SKL_FBB *Bits, int Level, const SKL_UINT32 * const Tab){  SKL_ASSERT(Level!=0 && Level>=-2048 && Level<=2047);  if (!((Level+64)&-128)) { // Level is in [-64,63] -> use table    const SKL_UINT32 Code = Tab[Level];    if (0<=(SKL_INT32)Code)  // !bit31? -> it's a regular 21bits-max code      Bits->Put_Bits( Code&0x00ffffff, Code>>24 );    else                     // otherwise, code is actually a 30bits-Esc3      Bits->Put_Bits( Code&0x7fffffff, 7+2+1+6+1+12+1 );  }  else {      // Esc3 encoding (30bits total) for level not in [-64,63]      // Tab[0] contains the esc3 code base: 0x01e02001 | (last<<20) | (run<<14)    const SKL_UINT32 Code = Tab[0] | ((Level&0xfff)<<1);    Bits->Put_Bits( Code, 7+2+1+6+1+12+1 );  }}static inline void Write_Coeffs(SKL_FBB * const Bits,                                 const SKL_INT16 *C,                                const int Zigzag[],                                int Last,                                const SKL_UINT32 Tabs[2][64][128]){  Zigzag += Last;  int j = -Last;  while(1) {    int Level;    do Level = C[Zigzag[j++]]; while (!Level);    if (j<=0) {      Encode_Coeff( Bits, Level, &Tabs[0][Last+j-1][64] );      Last = -j;    }    else {      Encode_Coeff( Bits, Level, &Tabs[1][Last][64] );      break;    }  }}static inline int Find_Last(const SKL_INT16 C[6*64], const int *Zigzag, int i){  while(i>=0)    if (C[Zigzag[i]])      return i;    else i--;  return -1;}//////////////////////////////////////////////////////////////        Trellis-Based quantization//// So far I understand this paper:////  "Trellis-Based R-D Optimal Quantization in H.263+"//    J.Wen, M.Luttrell, J.Villasenor//    IEEE Transactions on Image Processing, Vol.9, No.8, Aug. 2000.//// we are at stake with a simplified Bellman-Ford / Dijkstra Single// Source Shortest Path algo. But due to the underlying graph structure// ("Trellis"), it can be turned into a dynamic programming algo,// partially saving the explicit graph's nodes representation. And // without using a heap, since the open frontier of the DAG is always// known, and of fixed size.////////////////////////////////////////////////////////////#define DBG 0SKL_UINT32 SKL_MP4_ENC_I::Evaluate_Cost(const SKL_INT16 *C, const int * const Zigzag, int Max, int Lambda) const{#if (DBG>0)  const SKL_INT16 * const Ref = C + 6*64;  int Last = Max;  while(Last>=0 && C[Zigzag[Last]]==0) Last--;  int Bits = 0;  if (Last>=0) {    Bits = 2;   // CBP    int j=0, j0=0;    int Run, Level;    while(j<Last) {      while(!C[Zigzag[j]]) j++;      if (j==Last) break;      Level=C[Zigzag[j]];      Run = j - j0;      j0 = ++j;      if (Level>=-24 && Level<=24) Bits += B16_17_Code_Len[(Level<0) ? -Level-1 : Level-1][Run];      else Bits += 30;    }    Level = C[Zigzag[Last]];    Run = j - j0;    if (Level>=-6 && Level<=6) Bits += B16_17_Code_Len_Last[(Level<0) ? -Level-1 : Level-1][Run];    else Bits += 30;  }  int Dist = 0;  for(int i=0; i<=Last; ++i) {    const int q = Quant_Type ? ((Q*Inter_Matrix[Zigzag[i]]) >> 4) : Q;    const int Mult = 2*q;    const int Bias = (q-1) | 1;    int V = C[Zigzag[i]]*Mult;    if      (V>0) V += Bias;    else if (V<0) V -= Bias;    V -= Ref[Zigzag[i]];    Dist += V*V;  }  SKL_UINT32 Cost = Lambda*Dist + (Bits<<16);  if (DBG==1)    printf( " Last:%2d/%2d Cost = [(Bits=%5.0d) + Lambda*(Dist=%6.0d) = %d ] >>12= %d ", Last,Max, Bits, Dist, Cost, Cost>>12 );  return Cost;#else  return 0;#endif}#define TL(q) 0xfe00/(q*q)static const int Trellis_Lambda_Tabs[31] = {         TL( 1),TL( 2),TL( 3),TL( 4),TL( 5),TL( 6), TL( 7),  TL( 8),TL( 9),TL(10),TL(11),TL(12),TL(13),TL(14), TL(15),  TL(16),TL(17),TL(18),TL(19),TL(20),TL(21),TL(22), TL(23),  TL(24),TL(25),TL(26),TL(27),TL(28),TL(29),TL(30), TL(31)};#undef TLint SKL_MP4_ENC_I::Trellis_Quantize(SKL_INT16 * const Out, const int Q, const int * const Zigzag, int Non_Zero) const{    // Note: We should search last non-zero coeffs on *real* DCT input coeffs (In[]),     // not quantized one (Out[]). However, it only improves the result *very*     // slightly (~0.01dB), whereas speed drops to crawling level :)    // Well, actually, taking 1 more coeff past Non_Zero into account sometimes helps,  Non_Zero = Find_Last(Out, Zigzag, Non_Zero);  if (Non_Zero<0)      return -1;    struct NODE { SKL_INT16 Run, Level; };  NODE Nodes[65], Last;  SKL_UINT32 Run_Costs0[64+1], * const Run_Costs = Run_Costs0 + 1;  const int Lambda = Trellis_Lambda_Tabs[Q-1];    // it's 1/lambda, actually  int Run_Start = -1;  Run_Costs[-1] = 2<<16;                          // source (w/ CBP penalty)  SKL_UINT32 Min_Cost = 2<<16;  int Last_Node = -1;  SKL_UINT32 Last_Cost = 0;#if (DBG>0)  Last.Level = 0; Last.Run = -1; // just initialize to smthg#endif  int i, j;  for(i=0; i<=Non_Zero; i++)  {    const int q = Quant_Type ? ((Q*Inter_Matrix[Zigzag[i]]) >> 4) : Q;    const int Mult = 2*q;    const int Bias = (q-1) | 1;    const int Lev0 = Mult + Bias;    const SKL_INT16 * const In = Out + 6*64;    const int AC = In[Zigzag[i]];    const int Level1 = Out[Zigzag[i]];    const int Dist0 = Lambda* AC*AC;    Last_Cost += Dist0;    SKL_UINT32 Best_Cost;    if (3U>(SKL_UINT32)(Level1+1))                 // very specialized loop for -1,0,+1    {      int dQ;      if (AC<0) {        Nodes[i].Level = -1;        dQ = Lev0 + AC;      }      else {        Nodes[i].Level = 1;        dQ = Lev0 - AC;      }      const SKL_UINT32 Cost0 = Lambda*dQ*dQ;      Nodes[i].Run = 1;      Best_Cost = (Code_Len20[0]<<16) + Run_Costs[i-1]+Cost0;      for(int Run=i-Run_Start; Run>0; --Run)      {        const SKL_UINT32 Cost_Base = Cost0 + Run_Costs[i-Run];        const SKL_UINT32 Cost = Cost_Base + (Code_Len20[Run-1]<<16);          // TODO: what about tie-breaks? Should we favor short runs or          // long runs? Although the error is the same, it would not be          // spread the same way along high and low frequencies...        if (Cost<Best_Cost)        {          Best_Cost    = Cost;          Nodes[i].Run = Run;        }        const SKL_UINT32 lCost = Cost_Base + (Code_Len24[Run-1]<<16);        if (lCost<Last_Cost)        {          Last_Cost  = lCost;          Last.Run   = Run;          Last_Node  = i;        }      }      if (Last_Node==i) Last.Level = Nodes[i].Level;      if (DBG==1) {        Run_Costs[i] = Best_Cost;        printf( "Costs #%2d: ", i);        for(j=-1;j<=Non_Zero;++j) {          if (j==Run_Start)            printf( " %3.0d|", Run_Costs[j]>>12 );          else if (j>Run_Start && j<i) printf( " %3.0d|", Run_Costs[j]>>12 );          else if (j==i)               printf( "(%3.0d)", Run_Costs[j]>>12 );          else                         printf( "  - |" );        }        printf( "<%3.0d %2d %d>", Min_Cost>>12, Nodes[i].Level, Nodes[i].Run );        printf( "  Last:#%2d {%3.0d %2d %d}", Last_Node, Last_Cost>>12, Last.Level, Last.Run );        printf( " AC:%3.0d Dist0:%3d Dist(%d)=%d", AC, Dist0>>12, Nodes[i].Level, Cost0 );        printf( "\n" );      }    }    else if (51U>(SKL_UINT32)(Level1+25))             // "big" levels (not less than ESC3, though)    {      Best_Cost = 0xf0000000;      const SKL_BYTE *Tbl_L1, *Tbl_L2, *Tbl_L1_Last, *Tbl_L2_Last;      int Level2;      int dQ1, dQ2;      if (Level1>1) {        dQ1 = Level1*Mult-AC + Bias;        dQ2 = dQ1 - Mult;        Level2 = Level1-1;        Tbl_L1      = (Level1<=24) ? B16_17_Code_Len[Level1-1]     : Code_Len0;        Tbl_L2      = (Level2<=24) ? B16_17_Code_Len[Level2-1]     : Code_Len0;        Tbl_L1_Last = (Level1<=6) ? B16_17_Code_Len_Last[Level1-1] : Code_Len0;        Tbl_L2_Last = (Level2<=6) ? B16_17_Code_Len_Last[Level2-1] : Code_Len0;      }      else { // Level1<-1        dQ1 = Level1*Mult-AC - Bias;        dQ2 = dQ1 + Mult;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美揉bbbbb揉bbbbb| 欧美三区在线视频| 美女高潮久久久| 无码av中文一区二区三区桃花岛| 国产精品免费看片| 国产精品色眯眯| 日韩一区欧美一区| 亚洲欧美激情一区二区| 亚洲一区二区精品视频| 天天亚洲美女在线视频| 日韩精品一级中文字幕精品视频免费观看 | 欧美成人免费网站| 精品国产乱码久久久久久影片| 欧美videos中文字幕| 久久精品亚洲精品国产欧美kt∨| 中文av一区特黄| 亚洲欧美日韩系列| 日韩一区欧美二区| 国产ts人妖一区二区| 日本精品视频一区二区三区| 欧美日韩精品一区二区三区 | 中文字幕乱码日本亚洲一区二区| 精品成人在线观看| 中文字幕在线免费不卡| 香蕉成人啪国产精品视频综合网| 日本亚洲天堂网| 国产乱码精品一区二区三区五月婷 | 欧美三级日本三级少妇99| 欧美亚洲一区二区在线观看| 欧美日韩免费电影| 久久亚洲捆绑美女| 亚洲一二三级电影| 国产精品一区二区久久精品爱涩| 成人黄色av网站在线| 欧美顶级少妇做爰| 国产精品素人一区二区| 亚洲精品大片www| 九一久久久久久| 91美女福利视频| 欧美r级电影在线观看| 亚洲欧洲制服丝袜| 精品一区二区三区在线视频| 色婷婷狠狠综合| 久久久噜噜噜久噜久久综合| 亚洲一级电影视频| 国产成人免费视频网站| 91精品久久久久久蜜臀| 亚洲欧美电影院| 国产成人免费视频一区| 91精品国产综合久久精品麻豆 | 99久免费精品视频在线观看 | 精一区二区三区| 在线影院国内精品| 国产精品美女视频| 国产在线视频一区二区三区| 欧美亚洲国产一区二区三区| 中国色在线观看另类| 美日韩黄色大片| 欧美日韩国产bt| 一区二区三区av电影 | 天堂精品中文字幕在线| 91视频免费观看| 国产日韩欧美制服另类| 精品一区二区在线视频| 欧美男男青年gay1069videost| 1024精品合集| www.性欧美| 国产午夜三级一区二区三| 久久99精品久久久久久久久久久久 | 91亚洲男人天堂| 国产精品网站在线观看| 懂色av一区二区夜夜嗨| 国产亚洲人成网站| 国产91精品一区二区麻豆网站| 精品国产伦一区二区三区观看方式 | 91精品国产乱码| 日韩国产欧美在线视频| 717成人午夜免费福利电影| 性做久久久久久免费观看| 91捆绑美女网站| 亚洲欧美视频一区| 91成人国产精品| 亚洲成在人线在线播放| 欧美日韩国产区一| 免费在线成人网| 欧美zozo另类异族| 高潮精品一区videoshd| 国产精品福利一区二区| 色婷婷av一区二区三区之一色屋| 一区av在线播放| 91精品国产福利在线观看| 久久精品久久综合| 国产欧美日韩精品在线| 91性感美女视频| 亚洲成人av资源| 精品国产成人在线影院| 成人avav影音| 天天综合天天做天天综合| 2020日本不卡一区二区视频| 国产精品一二三四| 亚洲综合免费观看高清完整版在线| 欧美日韩一区在线观看| 极品少妇xxxx偷拍精品少妇| 国产精品私人影院| 欧美三级在线播放| 国产美女精品在线| 亚洲欧美一区二区久久| 日韩欧美一区二区三区在线| 国产91精品露脸国语对白| 亚洲一区二区三区在线| 欧美精品一区二区久久久 | 亚洲va欧美va天堂v国产综合| 91精品国产色综合久久ai换脸| 国产不卡在线播放| 午夜精品久久久久久久99水蜜桃 | 成人av网在线| 日日噜噜夜夜狠狠视频欧美人| 国产欧美一区二区精品性色超碰| 色婷婷综合在线| 国产麻豆精品久久一二三| 亚洲风情在线资源站| 日本一区二区三区在线观看| 欧美日韩在线精品一区二区三区激情| 国产精品亚洲第一| 免费成人av资源网| 亚洲国产精品久久人人爱蜜臀| 国产区在线观看成人精品 | 国产精一品亚洲二区在线视频| 亚洲一区二区三区中文字幕| 国产精品美女久久久久久久久久久 | 日韩欧美一级二级三级| 色婷婷综合久久久久中文一区二区| 国内精品在线播放| 欧美96一区二区免费视频| 亚洲六月丁香色婷婷综合久久| 亚洲精品在线免费观看视频| 制服丝袜亚洲播放| 欧美视频日韩视频| 91同城在线观看| av不卡在线观看| 不卡一区中文字幕| 岛国av在线一区| 国产精品911| 国产精品影音先锋| 另类小说视频一区二区| 日本一不卡视频| 蜜臀av一区二区在线观看| 日韩电影在线观看一区| 视频一区视频二区中文| 午夜不卡在线视频| 一区二区三区av电影| 一区二区不卡在线视频 午夜欧美不卡在| 中文字幕乱码久久午夜不卡| 国产精品欧美精品| 国产日韩欧美麻豆| 国产精品三级视频| 国产精品久久久久久久久免费丝袜| 国产三级精品在线| 国产欧美精品一区| 亚洲图片欧美激情| 一区二区三区欧美日| 亚洲一区二区三区四区在线免费观看| 亚洲激情男女视频| 午夜欧美视频在线观看 | 国产精品456| 成人性视频网站| 91亚洲精品乱码久久久久久蜜桃| 91免费在线播放| 欧美日韩黄色一区二区| 91精品国产综合久久久蜜臀粉嫩| 精品日韩一区二区三区| 国产午夜精品在线观看| 国产精品国产三级国产aⅴ无密码| 青娱乐精品视频| 国产精品一区二区黑丝| 色婷婷综合久久久久中文一区二区| 欧美日韩一区小说| 2019国产精品| 亚洲免费av高清| 蜜臀久久99精品久久久久宅男| 久久成人久久鬼色| 99久久久免费精品国产一区二区| 欧美天堂亚洲电影院在线播放| 5858s免费视频成人| 中文字幕免费不卡在线| 亚洲成人免费看| 国产精品自拍三区| 欧美日韩综合在线| 久久综合狠狠综合久久综合88| 中文字幕一区二区三区蜜月 | 国产一区二区三区不卡在线观看| av日韩在线网站| 日韩一级精品视频在线观看| 国产精品你懂的| 美女国产一区二区三区| 欧美在线观看18| 欧美激情中文字幕一区二区| 视频一区中文字幕| 色哟哟在线观看一区二区三区| 欧美精品一区二区高清在线观看|