Merge "Make MtpDatabase use libexif instead of libjhead" into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9823a170e4
@@ -37,7 +37,7 @@ LOCAL_SHARED_LIBRARIES := \
|
|||||||
libcamera_client \
|
libcamera_client \
|
||||||
libmtp \
|
libmtp \
|
||||||
libusbhost \
|
libusbhost \
|
||||||
libjhead \
|
libexif \
|
||||||
libstagefright_amrnb_common \
|
libstagefright_amrnb_common \
|
||||||
|
|
||||||
LOCAL_REQUIRED_MODULES := \
|
LOCAL_REQUIRED_MODULES := \
|
||||||
@@ -47,7 +47,7 @@ LOCAL_STATIC_LIBRARIES := \
|
|||||||
libstagefright_amrnbenc
|
libstagefright_amrnbenc
|
||||||
|
|
||||||
LOCAL_C_INCLUDES += \
|
LOCAL_C_INCLUDES += \
|
||||||
external/jhead \
|
external/libexif/ \
|
||||||
external/tremor/Tremor \
|
external/tremor/Tremor \
|
||||||
frameworks/base/core/jni \
|
frameworks/base/core/jni \
|
||||||
frameworks/av/media/libmedia \
|
frameworks/av/media/libmedia \
|
||||||
|
|||||||
@@ -37,7 +37,10 @@
|
|||||||
#include "mtp.h"
|
#include "mtp.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "jhead.h"
|
#include "libexif/exif-content.h"
|
||||||
|
#include "libexif/exif-data.h"
|
||||||
|
#include "libexif/exif-tag.h"
|
||||||
|
#include "libexif/exif-utils.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
@@ -750,6 +753,22 @@ MtpResponseCode MyMtpDatabase::getObjectPropertyList(MtpObjectHandle handle,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void foreachentry(ExifEntry *entry, void *user) {
|
||||||
|
char buf[1024];
|
||||||
|
ALOGI("entry %x, format %d, size %d: %s",
|
||||||
|
entry->tag, entry->format, entry->size, exif_entry_get_value(entry, buf, sizeof(buf)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void foreachcontent(ExifContent *content, void *user) {
|
||||||
|
ALOGI("content %d", exif_content_get_ifd(content));
|
||||||
|
exif_content_foreach_entry(content, foreachentry, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
static long getLongFromExifEntry(ExifEntry *e) {
|
||||||
|
ExifByteOrder o = exif_data_get_byte_order(e->parent->parent);
|
||||||
|
return exif_get_long(e->data, o);
|
||||||
|
}
|
||||||
|
|
||||||
MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle,
|
MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle,
|
||||||
MtpObjectInfo& info) {
|
MtpObjectInfo& info) {
|
||||||
char date[20];
|
char date[20];
|
||||||
@@ -792,24 +811,23 @@ MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle,
|
|||||||
|
|
||||||
// read EXIF data for thumbnail information
|
// read EXIF data for thumbnail information
|
||||||
if (info.mFormat == MTP_FORMAT_EXIF_JPEG || info.mFormat == MTP_FORMAT_JFIF) {
|
if (info.mFormat == MTP_FORMAT_EXIF_JPEG || info.mFormat == MTP_FORMAT_JFIF) {
|
||||||
ResetJpgfile();
|
|
||||||
// Start with an empty image information structure.
|
ExifData *exifdata = exif_data_new_from_file(path);
|
||||||
memset(&ImageInfo, 0, sizeof(ImageInfo));
|
if (exifdata) {
|
||||||
ImageInfo.FlashUsed = -1;
|
//exif_data_foreach_content(exifdata, foreachcontent, NULL);
|
||||||
ImageInfo.MeteringMode = -1;
|
|
||||||
ImageInfo.Whitebalance = -1;
|
// XXX get this from exif, or parse jpeg header instead?
|
||||||
strncpy(ImageInfo.FileName, (const char *)path, PATH_MAX);
|
ExifEntry *w = exif_content_get_entry(
|
||||||
if (ReadJpegFile((const char*)path, READ_METADATA)) {
|
exifdata->ifd[EXIF_IFD_EXIF], EXIF_TAG_PIXEL_X_DIMENSION);
|
||||||
Section_t* section = FindSection(M_EXIF);
|
ExifEntry *h = exif_content_get_entry(
|
||||||
if (section) {
|
exifdata->ifd[EXIF_IFD_EXIF], EXIF_TAG_PIXEL_Y_DIMENSION);
|
||||||
info.mThumbCompressedSize = ImageInfo.ThumbnailSize;
|
info.mThumbCompressedSize = exifdata->data ? exifdata->size : 0;
|
||||||
info.mThumbFormat = MTP_FORMAT_EXIF_JPEG;
|
info.mThumbFormat = MTP_FORMAT_EXIF_JPEG;
|
||||||
info.mImagePixWidth = ImageInfo.Width;
|
info.mImagePixWidth = w ? getLongFromExifEntry(w) : 0;
|
||||||
info.mImagePixHeight = ImageInfo.Height;
|
info.mImagePixHeight = h ? getLongFromExifEntry(h) : 0;
|
||||||
|
exif_data_unref(exifdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DiscardData();
|
|
||||||
}
|
|
||||||
|
|
||||||
checkAndClearExceptionFromCallback(env, __FUNCTION__);
|
checkAndClearExceptionFromCallback(env, __FUNCTION__);
|
||||||
return MTP_RESPONSE_OK;
|
return MTP_RESPONSE_OK;
|
||||||
@@ -824,22 +842,16 @@ void* MyMtpDatabase::getThumbnail(MtpObjectHandle handle, size_t& outThumbSize)
|
|||||||
|
|
||||||
if (getObjectFilePath(handle, path, length, format) == MTP_RESPONSE_OK
|
if (getObjectFilePath(handle, path, length, format) == MTP_RESPONSE_OK
|
||||||
&& (format == MTP_FORMAT_EXIF_JPEG || format == MTP_FORMAT_JFIF)) {
|
&& (format == MTP_FORMAT_EXIF_JPEG || format == MTP_FORMAT_JFIF)) {
|
||||||
ResetJpgfile();
|
|
||||||
// Start with an empty image information structure.
|
ExifData *exifdata = exif_data_new_from_file(path);
|
||||||
memset(&ImageInfo, 0, sizeof(ImageInfo));
|
if (exifdata) {
|
||||||
ImageInfo.FlashUsed = -1;
|
if (exifdata->data) {
|
||||||
ImageInfo.MeteringMode = -1;
|
result = malloc(exifdata->size);
|
||||||
ImageInfo.Whitebalance = -1;
|
if (result) {
|
||||||
strncpy(ImageInfo.FileName, (const char *)path, PATH_MAX);
|
memcpy(result, exifdata->data, exifdata->size);
|
||||||
if (ReadJpegFile((const char*)path, READ_METADATA)) {
|
|
||||||
Section_t* section = FindSection(M_EXIF);
|
|
||||||
if (section) {
|
|
||||||
outThumbSize = ImageInfo.ThumbnailSize;
|
|
||||||
result = malloc(outThumbSize);
|
|
||||||
if (result)
|
|
||||||
memcpy(result, section->Data + ImageInfo.ThumbnailOffset + 8, outThumbSize);
|
|
||||||
}
|
}
|
||||||
DiscardData();
|
}
|
||||||
|
exif_data_unref(exifdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user