public override int MarkerDHT(PDJPG_Context ctx, BytePtr buf) { BytePtr cs; int i, j, k, sz, tn; sz = (ushort)((buf[0] << 8) | buf[1]); buf += 2; i = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; // printf("PDJPG_MarkerAPP12: %08X\n", i); if (buf.memcmp("DRCT", 4)) return (-1); cs = buf + 4; i = cs.next(); k = (i >> 4) & 15; j = i & 15; tn = j * 2 + k; for (i = 0; i < 256; i++) { rtab_len[tn * 256 + i] = 0; } for (i = 0; i < 256; i++) { j = (int)cs.ReadSVLI(); if (j <= 0) { if (j == 0) break; i += (-j) - 1; continue; } rtab_len[tn * 256 + i] = j; } SetupRangeTable(tn); return sz; }
public static int PDJPG_MarkerAPP9(PDJPG_Context ctx, BytePtr buf) { // int i; buf += 2; if (!buf.memcmp("JPSERM", 6)) { ctx.jpg_rdct = true; return (1); } return (0); }
public static int PDJPG_MarkerDMLT(PDJPG_Context ctx, BytePtr buf) { BytePtr cs, css; int i, j, k, sz, sz1, tn, tag; sz = (ushort)((buf[0] << 8) | buf[1]); buf += 2; i = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; // printf("PDJPG_MarkerAPP12: %08X\n", i); if (buf.memcmp("DMLT", 4)) return (-1); cs = buf + 4; tag = cs.next(); sz1 = (int)cs.ReadUVLI(); css = cs; while (tag != 0) { switch (tag) { case PDJPG_DMLT_DVFH: ctx.dvfh_lidx = (cs[2] << 8) + cs[3]; break; case PDJPG_DMLT_DHT0: case PDJPG_DMLT_DHT1: case PDJPG_DMLT_DHT2: case PDJPG_DMLT_DHT3: case PDJPG_DMLT_DHT4: case PDJPG_DMLT_DHT5: case PDJPG_DMLT_DHT6: case PDJPG_DMLT_DHT7: i = tag - PDJPG_DMLT_DHT0; ctx.huff.InitStream(ctx, cs); ((PDJHUFF)ctx.huff).BSXRP_DecodeHuffTable(ctx, i); break; case PDJPG_DMLT_DQT0: case PDJPG_DMLT_DQT1: case PDJPG_DMLT_DQT2: case PDJPG_DMLT_DQT3: case PDJPG_DMLT_DQT4: case PDJPG_DMLT_DQT5: case PDJPG_DMLT_DQT6: case PDJPG_DMLT_DQT7: i = tag - PDJPG_DMLT_DQT0; PDJPG_MarkerDMLT_DQT(ctx, cs, i); break; default: break; } cs = css + sz1; tag = cs.next(); sz1 = (int)cs.ReadUVLI(); css = cs; } return 1; }
public static int PDJPG_MarkerAPP12(PDJPG_Context ctx, BytePtr buf) { BytePtr ob, cs, css; int i, sz, sz1, tag; ob = buf; sz = (ushort)((buf[0] << 8) | buf[1]); buf += 2; i = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; // printf("PDJPG_MarkerAPP12: %08X\n", i); if (!buf.memcmp("DMLT", 4)) { i = PDJPG_MarkerDMLT(ctx, ob); return i; } if (!buf.memcmp("BCST", 4)) { ctx.bcst_version = (ushort)((buf[4] << 8) | buf[5]); ctx.bcst_trans = (byte)buf[6]; ctx.bcst_bpp = (byte)buf[7]; ctx.bcst_flags = (uint)((buf[8] << 24) | (buf[9] << 16) | (buf[10] << 8) | buf[11]); if (sz > 14) { ctx.bcst_alpha = (byte)buf[12]; ctx.bcst_blend = (byte)buf[13]; ctx.bcst_orgx = (ushort)((buf[14] << 8) | buf[15]); ctx.bcst_orgy = (ushort)((buf[16] << 8) | buf[17]); ctx.bcst_minx = (ushort)((buf[18] << 8) | buf[19]); ctx.bcst_miny = (ushort)((buf[20] << 8) | buf[21]); ctx.bcst_maxx = (ushort)((buf[22] << 8) | buf[23]); ctx.bcst_maxy = (ushort)((buf[24] << 8) | buf[25]); } else { ctx.bcst_alpha = 255; ctx.bcst_blend = 0; ctx.bcst_orgx = 0; ctx.bcst_orgy = 0; ctx.bcst_minx = 0; ctx.bcst_miny = 0; ctx.bcst_maxx = 0; ctx.bcst_maxy = 0; } ctx.jpg_clrtrans = ctx.bcst_trans; if ((ctx.bcst_flags & PDJPG_BCSFL_RDCT) != 0) ctx.jpg_rdct = true; if ((ctx.bcst_flags & PDJPG_BCSFL_LAYER_HIDDEN) != 0) ctx.layer_hidden = true; if ((ctx.bcst_flags & PDJPG_BCSFL_MEGABLOCK) != 0) ctx.megablock = true; if ((ctx.bcst_flags & PDJPG_BCSFL_ALTVLC) != 0) ctx.altvlc = true; if ((ctx.bcst_flags & PDJPG_BCSFL_AUTODCT) != 0) ctx.auto_dct = true; // printf("PDJPG_MarkerAPP12: BCST %04X %02X %02X %08X\n", // ctx.bcst_version, ctx.bcst_trans, // ctx.bcst_bpp, ctx.bcst_flags); return (1); } if (!buf.memcmp("DRCT", 4)) { if (ctx.huff == null) ctx.huff = new BTJRange(ctx); i = ctx.huff.MarkerDHT(ctx, ob); return i; } return (0); }