OpenCores
URL https://opencores.org/ocsvn/mpdma/mpdma/trunk

Subversion Repositories mpdma

[/] [mpdma/] [trunk/] [mb-vlc/] [mb-zzq.c] - Blame information for rev 28

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 quickwayne
#include "xparameters.h"
2
#include "xutil.h"
3
#include "mb_interface.h"
4
#include "fifo_link.h"
5
 
6
#include "ejpgl.h"
7
#include "mb-zzq.h"
8
 
9
#define XPAR_FSL_FIFO_LINK_0_INPUT_SLOT_ID 0
10
#define XPAR_FSL_FIFO_LINK_0_OUTPUT_SLOT_ID 0
11
 
12
 
13
unsigned char quantization_table[MATRIX_SIZE][MATRIX_SIZE] ={
14
        {4, 3, 3, 4, 4, 5, 6, 6},
15
        {3, 3, 4, 4, 5, 6, 6, 6},
16
        {4, 4, 4, 4, 5, 6, 6, 6},
17
        {4, 4, 4, 5, 6, 6, 6, 6},
18
        {4, 4, 5, 6, 6, 7, 7, 6},
19
        {4, 5, 6, 6, 6, 7, 7, 6},
20
        {6, 6, 6, 6, 7, 7, 7, 7},
21
        {6, 6, 6, 7, 7, 7, 7, 7}
22
    };
23
 
24
signed char bitstream[NUMBER_OF_PIXELS] ;
25
 
26
int zzq_encode_init_start(int compression) {
27
 
28
        return 0;
29
 
30
}
31
 
32
void zzq_encode(signed short pixelmatrix[MATRIX_SIZE][MATRIX_SIZE], int color)
33
{
34
    int i, x, y, jumped, deltax, deltay;
35
 
36
    x = y = deltax = deltay = jumped = 0;
37
 
38
    for(i=0;i<NUMBER_OF_PIXELS;i++)
39
    {
40
                if(pixelmatrix[y][x]>0)
41
                        bitstream[i] = (pixelmatrix[y][x]>>quantization_table[y][x]);
42
                else
43
                        bitstream[i] = -((-pixelmatrix[y][x])>>quantization_table[y][x]);
44
 
45
        if((y == 0) || (y == MATRIX_SIZE-1)) { //on top or bottom side of matrix
46
                if(!jumped) { //first jump to element on the right
47
                        x++;
48
                        jumped = 1;
49
                } else { //modify direction
50
                        if(i<(NUMBER_OF_PIXELS>>1)) {
51
                                deltax = -1;
52
                                deltay = 1;
53
                        } else {
54
                                deltax = 1;
55
                                deltay = -1;
56
                        }
57
                        x += deltax;
58
                        y += deltay;
59
                        jumped = 0;
60
                }
61
        } else if ((x == 0) || (x == MATRIX_SIZE-1)) { //on left or right side of matrix
62
                if(!jumped) { //jump to element below
63
                        y++;
64
                        jumped = 1;
65
                } else { //modify direction
66
                        if(i<(NUMBER_OF_PIXELS>>1)) {
67
                                deltax = 1;
68
                                deltay = -1;
69
                        } else {
70
                                deltax = -1;
71
                                deltay = 1;
72
                        }
73
                        x += deltax;
74
                        y += deltay;
75
                        jumped = 0;
76
                }
77
        }
78
        else {//not on the edges of the matrix
79
                x += deltax;
80
                y += deltay;
81
        }
82
    }
83
 
84
    EncodeDataUnit(bitstream, color);
85
 
86
}
87
//---------------------------------------------------------------------------
88
 
89
signed short dctresult[MATRIX_SIZE][MATRIX_SIZE];
90
 
91
int main() {
92
        int i;
93
        int result;
94
        int color;
95
 
96
  zzq_encode_init_start(0);
97
  vlc_init_start(0);
98
 
99
  for (;;) {
100
 
101
        read_from_fsl(color, XPAR_FSL_FIFO_LINK_0_INPUT_SLOT_ID);
102
 
103
        if (color == 0xff) {
104
                HuffmanEncodeFinishSend();
105
                }
106
        else {
107
        for (i=0; i<64; i++){
108
                read_from_fsl(result, XPAR_FSL_FIFO_LINK_0_INPUT_SLOT_ID);
109
                ((short*)dctresult)[i] = result;
110
                }
111
 
112
        zzq_encode(dctresult, color);
113
                }
114
 
115
        }
116
 
117
}
118
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.