00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "mmsgui/fb/mmsfbconv.h"
00034
00035 #ifdef __HAVE_PF_AYUV__
00036 #ifdef __HAVE_PF_RGB16__
00037
00038 #include "mmstools/mmstools.h"
00039
00040 void mmsfb_blit_blend_ayuv_to_rgb16(MMSFBExternalSurfaceBuffer *extbuf, int src_height, int sx, int sy, int sw, int sh,
00041 unsigned short int *dst, int dst_pitch, int dst_height, int dx, int dy) {
00042
00043 static bool firsttime = true;
00044 if (firsttime) {
00045 printf("DISKO: Using accelerated blend AYUV to RGB16.\n");
00046 firsttime = false;
00047 }
00048
00049
00050 unsigned int *src = (unsigned int *)extbuf->ptr;
00051 int src_pitch = extbuf->pitch;
00052
00053
00054 int src_pitch_pix = src_pitch >> 2;
00055 int dst_pitch_pix = dst_pitch >> 1;
00056 src+= sx + sy * src_pitch_pix;
00057 dst+= dx + dy * dst_pitch_pix;
00058
00059
00060 if (dst_pitch_pix - dx < sw - sx)
00061 sw = dst_pitch_pix - dx - sx;
00062 if (dst_height - dy < sh - sy)
00063 sh = dst_height - dy - sy;
00064 if ((sw <= 0)||(sh <= 0))
00065 return;
00066
00067 unsigned short int OLDDST = (*dst) + 1;
00068 unsigned int OLDSRC = (*src) + 1;
00069 unsigned int *src_end = src + src_pitch_pix * sh;
00070 int src_pitch_diff = src_pitch_pix - sw;
00071 int dst_pitch_diff = dst_pitch_pix - sw;
00072 register unsigned short int d;
00073
00074
00075
00076 while (src < src_end) {
00077
00078 unsigned int *line_end = src + sw;
00079 while (src < line_end) {
00080
00081 register unsigned int SRC = *src;
00082
00083
00084 register unsigned int A = SRC >> 24;
00085 if (A == 0xff) {
00086
00087 unsigned int y = (SRC << 8) >> 24;
00088 unsigned int u = (SRC << 16) >> 24;
00089 unsigned int v = SRC & 0xff;
00090 unsigned int R;
00091 unsigned int G;
00092 unsigned int B;
00093
00094 MMSFB_CONV_PREPARE_YUV2RGB(y,u,v);
00095 MMSFB_CONV_YUV2R(y,u,v,R);
00096 MMSFB_CONV_YUV2G(y,u,v,G);
00097 MMSFB_CONV_YUV2B(y,u,v,B);
00098
00099 *dst = ((R >> 3) << 11)
00100 | ((G >> 2) << 5)
00101 | (B >> 3);
00102 }
00103 else
00104 if (A) {
00105
00106 register unsigned short int DST = *dst;
00107
00108 if ((DST==OLDDST)&&(SRC==OLDSRC)) {
00109
00110 *dst = d;
00111 dst++;
00112 src++;
00113 continue;
00114 }
00115 OLDDST = DST;
00116 OLDSRC = SRC;
00117
00118 register unsigned int SA= 0x100 - A;
00119 unsigned int r = (DST >> 11) << 3;
00120 unsigned int g = (DST & 0x07e0) >> 3;
00121 unsigned int b = (DST & 0x1f) << 3;
00122
00123
00124 r = SA * r;
00125 g = SA * g;
00126 b = SA * b;
00127
00128
00129 unsigned int y = (SRC << 8) >> 24;
00130 unsigned int u = (SRC << 16) >> 24;
00131 unsigned int v = SRC & 0xff;
00132 unsigned int R;
00133 unsigned int G;
00134 unsigned int B;
00135 MMSFB_CONV_PREPARE_YUV2RGB(y,u,v);
00136 MMSFB_CONV_YUV2RX(y,u,v,R);
00137 MMSFB_CONV_YUV2GX(y,u,v,G);
00138 MMSFB_CONV_YUV2BX(y,u,v,B);
00139
00140
00141 r += (A*R) >> 8;
00142 g += (A*G) >> 8;
00143 b += (A*B) >> 8;
00144 d = ((r >> 16) ? 0xf800 : (r & 0xf800))
00145 | ((g >> 16) ? 0x07e0 : ((g >> 10) << 5))
00146 | ((b >> 16) ? 0x1f : (b >> 11));
00147 *dst = d;
00148 }
00149
00150 dst++;
00151 src++;
00152 }
00153
00154
00155 src+= src_pitch_diff;
00156 dst+= dst_pitch_diff;
00157 }
00158 }
00159
00160 #endif
00161 #endif