Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
- Updated `gyroflow_core`.
- Tweaked build scripts.
- Hooked up FOV Overview.
  • Loading branch information
latenitefilms committed Jul 14, 2023
1 parent bbc7980 commit 4853528
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Scripts/build_rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions Scripts/build_rust_update.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Source/Frameworks/gyroflow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Source/Frameworks/gyroflow/inc/gyroflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 16 additions & 4 deletions Source/Frameworks/gyroflow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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:
//---------------------------------------------------------
Expand Down Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion Source/Gyroflow/Plugin/GyroflowConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ enum {
//---------------------------------------------------------
kCB_ToolsSection = 300,

kCB_StabilisationOverview = 310,
kCB_FieldOfViewOverview = 310,

//---------------------------------------------------------
// File Management:
Expand Down
4 changes: 4 additions & 0 deletions Source/Gyroflow/Plugin/GyroflowParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
NSNumber *positionOffsetY;
NSNumber *inputRotation;
NSNumber *videoRotation;

NSNumber *fovOverview;
}

@property (nonatomic, copy) NSString *uniqueIdentifier;
Expand All @@ -40,4 +42,6 @@
@property (nonatomic, copy) NSNumber *inputRotation;
@property (nonatomic, copy) NSNumber *videoRotation;

@property (nonatomic, copy) NSNumber *fovOverview;

@end
8 changes: 8 additions & 0 deletions Source/Gyroflow/Plugin/GyroflowParameters.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ @implementation GyroflowParameters
@synthesize inputRotation;
@synthesize videoRotation;

@synthesize fovOverview;

+ (BOOL)supportsSecureCoding
{
return YES;
Expand All @@ -52,6 +54,8 @@ - (void)dealloc {
[inputRotation release];
[videoRotation release];

[fovOverview release];

[super dealloc];
}

Expand All @@ -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;
}
Expand All @@ -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
19 changes: 16 additions & 3 deletions Source/Gyroflow/Plugin/GyroflowPlugIn.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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`:
//---------------------------------------------------------
Expand Down Expand Up @@ -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);

//---------------------------------------------------------
Expand Down Expand Up @@ -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:
//---------------------------------------------------------
Expand All @@ -1766,6 +1778,7 @@ - (BOOL)renderDestinationImage:(FxImageTile *)destinationImage
sourcePositionOffsetY, // double
sourceInputRotation, // double
sourceVideoRotation, // double
sourceFOVOverview, // uint8_t
inputTexture, // MTLTexture
outputTexture, // MTLTexture
commandQueue // MTLCommandQueue
Expand Down

0 comments on commit 4853528

Please sign in to comment.