Bases: object
Abstract class to read DVI, PK, TFM and VF streams.
The followings methods are abstracts:
and must be implemented in subclass.
In the followings methods, the position argument is used to specify a position in the stream for the read operation. If position is not None, it seeks to the specified position before to read the stream else it reads from the current position. See also read_bytes().
Read a BCPL string.
The BCPL string format comes from the Basic Combined Programming Language. The length of the string is given by the first byte, thus its length is limited to 256 characters.
Read a signed or an unsigned integer encoded in big endian order with number_of_bytes bytes, cf. read_bytes().
Read number_of_bytes times 8-bit unsigned integers, cf. read_bytes().
Read number_of_bytes bytes from the optional position or the current position. If position, it seeks to the specified position and thus change the current position in the stream.
Read four 8-bit unsigned integers, cf. read_bytes().
Read a 1-byte signed integer, cf. read_big_endian_number().
Read a 2-byte signed integer, cf. read_big_endian_number().
Read a 3-byte signed integer, cf. read_big_endian_number().
Read a 4-byte signed integer, cf. read_big_endian_number().
This tuple permits to get the read_signed_byte method with the number of bytes as index.
Read three 8-bit unsigned integers, cf. read_bytes().
Read a 1-byte unsigned integer, cf. read_big_endian_number().
Read a 2-byte unsigned integer, cf. read_big_endian_number().
Read a 3-byte unsigned integer, cf. read_big_endian_number().
Read a 4-byte unsigned integer, cf. read_big_endian_number().
This tuple permits to get the read_unsigned_byte method with the number of bytes as index.
Bases: PyDvi.Tools.Stream.AbstractStream
Abstract stream class.
The attribute stream must be defined in subclass.
Bases: PyDvi.Tools.Stream.StandardStream
Convert x to a fix word.
A fix word is a 32-bit representation of a binary fraction. A fix word is a signed quantity, with the two’s complement of the entire word used to represent negation. Of the 32 bits in a fix word, exactly 12 are to the left of the binary point; thus, the largest fix word value is 2048 - 2**-20, and the smallest is -2048.
fix word = x / 2**20