Skip to content

Commit

Permalink
Add 'processing profiles'
Browse files Browse the repository at this point in the history
@masc4ii Now you can remove tonemapping checkbox completely, and replace it with processing profile selector, there are 4 profiles:
#define PROFILE_STANDARD    0   /* Gamma Corrected */
#define PROFILE_TONEMAPPED  1   /* Gamma Corrected + Tonemapped */
#define PROFILE_ALEXA_LOG   2   /* Alexa log (Also known as Log-C) */
#define PROFILE_LINEAR      3   /* Linear, idk who would want this */

Which you set with function: void processingSetImageProfile(processingObject_t * processing, int imageProfile);

More will be added in the future

Hope it didn't break the app, I think it should still compile with your version, I've tried to maintain backward compatibility(for the transition)

Look at release to see how I implemented the profile selector menu, you decide where to put the selector, top or bottom, mines currently at the top but I'll probably put it at the bottom once I add histogram.
  • Loading branch information
ilia3101 authored Aug 26, 2017
1 parent 5b14a7e commit 3824475
Show file tree
Hide file tree
Showing 10 changed files with 294 additions and 64 deletions.
5 changes: 4 additions & 1 deletion platform/cocoa/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ appname = "MLV App"
# List of all objects to link
objects = main.o video_mlv.o debayer.o amaze_demosaic.o raw_processing.o \
main_methods.o useful_methods.o background_thread.o matrix.o \
camera_matrices.o frame_caching.o lj92.o
camera_matrices.o frame_caching.o lj92.o session_methods.o

# Compiler
CC = gcc # Normal
Expand Down Expand Up @@ -54,6 +54,9 @@ main.o : main.m
main_methods.o : main_methods.m
$(CC) $(cflags) main_methods.m

session_methods.o : session_methods.m
$(CC) $(cflags) session_methods.m

background_thread.o : background_thread.m
$(CC) $(cflags) background_thread.m

Expand Down
19 changes: 13 additions & 6 deletions platform/cocoa/godobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,23 @@ typedef struct {
NSButton * alwaysUseAmazeSelector;
NSButton * tonemappingSelector;

/* Select image profile */
NSPopUpButton * imageProfile;

/****************************************
** SESSION STUFF **
****************************************/

/* Number of clips */
int clipCount;
/* List of clips loaded (in session) */
NSTableView * clipTable;
/* Info about each one (array as long as clipcount) */
clipInfo_t * clipInfo;
struct {

/* Number of clips */
int clipCount;
/* List of clips loaded (in session) */
NSTableView * clipTable;
/* Info about each one (array as long as clipcount) */
clipInfo_t * clipInfo;

} session;

/****************************************
** END OF SESSION STUFF **
Expand Down
48 changes: 21 additions & 27 deletions platform/cocoa/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
godObject_t * App;


/* Default image profile when app is loaded */
#define DEFAULT_IMAGE_PROFILE_APP PROFILE_TONEMAPPED


int main(int argc, char * argv[])
{
/* Apple documentation says this is right way to do things */
Expand Down Expand Up @@ -97,15 +101,18 @@ int NSApplicationMain(int argc, const char * argv[])
App->window.titlebarAppearsTransparent = true;

/* Processing style selector */
NSPopUpButton * processingStyle = [
[NSPopUpButton alloc]
initWithFrame: NSMakeRect( RIGHT_SIDEBAR_SLIDER(0,24,19) )
];
[processingStyle anchorRight: YES];
[processingStyle anchorTop: YES];
[processingStyle addItemWithTitle: @"Faithful"];
// [processingStyle addItemWithTitle: @"Milo"];
[[App->window contentView] addSubview: processingStyle];
App->imageProfile = [ [NSPopUpButton alloc]
initWithFrame: NSMakeRect( RIGHT_SIDEBAR_SLIDER(0,24,19) ) ];
[App->imageProfile anchorRight: YES];
[App->imageProfile anchorTop: YES];
[App->imageProfile insertItemWithTitle: @"Standard" atIndex: PROFILE_STANDARD];
[App->imageProfile insertItemWithTitle: @"Tonemapped" atIndex: PROFILE_TONEMAPPED];
[App->imageProfile insertItemWithTitle: @"Alexa Log" atIndex: PROFILE_ALEXA_LOG];
[App->imageProfile insertItemWithTitle: @"Linear" atIndex: PROFILE_LINEAR];
[App->imageProfile setTarget: App->imageProfile];
[App->imageProfile setAction: @selector(toggleImageProfile)];
[App->imageProfile selectItemAtIndex: DEFAULT_IMAGE_PROFILE_APP];
[[App->window contentView] addSubview: App->imageProfile];

/* Yes, macros - Az u can tell by the capietals.
* I don't want to add hundreds of lines of Objective C
Expand Down Expand Up @@ -135,7 +142,7 @@ int NSApplicationMain(int argc, const char * argv[])
/* Maybe we won't have sharpness */

/* Enable/disable highlight reconstruction */
App->highlightReconstructionSelector = [ [NSButton alloc]
App->highlightReconstructionSelector = [ [NSButton alloc]
initWithFrame: NSMakeRect( RIGHT_SIDEBAR_SLIDER(11, ELEMENT_HEIGHT, 16) )];
[App->highlightReconstructionSelector setButtonType: NSSwitchButton];
[App->highlightReconstructionSelector setTitle: @"Highlight Reconstruction"];
Expand All @@ -146,7 +153,7 @@ int NSApplicationMain(int argc, const char * argv[])
[[App->window contentView] addSubview: App->highlightReconstructionSelector];

/* To set always use AMaZE on/off */
App->alwaysUseAmazeSelector = [ [NSButton alloc]
App->alwaysUseAmazeSelector = [ [NSButton alloc]
initWithFrame: NSMakeRect( RIGHT_SIDEBAR_SLIDER(12, ELEMENT_HEIGHT, 30) )];
[App->alwaysUseAmazeSelector setButtonType: NSSwitchButton];
[App->alwaysUseAmazeSelector setTitle: @"Always use AMaZE"];
Expand All @@ -156,17 +163,6 @@ int NSApplicationMain(int argc, const char * argv[])
[App->alwaysUseAmazeSelector setAction: @selector(toggleAlwaysAmaze)];
[[App->window contentView] addSubview: App->alwaysUseAmazeSelector];

/* To set enable/disable tonemapping */
App->tonemappingSelector = [ [NSButton alloc]
initWithFrame: NSMakeRect( RIGHT_SIDEBAR_SLIDER(13, ELEMENT_HEIGHT, 44) )];
[App->tonemappingSelector setButtonType: NSSwitchButton];
[App->tonemappingSelector setTitle: @"Apply Tonemapping"];
[App->tonemappingSelector anchorRight: YES];
[App->tonemappingSelector anchorTop: YES];
[App->tonemappingSelector setTarget: App->tonemappingSelector];
[App->tonemappingSelector setAction: @selector(toggleTonemapping)];
[[App->window contentView] addSubview: App->tonemappingSelector];

/*
*******************************************************************************
* LEFT SIDEBAR STUFF
Expand All @@ -175,12 +171,8 @@ int NSApplicationMain(int argc, const char * argv[])

/* Open MLV file button */
CREATE_BUTTON_LEFT_TOP( App->openMLVButton, 0, openMlvDialog, 0, @"Open MLV File" );
/* Export an image sequence (temporary) - these buttons look awkward and awful :[ */
// CREATE_BUTTON_LEFT_BOTTOM( exportJpegSequenceButton, 1, exportJpegSequence, 1, @"Export JPEG Sequence" );
// CREATE_BUTTON_LEFT_BOTTOM( exportPngSequenceButton, 0, exportPngSequence, 1, @"Export PNG Sequence" );
// CREATE_BUTTON_LEFT_TOP( App->openMLVButton, 1, openMlvDialog, 6, @"Open Session" ); /* Commented out as not working yet */
CREATE_BUTTON_LEFT_BOTTOM( App->exportProRes4444Button, 0, exportProRes4444, 1, @"Export ProRes 4444" );
/* Black level user input/adjustment */
// CREATE_INPUT_WITH_LABEL_LEFT( blackLevelEntry, 1, blackLevelSet, 0, @"Black Level:" );

/* NSTableView - List of all clips currently open (session) */
// NSScrollView * tableContainer = [[NSScrollView alloc] initWithFrame:NSMakeRect(10, 10, 380, 200)];
Expand All @@ -206,6 +198,8 @@ int NSApplicationMain(int argc, const char * argv[])
/* Set exposure to + 1.2 stops instead of correct 0.0, this is to give the impression
* (to those that believe) that highlights are recoverable (shhh don't tell) */
processingSetExposureStops(App->processingSettings, 1.2);
/* TEST */
processingSetImageProfile(App->processingSettings, DEFAULT_IMAGE_PROFILE_APP);
/* Link video with processing settings */
setMlvProcessing(App->videoMLV, App->processingSettings);
/* Limit frame cache to suitable amount of RAM (~33% at 8GB and below, ~50% at 16GB, then up and up) */
Expand Down
12 changes: 10 additions & 2 deletions platform/cocoa/main_methods.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _main_methods_
#define _main_methods_
#ifndef _main_methods_h_
#define _main_methods_h_

/* Methods that actually do stuff related to MLV on user interface interactions */

Expand All @@ -25,6 +25,14 @@ void setAppNewMlvClip(char * mlvPathString, char * mlvFileName);

@end

/* NSPopUpButton methods */
@interface NSPopUpButton (mainMethods)

/* Select processing image profile */
-(void)toggleImageProfile;

@end

/* Slider methods */
@interface NSSlider (mainMethods)

Expand Down
16 changes: 15 additions & 1 deletion platform/cocoa/main_methods.m
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,22 @@ -(void)exportProRes4444

@end

/* Slider methods */

/* NSPopUpButton methods */
@implementation NSPopUpButton (mainMethods)

/* Select processing image profile */
-(void)toggleImageProfile
{
/* Indexes of menu items correspond to defines of processing profiles */
processingSetImageProfile(App->processingSettings, (int)[self indexOfSelectedItem]);
App->frameChanged++;
}

@end


/* Slider methods */
@implementation NSSlider (mainMethods)

/* Change frame based on time slider */
Expand Down
29 changes: 29 additions & 0 deletions platform/cocoa/session_methods.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef _session_methods_h_
#define _session_methods_h_

/* Methods/functions for handling sessions */


/* This is a function as it may be used in more than one place */
void sessionAddNewMlvClip(char * mlvPathString, char * mlvFileName);
/* Called from -(void)openSessionDialog - currently only loads first clip */
void appLoadSession(char * sessionPath);
/* Frees/deletes all mlv objects */
void appClearSession();


/* Button methods */
@interface NSButton (sessionMethods)

/* Opens a dialog to select MLV file + sets MLV file to that */
-(void)openSessionDialog;

@end


/* Slider methods */
@interface NSSlider (sessionMethods)

@end

#endif
84 changes: 84 additions & 0 deletions platform/cocoa/session_methods.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* Methods for user interface interactions
* this is where some real code goes */

#include <math.h>
#include <string.h>
#include <unistd.h>

#import "Cocoa/Cocoa.h"

#include "gui_stuff/app_design.h"

#include "main_methods.h"
#include "../../src/mlv_include.h"

#include "mac_info.h"

#include "background_thread.h"

/* God object used to share globals (type) */
#include "godobject.h"
/* The godobject itsself */
extern godObject_t * App;


/* Methods/functions for handling sessions */

/* This is a function as it may be used in more than one place */
void sessionAddNewMlvClip(char * mlvPathString, char * mlvFileName)
{
return;
/* Do clip adding stuff here... */
App->session.clipCount++;
}

/* Called from -(void)openSessionDialog - currently only loads first clip */
void appLoadSession(char * sessionPath)
{
/* Open the MASXML file 4 reading */
FILE * session_file = fopen(sessionPath, "rb");

/* Get size of file */
fseek(session_file, 0, SEEK_END);
uint64_t masxml_size = ftell(session_file);

/* Don't allow files over over 8MB */
if (masxml_size > (1 << 23)) return;

/* Read whole session in to memory */
char * session_xml = calloc(masxml_size, sizeof(char));
fread(session_xml, sizeof(char), masxml_size, session_file);
fclose(session_file);

/* Parse the XML... */

/* This will be boring to write :( */

free(session_xml);
}

/* Frees/deletes all mlv objects */
void appClearSession()
{
/* Not done as you can see */
App->session.clipCount = 0;
return;
}


/* Button methods */
@implementation NSButton (sessionMethods)

/* Opens a dialog to select MLV file + sets MLV file to that */
-(void)openSessionDialog
{
return;
}

@end


/* Slider methods */
@implementation NSSlider (sessionMethods)

@end
12 changes: 10 additions & 2 deletions src/processing/processing_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
/* Processing settings structure (a mess) */
typedef struct {

/* Image profile, options:
* STANDARD - Gamma Corrected
* TONEMAPPED - Gamma Corrected + Tonemapped
* ALEXA_LOG - Alexa log (Also known as Log-C)
* LINEAR - Linear, idk who would want this */
int image_profile;

/* (RAW) white and black levels */
int black_level, white_level;

Expand Down Expand Up @@ -61,11 +68,12 @@ typedef struct {
* will be calculated on setting changes, values 0-65535 */
uint16_t * pre_calc_curve_r;
uint16_t * pre_calc_curve_g;
uint16_t * pre_calc_curve_b;
uint16_t * pre_calc_curve_b; int use_rgb_curves; /* The r, g and b curves can be disabled */
uint16_t * pre_calc_levels; /* For black level and white level */
uint16_t * pre_calc_gamma;
uint16_t * pre_calc_o_curve; int use_o_curve; /* Output curve - not always used */
/* Precalculated values for saturation */
int32_t * pre_calc_sat;
int32_t * pre_calc_sat; int use_saturation; /* Saturation is disable-able */

} processingObject_t;

Expand Down
Loading

1 comment on commit 3824475

@masc4ii
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE!

Please sign in to comment.