Example #1
0
// slot
void Animation::playbackTimeout()
{
//  qDebug("Animation::playbackTimeout()");

  currentPlayTime+=PLAYBACK_RESOLUTION/1000.0;

  while(currentPlayTime>=frameTime())
  {
//    qDebug("Animation::playbackTimeout(%lx): !!! currentPlayTime=%f frameTime=%f",this,currentPlayTime,frameTime);
    currentPlayTime-=frameTime();
    stepForward();
  }
}
Example #2
0
void NiAnimation::stopRecording()
{
    is_recording = false;
    setFPS(DEFAULT_FPS);
    setNumberOfFrames(current_frame);
    setFrameTime(frameTime());
}
Example #3
0
void Editor::seek_timeExact(float seconds, bool display)
{
	for(int i = 0; i == 0 || frameTime() >= seconds - 0.5; ++i)
		seek_time(seconds - 1.0 * i, false);
	
	if(seconds - frameTime() > 5.0)
	{
		QMessageBox::critical(this, tr("Error"), tr("Exact seeking failed."));
		fprintf(stderr, "WARNING: Big gap: dest is %f, frameTime is %f\n",
			seconds, frameTime());
		seek_time(seconds, true);
		return;
	}
	
	while(frameTime() < seconds - 0.002)
		seek_nextFrame(false);
	
	if(display)
		displayCurrentFrame();
}
Example #4
0
void Editor::cut_pointActivated(QModelIndex idx)
{
	CutPoint* point = m_cutPointModel.cutPointForIdx(idx);
	
	m_ui->cutVideoWidget->paintFrame(point->img);
	if(fabs(frameTime() - point->time) > 0.005)
	{
		if(point->direction == CutPoint::CUT_OUT)
			seek_timeExactBefore(point->time);
		else
			seek_timeExact(point->time);
	}
}
Example #5
0
void Editor::seek_prevFrame(bool display)
{
	float time = frameTime();
	
	if(time == 0)
		return;
	
	if(--m_frameIdx < 0 && m_fullBuffer)
		m_frameIdx = NUM_FRAMES - 1;
	
	if(m_frameIdx == m_headFrame || m_frameIdx < 0)
	{
		seek_timeExactBefore(time);
		return;
	}
	
	if(display)
		displayCurrentFrame();
}
Example #6
0
void Editor::displayCurrentFrame()
{
	m_ui->videoWidget->paintFrame(
		m_frameBuffer[m_frameIdx]
	);
	
	m_ui->frameTypeLabel->setText(QString::number(m_frameBuffer[m_frameIdx]->pict_type));
	m_ui->timeStampLabel->setText(QString("%1s").arg(frameTime(m_frameIdx), 7, 'f', 4));
	m_ui->rawPTSLabel->setText(QString("%1").arg(m_frameTimestamps[m_frameIdx]));
	m_ui->headIdxLabel->setText(QString::number(m_headFrame));
	m_ui->frameIdxLabel->setText(QString::number(m_frameIdx));
	
	if(!m_ui->timeSlider->isSliderDown())
	{
		m_ui->timeSlider->blockSignals(true);
		m_ui->timeSlider->setValue(pts_val(m_frameTimestamps[m_frameIdx] - m_timeStampStart) * m_videoTimeBase);
		m_ui->timeSlider->blockSignals(false);
	}
}
Example #7
0
void Editor::cut_cut(CutPoint::Direction dir)
{
	int w = m_videoCodecCtx->width;
	int h = m_videoCodecCtx->height;
	
	AVFrame* frame = avcodec_alloc_frame();
	
	avpicture_fill(
		(AVPicture*)frame,
		(uint8_t*)av_malloc(avpicture_get_size(
			PIX_FMT_YUV420P,
			w, h
		)),
		PIX_FMT_YUV420P,
		w, h
	);
	
	av_picture_copy(
		(AVPicture*)frame,
		(AVPicture*)m_frameBuffer[m_frameIdx],
		PIX_FMT_YUV420P,
		w, h
	);
	
	if(dir == CutPoint::CUT_OUT)
		seek_nextFrame();
	
	int64_t pts = av_rescale_q(
		pts_val(m_frameTimestamps[m_frameIdx] - m_timeStampStart),
		m_videoTimeBase_q,
		AV_TIME_BASE_Q
	);
	
	int num = m_cutPoints.addCutPoint(frameTime(), dir, frame, pts);
	QModelIndex idx = m_cutPointModel.idxForNum(num);
	m_ui->cutPointView->setCurrentIndex(idx);
	
	if(dir == CutPoint::CUT_OUT)
		seek_prevFrame();
	
	cut_pointActivated(idx);
}
Example #8
0
void EmptyTrace::PrecomputeBackgroundSlopeForDeriv ( int flow_buffer_index )
{
  // calculate the slope of the background curve at every point
  float *bsPtr = &neg_bg_buffers_slope[flow_buffer_index*imgFrames];
  float *bPtr  = &bg_buffers[flow_buffer_index*imgFrames];

  // expand into frames
  assert (secondsPerFrame > 0.0f);
  assert (imgFrames == (int)timePoints.size());

  int nFrames = (int)( (timePoints[timePoints.size()-1]+.0001)/secondsPerFrame);
  std::vector<float> frameTime(nFrames, 0);
  for (int i=0; i<nFrames; i++)
    frameTime[i] = (i+1.0f)*secondsPerFrame;

  std::vector<float> interpValues(nFrames, 0);
  TimeCompression::Interpolate(&timePoints[0], bPtr, imgFrames, &frameTime[0], &interpValues[0], nFrames);
			  
  //SavitskyGolayComputeSlope ( bsPtr,bPtr,imgFrames );
  std::vector<float> slopes(nFrames, 0);
  SavitskyGolayComputeSlope ( &slopes[0], &interpValues[0], nFrames );
  TimeCompression::Interpolate(&frameTime[0], &slopes[0], nFrames, &timePoints[0], bsPtr, imgFrames);

  /* // jgv
     char s[60000]; int n=0;
     n += sprintf(s, "SavitskyGolayComputeSlope\t%d :", regionIndex);
     for (int pt = 0;pt < imgFrames;pt++)
     n += sprintf(&s[n], "\t%f", bsPtr[pt]);

     n += sprintf(&s[n], "\nOrig Time: ");
     for (int i=0; i< timePoints.size(); i++)
     n += sprintf(&s[n], "\t%f", timePoints[i]);
     n += sprintf(&s[n], "\n\0");
     assert (n<60000);
     fprintf(stdout, "%s", s);
  */
}
Example #9
0
// -------------------------
int _tmain(int argc, _TCHAR* argv[])
{


	// decl a default time
	cTime a;

	// a.mHours == 0

	// decl a time set to 1:15:30 (and :0 ms)
	cTime b( 1, 15, 30 );

	SYSTEMTIME st;
	//GetSystemTime(&st);
	GetLocalTime(&st);
		// regular constructor
	cTime now(st);
	
	// decl a time set to the value of b
	cTime c(b); // const

	// copy c to d
		// equality operator
	cTime d = c;	// half as efficient as cTime d( c );

	a.ToString();
	b.ToString();
	c.ToString();
	d.ToString();
	now.ToString();

	if(c == b)
	{
		cout << "c == b" << endl;
	}
	else
	{
		cout << "c != b" << endl;
	}

	cTime stopTime(0, 0, 30);
	cTime clock; //0, 0, 0
	cTime frameTime(0, 0, 1); //1 frame per second
	GetLocalTime(&st);
	cTime before(st);

	while(clock < stopTime)
	{
		GetLocalTime(&st);
		cTime now(st);
		cTime elapsed = now - before;
		if(elapsed >= frameTime)
		{
			clock += (elapsed.CalcSum());
			clock.ToString();
			before = now;
		}
	}

	//::OutputDebugString("Hello World\n"); //great to use later on for debugging

	cout << "Time is up!" << endl;

	return 0;
}
Example #10
0
void Editor::seek_minus30Sec()
{
	seek_time(frameTime() - 30.0);
}
Example #11
0
void Editor::seek_minus1Second()
{
	seek_time(frameTime() - 1.0);
}
Example #12
0
void Editor::seek_plus30Sec()
{
	seek_time(frameTime() + 30.0);
}
Example #13
0
void Editor::seek_plus1Second()
{
	seek_time(frameTime() + 1.0);
}
Example #14
0
void ScreenProvider::updateFps()
{
    emit fpsChanged(framebufferinfo_.fps);
    emit frameTime(framebufferinfo_.frametime);
}
Animator::Animator()
{
  Dout( dc::notice, "Animator::Animator() - current frametime is " << frameTime() );
  _ea = ecore_animator_add( &Animator::__dispatcher, this );
}
Example #16
0
bool calculateMasterConditions_(struct game_t* game)
{
    int sectionSum = 0;
    const int TETRIS_INDEX = 3;

    for (int i = 0; i < game->currentSection; i++)
    {
        struct section_t* section = &game->sections[i];

        // First 5 sections must be completed in 1:05:00 or less
        if (i < 5)
        {
            if (getSectionTime(section) > frameTime(65))
            {
                return false;
            }
            sectionSum += getSectionTime(section);

            // Two tetrises per section is required for the first 5 sections.
            if (section->lines[TETRIS_INDEX] < 2)
            {
                return false;
            }
        }
        // Sixth section (500-600) must be less than two seconds slower than the
        // average of the first 5 sections.
        else if (i == 5)
        {
            if (getSectionTime(section) > frameTime(sectionSum / 5 + 2))
            {
                return false;
            }

            // One tetris is required for the sixth section.
            if (section->lines[TETRIS_INDEX] < 1)
            {
                return false;
            }
        }
        // Last four sections must be less than two seconds slower than the
        // previous section.
        else
        {
            struct section_t* prevSection = &game->sections[i - 1];

            if (getSectionTime(section) > getSectionTime(prevSection) + frameTime(2))
            {
                return false;
            }

            // One tetris is required for the last four sections EXCEPT the last
            // one.
            if (section->lines[TETRIS_INDEX] < 1)
            {
                return false;
            }
        }
    }

    // Finally, an S9 grade is required at level 999 along with the same time
    // requirements as the eigth section.
    if (game->curState.level == LEVEL_MAX_LONG)
    {
        if (game->curState.grade < MASTER_S9_INTERNAL_GRADE)
        {
            return false;
        }

        // Hard time requirement over the entire game is 8:45:00
        if (game->sections[9].endTime - game->sections[0].startTime > frameTime(8 * 60 + 45))
        {
            return false;
        }

        // Test section time vs previous section
        struct section_t* section = &game->sections[9];
        struct section_t* prevSection = &game->sections[8];

        if (getSectionTime(section) > getSectionTime(prevSection) + frameTime(2))
        {
            return false;
        }
    }

    return true;
}