mediaframe.mpeg1
Class IDCT

java.lang.Object
  |
  +--mediaframe.mpeg1.IDCT

public class IDCT
extends java.lang.Object

This file contains the class "IDCT" which provides methods to perform the inverse discrete cosine transform. Actually a IDFT (inverse discrete fourier transform) is implemented. To gain the DFT values from the DCT values the quantization matrices are multiplied with constants. This occurs only once. The modified quantization values cause a DCT-->DFT transformation during quantization step.

The implementation follows the proposals of Arai, Agiu and Nakajima as well as of Tseng and Miller completed by the extensions made by Feig. The reason is: Their algorithm is a 2-D-approach which consumes only 462 additions, 54 multiplications 6 shifts to the left per block. I thought this were be faster than the ordinary horizontal/vertial- algorithms, which consume more operations. But whether this is really true must be proved (or disproved) by a C implementation.

To understand the algorithm refer to: http://rnvs.informatik.tu-chemnitz.de/~ja/MPEG/HTML/IDCT.html The comments assume you are familar with this page.

To avoid double arithmetics the constants are multiplied with 2^CONST_BITS and the DCT (DFT) coefficients are multiplied with 2^VAL_BITS. This is not a scientific gained result. I tried some values and as I had the impression the error is quite small I took the appropriate values. But feel free to experiment for your own. BUT: If you change VAL_BITS don't forget to translate "MPEG_video.java"! This value is used there.


Field Summary
private  int ALLBITS
          For small error of integer arithmetics the results of IDFT are divided by 2^ALLBITS.
private  int C4
          The constanta "C4" (constanta for the IDFT).
private  int C4C6
          The constanta, equals to C4 * C6 (constants for the IDFT).
private  int C4Q
          The constanta, equals to C4 * Q (constants for the IDFT).
private  int C4R
          The constanta, equals to C4 * R (constants for the IDFT).
private  int C6
          The constanta "C6" (constanta for the IDFT).
private  int CONST_BITS
          For small error of integer arithmetics the constants are multiplied with 2^CONST_BITS.
private static int[][] IDFT_table
          If only one AC coefficient is available the table of pre-computed values is consulted.
private  int[] matr1
          The storage for temporary results of IDFT algorithm.
private  int[] matr2
          The storage for temporary results of IDFT algorithm.
private  int Q
          The constanta "Q" (constanta for the IDFT).
private  int R
          The constanta "R" (constanta for the IDFT).
private  int TWO
          The constanta "2" (constanta for the IDFT).
 int VAL_BITS
          For small error of integer arithmetics the DCT (DFT) coefficients are multiplied with 2^VAL_BITS.
 
Constructor Summary
(package private) IDCT()
          Constructs an IDCT object, initializes the "IDFT_table" and constants.
 
Method Summary
private  void initialize_constants()
          Calculates the constants for the IDFT (C4, C6, C4*C6, Q, C4 * Q, R, C4 * R).
 void invers_dct_special(int[] coeff, int pos)
          The method "invers_dct_special" is called if only one DCT value appears.
 void invers_dct(int[] coeff)
          The method "invers_dct" is an implementation of a full IDCT (actually IDFT).
 void norm(int[] m1)
          The method "norm" performs the modification of the quatization matrices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONST_BITS

private final int CONST_BITS
For small error of integer arithmetics the constants are multiplied with 2^CONST_BITS.

See Also:
Constant Field Values

VAL_BITS

public final int VAL_BITS
For small error of integer arithmetics the DCT (DFT) coefficients are multiplied with 2^VAL_BITS.

See Also:
Constant Field Values

ALLBITS

private final int ALLBITS
For small error of integer arithmetics the results of IDFT are divided by 2^ALLBITS.

See Also:
Constant Field Values

TWO

private final int TWO
The constanta "2" (constanta for the IDFT).

See Also:
Constant Field Values

C6

private int C6
The constanta "C6" (constanta for the IDFT).


C4C6

private int C4C6
The constanta, equals to C4 * C6 (constants for the IDFT).


C4

private int C4
The constanta "C4" (constanta for the IDFT).


Q

private int Q
The constanta "Q" (constanta for the IDFT).


C4Q

private int C4Q
The constanta, equals to C4 * Q (constants for the IDFT).


R

private int R
The constanta "R" (constanta for the IDFT).


C4R

private int C4R
The constanta, equals to C4 * R (constants for the IDFT).


matr1

private int[] matr1
The storage for temporary results of IDFT algorithm.


matr2

private int[] matr2
The storage for temporary results of IDFT algorithm.


IDFT_table

private static int[][] IDFT_table
If only one AC coefficient is available the table of pre-computed values is consulted.

Constructor Detail

IDCT

IDCT()
Constructs an IDCT object, initializes the "IDFT_table" and constants.

Method Detail

initialize_constants

private void initialize_constants()
Calculates the constants for the IDFT (C4, C6, C4*C6, Q, C4 * Q, R, C4 * R).


norm

public void norm(int[] m1)
The method "norm" performs the modification of the quatization matrices. It is called in class "MPEG_video" and changes the quantization values such that a DCT-->DFT tranformation occurs during quantization step.

Parameters:
m1 - the quatization matrice.

invers_dct_special

public void invers_dct_special(int[] coeff,
                               int pos)
The method "invers_dct_special" is called if only one DCT value appears.

Parameters:
coeff - the DC and AC coefficients in de-"zigzag"-ed order.
pos - the position of the DCT value in the input array.

invers_dct

public void invers_dct(int[] coeff)
The method "invers_dct" is an implementation of a full IDCT (actually IDFT). The algorithm is described on WEB page: http://rnvs.informatik.tu-chemnitz.de/~ja/MPEG/HTML/IDCT.html

Parameters:
coeff - the DC and AC coefficients in de-"zigzag"-ed order.