Ana səhifə

Contents Page


Yüklə 2.59 Mb.
səhifə11/35
tarix25.06.2016
ölçüsü2.59 Mb.
1   ...   7   8   9   10   11   12   13   14   ...   35

7.4 Inverse quantisation


The two-dimensional array of coefficients, QF[v][u], is inverse quantised to produce the reconstructed DCT coefficients. This process is essentially a multiplication by the quantiser step size. The quantiser step size is modified by two mechanisms; a weighting matrix is used to modify the step size within a block and a scale factor is used in order that the step size can be modified at the cost of only a few bits (as compared to encoding an entire new weighting matrix).



Figure 7-4. Inverse quantisation process

Figure 7-4 illustrates the overall inverse quantisation process. After the appropriate inverse quantisation arithmetic the resulting coefficients, F''[v][u], are saturated to yield F'[v][u] and then a mismatch control operation is performed to give the final reconstructed DCT coefficients, F[v][u].

NOTE - Attention is drawn to the fact that the method of achieving mismatch control in this specification is different to that employed by ISO/IEC 11172-2.

7.4.1 Intra DC coefficient


The DC coefficients of intra coded blocks shall be inverse quantised in a different manner to all other coefficients.

In intra blocks F’’[0][0] shall be obtained by multiplying QF[0][0] by a constant multiplier, intra_dc_mult, (constant in the sense that it is not modified by either the weighting matrix or the scale factor). The multiplier is related to the parameter intra_dc_precision that is encoded in the picture coding extension. Table 7-4 specifies the relation between intra_dc_precision and intra_dc_mult.



Table 7-4. Relation between intra_dc_precision and intra_dc_mult

intra_dc_precision

Bits of precision

intra_dc_mult

0

8

8

1

9

4

3


11

1

Thus;

7.4.2 Other coefficients


All coefficients other than the DC coefficient of an intra block shall be inverse quantised as specified in this clause.

7.4.2.1 Weighting matrices


When 4:2:0 data is used two weighting matrices are used. One shall be used for intra macroblocks and the other for non-intra macroblocks. When 4:2:2 or 4:4:4 data is used, four matrices are used allowing different matrices to be used for luminance and chrominance data. Each matrix has a default set of values which may be overwritten by down-loading a user defined matrix as explained in 6.2.3.2.

Let the weighting matrices be denoted by W[w][v][u] where w takes the values 0 to 3 indicating which of the matrices is being used. Table 7-5 summarises the rules governing the selection of w.



Table 7-5. Selection of w




4:2:0




4:2:2 and 4:4:4







luminance

(cc = 0)

chrominance

(cc ≠ 0)

luminance

(cc = 0)

chrominance

(cc ≠ 0)

intra blocks

(macroblock_intra = 1)

0

0

0

2

non-intra blocks

(macroblock_intra = 0)

1

1

1

3


7.4.2.2 Quantiser scale factor


The quantisation scale factor is encoded as a 5 bit fixed length code, quantiser_scale_code. This indicates the appropriate quantiser_scale to apply in the inverse quantisation arithmetic.

q_scale_type (encoded in the picture coding extension) indicates which of two mappings between quantiser_scale_code and quantiser_scale shall apply. Table 7-6 shows the two mappings between quantiser_scale_code and quantiser_scale.



Table 7-6. Relation between quantiser_scale and quantiser_scale_code




quantiser_scale[q_scale_type]




quantiser_scale_code

q_scale_type = 0

q_scale_type = 1

0

(forbidden)




1

2

1

31


62

112


7.4.2.3 Reconstruction formulae


The following equation specifies the arithmetic to reconstruct F''[v][u] from QF[v][u] (for all coefficients except intra DC coefficients).

NOTE - The above equation uses the “/” operator as defined in 4.1.


7.4.3 Saturation


The coefficients resulting from the Inverse Quantisation Arithmetic are saturated to lie in the range . Thus:


7.4.4 Mismatch control


Mismatch control shall be performed by any process equivalent to the following. Firstly all of the reconstructed, saturated coefficients, F'[v][u] in the block shall be summed. This value is then tested to determine whether it is odd or even. If the sum is even then a correction shall be made to just one coefficient; F[7][7]. Thus:

NOTES -


1 It may be useful to note that the above correction for F[7][7] may simply be implemented by toggling the least significant bit of the twos complement representation of the coefficient. Also since only the “oddness” or “evenness” of the sum is of interest an exclusive OR (of just the least significant bit) may be used to calculate “sum”.

2 Warning. Small non-zero inputs to the IDCT may result in zero output for compliant IDCTs. If this occurs in an encoder, mismatch may occur in some pictures in a decoder that uses a different compliant IDCT. An encoder should avoid this problem and may do so by checking the output of its own IDCT. It should ensure that it never inserts any non-zero coefficients into the bitstream when the block in question reconstructs to zero through its own IDCT function. If this action is not taken by the encoder, situations can arise where large and very visible mismatches between the state of the encoder and decoder occur.


7.4.5 Summary


In summary the inverse quantisation process is any process numerically equivalent to:

for (v=0; v<8;v++) {

for (u=0; u<8;u++) {

if ( (u==0) && (v==0) && (macroblock_intra) ) {

F''[v][u] = intra_dc_mult * QF[v][u];

} else {

if ( macroblock_intra ) {

F''[v][u] = ( QF[v][u] * W[w][v][u] * quantiser_scale * 2 ) / 32;

} else {

F''[v][u] = ( ( ( QF[v][u] * 2 ) + Sign(QF[v][u]) ) * W[w][v][u]

* quantiser_scale ) / 32;

}

}



}

}

sum = 0;

for (v=0; v<8;v++) {

for (u=0; u<8;u++) {

if ( F’'[v][u] > 2047 ) {

F’[v][u] = 2047;

} else {

if ( F’'[v][u] < -2048 ) {

F’[v][u] = -2048;

} else {

F’[v][u] = F'‘[v][u];

}

}



sum = sum + F’[v][u];

F[v][u] = F’[v][u];

}

}

if ((sum & 1) == 0) {



if ((F[7][7] & 1) != 0) {

F[7][7] = F'[7][7] - 1;

} else {

F[7][7] = F'[7][7] + 1;

}

}

1   ...   7   8   9   10   11   12   13   14   ...   35


Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©atelim.com 2016
rəhbərliyinə müraciət