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

Subversion Repositories mpdma

[/] [mpdma/] [trunk/] [mb-bmp2jpg/] [ColorConversion.c] - Blame information for rev 22

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

Line No. Rev Author Line
1 7 quickwayne
#include <stdio.h>
2 22 quickwayne
#include "xutil.h"
3
#include "mb_interface.h"
4
#include "fifo_link.h"
5
 
6
#include "ejpgl.h"
7 7 quickwayne
#include "io.h"
8
 
9 22 quickwayne
#define XPAR_FSL_FIFO_LINK_0_INPUT_SLOT_ID 0
10
#define XPAR_FSL_FIFO_LINK_0_OUTPUT_SLOT_ID 0
11
 
12
void put_char(unsigned char c);
13
 
14
int cc_init_start() {
15
 
16
        return 0;
17
 
18
}
19
 
20
void check_fsl() {
21
        unsigned long result;
22
        unsigned long status;
23
        unsigned char ch;
24
 
25
        for (;;) {
26
        microblaze_nbread_datafsl(result, 0);
27
        asm volatile ("mfs %0, rmsr" : "=d" (status));
28
        if (status & 0x80000000) return;
29
//              xil_printf("-->%x-%x\r\n", result, status);
30
        ch = result;
31
        put_char(ch);
32
                }
33
        return;
34
 
35
}
36
 
37
void RGB2YCrCb(signed char pixelmatrix[MACRO_BLOCK_SIZE][MACRO_BLOCK_SIZE*3],signed char YMatrix[MATRIX_SIZE][MATRIX_SIZE],signed char CrMatrix[MATRIX_SIZE][MATRIX_SIZE],signed char CbMatrix[MATRIX_SIZE][MATRIX_SIZE], unsigned int sample)
38
{
39
        int i;
40
        int result;
41
        int msg;
42
 
43
        msg = 0;
44
       write_into_fsl(msg, XPAR_FSL_FIFO_LINK_0_OUTPUT_SLOT_ID);
45
 
46
        for (i=0; i<MACRO_BLOCK_SIZE*MACRO_BLOCK_SIZE*3; i++) {
47
                check_fsl();
48
                result = ((signed char*)pixelmatrix)[i];
49
                write_into_fsl(result, XPAR_FSL_FIFO_LINK_0_OUTPUT_SLOT_ID);
50
                }
51
                check_fsl();
52
 
53
}
54
 
55
int cc_end_done() {
56
        int msg;
57
 
58
        msg=0xff;
59
 
60
        write_into_fsl(msg, XPAR_FSL_FIFO_LINK_0_OUTPUT_SLOT_ID);
61
        return 0;
62
 
63
}
64
 
65
#if 0
66
 
67 7 quickwayne
#define RGB2Y(r, g, b)     (((66*r + 129*g + 25*b + 128)>>8)+128)
68
#define RGB2Cr(r, g, b)    (((-38*r - 74*g + 112*b + 128)>>8)+128)
69
#define RGB2Cb(r, g, b)   (((112*r - 94*g - 18*b + 128)>>8)+128)
70
 
71
void RGB2YCrCb(signed char pixelmatrix[MACRO_BLOCK_SIZE][MACRO_BLOCK_SIZE*3],signed char YMatrix[MATRIX_SIZE][MATRIX_SIZE],signed char CrMatrix[MATRIX_SIZE][MATRIX_SIZE],signed char CbMatrix[MATRIX_SIZE][MATRIX_SIZE], unsigned int sample)
72
{
73
        unsigned int row, col, rowoffset, coloffset, xoffset, yoffset;
74
        for(row = 0;row < MATRIX_SIZE; row++) {
75
                for(col = 0; col < MATRIX_SIZE; col++) {
76
                        coloffset = (sample&0x01)*8;
77
                        rowoffset = (sample&0x02)*4;
78
                        YMatrix[row][col] = RGB2Y(pixelmatrix[row+rowoffset][(col+coloffset)*3+2],pixelmatrix[row+rowoffset][(col+coloffset)*3+1],pixelmatrix[row+rowoffset][(col+coloffset)*3]) - 128;
79
                        if (col%2==0) {
80
                                yoffset = (sample&0x01)*4;
81
                                xoffset = (sample&0x02)*2;
82
                                if (row%2==0) {
83
                                        CrMatrix[xoffset+(row>>1)][yoffset+(col>>1)] = RGB2Cr(pixelmatrix[row+rowoffset][(col+coloffset)*3+2],pixelmatrix[row+rowoffset][(col+coloffset)*3+1],pixelmatrix[row+rowoffset][(col+coloffset)*3]) - 128;
84
                                } else {
85
                                        CbMatrix[xoffset+((row)>>2)][yoffset+(col>>2)] = RGB2Cb(pixelmatrix[row+rowoffset][(col+coloffset)*3+2],pixelmatrix[row+rowoffset][(col+coloffset)*3+1],pixelmatrix[row+rowoffset][(col+coloffset)*3]) - 128;
86
                                }
87
                        }
88
                }
89
        }
90
}
91 22 quickwayne
 
92
#endif
93
 

powered by: WebSVN 2.1.0

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