From 5076dbf5c8974316119d6bad42c413a3e3bf5ec9 Mon Sep 17 00:00:00 2001 From: iovar Date: Sat, 28 Oct 2006 15:14:57 +0000 Subject: mostly changes on cache writting/loading/encoding,which is now functional.Also var other minor changes git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@124 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- rMD-exp/src/cache_frame.c | 101 +++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 45 deletions(-) (limited to 'rMD-exp/src/cache_frame.c') diff --git a/rMD-exp/src/cache_frame.c b/rMD-exp/src/cache_frame.c index c83b54b..45fb660 100644 --- a/rMD-exp/src/cache_frame.c +++ b/rMD-exp/src/cache_frame.c @@ -96,12 +96,20 @@ void *CacheImageBuffer(void *pdata){ while(((ProgData *)pdata)->running){ + int prev; + int j; + unsigned short ynum,unum,vnum; + unsigned char yblocks[256],ublocks[64],vblocks[64]; + FrameHeader fheader; + ynum=unum=vnum=0; + pthread_cond_wait(&((ProgData *)pdata)->image_buffer_ready,&imut); if(Paused) pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex); //rotate buffers + prev=current; current=(current)?0:1; //copy incoming memcpy(yuv[current].y,((ProgData *)pdata)->enc_data->yuv.y,yuv[current].y_width*yuv[current].y_height); @@ -117,16 +125,21 @@ void *CacheImageBuffer(void *pdata){ //find and flush different blocks if(firstrun){ firstrun=0; - continue; + for(j=0;j(pow(divisor,2)+pow(divisor/2,2)*2)/10) - gzsetparams (fp,1,Z_FILTERED); - else - gzsetparams (fp,0,Z_FILTERED); - strncpy(fheader.frame_prefix,"FRAM",4); - fheader.frameno=++frameno; - fheader.current_total=frames_total; - fheader.Ynum=ynum; - fheader.Unum=unum; - fheader.Vnum=vnum; - fheader.pad=0; - gzwrite(fp,(void*)&fheader,sizeof(FrameHeader)); - //flush indexes - if(ynum)gzwrite(fp,yblocks,ynum); - if(unum)gzwrite(fp,ublocks,unum); - if(vnum)gzwrite(fp,vblocks,vnum); - - - //flush the blocks for each buffer - if(ynum) - for(j=0;javd+=((ProgData *)pdata)->frametime*2*((ProgData *)pdata)->args.channels; - - - } + /**WRITE FRAME TO DISK*/ + if(ynum+unum+vnum>(pow(divisor,2)+pow(divisor/2,2)*2)/10) + gzsetparams (fp,1,Z_FILTERED); + else + gzsetparams (fp,0,Z_FILTERED); + strncpy(fheader.frame_prefix,"FRAM",4); + fheader.frameno=++frameno; + fheader.current_total=frames_total; + fheader.Ynum=ynum; + fheader.Unum=unum; + fheader.Vnum=vnum; + fheader.pad=0; + gzwrite(fp,(void*)&fheader,sizeof(FrameHeader)); + //flush indexes + if(ynum)gzwrite(fp,yblocks,ynum); + if(unum)gzwrite(fp,ublocks,unum); + if(vnum)gzwrite(fp,vblocks,vnum); + + + //flush the blocks for each buffer + if(ynum) + for(j=0;javd+=((ProgData *)pdata)->frametime*2*((ProgData *)pdata)->args.channels; + } //clean up since we're not finished @@ -190,7 +201,7 @@ void *CacheImageBuffer(void *pdata){ free(yuv[i].u); free(yuv[i].v); } - fprintf(stderr,"Saved %d frames in a total of %d requests",frameno,frames_total); + fprintf(stderr,"Saved %d frames in a total of %d requests\n",frameno,frames_total); gzclose(fp); pthread_exit(&errno); } -- cgit v1.2.3