/** 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; }
/* at this point, the buffer must be a complete dirac packet */ private void Dispatch(Buffer b) { if (b.GetInt(5) != b.Size()) throw new Exception("Incorrect buffer sizes"); byte c = b.GetByte(4); switch(c) { case 0x00: VideoFormat tmp = new VideoFormat(b); if(format == null) { format = tmp; status = Status.OK; } else if(!tmp.Equals(format)) { throw new Exception("Stream Error: Inequal Video Formats"); } break; case 0x10: status = Status.DONE; break; case 0x20: case 0x30: break; default: if(format == null) throw new Exception("Stream Error: Picture Before Header"); Picture pic = new Picture(b, this); pic.Parse(); inQueue.Push(pic); break; } }