int main()
{

    int x, y, h, w;
    int nfiles, smooth;//smooth no se usa todavia
    int factor, factor1;
    int intaux;
    bool rail;
    bool curves;
    float wroad;

    string s_aux;
    string file1, file2;

    ifstream f;


    cout << "***********************************************************\n";
    cout << "*     AUTO ROAD MAKER WITH 128x128 AND 256x256 SUPPORT    *\n";
    cout << "***********************************************************" << endl << endl << "By Com_GP ([email protected]) 06/12/2002" << endl << endl;
    cout << "SCRIPT DRIVEN, the script should be in the same folder and its\ncalled bmplist.txt\n";

    f.open("bmplist.txt");
    if(!f) {
        cout << "ERROR OPENING THE SCRIPT FILE" << endl;
        system("PAUSE");
    }
    else {

        getline( f, s_aux);
        nfiles = String2Int( s_aux );
        cout << endl << "NUMBER OF BMPs ---------> " << nfiles << endl;
        getline( f, s_aux);
        rail = String2Int( s_aux );
        cout << "RAIL EFFECT ------------> " << rail << endl;
        getline( f, s_aux);
        curves = String2Int( s_aux );
        cout << "CURVES EFFECT ----------> " << curves << endl << endl;
        getline( f, s_aux);
        intaux = String2Int( s_aux );
        wroad = (float(intaux)/100.0);
        cout << "PERCENTAGE EFFECT ------> " << intaux << endl << endl;



        rail = !rail;

        system("PAUSE");
        getline( f, file1);
        while( nfiles > 0 ) {
            getline( f, file2 );
            if( MakeTransition( file1, file2, factor, factor1, rail, curves, wroad ) == 0 )
                return 0;
            nfiles --;
        }

        f.close();
    }
    return 0;
}
// figure processing latency by doing 'dry runs' of filterBuffer()
bigtime_t FlipTransition::calcProcessingLatency() {
	PRINT(("FlipTransition::calcProcessingLatency()\n"));
	
	if(m_output.destination == media_destination::null) {
		PRINT(("\tNot connected.\n"));
		return 0LL;
	}
	
	// allocate a temporary buffer group
	BBufferGroup* pTestGroup = new BBufferGroup(4 * m_output.format.u.raw_video.display.line_width * m_output.format.u.raw_video.display.line_count, 2);
	
	// fetch a buffer
	BBuffer* pBuffer = pTestGroup->RequestBuffer(4 * m_output.format.u.raw_video.display.line_width * m_output.format.u.raw_video.display.line_count);
	BBuffer* pBuffer2 = pTestGroup->RequestBuffer(4 * m_output.format.u.raw_video.display.line_width * m_output.format.u.raw_video.display.line_count);
	ASSERT(pBuffer);
	ASSERT(pBuffer2);
	
	pBuffer->Header()->type = B_MEDIA_RAW_VIDEO;
	pBuffer->Header()->size_used = m_output.format.u.raw_video.display.line_width * m_output.format.u.raw_video.display.line_count;

	pBuffer2->Header()->type = B_MEDIA_RAW_VIDEO;
	pBuffer2->Header()->size_used = m_output.format.u.raw_video.display.line_width * m_output.format.u.raw_video.display.line_count;
	
	// run the test
	bigtime_t preTest = system_time();
	MakeTransition(pBuffer, pBuffer2);
	bigtime_t elapsed = system_time()-preTest;
	
	// clean up
	pBuffer->Recycle();
	pBuffer2->Recycle();
	delete pTestGroup;

	// reset filter state
	initFilter();

	return elapsed;
}
void FlipTransition::BufferReceived(BBuffer* pBuffer)
{
	ASSERT(pBuffer);

	// check buffer destination
	if ((pBuffer->Header()->destination != first_input.destination.id) && (pBuffer->Header()->destination != second_input.destination.id))
	{
		PRINT(("FlipTransition::BufferReceived():\n"
			"\tBad destination.\n"));
		pBuffer->Recycle();
		return;
	}
	
	if ((RunMode() != B_OFFLINE) && (pBuffer->Header()->time_source != TimeSource()->ID())) 
	{
		PRINT(("* timesource mismatch\n"));
	}

	// check output
	if (m_output.destination == media_destination::null || !m_outputEnabled) 
	{
		pBuffer->Recycle();
		return;
	}
	
	if (pBuffer->Header()->destination != first_input.destination.id)
	{// buffer vient de la premiere entree
		firstInputBufferHere = true;
		firstBuffer = pBuffer;
		PRINT(("First Buffer Received\n"));
	}
	else
	{// buffer vient de la 2eme entree
		secondInputBufferHere = true;
		secondBuffer = pBuffer;
		PRINT(("Second Buffer Received\n"));
	}
	
	if (firstInputBufferHere && secondInputBufferHere) // que ce passe-t-il si l'un des producteurs n'est plus valable ?
	{
		// process and retransmit buffer
		MakeTransition(firstBuffer, secondBuffer);		
	
		status_t err = SendBuffer(transitionBuffer, m_output.source, m_output.destination);
		if (err < B_OK)
		{
			PRINT(("FlipTransition::BufferReceived():\n"
				"\tSendBuffer() failed: %s\n", strerror(err)));
			transitionBuffer->Recycle();
		}
		firstBuffer->Recycle();
		secondBuffer->Recycle();
		firstInputBufferHere = false;
		secondInputBufferHere = false;

		if (RunMode() == B_OFFLINE)
		{
			SetOfflineTime(transitionBuffer->Header()->start_time);
//			RequestAdditionalBuffer(first_input.source, OfflineTime());
//			RequestAdditionalBuffer(second_input.source, OfflineTime());
		}
		// sent!
	}
}