/** Picture: * @param b payload buffer * @param d decoder of the picture * * The b buffer should only point to the payload data section of * the picture (not the header). The only methods that would ever need * to be called are parse(), decode(), and getImage(). However, * one should check wether the error variable is set before and after * calling a method. One should not call them in any other order than that * just specified. Each can be called without arguments and should not be * called twice. */ public Picture(Buffer b, Decoder d) { num = b.GetInt(13); code = b.GetByte(4); buf = b; dec = d; par = new Parameters(code); coeffs = new SubBand[3][]; coeffs[0] = new SubBand[19]; coeffs[1] = new SubBand[19]; coeffs[2] = new SubBand[19]; motion_buffers = new Buffer[9]; status = Decoder.Status.NULL; }
/** synchronized decoding * * Decodes the picture. */ public void Decode() { lock (obj) { if (status != Decoder.Status.OK) return; status = Decoder.Status.WAIT; if (!zero_residual) { InitializeIwtFrames(); DecodeWaveletTransform(); } if (!par.is_intra) { InitializeMCFrames(); DecodeMotionCompensate(); if (zero_residual) iwt_frame = mc_frame; else for (int i = 0; i < 3; i++) mc_frame[i].AddTo(iwt_frame[i]); } if (par.is_ref) { if (retire != 0) dec.refs.Remove(retire + num); dec.refs.Add(num, iwt_frame); } CreateImage(); status = Decoder.Status.DONE; } }
public void Parse() { lock(obj) { if(status != Decoder.Status.NULL) return; status = Decoder.Status.WAIT; try { Unpack u = new Unpack(buf); u.Skip(136); /* 17 * 8 */ ParseHeader(u); par.CalculateIwtSizes(dec.format); if(!par.is_intra) { u.Align(); ParsePredictionParameters(u); par.CalculateMCSizes(); u.Align(); ParseBlockData(u); } u.Align(); if(!par.is_intra) { zero_residual = u.DecodeBool(); } if(!zero_residual) { ParseTransformParameters(u); u.Align(); if(par.is_lowdelay) { ParseLowDelayTransformData(u); } else { ParseTransformData(u); } } status = Decoder.Status.OK; } catch(Exception e) { error = e; status = Decoder.Status.ERROR; } buf = null; } }