From 4853528ceff3f5b0156cd2a3505abd6c6f961d36 Mon Sep 17 00:00:00 2001 From: Chris Hocking Date: Sat, 15 Jul 2023 08:23:23 +1000 Subject: [PATCH] Improvements - Updated `gyroflow_core`. - Tweaked build scripts. - Hooked up FOV Overview. --- Scripts/build_rust.sh | 4 ++-- Scripts/build_rust_update.sh | 17 +++++++++++++++++ Source/Frameworks/gyroflow/Cargo.toml | 2 +- Source/Frameworks/gyroflow/inc/gyroflow.h | 1 + Source/Frameworks/gyroflow/src/lib.rs | 20 ++++++++++++++++---- Source/Gyroflow/Plugin/GyroflowConstants.h | 2 +- Source/Gyroflow/Plugin/GyroflowParameters.h | 4 ++++ Source/Gyroflow/Plugin/GyroflowParameters.m | 8 ++++++++ Source/Gyroflow/Plugin/GyroflowPlugIn.m | 19 ++++++++++++++++--- 9 files changed, 66 insertions(+), 11 deletions(-) create mode 100755 Scripts/build_rust_update.sh diff --git a/Scripts/build_rust.sh b/Scripts/build_rust.sh index bae14180..a9b60554 100755 --- a/Scripts/build_rust.sh +++ b/Scripts/build_rust.sh @@ -8,10 +8,10 @@ export REPO_HOME ; REPO_HOME="$(greadlink -f "${SCRIPT_HOME}/../")" cd "${REPO_HOME}/Source/Frameworks/gyroflow" #~/.cargo/bin/cargo clean -~/.cargo/bin/cargo update +#~/.cargo/bin/cargo update ~/.cargo/bin/cargo build --release --target x86_64-apple-darwin ~/.cargo/bin/cargo build --release --target aarch64-apple-darwin lipo -create -output "${REPO_HOME}/Source/Frameworks/gyroflow/target/libgyroflow_toolbox.dylib" "${REPO_HOME}/Source/Frameworks/gyroflow/target/x86_64-apple-darwin/release/libgyroflow_toolbox.dylib" "${REPO_HOME}/Source/Frameworks/gyroflow/target/aarch64-apple-darwin/release/libgyroflow_toolbox.dylib" /bin/mv "${REPO_HOME}/Source/Frameworks/gyroflow/target/libgyroflow_toolbox.dylib" "${REPO_HOME}/Source/Frameworks/gyroflow/binary/libgyroflow_toolbox.dylib" cd "${REPO_HOME}/Source/Frameworks/gyroflow/binary" -/usr/bin/install_name_tool -id "@rpath/libgyroflow_toolbox.dylib" libgyroflow_toolbox.dylib +/usr/bin/install_name_tool -id "@rpath/libgyroflow_toolbox.dylib" libgyroflow_toolbox.dylib \ No newline at end of file diff --git a/Scripts/build_rust_update.sh b/Scripts/build_rust_update.sh new file mode 100755 index 00000000..d62bd49a --- /dev/null +++ b/Scripts/build_rust_update.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -eu +set -o pipefail + +export SCRIPT_HOME ; SCRIPT_HOME="$(dirname "$(greadlink -f "$0")")" +export REPO_HOME ; REPO_HOME="$(greadlink -f "${SCRIPT_HOME}/../")" + +cd "${REPO_HOME}/Source/Frameworks/gyroflow" +#~/.cargo/bin/cargo clean +~/.cargo/bin/cargo update +~/.cargo/bin/cargo build --release --target x86_64-apple-darwin +~/.cargo/bin/cargo build --release --target aarch64-apple-darwin +lipo -create -output "${REPO_HOME}/Source/Frameworks/gyroflow/target/libgyroflow_toolbox.dylib" "${REPO_HOME}/Source/Frameworks/gyroflow/target/x86_64-apple-darwin/release/libgyroflow_toolbox.dylib" "${REPO_HOME}/Source/Frameworks/gyroflow/target/aarch64-apple-darwin/release/libgyroflow_toolbox.dylib" +/bin/mv "${REPO_HOME}/Source/Frameworks/gyroflow/target/libgyroflow_toolbox.dylib" "${REPO_HOME}/Source/Frameworks/gyroflow/binary/libgyroflow_toolbox.dylib" +cd "${REPO_HOME}/Source/Frameworks/gyroflow/binary" +/usr/bin/install_name_tool -id "@rpath/libgyroflow_toolbox.dylib" libgyroflow_toolbox.dylib \ No newline at end of file diff --git a/Source/Frameworks/gyroflow/Cargo.toml b/Source/Frameworks/gyroflow/Cargo.toml index d1912aff..9caeae16 100644 --- a/Source/Frameworks/gyroflow/Cargo.toml +++ b/Source/Frameworks/gyroflow/Cargo.toml @@ -13,7 +13,7 @@ argh = "*" serde = "1.0" serde_json = "1.0" libc = "0.2" -gyroflow-core = { git = "https://github.com/gyroflow/gyroflow.git", default-features = false, rev = "af4c575", features = ["bundle-lens-profiles"] } +gyroflow-core = { git = "https://github.com/gyroflow/gyroflow.git", default-features = false, rev = "6f60b83", features = ["bundle-lens-profiles"] } log = "0.4.17" oslog = "0.2.0" lazy_static = "1.4.0" diff --git a/Source/Frameworks/gyroflow/inc/gyroflow.h b/Source/Frameworks/gyroflow/inc/gyroflow.h index 06989090..2effad82 100644 --- a/Source/Frameworks/gyroflow/inc/gyroflow.h +++ b/Source/Frameworks/gyroflow/inc/gyroflow.h @@ -30,6 +30,7 @@ const char* processFrame( double position_offset_y, double input_rotation, double video_rotation, + uint8_t fov_overview, void *in_mtl_texture, void *out_mtl_texture, void *command_queue diff --git a/Source/Frameworks/gyroflow/src/lib.rs b/Source/Frameworks/gyroflow/src/lib.rs index 683da700..bff9ef08 100644 --- a/Source/Frameworks/gyroflow/src/lib.rs +++ b/Source/Frameworks/gyroflow/src/lib.rs @@ -277,6 +277,7 @@ pub extern "C" fn processFrame( position_offset_y: f64, input_rotation: f64, video_rotation: f64, + fov_overview: u8, in_mtl_tex: *mut std::ffi::c_void, out_mtl_tex: *mut std::ffi::c_void, command_queue: *mut std::ffi::c_void, @@ -299,7 +300,7 @@ pub extern "C" fn processFrame( let unique_identifier_pointer = unsafe { CStr::from_ptr(unique_identifier) }; let unique_identifier_string = unique_identifier_pointer.to_string_lossy(); - //log::info!("[Gyroflow Toolbox] unique_identifier_string: {:?}", unique_identifier_string); + //log::info!("[Gyroflow Toolbox Rust] unique_identifier_string: {:?}", unique_identifier_string); //--------------------------------------------------------- // Get Pixel Format: @@ -382,7 +383,7 @@ pub extern "C" fn processFrame( //--------------------------------------------------------- // Return an error message is something fails: //--------------------------------------------------------- - log::error!("[Gyroflow Toolbox] Failed to import Gyroflow File: {:?}", e); + log::error!("[Gyroflow Toolbox Rust] Failed to import Gyroflow File: {:?}", e); } } @@ -393,9 +394,20 @@ pub extern "C" fn processFrame( //--------------------------------------------------------- // Have parameters changed: //--------------------------------------------------------- - let mut params_changed = false; + let mut params_changed = false; { let mut params = manager.params.write(); + + //--------------------------------------------------------- + // Set the FOV Overview: + //--------------------------------------------------------- + let incoming_fov_overview = fov_overview != 0; + if incoming_fov_overview != params.fov_overview { + log::error!("[Gyroflow Toolbox Rust] FOV Changed!"); + params.fov_overview = incoming_fov_overview; + params_changed = true; + } + //--------------------------------------------------------- // Set the FOV: //--------------------------------------------------------- @@ -512,7 +524,7 @@ pub extern "C" fn processFrame( //--------------------------------------------------------- // Output the Stabilization result to the Console: //--------------------------------------------------------- - //log::info!("[Gyroflow Toolbox] stabilization_result: {:?}", &_stabilization_result); + //log::info!("[Gyroflow Toolbox Rust] stabilization_result: {:?}", &_stabilization_result); //--------------------------------------------------------- // Return "DONE": diff --git a/Source/Gyroflow/Plugin/GyroflowConstants.h b/Source/Gyroflow/Plugin/GyroflowConstants.h index 688d9f1e..a5c5d280 100644 --- a/Source/Gyroflow/Plugin/GyroflowConstants.h +++ b/Source/Gyroflow/Plugin/GyroflowConstants.h @@ -65,7 +65,7 @@ enum { //--------------------------------------------------------- kCB_ToolsSection = 300, - kCB_StabilisationOverview = 310, + kCB_FieldOfViewOverview = 310, //--------------------------------------------------------- // File Management: diff --git a/Source/Gyroflow/Plugin/GyroflowParameters.h b/Source/Gyroflow/Plugin/GyroflowParameters.h index 668d9b60..9004bbb5 100644 --- a/Source/Gyroflow/Plugin/GyroflowParameters.h +++ b/Source/Gyroflow/Plugin/GyroflowParameters.h @@ -23,6 +23,8 @@ NSNumber *positionOffsetY; NSNumber *inputRotation; NSNumber *videoRotation; + + NSNumber *fovOverview; } @property (nonatomic, copy) NSString *uniqueIdentifier; @@ -40,4 +42,6 @@ @property (nonatomic, copy) NSNumber *inputRotation; @property (nonatomic, copy) NSNumber *videoRotation; +@property (nonatomic, copy) NSNumber *fovOverview; + @end diff --git a/Source/Gyroflow/Plugin/GyroflowParameters.m b/Source/Gyroflow/Plugin/GyroflowParameters.m index 3eb2ae39..bb841a1c 100644 --- a/Source/Gyroflow/Plugin/GyroflowParameters.m +++ b/Source/Gyroflow/Plugin/GyroflowParameters.m @@ -31,6 +31,8 @@ @implementation GyroflowParameters @synthesize inputRotation; @synthesize videoRotation; +@synthesize fovOverview; + + (BOOL)supportsSecureCoding { return YES; @@ -52,6 +54,8 @@ - (void)dealloc { [inputRotation release]; [videoRotation release]; + [fovOverview release]; + [super dealloc]; } @@ -71,6 +75,8 @@ - (id)initWithCoder:(NSCoder *)decoder { self.positionOffsetY = [decoder decodeObjectOfClass:[NSNumber class] forKey:@"positionOffsetY"]; self.inputRotation = [decoder decodeObjectOfClass:[NSNumber class] forKey:@"inputRotation"]; self.videoRotation = [decoder decodeObjectOfClass:[NSNumber class] forKey:@"videoRotation"]; + + self.fovOverview = [decoder decodeObjectOfClass:[NSNumber class] forKey:@"fovOverview"]; } return self; } @@ -90,6 +96,8 @@ - (void)encodeWithCoder:(NSCoder *)encoder { [encoder encodeObject:positionOffsetY forKey:@"positionOffsetY"]; [encoder encodeObject:inputRotation forKey:@"inputRotation"]; [encoder encodeObject:videoRotation forKey:@"videoRotation"]; + + [encoder encodeObject:fovOverview forKey:@"fovOverview"]; } @end diff --git a/Source/Gyroflow/Plugin/GyroflowPlugIn.m b/Source/Gyroflow/Plugin/GyroflowPlugIn.m index 1052ca4d..b9d7e0fa 100644 --- a/Source/Gyroflow/Plugin/GyroflowPlugIn.m +++ b/Source/Gyroflow/Plugin/GyroflowPlugIn.m @@ -766,11 +766,11 @@ - (BOOL)addParametersWithError:(NSError**)error // ADD PARAMETER: 'Stabilisation Overview' Check Box //--------------------------------------------------------- if (![paramAPI addToggleButtonWithName:@"Stabilisation Overview" - parameterID:kCB_StabilisationOverview + parameterID:kCB_FieldOfViewOverview defaultValue:NO parameterFlags:kFxParameterFlag_DEFAULT]) { if (error != NULL) { - NSDictionary* userInfo = @{NSLocalizedDescriptionKey : @"[Gyroflow Toolbox Renderer] Unable to add parameter: kCB_StabilisationOverview"}; + NSDictionary* userInfo = @{NSLocalizedDescriptionKey : @"[Gyroflow Toolbox Renderer] Unable to add parameter: kCB_FieldOfViewOverview"}; *error = [NSError errorWithDomain:FxPlugErrorDomain code:kFxError_InvalidParameter userInfo:userInfo]; @@ -1188,6 +1188,13 @@ - (BOOL)pluginState:(NSData**)pluginState [paramGetAPI getFloatValue:&videoRotation fromParameter:kCB_VideoRotation atTime:renderTime]; params.videoRotation = [NSNumber numberWithDouble:videoRotation]; + //--------------------------------------------------------- + // FOV Overview: + //--------------------------------------------------------- + BOOL fovOverview; + [paramGetAPI getBoolValue:&fovOverview fromParameter:kCB_FieldOfViewOverview atTime:renderTime]; + params.fovOverview = [NSNumber numberWithBool:fovOverview]; + //--------------------------------------------------------- // Write the parameters to the pluginState as `NSData`: //--------------------------------------------------------- @@ -1349,6 +1356,8 @@ - (BOOL)renderDestinationImage:(FxImageTile *)destinationImage NSNumber *inputRotation = params.inputRotation; NSNumber *videoRotation = params.videoRotation; + NSNumber *fovOverview = params.fovOverview; + //NSLog(@"[Gyroflow Toolbox Renderer] uniqueIdentifier: '%@'", uniqueIdentifier); //--------------------------------------------------------- @@ -1740,7 +1749,10 @@ - (BOOL)renderDestinationImage:(FxImageTile *)destinationImage double sourcePositionOffsetY = [positionOffsetY doubleValue]; double sourceInputRotation = [inputRotation doubleValue]; double sourceVideoRotation = [videoRotation doubleValue]; - + uint8_t sourceFOVOverview = [fovOverview unsignedCharValue]; + + NSLog(@"[Gyroflow Toolbox Renderer] sourceFOVOverview: %hhu", sourceFOVOverview); + //--------------------------------------------------------- // Only trigger the Rust function if we have Gyroflow Data: //--------------------------------------------------------- @@ -1766,6 +1778,7 @@ - (BOOL)renderDestinationImage:(FxImageTile *)destinationImage sourcePositionOffsetY, // double sourceInputRotation, // double sourceVideoRotation, // double + sourceFOVOverview, // uint8_t inputTexture, // MTLTexture outputTexture, // MTLTexture commandQueue // MTLCommandQueue