From 3294002ea7e394ae2038586db400e964d9cc7599 Mon Sep 17 00:00:00 2001 From: Nathan Hand Date: Fri, 8 Jan 2021 13:42:21 +1100 Subject: [PATCH 1/6] fixes build failure with gcc-10 --- omx_render.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omx_render.h b/omx_render.h index 421ad1d..f39cb98 100644 --- a/omx_render.h +++ b/omx_render.h @@ -64,7 +64,7 @@ typedef struct OMX_RENDER_DISP_CONF{ } OMX_RENDER_DISP_CONF; -struct OMX_RENDER_TRANSITION{ +typedef struct OMX_RENDER_TRANSITION{ enum transition_t{NONE, BLEND} type; int durationMs; From 076854a8749dcd8379b9f780dca9b426284802c5 Mon Sep 17 00:00:00 2001 From: HaarigerHarald Date: Thu, 25 Nov 2021 21:18:47 +0100 Subject: [PATCH 2/6] README: Specify non version specific dev packages --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a58a1f..99fb8e7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A GPU accelerated image viewer for the Raspberry Pi. ## Building You will need the development header for libjpeg and libpng -(Debian: libjpeg8-dev, libpng12-dev). Then build it on the Pi with: +(Debian: libjpeg-dev, libpng-dev). Then build it on the Pi with: make ilclient make From d4636a2b323ed13d7c0f72d6cf313476a63db30f Mon Sep 17 00:00:00 2001 From: HaarigerHarald Date: Thu, 25 Nov 2021 21:27:02 +0100 Subject: [PATCH 3/6] README: Add OpenMax deprecation notice --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 99fb8e7..aeb9e78 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # OMX image viewer -A GPU accelerated image viewer for the Raspberry Pi. +A GPU accelerated image viewer for the Raspberry Pi. + +Due to deprecation of the OpenMax API and the unavailability of those libraries on arm64, this project only supports 32bit operating systems. ## Building From 64ef267ce3097c9c695656f79e31c3040ab92926 Mon Sep 17 00:00:00 2001 From: cmitu <31816814+cmitu@users.noreply.github.com> Date: Wed, 11 Sep 2019 05:05:28 +0100 Subject: [PATCH 4/6] Added 2 new features and modify default slideshow behavior Slideshow behavior is changed so it exits at the end, even with one image, after the set timeout. Added 2 new features: * randomize the list of images (`-r`) * read a list of images from a text file (`-f`). They are inserted in slideshow before the ones added through the command line. --- README.md | 2 + omxiv.c | 129 ++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 103 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index aeb9e78..68c86a7 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ OPTIONS: -k --no-keys Disable keyboard input -s --soft Force software decoding --ignore-exif Ignore exif orientation + -f --file-list Read a list of images from a text file + -r --randomize Randomize the list of images KEY CONFIGURATION: diff --git a/omxiv.c b/omxiv.c index 3fe0fb3..a46a17f 100644 --- a/omxiv.c +++ b/omxiv.c @@ -44,6 +44,8 @@ static const struct option longOpts[] = { {"no-keys", no_argument, 0, 'k'}, {"soft", no_argument, 0, 's'}, {"ignore-exif", no_argument, 0, 0x103}, + {"input-filename", required_argument, 0, 'f'}, + {"randomize", no_argument, 0, 'r'}, {0, 0, 0, 0} }; @@ -102,29 +104,30 @@ static int imageFilter(const struct dirent *entry){ return 0; } -static int getImageFilesInDir(char ***list, const char* path){ +static int getImageFilesInDir(char ***list, const char* path, const int offset){ struct dirent **namelist; int imageNum; + printf("Scanning folder %s\n", path); imageNum = scandir(path, &namelist, imageFilter, alphasort); if (imageNum < 0) return imageNum; else { - *list=malloc(sizeof(char*) *imageNum); + *list=realloc(*list, sizeof(char*)*(imageNum+offset)); int i; for(i=0; id_name)+1); - strcpy((*list)[i], namelist[i]->d_name); + (*list)[offset+i]= malloc(strlen(namelist[i]->d_name)+1); + strcpy((*list)[offset+i], namelist[i]->d_name); }else{ if(strrchr(path, '/')- path != strlen(path)-1){ - (*list)[i]= malloc(strlen(path)+strlen(namelist[i]->d_name)+2); - strcpy((*list)[i],path); - (*list)[i][strlen(path)]='/'; - strcpy((*list)[i]+strlen(path)+1,namelist[i]->d_name); + (*list)[offset+i]= malloc(strlen(path)+strlen(namelist[i]->d_name)+2); + strcpy((*list)[offset+i],path); + (*list)[offset+i][strlen(path)]='/'; + strcpy((*list)[offset+i]+strlen(path)+1,namelist[i]->d_name); }else{ - (*list)[i]= malloc(strlen(path)+strlen(namelist[i]->d_name)+1); - strcpy((*list)[i],path); - strcpy((*list)[i]+strlen(path),namelist[i]->d_name); + (*list)[offset+i]= malloc(strlen(path)+strlen(namelist[i]->d_name)+1); + strcpy((*list)[offset+i],path); + strcpy((*list)[offset+i]+strlen(path),namelist[i]->d_name); } } free(namelist[i]); @@ -362,14 +365,66 @@ static int isBackgroundProc() { } static void printVersion(){ - printf("Version: %s\n", VERSION); + printf("Version: %s-custom\n", VERSION); printf("Build date: %s\n", __DATE__); } +static int readImageList(char ***files, const char *listfile) +{ + char filename[256]; + FILE *list; + char *cFile; + struct stat liststat; + int fileCount=0; + + list = fopen(listfile,"r"); + if (NULL == list) { + fprintf(stderr,"open %s: %s\n",listfile,strerror(errno)); + return -1; + } + + fstat(fileno(list), &liststat); + while (NULL != fgets(filename,sizeof(filename)-1,list)) { + size_t off = strcspn(filename,"\r\n"); + if (off) + filename[off] = 0; + else + continue; + + cFile=strdup(filename); + if (cFile==NULL) + continue; + + *files = realloc(*files, sizeof(char*)*fileCount + sizeof(char*)); + if (*files!=NULL) { + (*files)[fileCount++] = cFile; + } + } + + fclose(list); + return fileCount; +} + +// Implement the Fisher-Yates shuffle +static void randomizeImages(char ***list, const int imageNum) +{ + int count, _random; + char *swap; + srand((unsigned)time(NULL)); + + for (count = imageNum-1; count > 0; count--) { + _random = rand()%(count + 1); + swap = (*list)[count]; + (*list)[count] = (*list)[_random]; + (*list)[_random] = swap; + } +} + int main(int argc, char *argv[]){ int ret = 1; long timeout = 0; - + char *inputFileName = NULL; + int randomize = 0; render.transition.type = NONE; render.transition.durationMs = 400; @@ -377,7 +432,7 @@ int main(int argc, char *argv[]){ keys=0; int opt; - while((opt = getopt_long(argc, argv, "hvt:bT:a:o:ml:d:iks", + while((opt = getopt_long(argc, argv, "hvt:bT:a:o:ml:d:iksf:r", longOpts, NULL)) != -1){ switch(opt){ @@ -435,29 +490,37 @@ int main(int argc, char *argv[]){ info = 1; break; case 'k': keys = 0; break; + case 'f': + inputFileName=strdup(optarg); break; case 's': soft = 1; break; case 0x103: exifOrient = 0; break; + case 'r': + randomize = 1; break; default: return EXIT_FAILURE; } } - int imageNum; - char **files; + int imageNum=0; + char **files=NULL; + if (inputFileName!=NULL) { + imageNum=readImageList(&files, inputFileName); + } + if(argc-optind <= 0){ - imageNum=getImageFilesInDir(&files, "./"); + imageNum+=getImageFilesInDir(&files, "./", imageNum); }else if(isDir(argv[optind])){ - imageNum=getImageFilesInDir(&files, argv[optind]); + imageNum+=getImageFilesInDir(&files, argv[optind], imageNum); }else{ - imageNum = argc-optind; - - files=malloc(sizeof(char*) *imageNum); + files=realloc(files, sizeof(char*)*(imageNum+argc-optind)); int x; - for(x =0; optind+x 1 && !paused){ + + if(timeout>0 && !paused){ + cTime = getCurrentTimeMs(); + if( (cTime-lShowTime) > timeout){ + // Exit if this is the last image if(imageNum <= ++i) - i=0; + break; + stopAnimation(pCurRender); ret=decodeImage(files[i], &image, &anim); if(ret==0){ @@ -604,7 +677,7 @@ int main(int argc, char *argv[]){ else printf("Continue\n"); } - } + } // end while. if(ret == 0){ ret = stopOmxImageRender(pCurRender); From 79665212c3e75c6148d8ae275626cd2f648297bf Mon Sep 17 00:00:00 2001 From: cmitu <31816814+cmitu@users.noreply.github.com> Date: Wed, 11 Sep 2019 18:34:32 +0100 Subject: [PATCH 5/6] Preserve the upstream repeat behavior, add a parameter to exit after showing the image(s) once --- Makefile | 5 +++-- README.md | 1 + omxiv.c | 22 ++++++++++++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 84c9c24..5632eb2 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ OBJS=omxiv.o omx_image.o omx_render.o soft_image.o ./libnsbmp/libnsbmp.o ./libns BIN=omxiv.bin LDFLAGS+=-lilclient -ljpeg -lpng -lrt -ldl -Wl,--gc-sections -s INCLUDES+=-I./libnsbmp -I./libnsgif -I./libs/ilclient +INSTALL ?= /usr/local/bin BUILDVERSION=\"$(shell git rev-parse --short=10 HEAD 2>/dev/null;test $$? -gt 0 && echo UNKNOWN)\" LIBCURL_NAME=\"$(shell ldconfig -p | grep libcurl | head -n 1 | awk '{print $$1;}' 2>/dev/null)\" @@ -26,10 +27,10 @@ ilclient: make -C libs/ilclient install: - install $(BIN) /usr/bin/omxiv + install -D $(BIN) $(INSTALL)/omxiv uninstall: - rm -f /usr/bin/omxiv + rm -f $(INSTALL)/omxiv debug: CFLAGS:=$(filter-out -O3,$(CFLAGS)) -Og debug: LDFLAGS:=$(filter-out -s,$(LDFLAGS)) diff --git a/README.md b/README.md index 68c86a7..8bb1ed7 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ OPTIONS: --ignore-exif Ignore exif orientation -f --file-list Read a list of images from a text file -r --randomize Randomize the list of images + --once Only show the image(s) once, exit after the last KEY CONFIGURATION: diff --git a/omxiv.c b/omxiv.c index a46a17f..27615c4 100644 --- a/omxiv.c +++ b/omxiv.c @@ -46,6 +46,7 @@ static const struct option longOpts[] = { {"ignore-exif", no_argument, 0, 0x103}, {"input-filename", required_argument, 0, 'f'}, {"randomize", no_argument, 0, 'r'}, + {"once", no_argument, 0, 0x104}, {0, 0, 0, 0} }; @@ -365,7 +366,7 @@ static int isBackgroundProc() { } static void printVersion(){ - printf("Version: %s-custom\n", VERSION); + printf("Version: %s\n", VERSION); printf("Build date: %s\n", __DATE__); } @@ -425,6 +426,7 @@ int main(int argc, char *argv[]){ long timeout = 0; char *inputFileName = NULL; int randomize = 0; + int repeat = 1; render.transition.type = NONE; render.transition.durationMs = 400; @@ -498,18 +500,21 @@ int main(int argc, char *argv[]){ exifOrient = 0; break; case 'r': randomize = 1; break; + case 0x104: + repeat = 0; break; default: return EXIT_FAILURE; } } + int imageNum=0; char **files=NULL; if (inputFileName!=NULL) { imageNum=readImageList(&files, inputFileName); } - if(argc-optind <= 0){ + if(argc-optind <= 0 && imageNum<=0 ){ imageNum+=getImageFilesInDir(&files, "./", imageNum); }else if(isDir(argv[optind])){ imageNum+=getImageFilesInDir(&files, argv[optind], imageNum); @@ -601,10 +606,15 @@ int main(int argc, char *argv[]){ cTime = getCurrentTimeMs(); if( (cTime-lShowTime) > timeout){ - // Exit if this is the last image - if(imageNum <= ++i) - break; - + // Exit if this is the last image and looping is disabled + if(imageNum <= ++i) { + if(repeat) { + i=0; + } else { + break; + } + } + stopAnimation(pCurRender); ret=decodeImage(files[i], &image, &anim); if(ret==0){ From e89e77e0ed26a1fc80de5944fc425e74b1fd7951 Mon Sep 17 00:00:00 2001 From: cmitu <31816814+cmitu@users.noreply.github.com> Date: Fri, 20 Sep 2019 04:48:08 +0100 Subject: [PATCH 6/6] Fix "file-list" argument --- omxiv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omxiv.c b/omxiv.c index 27615c4..2c9f3cc 100644 --- a/omxiv.c +++ b/omxiv.c @@ -44,7 +44,7 @@ static const struct option longOpts[] = { {"no-keys", no_argument, 0, 'k'}, {"soft", no_argument, 0, 's'}, {"ignore-exif", no_argument, 0, 0x103}, - {"input-filename", required_argument, 0, 'f'}, + {"file-list", required_argument, 0, 'f'}, {"randomize", no_argument, 0, 'r'}, {"once", no_argument, 0, 0x104}, {0, 0, 0, 0}