From e18b74de02297d6cd6381abec20eed3731e3faf8 Mon Sep 17 00:00:00 2001 From: iovar Date: Sun, 8 Jul 2007 15:25:55 +0000 Subject: cache_frame.c: removed changed blocks calculation as this information is now extracted at rgb2yuv conversion for full shots and from damage events in xdamage mode. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@367 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- recordmydesktop/src/cache_frame.c | 157 ++++++++++++-------------------------- 1 file changed, 47 insertions(+), 110 deletions(-) (limited to 'recordmydesktop') diff --git a/recordmydesktop/src/cache_frame.c b/recordmydesktop/src/cache_frame.c index 6eb169a..08f503f 100644 --- a/recordmydesktop/src/cache_frame.c +++ b/recordmydesktop/src/cache_frame.c @@ -27,34 +27,6 @@ #include -int CompareBlocks(unsigned char *incoming, - unsigned char *old, - int blockno, - int width, - int height, - int blockwidth){ - int j,i, - block_i=blockno/(width/blockwidth),//place on the grid - block_k=blockno%(width/blockwidth); - register cmp_int_t *incoming_reg=(cmp_int_t *)&(incoming[(block_i* - width+ - block_k)*blockwidth]), - *old_reg=(cmp_int_t *)&(old[(block_i* - width+ - block_k)*blockwidth]); - //blocks are square - for(j=0;jenc_data->yuv.y_width/Y_UNIT_WIDTH, blocknum_y=pdata->enc_data->yuv.y_height/Y_UNIT_WIDTH, firstrun=1, frameno=0, nbytes=0, nth_cache=1; - u_int32_t ynum,unum,vnum; - u_int32_t yblocks[blocknum_x*blocknum_y], - ublocks[blocknum_x*blocknum_y], - vblocks[blocknum_x*blocknum_y]; + u_int32_t ynum,unum,vnum, + y_short_blocks[blocknum_x*blocknum_y], + u_short_blocks[blocknum_x*blocknum_y], + v_short_blocks[blocknum_x*blocknum_y]; + if(!pdata->args.zerocompression){ fp=pdata->cache_data->ifp; if(fp==NULL)exit(13); @@ -122,20 +93,7 @@ void *CacheImageBuffer(ProgData *pdata){ } - for(i=0;i<2;i++){ - yuv[i].y_width=pdata->enc_data->yuv.y_width; - yuv[i].y_height=pdata->enc_data->yuv.y_height; - yuv[i].uv_width=pdata->enc_data->yuv.uv_width; - yuv[i].uv_height=pdata->enc_data->yuv.uv_height; - - yuv[i].y=(unsigned char *)malloc(yuv[i].y_width*yuv[i].y_height); - yuv[i].u=(unsigned char *)malloc(yuv[i].uv_width*yuv[i].uv_height); - yuv[i].v=(unsigned char *)malloc(yuv[i].uv_width*yuv[i].uv_height); - } - - while(pdata->running){ - int prev; int j; FrameHeader fheader; ynum=unum=vnum=0; @@ -155,64 +113,39 @@ void *CacheImageBuffer(ProgData *pdata){ pthread_mutex_lock(&pdata->yuv_mutex); - //rotate buffers - prev=current; - current=(current)?0:1; - //copy incoming - memcpy(yuv[current].y,pdata->enc_data->yuv.y, - yuv[current].y_width*yuv[current].y_height); - memcpy(yuv[current].u,pdata->enc_data->yuv.u, - yuv[current].uv_width*yuv[current].uv_height); - memcpy(yuv[current].v,pdata->enc_data->yuv.v, - yuv[current].uv_width*yuv[current].uv_height); - //release main buffer - pthread_mutex_unlock(&pdata->yuv_mutex); - //get checksums for new - //find and flush different blocks if(firstrun){ firstrun=0; for(j=0;jargs.zerocompression){ if(ynum*4+unum+vnum>(blocknum_x*blocknum_y*6)/10) @@ -231,27 +164,33 @@ void *CacheImageBuffer(ProgData *pdata){ if(!pdata->args.zerocompression){ nbytes+=gzwrite(fp,(void*)&fheader,sizeof(FrameHeader)); //flush indexes - if(ynum)nbytes+=gzwrite(fp,(void*)yblocks,ynum*index_entry_size); - if(unum)nbytes+=gzwrite(fp,(void*)ublocks,unum*index_entry_size); - if(vnum)nbytes+=gzwrite(fp,(void*)vblocks,vnum*index_entry_size); + if(ynum)nbytes+=gzwrite(fp, + (void*)y_short_blocks, + ynum*index_entry_size); + if(unum)nbytes+=gzwrite(fp, + (void*)u_short_blocks, + unum*index_entry_size); + if(vnum)nbytes+=gzwrite(fp, + (void*)v_short_blocks, + vnum*index_entry_size); } else{ nbytes+=sizeof(FrameHeader)* fwrite((void*)&fheader,sizeof(FrameHeader),1,ucfp); //flush indexes if(ynum)nbytes+=index_entry_size* - fwrite(yblocks,index_entry_size,ynum,ucfp); + fwrite(y_short_blocks,index_entry_size,ynum,ucfp); if(unum)nbytes+=index_entry_size* - fwrite(ublocks,index_entry_size,unum,ucfp); + fwrite(u_short_blocks,index_entry_size,unum,ucfp); if(vnum)nbytes+=index_entry_size* - fwrite(vblocks,index_entry_size,vnum,ucfp); + fwrite(v_short_blocks,index_entry_size,vnum,ucfp); } //flush the blocks for each buffer if(ynum){ for(j=0;jenc_data->yuv.y,y_short_blocks[j], + pdata->enc_data->yuv.y_width, + pdata->enc_data->yuv.y_height, Y_UNIT_WIDTH, fp, ucfp, @@ -259,9 +198,9 @@ void *CacheImageBuffer(ProgData *pdata){ } if(unum){ for(j=0;jenc_data->yuv.u,u_short_blocks[j], + pdata->enc_data->yuv.uv_width, + pdata->enc_data->yuv.uv_height, UV_UNIT_WIDTH, fp, ucfp, @@ -269,14 +208,17 @@ void *CacheImageBuffer(ProgData *pdata){ } if(vnum){ for(j=0;jenc_data->yuv.v,v_short_blocks[j], + pdata->enc_data->yuv.uv_width, + pdata->enc_data->yuv.uv_height, UV_UNIT_WIDTH, fp, ucfp, 0); } + //release main buffer + pthread_mutex_unlock(&pdata->yuv_mutex); + nbytes+=FlushBlock(NULL,0,0,0,0,fp,ucfp,1); /**@________________@**/ pdata->avd+=pdata->frametime; @@ -303,14 +245,9 @@ void *CacheImageBuffer(ProgData *pdata){ nbytes=0; } } - //clean up since we're not finished - for(i=0;i<2;i++){ - free(yuv[i].y); - free(yuv[i].u); - free(yuv[i].v); - } + fprintf(stderr,"Saved %d frames in a total of %d requests\n", - frameno,frames_total); + frameno,frames_total);fflush(stderr); if(!pdata->args.zerocompression){ gzflush(fp,Z_FINISH); gzclose(fp); -- cgit v1.2.3