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

Subversion Repositories mpdma

[/] [mpdma/] [trunk/] [mb-bmp2jpg/] [zzq.c] - Blame information for rev 18

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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