00001
00002
00003 #include <stdio.h>
00004 #include "ccvt.h"
00005 #include "conv.h"
00006
00007
00008 void conv_420p_rgb96(int width,int height,void* src,void* dst)
00009 {
00010 static unsigned int oldSize = 0;
00011 static unsigned char* rgb;
00012
00013 unsigned int size = width * height;
00014
00015
00016 if (oldSize < size) {
00017 delete [] rgb;
00018 rgb = new (unsigned char)[size * 4];
00019 }
00020
00021
00022 unsigned char *s = (unsigned char *)src;
00023 int *d = (int *)dst;
00024
00025 static unsigned int offset_U = size;
00026 static unsigned int offset_V = size + size / 4;
00027
00028 unsigned char* Y = s;
00029 unsigned char* U = s + offset_U;
00030 unsigned char* V = s + offset_V;
00031
00032
00033 ccvt_420p_rgb32(width, height, Y, U, V, rgb);
00034 conv_rgb32_rgb96(width, height, rgb, d);
00035 }
00036
00037
00038 void conv_420p_grey(int width,int height,void *src,void *dst)
00039 {
00040 unsigned char *s = (unsigned char *)src;
00041 int *d = (int *)dst;
00042
00043 unsigned int size = width * height;
00044
00045 for (unsigned int i = 0; i < size; i++) *(d++) = *(s++);
00046 }
00047
00048
00049 void conv_rgb24_rgb96(int width, int height, void *src, void *dst)
00050 {
00051 unsigned char** rows = (unsigned char**) src;
00052 unsigned char* s;
00053 int* d = (int*) dst;
00054
00055 for (int j = 0; j < height; j++) {
00056 s = rows[j];
00057
00058 for (int i = 0; i < width; i++) {
00059 *(d++) = *(s++);
00060 *(d++) = *(s++);
00061 *(d++) = *(s++);
00062 }
00063 }
00064 }
00065
00066 void conv_rgb24_grey(int width, int height, void *src, void *dst)
00067 {
00068 unsigned char* s;
00069 int* d = (int*) dst;
00070
00071 s = (unsigned char *)src ;
00072
00073 for (int j = 0; j < height; j++) {
00074
00075 for (int i = 0; i < width; i++) {
00076 *d = *(s++);
00077 *d += *(s++);
00078 *d += *(s++);
00079 *d /= 3 ;
00080 d++ ;
00081 }
00082 }
00083 }
00084
00085
00086
00087 void conv_bgr24_rgb96(int width, int height, void *src, void *dst)
00088 {
00089 unsigned char* s ;
00090 int *d ;
00091 int hw ;
00092
00093 s = (unsigned char*)src ;
00094 d = (int*)dst + 2 ;
00095
00096 hw = width*height ;
00097
00098 for (int j = 0; j < hw; j++, d+=5) {
00099 *(d--) = *(s++);
00100 *(d--) = *(s++);
00101 *(d) = *(s++);
00102 }
00103 }
00104
00105
00106 void conv_rgb32_rgb96(int width,int height,void *src,void *dst)
00107 {
00108 unsigned char *s = (unsigned char *)src;
00109 int *d = (int *)dst;
00110
00111 unsigned int size = width * height;
00112
00113 for (unsigned int i = 0; i < size; i++, s++) {
00114 *(d++) = *(s++);
00115 *(d++) = *(s++);
00116 *(d++) = *(s++);
00117 }
00118 }
00119
00120
00121 void conv_rgb32_grey(int width,int height,void* src,void* dst)
00122 {
00123 unsigned char *s = (unsigned char *)src;
00124 int *d = (int *)dst;
00125
00126 unsigned int size = width * height;
00127
00128 for (unsigned int i = 0; i < size; i++, s++)
00129 *(d++) = (*(s++) + *(s++) + *(s++)) / 3;
00130 }
00131