View Single Post
Old 01-04-2014, 02:44 PM   #3
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773670
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
And here is the relevant code that takes the pre-dithered content piped in from raw2gmv or from a pre-dithered video (gmv) file, and converts it to whatever the framebuffer requirements dictate for the kindle models and boot modes supported (all of them, as of the PW).
PHP Code:
//----- gmlib global vars ----- 
enum GMLIB_op {GMLIB_INIT,GMLIB_CLOSE,GMLIB_UPDATE,GMLIB_VSYNC}; 
u8 *fb0=NULL;     // framebuffer pointer 
int fdFB=0;      // fb0 file descriptor 
int teu=0;      // eink update time 
u32 fs=0;      // fb0 stride 
u32 MX=0;     // xres (visible) 
u32 MY=0;    // yres (visible) 
u32 VY=0;   // (VY>MY): mxcfb driver 
u8 ppb=0;  // pixels per byte 
u32 fc=0// frame counter 
#define FBSIZE (600/8*800) 
//================================== 
// gmplay4 - play video on 4-bit fb0 
//---------------------------------- 
void gmplay4(void) { 
    
u32 i,x,y,b,p,off=(MY/2-400)*fs+MX/4-150,fbsize=FBSIZEu8 fbt[FBSIZE]; 
    while (
fread(fbt,fbsize,1,stdin)) { teu+=130// teu: next update time 
        
if (getmsec()>teu+1000) continue; // drop frame if > 1 sec behind 
        
gmlib(GMLIB_VSYNC); // wait for fb0 ready 
        
for (y=0;y<800;y++) for (x=0;x<600;x+=8) { 
            
b=fbt[600/8*y+x/8]; i=y*fs+x/2+off
            
p=(b&1)*240b>>=1fb0[i]=p|(b&1)*15b>>=1
            
p=(b&1)*240b>>=1fb0[i+1]=p|(b&1)*15b>>=1
            
p=(b&1)*240b>>=1fb0[i+2]=p|(b&1)*15b>>=1
            
p=(b&1)*240b>>=1fb0[i+3]=p|(b&1)*15
        } 
fc++; gmlib(GMLIB_UPDATE); 
    } 

//================================== 
// gmplay8 - play video on 8-bit fb0 
//---------------------------------- 
void gmplay8(void) { 
    
u32 i,x,y,b,fbsize=FBSIZEu8 fbt[FBSIZE]; 
    while (
fread(fbt,fbsize,1,stdin)) { teu+=130// teu: next update time 
        
if (getmsec()>teu+1000) continue; // drop frame if > 1 sec behind 
        
gmlib(GMLIB_VSYNC); // wait for fb0 ready 
        
for (y=0;y<800;y++) for (x=0;x<600;x+=8) { 
            
b=fbt[600/8*y+x/8]; i=y*fs+x
            
fb0[i]=(b&1)*255b>>=1fb0[i+1]=(b&1)*255b>>=1
            
fb0[i+2]=(b&1)*255b>>=1fb0[i+3]=(b&1)*255b>>=1
            
fb0[i+4]=(b&1)*255b>>=1fb0[i+5]=(b&1)*255b>>=1
            
fb0[i+6]=(b&1)*255b>>=1fb0[i+7]=(b&1)*255
        } 
fc++; gmlib(GMLIB_UPDATE); 
    } 

I will add more details about how it works here, but again, there are already some details in the relevant posts:
https://www.mobileread.com/forums/sho...d.php?t=177455

Last edited by geekmaster; 01-04-2014 at 03:07 PM.
geekmaster is offline   Reply With Quote