<< >>

module_dct_jpeg

The DCT module comprises a heavily optimised DCT function that needs to run in a thread of its own (since it uses all registers of the processor). The DCT function operates in place on 8x8 blocks of 2D data. A block of data is to be stored in memory, the address is to be passed to the function, and on completion the pointer is returned. Between outputting the address, and getting it back, the buffer is owned by the DCT-thread, and shall not be used by any other thread. A common scheme would use a triple buffering scheme, where one buffer is filled with new data, whilst a second buffer is transformed by the DCT thread, whilst the third buffer is compressed using the huffman module.

API

void forwardDCT(streaming chanend blocks, int preprocessedQuant[65])

This function performs zero or more DCT operations, and quantises the result.

Each block address is sent to the DCT process over the channel, and when done the address is sent out over the channel. It is streaming so that a block can always be waiting in the channel. This function should be running inside a thread, and is interfaced to through the streaming channel.

The quant array should have been preprocessed using the quantDCT function.

The functions doDCT and endDCT can be used to interact with the forwardDCT function; if full parallelism is required, then a block address should be sent over the channel, and subsequently a block address should be input for every block address that is output. Some form of double buffering is required to make sure that forwardDCT() “owns” the buffer that it operates on.

This function does not return until it receives an ‘END’ control token over its channel.

Parameters:
  • blocks – The channel end to stream addresses of blocks over
  • preprocessedQuant – array of quantisation values.
int doDCT(streaming chanend blocks, int dataBlock[64])

This is an Interface function to synchronously perform a DCT operation on a single datablock.

Parameters:
  • blocks – The channelend that connects to the forwardDCT function.
  • dataBlock – an 8x8 array of integers on which to perform a quantised DCT.
void endDCT(streaming chanend blocks)

This interface function terminates the forwardDCT function.

Parameters:
  • blocks – The channelend that connects to the forwardDCT function.
void quantDCT(int preprocessedQuant[65], const unsigned char quantisationTable[64])

This function preprocesses the quantisation table for use by forwardDCT.

Note that the preprocessed table is one word longer than the input table.

Parameters:
  • quantisationTable – table with divider values for the quantisation process
  • preprocessedQuant – table to be passed to forwardDCT

Example program

provideBlocks(streaming chanend toDCT) {
for(int i = 0; i < 256; i++) {
doDCT(block1); // This needs to be split
// And needs a better example

}

}

docompress(in quant[]) {

int quant2[65]; quantDCT(quant2, quant);

par {
forwardDCT(toDCT, quant2); provideBlocks(toDCT, toHuffman);

}

}