From ba11f851311f9f92f92fcd8148a8f621b736e979 Mon Sep 17 00:00:00 2001 From: iovar Date: Tue, 24 Oct 2006 12:58:54 +0000 Subject: gzipped frame caching git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@114 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- rMD-exp/include/recordmydesktop.h | 38 +++++++++++++++---------- rMD-exp/src/cache_frame.c | 58 +++++++++++++++++++++++++++++++++++---- 2 files changed, 76 insertions(+), 20 deletions(-) diff --git a/rMD-exp/include/recordmydesktop.h b/rMD-exp/include/recordmydesktop.h index 9255525..b06db1b 100644 --- a/rMD-exp/include/recordmydesktop.h +++ b/rMD-exp/include/recordmydesktop.h @@ -235,31 +235,39 @@ typedef struct _ProgData{ //the same platform. //We need the total number of blocks -//and the position number of each of them -//(separately for y,u,v planes). +//for each plane. + //The number of the frame compared to the //number of time expirations at the time of //caching, will enable us to make up for lost frames. - +//default 4+4+2+2+2=14!bad! +//me add pad, make god of 2 happy! typedef struct _FrameHeader{ - - unsigned int frameno;//number of frame(cached frames) - unsigned int current_total;//number of frames that should have been + u_int32_t frameno,//number of frame(cached frames) + current_total;//number of frames that should have been //taken at time of caching this one - unsigned short Ynum;//number of changed blocks in the Y plane - unsigned short Unum;//number of changed blocks in the U plane - unsigned short Vnum;//number of changed blocks in the V plane - unsigned char *YBlocks;//identifying number on the grid, starting at top left - unsigned char *UBlocks;// >> >> - unsigned char *VBlocks;// >> >> - unsigned char *YData;//data for the blocks that have changed, - unsigned char *UData;//which have to be remapped on the buffer when reading - unsigned char *VData; + u_int16_t Ynum,//number of changed blocks in the Y plane + Unum,//number of changed blocks in the U plane + Vnum;//number of changed blocks in the V plane + u_int16_t pad;//always zero }FrameHeader; +//The frame after retrieval. +//Based on the Header information +//we can read the correct amount of bytes. + +typedef struct _CachedFrame{ + FrameHeader *header; + unsigned char *YBlocks;//identifying number on the grid, starting at top left + unsigned char *UBlocks;// >> >> + unsigned char *VBlocks;// >> >> + unsigned char *YData;//pointer to data for the blocks that have changed, + unsigned char *UData;//which have to be remapped on the buffer when reading + unsigned char *VData; +}CachedFrame; /**Globals*/ diff --git a/rMD-exp/src/cache_frame.c b/rMD-exp/src/cache_frame.c index 894de3b..6b214e0 100644 --- a/rMD-exp/src/cache_frame.c +++ b/rMD-exp/src/cache_frame.c @@ -25,7 +25,7 @@ **********************************************************************************/ #include - +#include void MakeChecksums(unsigned char *buf,int width,int height,int divisor,unsigned short int *checksums){ int i,k,j,m; @@ -45,17 +45,29 @@ void MakeChecksums(unsigned char *buf,int width,int height,int divisor,unsigned } } +void FlushBlock(unsigned char *buf,int blockno,int width, int height,int divisor,gzFile *fp){ + int j, + block_i=blockno/divisor,//place on the grid + block_k=blockno%divisor; + + for(j=0;j(pow(divisor,2)+pow(divisor/2,2)*2)/10) + gzsetparams (fp,1,Z_FILTERED); + else + gzsetparams (fp,0,Z_FILTERED); + fheader.frameno=++frameno; + fheader.current_total=frames_total; + fheader.Ynum=ynum; + fheader.Unum=unum; + fheader.Vnum=vnum; + fheader.pad=0; + gzwrite(fp,(void*)&fheader,16); + //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; -// fprintf(stderr,"k %d uk %d vk %d\n ",k,uk,vk); + + + } } @@ -141,6 +188,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); + gzclose(fp); pthread_exit(&errno); } -- cgit v1.2.3