Jump to content

Projects/Liberty/File Formats/Husqvarna HUS

From KDE Community Wiki
Revision as of 01:34, 17 December 2012 by Purple-bobby (talk | contribs) (Detailed Table)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Husqvarna HUS

This file format appears to describe a stitch out similar to that used in JEF files.

A source of information about this format can be found on this external page: HUS and VIP File Formats. However, as described in that document, the compression technique used seems to be both proprietary and closed, so encoding and decoding of stitch information may prove to be difficult. It depends on whether or not the compression methods used in the ARJ archive format are closely related to those provided in the library used for HUS files.

Compression Parameters

The HUS/VIP compression does seem to use the ARJ decode (1 to 3) with a dictionary size of 1024 instead of 26k.

Parameter Value
CODE_BIT 16
THRESHOLD 3
MAXMATCH 256
DICBIT 10
DICSIZE 1024
NT 19
TBIT 5
NP 15
PTABLESIZE 256
PBIT 5
NC 511
CTABLESIZE 4096
CBIT 9
NPT 19

File Header

Offset Description
0 magic number? (0x00c8fc5d for HUS; 0x0190fc5d for VIP)
4 (looks like an offset into the file, but can be larger than the file extent)
8 number of threads/colours
12, 14 maximum coordinates (16-bit, little endian, signed)
16 (0x10), 18 minimum coordinates (16-bit, little endian, signed)
20 (0x14) offset to data past colour/thread definitions
24 (0x18) unknown (looking at a file with an odd number of bytes where this field is also an odd number suggests that this could be the start of thread position data)
28 (0x1c) unknown (looks like a length or offset)
32-40 (0x20-0x28) Pattern name or null bytes - VIP format includes extra data at 40 (0x28)
40 (0x28) two zero bytes
42 (0x2a) start of colour/thread definitions (2 bytes each)

Detailed Table

Offset Size Type Description
0 2 Byte Signature-1 = 0x5d 0xfc or 0x5b 0xaf
2 2 Int Signature-2 = (little endian) 200 HUS or 400 VIP
4 4 Int Stitch/Time Count
8 4 Int Thread/Colour Count
12 2 Int maximum x coordinates (16-bit, little endian, signed)
14 2 Int maximum y coordinates (16-bit, little endian, signed)
16 (0x10) 2 Int minimum x coordinates (16-bit, little endian, signed)
18 (0x12) 2 Int minimum y coordinates (16-bit, little endian, signed)
20 (0x14) 4 Int file offset to compressed stitch attribute data (move, stitch, thread change)
24 (0x18) 4 Int file offset to compressed stitch x data
28 (0x1c) 4 Int file offset to compressed stitch y data
32 4 Int Unknown = 0, eight byte name
36 4 Int Unknown = 0
40 (0x28) 2 Byte two zero bytes
42 (0x2a) N1 Colour start of colour/thread definitions (HUS: 2 bytes each, VIP: 4 bytes each)

The HUS colour table is Colour-Count 16 bit indices. The VIP colour table is a file-offset to next section, then Colour-Count 32 bit encoded RGB values, followed by Colour-count 32 bit Type/Tension numbers. The VIP file then has a 32 bit number which may be a string length count, followed by 16 bit character string giving the name of the design/pattern.