summaryrefslogtreecommitdiff
path: root/recordmydesktop
diff options
context:
space:
mode:
Diffstat (limited to 'recordmydesktop')
-rw-r--r--recordmydesktop/src/bgr_to_yuv.c33
-rw-r--r--recordmydesktop/src/get_frame.c25
-rw-r--r--recordmydesktop/src/recordmydesktop.c37
-rw-r--r--recordmydesktop/src/setbrwindow.c51
-rw-r--r--recordmydesktop/src/update_image.c4
5 files changed, 104 insertions, 46 deletions
diff --git a/recordmydesktop/src/bgr_to_yuv.c b/recordmydesktop/src/bgr_to_yuv.c
index 2266e94..c3730ad 100644
--- a/recordmydesktop/src/bgr_to_yuv.c
+++ b/recordmydesktop/src/bgr_to_yuv.c
@@ -27,39 +27,6 @@
#include <recordmydesktop.h>
-// void XImageToYUV(XImage *imgz,yuv_buffer *yuv,int no_quick_subsample){
-// unsigned char *dtap=(unsigned char *)imgz->data;
-// unsigned char avg2,avg1,avg0;
-// int i,k,j=0;
-//
-// for(k=0;k<(imgz->width*imgz->height);k++){
-// yuv->y[k]=Yr[dtap[(k*4)+2]] + Yg[dtap[(k*4)+1]] + Yb[dtap[(k*4)]];
-// }
-// if(!no_quick_subsample){
-// for(i=0;i<(imgz->height);i+=2){
-// for(k=0;k<(imgz->width);k+=2){
-// yuv->u[j]=Ur[dtap[i*imgz->bytes_per_line+k*4+2]] + Ug[dtap[i*imgz->bytes_per_line+k*4+1]] + Ub[dtap[i*imgz->bytes_per_line+k*4]];
-// yuv->v[j]=Vr[dtap[i*imgz->bytes_per_line+k*4+2]] + Vg[dtap[i*imgz->bytes_per_line+k*4+1]] + Vb[dtap[i*imgz->bytes_per_line+k*4]] ;
-// j++;
-// }
-// }
-// }
-// else{
-// for(i=0;i<(imgz->height);i+=2){
-// for(k=0;k<(imgz->width);k+=2){
-// avg2=AVG_4_PIXELS(dtap,(imgz->width),i,k,2);
-// avg1=AVG_4_PIXELS(dtap,(imgz->width),i,k,1);
-// avg0=AVG_4_PIXELS(dtap,(imgz->width),i,k,0);
-//
-// yuv->u[j]=Ur[avg2] + Ug[avg1] + Ub[avg0];
-// yuv->v[j]=Vr[avg2] + Vg[avg1] + Vb[avg0] ;
-// j++;
-// }
-// }
-// }
-// }
-
-
void MakeMatrices(){
int i;
for(i=0;i<256;i++)
diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c
index 6a93ceb..d5673e6 100644
--- a/recordmydesktop/src/get_frame.c
+++ b/recordmydesktop/src/get_frame.c
@@ -111,14 +111,31 @@ void *GetFrame(void *pdata){
((ProgData *)pdata)->brwin.rgeom.width,
((ProgData *)pdata)->brwin.rgeom.height);
pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex);
- XImageToYUV(((ProgData *)pdata)->image,&((ProgData *)pdata)->enc_data->yuv,
- ((ProgData *)pdata)->args.no_quick_subsample);
+ if(((ProgData *)pdata)->args.no_quick_subsample){
+ UPDATE_YUV_BUFFER_IM_AVG((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->image->data),
+ (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset),
+ (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height));
+ }
+ else{
+ UPDATE_YUV_BUFFER_IM((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->image->data),
+ (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset),
+ (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height));
+ }
pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex);
}
else{
pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex);
- XImageToYUV(((ProgData *)pdata)->shimage,&((ProgData *)pdata)->enc_data->yuv,
- ((ProgData *)pdata)->args.no_quick_subsample);
+ if(((ProgData *)pdata)->args.no_quick_subsample){
+ UPDATE_YUV_BUFFER_IM_AVG((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->shimage->data),
+ (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset),
+ (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height));
+ }
+ else{
+ UPDATE_YUV_BUFFER_IM((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->shimage->data),
+ (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset),
+ (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height));
+ }
+
pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex);
}
}
diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c
index 9f6d596..a873f70 100644
--- a/recordmydesktop/src/recordmydesktop.c
+++ b/recordmydesktop/src/recordmydesktop.c
@@ -54,6 +54,7 @@ int main(int argc,char **argv){
sound_encode_t,
flush_to_ogg_t;
XShmSegmentInfo shminfo;
+ int i;
QUERY_DISPLAY_SPECS(pdata.dpy,&pdata.specs);
if(pdata.specs.depth!=24){
@@ -117,8 +118,7 @@ int main(int argc,char **argv){
fprintf(stderr,"Failed to attach shared memory to proccess.\n");
exit(1);
}
- XShmGetImage(pdata.dpy,pdata.specs.root,pdata.shimage,0,0,AllPlanes);
-
+ XShmGetImage(pdata.dpy,pdata.specs.root,pdata.shimage,pdata.brwin.rgeom.x,pdata.brwin.rgeom.y,AllPlanes);
}
if(pdata.args.scshot){
if(pdata.args.delay>0){
@@ -139,10 +139,35 @@ int main(int argc,char **argv){
pdata.args.nosound=1;
}
InitEncoder(&pdata,&enc_data);
- if((pdata.args.nocondshared)&&(!pdata.args.noshared))
- XImageToYUV(pdata.shimage,&pdata.enc_data->yuv,pdata.args.no_quick_subsample);
- else
- XImageToYUV(pdata.shimage,&pdata.enc_data->yuv,pdata.args.no_quick_subsample);
+ for(i=0;i<(pdata.enc_data->yuv.y_width*pdata.enc_data->yuv.y_height);i++)
+ pdata.enc_data->yuv.y[i]=0;
+ for(i=0;i<(pdata.enc_data->yuv.uv_width*pdata.enc_data->yuv.uv_height);i++){
+ pdata.enc_data->yuv.v[i]=pdata.enc_data->yuv.u[i]=127;
+ }
+ if((pdata.args.nocondshared)&&(!pdata.args.noshared)){
+ if(pdata.args.no_quick_subsample){
+ UPDATE_YUV_BUFFER_IM_AVG((&pdata.enc_data->yuv),((unsigned char*)pdata.shimage->data),
+ (pdata.enc_data->x_offset),(pdata.enc_data->y_offset),
+ (pdata.brwin.rgeom.width),(pdata.brwin.rgeom.height));
+ }
+ else{
+ UPDATE_YUV_BUFFER_IM((&pdata.enc_data->yuv),((unsigned char*)pdata.shimage->data),
+ (pdata.enc_data->x_offset),(pdata.enc_data->y_offset),
+ (pdata.brwin.rgeom.width),(pdata.brwin.rgeom.height));
+ }
+ }
+ else{
+ if(pdata.args.no_quick_subsample){
+ UPDATE_YUV_BUFFER_IM_AVG((&pdata.enc_data->yuv),((unsigned char*)pdata.image->data),
+ (pdata.enc_data->x_offset),(pdata.enc_data->y_offset),
+ (pdata.brwin.rgeom.width),(pdata.brwin.rgeom.height));
+ }
+ else{
+ UPDATE_YUV_BUFFER_IM((&pdata.enc_data->yuv),((unsigned char*)pdata.image->data),
+ (pdata.enc_data->x_offset),(pdata.enc_data->y_offset),
+ (pdata.brwin.rgeom.width),(pdata.brwin.rgeom.height));
+ }
+ }
pdata.frametime=(1000000)/pdata.args.fps;
diff --git a/recordmydesktop/src/setbrwindow.c b/recordmydesktop/src/setbrwindow.c
index e5035d5..dafcc89 100644
--- a/recordmydesktop/src/setbrwindow.c
+++ b/recordmydesktop/src/setbrwindow.c
@@ -29,6 +29,7 @@
int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args){
//before we start recording we have to make sure the ranges are valid
+ int octoffset=0;
if(args->windowid==0){//root window
//first set it up
brwin->windowid=specs->root;
@@ -79,6 +80,9 @@ int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args)
return 1;
}
}
+ fprintf(stderr, "Initial recording window is set to:\n"
+ "X:%d Y:%d Width:%d Height:%d\n"
+ ,brwin->rgeom.x,brwin->rgeom.y,brwin->rgeom.width,brwin->rgeom.height);
//align in two
//an odd x can always go down and still be in recording area.
//Resolutions come in even numbers
@@ -93,7 +97,52 @@ int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args)
brwin->rgeom.x-=brwin->rgeom.x%2;
brwin->rgeom.y-=brwin->rgeom.y%2;
- brwin->nbytes=(((brwin->rgeom.width+15)>>4)<<4)*(((brwin->rgeom.height+15)>>4)<<4)*4;
+ //32 bit pack align
+ //we already have disible by two width,so
+ //it's 2, 4 or 6
+ octoffset=(brwin->rgeom.width%8);
+ if(octoffset==2){
+ brwin->rgeom.width-=2;
+
+ }
+ else if(octoffset==6){
+ if(brwin->rgeom.width+brwin->rgeom.x+2<=specs->width)
+ brwin->rgeom.width+=2;
+ else if(brwin->rgeom.x>=2){
+ brwin->rgeom.x-=2;
+ brwin->rgeom.width+=2;
+ }
+ else{
+ brwin->rgeom.x+=2;
+ brwin->rgeom.width-=4;
+ }
+ }
+
+ else if(octoffset==4){
+ if((brwin->rgeom.width+brwin->rgeom.x+2<=specs->width)&&(brwin->rgeom.x>=2)){
+ brwin->rgeom.x-=2;
+ brwin->rgeom.width+=4;
+ }
+ else if(brwin->rgeom.width+brwin->rgeom.x+4<=specs->width){
+ brwin->rgeom.width+=4;
+ }
+ else if(brwin->rgeom.x>=4){
+ brwin->rgeom.x-=4;
+ brwin->rgeom.width+=4;
+ }
+ else{
+ brwin->rgeom.x+=2;
+ brwin->rgeom.width-=4;
+ }
+ }
+ fprintf(stderr, "Adjusted recording window is set to:\n"
+ "X:%d Y:%d Width:%d Height:%d\n"
+ ,brwin->rgeom.x,brwin->rgeom.y,brwin->rgeom.width,brwin->rgeom.height);
+
+
+ brwin->nbytes=(((brwin->rgeom.width+15)>>4)<<4)*(((brwin->rgeom.height+15)>>4)<<4)*4;
+
+
return 0;
}
diff --git a/recordmydesktop/src/update_image.c b/recordmydesktop/src/update_image.c
index 0de3f0a..fed9445 100644
--- a/recordmydesktop/src/update_image.c
+++ b/recordmydesktop/src/update_image.c
@@ -68,12 +68,12 @@ void UpdateImage(Display * dpy,
}
else{
if(no_quick_subsample){
- UPDATE_YUV_BUFFER_SH_AVG(yuv,dtap,
+ UPDATE_YUV_BUFFER_SH_AVG(yuv,dtap,
(temp->geom.x-brwin->rgeom.x+enc->x_offset),(temp->geom.y-brwin->rgeom.y+enc->y_offset),
(temp->geom.width),(temp->geom.height));
}
else{
- UPDATE_YUV_BUFFER_SH(yuv,dtap,
+ UPDATE_YUV_BUFFER_SH(yuv,dtap,
(temp->geom.x-brwin->rgeom.x+enc->x_offset),(temp->geom.y-brwin->rgeom.y+enc->y_offset),
(temp->geom.width),(temp->geom.height));
}
© All Rights Reserved