當前位置: 首頁>>代碼示例>>C#>>正文


C# BitWriter.WriteVarIntSigned方法代碼示例

本文整理匯總了C#中BitWriter.WriteVarIntSigned方法的典型用法代碼示例。如果您正苦於以下問題:C# BitWriter.WriteVarIntSigned方法的具體用法?C# BitWriter.WriteVarIntSigned怎麽用?C# BitWriter.WriteVarIntSigned使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BitWriter的用法示例。


在下文中一共展示了BitWriter.WriteVarIntSigned方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: EncodePrediction

 private unsafe byte[] EncodePrediction(Bitmap Frame)
 {
     //We'll just look if there are blocks that are 100% the same first
     BitmapData d = Frame.LockBits(new Rectangle(0, 0, Frame.Width, Frame.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
     BitmapData prev = PastFrames[1].LockBits(new Rectangle(0, 0, Frame.Width, Frame.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
     for (int y = 0; y < Height; y += 16)
     {
         for (int x = 0; x < Width; x += 16)
         {
             MacroBlocks[y / 16][x / 16] = new MacroBlock(d, x, y);
             bool same = true;
             for (int y2 = 0; y2 < 16; y2++)
             {
                 ulong* pA = (ulong*)(((byte*)d.Scan0) + (y + y2) * d.Stride + x * 4);
                 ulong* pB = (ulong*)(((byte*)prev.Scan0) + (y + y2) * prev.Stride + x * 4);
                 for (int x2 = 0; x2 < 16; x2+=2)
                 {
                     ulong color = *pA++;
                     ulong color2 = *pB++;
                     if (color != color2)
                     {
                         same = false;
                         break;
                     }
                 }
                 if (!same) break;
             }
             if (same) MacroBlocks[y / 16][x / 16].Predict = true;
             else
             {
                 Analyzer.ConfigureBlockY(this, MacroBlocks[y / 16][x / 16]);
                 int blocktype2 = Analyzer.AnalyzeBlockUV(this, MacroBlocks[y / 16][x / 16]);
                 MacroBlocks[y / 16][x / 16].UVPredictionMode = blocktype2;
                 MacroBlocks[y / 16][x / 16].UVUseComplex8x8[0] = true;
                 MacroBlocks[y / 16][x / 16].UVUseComplex8x8[1] = true;
                 MacroBlocks[y / 16][x / 16].SetupDCTs(this);
             }
         }
     }
     Frame.UnlockBits(d);
     PastFrames[1].UnlockBits(prev);
     BitWriter b = new BitWriter();
     b.WriteBits(0, 1);//Interframe
     b.WriteVarIntSigned(0);
     for (int y = 0; y < Height; y += 16)
     {
         for (int x = 0; x < Width; x += 16)
         {
             MacroBlock curblock = MacroBlocks[y / 16][x / 16];
             if (curblock.Predict)
             {
                 b.WriteBits(1, 1);
                 b.WriteVarIntUnsigned(0);
             }
             else
             {
                 b.WriteBits(0xE >> 1, 5);
                 EncodeBlockIntra(curblock, b);
             }
         }
     }
     b.WriteBits(0, 16);
     b.Flush();
     byte[] result = b.ToArray();
     return result;
 }
開發者ID:elfinlazz,項目名稱:MobiclipDecoder,代碼行數:66,代碼來源:MobiEncoder.cs


注:本文中的BitWriter.WriteVarIntSigned方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。