# HG changeset patch # User diego # Date 1175350651 0 # Node ID 9ca2cd57161886ba847c5b5b491184772a3c7571 # Parent 4d49e4ae19bb66bdd0031341464fa3848a4b9290 Remove unused/nonworking wallpaper setting utility. diff -r 4d49e4ae19bb -r 9ca2cd571618 TOOLS/mwallp/README --- a/TOOLS/mwallp/README Sat Mar 31 14:15:20 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -mwallp - mplayer's wallpaper setting utility -====== - -Usage: mwallp file1.jpg [file2.jpg file3.jpg ...] -~~~~~~ - -About: -~~~~~~ -MWallp is a simple tool to set .jpg images as background/wallpaper on the -desktop. It scales (bicubic) and convert the given jpg image to desktop -size/bpp and set as background of Root window. - -If more than 1 filenames given, it randomly selects one, so running something -like 'mwallp ~/.wallpapers/*.jpg' from cron will randomly changes wallpaper. - -Why? -~~~~ -I've tried several programs, and as most of them used Imlib, their quality -sucks (Imlib uses neares-neighbour scaling...). -So I've decided to put together something very simple but efficient built -using the MPlayer codebase. - -A'rpi diff -r 4d49e4ae19bb -r 9ca2cd571618 TOOLS/mwallp/compile.sh --- a/TOOLS/mwallp/compile.sh Sat Mar 31 14:15:20 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -echo -gcc -g mwallp.c jpeg.c ../../libvo/aclib.o ../../libmpcodecs/img_format.o \ - ../../cpudetect.o ../../mp_msg-mencoder.o ../../libavcodec/libavcodec.a \ - ../../libswscale/libswscale.a ../../osdep/libosdep.a \ - -I../../libmpcodecs -I../.. -I../../libswscale \ - -L/usr/X11/lib -L/usr/X11R6/lib -lX11 -lm -ljpeg -o mwallp diff -r 4d49e4ae19bb -r 9ca2cd571618 TOOLS/mwallp/jpeg.c --- a/TOOLS/mwallp/jpeg.c Sat Mar 31 14:15:20 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,147 +0,0 @@ -// based on vd_ijpg.c by Pontscho - -#include -#include - -#include -#define UINT16 IJPG_UINT16 -#define INT16 IJPG_INT16 - -#include - -#include - -#include "img_format.h" - -#include "swscale.h" -#include "rgb2rgb.h" - -static struct SwsContext *swsContext=NULL; - -typedef struct -{ - struct jpeg_source_mgr pub; - unsigned char * inbuf; - int bufsize; -} my_source_mgr; - -typedef my_source_mgr * my_src_ptr; - -METHODDEF(void) init_source (j_decompress_ptr cinfo) -{ -} - -METHODDEF(boolean) fill_input_buffer (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - size_t nbytes; - src->pub.next_input_byte = src->inbuf; - src->pub.bytes_in_buffer = src->bufsize; - return TRUE; -} - -METHODDEF(void) skip_input_data (j_decompress_ptr cinfo, long num_bytes) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - if (num_bytes > 0) - { - while (num_bytes > (long) src->pub.bytes_in_buffer) - { - num_bytes -= (long) src->pub.bytes_in_buffer; - (void) fill_input_buffer(cinfo); - } - src->pub.next_input_byte += (size_t) num_bytes; - src->pub.bytes_in_buffer -= (size_t) num_bytes; - } -} - -METHODDEF(void) term_source (j_decompress_ptr cinfo) { } - -GLOBAL(void) jpeg_buf_src ( j_decompress_ptr cinfo, char * inbuf,int bufsize ) -{ - my_src_ptr src; - if (cinfo->src == NULL) cinfo->src=malloc( sizeof( my_source_mgr ) ); - src = (my_src_ptr) cinfo->src; - src->pub.init_source = init_source; - src->pub.fill_input_buffer = fill_input_buffer; - src->pub.skip_input_data = skip_input_data; - src->pub.resync_to_restart = jpeg_resync_to_restart; - src->pub.term_source = term_source; - src->inbuf = inbuf; - src->bufsize=bufsize; - src->pub.bytes_in_buffer = 0; - src->pub.next_input_byte = NULL; -} - -struct my_error_mgr -{ - struct jpeg_error_mgr pub; - jmp_buf setjmp_buffer; -}; - -typedef struct my_error_mgr * my_error_ptr; - -METHODDEF(void) my_error_exit (j_common_ptr cinfo) -{ - my_error_ptr myerr=(my_error_ptr) cinfo->err; - (*cinfo->err->output_message) (cinfo); - longjmp(myerr->setjmp_buffer, 1); -} - -static struct jpeg_decompress_struct cinfo; -static struct my_error_mgr jerr; - -// decode a frame -int decode_jpeg(void* data,int len,char* dbuffer,int dwidth,int dheight, int dstride,int dbpp){ - int width,height,depth,i; - int row_stride; - unsigned char* img=NULL; - int in_fmt=0; - - if ( len <= 0 ) return 0; // skipped frame - - cinfo.err=jpeg_std_error( &jerr.pub ); - jerr.pub.error_exit=my_error_exit; - if( setjmp( jerr.setjmp_buffer ) ) - { - return 0; - } - - jpeg_create_decompress( &cinfo ); - jpeg_buf_src( &cinfo,data,len ); - jpeg_read_header( &cinfo,TRUE ); - width=cinfo.image_width; - height=cinfo.image_height; - jpeg_start_decompress( &cinfo ); - depth=cinfo.output_components * 8; - - switch( depth ) { - case 8: in_fmt=IMGFMT_Y8;break; - case 24: in_fmt=IMGFMT_RGB|24;break; - default: return 0; - } - - row_stride=cinfo.output_width * cinfo.output_components; - img=malloc(row_stride * (height+1)); - - for ( i=0;i < height;i++ ){ -// char* row=dbuffer+i*dstride; - char* row=img+row_stride*i; - jpeg_read_scanlines( &cinfo,(JSAMPLE**)&row,1 ); - } - - jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - - swsContext= sws_getContext(width,height, in_fmt, - dwidth,dheight, IMGFMT_BGR|dbpp, SWS_BICUBIC, NULL, NULL, NULL); - - sws_scale(swsContext,&img,&row_stride,0,height,&dbuffer, &dstride); - - sws_freeContext(swsContext); - - free(img); - - return 1; -} diff -r 4d49e4ae19bb -r 9ca2cd571618 TOOLS/mwallp/mwallp.c --- a/TOOLS/mwallp/mwallp.c Sat Mar 31 14:15:20 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -// based on x11_common.c/vo_x11.c from libvo - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "cpudetect.h" - -char* mDisplayName=NULL; -Display* mDisplay=NULL; -Window mRootWin=None; -int mScreen=0; -XImage * mXImage = NULL; -GC vo_gc = NULL; -Pixmap mPixmap=0; - -int vo_depthonscreen=0; -int vo_screenwidth=0; -int vo_screenheight=0; - -int verbose=0; -int namecnt=0; - -int main(int argc,char* argv[]){ - unsigned int mask; - int bpp,depth; - - mp_msg_init(); - mp_msg_set_level(5); - - GetCpuCaps(&gCpuCaps); - - mDisplayName = XDisplayName(mDisplayName); - mDisplay=XOpenDisplay(mDisplayName); - if ( !mDisplay ) - { - printf("vo: couldn't open the X11 display (%s)!\n",mDisplayName ); - return 0; - } - mScreen=DefaultScreen( mDisplay ); // Screen ID. - mRootWin=RootWindow( mDisplay,mScreen );// Root window ID. - - vo_screenwidth=DisplayWidth( mDisplay,mScreen ); - vo_screenheight=DisplayHeight( mDisplay,mScreen ); - - // get color depth (from root window, or the best visual): - { XWindowAttributes attribs; - XGetWindowAttributes(mDisplay, mRootWin, &attribs); - depth=vo_depthonscreen=attribs.depth; - } - mXImage=XGetImage( mDisplay,mRootWin,0,0,vo_screenwidth,vo_screenheight,AllPlanes,ZPixmap ); - - bpp=mXImage->bits_per_pixel; - if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi - mask=mXImage->red_mask|mXImage->green_mask|mXImage->blue_mask; - - if(((vo_depthonscreen+7)/8)==2){ - if(mask==0x7FFF) vo_depthonscreen=15; else - if(mask==0xFFFF) vo_depthonscreen=16; - } - - printf("X11 running at %d x %d, %d bpp \n",vo_screenwidth,vo_screenheight,vo_depthonscreen); - - mPixmap=XCreatePixmap(mDisplay,mRootWin,vo_screenwidth,vo_screenheight,depth); - - { XGCValues xgcv; - vo_gc=XCreateGC( mDisplay,mRootWin,0L,&xgcv ); - } - - if(argc<2){ printf("no filenames!\n");return;} - - srand(time(NULL)); - -while(1){ - FILE *f; - char* data; - int len; - int ret; - - namecnt=1+(long long)rand()*(argc-1)/RAND_MAX; - //++namecnt; if(namecnt>=argc) namecnt=1; - if(namecnt<1 || namecnt>=argc) continue; // ??? - - f=fopen(argv[namecnt],"rb");if(!f) continue; - fseek(f,0,SEEK_END); len=ftell(f); fseek(f,0,SEEK_SET); - data=malloc(len); - len=fread(data,1,len,f); - fclose(f); - - ret=decode_jpeg(data,len,mXImage->data,vo_screenwidth,vo_screenheight, - ((vo_depthonscreen+7)/8)*vo_screenwidth,vo_depthonscreen); - - free(data); - - if(!ret) continue; // failed to load - - XPutImage( mDisplay,mPixmap,vo_gc,mXImage, - 0,0, 0,0, vo_screenwidth,vo_screenheight); - XSetWindowBackgroundPixmap(mDisplay,mRootWin,mPixmap); - XClearWindow(mDisplay,mRootWin); - XSync(mDisplay, True); - - break; // DONE! -} - -}