gyencode implements the simple version of Gersho and Yano's algorithm. The vectors of datfile (DAT format) are encoded using the Gersho-Yano algorithm, with codebook (CBK format) being the initial codebook. gyencode outputs a channel of VQ indices, channelfile (CHN format), and side information, sideinfofile (SID format). codebook_coder (SQ format) gives the scalar quantizer used to produce the side information (see below).
The Gersho-Yano algorithm operates as follows. Over the vectors of each adaption interval (the length of which is given by adaption_interval), the partition with the greatest partial distortion is split. An iteration of the generalized Lloyd algorithm is run to refine the locations of the two new codewords. One codeword replaces the split codeword; the other replaces the codeword with the smallest partial distortion.
gydecode is used for the corresponding decoding of channelfile and sideinfofile; avqrate calculates the bit rate for the Gersho-Yano algorithm as represented by this channel and the side information. See gydecode(1) and avqrate(1) for more details.
Note: If the number of the vectors in datfile is not a multiple of adaption_interval, then the final adaption interval will contain fewer than adaption_interval vectors.
If option -fc is specified, gyencode outputs the final state of the codebook, taking into account all codebook updates performed during coding, to final_codebook.
The side information output by gyencode consists of a series of addresses and vectors. gyencode updates two vectors per adaption interval. Thus, for each adaption interval, sideinfofile contains two vectors, which update the codebook, as well as their corresponding addresses in the codebook.
The side-information file, sideinfofile, consists of a sequence of symbols of the following form:
<symbol type> <symbol value>
where <symbol type> is 2 for an address, and 3 for an update vector. The symbols are stored in pairs: first an address which is then followed by its correspomding update vector. For an address, <symbol type> = 2, and <symbol value> is an integer (0 through codebook size - 1) denoting the address in the codebook to which the following vector is assigned. If <symbol type> = 3, then the current symbol is a vector. In this case, <symbol value> = v[1] v[2] ... v[dim]. The scalar quantizer codebook_coder (SQ format) is used to quantize each component of the vector that updates the codebook. Thus, each v[i] is an index output from this scalar quantizer. Note: dim is the vector dimension specified in the header of sideinfofile (see QccPack(1) ). Note: in all instances, <symbol value> and <symbol type> are stored in ASCII characters.
Note: The value of adaption_interval is stored in the header of sideinfofile as N (see QccPack(1) ). sideinfofile.
A. Gersho and M. Yano, "Adaptive Vector Quantization by Progressive Codevector Replacement," Proc. ICASSP, pp. 133-136, 1985.