Skip to content

Commit

Permalink
Added Unique Identifier Attribute
Browse files Browse the repository at this point in the history
- Updated to `gyroflow_core` `64178f8`.
- Added a unique identifier attribute. Currently not used for anything.
  • Loading branch information
latenitefilms committed Jul 13, 2023
1 parent cb681be commit e0c0cc6
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 9 deletions.
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 = "fa45053", features = ["bundle-lens-profiles"] }
gyroflow-core = { git = "https://github.com/gyroflow/gyroflow.git", default-features = false, rev = "64178f8", 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 @@ -13,6 +13,7 @@
// This is the "interface" to the Rust code:
//
const char* processFrame(
const char* unique_identifier,
uint32_t width,
uint32_t height,
const char* pixel_format,
Expand Down
9 changes: 9 additions & 0 deletions Source/Frameworks/gyroflow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ lazy_static! {
//---------------------------------------------------------
#[no_mangle]
pub extern "C" fn processFrame(
unique_identifier: *const c_char,
width: u32,
height: u32,
pixel_format: *const c_char,
Expand Down Expand Up @@ -68,6 +69,14 @@ pub extern "C" fn processFrame(
Mutex::new(logger)
});

//---------------------------------------------------------
// Get the Unique Identifier:
//---------------------------------------------------------
let unique_identifier_pointer = unsafe { CStr::from_ptr(unique_identifier) };
let unique_identifier_string = unique_identifier_pointer.to_string_lossy();

log::info!("[Gyroflow Toolbox] stabilization_result: {:?}", unique_identifier_string);

//---------------------------------------------------------
// Get Pixel Format:
//---------------------------------------------------------
Expand Down
11 changes: 10 additions & 1 deletion Source/Gyroflow/Plugin/GyroflowConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
// Plugin Parameter Constants:
//---------------------------------------------------------
enum {
kCB_Header = 1,

kCB_DropZone = 10,

kCB_LaunchGyroflow = 20,
kCB_LoadLastGyroflowProject = 25,
kCB_ImportGyroflowProject = 30,
Expand All @@ -25,6 +26,9 @@ enum {
kCB_GyroflowProjectBookmarkData = 70,
kCB_GyroflowProjectData = 80,

//---------------------------------------------------------
// Parameters:
//---------------------------------------------------------
kCB_GyroflowParameters = 90,
kCB_FOV = 100,
kCB_Smoothness = 110,
Expand All @@ -38,6 +42,11 @@ enum {
kCB_InputRotation = 170,
kCB_VideoRotation = 180,
kCB_VideoSpeed = 190,

//---------------------------------------------------------
// Hidden Metadata:
//---------------------------------------------------------
kCB_UniqueIdentifier = 500,
};

//---------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion Source/Gyroflow/Plugin/GyroflowParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
//---------------------------------------------------------
// Plugin Parameters:
//---------------------------------------------------------
@interface GyroflowParameters : NSObject <NSCoding, NSSecureCoding> {
@interface GyroflowParameters : NSObject <NSCoding, NSSecureCoding> {
NSString *uniqueIdentifier;
NSString *gyroflowPath;
NSString *gyroflowData;
NSNumber *timestamp;
Expand All @@ -24,6 +25,7 @@
NSNumber *videoRotation;
}

@property (nonatomic, copy) NSString *uniqueIdentifier;
@property (nonatomic, copy) NSString *gyroflowPath;
@property (nonatomic, copy) NSString *gyroflowData;
@property (nonatomic, copy) NSNumber *timestamp;
Expand Down
4 changes: 4 additions & 0 deletions Source/Gyroflow/Plugin/GyroflowParameters.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//---------------------------------------------------------
@implementation GyroflowParameters

@synthesize uniqueIdentifier;
@synthesize gyroflowPath;
@synthesize gyroflowData;
@synthesize timestamp;
Expand All @@ -36,6 +37,7 @@ + (BOOL)supportsSecureCoding
}

- (void)dealloc {
[uniqueIdentifier release];
[gyroflowPath release];
[gyroflowData release];
[timestamp release];
Expand All @@ -55,6 +57,7 @@ - (void)dealloc {

- (id)initWithCoder:(NSCoder *)decoder {
if (self = [super init]) {
self.uniqueIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"uniqueIdentifier"];
self.gyroflowPath = [decoder decodeObjectOfClass:[NSString class] forKey:@"gyroflowPath"];
self.gyroflowData = [decoder decodeObjectOfClass:[NSString class] forKey:@"gyroflowData"];
self.timestamp = [decoder decodeObjectOfClass:[NSNumber class] forKey:@"timestamp"];
Expand All @@ -73,6 +76,7 @@ - (id)initWithCoder:(NSCoder *)decoder {
}

- (void)encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:uniqueIdentifier forKey:@"uniqueIdentifier"];
[encoder encodeObject:gyroflowPath forKey:@"gyroflowPath"];
[encoder encodeObject:gyroflowData forKey:@"gyroflowData"];
[encoder encodeObject:timestamp forKey:@"timestamp"];
Expand Down
71 changes: 68 additions & 3 deletions Source/Gyroflow/Plugin/GyroflowPlugIn.m
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,25 @@ - (BOOL)addParametersWithError:(NSError**)error
return NO;
}

//

//---------------------------------------------------------
// ADD PARAMETER: Unique Identifier
//---------------------------------------------------------
if (![paramAPI addStringParameterWithName:@"Unique Identifier"
parameterID:kCB_UniqueIdentifier
defaultValue:@""
parameterFlags:kFxParameterFlag_DISABLED])
{
if (error != NULL) {
NSDictionary* userInfo = @{NSLocalizedDescriptionKey : @"[Gyroflow Toolbox Renderer] Unable to add parameter: kCB_UniqueIdentifier"};
*error = [NSError errorWithDomain:FxPlugErrorDomain
code:kFxError_InvalidParameter
userInfo:userInfo];
}
return NO;
}

return YES;
}

Expand Down Expand Up @@ -743,6 +762,33 @@ - (BOOL)pluginState:(NSData**)pluginState
NSLog(@"---------------------------------");
*/

//---------------------------------------------------------
// Unique Identifier:
//---------------------------------------------------------
NSString *uniqueIdentifier;
[paramGetAPI getStringParameterValue:&uniqueIdentifier fromParameter:kCB_UniqueIdentifier];

if (uniqueIdentifier == nil || [uniqueIdentifier isEqualToString:@""]) {
NSLog(@"[Gyroflow Toolbox Renderer] pluginState was handed a clip that doesn't already have a unique identifier!");

//---------------------------------------------------------
// Load the Parameter Set API:
//---------------------------------------------------------
id<FxParameterSettingAPI_v5> paramSetAPI = [_apiManager apiForProtocol:@protocol(FxParameterSettingAPI_v5)];
if (paramSetAPI == nil)
{
NSLog(@"[Gyroflow Toolbox Renderer] Failed to load paramSetAPI in pluginState!");
}

NSUUID *uuid = [NSUUID UUID];
uniqueIdentifier = uuid.UUIDString;
[paramSetAPI setStringParameterValue:uniqueIdentifier toParameter:kCB_UniqueIdentifier];
}

params.uniqueIdentifier = uniqueIdentifier;

NSLog(@"[Gyroflow Toolbox Renderer] Unique Identifier in Plugin State: %@", uniqueIdentifier);

//---------------------------------------------------------
// Gyroflow Path:
//---------------------------------------------------------
Expand Down Expand Up @@ -957,6 +1003,7 @@ - (BOOL)renderDestinationImage:(FxImageTile *)destinationImage
//---------------------------------------------------------
// Get the parameter data:
//---------------------------------------------------------
NSString *uniqueIdentifier = params.uniqueIdentifier;
NSNumber *timestamp = params.timestamp;
NSString *gyroflowPath = params.gyroflowPath;
NSString *gyroflowData = params.gyroflowData;
Expand All @@ -971,6 +1018,15 @@ - (BOOL)renderDestinationImage:(FxImageTile *)destinationImage
NSNumber *inputRotation = params.inputRotation;
NSNumber *videoRotation = params.videoRotation;

if (uniqueIdentifier == nil || [uniqueIdentifier isEqualToString:@""]) {
NSLog(@"[Gyroflow Toolbox Renderer] BUG! uniqueIdentifier was not valid during render!");

NSUUID *uuid = [NSUUID UUID];
uniqueIdentifier = uuid.UUIDString;
}

NSLog(@"[Gyroflow Toolbox Renderer] uniqueIdentifier during render: %@", uniqueIdentifier);

//---------------------------------------------------------
// Set up the renderer, in this case we are using Metal.
//---------------------------------------------------------
Expand Down Expand Up @@ -1038,6 +1094,7 @@ - (BOOL)renderDestinationImage:(FxImageTile *)destinationImage
//---------------------------------------------------------
// Collect all the Parameters for Gyroflow:
//---------------------------------------------------------
const char* sourceUniqueIdentifier = [uniqueIdentifier UTF8String];
uint32_t sourceWidth = (uint32_t)inputTexture.width;
uint32_t sourceHeight = (uint32_t)inputTexture.height;
const char* sourcePixelFormat = [inputPixelFormat UTF8String];
Expand All @@ -1062,6 +1119,7 @@ - (BOOL)renderDestinationImage:(FxImageTile *)destinationImage
// Trigger the Gyroflow Rust Function:
//---------------------------------------------------------
const char* result = processFrame(
sourceUniqueIdentifier, // const char*
sourceWidth, // uint32_t
sourceHeight, // uint32_t
sourcePixelFormat, // const char*
Expand Down Expand Up @@ -1498,7 +1556,7 @@ - (void)requestSandboxAccessWithURL:(NSURL*)gyroflowPlistURL {

if (bookmarkError != nil) {
NSString *errorMessage = [NSString stringWithFormat:@"Failed to create a security-scoped bookmark due to the following error:\n\n %@", [bookmarkError localizedDescription]];
NSLog(@"[Gyroflow Toolbox] %@", errorMessage);
NSLog(@"[Gyroflow Toolbox Renderer] %@", errorMessage);
[self showAlertWithMessage:@"An error has occurred" info:errorMessage];
[url stopAccessingSecurityScopedResource];
return;
Expand All @@ -1510,7 +1568,7 @@ - (void)requestSandboxAccessWithURL:(NSURL*)gyroflowPlistURL {
return;
}

//NSLog(@"[Gyroflow Toolbox] Bookmark created successfully for: %@", [url path]);
//NSLog(@"[Gyroflow Toolbox Renderer] Bookmark created successfully for: %@", [url path]);

NSUserDefaults *userDefaults = [[NSUserDefaults alloc] init];
[userDefaults setObject:bookmark forKey:@"gyroFlowPreferencesBookmarkData"];
Expand Down Expand Up @@ -1718,7 +1776,7 @@ - (void)importGyroflowProjectWithOptionalURL:(NSURL*)optionalURL {
NSString *selectedGyroflowProjectFile = [[url lastPathComponent] stringByDeletingPathExtension];
NSString *selectedGyroflowProjectPath = [url path];
NSString *selectedGyroflowProjectBookmarkData = [bookmark base64EncodedStringWithOptions:0];

//---------------------------------------------------------
// Read the Gyroflow Project Data from File:
//---------------------------------------------------------
Expand Down Expand Up @@ -1806,6 +1864,13 @@ - (void)importGyroflowProjectWithOptionalURL:(NSURL*)optionalURL {
return;
}

//---------------------------------------------------------
// Generate a unique identifier:
//---------------------------------------------------------
NSUUID *uuid = [NSUUID UUID];
NSString *uniqueIdentifier = uuid.UUIDString;
[paramSetAPI setStringParameterValue:uniqueIdentifier toParameter:kCB_UniqueIdentifier];

//---------------------------------------------------------
// Update 'Gyroflow Project Path':
//---------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
<savePreviewMovie>0</savePreviewMovie>
<Object3DEnvironments>100</Object3DEnvironments>
<DRTSupport>0</DRTSupport>
<onHDRDisplay>1</onHDRDisplay>
<onHDRDisplay>0</onHDRDisplay>
</sceneSettings>
<publishSettings>
<version>2</version>
Expand All @@ -172,6 +172,7 @@
<target object="10036" channel="./90" name="Gyroflow Parameters"/>
</publishSettings>
<currentFrame>36864 153600 1 0</currentFrame>
<currentObject>10016</currentObject>
<activeLayer>10013</activeLayer>
<timeRange offset="0 1 1 0" duration="1536000 153600 1 0"/>
<playRange offset="0 1 1 0" duration="1536000 153600 1 0"/>
Expand Down Expand Up @@ -207,7 +208,7 @@
<aspectRatio>1</aspectRatio>
<flags>0</flags>
<timing in="0 1 1 0" out="1529856 153600 1 0" offset="0 1 1 0"/>
<foldFlags>16384</foldFlags>
<foldFlags>24576</foldFlags>
<baseFlags>524304</baseFlags>
<parameter name="Properties" id="1" flags="8589938704">
<parameter name="Cinematic" id="344" flags="8589938706">
Expand Down Expand Up @@ -259,7 +260,7 @@
</parameter>
<filter name="Gyroflow Toolbox" id="10036" factoryID="6" pluginUUID="92ADB2F9-C649-48C2-B2D4-441CFC0633CB" pluginVersion="1" pluginName="Gyroflow Toolbox" pluginDynamicParams="0">
<timing in="0 1 1 0" out="1529856 153600 1 0" offset="0 1 1 0"/>
<baseFlags>8589934608</baseFlags>
<baseFlags>8589934609</baseFlags>
<parameter name="Drop Zone" id="10" flags="12884901904">
<numberOfKeypoints>0</numberOfKeypoints>
<defaultVal>*********J2eMb-gOLBoA11I*E61-*I4-klM75NZQbBdPqtN743mMqVdRaJmJ0FoPr-M74xWOaJXR5AG**44c3wE1otHGqJtNKF-QaBcOLNZQh660Ec9L2FVR437QolZNq3XSJwE1o7gOKtYF43oMIxWOaJXR6*0U*4X1EsDJGFiRKlgHl0GMb-gOLBoA11I*E61-*I4-kdM75NZQbBdPqtN743mMqVdRaJmJ0FoPr-M74xWOaJXR5AG**44c3wE1otHGqJtNKF-QaBcOLNZQh260Jh1RLBoPqoUF43oMM*-cUgAJGFiRKlg2**62FcY8H6rGIlMKZpX*********E2*********1E*******************4I6**U*2E*O*0E*8E*m*1Q*GE-C*3g*PE-j*52*RE-v*F*********0*E*********E*******************-2E**</defaultVal>
Expand Down Expand Up @@ -302,6 +303,7 @@
<parameter name="Input Rotation" id="170" flags="12884901904" default="0" value="0"/>
<parameter name="Video Rotation" id="180" flags="12884901904" default="0" value="0"/>
</parameter>
<parameter name="Unique Identifier" id="500" flags="12884967428"/>
<parameter name="Mix" id="10001" flags="12884901888" default="1" value="1"/>
<parameter name="Flip" id="10002" flags="12889161760" default="0" value="0"/>
<parameter name="Input Points" id="10003" flags="12889161760" default="1" value="1"/>
Expand Down

0 comments on commit e0c0cc6

Please sign in to comment.