Ejemplo n.º 1
0
char*
ClHelper::loadProgramSource(const char *filename)
{
    struct stat statbuf;
    FILE *inFile;
    char *source;

    inFile = fopen(filename, "rb");
    if (inFile == 0) {
        perror("fopen");
        fprintf(stderr, "file: %s\n", filename);
        throw MyError("kernel program file open failed.", __FUNCTION__);
    }
    if (stat(filename, &statbuf) != 0) {
        perror("stat");
        throw MyError("function stat() failed.", __FUNCTION__);
    }

    source = new char[statbuf.st_size + 1];
    fread(source, statbuf.st_size, 1, inFile);
    source[statbuf.st_size] = '\0';
    fclose(inFile);

    return source;
}
Ejemplo n.º 2
0
/*------------------------------------------------------------------------------------------------------------
 *
 */
void Bitmap::initialize(const int width, const int height)
{
    if (width <= 0) {
        throw MyError("width must be > 0\n", __FUNCTION__);
    }
    if (width % 4 != 0) {
        throw MyError("width must be a multiply of 4.", __FUNCTION__);
    }
    
    initFileHeader();
    initInfoHeader();
    
    mWidth = width;
    mHeight = height;
    
    const int absHeight = height > 0 ? height : height * -1;
    mTotalPixels = width * absHeight;
    mDataSize = mTotalPixels * 3;
    
    if (mData != 0) {
        delete [] mData;
        mData = 0;
    }
    
    mData = new unsigned char[mDataSize];
    
    mInfoHeader.biWidth = width;
    mInfoHeader.biHeight = height;
    mFileHeader.bfSize = (MyDWORD)(mDataSize + sizeof(mFileHeader) + sizeof(mInfoHeader));
}
Ejemplo n.º 3
0
int FastReadStream::_Commit(int stream, __int64 i64BlockNo) {
    int iCacheBlock;
    int i;

    // Already have the block?

    for(i=0; i<lBlockCount; i++)
        if (pHeaders[i].i64BlockNo == i64BlockNo) {
            pHeaders[i].fAccessedBits |= 1L<<stream;
//            _RPT1(0,"Commit(%I64d): cache hit\n", i64BlockNo);
            return i;
        }

    // Pick a replacement candidate.

    iCacheBlock = _PickVictim(stream);

    // Replace it.

    try {
        ++lHistory;

//        _RPT2(0,"Commit(%I64d): cache miss (stream %d)\n", i64BlockNo, stream);
        if (iFile >= 0) {
            int iActual;

            if (-1 == _lseeki64(iFile, i64BlockNo * lBlockSize, SEEK_SET))
                throw MyError("FastRead seek error: %s.", strerror(errno));

            iActual = _read(iFile, (char *)pBuffer + iCacheBlock * lBlockSize, lBlockSize);

            if (iActual < 0)
                throw MyError("FastRead read error: %s.", strerror(errno));

            pHeaders[iCacheBlock].lBytes = iActual;

        } else {
            LONG lLow = (LONG)i64BlockNo*lBlockSize;
            LONG lHigh = (LONG)((i64BlockNo*lBlockSize) >> 32);
            DWORD err, dwActual;

            if (0xFFFFFFFF == SetFilePointer(hFile, lLow, &lHigh, FILE_BEGIN))
                if ((err = GetLastError()) != NO_ERROR)
                    throw MyWin32Error("FastRead seek error: %%s", GetLastError());

            if (!ReadFile(hFile, (char *)pBuffer + iCacheBlock * lBlockSize, lBlockSize, &dwActual, NULL))
                throw MyWin32Error("FastRead read error: %%s", GetLastError());

            pHeaders[iCacheBlock].lBytes = dwActual;
        }
        pHeaders[iCacheBlock].i64BlockNo = i64BlockNo;
        pHeaders[iCacheBlock].fAccessedBits = 1L<<stream;
        pHeaders[iCacheBlock].lHistoryVal = lHistory;
    } catch(...) {
        pHeaders[iCacheBlock].i64BlockNo = -1;
        pHeaders[iCacheBlock].fAccessedBits = 0;
    }

    return iCacheBlock;
}
Ejemplo n.º 4
0
ClHelper::ClHelper()
    : mContext((cl_context)0), mDeviceId((cl_device_id)0),
      mCommandQueue((cl_command_queue)0), mProgram((cl_program)0),
      mKernel((cl_kernel)0)
{
    cl_int status;

    // 플랫폼
    cl_platform_id platforms[10];
    cl_uint num_platforms;
    status = clGetPlatformIDs(sizeof(platforms) / sizeof(platforms[0]),
                              platforms,
                              &num_platforms);
    if (status != CL_SUCCESS || num_platforms <= 0) {        
        fprintf(stderr, "clGetPlatformIDs failed.\n");
        printError(status);
        throw MyError("failed to get platform IDs.",  __FUNCTION__);
    }

    cl_context_properties properties[]
        = {CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[0], 0};

    // 디바이스에 따른 컨텍스트 취득
    mContext = clCreateContextFromType(properties,
                                       // CL_DEVICE_TYPE_CPU, // CPUを使用
                                       CL_DEVICE_TYPE_GPU,    // GPUを使用
                                       NULL,
                                       NULL,
                                       &status);
    if (status != CL_SUCCESS) {
        printError(status);
        throw MyError("failed to create context.",  __FUNCTION__);
    }

    // 디바이스 아이디 취득
    cl_device_id devices[10];
    status = clGetContextInfo(mContext,
                              CL_CONTEXT_DEVICES,
                              sizeof(devices),
                              devices,
                              NULL);
    if (status != CL_SUCCESS) {
        printError(status);
        throw MyError("failed to get device id.", __FUNCTION__);
    }
    mDeviceId = devices[0];

    // 커맨드 큐 생성
    mCommandQueue = clCreateCommandQueue(mContext,
                                         devices[0],
                                         0,
                                         &status);
    if (status != CL_SUCCESS) {
        printError(status);
        throw MyError("failed to create command queue.", __FUNCTION__);
    }
}
Ejemplo n.º 5
0
void SaveWAV(const wchar_t *szFilename, bool fProp, DubOptions *quick_opts) {
	if (!inputVideo)
		throw MyError("No input file to process.");

	if (!inputAudio)
		throw MyError("No audio stream to process.");

	VDAVIOutputWAVSystem wavout(szFilename);
	g_project->RunOperation(&wavout, TRUE, quick_opts, 0, fProp);
}
Ejemplo n.º 6
0
AVIStripeIndexLookup::AVIStripeIndexLookup(IAVIReadStream *pasIndex) {
	index_table		= NULL;

	try {
		AVIStripeIndexEntry *asieptr;
		LONG lStart, lCur, lEnd;

		if (-1 == (lStart = (long)pasIndex->Start())
			|| -1 == (lEnd = (long)pasIndex->End()))

			throw MyError("Stripe index: can't get start/end of index stream");

		ProgressDialog pd(NULL, "AVI Striped Import Filter", "Reading stripe index", lEnd-lStart, true);

		pd.setValueFormat("Frame %ld/%ld");

		index_table_size = lEnd - lStart;

		if (!(index_table = new AVIStripeIndexEntry[index_table_size]))
			throw MyMemoryError();

		asieptr = index_table;

		pasIndex->BeginStreaming(lStart, lEnd, 100000);

		lCur = lStart;

		while(lCur < lEnd) {
			HRESULT err;
			LONG lActualBytes, lActualSamples;

			err = pasIndex->Read(lCur, lEnd-lCur, asieptr, sizeof(AVIStripeIndexEntry)*(lEnd-lCur), &lActualBytes, &lActualSamples);

			if (err == AVIERR_OK && !lActualSamples)
				err = AVIERR_FILEREAD;

			if (err != AVIERR_OK) throw MyAVIError("AVIStripeIndex",err);

			if ((size_t)lActualBytes != lActualSamples * sizeof(AVIStripeIndexEntry))
				throw MyError("Stripe index: bad index marks! (not 16 bytes)");

			lCur += lActualSamples;
			asieptr += lActualSamples;

			pd.advance(lCur);
			pd.check();
		}

		pasIndex->EndStreaming();

	} catch(...) {
		delete index_table;
		throw;
	}
}
Ejemplo n.º 7
0
int main(int argc, char* argv[])
{
	int i,board=0;
	char s[MAX_LINE],s2[16];
	int data[N];

	KM = new CKMotionDLL(0);  // create as board 0

	// fill simple buffer with a ramp

	for (i=0;i<N; i++) data[i]=i;



	// first get the token for the board to allow uninterrupted access

	if (KM->WaitToken()!=KMOTION_LOCKED) MyError();

	// tell the board we will send N (32 bit ) words at offset 0

	sprintf(s,"SetGatherHex 0 %d", N);
	if (KM->WriteLine(s))  MyError();


	// send the data (simple ramp)  (8 hex words per line)

	s[0]=0;
	for (i=0; i<N; i++)
	{
		sprintf(s2,"%X", data[i]);

		strncat(s,s2,10);  // append the hex string

		if (((i%8) == 7) || i==N-1)  // every 8 or on the last send it
		{
			if (KM->WriteLine(s))  MyError();
			s[0]=0;
		}
		else
		{
			strncat(s," ",1);  // otherwise insert a space
		}

	} 

	// release our access to the board

	KM->ReleaseToken();


	return 0;
}
Ejemplo n.º 8
0
VDLazyTimer::VDLazyTimer()
	: mTimerId(NULL)
	, mpCB(NULL)
{
	if (!VDInitThunkAllocator())
		throw MyError("Unable to initialize thunk allocator.");

	mpThunk = VDCreateFunctionThunkFromMethod(this, &VDLazyTimer::StaticTimeCallback, true);
	if (!mpThunk) {
		VDShutdownThunkAllocator();
		throw MyError("Unable to create timer thunk.");
	}
}
Ejemplo n.º 9
0
void VDInputFileFLM::Init(const wchar_t *filename) {
	bool valid = false;

	mFile.open(filename, nsVDFile::kRead | nsVDFile::kDenyWrite | nsVDFile::kOpenExisting);
	sint64 fsize = mFile.size();
	FilmstripHeader	mHeader;
	if (fsize >= 36) {
		mFile.seek(fsize - 36);
		
		char hdrbuf[36];
		mFile.read(hdrbuf, 36);

		mHeader.Read(hdrbuf);

		if (mHeader.Validate()) {
			mFrameSize	= (uint32)mHeader.width * ((uint32)mHeader.height + (uint32)mHeader.leading) * 4;

			if ((uint64)mFrameSize * (uint16)mHeader.numFrames + 36 <= fsize)
				valid = true;
		}
	}

	if (!valid)
		throw MyError("%ls does not appear to be a valid Adobe filmstrip file.", mFile.getFilenameForError());

	mVisibleFrameSize	= (uint32)mHeader.width * (uint32)mHeader.height * 4;
	mFrameWidth			= (uint32)mHeader.width;
	mFrameHeight		= (uint32)mHeader.height;
	mFrameCount			= (uint32)mHeader.numFrames;
	mFrameRate.Assign((uint32)mHeader.framesPerSec, 1);
}
Ejemplo n.º 10
0
/*-------------------------------------------------------------------------
 * 画像データをR, G, Bチャンネル (dataR, dataG, dataB) に分割して返す。
 */
void
Bitmap::getRgbData(unsigned char* dataR,
                   unsigned char* dataG,
                   unsigned char* dataB) const
{
    int index = 0;


    if (mInfoHeader.biBitCount == 32) {
        // 32-bitビットマップ (BGRA)
        for (int i = 0; i < mDataSize; i += 4) {
            dataB[index] = mData[i + 0];
            dataG[index] = mData[i + 1];
            dataR[index] = mData[i + 2];
            index++;
        }
    } else if (mInfoHeader.biBitCount == 24) {
        // 24-bitビットマップ (BGR)
        for (int i = 0; i < mDataSize; i += 3) {
            dataB[index] = mData[i + 0];
            dataG[index] = mData[i + 1];
            dataR[index] = mData[i + 2];
            index++;
        }
    } else {
        throw MyError("Unsupported bitmap format", __FUNCTION__);
    }
}
Ejemplo n.º 11
0
void VDInputFileWAV::Init(const wchar_t *szFile) {
	mFile.open(szFile);

	// Read the first 12 bytes of the file. They must always be RIFF <size> WAVE for a WAVE
	// file. We deliberately ignore the length of the RIFF and only use the length of the data
	// chunk.
	uint32 ckinfo[10];

	mBufferedFile.Read(ckinfo, 12);
	if (ckinfo[0] == mmioFOURCC('R', 'I', 'F', 'F') && ckinfo[2] == mmioFOURCC('W', 'A', 'V', 'E')) {
		ParseWAVE();
		goto ok;
	} else if (ckinfo[0] == mmioFOURCC('r', 'i', 'f', 'f')) {
		mBufferedFile.Read(ckinfo+3, 40 - 12);

		if (!memcmp(ckinfo, kGuidRIFF, 16) && !memcmp(ckinfo + 6, kGuidWAVE, 16)) {
			ParseWAVE64();
			goto ok;
		}
	}

	throw MyError("\"%ls\" is not a WAVE file.", mBufferedFile.GetNameForError());

ok:
	mBytesPerSample	= mWaveFormat->mBlockSize;
}
Ejemplo n.º 12
0
  void SPARSE_BIT_Array_2D :: SetSize (int ah, int aw)
  {
    DeleteElements();
    if (lines)
      {
	delete lines;
	lines = NULL;
      }

    if (!aw) aw = ah;

    height = ah;
    width = aw;

    if (!ah) return;
    lines = new linestruct[ah];

    if (lines)
      {
	for (int i = 0; i < ah; i++)
	  {
	    lines[i].size = 0;
	    lines[i].maxsize = 0;
	    lines[i].col = NULL;
	  }
      }
    else
      {
	height = width = 0;
	MyError ("SPARSE_Array::SetSize: Out of memory");
      }
  }
Ejemplo n.º 13
0
/*------------------------------------------------------------------------------------------------------------
 * コンストラクタ
 */
ClHelper::ClHelper()
    :mContext((cl_context)0), mDevaiceId((cl_device_id)0),
    mCommandQueue((cl_command_queue)0), mProgram((cl_program)0),
    mKernel((cl_kernel)0)
{
    cl_int status;
    
    // create context for specified device
    mContext = clCreateContextFromType(NULL,
                               // CL_DEVICE_TYPE_CPU, // CPUを使用
                               CL_DEVICE_TYPE_GPU,    // GPUを使用
                               NULL,
                               NULL,
                               &status);
    
    if (status != CL_SUCCESS) {
        printError(status);
        throw MyError("failed to create context.", __FUNCTION__);
    }
    
    
    // get device id from context
    cl_device_id devices[10];
    
    status = clGetContextInfo(mContext,
                              CL_CONTEXT_DEVICES,
                              sizeof(devices),
                              devices,
                              NULL);
    if(status != CL_SUCCESS){
        printError(status);
        throw MyError("failed to get device id.", __FUNCTION__);
    }
    mDevaiceId = devices[0];
    
    // Create command queue
    mCommandQueue = clCreateCommandQueue(mContext,
                                         devices[0],
                                         0,
                                         &status);
    if(status != CL_SUCCESS){
        printError(status);
        throw MyError("failed to create command queue.", __FUNCTION__);
    }
}
Ejemplo n.º 14
0
void VDInputFileWAV::ParseWAVE() {
	// iteratively open chunks
	static const uint32 kFoundFormat = 1;
	static const uint32 kFoundData = 2;

	uint32 notFoundYet = kFoundFormat | kFoundData;
	while(notFoundYet != 0) {
		uint32 ckinfo[2];

		// read chunk and chunk id
		if (8 != mBufferedFile.ReadData(ckinfo, 8))
			throw MyError("\"%ls\" is incomplete and could not be opened as a WAVE file.", mBufferedFile.GetNameForError());

		uint32 size = ckinfo[1];
		uint32 sizeToSkip = (size + 1) & ~1;	// RIFF chunks are dword aligned.

		switch(ckinfo[0]) {
			case mmioFOURCC('f', 'm', 't', ' '):
				if (size > 0x100000)
					throw MyError("\"%ls\" contains a format block that is too large (%u bytes).", mBufferedFile.GetNameForError(), size);

				mWaveFormat.resize(size);
				mBufferedFile.Read(mWaveFormat.data(), size);
				sizeToSkip -= size;
				notFoundYet &= ~kFoundFormat;
				break;

			case mmioFOURCC('d', 'a', 't', 'a'):
				mDataStart = mBufferedFile.Pos();

				// truncate length if it extends beyond file
				mDataLength = std::min<sint64>(size, mBufferedFile.Length() - mDataStart);
				notFoundYet &= ~kFoundData;
				break;

			case mmioFOURCC('L', 'I', 'S', 'T'):
				if (size < 4)
					throw MyError("\"%ls\" contains a structural error at position %08llx and cannot be loaded.", mBufferedFile.GetNameForError(), mBufferedFile.Pos() - 8);
				sizeToSkip = 4;
				break;
		}

		mBufferedFile.Skip(sizeToSkip);
	}
}
Ejemplo n.º 15
0
void SaveSegmentedAVI(const wchar_t *szFilename, bool fProp, DubOptions *quick_opts, long lSpillThreshold, long lSpillFrameThreshold, int digits) {
	if (!inputVideo)
		throw MyError("No input file to process.");

	if (digits < 1 || digits > 10)
		throw MyError("Invalid digit count: %d", digits);

	VDAVIOutputFileSystem outfile;

	outfile.SetIndexing(false);
	outfile.SetCaching(false);
	outfile.SetBuffer(VDPreferencesGetRenderOutputBufferSize());

	const VDStringW filename(szFilename);
	outfile.SetFilenamePattern(VDFileSplitExtLeft(filename).c_str(), VDFileSplitExtRight(filename).c_str(), digits);

	g_project->RunOperation(&outfile, FALSE, quick_opts, g_prefs.main.iDubPriority, fProp, lSpillThreshold, lSpillFrameThreshold, VDPreferencesGetRenderBackgroundPriority());
}
Ejemplo n.º 16
0
Archivo: eh12.C Proyecto: 0day-ci/gcc
int main (int argc, char **argv) {
  try {
    throw MyError();
  }
  catch (MyError x) {
  }

  return 0;
}
Ejemplo n.º 17
0
void SaveStripedAVI(const wchar_t *szFile) {
	if (!inputVideoAVI)
		throw MyError("No input video stream to process.");

	VDAVIOutputStripedSystem outstriped(szFile);

	outstriped.Set1GBLimit(g_prefs.fAVIRestrict1Gb != 0);

	g_project->RunOperation(&outstriped, FALSE, NULL, g_prefs.main.iDubPriority, false, 0, 0);
}
Ejemplo n.º 18
0
void SaveStripeMaster(const wchar_t *szFile) {
	if (!inputVideo)
		throw MyError("No input video stream to process.");

	VDAVIOutputStripedSystem outstriped(szFile);

	outstriped.Set1GBLimit(g_prefs.fAVIRestrict1Gb != 0);

	g_project->RunOperation(&outstriped, 2, NULL, g_prefs.main.iDubPriority, false, 0, 0, VDPreferencesGetRenderBackgroundPriority());
}
Ejemplo n.º 19
0
void VDInputFileImages::Init(const wchar_t *szFile) {
	// Attempt to discern path format.
	//
	// First, find the start of the filename.  Then skip
	// backwards until the first period is found, then to the
	// beginning of the first number.

	mBaseName = szFile;
	const wchar_t *pszBaseFormat = mBaseName.c_str();

	const wchar_t *pszFileBase = VDFileSplitPath(pszBaseFormat);
	const wchar_t *s = pszFileBase;

	mLastDigitPos = -1;

	while(*s)
		++s;

	while(s > pszFileBase && s[-1] != L'.')
		--s;

	while(s > pszFileBase) {
		--s;

		if (iswdigit(*s)) {
			mLastDigitPos = s - pszBaseFormat;
			break;
		}
	}

	mFrames = 1;

	// Make sure the first file exists.
	vdfastvector<wchar_t> namebuf;
	if (!VDDoesPathExist(ComputeFilename(namebuf, 0)))
		throw MyError("File \"%ls\" does not exist.", namebuf.data());

	// Stat as many files as we can until we get an error.
	if (mLastDigitPos >= 0) {
		vdfastvector<wchar_t> namebuf;

		ProgressDialog pd(g_hWnd, "Image import filter", "Scanning for images", 0x3FFFFFFF, true);

		pd.setValueFormat("Scanning frame %lu");

		while(VDDoesPathExist(ComputeFilename(namebuf, mFrames))) {
			++mFrames;
			pd.advance((long)mFrames);
		}
	}

	// make sure the first frame is valid
	vdrefptr<IVDVideoSource> vs;
	GetVideoSource(0, ~vs);
}
Ejemplo n.º 20
0
void VDInputFileWAV::ParseWAVE64() {
	// iteratively open chunks
	static const uint32 kFoundFormat = 1;
	static const uint32 kFoundData = 2;

	uint32 notFoundYet = kFoundFormat | kFoundData;
	while(notFoundYet != 0) {
		struct {
			uint8 guid[16];
			uint64 size;
		} ck;

		// read chunk and chunk id
		if (24 != mBufferedFile.ReadData(&ck, 24))
			break;

		// unlike RIFF, WAVE64 includes the chunk header in the chunk size.
		if (ck.size < 24)
			throw MyError("\"%ls\" contains a structural error at position %08llx and cannot be loaded.", mBufferedFile.GetNameForError(), mBufferedFile.Pos() - 8);

		sint64 sizeToSkip = (ck.size + 7 - 24) & ~7;		// WAVE64 chunks are 8-byte aligned.

		if (!memcmp(ck.guid, kGuidfmt, 16)) {
			if (ck.size > 0x100000)
				throw MyError("\"%ls\" contains a format block that is too large (%llu bytes).", mBufferedFile.GetNameForError(), (unsigned long long)ck.size);

			mWaveFormat.resize((uint32)ck.size - 24);
			mBufferedFile.Read(mWaveFormat.data(), mWaveFormat.size());
			sizeToSkip -= mWaveFormat.size();
			notFoundYet &= ~kFoundFormat;
		} else if (!memcmp(ck.guid, kGuiddata, 16)) {
			mDataStart = mBufferedFile.Pos();

			// truncate length if it extends beyond file
			mDataLength = std::min<sint64>(ck.size - 24, mBufferedFile.Length() - mDataStart);
		} else if (!memcmp(ck.guid, kGuidLIST, 16)) {
			sizeToSkip = 8;
		}

		mBufferedFile.Skip(sizeToSkip);
	}
}
Ejemplo n.º 21
0
int VideoSourceImages::_read(VDPosition lStart, uint32 lCount, void *lpBuffer, uint32 cbBuffer, uint32 *plBytesRead, uint32 *plSamplesRead) {
	if (plBytesRead)
		*plBytesRead = 0;

	if (plSamplesRead)
		*plSamplesRead = 0;

	const wchar_t *buf = mpParent->ComputeFilename(mPathBuf, lStart);

	// Check if we already have the file handle cached.  If not, open the file.
	
	if (lStart == mCachedHandleFrame) {
		mCachedFile.seek(0);
	} else{
		mCachedHandleFrame = -1;
		mCachedFile.closeNT();
		mCachedFile.open(buf, nsVDFile::kRead | nsVDFile::kDenyWrite | nsVDFile::kOpenExisting);
		mCachedHandleFrame = lStart;
	}

	// Replace

	uint32 size = (uint32)mCachedFile.size();

	if (size > 0x3fffffff)
		throw MyError("VideoSourceImages: File \"%s\" is too large (>1GB).", VDTextWToA(buf).c_str());

	if (!lpBuffer) {
		if (plBytesRead)
			*plBytesRead = size;

		if (plSamplesRead)
			*plSamplesRead = 1;

		return 0;
	}

	if (size > cbBuffer) {
		if (plBytesRead)
			*plBytesRead = size;

		return IVDStreamSource::kBufferTooSmall;
	}

	mCachedFile.read(lpBuffer, size);
	
	if (plBytesRead)
		*plBytesRead = size;

	if (plSamplesRead)
		*plSamplesRead = 1;

	return 0;
}
Ejemplo n.º 22
0
inline void Mat2d :: Solve (const Vec2d & rhs, Vec2d & x) const
{
  double det = Det();
  
  if (det == 0)
    MyError ("Mat2d::Solve: zero determinant");
  else
    {
      x.X() = (coeff[3] * rhs.X() - coeff[1] * rhs.Y()) / det;
      x.Y() = (-coeff[2] * rhs.X() + coeff[0] * rhs.Y()) / det;
    }
}
Ejemplo n.º 23
0
void VDShowHelp(HWND hwnd, const wchar_t *filename) {
	try {
		VDStringW helpFile(VDGetHelpPath());

		if (!VDDoesPathExist(helpFile.c_str()))
			throw MyError("Cannot find help file: %ls", helpFile.c_str());

		// If we're on Windows NT, check for the ADS and/or network drive.
		if (VDIsWindowsNT()) {
			VDStringW helpFileADS(helpFile);
			helpFileADS += L":Zone.Identifier";
			if (VDDoesPathExist(helpFileADS.c_str())) {
				int rv = MessageBox(hwnd, "VirtualDub has detected that its help file, VirtualDub.chm, has an Internet Explorer download location marker on it. This may prevent the help file from being displayed properly, resulting in \"Action canceled\" errors being displayed. Would you like to remove it?", "VirtualDub warning", MB_YESNO|MB_ICONEXCLAMATION);

				if (rv == IDYES)
					DeleteFileW(helpFileADS.c_str());
			}
		}

		if (filename) {
			helpFile.append(L"::/");
			helpFile.append(filename);
		}

		VDStringW helpCommand(VDStringW(L"\"hh.exe\" \"") + helpFile + L'"');

		PROCESS_INFORMATION pi;
		BOOL retval;

		// CreateProcess will actually modify the string that it gets, soo....
		if (VDIsWindowsNT()) {
			STARTUPINFOW si = {sizeof(STARTUPINFOW)};
			std::vector<wchar_t> tempbufW(helpCommand.size() + 1, 0);
			helpCommand.copy(&tempbufW[0], tempbufW.size());
			retval = CreateProcessW(NULL, &tempbufW[0], NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &si, &pi);
		} else {
			STARTUPINFOA si = {sizeof(STARTUPINFOA)};
			VDStringA strA(VDTextWToA(helpCommand));
			std::vector<char> tempbufA(strA.size() + 1, 0);
			strA.copy(&tempbufA[0], tempbufA.size());
			retval = CreateProcessA(NULL, &tempbufA[0], NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &si, &pi);
		}

		if (retval) {
			CloseHandle(pi.hThread);
			CloseHandle(pi.hProcess);
		} else
			throw MyWin32Error("Cannot launch HTML Help: %%s", GetLastError());
	} catch(const MyError& e) {
		e.post(hwnd, g_szError);
	}
}
Ejemplo n.º 24
0
/*------------------------------------------------------------------------------------------------------------
 * 指定したソースコードファイルからプログラムオブジェクとを作成する
 * filename:カーネルのソースファイル
 */
void ClHelper::preloadProgram(const char* filename)
{
    cl_int status;
    char *source = 0;
    
    // ファイルからプログラムを読み込む
    try {
        source = loadProgramSource(filename);
    } catch (MyError err) {
        fprintf(stderr, "Error: %s\n", err.cstr());
        throw MyError("failed to load compute program from file.", __FUNCTION__);
    }
    
    // プログラムオブジェクトを作成する
    mProgram = clCreateProgramWithSource(mContext,
                                         1,
                                         (const char **)&source,
                                         NULL,
                                         &status);
    if (mProgram ==(cl_program)0) {
        printError(status);
        delete [] source;
        throw MyError("failed to create program object", __FUNCTION__);
    }
    
    // プログラムをビルドする
    cl_device_id devices[1];
    devices[0] = mDevaiceId;
    
    status = clBuildProgram(mProgram, 1, devices, NULL, NULL, NULL);
    if (status != CL_SUCCESS) {
        printError(status);
        showBuildingLog(mProgram, devices[0]);
        delete [] source;
        throw MyError("failed to build program object.", __FUNCTION__);
    }
    
    delete [] source;
}
Ejemplo n.º 25
0
inline Vec2d & Vec2d :: operator/= (double s)
{
  if (s != 0)
    {
      vx /= s;
      vy /= s;
    }
  else
    {
      MyError ("Vec2d::operator /=: Division by zero");
    }
  return *this;
}
Ejemplo n.º 26
0
/*------------------------------------------------------------------------------------------------------------
 * ビットマップファイルを読み込む
 *
 * path: 読み込むビットマップファイル
 */
void Bitmap::readFile(const char *path)
{
    FILE *ifp = fopen(path, "rb");
    
    if (ifp == 0) {
        perror("fopen");
        fprintf(stderr, "file: %s\n", path);
        throw MyError("bitmap file open failed", __FUNCTION__);
    }
    
    int error;
    error = readFileHeader(ifp);
    if (error > 0) {
        throw MyError("failed to read bitmap file header", __FUNCTION__);
    }
    
    error = readInfoHeader(ifp);
    if (error > 0) {
        throw MyError("failed to read bitmap info header", __FUNCTION__);
    }
    
    mDataSize = mFileHeader.bfSize - mInfoHeader.biSize - sizeof(mFileHeader);
    if (mDataSize != 0) {
        delete [] mData;
    }
    mData = new unsigned char[mDataSize];
    
    error = readBitmapData(ifp);
    if (error > 0) {
        throw MyError("failed toread bitmap data", __FUNCTION__);
    }
    
    
    mWidth = mInfoHeader.biWidth;
    mHeight = mInfoHeader.biHeight;
    
    fclose(ifp);
}
Ejemplo n.º 27
0
void Vector :: GetPart (int startpos, BaseVector & v2) const
{
  Vector & hv2 = v2.CastToVector();

  if (Length() >= startpos + v2.Length() - 1)
    {
      const double * p1 = &Get(startpos);
      double * p2 = &hv2.Elem(1);
      
      memcpy (p2, p1, hv2.Length() * sizeof(double));
    }
  else
    MyError ("Vector::GetPart: Vector to short");
}
Ejemplo n.º 28
0
/*------------------------------------------------------------------------------------------------------------
 * ビットマップファイルを書き出す
 *
 * path: 書き出すビットマップファイル
 */
void Bitmap::writeFile(const char *path) const
{
    FILE *ofp = fopen(path, "wb");
    if (ofp == 0) {
        perror("fopen");
        fprintf(stderr, "file: %s\n", path);
        throw MyError("bitmap file open failed", __FUNCTION__);
    }
    
    writeFileHeader(ofp);
    writeInfoHeader(ofp);
    writeBitmapData(ofp);
    
    fclose(ofp);
}
Ejemplo n.º 29
0
void VDVideoDecompressorHuffyuv::DecompressFrame(void *dst, const void *src, uint32 srcSize, bool keyframe, bool preroll) {
	if (!mFormat)
		throw MyError("Cannot find compatible target format for video decompression.");

	mpDecoder->DecompressFrame(src, srcSize);

	// blit time!

	VDPixmap pxsrc(mpDecoder->GetFrameBuffer());

	VDPixmapLayout dstlayout;
	VDMakeBitmapCompatiblePixmapLayout(dstlayout, mWidth, mHeight, mFormat, 0);
	VDPixmap pxdst(VDPixmapFromLayout(dstlayout, dst));

	VDPixmapBlt(pxdst, pxsrc);
}
sint32 AVIReadTunnelStream::Read(VDPosition lStart, long lSamples, void *lpBuffer, long cbBuffer, long *plBytes, long *plSamples) {
    HRESULT hr;

    {
        VDExternalCodeBracket(mpAvisynthClipInfo ? L"Avisynth" : L"An AVIFile input stream driver", __FILE__, __LINE__);
        hr = AVIStreamRead(pas, (LONG)lStart, lSamples, lpBuffer, cbBuffer, plBytes, plSamples);
    }

    if (mpAvisynthClipInfo) {
        const char *pszErr;

        if (mpAvisynthClipInfo->GetError(&pszErr))
            throw MyError("Avisynth read error:\n%s", pszErr);
    }

    return hr;
}