예제 #1
0
파일: yuyv.c 프로젝트: adabsurdum/libvideo
void yuyv2rgb( const uint16_t *yuyv, int w, int h, uint8_t *o ) {

	for(int r = 0; r < h; r++ ) {
#if 0
		/**
		  * ...grayscale rendered as 24-bit color in the process.
		  */
		for(c = 0; c < w; c++ ) {
			const uint8_t GRAY
				= (uint8_t)(0x00FF & yuyv[ r*w + c ]);
			o[ 4*w*r + 4*c+2 ] = GRAY; // red
			o[ 4*w*r + 4*c+1 ] = GRAY; // green
			o[ 4*w*r + 4*c+0 ] = GRAY; // blue
		}
#else
		/**
		  * ...24-bit color in the process.
		  */
		const uint8_t *iline
			= (const uint8_t*)(yuyv  + r*w );
		uint8_t *oline = o + r*w*3;
		for(int c = 0; c < 2*w; c+=4 ) {
			const int Y0 = iline[c+0];
			const int U  = iline[c+1];
			const int Y1 = iline[c+2];
			const int V  = iline[c+3];
			YUV2RGB( Y0, U, V, oline + 3*(c/2+0) );
			YUV2RGB( Y1, U, V, oline + 3*(c/2+1) );
		}
#endif
	}
}
예제 #2
0
파일: convertvid.cpp 프로젝트: K0F/FreeJ
int mlt_convert_yuv422_to_rgb24a(uint8_t *yuv, uint8_t *rgba, unsigned int total) {
    int ret = 0;
    int yy, uu, vv;
    int r, g, b;
    total /= 2;
    while(total--) {
        yy = yuv[0];
        uu = yuv[1];
        vv = yuv[3];
        YUV2RGB(yy, uu, vv, r, g, b);
        rgba[0] = r;
        rgba[1] = g;
        rgba[2] = b;
        rgba[3] = 255;
        yy = yuv[2];
        YUV2RGB(yy, uu, vv, r, g, b);
        rgba[4] = r;
        rgba[5] = g;
        rgba[6] = b;
        rgba[7] = 255;
        yuv += 4;
        rgba += 8;
    }
    return ret;
}
예제 #3
0
	static void
uyyvyy2bgr(const unsigned char *src, unsigned char *dest,
		unsigned long long int NumPixels)
{
	register int i = NumPixels + (NumPixels >> 1) - 1;
	register int j = NumPixels + (NumPixels << 1) - 1;
	register int y0, y1, y2, y3, u, v;
	register int r, g, b;

	while (i > 0) {
		y3 = src[i--];
		y2 = src[i--];
		v = src[i--] - 128;
		y1 = src[i--];
		y0 = src[i--];
		u = src[i--] - 128;
		YUV2RGB(y3, u, v, r, g, b);
		dest[j--] = r;
		dest[j--] = g;
		dest[j--] = b;
		YUV2RGB(y2, u, v, r, g, b);
		dest[j--] = r;
		dest[j--] = g;
		dest[j--] = b;
		YUV2RGB(y1, u, v, r, g, b);
		dest[j--] = r;
		dest[j--] = g;
		dest[j--] = b;
		YUV2RGB(y0, u, v, r, g, b);
		dest[j--] = r;
		dest[j--] = g;
		dest[j--] = b;
	}
}
예제 #4
0
파일: yuv.c 프로젝트: howard5888/wineT
static void Parse_YUYV(unsigned char *destbuffer, const unsigned char *input, int width, int height)
{
   const unsigned char *pY, *pCb, *pCr;
   int togo = width * height / 2;
   pY = input;
   pCb = input+1;
   pCr = input+3;
   while (--togo) {
      YUV2RGB(*pY, *pCb, *pCr, (RGB *)destbuffer);
      pY += 2; destbuffer += 3;
      YUV2RGB(*pY, *pCb, *pCr, (RGB *)destbuffer);
      pY += 2; pCb += 4; pCr += 4; destbuffer += 3;
   }
}
예제 #5
0
void CPlayerWnd::VideoComing(
    DWORD dwVideoFormat,
    FRAMEBUFSTRUCT *bufs )
{
    if ( !IsWindow() )
    {
        return;
    }
    // 为了支持多分辨显示,及CIF变为D1等,不用static
    ///*static*/ DWORD s_dwWidth = g_pFormat[dwVideoFormat][0];
    ///*static*/ DWORD s_dwHeight = g_pFormat[dwVideoFormat][1];
#ifndef YUV_Play
    YUV2RGB(
        bufs->pBuf,
        m_pRGBBuf,      
        bufs->width,
        bufs->height);

    //static bool s_bSavePic = true;
    //if( s_bSavePic )
    //{
    //    static int j = 0;
    //    static char szBuf[MAX_PATH] = {0};
    //    sprintf_s(szBuf, "C:\\%d.jpg", j++);
    //    ofstream Write(szBuf, ios::binary);
    //    Write.write((char*)m_pRGBBuf, 352*288*3);
    //    Write.close();
    //    s_bSavePic = false;
    //}
#endif
    int nChannel = bufs->ChannelIndex;
    CRect Rect;
    GetClientRect(&Rect);
    ClientToScreen(&Rect);

    FILETIME* pTime = (FILETIME*)&bufs->FrameTime;

#ifdef YUV_Play
    m_Player.Show(
        &Rect, bufs->pBuf,
        bufs->width, bufs->height,
        CSingleVideoPlayer::YUV422, 0, 
        pTime,
        this, bufs->ChannelIndex );
#else
    m_Player.Show(
        &Rect,
        m_pRGBBuf,
        bufs->width,
        bufs->height,
        pTime,
        this, bufs->ChannelIndex );
#endif
}
예제 #6
0
/*static uint8_t*YUV2RGB(double Y,double U,double V,uint8_t*out){
	*out++=clipp(Y+(1.402*(U-128.0)));
	*out++=clipp(Y-(.34414*(V-128))-(.71414*(U-128.0)));
	*out++=clipp(Y+(1.772*(V-128.0)));
	return out;
}*/
void yuv2rgb(uint8_t * yuvDat,uint8_t * out,int alg,uint32_t img_w,uint32_t img_h){
	uint32_t xy;
	int y1,y2,y3,y4;
	switch(alg){
		case ALG_YUV_0:
			y1=0;
			y2=2;
			y3=1;
			y4=3;
		break;
		case ALG_YUV_1:
			y1=2;
			y2=0;
			y3=1;
			y4=3;
		break;
		case ALG_YUV_2:
			y1=0;
			y2=2;
			y3=3;
			y4=1;
		break;
		case ALG_YUV_3:
			y1=2;
			y2=0;
			y3=3;
			y4=1;
		break;
	}
	for (xy=0;xy<(img_w/2)*img_h;++xy){
		/* *out++=YUV2R(yuvDat[y1],yuvDat[y3],yuvDat[y4]);
		*out++=YUV2G(yuvDat[y1],yuvDat[y3],yuvDat[y4]);
		*out++=YUV2B(yuvDat[y1],yuvDat[y3],yuvDat[y4]);
		*out++=YUV2R(yuvDat[y2],yuvDat[y3],yuvDat[y4]);
		*out++=YUV2G(yuvDat[y2],yuvDat[y3],yuvDat[y4]);
		*out++=YUV2B(yuvDat[y2],yuvDat[y3],yuvDat[y4]);*/
		out=YUV2RGB(yuvDat[y1],yuvDat[y3],yuvDat[y4],out);
		out=YUV2RGB(yuvDat[y2],yuvDat[y3],yuvDat[y4],out);
		yuvDat+=4;
	}
}
예제 #7
0
파일: usb_cam.cpp 프로젝트: sujiwo/robocar
void uyvy2rgb(char *YUV, char *RGB, int NumPixels)
{
  int i, j;
  unsigned char y0, y1, u, v;
  unsigned char r, g, b;
  for (i = 0, j = 0; i < (NumPixels << 1); i += 4, j += 6)
  {
    u = (unsigned char)YUV[i + 0];
    y0 = (unsigned char)YUV[i + 1];
    v = (unsigned char)YUV[i + 2];
    y1 = (unsigned char)YUV[i + 3];
    YUV2RGB(y0, u, v, &r, &g, &b);
    RGB[j + 0] = r;
    RGB[j + 1] = g;
    RGB[j + 2] = b;
    YUV2RGB(y1, u, v, &r, &g, &b);
    RGB[j + 3] = r;
    RGB[j + 4] = g;
    RGB[j + 5] = b;
  }
}
예제 #8
0
BOOL YYUVToRgb24 (BYTE *yuv_src,int yuvsize, int width, int height,BYTE *dest,int destsize)
{
	if(yuvsize < width * height *3 || destsize < width * height *3)
	{
		return FALSE;
	}
	BYTE *yy_src;
	BYTE *uv_src;
	yy_src = yuv_src;
	uv_src = yuv_src+width*height;
	int i,j;
	int y0, y1, u, v;
	int r, g, b;
	BYTE *s[2];
	s[0] = yy_src;      // Y
	s[1] = uv_src;      // UV
	for (i = 0; i < height; i++) 
	{
		for (j = 0; j < width; j+=2) 
		{
			y0 = s[0][j];
			y1 = s[0][j+1];
			u = s[1][j];
			v = s[1][j+1];
			YUV2RGB (y0, u, v, r, g, b);
			*dest++ = r;    // 图像实际为BGR模式
			*dest++ = g;
			*dest++ = b;
			YUV2RGB (y1, u, v, r, g, b);
			*dest++ = r;    // 图像实际为BGR模式
			*dest++ = g;
			*dest++ = b;
		}
		s[0] += width;
		s[1] += width;
	}
	return TRUE;
}
예제 #9
0
	static void
uyv2bgr(const unsigned char *src, unsigned char *dest,
		unsigned long long int NumPixels)
{
	register int i = NumPixels + (NumPixels << 1) - 1;
	register int j = NumPixels + (NumPixels << 1) - 1;
	register int y, u, v;
	register int r, g, b;

	while (i > 0) {
		v = src[i--] - 128;
		y = src[i--];
		u = src[i--] - 128;
		YUV2RGB(y, u, v, r, g, b);
		dest[j--] = r;
		dest[j--] = g;
		dest[j--] = b;
	}
}
예제 #10
0
파일: yuv.c 프로젝트: howard5888/wineT
static void Parse_PYUV(unsigned char *destbuffer, const unsigned char *input, int width, int height, int wstep, int hstep)
{
   /* We have 3 pointers, One to Y, one to Cb and 1 to Cr */

/* C19 *89* declaration block (Grr julliard for not allowing C99) */
   int uvjump, ysize, uvsize;
   const unsigned char *pY, *pCb, *pCr;
   int swstep = 0, shstep = 0;
   int ypos = 0, xpos = 0;
   int indexUV = 0, cUv;
/* End of Grr */

   uvjump = width / wstep;
   ysize = width * height;
   uvsize = (width / wstep) * (height / hstep);
   pY = input;
   pCb = pY + ysize;
   pCr = pCb + uvsize;
   /* Bottom down DIB */
   do {
      swstep = 0;
      cUv = indexUV;
      for (xpos = 0; xpos < width; xpos++) {
         YUV2RGB(*(pY++), pCb[cUv], pCr[cUv], (RGB *)destbuffer);
         destbuffer += 3;
         if (++swstep == wstep) {
            cUv++;
            swstep = 0;
         }
      }
      if (++shstep == hstep) {
         shstep = 0;
         indexUV = cUv;
      }
   } while (++ypos < height);
}
예제 #11
0
int YUV2BMP(unsigned char *pSrcBuffer, long width, long height, const char *fileName)
{
	int i = 0;
	int j = 0;
	MyRGB tmpRGB;
	long size = width * height;
	long index;
	FILE *pf;

	if(NULL == pSrcBuffer)
		return -1;
		
	pf = fopen(fileName, "w+");
	if(NULL == pf)
		return -1;
		
	if(0 != WriteBmpFileHead(pf, width, height))
		return -1;
		
	for(i = height - 1; i > -1; i--)
	{
		for(j = 0; j < width; j++)
		{
			index =  i * width + j;
			YUV2RGB(pSrcBuffer[index], pSrcBuffer[index / 4 + size], pSrcBuffer[index / 4 + size * 5 / 4] , &tmpRGB);
			fwrite(&tmpRGB, 3, 1, pf);
		}
	
	}
	
	fclose(pf);
	
	return 0;


}
예제 #12
0
int TAP_Main (void)
{
  AddTime(0, 0);
  BMP_WriteHeader(NULL, 0, 0);
  BootReason();
  BuildWindowBorder();
  BuildWindowInfo();
  BuildWindowLine();
  BuildWindowLineSelected();
  BuildWindowScrollBar();
  BuildWindowTitle();
  busyWait();
  CalcAbsSectorFromFAT(NULL, 0);
  CalcPrepare();
  CalcTopIndex(0, 0);
  Callback(0, NULL, 0, 0, 0, 0);
  CallbackHelper(NULL, NULL, 0, 0, 0, 0);
  CallBIOS(0, 0, 0, 0, 0);
  CallFirmware(0, 0, 0, 0, 0);
  CallTraceEnable(FALSE);
  CallTraceEnter(NULL);
  CallTraceExit(NULL);
  CallTraceInit();
  CaptureScreen(0, 0, 0, NULL, 0, 0);
  ChangeDirRoot();
  CheckSelectable(0, 0);
  combineVfdData(NULL, NULL);
  compact(NULL, 0);
  CompressBlock(NULL, 0, NULL);
  CompressedTFDSize(NULL, 0, NULL);
  CompressTFD(NULL, 0, NULL, 0, 0, NULL);
  CRC16(0, NULL, 0);
  CRC32 (0, NULL, 0);
  Delay(0);
  DialogEvent(NULL, NULL, NULL);
  DialogMsgBoxButtonAdd(NULL, FALSE);
  DialogMsgBoxExit();
  DialogMsgBoxInit(NULL, NULL, NULL, NULL);
  DialogMsgBoxShow();
  DialogMsgBoxShowInfo(0);
  DialogMsgBoxShowOK();
  DialogMsgBoxShowOKCancel(0);
  DialogMsgBoxShowYesNo(0);
  DialogMsgBoxShowYesNoCancel(0);
  DialogMsgBoxTitleSet(NULL, NULL);
  DialogProfileChange(NULL);
  DialogProfileCheck(NULL, NULL, FALSE);
  DialogProfileLoad(NULL);
  DialogProfileLoadDefault();
  DialogProfileLoadMy(NULL, FALSE);
  DialogProfileSave(NULL);
  DialogProfileSaveDefault();
  DialogProfileScrollBehaviourChange(FALSE, FALSE);
  DialogProgressBarExit();
  DialogProgressBarInit(NULL, NULL, 0, 0, NULL, 0, 0);
  DialogProgressBarSet(0, 0);
  DialogProgressBarShow();
  DialogProgressBarTitleSet(NULL);
  DialogWindowChange(NULL, FALSE);
  DialogWindowCursorChange(FALSE);
  DialogWindowCursorSet(0);
  DialogWindowExit();
  DialogWindowHide();
  DialogWindowInfoAddIcon(0, 0, NULL);
  DialogWindowInfoAddS(0, 0, 0, NULL, 0, 0, 0, 0, 0);
  DialogWindowInfoDeleteAll();
  DialogWindowInit(NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, 0, 0, 0);
  DialogWindowItemAdd(NULL, 0, NULL, 0, FALSE, FALSE, 0, NULL);
  DialogWindowItemAddSeparator();
  DialogWindowItemChangeFlags(0, FALSE, FALSE);
  DialogWindowItemChangeIcon(0, 0, NULL);
  DialogWindowItemChangeParameter(0, NULL, 0);
  DialogWindowItemChangeValue(0, NULL, 0);
  DialogWindowItemDelete(0);
  DialogWindowItemDeleteAll();
  DialogWindowRefresh();
  DialogWindowReInit(0, 0, 0, 0, 0, 0);
  DialogWindowScrollDown();
  DialogWindowScrollDownPage();
  DialogWindowScrollUp();
  DialogWindowScrollUpPage();
  DialogWindowShow();
  DialogWindowTabulatorSet(0, 0);
  DialogWindowTitleChange(NULL, NULL, NULL);
  DialogWindowTypeChange(0);
  DrawMsgBoxButtons();
  DrawMsgBoxTitle();
  DrawOSDLine(0, 0, 0, 0, 0, 0);
  DrawProgressBarBar(0, 0);
  DrawProgressBarTitle();
  DrawWindowBorder();
  DrawWindowInfo();
  DrawWindowLine(0);
  DrawWindowLines();
  DrawWindowScrollBar();
  DrawWindowTitle();
  EndMessageWin();
  exitHook();
  ExtractLine(NULL, NULL);
  FileSelector(NULL, NULL, NULL, 0);
  FileSelectorKey(0, 0);
  FindDBTrack();
  FindInstructionSequence(NULL, NULL, 0, 0, 0, 0);
  findSendToVfdDisplay(0, 0);
  FlashAddFavourite(NULL, 0, FALSE);
  FlashDeleteFavourites();
  FlashFindEndOfServiceNameTableAddress();
  FlashFindEndOfServiceTableAddress(0);
  FlashFindServiceAddress(0, 0, 0, 0);
  FlashFindTransponderIndex(0, 0, 0);
  FlashGetBlockStartAddress(0);
  FlashGetChannelNumber(0, 0, 0, 0);
  FlashGetSatelliteByIndex(0);
  FlashGetServiceByIndex(0, FALSE);
  FlashGetServiceByName (NULL, FALSE);
  FlashGetTransponderCByIndex(0);
  FlashGetTransponderSByIndex(0, 0);
  FlashGetTransponderTByIndex(0);
  FlashGetTrueLocalTime(0, 0);
  FlashGetType();
  FlashInitialize(0);
  FlashProgram();
  FlashReindexFavourites(0, 0, 0);
  FlashReindexTimers(0, 0, 0);
  FlashRemoveCASServices(FALSE);
  FlashRemoveServiceByIndex(0, FALSE);
  FlashRemoveServiceByIndexString(NULL, FALSE);
  FlashRemoveServiceByLCN(NULL, FALSE);
  FlashRemoveServiceByName(NULL, FALSE);
  FlashRemoveServiceByPartOfName(NULL, FALSE);
  FlashRemoveServiceByUHF(NULL, FALSE, FALSE);
  FlashServiceAddressToServiceIndex(NULL);
  FlashWrite(NULL, NULL, 0, NULL);
  FlushCache(NULL, 0);
  FreeOSDRegion(0);
  fwHook(0);
  GetAudioTrackPID(0, NULL);
  GetClusterPointer(0);
  GetCurrentEvent(NULL);
  GetEEPROMAddress();
  GetEEPROMPin();
  GetFrameBufferPixel(0, 0);
  GetFrameSize(0, 0);
  GetFWInfo(0, 0, 0, 0, 0, 0, 0, 0);
  GetHeapParameter(NULL, 0);
  GetLine(NULL, 0);
  GetOSDMapAddress();
  GetOSDRegionHeight(0);
  GetOSDRegionWidth(0);
  GetPinStatus();
  GetPIPPosition(NULL, NULL, NULL, NULL);
  getRECSlotAddress();
  GetSysOsdControl(0);
  GetToppyString(0);
  HasEnoughItemMemory();
  HDD_AAM_Disable();
  HDD_AAM_Enable(0);
  HDD_APM_Disable();
  HDD_APM_Enable(0);
  HDD_BigFile_Read(NULL, 0, 0, NULL);
  HDD_BigFile_Size(NULL);
  HDD_BigFile_Write(NULL, 0, 0, NULL);
  HDD_ChangeDir(NULL);
  HDD_DecodeRECHeader(NULL, NULL);
  HDD_EncodeRECHeader(NULL, NULL, 0);
  HDD_FappendOpen(NULL);
  HDD_FappendWrite(NULL, NULL);
  HDD_FindPCR(NULL, 0);
  HDD_FindPMT(NULL, 0, NULL);
  HDD_FreeSize();
  HDD_GetClusterSize();
  HDD_GetFileDir(NULL, 0, NULL);
  HDD_GetFirmwareDirCluster();
  HDD_GetHddID(NULL, NULL, NULL);
  HDD_IdentifyDevice(NULL);
  HDD_isAnyRecording();
  HDD_isCryptedStream(NULL, 0);
  HDD_isRecording(0);
  HDD_LiveFS_GetChainLength(0);
  HDD_LiveFS_GetFAT1Address();
  HDD_LiveFS_GetFAT2Address();
  HDD_LiveFS_GetFirstCluster(0);
  HDD_LiveFS_GetLastCluster(0);
  HDD_LiveFS_GetNextCluster(0);
  HDD_LiveFS_GetPreviousCluster(0);
  HDD_LiveFS_GetRootDirAddress();
  HDD_LiveFS_GetSuperBlockAddress();
  HDD_MakeNewRecName(NULL, 0);
  HDD_Move(NULL, NULL, NULL);
  HDD_ReadClusterDMA(0, NULL);
  HDD_ReadSector(0, 0);
  HDD_ReadSectorDMA(0, 0, NULL);
  HDD_RECSlotGetAddress(0);
  HDD_RECSlotIsPaused(0);
  HDD_RECSlotPause(0, FALSE);
  HDD_RECSlotSetDuration(0, 0);
  HDD_SetCryptFlag(NULL, 0);
  HDD_SetFileDateTime(NULL, 0, 0, 0);
  HDD_SetSkipFlag (NULL, FALSE);
  HDD_SetStandbyTimer(0);
  HDD_Smart_DisableAttributeAutoSave();
  HDD_Smart_DisableOperations();
  HDD_Smart_EnableAttributeAutoSave();
  HDD_Smart_EnableOperations();
  HDD_Smart_ExecuteOfflineImmediate(0);
  HDD_Smart_ReadData(0);
  HDD_Smart_ReadThresholdData(0);
  HDD_Smart_ReturnStatus();
  HDD_Stop();
  HDD_TAP_Callback(0, NULL, 0, 0, 0, 0);
  HDD_TAP_Disable(0, 0);
  HDD_TAP_DisableAll(0);
  HDD_TAP_DisabledEventHandler(0, 0, 0);
  HDD_TAP_GetCurrentDir(NULL);
  HDD_TAP_GetCurrentDirCluster();
  HDD_TAP_GetIDByFileName(NULL);
  HDD_TAP_GetIDByIndex(0);
  HDD_TAP_GetIndexByID(0);
  HDD_TAP_GetInfo(0, NULL);
  HDD_TAP_GetStartParameter();
  HDD_TAP_isAnyRunning();
  HDD_TAP_isBatchMode();
  HDD_TAP_isDisabled(0);
  HDD_TAP_isDisabledAll();
  HDD_TAP_isRunning(0);
  HDD_TAP_SendEvent(0, FALSE, 0, 0, 0);
  HDD_TAP_SetCurrentDirCluster(0);
  HDD_TAP_Start(NULL, FALSE, NULL, NULL);
  HDD_TAP_StartedByTAP();
  HDD_TAP_Terminate(0);
  HDD_TouchFile(NULL);
  HDD_TranslateDirCluster(0, NULL);
  HDD_TruncateFile(NULL, 0);
  HDD_Write(NULL, 0, NULL);
  HDD_WriteClusterDMA(0, NULL);
  HDD_WriteSectorDMA(0, 0, NULL);
  HookEnable(0, 0);
  HookExit();
  HookIsEnabled(0);
  HookMIPS_Clear(0, 0, 0);
  HookMIPS_Set(0, 0, 0);
  HookSet(0, 0);
  IMEM_Alloc(0);
  IMEM_Init(0);
  IMEM_isInitialized();
  IMEM_Compact();
  IMEM_Free(NULL);
  IMEM_GetInfo(NULL, NULL);
  IMEM_Kill();
  InfoTestGrid();
  INICloseFile();
  INIFindStartEnd(NULL, NULL, NULL, 0);
  INIGetARGB(NULL, NULL, NULL, NULL, NULL, 0);
  INIGetHexByte(NULL, 0, 0, 0);
  INIGetHexDWord(NULL, 0, 0, 0);
  INIGetHexWord(NULL, 0, 0, 0);
  INIGetInt(NULL, 0, 0, 0);
  INIGetString(NULL, NULL, NULL, 0);
  INIKillKey(NULL);
  INIOpenFile(NULL);
  INISaveFile(NULL);
  INISetARGB(NULL, 0, 0, 0, 0);
  INISetComment(NULL);
  INISetHexByte(NULL, 0);
  INISetHexDWord(NULL, 0);
  INISetHexWord(NULL, 0);
  INISetInt(NULL, 0);
  INISetString(NULL, NULL);
  initCodeWrapper(0);
  InitTAPAPIFix();
  InitTAPex();
  InteractiveGetStatus();
  InteractiveSetStatus(FALSE);
  intLock();
  intUnlock(0);
  isAnyOSDVisible(0, 0, 0, 0);
  isLegalChar(0, 0);
  isMasterpiece();
  isMPMenu();
  iso639_1(0);
  isOSDRegionAlive(0);
  isValidChannel(NULL);
  LangGetString(0);
  LangLoadStrings(NULL, 0, 0);
  LangUnloadStrings();
  Log(NULL, NULL, FALSE, 0, NULL);
  LowerCase(NULL);
  MakeValidFileName(NULL, 0);
  MHEG_Status();
  MPDisplayClearDisplay();
  MPDisplayClearSegments(0, 0);
  MPDisplayDisplayLongString(NULL);
  MPDisplayDisplayShortString(NULL);
  MPDisplayGetDisplayByte(0);
  MPDisplayGetDisplayMask(0);
  MPDisplayInstallMPDisplayFwHook();
  MPDisplaySetAmFlag(0);
  MPDisplaySetColonFlag(0);
  MPDisplaySetDisplayByte(0, 0);
  MPDisplaySetDisplayMask(0, 0);
  MPDisplaySetDisplayMemory(NULL);
  MPDisplaySetDisplayMode(0);
  MPDisplaySetPmFlag(0);
  MPDisplaySetSegments(0, 0);
  MPDisplayToggleSegments(0, 0);
  MPDisplayUninstallMPDisplayFwHook();
  MPDisplayUpdateDisplay();
  Now(NULL);
  OSDCopy(0, 0, 0, 0, 0, 0, 0);
  OSDLinesForeDirty(FALSE);
  ParseLine(NULL, NULL, 0);
  ProfileDirty();
  ProfileInit();
  ProfileLoad(NULL, FALSE);
  ProfileMayReload();
  ReadEEPROM(0, 0, NULL);
  ReadIICRegister(0, 0, 0, 0, NULL);
  Reboot(0);
  ReceiveSector(0);
  RTrim(NULL);
  SaveBitmap(NULL, 0, 0, NULL);
  SendEvent(0, 0, 0, 0);
  SendEventHelper(NULL, 0, 0, 0);
  SendHDDCommand(0, 0, 0, 0, 0, 0, 0);
  SendToFP(NULL);
  SeparatePathComponents(NULL, NULL, NULL, NULL);
  SetCrashBehaviour(0);
  setSymbol14(0, 0);
  setSymbol17(0, 0);
  ShowMessageWin(NULL, NULL, NULL, 0);
  ShowMessageWindow(NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  Shutdown(0);
  SoundSinus(0, 0, 0);
  StrEndsWith(NULL, NULL);
  stricstr(NULL, NULL);
  SubtitleGetStatus();
  SubtitleSetStatus(FALSE);
  SuppressedAutoStart();
  SwapDWords(0);
  SwapWords(0);
  TAP_Osd_PutFreeColorGd(0, 0, 0, NULL, FALSE, 0);
  TAPCOM_CloseChannel(NULL);
  TAPCOM_Finish(NULL, 0);
  TAPCOM_GetChannel(0, NULL, NULL, NULL, NULL);
  TAPCOM_GetReturnValue(NULL);
  TAPCOM_GetStatus(NULL);
  TAPCOM_LastAlive(NULL);
  TAPCOM_OpenChannel(0, 0, 0, NULL);
  TAPCOM_Reject(NULL);
  TAPCOM_StillAlive(NULL);
  TFDSize(NULL);
  TimeDiff(0, 0);
  TimeFormat(0, 0, 0);
  TunerGet(0);
  TunerSet(0);
  UncompressBlock(NULL, 0, NULL, 0);
  UncompressedFirmwareSize(NULL);
  UncompressedLoaderSize(NULL);
  UncompressedTFDSize(NULL);
  UncompressFirmware(NULL, NULL, NULL);
  UncompressLoader(NULL, NULL, NULL);
  UncompressTFD(NULL, NULL, NULL);
  UpperCase(NULL);
  ValidFileName(NULL, 0);
  WindowDirty();
  WriteIICRegister(0, 0, 0, 0, NULL);
  YUV2RGB(0, 0, 0, NULL, NULL, NULL);
  YUV2RGB2(0, 0, 0, NULL, NULL, NULL);

  return 0;
}
// 读取PAL文件转换为RGB并显示
void CRGB2YUVView::OnReadPAL() 
{
	// TODO: Add your command handler code here
	CDC *pDC = GetDC();
	CRect rect;
	CBrush brush(RGB(128,128,128));
	GetClientRect(&rect);
	pDC->FillRect(&rect, &brush);

	// PAL 720x576 : 中国的电视标准为PAL制	
	int CurrentXRes = 720;
	int CurrentYRes = 576;
	int size        = CurrentXRes * CurrentYRes;
    
	// 分配内存
	byte *Video_Field0 = (byte*)malloc(CurrentXRes*CurrentYRes);  
	byte *Video_Field1 = (byte*)malloc(CurrentXRes*CurrentYRes);

	// 保存内存指针
	byte *Video_Field0_ = Video_Field0;
	byte *Video_Field1_ = Video_Field1;

	// 初始化内存
	ZeroMemory(Video_Field0, CurrentXRes*CurrentYRes);
	ZeroMemory(Video_Field1, CurrentXRes*CurrentYRes);

	byte yuv_y0, yuv_u0, yuv_v0; // yuv_v1;  // {y0, u0, v0, v1};
	byte r, g, b;
	byte bufRGB[3];  // 临时保存{R,G,B}
	byte bufYUV[3];  // 临时保存{Y,U,V}
	
	// 初始化数组空间
	memset(bufRGB,0, sizeof(byte)*3); 
	memset(bufYUV,0, sizeof(byte)*3); 
    
    char strFileName[MAX_PATH]="720bmp.pal";
 
    // 分配图片像素内存
    RGBTRIPLE *rgb;
	rgb = new RGBTRIPLE[CurrentXRes*CurrentYRes];

	memset(rgb,0, sizeof(RGBTRIPLE)*CurrentXRes*CurrentYRes); // 初始化内存空间

	CFile* f;
	f = new CFile();
	f->Open(strFileName, CFile::modeRead);
	f->SeekToBegin();
	f->Read(Video_Field0, CurrentXRes*CurrentYRes);
	f->Read(Video_Field1, CurrentXRes*CurrentYRes);

	// 上场  (1,3,5,7...行)
	for ( int i = CurrentYRes-1; i>=0; i--) {
		for ( int j = 0; j<CurrentXRes; j++) {
			if(!(i%2)==0) 
			{
				// UYVY标准  [U0 Y0 V0 Y1] [U1 Y2 V1 Y3] [U2 Y4 V2 Y5] 每像素点两个字节,[内]为四个字节 
				if ((j%2)==0) 
				{
					yuv_u0 = *Video_Field0;  
					Video_Field0++;
				} 
				else
				{
					yuv_v0 = *Video_Field0;  
					Video_Field0++;
				}
				yuv_y0 = *Video_Field0;      
				Video_Field0++;

				bufYUV[0] = yuv_y0;  //	Y
				bufYUV[1] = yuv_u0;  // U
				bufYUV[2] = yuv_v0;  // V

				// RGB转换为YUV
				YUV2RGB(bufRGB,bufYUV);
				r = bufRGB[0];   // y
				g = bufRGB[1];   // u
				b = bufRGB[2];   // v
				if (r>255) r=255; if (r<0) r=0;
				if (g>255) g=255; if (g<0) g=0;
				if (b>255) b=255; if (b<0) b=0;

				for (int k=0; k<1000; k++) ;  //延时
				// 视图中显示
				pDC->SetPixel(j, CurrentYRes-1-i, RGB(r, g, b));

			}// end if i%2
		}
	}

    // 下场 (2,4,6,8...行)
	for ( int i_ = CurrentYRes-1; i_>=0; i_--) {
		for ( int j_ = 0; j_<CurrentXRes; j_++) {
			if((i_%2)==0) 
			{
				// UYVY标准  [U0 Y0 V0 Y1] [U1 Y2 V1 Y3] [U2 Y4 V2 Y5] 每像素点两个字节,[内]为四个字节 
				if ((j_%2)==0) 
				{
					yuv_u0 = *Video_Field1;  
					Video_Field1++;
				} 
				else
				{
					yuv_v0 = *Video_Field1;  
					Video_Field1++;
				}
				yuv_y0 = *Video_Field1;      
				Video_Field1++;

				bufYUV[0] = yuv_y0;  //	Y
				bufYUV[1] = yuv_u0;  // U
				bufYUV[2] = yuv_v0;  // V

				// RGB转换为YUV
				YUV2RGB(bufRGB,bufYUV);
				r = bufRGB[0];   // y
				g = bufRGB[1];   // u
				b = bufRGB[2];   // v
				if (r>255) r=255; if (r<0) r=0;
				if (g>255) g=255; if (g<0) g=0;
				if (b>255) b=255; if (b<0) b=0;

				for (int k=0; k<1000; k++) ;  //延时
				// 视图中显示
				pDC->SetPixel(j_, CurrentYRes-1-i_, RGB(r, g, b));
			}
		}
	}
	
	// 提示完成
	char buffer[80];
	sprintf(buffer,"完成读取PAL文件:%s ", strFileName);
	MessageBox(buffer, "提示信息", MB_OK | MB_ICONINFORMATION);

    // 关闭PAL电视场文件
	f->Close();
	// WriteYUV(Video_Field0_, Video_Field1_, size);
	
	// 释放内存
	free( Video_Field0_ ); 
	free( Video_Field1_ );
	delete f;
	delete rgb;
}
예제 #14
0
    // TODO: optimize for other color spaces
    void compute() const {
        recompute = false;
        //http://docs.rainmeter.net/tips/colormatrix-guide
        //http://www.graficaobscura.com/matrix/index.html
        //http://beesbuzz.biz/code/hsv_color_transforms.php
        // ??
        const float b = brightness;
        // brightness R,G,B
        QMatrix4x4 B(1, 0, 0, b,
                     0, 1, 0, b,
                     0, 0, 1, b,
                     0, 0, 0, 1);
        // Contrast (offset) R,G,B
        const float c = contrast+1.0;
        const float t = (1.0 - c) / 2.0;
        QMatrix4x4 C(c, 0, 0, t,
                     0, c, 0, t,
                     0, 0, c, t,
                     0, 0, 0, 1);
        // Saturation
        const float wr = 0.3086f;
        const float wg = 0.6094f;
        const float wb = 0.0820f;
        float s = saturation + 1.0f;
        QMatrix4x4 S(
            (1.0f - s)*wr + s, (1.0f - s)*wg    , (1.0f - s)*wb    , 0.0f,
            (1.0f - s)*wr    , (1.0f - s)*wg + s, (1.0f - s)*wb    , 0.0f,
            (1.0f - s)*wr    , (1.0f - s)*wg    , (1.0f - s)*wb + s, 0.0f,
                         0.0f,              0.0f,              0.0f, 1.0f
        );
        // Hue
        const float n = 1.0f / sqrtf(3.0f);       // normalized hue rotation axis: sqrt(3)*(1 1 1)
        const float h = hue*M_PI;               // hue rotation angle
        const float hc = cosf(h);
        const float hs = sinf(h);
        QMatrix4x4 H(     // conversion of angle/axis representation to matrix representation
            n*n*(1.0f - hc) + hc  , n*n*(1.0f - hc) - n*hs, n*n*(1.0f - hc) + n*hs, 0.0f,
            n*n*(1.0f - hc) + n*hs, n*n*(1.0f - hc) + hc  , n*n*(1.0f - hc) - n*hs, 0.0f,
            n*n*(1.0f - hc) - n*hs, n*n*(1.0f - hc) + n*hs, n*n*(1.0f - hc) + hc  , 0.0f,
                              0.0f,                   0.0f,                   0.0f, 1.0f
        );

        // B*C*S*H*rgb_range_mat(*yuv2rgb*yuv_range_mat)*bpc_scale
        M = B*C*S*H;
        // M *= rgb_range_translate*rgb_range_scale
        // TODO: transform to output color space other than RGB
        switch (cs_out) {
        case ColorSpace_XYZ:
            M = kXYZ2sRGB.inverted() * M;
            break;
        case ColorSpace_RGB:
            M *= ColorRangeRGB(ColorRange_Full, range_out);
            break;
        case ColorSpace_GBR:
            M *= ColorRangeRGB(ColorRange_Full, range_out);
            M = kGBR2RGB.inverted() * M;
            break;
        default:
            M = YUV2RGB(cs_out).inverted() * M;
            break;
        }

        switch (cs_in) {
        case ColorSpace_XYZ:
            M *= kXYZ2sRGB;
            break;
        case ColorSpace_RGB:
            break;
        case ColorSpace_GBR:
            M *= kGBR2RGB;
            break;
        default:
            M *= YUV2RGB(cs_in)*ColorRangeYUV(range_in, ColorRange_Full);
            break;
        }
        if (bpc_scale != 1.0 && cs_in != ColorSpace_XYZ) { // why no range correction for xyz?
            //qDebug("bpc scale: %f", bpc_scale);
            M *= QMatrix4x4(bpc_scale, 0, 0, 0,
                            0, bpc_scale, 0, 0,
                            0, 0, bpc_scale, 0,
                            0, 0, 0, a_bpc_scale ? bpc_scale : 1); // scale alpha channel too
        }
        //qDebug() << "color mat: " << M;
    }
예제 #15
0
static FIBITMAP * DLL_CALLCONV
Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
	FIBITMAP *dib = NULL;
	unsigned width;
	unsigned height;
	const unsigned bpp = 24;
	int scan_line_add   = 1;
	int start_scan_line = 0;
	
	BYTE *y1 = NULL, *y2 = NULL, *cbcr = NULL;

	BOOL header_only = (flags & FIF_LOAD_NOPIXELS) == FIF_LOAD_NOPIXELS;

	// to make absolute seeks possible we store the current position in the file
	
	long offset_in_file = io->tell_proc(handle);
	long seek = 0;

	// decide which bitmap in the cabinet to load

	switch (flags) {
		case PCD_BASEDIV4 :
			seek = 0x2000;
			width = 192;
			height = 128;
			break;

		case PCD_BASEDIV16 :
			seek = 0xB800;
			width = 384;
			height = 256;
			break;

		default :
			seek = 0x30000;
			width = 768;
			height = 512;
			break;
	}

	try {
		// allocate the dib and write out the header
		dib = FreeImage_AllocateHeader(header_only, width, height, bpp, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
		if(!dib) throw FI_MSG_ERROR_DIB_MEMORY;

		if(header_only) {
			return dib;
		}

		// check if the PCD is bottom-up

		if (VerticalOrientation(io, handle)) {
			scan_line_add = -1;
			start_scan_line = height - 1;		
		}

		// temporary stuff to load PCD

		BYTE *y1 = (BYTE*)malloc(width * sizeof(BYTE));
		BYTE *y2 = (BYTE*)malloc(width * sizeof(BYTE));
		BYTE *cbcr = (BYTE*)malloc(width * sizeof(BYTE));
		if(!y1 || !y2 || !cbcr) throw FI_MSG_ERROR_MEMORY;

		BYTE *yl[] = { y1, y2 };

		// seek to the part where the bitmap data begins

		io->seek_proc(handle, offset_in_file, SEEK_SET);
		io->seek_proc(handle, seek, SEEK_CUR);

		// read the data

		for (unsigned y = 0; y < height / 2; y++) {
			io->read_proc(y1, width, 1, handle);
			io->read_proc(y2, width, 1, handle);
			io->read_proc(cbcr, width, 1, handle);

			for (int i = 0; i < 2; i++) {
				BYTE *bits = FreeImage_GetScanLine(dib, start_scan_line);
				for (unsigned x = 0; x < width; x++) {
					int r, g, b;

					YUV2RGB(yl[i][x], cbcr[x / 2], cbcr[(width / 2) + (x / 2)], r, g, b);

					bits[FI_RGBA_BLUE]  = (BYTE)b;
					bits[FI_RGBA_GREEN] = (BYTE)g;
					bits[FI_RGBA_RED]   = (BYTE)r;
					bits += 3;
				}

				start_scan_line += scan_line_add;
			}
		}

		free(cbcr);
		free(y2);
		free(y1);

		return dib;

	} catch(const char *text) {
		if(dib) FreeImage_Unload(dib);
		if(cbcr) free(cbcr);
		if(y2) free(y2);
		if(y1) free(y1);

		FreeImage_OutputMessageProc(s_format_id, text);

		return NULL;
	}
}
예제 #16
0
void COLOURS_PAL_Update(int colourtable[256])
{
	double yuv_table[256*5];
	COLOURS_PAL_GetYUV(yuv_table);
	YUV2RGB(colourtable, yuv_table);
}
예제 #17
0
static FIBITMAP * DLL_CALLCONV
Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
	int width;
	int height;
	int line;
	int pitch;
	int bpp = 24;
	int scan_line_add   = 1;
	int start_scan_line = 0;

	// to make absolute seeks possible we store the current position in the file
	
	long offset_in_file = io->tell_proc(handle);
	long seek = 0;

	// decide which bitmap in the cabinet to load

	switch (flags) {
		case PCD_BASEDIV4 :
			seek = 0x2000;
			width = 192;
			height = 128;
			break;

		case PCD_BASEDIV16 :
			seek = 0xB800;
			width = 384;
			height = 256;
			break;

		default :
			seek = 0x30000;
			width = 768;
			height = 512;
			break;
	}

	// calculate line and pitch based on the selected bitmap size

	line = CalculateLine(width, bpp);
	pitch = CalculatePitch(line);

	// allocate the dib and write out the header

	FIBITMAP *dib = FreeImage_Allocate(width, height, bpp, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
	
	// check if the PCD is bottom-up

	if (VerticalOrientation(io, handle)) {
		scan_line_add = -1;
		start_scan_line = height - 1;		
	}

	// temporary stuff to load PCD

	BYTE *y1   = new BYTE[width];
	BYTE *y2   = new BYTE[width];
	BYTE *cbcr = new BYTE[width];
	BYTE *yl[] = { y1, y2 };

	// seek to the part where the bitmap data begins

	io->seek_proc(handle, offset_in_file, SEEK_SET);
	io->seek_proc(handle, seek, SEEK_CUR);

	// read the data

	for (int y = 0; y < height / 2; ++y) {
		io->read_proc(y1, width, 1, handle);
		io->read_proc(y2, width, 1, handle);
		io->read_proc(cbcr, width, 1, handle);

		for (int i = 0; i < 2; ++i) {
			BYTE *img = FreeImage_GetScanLine(dib, start_scan_line);
			for (int x = 0; x < width; ++x) {
				int r, g, b;

				YUV2RGB(yl[i][x], cbcr[x / 2], cbcr[(width / 2) + (x / 2)], r, g, b);

				img[FI_RGBA_BLUE]  = (BYTE)b;
				img[FI_RGBA_GREEN] = (BYTE)g;
				img[FI_RGBA_RED]   = (BYTE)r;
				img += 3;
			}

			start_scan_line += scan_line_add;
		}
	}

	delete [] cbcr;
	delete [] y2;
	delete [] y1;

	return dib;
}
예제 #18
0
int
main(int argc,char** argv){
  quality=atof(argv[1]);
  BMP fin2 (argv[2]);
  BMP fin ;fin.init(fin2.w,fin2.h);
  BMP fout2;fout2.init(fin2.w,fin2.h);
  BMP fout;fout.init(fin2.w,fin2.h);
  
  double in[8][8];
  double out[8][8];
  double out2[8][8];
  int i,j,idx;

  init_walsh();
  init_dwt();

  bmp_for(fin)
    RGB2YUV(fin2(x,y),fin(x,y));


  int    num_dat[14];
  double prob_dat[14];
  int    sum_dat[14];
  double bit_dat[14];
  
  memset(num_dat,0,sizeof(num_dat));


  int num_totallen=0;
  for(int c=0;c<3;c++){
    for(int by=0;by<fin.h/8;by++)
      for(int bx=0;bx<fin.w/8;bx++){
	int num_codelen=0;
	for(int dy=0;dy<8;dy++)
	  for(int dx=0;dx<8;dx++){
	    int x=bx*8+dx;
	    int y=by*8+dy;
	    in[   dy][   dx]=fin(x,y)[c];
	    // in[   dy][   dx]=255;
	  }

	//dct(in,out);
	//walsh(in,out);

	// mprint(in);
	//dwt(in,out);
	haar(in,out);
	// mprint(out);
	// idwt(out,in);
	// mprint(in);
	// return 0;
	// ihaar(out,in);
	// mprint(in);
	// return 0;
	
	
	// if(c!=0)
	mmap(out,(1.0/(qt[c][y][x]*quality))*);
	mmap(out,round);


	//	mprint(out);
	vector<RunBit> rvec;
	vector<Code>   cvec;
	mkRunBit(out,rvec);
	mkCode(rvec,cvec);
	
	for(int dy=0;dy<8;dy++)
	  for(int dx=0;dx<8;dx++){
	    num_dat[(int)(log(fabs(out[dy][dx])+1.0)/log(2))]++;
	  }
		
	// for(int i=0;i<rvec.size();i++)
	//   printf("%d %d\n",rvec[i].zero,rvec[i].code);

	// printf("\n");
	
	// for(int i=0;i<cvec.size();i++)
	//   printf("%d %x\n",cvec[i].len,cvec[i].code);
	// return 0;

	for(int i=0;i<cvec.size();i++)
	  num_codelen+=cvec[i].len;
	double comprate=(double)(8*8*8)/(double)(num_codelen);

	// if(comprate<3){
	//   mprint(out);

		
	//   for(int i=0;i<rvec.size();i++)
	//     printf("%d %d\n",rvec[i].zero,rvec[i].code);
	//   printf("\n");
	
	//   for(int i=0;i<cvec.size();i++)
	//     printf("%d %x\n",cvec[i].len,cvec[i].code);
	//   printf("\n");

	//   printf("comprate %f",comprate);


	//   return 0;
	// }

	num_totallen+=num_codelen;
    
	
	//	if(c!=0)
	mmap(out,(qt[c][y][x]*quality)*);
	//idct(out,out2);
	//walsh(out,out2);
	//idwt(out,out2);
	ihaar(out,out2);

	for(int dy=0;dy<8;dy++)
	  for(int dx=0;dx<8;dx++){
	    int x=bx*8+dx;
	    int y=by*8+dy;
	    fout(x,y)[c]=lmt3[c](out2[   dy][   dx]);
	  }



      }
  }
  bmp_for(fin)
    YUV2RGB(fout(x,y),fout2(x,y));

  for(int y=0;y<14;y++)
    prob_dat[y]=(double)(num_dat[y])/(double)(fin.w*fin.h*3);

  for(int y=0;y<14;y++)
    sum_dat[y]=1<<y;
  
  for(int y=0;y<14;y++)
    if(sum_dat[y]!=0&&prob_dat[y]!=0.0)
      bit_dat[y]=-log(prob_dat[y]/sum_dat[y])/log(2);

  double ave_bits=0;
  
  for(int y=0;y<14;y++)
    ave_bits+=prob_dat[y]*bit_dat[y];
  

  
  for(int y=0;y<14;y++){
    printf("%2d,%5d,%9d,%8.3f,%8.3f,%8.3f\n",
	   y,
	   sum_dat[y],
	   num_dat[y],
	   prob_dat[y],
	   bit_dat[y],
	   prob_dat[y]*bit_dat[y]
	   );
  }
  printf("ideal comprate:%f\n",8.0/ave_bits);


  
  double tcomprate=(double)(fin.w*fin.h*24)/(double)(num_totallen);
  printf("tcomprate %f\n",tcomprate);


  fout2.write(argv[3]);
 
  return true;
}