Skip to content

Commit 7284605

Browse files
More C like file naming
1 parent e43b45f commit 7284605

12 files changed

+90
-92
lines changed

HttpImage.c

Lines changed: 0 additions & 70 deletions
This file was deleted.

HttpImage.h

Lines changed: 0 additions & 3 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
OBJS=omxiv.o OmxImage.o OmxRender.o SoftImage.o ./libnsbmp/libnsbmp.o
1+
OBJS=omxiv.o omx_image.o omx_render.o soft_image.o ./libnsbmp/libnsbmp.o
22
BIN=omxiv.bin
33
LDFLAGS+=-lilclient -ljpeg -lpng
44
INCLUDES+=-I./libnsbmp -I./libs/ilclient
55

66
ifneq ($(CURL),0)
7-
OBJS+= HttpImage.o
87
LDFLAGS+= -lcurl
98
CFLAGS+= -DUSE_LIBCURL
109
endif

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ A GPU accelerated image viewer for the Raspberry Pi.
44

55
## Building
66

7-
Make sure that you have the development header for libjpeg, libpng and optional
8-
libcurl installed (libjpeg8-dev, libpng12-dev, libcurl4-openssl-dev), then build
9-
it on the Pi with:
7+
You will need the development header for libjpeg, libpng and optional
8+
libcurl (Debian: libjpeg8-dev, libpng12-dev, libcurl4-openssl-dev).
9+
Then build it on the Pi with:
1010

1111
make ilclient
1212
make
@@ -35,6 +35,5 @@ And install with:
3535
##### Thanks to:
3636
* Matt Ownby, Anthong Sale for their hello_jpeg example
3737
* Jan Newmarch for his [blog](http://jan.newmarch.name/RPi/index.html): Programming AudioVideo on the Raspberry Pi GPU
38-
* The xbmc/kodi guys for their omxplayer
39-
* Everyone else I might have forgotten
38+
* Various authors of example code and other parts (marked in the source files)
4039

ImageDef.h renamed to image_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ typedef struct IMAGE{
1717
char colorSpace;
1818
} IMAGE;
1919

20-
#endif
20+
#endif

OmxImage.c renamed to omx_image.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <stdlib.h>
3232
#include <pthread.h>
3333

34-
#include "OmxImage.h"
34+
#include "omx_image.h"
3535
#include "bcm_host.h"
3636

3737
#define TIMEOUT_MS 1500
@@ -162,7 +162,7 @@ static int startupDecoder(JPEG_DECODER * decoder){
162162
if (OMX_AllocateBuffer(decoder->handle,
163163
&decoder->ppInputBufferHeader[i],
164164
decoder->inPort,
165-
(void *) i, portdef.nBufferSize) != OMX_ErrorNone) {
165+
NULL, portdef.nBufferSize) != OMX_ErrorNone) {
166166
return OMX_JPEG_ERROR_MEMORY;
167167
}
168168
}

OmxImage.h renamed to omx_image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727

2828
#include "ilclient.h"
29-
#include "ImageDef.h"
29+
#include "image_def.h"
3030

3131
#define OMX_JPEG_OK 0x0
3232
#define OMX_JPEG_ERROR_MEMORY 0x1

OmxRender.c renamed to omx_render.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include <stdlib.h>
2929

30-
#include "OmxRender.h"
30+
#include "omx_render.h"
3131
#include "bcm_host.h"
3232

3333
#define TIMEOUT_MS 2000

OmxRender.h renamed to omx_render.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626
*/
2727

28-
#include "ImageDef.h"
28+
#include "image_def.h"
2929
#include "ilclient.h"
3030

3131
#define OMX_RENDER_OK 0x0

omxiv.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
#include <signal.h>
1010
#include <dirent.h>
1111

12-
#include "OmxRender.h"
13-
#include "OmxImage.h"
14-
#include "SoftImage.h"
15-
#include "HttpImage.h"
12+
#include "omx_render.h"
13+
#include "omx_image.h"
14+
#include "soft_image.h"
1615
#include "bcm_host.h"
1716

1817
#define str(s) #s

SoftImage.c renamed to soft_image.c

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#include <stdio.h>
22
#include <stdlib.h>
33
#include <string.h>
4+
45
#include <jpeglib.h>
56
#include <png.h>
67

7-
#include "SoftImage.h"
8+
#include "soft_image.h"
89
#include "libnsbmp/libnsbmp.h"
910

1011
struct my_error_mgr {
@@ -329,3 +330,72 @@ int softDecodeBMP(FILE *fp, IMAGE* bmpImage){
329330
return ret;
330331
}
331332

333+
#ifdef USE_LIBCURL
334+
335+
/**
336+
* Modified from: http://curl.haxx.se/libcurl/c/getinmemory.html
337+
* Copyright (C) 1998 - 2015, Daniel Stenberg, <[email protected]>, et al.
338+
* Distributed under: http://curl.haxx.se/docs/copyright.html
339+
**/
340+
341+
#include <curl/curl.h>
342+
343+
struct MemoryStruct {
344+
char *memory;
345+
size_t size;
346+
};
347+
348+
static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
349+
{
350+
size_t realsize = size * nmemb;
351+
struct MemoryStruct *mem = (struct MemoryStruct *)userp;
352+
353+
mem->memory = realloc(mem->memory, mem->size + realsize);
354+
if(!mem->memory) {
355+
return 0;
356+
}
357+
358+
memcpy(&(mem->memory[mem->size]), contents, realsize);
359+
mem->size += realsize;
360+
361+
return realsize;
362+
}
363+
364+
char* getImageFromUrl(const char *url, size_t *size){
365+
CURL *curl_handle;
366+
CURLcode res;
367+
368+
struct MemoryStruct chunk;
369+
370+
chunk.memory = NULL;
371+
chunk.size = 0;
372+
373+
curl_global_init(CURL_GLOBAL_ALL);
374+
375+
curl_handle = curl_easy_init();
376+
377+
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
378+
379+
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
380+
381+
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
382+
383+
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
384+
385+
res = curl_easy_perform(curl_handle);
386+
387+
if(res != CURLE_OK) {
388+
free(chunk.memory);
389+
chunk.memory=NULL;
390+
chunk.size = 0;
391+
printf("libCurl returned error code %d\n", res);
392+
}
393+
394+
*size= chunk.size;
395+
396+
curl_easy_cleanup(curl_handle);
397+
curl_global_cleanup();
398+
399+
return chunk.memory;
400+
}
401+
#endif

SoftImage.h renamed to soft_image.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "ImageDef.h"
1+
#include "image_def.h"
22

33
#define SOFT_IMAGE_ERROR_FILE_OPEN 0x02
44

@@ -32,3 +32,7 @@ int softDecodePng(FILE *pngFile, IMAGE* png);
3232
#define SOFT_BMP_ERROR_ANALYSING 0x08
3333

3434
int softDecodeBMP(FILE *bmpFile, IMAGE* bmpImage);
35+
36+
/* Get Image from Url */
37+
char* getImageFromUrl(const char *url, size_t *size);
38+

0 commit comments

Comments
 (0)