about summary refs log tree commit diff
path: root/converter/ppm/ppmtompeg/mquant.c
blob: 0251a142af781431cbd42a6cfc502f8600775d63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "mtypes.h"
#include "mproto.h"

static int qtable[][8] = {
    { 8,16,19,22,26,27,29,34},
    {16,16,22,24,27,29,34,37},
    {19,22,26,27,29,34,34,38},
    {22,22,26,27,29,34,37,40},
    {22,26,27,29,32,35,40,48},
    {26,27,29,32,35,40,48,58},
    {26,27,29,34,38,46,56,69},
    {27,29,35,38,46,56,69,83} };


/*
 *--------------------------------------------------------------
 *
 * mp_quant_block --
 *
 *      Quantizes a block -- removing information
 *      It's safe for out == in.
 *
 * Results:
 *      None.
 *
 * Side effects:
 *      Modifies the out block.
 *
 *--------------------------------------------------------------
 */
void mp_quant_block(Block in, Block out) {
    int i;

    for(i=0;i<8;i++) {
        out[i][0] = in[i][0] / qtable[i][0];
        out[i][1] = in[i][1] / qtable[i][1];
        out[i][2] = in[i][2] / qtable[i][2];
        out[i][3] = in[i][3] / qtable[i][3];
        out[i][4] = in[i][4] / qtable[i][4];
        out[i][5] = in[i][5] / qtable[i][5];
        out[i][6] = in[i][6] / qtable[i][6];
        out[i][7] = in[i][7] / qtable[i][7];
    }
}