BOOL GradientRectangle(HDC hDC, int x0, int y0, int x1, int y1, COLORREF c0, COLORREF c1, int angle) { TRIVERTEX vert[4] = { { x0, y0, R16(c0), G16(c0), B16(c0), 0 }, // 0:c0 3:(c0+c1)/2 { x1, y1, R16(c1), G16(c1), B16(c1), 0 }, // { x0, y1, R16(c0, c1), G16(c0, c1), B16(c0, c1), 0 }, // { x1, y0, R16(c0, c1), G16(c0, c1), B16(c0, c1), 0 } // 2:(c0+c1)/2 1: c1 }; ULONG Index[] = { 0, 1, 2, 0, 1, 3}; switch ( angle % 180 ) { case 0: return GradientFill(hDC, vert, 2, Index, 1, GRADIENT_FILL_RECT_H); case 45: return GradientFill(hDC, vert, 4, Index, 2, GRADIENT_FILL_TRIANGLE); case 90: return GradientFill(hDC, vert, 2, Index, 1, GRADIENT_FILL_RECT_V); case 135: vert[0].x = x1; vert[3].x = x0; vert[1].x = x0; vert[2].x = x1; return GradientFill(hDC, vert, 4, Index, 2, GRADIENT_FILL_TRIANGLE); } return FALSE; }
int IsArmPopMul(INSTR instr) { if(B16(1000,10111101)==instr.popMul.be100010111101) { if(B8(1)==instr.popMul.bits&B16(1000000,00000000)) return 0; } return -1; }
int IsThumbLoadMul(INSTR instr) { if(B16(11,10100010)==instr.tloadMultiple.be1110100010) { if(1==instr.tloadMultiple.bits1&B16(1000000,00000000)) return 0; } return -1; }
int IsArmPopSingal(INSTR instr) { if(B16(0000,00000100)==instr.popSingal.be000000000100 && B16(0100,10011101)==instr.popSingal.be010010011101) { if(B8(1)==instr.popSingal.rt) return 0; } return -1; }
int IsThumbPopSinal(INSTR instr) { if(B16(1011,00000100)==instr.tpopSingal.be101100000100 && B16(11111000,01011101)==instr.tpopSingal.be1111100001011101) { if(15==instr.tpopSingal.rt) return 0; } return -1; }
int blur_16(mapa_t *mapa, uint32_t w, uint32_t h, int radio) { int c, f, pos; uint32_t prom; pixel_16 *matrix, *inicio; inicio=mapa->map_16; matrix=(pixel_16*)malloc((w*h)*sizeof(pixel_16)); for(f=0;f<h;f++) { for(c=0;c<w;c++) { pos = c+(f*w); prom=promPixels(mapa, w, h, 16, c, f, radio); (matrix+pos)->r = R16(prom); (matrix+pos)->g = G16(prom); (matrix+pos)->b = B16(prom); } } free(mapa->map_16); /*Se libera memoria.*/ mapa->map_16=matrix; return 1; } /*Fn blur_16*/
int IsThumbTableBranch(INSTR instr) { if(B8(000)==instr.ttableBranch.be000 && B16(1110,10001101)==instr.ttableBranch.be111010001101) return 0; return -1; }
int IsArmDataPrcImm(INSTR instr) { if(B8(001)==instr.dataProcssingImm.be001) { if(15==instr.dataProcssingImm.bits1&B16(11110000,00000000)) return 0; } return -1; }
int IsArmLoadMul(INSTR instr) { if(B8(1)==instr.loadMultiple.be1 && B8(1)==instr.loadMultiple.is1 && B8(100)==instr.loadMultiple.be100) { if(B8(1)==instr.loadMultiple.registers&B16(1000000,00000000)) { return 0; } } return -1; }
int IsThumbMovReg(INSTR instr) { if(B8(01000110)==instr.tmoveRes.tMoveRes1.be01000110) { if(15==(instr.tmoveRes.tMoveRes1.rd1+instr.tmoveRes.tMoveRes1.rd2*8)) return 0; } else if(B16(00,00000000)==instr.tmoveRes.tMoveRes2.be0000000000) { if(15==instr.tmoveRes.tMoveRes2.rd) return 0; } return -1; }
inline void AlphaBlend( Uint16& p, int cr, int cg, int cb, int a, int ia ) { //565 p = R16G16B16_TO_RGB565( a * cr + ia * R16(p), a * cg + ia * G16(p), a * cb + ia * B16(p) ); }
void ExtractRgb( uint16 c, int& r, int &g, int &b ) { r = R16(c); g = G16(c); b = B16(c); }
int ltc_decode(SMPTEDecoder *d, unsigned char *bits, unsigned long *offset, long int posinfo, int size) { int i; int bitNum, bitSet, bytePos; for (i = 0 ; i < size ; i++) { if (d->decodeBitCnt == 0) { memset(&d->decodeFrame, 0, sizeof(SMPTEFrame)); if (i > 0) { d->decodeFrameStartPos = posinfo + offset[i-1]; } else { d->decodeFrameStartPos = posinfo + offset[i] - d->soundToBiphasePeriod; // d->soundToBiphasePeriod is an approximation } } #ifdef TRACK_DECODE_FRAME_BIT_OFFSETS d->decodeFrameBitOffsets[d->decodeBitCnt] = posinfo + offset[i]; #endif d->decodeSyncWord <<= 1; if (bits[i]) { d->decodeSyncWord |= B16(00000000,00000001); if (d->decodeBitCnt < LTC_FRAME_BIT_COUNT) { // Isolating the lowest three bits: the location of this bit in the current byte bitNum = (d->decodeBitCnt & B8(00000111)); // Using the bit number to define which of the eight bits to set bitSet = (B8(00000001) << bitNum); // Isolating the higher bits: the number of the byte/char the target bit is contained in bytePos = d->decodeBitCnt >> 3; (((unsigned char*)&d->decodeFrame)[bytePos]) |= bitSet; } } d->decodeBitCnt++; if (d->decodeSyncWord == B16(00111111,11111101) /*LTC Sync Word 0x3ffd*/) { if (d->decodeBitCnt == LTC_FRAME_BIT_COUNT) { int frame = FR_toint(&d->fps)* (60*60*( d->decodeFrame.hoursTens*10 + d->decodeFrame.hoursUnits) + 60* (d->decodeFrame.minsTens*10 + d->decodeFrame.minsUnits) + (d->decodeFrame.secsTens*10 + d->decodeFrame.secsUnits) ) + d->decodeFrame.frameTens*10 + d->decodeFrame.frameUnits; if ( (d->lastFrame == 0) && (d->firstFrame == 0) ) { d->firstFrame = frame; d->lastFrame = frame; } else if ( (frame - d->lastFrame) != 1 ) { d->errorCnt++; } d->lastFrame = frame; memcpy( &d->queue[d->qWritePos].base, &d->decodeFrame, sizeof(SMPTEFrame)); if (d->correctJitter) d->queue[d->qWritePos].delayed = size-i; else d->queue[d->qWritePos].delayed = 0; // TODO: compare: sampleRate*80*soundToBiphasePeriod*delayed d->queue[d->qWritePos].startpos = d->decodeFrameStartPos; d->queue[d->qWritePos].endpos = posinfo + offset[i]; //d->queue[d->qWritePos].startpos = d->decodeFrameBitOffsets[0]; //d->queue[d->qWritePos].endpos = d->decodeFrameBitOffsets[LTC_FRAME_BIT_COUNT-1]; d->qWritePos++; if (d->qWritePos == d->qLen) d->qWritePos = 0; } d->decodeBitCnt = 0; } }