public Bitmap[] load(Stream stream) { BinaryReader binaryReader = new BinaryReader(stream); if (binaryReader.ReadChar() != id) { // } width = binaryReader.ReadInt32(); height = binaryReader.ReadInt32(); //intra frame int count = binaryReader.ReadInt32(); YEncode = new List <byte>(binaryReader.ReadBytes(count)); count = binaryReader.ReadInt32(); CbEncode = new List <byte>(binaryReader.ReadBytes(count)); count = binaryReader.ReadInt32(); CrEncode = new List <byte>(binaryReader.ReadBytes(count)); //inter frame count = binaryReader.ReadInt32(); YEncodeInter = new List <byte>(binaryReader.ReadBytes(count)); count = binaryReader.ReadInt32(); CbEncodeInter = new List <byte>(binaryReader.ReadBytes(count)); count = binaryReader.ReadInt32(); CrEncodeInter = new List <byte>(binaryReader.ReadBytes(count)); //motion vector int x = binaryReader.ReadInt32(); int y = binaryReader.ReadInt32(); YMoVec = new Point[x, y]; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { YMoVec[i, j].X = binaryReader.ReadSByte(); YMoVec[i, j].Y = binaryReader.ReadSByte(); } } x = binaryReader.ReadInt32(); y = binaryReader.ReadInt32(); CbMoVec = new Point[x, y]; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { CbMoVec[i, j].X = binaryReader.ReadSByte(); CbMoVec[i, j].Y = binaryReader.ReadSByte(); } } x = binaryReader.ReadInt32(); y = binaryReader.ReadInt32(); CrMoVec = new Point[x, y]; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { CrMoVec[i, j].X = binaryReader.ReadSByte(); CrMoVec[i, j].Y = binaryReader.ReadSByte(); } } Bitmap[] ret = new Bitmap[2]; ret[0] = new Bitmap(width, height); ret[1] = new Bitmap(width, height); //decode intra frame YQuant = decoding(YEncode, width, height); CbQuant = decoding(CbEncode, width / 2, height / 2); CrQuant = decoding(CrEncode, width / 2, height / 2); YDCT = invQuantization(YQuant); CbDCT = invQuantization(CbQuant); CrDCT = invQuantization(CrQuant); Y = inverseDCT(YDCT, width, height); Cb = inverseDCT(CbDCT, Cb.GetLength(0), Cb.GetLength(1)); Cr = inverseDCT(CrDCT, Cr.GetLength(0), Cr.GetLength(1)); unsubSampling(ref Cb, ref Cr); YCbCrtoRGB(ret[0], Y, Cb, Cr); //decode inter frame subSampling(ref Cb, ref Cr); YQuantInter = decoding(YEncodeInter, width, height); CbQuantInter = decoding(CbEncodeInter, width / 2, height / 2); CrQuantInter = decoding(CrEncodeInter, width / 2, height / 2); YDCTInter = invQuantization(YQuantInter); CbDCTInter = invQuantization(CbQuantInter); CrDCTInter = invQuantization(CrQuantInter); YDif = inverseDCTInter(YDCTInter, width, height); CbDif = inverseDCTInter(CbDCTInter, CbInter.GetLength(0), CbInter.GetLength(1)); CrDif = inverseDCTInter(CrDCTInter, CrInter.GetLength(0), CrInter.GetLength(1)); YInter = unCalcDifference(Y, YMoVec, YDif); CbInter = unCalcDifference(Cb, CbMoVec, CbDif); CrInter = unCalcDifference(Cr, CrMoVec, CrDif); unsubSampling(ref CbInter, ref CrInter); YCbCrtoRGB(ret[1], YInter, CbInter, CrInter); return(ret); }