/* this function calculates the packet size (frame size) for each video frame, the idt is always fixed to the framerate (i.e., between 20 and 50 fps, default=25) input: - vidoe stream output: - frame size */ double tarmaCalculateVideoSample(tarmaVideo_t *video){ double size=0; double inputsamples[TARMA_NUM_PROCESSES]; tarmaProcess_t *proc; int frameidx; int cntp, cntpy; if(video){ proc=&(video->tarma_size); frameidx=video->tarmaVideoGopStructure[video->tarmaVideoFrameNumber]; LOG_D(OTG,"TARMA_DEBUG: tarmaCalculateVideoSample(%p) called\n", video); LOG_D(OTG,"TARMA_DEBUG: frameidx=%d\n",frameidx); if(frameidx>=0 && frameidx<=TARMA_NUM_FRAME_TYPES){ for(cntpy=0; cntpy<TARMA_NUM_POLY_MAX; cntpy++){ proc->polyWeight[cntpy]=video->polyWeightFrame[frameidx][cntpy]; } for(cntp=0; cntp<TARMA_NUM_PROCESSES; cntp++){ inputsamples[cntp]=gaussian_dist(10000,1)-10000; } size=tarmaCalculateSample(inputsamples,proc); } /*get ready for the next frame*/ video->tarmaVideoFrameNumber++; if(video->tarmaVideoFrameNumber>=TARMA_NUM_GOP_MAX){ video->tarmaVideoFrameNumber=0; } if(video->tarmaVideoGopStructure[video->tarmaVideoFrameNumber]<0 || video->tarmaVideoGopStructure[video->tarmaVideoFrameNumber]>TARMA_NUM_FRAME_TYPES){ video->tarmaVideoFrameNumber=0; } } return size; }
// -------------------------------------------------- double RngBoost::gaussianSample(double stdDev) const { double mean = 0.; //it will be added conveniently later static boost::uniform_01<boost::mt19937> zeroone(m_rng); boost::math::normal_distribution<double> gaussian_dist(mean, stdDev); return quantile(gaussian_dist, zeroone()); }
/* this function must be called each time before size and itd are generated for the respective packet. it updates the input samples stored in the structure stream, ps: calling it more often than for each packet is also fine input: - the stream to be updated output: */ void tarmaUpdateInputSample (tarmaStream_t *stream){ int cnt; LOG_T(OTG,"TARMA_DEBUG: tarmaUpdateInputSample(%p)\n", stream); if(stream){ for(cnt=0; cnt<TARMA_NUM_PROCESSES; cnt++){ stream->tarma_input_samples[cnt]=gaussian_dist(10000,1)-10000; LOG_D(OTG,"TARMA_DEBUG: %f\n",stream->tarma_input_samples[cnt]); } } }