#1269 fixed cataloguing images with wrong MPF offsets

This commit is contained in:
Thibault Deckers 2024-11-18 21:51:20 +01:00
parent 89c4fdd854
commit 58e3912f86
2 changed files with 9 additions and 4 deletions

View file

@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
### Fixed ### Fixed
- crash when playing video with DCL restriction enabled - crash when playing video with DCL restriction enabled
- cataloguing images with wrong MPF offsets
- printing multi-page items containing some unprintable pages - printing multi-page items containing some unprintable pages
- English (Shavian) locale tags for store listing - English (Shavian) locale tags for store listing

View file

@ -792,7 +792,7 @@ class MetadataFetchHandler(private val context: Context) : MethodCallHandler {
private fun hasAppleHdrGainMap(uri: Uri, sizeBytes: Long?): Boolean { private fun hasAppleHdrGainMap(uri: Uri, sizeBytes: Long?): Boolean {
val mpEntries = MultiPage.getJpegMpfEntries(context, uri, sizeBytes) ?: return false val mpEntries = MultiPage.getJpegMpfEntries(context, uri, sizeBytes) ?: return false
mpEntries.filter { it.type == MpEntry.TYPE_UNDEFINED }.forEach { mpEntry -> mpEntries.filter { it.type == MpEntry.TYPE_UNDEFINED }.forEachIndexed { mpIndex, mpEntry ->
var dataOffset = mpEntry.dataOffset var dataOffset = mpEntry.dataOffset
if (dataOffset > 0) { if (dataOffset > 0) {
val baseOffset = MultiPage.getJpegMpfBaseOffset(context, uri, sizeBytes) val baseOffset = MultiPage.getJpegMpfBaseOffset(context, uri, sizeBytes)
@ -802,10 +802,14 @@ class MetadataFetchHandler(private val context: Context) : MethodCallHandler {
} }
StorageUtils.openInputStream(context, uri)?.let { input -> StorageUtils.openInputStream(context, uri)?.let { input ->
input.skip(dataOffset) input.skip(dataOffset)
try {
val pageMetadata = Helper.safeRead(input, sizeBytes) val pageMetadata = Helper.safeRead(input, sizeBytes)
if (pageMetadata.getDirectoriesOfType(XmpDirectory::class.java).any { it.xmpMeta.hasHdrGainMap() }) { if (pageMetadata.getDirectoriesOfType(XmpDirectory::class.java).any { it.xmpMeta.hasHdrGainMap() }) {
return true return true
} }
} catch (e: Exception) {
Log.w(LOG_TAG, "failed to read metadata by metadata-extractor for uri=$uri mpIndex=$mpIndex mpEntry=$mpEntry", e)
}
} }
} }
return false return false