diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-06-19 12:24:31 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-06-20 15:59:59 -0700 |
commit | 1c4174855664744595541347afecfea1fb919b52 (patch) | |
tree | 07f52cff8bec78526e28be5bcccbb6610884f143 /recordmydesktop/src | |
parent | b8bc8eaf02d19b5739df3797100b4b5d12d8fbbc (diff) |
setbrwindow: yank nbytes out of BRWindow struct
This only gets used in one place and isn't even relevant for
shmem scenarios where the size in bytes depends on the bytes per
row from the server.
For now I'm just moving its simple computation to where it's
used, as-is.
It seems to be doing some 16-byte alignment dance as well
which... seems very odd. If the sizes were already getting
16-byte aligned, why do this again? I fully expect to throw the
alignment shit out at some point, as this all gets reworked. The
way this was done seems completely misguided... the Theora
alignment considerations should be handled in the YUV buffer,
since the copy needs to be made from the XImage in all cases -
shmem and non, to convert to YUV, the YUV buffer should have been
sized to accomodate Theora, and the RGB->YUV conversion-copy
should pad out the aligned target buffer as needed.
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r-- | recordmydesktop/src/rmd_get_frame.c | 39 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_setbrwindow.c | 4 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_types.h | 1 |
3 files changed, 25 insertions, 19 deletions
diff --git a/recordmydesktop/src/rmd_get_frame.c b/recordmydesktop/src/rmd_get_frame.c index b05177c..229cb61 100644 --- a/recordmydesktop/src/rmd_get_frame.c +++ b/recordmydesktop/src/rmd_get_frame.c @@ -197,11 +197,23 @@ //besides taking the first screenshot, this functions primary purpose is to //initialize the structures and memory. static int rmdFirstFrame(ProgData *pdata, XImage **image, XShmSegmentInfo *shminfo) { + const BRWindow *brwin = &pdata->brwin; if ((pdata->args.noshared)) { - char *pxl_data; + char *pxl_data; + size_t nbytes; - pxl_data=(char *)malloc(pdata->brwin.nbytes); + /* XXX: this was blindly relocated from rmdSetBRWindow(), + * I'm unclear on why there's this alignment crap happening, + * but just wanted to to move nbytes out to the one place it's + * used. + */ + nbytes = (((brwin->rrect.width + 15) >> 4) << 4) * + (((brwin->rrect.height + 15) >> 4) << 4) * + ((pdata->specs.depth == 16) ? 2 : 4); + + + pxl_data=(char *)malloc(nbytes); (*image)=XCreateImage( pdata->dpy, pdata->specs.visual, @@ -209,17 +221,17 @@ static int rmdFirstFrame(ProgData *pdata, XImage **image, XShmSegmentInfo *shmin ZPixmap, 0, pxl_data, - pdata->brwin.rrect.width, - pdata->brwin.rrect.height, + brwin->rrect.width, + brwin->rrect.height, 8, 0); XInitImage((*image)); rmdGetZPixmap( pdata->dpy,pdata->specs.root, (*image)->data, - pdata->brwin.rrect.x, - pdata->brwin.rrect.y, - pdata->brwin.rrect.width, - pdata->brwin.rrect.height); + brwin->rrect.x, + brwin->rrect.y, + brwin->rrect.width, + brwin->rrect.height); } else { (*image)=XShmCreateImage( pdata->dpy, pdata->specs.visual, @@ -227,8 +239,8 @@ static int rmdFirstFrame(ProgData *pdata, XImage **image, XShmSegmentInfo *shmin ZPixmap, NULL, shminfo, - pdata->brwin.rrect.width, - pdata->brwin.rrect.height); + brwin->rrect.width, + brwin->rrect.height); (*shminfo).shmid=shmget(IPC_PRIVATE, (*image)->bytes_per_line* @@ -251,15 +263,15 @@ static int rmdFirstFrame(ProgData *pdata, XImage **image, XShmSegmentInfo *shmin XShmGetImage(pdata->dpy, pdata->specs.root, (*image), - pdata->brwin.rrect.x, - pdata->brwin.rrect.y, + brwin->rrect.x, + brwin->rrect.y, AllPlanes); } UPDATE_YUV_BUFFER((&pdata->enc_data->yuv), ((unsigned char*)((*image))->data),NULL, (pdata->enc_data->x_offset),(pdata->enc_data->y_offset), - (pdata->brwin.rrect.width),(pdata->brwin.rrect.height), + (brwin->rrect.width),(brwin->rrect.height), (pdata->args.no_quick_subsample), pdata->specs.depth); @@ -270,7 +282,6 @@ static int rmdFirstFrame(ProgData *pdata, XImage **image, XShmSegmentInfo *shmin static void rmdBRWinCpy(BRWindow *target, BRWindow *source) { target->winrect = source->winrect; target->rrect = source->rrect; - target->nbytes = source->nbytes; target->windowid = source->windowid; } diff --git a/recordmydesktop/src/rmd_setbrwindow.c b/recordmydesktop/src/rmd_setbrwindow.c index 7b5b862..837d597 100644 --- a/recordmydesktop/src/rmd_setbrwindow.c +++ b/recordmydesktop/src/rmd_setbrwindow.c @@ -189,9 +189,5 @@ boolean rmdSetBRWindow( Display *dpy, brwin->rrect.x,brwin->rrect.y, brwin->rrect.width,brwin->rrect.height); - brwin->nbytes= (((brwin->rrect.width+15)>>4)<<4)* - (((brwin->rrect.height+15)>>4)<<4)* - ((specs->depth==16)?2:4); - return TRUE; } diff --git a/recordmydesktop/src/rmd_types.h b/recordmydesktop/src/rmd_types.h index 7cdb0cb..218d832 100644 --- a/recordmydesktop/src/rmd_types.h +++ b/recordmydesktop/src/rmd_types.h @@ -105,7 +105,6 @@ typedef struct _RectArea{ //an area that has been damaged gets stored typedef struct _BRWindow{ //'basic recorded window' specs XRectangle winrect; //window attributes XRectangle rrect; //part of window that is recorded (rounded to alignment) - int nbytes; //size of zpixmap when screenshoting Window windowid; //id }BRWindow; |