Repository navigation
[libmotionphoto] Optimize JPEG motion photo detection and trailer parsing performance. - #6
Merged
Merged
Conversation
…aths - Use absl::string_view in GoogleMotionPhotoProvider::Identify and LegacyMicroVideoProvider::Identify where absl::StrContains is called, fixing compilation against Debian/Ubuntu system libabsl-dev (where absl::string_view is absl::debian3::string_view). - Respect LIBMOTIONPHOTO_USE_SYSTEM_DEPS when resolving absl in lib/core/CMakeLists.txt and guard optional absl::log_internal_check_op with $<$<TARGET_EXISTS:absl::log_internal_check_op>:...>. - Avoid installing system abseil in fetchcontent CI jobs so FetchContent is properly exercised. - Update Java API doc check workflow and script paths to lib/java/** and harden workflows for Zizmor compliance (explicit permissions, SHA-pinned checkout action, and env variable step inputs).
…sing performance. - Early-terminate JPEG scanner at SOS marker once XMP parses video trailer bounds, avoiding multi-megabyte entropy scan. - Parse video trailer bounds (Item:Length / MicroVideoOffset) directly from XMP in JpegContainerSplitter. - Keep only a 64-byte prefix in RawMetadataBlock::bytes while preserving total_payload_size to eliminate 20-120 MB RAM allocations and copies for motion photo video trailers. - Use lazy FdDataSource (pread in 64 KB chunks on demand over full file range) across C++ (ParseMotionPhotoFromFile/Fd, ExtractPrimaryImageFromFile, ExtractVideoTrackFromFile) and JNI (MetadataEngineJni.parseMetadata and parseMetadataFd). Tested: - ./build.sh && ./test.sh (57/57 unit tests pass)
… HandlerOptions in ParseMotionPhoto API (#5) Syncs the review updates from cl/991201939 onto `Development`: 1. **Standard Motion Photo XMP parsing & Legacy MicroVideo 3P Plugin separation**: - Restricts `JpegContainerSplitter::ParseVideoLengthFromXmp` to standard Motion Photo metadata (`(GCamera|Camera):MotionPhoto` and `Container:Directory` `Item:Length` where `Item:Semantic="MotionPhoto"` in both attribute and element forms). - Moves legacy `MicroVideoOffset` parsing into `LegacyMicroVideoProvider` (`DecodeToSemantic` -> `LegacyMicroVideoMetadata::micro_video_offset` and `GetVideoInfo`). - Uses `total_payload_size` in `LegacyMicroVideoProvider` so full video payloads can be streamed directly from the underlying data source without buffering the video trailer in `RawMetadataBlock::bytes`. 2. **Expose `HandlerOptions` in `libmotionphoto_api.h` and govern `is_motion_photo` by enabled 3P plugins**: - Exposes `HandlerOptions` (`disable_3p_plugins`, `enabled_3p_plugins`) on `ParseMotionPhotoFrom{File,Fd,Memory}`. - Governs `out_metadata->is_motion_photo` strictly via `MetadataEngine::IsMotionPhoto(collection, engine_options)` so `is_motion_photo` returns `false` when 3P plugins are disabled or only non-matching 3P plugins are enabled, and `true` when all 3P plugins or a matching 3P plugin is enabled. - Adds unit tests in `legacy_micro_video_provider_test.cc` and `libmotionphoto_api_test.cc` covering all 4 `HandlerOptions` states.
DichenZhang1
force-pushed
the
Development
branch
from
October 2, 2026 19:30
c04f6e6 to
fe7b883
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Promotes
Development(cl/991201939— PR #4 and PR #5) tomain:Early termination of JPEG scanner at SOS marker:
XMP metadata precedes the Start of Scan (
SOS) marker in JPEG files. When video trailer bounds are extracted directly from XMP metadata, scanning the entire entropy-coded image data (SOStoEOI) is avoided, terminating scanning immediately atSOS.Parse standard Motion Photo video trailer bounds directly from XMP & separate Legacy MicroVideo into 3P Plugin:
Inspects standard Motion Photo metadata (
(GCamera|Camera):MotionPhotoandContainer:DirectoryItem:LengthwhereItem:Semantic="MotionPhoto"in both attribute and element forms) inJpegContainerSplitter, while moving legacyMicroVideoOffsetmetadata parsing into the 3PLegacyMicroVideoProviderplugin (DecodeToSemantic->LegacyMicroVideoMetadata::micro_video_offsetandGetVideoInfo).Expose
HandlerOptionsinlibmotionphoto_api.hand governis_motion_photoby enabled 3P plugins:Exposes
HandlerOptions(disable_3p_plugins,enabled_3p_plugins) onParseMotionPhotoFrom{File,Fd,Memory}and governsout_metadata->is_motion_photostrictly viaMetadataEngine::IsMotionPhoto(collection, engine_options).Eliminate multi-megabyte heap allocation in
RawMetadataBlock:Retains only a 64-byte prefix in
RawMetadataBlock::bytesfor signature verification while preservingtotal_payload_sizeso full video payloads can be streamed directly from the underlying data source without intermediate RAM allocation.Lazy on-demand
preadDataSourceacross C++ and JNI APIs:Replaces whole-file/whole-fd buffering in
ParseMotionPhotoFromFile,ParseMotionPhotoFromFd,ExtractPrimaryImageFromFile,ExtractVideoTrackFromFile, and JNIMetadataEngineJni(parseMetadataandparseMetadataFd) withFdDataSource(reading 64 KB chunks on demand viapread).