video_data_queue.clear();
do_reset_encoder_options();
+
+ //video_queue_mutex = new QMutex(QMutex::Recursive);
totalSrcFrame = 0;
totalDstFrame = 0;
totalAudioFrame = 0;
req_close = false;
req_stop = false;
bRunThread = false;
+
}
MOVIE_SAVER::~MOVIE_SAVER()
{
if(recording) do_close_main();
+ //if(video_queue_mutex) delete video_queue_mutex;
+
}
QString MOVIE_SAVER::ts2str(int64_t ts)
if(req_stop) return;
uint32_t *pq;
VIDEO_DATA *px = new VIDEO_DATA(frames, width, height, p);
- //AGAR_DebugLog(AGAR_LOG_DEBUG, "Movie: Enqueue video data %dx%d %d bytes %dx%d", width, height, p->byteCount(), p->width(), p->height());
+ //AGAR_DebugLog(AGAR_LOG_DEBUG, "Movie: Enqueue video data %dx%d %d bytes %dx%d %d frames", width, height, p->byteCount(), p->width(), p->height(), frames);
+ //video_queue_mutex->lock();
video_data_queue.enqueue(px);
+ //video_queue_mutex->unlock();
#endif
}
} OutputStream;
class OSD;
-
+class QMutex;
QT_BEGIN_NAMESPACE
class VIDEO_DATA {
private:
int n_encode_audio;
int n_encode_video;
-// int64_t audio_enqueue_count;
+ //QMutex *video_queue_mutex;
protected:
OSD *p_osd;
config_t *p_config;
uint32_t *p;
AVFrame *qq = ost->tmp_frame;
uint32_t *q;
+ uint32_t cacheline[8];
int i;
int ret;
if(ost->tmp_frame != NULL) {
//exit(1);
for(y = 0; y < h; y++) {
yy[0] = y * qq->linesize[0];
- //yy[0] = y * in_linesize[0];
p = (uint32_t *)(&(video_frame_buf[y * w]));
q = (uint32_t *)(&(qq->data[0][yy[0]]));
- for(x = 0; x < w; x++) {
- *q++ = *p++;
- }
+ for(x = 0; x < (w / 8); x++) {
+ cacheline[0] = p[0];
+ cacheline[1] = p[1];
+ cacheline[2] = p[2];
+ cacheline[3] = p[3];
+ cacheline[4] = p[4];
+ cacheline[5] = p[5];
+ cacheline[6] = p[6];
+ cacheline[7] = p[7];
+
+ q[0] = cacheline[0];
+ q[1] = cacheline[1];
+ q[2] = cacheline[2];
+ q[3] = cacheline[3];
+ q[4] = cacheline[4];
+ q[5] = cacheline[5];
+ q[6] = cacheline[6];
+ q[7] = cacheline[7];
+
+ q += 8;
+ p += 8;
+ }
+ if((w & 7) != 0) {
+ for(x = 0; x < (w & 7); x++) {
+ q[x] = p[x];
+ }
+ }
}
}
sws_scale(ost->sws_ctx,
double vm_fps = vm_frame_rate();
int delta_ns = (int)(1.0e9 / vm_fps);
//if(rec_video_fps_nsec >= delta_ns) {
- { // Will branch whether rec_video_fps_nsec >= delta_ns ?
+ if(delta_ns == rec_video_fps_nsec) {
+ rec_video_nsec += delta_ns;
+ if(rec_video_nsec > (rec_video_fps_nsec * 2)) {
+ rec_video_nsec -= rec_video_fps_nsec;
+ } else if(rec_video_nsec < (rec_video_fps_nsec * -2)) {
+ rec_video_nsec += rec_video_fps_nsec;
+ }
+ while(rec_video_nsec > rec_video_fps_nsec) {
+ rec_video_nsec -= rec_video_fps_nsec;
+ counter++;
+ }
+ } else { // Will branch whether rec_video_fps_nsec >= delta_ns ?
rec_video_nsec += delta_ns;
if(rec_video_nsec > (rec_video_fps_nsec * 2)) {
rec_video_nsec -= rec_video_fps_nsec;
} else {
int size = vm_screen_buffer.pImage.byteCount();
int i = counter;
- // Rescaling
QImage video_result = QImage(vm_screen_buffer.pImage);
+ // Rescaling
if(i > 0) {
// Enqueue to frame.
emit sig_enqueue_video(i, vm_screen_width, vm_screen_height, &video_result);