From 166c62a815b355f1c8e92b9f52c790f8d55711ed Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Thu, 28 Mar 2024 09:52:08 +0900 Subject: [PATCH] Correct the type 'ExifShort' is unsigned short. Updated related code. Change-Id: I1bb550b5171ba5dedb4d734c99238be2a57644f2 Signed-off-by: Minje Ahn --- src/common/media-svc-util.c | 25 +++++++++++-------------- src/include/common/media-svc-util.h | 6 +++--- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 5a1956f..a4bed31 100644 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -152,7 +152,7 @@ static char * __media_svc_get_exif_datetaken(ExifData *ed) return NULL; } -static bool __media_svc_get_exif_int(ExifData *ed, ExifTag tagtype, int *value) +static bool __media_svc_get_exif_short(ExifData *ed, ExifTag tagtype, unsigned short *value) { ExifEntry *entry; @@ -161,10 +161,7 @@ static bool __media_svc_get_exif_int(ExifData *ed, ExifTag tagtype, int *value) entry = exif_data_get_entry(ed, tagtype); media_svc_retv_if(!entry, false); - - short exif_value = exif_get_short(entry->data, exif_data_get_byte_order(ed)); - media_svc_retv_if(exif_value < 0, false); - *value = (int)exif_value; + *value = exif_get_short(entry->data, exif_data_get_byte_order(ed)); return true; } @@ -456,9 +453,9 @@ char * _media_svc_get_title_from_filename(const char *filename) int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info) { - int orient_value = 0; - int exif_width = 0; - int exif_height = 0; + unsigned short orient_value = 0; + unsigned short exif_width = 0; + unsigned short exif_height = 0; ExifData *ed = NULL; media_svc_retvm_if(!content_info, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid content_info"); @@ -476,16 +473,16 @@ int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info) content_info->media_meta.datetaken = __media_svc_get_exif_datetaken(ed); - if (__media_svc_get_exif_int(ed, EXIF_TAG_ORIENTATION, &orient_value)) { - if (orient_value >= NOT_AVAILABLE && orient_value <= ROT_270) + if (__media_svc_get_exif_short(ed, EXIF_TAG_ORIENTATION, &orient_value)) { + if (orient_value <= ROT_270) content_info->media_meta.orientation = orient_value; } - if (__media_svc_get_exif_int(ed, EXIF_TAG_PIXEL_X_DIMENSION, &exif_width)) - content_info->media_meta.width = exif_width; + if (__media_svc_get_exif_short(ed, EXIF_TAG_PIXEL_X_DIMENSION, &exif_width)) + content_info->media_meta.width = (unsigned int)exif_width; - if (__media_svc_get_exif_int(ed, EXIF_TAG_PIXEL_Y_DIMENSION, &exif_height)) - content_info->media_meta.height = exif_height; + if (__media_svc_get_exif_short(ed, EXIF_TAG_PIXEL_Y_DIMENSION, &exif_height)) + content_info->media_meta.height = (unsigned int)exif_height; exif_data_unref(ed); diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h index ee22a5b..d6f15e2 100755 --- a/src/include/common/media-svc-util.h +++ b/src/include/common/media-svc-util.h @@ -47,10 +47,10 @@ typedef struct { char *genre; /**< genre of track*/ char *year; /**< year*/ char *track_num; /**< track number*/ - int width; /**< width*/ - int height; /**< height*/ + unsigned int width; /**< width*/ + unsigned int height; /**< height*/ char *datetaken; /**< datetaken*/ - int orientation; /**< orientation*/ + unsigned short orientation; /**< orientation*/ } media_svc_content_meta_s; /** -- 2.7.4