medDataReaderWriter::Reader medDataReaderWriter::reader(const QString& path) {
    QList<QString> readers = medAbstractDataFactory::instance()->readers();

    if (readers.size()==0) {
#if 0
        emit showError(tr("No reader plugin"),5000);
        emit failure(this);
#endif
        return Reader();
    }

    const QFileInfo& fi(path);
    const QString&   filename = fi.filePath();

    //  Store the last reader.

    static Reader dreader;

    if (!dreader.isNull() && dreader->canRead(filename))
        return dreader;

    for (int i=0;i<readers.size();++i) {
        dreader = medAbstractDataFactory::instance()->readerSmartPointer(readers[i]);
        if (dreader->canRead(filename)) {
            dreader->enableDeferredDeletion(false);
            return dreader;
        }
    }
    return dreader = Reader();
}
bool MultipartParser::parse(const uint8_t *d, size_t l, const String &ct, bool files) {
    Reader r(ct.c_str(), ct.length());
	if (!parseContentType(r)) {
		return false;
	}

    readFiles = files;
    data = Reader((const char *)d, l);
    origData = Reader((const char *)d, l);
	return parseBody();
}
Exemple #3
0
static bool Bitmap_getTiffImageSize(StackBuffer<256> &data, const io::Producer &file, size_t &width, size_t &height) {
	auto reader = Reader(data.data() + 4, 4);
	auto offset = reader.readUnsigned32();

	data.clear();
	if (file.seekAndRead(offset, data, 2) != 2) {
		return false;
	}
	auto size = Reader(data.data(), 2).readUnsigned16();
	auto dictSize = size * 12;
	offset += 2;
	while (dictSize > 0) {
		data.clear();
		size_t blockSize = min(12 * 21, dictSize);
		if (file.read(data, blockSize) != blockSize) {
			return false;
		}

		auto blocks = blockSize / 12;
		reader = Reader(data.data(), blockSize);

		for (uint16_t i = 0; i < blocks; ++i) {
			auto tagid = reader.readUnsigned16();
			auto type = reader.readUnsigned16();
			auto count = reader.readUnsigned32();
			if (tagid == 256 && count == 1) {
				if (type == 3) {
					width = reader.readUnsigned16();
					reader.offset(2);
				} else if (type == 4) {
					width = reader.readUnsigned32();
				} else {
					reader.offset(4);
				}
			} else if (tagid == 257 && count == 1) {
				if (type == 3) {
					height = reader.readUnsigned16();
					reader.offset(2);
				} else if (type == 4) {
					height = reader.readUnsigned32();
				} else {
					reader.offset(4);
				}
				return true;
			} else {
				if (tagid > 257) {
					return false;
				}
				reader.offset(4);
			}
		}
	}
	return false;
}
Exemple #4
0
bool WiiWAD::IsWiiWAD(const std::string& _rName)
{
	DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName.c_str());
	if (pReader == NULL)
		return false;

	CBlobBigEndianReader Reader(*pReader);
	bool Result = false;

	// check for wii wad
	if (Reader.Read32(0x00) == 0x20)
	{
		u32 WADTYpe = Reader.Read32(0x04);
		switch(WADTYpe)
		{
		case 0x49730000:
		case 0x69620000:
			Result = true;
		}
	}

	delete pReader;

	return Result;
}
void FTransaction::FObjectRecord::Restore( FTransaction* Owner )
{
	if( !bRestored )
	{
		bRestored = true;
		TArray<uint8> FlipData;
		TArray<FReferencedObject> FlipReferencedObjects;
		TArray<FName> FlipReferencedNames;
		TSharedPtr<ITransactionObjectAnnotation> FlipObjectAnnotation;
		if( Owner->bFlip )
		{
			FlipObjectAnnotation = Object->GetTransactionAnnotation();
			FWriter Writer( FlipData, FlipReferencedObjects, FlipReferencedNames, bWantsBinarySerialization );
			SerializeContents( Writer, -Oper );
		}
		FTransaction::FObjectRecord::FReader Reader( Owner, Data, ReferencedObjects, ReferencedNames, bWantsBinarySerialization );
		SerializeContents( Reader, Oper );
		if( Owner->bFlip )
		{
			Exchange( ObjectAnnotation, FlipObjectAnnotation );
			Exchange( Data, FlipData );
			Exchange( ReferencedObjects, FlipReferencedObjects );
			Exchange( ReferencedNames, FlipReferencedNames );
			Oper *= -1;
		}
	}
}
Exemple #6
0
static int
GRecvCmd( int *val )
{
	if (Reader( val, sizeof(*val) ) != sizeof(*val))
		return 0;
	return 1;
}
void CSenBaseIdentityManager::StartElementL(
                                          const TDesC8& aNsUri,
                                          const TDesC8& aLocalName,
                                          const TDesC8& aQName,
                                          const RAttributeArray& aAttributes
                                                  )
    {
    if (aLocalName ==  KIdentityElementLocalName)
        {
        delete iIdentity;   // there can be only one at the moment
        iIdentity = NULL;
        TPtr8 imei = ipDeviceID->Des();
        iIdentity = CSenBaseIdentity::NewL(imei);
        iIdentity->SetAttributesL(aAttributes);
        iIdentity->SetReader(*Reader());
        DelegateParsingL(*iIdentity);
        }
//  else if (aLocalName == KUsers)
//      {
//      }
    else
        {
        CSenBaseFragment::StartElementL(aNsUri, 
                                    aLocalName, aQName, aAttributes);
        }
    }
void FourierSearch::run(QString pathToCuttedData) {
    QStringList files = QDir(pathToCuttedData).entryList();
    const int modules = 6;
    const int rays = 8;
    const int channels = 6;
    QVector<float> res[6][8];
    for (int i = 0; i < modules; i++)
        for (int j = 0; j < rays; j++) {
            res[i][j].resize(1024);
            res[i][j].fill(0);
        }

    for (int i = 0; i < files.size(); i++)
        if (files[i].endsWith(".pnt")) {
            QString name = QDir(pathToCuttedData).absolutePath()+ "/" + files[i];
            qDebug() << "processing file" << name;
            Data data = Reader().readBinaryFile(name);
            for (int module = 0; module < modules; module++)
                for (int ray = 0; ray < rays; ray++)
                    for (int channel = 0; channel < channels; channel++)
                        runFourier(data, res[module][ray], module, ray, channel);
        }

    QFile f("/home/vlad/txt");
    f.open(QIODevice::WriteOnly);
    QTextStream s(&f);
    for (int i = 0; i < 1024; i++)
        s << res[5][7][i] << "\n";
}
Exemple #9
0
MeshReader
detectInput( const std::string& filename )
// *****************************************************************************
//  Detect input mesh file type
//! \param[in] filename File to open and detect its type
//! \return enum specifying the mesh reader type
//! \author J. Bakosi
// *****************************************************************************
{
  // Get first three letters from input file
  std::string s( Reader( filename ).firstline().substr(0,4) );

  if ( s.find("$Me") != std::string::npos ) {
    return MeshReader::GMSH;
  } else if ( s.find("CDF") != std::string::npos ||
              s.find("HDF") != std::string::npos ) {
    return MeshReader::EXODUSII;
  } else if ( s.find("<?x") != std::string::npos ) {
    return MeshReader::HYPERMESH;
  } else {
    try {
      std::stoi(s);    // try to convert to an integer
    } catch ( std::invalid_argument ) {
      Throw( "Input mesh file type could not be determined from header: " +
             filename );
    }
    // could also catch std::out_of_range, the other exception potentially
    // thrown by std::stoi(), but a three-digit integer will always fit into int

    // if we got here, the above string-to-integer conversion succeeded
    return MeshReader::NETGEN;
  }
}
Exemple #10
0
int main()
{
	printf("\nProcessing...\n");

	pcb_list = fopen("directory.pcb", "rt");
	if (!pcb_list)
	{
		printf("error! no directory.pcb file in this dir\n");
		exit(1);
	}

	dd_list = fopen("daydream.dir", "wt");
	if (!dd_list)
	{
		printf("error writing directory.new.daydream file!\n");
		exit(1);
	}

	fgets(line, 200, pcb_list);
	fgets(line, 200, pcb_list);                     /* header */

	while (!feof(pcb_list))
		Reader();

	printf("Thanks for using pcbfilelist to daydreamfilelist.\n");

	fclose(pcb_list);
	printf("closed pcb_list\n");
	fclose(dd_list);
	printf("closed dd_list\n");

	return 0;
}
Exemple #11
0
EDiscType GetDiscType(IBlobReader& _rReader)
{
	CBlobBigEndianReader Reader(_rReader);
	u32 WiiMagic = Reader.Read32(0x18);
	u32 WiiContainerMagic = Reader.Read32(0x60);
	u32 WADMagic = Reader.Read32(0x02);
	u32 GCMagic = Reader.Read32(0x1C);

	// check for Wii
	if (WiiMagic == 0x5D1C9EA3 && WiiContainerMagic != 0)
		return DISC_TYPE_WII;
	if (WiiMagic == 0x5D1C9EA3 && WiiContainerMagic == 0)
		return DISC_TYPE_WII_CONTAINER;

	// check for WAD
	// 0x206962 for boot2 wads
	if (WADMagic == 0x00204973 || WADMagic == 0x00206962)
		return DISC_TYPE_WAD;

	// check for GC
	if (GCMagic == 0xC2339F3D)
		return DISC_TYPE_GC;

	WARN_LOG(DISCIO, "No known magic words found");
	WARN_LOG(DISCIO, "Wii  offset: 0x18 value: 0x%08x", WiiMagic);
	WARN_LOG(DISCIO, "WiiC offset: 0x60 value: 0x%08x", WiiContainerMagic);
	WARN_LOG(DISCIO, "WAD  offset: 0x02 value: 0x%08x", WADMagic);
	WARN_LOG(DISCIO, "GC   offset: 0x1C value: 0x%08x", GCMagic);

	return DISC_TYPE_UNK;
}
Exemple #12
0
//----------------------------------------------------------------------------
//! @brief	  	再生が開始された時にコールされる
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CDemuxSource::ChangeStart(void)
{
	UpdateFromSeek();
	if( m_rtStart > m_rtDuration  )
		m_rtStart = m_rtDuration;	// 丸め

	return Reader()->SetStartTime( m_rtStart );
}
Exemple #13
0
//Load and save gamesettings
void GameProperties::Load()
{
	CIniReader Reader(CFG_FILENAME);

	GameProperties::Width = Reader.ReadInteger("settings" , "app_width" , 1280);
	GameProperties::Height = Reader.ReadInteger("settings" , "app_height" , 1024);
	GameProperties::Windowed = Reader.ReadInteger("settings" , "app_windowed" , 1);

}
Exemple #14
0
bool FNFSMessageHeader::ReceivePayload(FArrayReader& OutPayload, const FSimpleAbstractSocket& Socket)
{
    // make room to receive a header
    TArray<uint8> HeaderBytes;
    int32 Size = sizeof(FNFSMessageHeader);
    HeaderBytes.AddZeroed(Size);

    if (!Socket.Receive(HeaderBytes.GetData(), Size))
    {
        UE_LOG(LogSockets, Error, TEXT("Unable to read full header"));
        return false;
    }

    // parse it as a header (doing any byte swapping as needed)
    FMemoryReader Reader(HeaderBytes);
    FNFSMessageHeader Header(Socket);
    Reader << Header;

    // make sure it's valid
    if (Header.Magic != Socket.GetMagic())
    {
        UE_LOG(LogSockets, Error, TEXT("Bad network header magic"));
        return false;
    }
    if (!Header.PayloadSize)
    {
        UE_LOG(LogSockets, Error, TEXT("Empty payload"));
        return false;
    }

    // was the header byteswapped? If so, make the archive byteswapped
    OutPayload.SetByteSwapping(Reader.ForceByteSwapping());

    // we are going to append to the payload, so note how much data is in it now
    int32 PayloadOffset = OutPayload.AddUninitialized(Header.PayloadSize);

    // put the read head at the start of the new data
    OutPayload.Seek(PayloadOffset);

    // receive the payload
    if (!Socket.Receive(OutPayload.GetData() + PayloadOffset, Header.PayloadSize))
    {
        UE_LOG(LogSockets, Error, TEXT("Unable to read full payload"));
        return false;
    }

    // make sure it's valid
    uint32 ActualPayloadCrc = FCrc::MemCrc_DEPRECATED(OutPayload.GetData() + PayloadOffset, Header.PayloadSize);
    if (Header.PayloadCrc != ActualPayloadCrc)
    {
        UE_LOG(LogSockets, Error, TEXT("Payload Crc failure."));
        return false;
    }

    // success!
    return true;
}
Exemple #15
0
//----------------------------------------------------------------------------
//! @brief	  	再生範囲の設定を反映する
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CWMReader::SetRange(void)
{
	QWORD		duration;
	if( m_EndTime != 0 )
		duration = m_EndTime - m_StartTime;
	else
		duration = GetDuration() - m_StartTime;
	return Reader()->SetRange( m_StartTime, duration );
}
Exemple #16
0
//----------------------------------------------------------------------------
//! @brief	  	ストリームが閉じられる時にコールされる
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CWMReader::Close(void)
{
	Reader()->Close();
	m_AudioOut.SetStreamNumber( 0 );
	m_VideoOut.SetStreamNumber( 0 );
	m_StartTime = 0;
	m_EndTime = 0;
	m_Rate = 1.0;
	return S_OK;
}
std::auto_ptr< input::Traits<engine::ImageStack> >
OpenFile::getTraits()
{
    char readsif_error[4096];
    dataSet->error_buffer = readsif_error;

    std::auto_ptr< engine::InputTraits > 
        rv( new engine::InputTraits() );
    /* Read the additional information file from the SIF file
     * and store it in SIF info structure. */
    std::stringstream ss;

    rv->push_back( engine::InputPlane() );
    rv->plane(0).image.size.x() = 
            readsif_imageWidth( dataSet, 0 ) * camera::pixel;
    rv->plane(0).image.size.y() = readsif_imageHeight( dataSet, 0 )
            * camera::pixel;
    if ( dataSet->instaImage.kinetic_cycle_time > 1E-8 ) {
        rv->frame_rate = 1.0f * camera::frame / ( dataSet->instaImage.kinetic_cycle_time
                * boost::units::si::second );
    }
    rv->image_number().range().second =
        (readsif_numberOfImages(dataSet) - 1) * camera::frame;

    boost::units::quantity<boost::units::celsius::temperature,int> temp
        = (int(dataSet->instaImage.temperature) * boost::units::celsius::degrees);
    Reader r(rv->infos[DataSetTraits::CameraTemperature]);
    static_cast<std::ostream&>(r) << temp;

    if ( dataSet->instaImage.OutputAmp == 0 )
        rv->infos[DataSetTraits::OutputAmplifierType] = "Electron multiplication";
    else
        rv->infos[DataSetTraits::OutputAmplifierType] = "Conventional amplification";

    Reader(rv->infos[DataSetTraits::VerticalShiftSpeed]) 
        << dataSet->instaImage.data_v_shift_speed*1E6 << " µs";
    Reader(rv->infos[DataSetTraits::HorizontalShiftSpeed]) 
        << 1E-6/dataSet->instaImage.pixel_readout_time << " MHz";
    Reader(rv->infos[DataSetTraits::PreamplifierGain]) 
        << dataSet->instaImage.PreAmpGain;

    return rv;
}
Exemple #18
0
void ReadReaders()
{
    std::ifstream in("./data/readers.txt", std::ios::in);
    readers.clear();
    Reader tmp;
    while (in >> tmp)
	{
        readers.push_back(tmp);
		tmp = Reader();
	}
}
void FTransaction::FObjectRecord::Restore( FTransaction* Owner )
{
	// only used by FMatineeTransaction:
	if( !bRestored )
	{
		bRestored = true;
		check(!Owner->bFlip);
		FTransaction::FObjectRecord::FReader Reader( Owner, Data, ReferencedObjects, ReferencedNames, bWantsBinarySerialization );
		SerializeContents( Reader, Oper );
	}
}
void ezReloadableVariableBase::RetrieveVariable(const char* szVarName, ezReloadableVariableBase* pVariable)
{
  if (s_StoredVariables)
  {
    if (s_StoredVariables->Find(szVarName).IsValid())
    {
      ezMemoryStreamReader Reader(&(*s_StoredVariables)[szVarName]);
      pVariable->LoadState(Reader);
    }
  }
}
Exemple #21
0
//----------------------------------------------------------------------------
//! @brief	  	再生レートが変更された時にコールされる
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CDemuxSource::ChangeRate(void)
{
	{	// クリティカル セクション ロックのスコープ。
		CAutoLock cAutoLock(&m_crtFilterLock);
		if( m_dRateSeeking <= 0 ) {
			m_dRateSeeking = 1.0;  // 適切な値にリセットする。
			return E_FAIL;
		}
	}
	UpdateFromSeek();
	return Reader()->SetRate( m_dRateSeeking );
}
Exemple #22
0
//----------------------------------------------------------------------------
//! @brief	  	ストリームを開く
//! @param		stream : ストリーム
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CWMReader::OpenStream( IStream *stream )
{
	HRESULT		hr = S_OK;
	if( stream == NULL )
		return E_INVALIDARG;

	if( m_WMReader.p == NULL )
	{	// DLLからWMCreateSyncReaderを読み込んで使用する
		if( m_WmvDll.IsLoaded() == false )
			m_WmvDll.Load("wmvcore.dll");
		if( m_WmvDll.IsLoaded() == false )
			return m_WmvDll.GetLastError();

		typedef HRESULT (*FuncWMCreateSyncReader)( IUnknown *pUnkCert, DWORD dwRights, IWMSyncReader **ppSyncReader );
		FuncWMCreateSyncReader pWMCreateSyncReader = (FuncWMCreateSyncReader)m_WmvDll.GetProcAddress("WMCreateSyncReader");
		if( pWMCreateSyncReader == NULL )
			return m_WmvDll.GetLastError();
		if( FAILED(hr = pWMCreateSyncReader(  NULL, 0, &m_WMReader ) ))
			return hr;
	}

	if( FAILED( hr = Reader()->OpenStream( stream ) ) )
		return hr;

	CComPtr<IWMProfile>	pProfile;
	if( FAILED(hr = Reader()->QueryInterface( &pProfile ) ) )
		return hr;

	if( FAILED(hr = GetStreamNumbers( pProfile ) ) )
		return hr;

	if( FAILED(hr = Reader()->QueryInterface( &m_HeaderInfo ) ) )
		return hr;

	if( FAILED(hr = SetStream() ) )
		return hr;

//	hr = SetRange();
	return hr;
}
	Map* MapLoader::loadMap(const string& mapFileName, const string& constrFileName) {
		ifstream mapFile(mapFileName);
		LoadableLocationSet locations;
		LoadableReaderSet readers;
		NameIdMap locationsMap;
		string line;
		if (mapFile.is_open()) {
			unsigned int lId = 0, rId = 0;
			while (getline(mapFile, line)) {
				Util::trim(line);
				// Jump if blank line or comment (starts with '#')
				if (line.length() == 0 || line[0] == '#') continue;
				vector<string> v = Util::split(line, SEP);
				if (v.size() == 5) { // Location line
					string name = v[0];
					double x = stod(v[1]), y = stod(v[2]),
					       w = stod(v[3]), h = stod(v[4]);
					locationsMap.insert(NameIdPair(name, lId));
					locations.push_back(Location(lId++, name, x, y, w, h));
				} else if (v.size() == 3) { // Reader line
					string name = v[0];
					double x = stod(v[1]), y = stod(v[2]);
					readers.push_back(Reader(rId++, name, x, y));
				} else throw BadInput();
			}
		} else throw BadInput();
		Map* map = Map::createMap<LoadableLocationSet,LoadableReaderSet>(locations, readers);
		ifstream constrFile(constrFileName);
		if (constrFile.is_open()) {
			while (getline(constrFile, line)) {
				Util::trim(line);
				// Jump if blank line or comment (starts with '#')
				if (line.length() == 0 || line[0] == '#') continue;
				vector<string> v = Util::split(line, CSEP);
				if (v[0] == "DR") { // Direct Reachability Constraint
					unsigned int id1 = locationsMap.at(v[1]), id2 = locationsMap.at(v[2]);
					map->setDR(id1, id2);
				} else if (v[0] == "DU") { // Direct Unreachability Constraint
					unsigned int id1 = locationsMap.at(v[1]), id2 = locationsMap.at(v[2]);
					map->setDU(id1, id2);
				} else if (v[0] == "LT") { // Latency Constraint
					unsigned int id = locationsMap.at(v[1]), latency = stoi(v[2]);
					map->setLT(id, latency);
				} else if (v[0] == "TT") { // Traveling Time Constraint
					unsigned int id1 = locationsMap.at(v[1]), id2 = locationsMap.at(v[2]),
						     travelingTime = stoi(v[3]);
					map->setTT(id1, id2, travelingTime);
				} else throw BadInput();
			}
		}
		return map;
	}
bool MultipartParser::parse(const uint8_t *d, size_t l, bool files) {
    data = Reader((const char *)d, l);
    origData = Reader((const char *)d, l);

	Reader str = readLine();
	while (!str.empty()) {
		if (str.is("Content-Type:")) {
            str.offset("Content-Type:"_len);
			if (!parseContentType(str)) {
				return false;
			}
		}
		str = readLine();
	}

	if (contentType.empty() || boundary.empty()) {
		return false;
	}

	readFiles = files;
	return parseBody();
}
Exemple #25
0
//----------------------------------------------------------------------------
//! @brief	  	再生したいストリームを開く
//! @param		stream : ムービーへのストリーム
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CDemuxSource::OpenStream( IStream *stream )
{
	CAutoLock lock(&m_crtFilterLock);

	HRESULT hr;
	if( (hr = Reader()->OpenStream(stream)) != S_OK )
		return hr;

	m_rtDuration = Reader()->GetDuration();
	m_rtStop = m_rtDuration;

	ClearPins();
	for( int i = 0; i < Reader()->GetNumberOfOutput(); ++i )
	{
		IOutputStream	*outStream = Reader()->GetOutputStream(i);
		assert( outStream );
		CDemuxOutputPin *pin = new CDemuxOutputPin( NAME("Demux Source"), this, &hr, L"Demux output pin", this, outStream, &m_crtFilterLock );
//		pin->AddRef();
		// AddPinはnewした段階でコールされるので、明示的に追加する必要はない
	}
	return hr;
}
int main(int argc, char *argv[])
{

	std::ifstream Reader("File1.txt");             //Open file

	std::string Art = getFileContents(Reader);       //Get file

	std::cout << Art << std::endl;               //Print it to the screen

	Reader.close();                           //Close file

	return 0;
}
Exemple #27
0
static void *
ReaderThread( void *param )
{
  cOpenHpiClientConf *c = (cOpenHpiClientConf *)param;

  c->m_thread_state = eOpenHpiClientThreadStateRun;

  Reader( c );

  c->m_thread_state = eOpenHpiClientThreadStateExit;

  return 0;
}
void UPaperSprite::FindTextureBoundingBox(float AlphaThreshold, /*out*/ FVector2D& OutBoxPosition, /*out*/ FVector2D& OutBoxSize)
{
	// Create an initial guess at the bounds based on the source rectangle
	int32 LeftBound = (int32)SourceUV.X;
	int32 RightBound = (int32)(SourceUV.X + SourceDimension.X - 1);

	int32 TopBound = (int32)SourceUV.Y;
	int32 BottomBound = (int32)(SourceUV.Y + SourceDimension.Y - 1);


	FTextureReader Reader(SourceTexture);
	if (Reader.IsValid())
	{
		Reader.AlphaThreshold = FMath::Clamp<int32>(AlphaThreshold * 255, 0, 255);

		// Make sure the initial bounds starts in the texture
		LeftBound = FMath::Clamp(LeftBound, 0, Reader.Width-1);
		RightBound = FMath::Clamp(RightBound, 0, Reader.Width-1);
		TopBound = FMath::Clamp(TopBound, 0, Reader.Height-1);
		BottomBound = FMath::Clamp(BottomBound, 0, Reader.Height-1);

		// Pull it in from the top
		while ((TopBound < BottomBound) && IsClearRow(Reader, LeftBound, RightBound, TopBound))
		{
			++TopBound;
		}

		// Pull it in from the bottom
		while ((BottomBound > TopBound) && IsClearRow(Reader, LeftBound, RightBound, BottomBound))
		{
			--BottomBound;
		}

		// Pull it in from the left
		while ((LeftBound < RightBound) && IsClearColumn(Reader, LeftBound, TopBound, BottomBound))
		{
			++LeftBound;
		}

		// Pull it in from the right
		while ((RightBound > LeftBound) && IsClearColumn(Reader, RightBound, TopBound, BottomBound))
		{
			--RightBound;
		}
	}

	OutBoxSize.X = RightBound - LeftBound + 1;
	OutBoxSize.Y = BottomBound - TopBound + 1;
	OutBoxPosition.X = LeftBound;
	OutBoxPosition.Y = TopBound;
}
Exemple #29
0
//----------------------------------------------------------------------------
//! @brief	  	フィルタをポーズする
//! @return		エラーコード
//----------------------------------------------------------------------------
STDMETHODIMP CDemuxSource::Pause()
{
	{
		CAutoLock lock(&m_crtFilterLock);
		if( m_State == State_Stopped )
		{
			HRESULT	hr = Reader()->OnStart();
			if( FAILED(hr) )
				return hr;
			NewSegment();
		}
	}
	return CSource::Pause();
}
Exemple #30
0
//----------------------------------------------------------------------------
//! @brief	  	次のサンプルを得る
//! @param		pSample : サンプルを返すポインタのポインタ
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CWMOutput::GetNextSample( IMediaSample **pSample )
{
	HRESULT hr;
	if( m_StreamNum == 0 || pSample == NULL )
		return S_FALSE;	// このストリームはない

	INSSBuffer	*pWMSample = NULL;
	QWORD	cnsSampleTime;
	QWORD	cnsDuration;
	DWORD	dwFlags;

	if( FAILED(hr = WMReader()->GetNextSample( m_StreamNum, &pWMSample, &cnsSampleTime, &cnsDuration, &dwFlags, NULL, NULL )) )
	{
		if( hr == NS_E_NO_MORE_SAMPLES ) return S_FALSE;
		return hr;
	}

	REFERENCE_TIME	startTime = (REFERENCE_TIME)cnsSampleTime;
	REFERENCE_TIME	endTime = (REFERENCE_TIME)(cnsSampleTime + cnsDuration);
	IMediaSample *pOutSample = reinterpret_cast<CWMBuffer*>(pWMSample)->GetSample();
	pOutSample->AddRef();
	pWMSample->Release();
	pOutSample->SetMediaTime(&startTime, &endTime);
#if 0
	if( startTime < Reader()->m_StartTime )
		pOutSample->SetPreroll(TRUE);
	else
		pOutSample->SetPreroll(FALSE);
#endif
	startTime -= Reader()->m_StartTime;
	endTime -= Reader()->m_StartTime;
	pOutSample->SetTime(&startTime, &endTime);
	pOutSample->SetSyncPoint(dwFlags & WM_SF_CLEANPOINT);
	*pSample = pOutSample;

	return hr;
}