From 30562d0b66f7777d2ff0223e6c2c5745c222645e Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Wed, 29 Jul 2015 23:23:55 -0700 Subject: [PATCH] upnpttp: Implement PixelShape support. TiVo uses this to get the aspect ratio correct on images. --- tagutils/tagutils-flc.c | 2 +- upnphttp.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tagutils/tagutils-flc.c b/tagutils/tagutils-flc.c index 11bb8be..a8713ea 100644 --- a/tagutils/tagutils-flc.c +++ b/tagutils/tagutils-flc.c @@ -76,7 +76,7 @@ _get_flctags(char *filename, struct song_metadata *psong) #if FLAC_API_VERSION_CURRENT >= 10 case FLAC__METADATA_TYPE_PICTURE: if (psong->image) { - DPRINTF(E_INFO, L_SCANNER, "Ignoring additional image [%s]\n", filename); + DPRINTF(E_MAXDEBUG, L_SCANNER, "Ignoring additional image [%s]\n", filename); break; } psong->image_size = block->data.picture.data_length; diff --git a/upnphttp.c b/upnphttp.c index bf6f3d3..c59f8cf 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -1568,8 +1568,7 @@ SendResp_resizedimg(struct upnphttp * h, char * object) char *key, *val; char *saveptr, *item = NULL; int rotate; - /* Not implemented yet * - char *pixelshape=NULL; */ + int pixw = 0, pixh = 0; long long id; int rows=0, chunked, ret; image_s *imsrc = NULL, *imdst = NULL; @@ -1622,11 +1621,12 @@ SendResp_resizedimg(struct upnphttp * h, char * object) rotate = (rotate + atoi(val)) % 360; sql_exec(db, "UPDATE DETAILS set ROTATION = %d where ID = %lld", rotate, id); } - /* Not implemented yet * else if( strcasecmp(key, "pixelshape") == 0 ) { - pixelshape = val; - } */ + ret = sscanf(val, "%d:%d", &pixw, &pixh); + if( ret != 2 ) + pixw = pixh = 0; + } } #if USE_FORK @@ -1680,6 +1680,14 @@ SendResp_resizedimg(struct upnphttp * h, char * object) dsth = height; dstw = (((height<<10)/srch) * srcw>>10); } + /* Account for pixel shape */ + if( pixw && pixh ) + { + if( pixh > pixw ) + dsth = dsth * pixw / pixh; + else if( pixw > pixh ) + dstw = dstw * pixh / pixw; + } if( dstw <= 160 && dsth <= 160 ) strcpy(dlna_pn, "DLNA.ORG_PN=JPEG_TN;");