From fe581c5e7fc9c1f7ef383eb5b953fe8a3169ec6e Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Mon, 23 Jan 2012 18:51:48 +0000 Subject: [PATCH] * Fix a couple errors in the rotation code. --- metadata.c | 4 ++-- upnphttp.c | 49 +++++++++++++++++++++++++------------------------ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/metadata.c b/metadata.c index af376f4..71e4acf 100644 --- a/metadata.c +++ b/metadata.c @@ -620,10 +620,10 @@ GetImageMetadata(const char * path, char * name) rotate = 180; break; case 6: - rotate = 270; + rotate = 90; break; case 8: - rotate = 90; + rotate = 270; break; default: rotate = 0; diff --git a/upnphttp.c b/upnphttp.c index feb8f42..a53ee50 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -1552,7 +1552,7 @@ SendResp_resizedimg(struct upnphttp * h, char * object) char dlna_pn[4]; time_t curtime = time(NULL); int width=640, height=480, dstw, dsth, size; - long srcw, srch; + int srcw, srch; unsigned char * data = NULL; char *path, *file_path; char *resolution; @@ -1636,9 +1636,31 @@ SendResp_resizedimg(struct upnphttp * h, char * object) } DPRINTF(E_INFO, L_HTTP, "Serving resized image for ObjectId: %lld [%s]\n", id, file_path); + switch( rotate ) + { + case 90: + ret = sscanf(resolution, "%dx%d", &srch, &srcw); + rotate = ROTATE_90; + break; + case 270: + ret = sscanf(resolution, "%dx%d", &srch, &srcw); + rotate = ROTATE_270; + break; + case 180: + ret = sscanf(resolution, "%dx%d", &srcw, &srch); + rotate = ROTATE_180; + break; + default: + ret = sscanf(resolution, "%dx%d", &srcw, &srch); + rotate = ROTATE_NONE; + break; + } + if( ret != 2 ) + { + Send500(h); + return; + } /* Figure out the best destination resolution we can use */ - srcw = strtol(resolution, &saveptr, 10); - srch = strtol(saveptr+1, NULL, 10); dstw = width; dsth = ((((width<<10)/srcw)*srch)>>10); if( dsth > height ) @@ -1646,27 +1668,6 @@ SendResp_resizedimg(struct upnphttp * h, char * object) dsth = height; dstw = (((height<<10)/srch) * srcw>>10); } - switch( rotate ) - { - case 90: - rotate = dsth; - dsth = dstw; - dstw = rotate; - rotate = ROTATE_90; - break; - case 270: - rotate = dsth; - dsth = dstw; - dstw = rotate; - rotate = ROTATE_270; - break; - case 180: - rotate = ROTATE_180; - break; - default: - rotate = ROTATE_NONE; - break; - } if( dstw <= 640 && dsth <= 480 ) strcpy(dlna_pn, "SM");