summaryrefslogtreecommitdiff
path: root/gpr/source/lib/gpr_sdk/private/gpr_exif_info.cpp
blob: 4b1e9bcf2d5537386d6297de24e2a0660874475e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

#include "gpr_platform.h"
#include "gpr_exif_info.h"
#include "stdc_includes.h"

static gpr_signed_rational signed_rational_construct(int32_t numerator, int32_t denominator)
{
    gpr_signed_rational a;
    a.numerator     = numerator;
    a.denominator   = denominator;
    return a;
}

static gpr_unsigned_rational unsigned_rational_construct(int32_t numerator, int32_t denominator)
{
    gpr_unsigned_rational a;
    a.numerator     = numerator;
    a.denominator   = denominator;
    return a;
}

gpr_date_and_time construct_dng_date_and_time (uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t minute, uint32_t second)
{
    gpr_date_and_time x;
    x.year     = year;
    x.month    = month;
    x.day      = day;
    x.hour     = hour;
    x.minute   = minute;
    x.second   = second;
    
    return x;
}

void gpr_exif_info_set_defaults( gpr_exif_info* x )
{
    x->exposure_time = unsigned_rational_construct(1, 60);
    
    x->exposure_bias = signed_rational_construct( 0, 1 );
    
    double d_aperture = 2.8;
    
    x->f_stop_number = unsigned_rational_construct( (unsigned int)(d_aperture * 1000), 1000 );
    
    // Convert aperture to APEX
    double aperture_apex = log(d_aperture) / log(sqrt(2.0));
    
    x->aperture     = unsigned_rational_construct( (unsigned int)(aperture_apex * 1000), 1000 );    
    
    x->focal_length = unsigned_rational_construct(3, 1);
    
    x->digital_zoom = unsigned_rational_construct(1, 1);
    
    x->metering_mode = gpr_metering_mode_center_weighted_average;
    
    x->focal_length_in_35mm_film = 15;
    
    x->exposure_program = gpr_exposure_program_normal;
    
    x->light_source = gpr_light_source_auto;
    
    x->flash = gpr_flash_not_supported;
    
    x->sensing_method = gpr_sensing_method_chip_color_area;
    
    x->file_source = gpr_file_source_digital_still;
    
    x->scene_type = gpr_scene_type_directly_photographed;
    
    x->white_balance = gpr_white_balance_auto;
    
    x->exposure_mode = gpr_exposure_mode_auto;
    
    x->scene_capture_type = gpr_scene_capture_type_standard;
    
    x->gain_control = gpr_gain_control_normal;
    
    x->contrast = gpr_contrast_normal;
    
    x->saturation = gpr_saturation_normal;
    
    x->sharpness = gpr_sharpness_hard;
    
    x->iso_speed_rating = 232;
    
    x->date_time_original = construct_dng_date_and_time (2016, 03, 25, 15, 55, 23 );
    
    x->date_time_digitized = x->date_time_original;
    
    strcpy( x->camera_make, "GoPro" );

    strcpy( x->camera_model, "HERO6 Black" );
    
    sprintf( x->software_version, "%d.%d.%d", GPR_VERSION_MAJOR, GPR_VERSION_MINOR, GPR_VERSION_REVISION );

    strcpy( x->user_comment, "" );
}

void gpr_exif_info_get_camera_make_and_model( const gpr_exif_info* x, char camera_make_and_model[256] )
{
    strcpy(camera_make_and_model, x->camera_make );
    strcpy(camera_make_and_model + strlen(camera_make_and_model), " " );
    strcpy(camera_make_and_model + strlen(camera_make_and_model), x->camera_model );
}