Make clang-format more aggressive
clang-format always manages to mix spaces into tab-based indentation. Since we already require an exact tab-width of 8 it makes more sense to use spaces.
This commit is contained in:
@@ -13,7 +13,7 @@ AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
@@ -26,8 +26,8 @@ AlwaysBreakAfterDefinitionReturnType: All
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
@@ -37,24 +37,24 @@ BraceWrapping:
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
#AfterExternBlock: false # Unknown to clang-format-5.0
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
#SplitEmptyFunction: true # Unknown to clang-format-4.0
|
||||
#SplitEmptyRecord: true # Unknown to clang-format-4.0
|
||||
#SplitEmptyNamespace: true # Unknown to clang-format-4.0
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Custom
|
||||
#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 85
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
#CompactNamespaces: false # Unknown to clang-format-4.0
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 8
|
||||
ContinuationIndentWidth: 8
|
||||
@@ -62,7 +62,7 @@ Cpp11BracedListStyle: false
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
#FixNamespaceComments: false # Unknown to clang-format-4.0
|
||||
FixNamespaceComments: false
|
||||
|
||||
# Taken from:
|
||||
# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \
|
||||
@@ -494,13 +494,13 @@ ForEachMacros:
|
||||
- 'xbc_node_for_each_key_value'
|
||||
- 'zorro_for_each_dev'
|
||||
|
||||
#IncludeBlocks: Preserve # Unknown to clang-format-5.0
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IndentCaseLabels: false
|
||||
#IndentPPDirectives: None # Unknown to clang-format-5.0
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 8
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
@@ -510,31 +510,31 @@ MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 8
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
|
||||
# Taken from git's rules
|
||||
#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
|
||||
PenaltyBreakBeforeFirstCallParameter: 30
|
||||
PenaltyBreakComment: 10
|
||||
PenaltyBreakFirstLessLess: 0
|
||||
PenaltyBreakString: 10
|
||||
PenaltyExcessCharacter: 100
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
#PenaltyBreakAssignment: 10
|
||||
#PenaltyBreakBeforeFirstCallParameter: 30
|
||||
#PenaltyBreakComment: 10
|
||||
#PenaltyBreakFirstLessLess: 0
|
||||
#PenaltyBreakString: 10
|
||||
#PenaltyExcessCharacter: 100
|
||||
#PenaltyReturnTypeOnItsOwnLine: 60
|
||||
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SortIncludes: false
|
||||
#SortUsingDeclarations: false # Unknown to clang-format-4.0
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
|
||||
#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
@@ -544,5 +544,5 @@ SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp03
|
||||
TabWidth: 8
|
||||
UseTab: Always
|
||||
UseTab: Never
|
||||
...
|
||||
|
@@ -1,9 +1,3 @@
|
||||
.build_template: &build_definition
|
||||
script:
|
||||
- meson build
|
||||
- ninja -C build
|
||||
- ninja -C build test
|
||||
|
||||
build:debian:
|
||||
image: debian:bookworm-slim
|
||||
before_script:
|
||||
|
@@ -25,11 +25,12 @@ main()
|
||||
// for each pixel, there's room here to do some better debayering.
|
||||
vec3 color = vec3(samples.w, (samples.y + samples.z) / 2.0, samples.x);
|
||||
|
||||
// Some crude blacklevel correction to make the preview a bit nicer, this should be an uniform
|
||||
// Some crude blacklevel correction to make the preview a bit nicer, this
|
||||
// should be an uniform
|
||||
vec3 corrected = color - 0.02;
|
||||
|
||||
// Apply the color matrices
|
||||
//vec3 corrected = color_matrix * color2;
|
||||
// vec3 corrected = color_matrix * color2;
|
||||
|
||||
// Fast SRGB estimate. See https://mimosa-pudica.net/fast-gamma/
|
||||
vec3 srgb_color =
|
||||
|
53
src/camera.c
53
src/camera.c
@@ -277,7 +277,8 @@ mp_camera_new(int video_fd, int subdev_fd)
|
||||
camera->has_set_mode = false;
|
||||
camera->num_buffers = 0;
|
||||
camera->use_mplane = use_mplane;
|
||||
memset(camera->child_bg_pids, 0,
|
||||
memset(camera->child_bg_pids,
|
||||
0,
|
||||
sizeof(camera->child_bg_pids[0]) * MAX_BG_TASKS);
|
||||
return camera;
|
||||
}
|
||||
@@ -306,9 +307,11 @@ mp_camera_add_bg_task(MPCamera *camera, pid_t pid)
|
||||
return;
|
||||
} else {
|
||||
// error == -1, still running == 0
|
||||
if (waitpid(camera->child_bg_pids[i], &status,
|
||||
if (waitpid(camera->child_bg_pids[i],
|
||||
&status,
|
||||
WNOHANG) <= 0)
|
||||
continue; // consider errored wait still running
|
||||
continue; // consider errored wait still
|
||||
// running
|
||||
|
||||
if (WIFEXITED(status)) {
|
||||
// replace exited
|
||||
@@ -453,7 +456,8 @@ mp_camera_set_mode(MPCamera *camera, MPCameraMode *mode)
|
||||
struct v4l2_subdev_frame_interval interval = {};
|
||||
interval.pad = 0;
|
||||
interval.interval = mode->frame_interval;
|
||||
if (xioctl(camera->subdev_fd, VIDIOC_SUBDEV_S_FRAME_INTERVAL,
|
||||
if (xioctl(camera->subdev_fd,
|
||||
VIDIOC_SUBDEV_S_FRAME_INTERVAL,
|
||||
&interval) == -1) {
|
||||
errno_printerr("VIDIOC_SUBDEV_S_FRAME_INTERVAL");
|
||||
return false;
|
||||
@@ -477,13 +481,14 @@ mp_camera_set_mode(MPCamera *camera, MPCameraMode *mode)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Some drivers like ov5640 don't allow you to set the frame format with
|
||||
// too high a frame-rate, but that means the frame-rate won't be set
|
||||
// after the format change. So we need to try again here if we didn't
|
||||
// succeed before. Ideally we'd be able to set both at once.
|
||||
// Some drivers like ov5640 don't allow you to set the frame format
|
||||
// with too high a frame-rate, but that means the frame-rate won't be
|
||||
// set after the format change. So we need to try again here if we
|
||||
// didn't succeed before. Ideally we'd be able to set both at once.
|
||||
if (!did_set_frame_rate) {
|
||||
interval.interval = mode->frame_interval;
|
||||
if (xioctl(camera->subdev_fd, VIDIOC_SUBDEV_S_FRAME_INTERVAL,
|
||||
if (xioctl(camera->subdev_fd,
|
||||
VIDIOC_SUBDEV_S_FRAME_INTERVAL,
|
||||
&interval) == -1) {
|
||||
errno_printerr("VIDIOC_SUBDEV_S_FRAME_INTERVAL");
|
||||
}
|
||||
@@ -561,14 +566,20 @@ mp_camera_start_capture(MPCamera *camera)
|
||||
|
||||
if (camera->use_mplane) {
|
||||
camera->buffers[i].length = planes[0].length;
|
||||
camera->buffers[i].data =
|
||||
mmap(NULL, planes[0].length, PROT_READ, MAP_SHARED,
|
||||
camera->video_fd, planes[0].m.mem_offset);
|
||||
camera->buffers[i].data = mmap(NULL,
|
||||
planes[0].length,
|
||||
PROT_READ,
|
||||
MAP_SHARED,
|
||||
camera->video_fd,
|
||||
planes[0].m.mem_offset);
|
||||
} else {
|
||||
camera->buffers[i].length = buf.length;
|
||||
camera->buffers[i].data =
|
||||
mmap(NULL, buf.length, PROT_READ, MAP_SHARED,
|
||||
camera->video_fd, buf.m.offset);
|
||||
camera->buffers[i].data = mmap(NULL,
|
||||
buf.length,
|
||||
PROT_READ,
|
||||
MAP_SHARED,
|
||||
camera->video_fd,
|
||||
buf.m.offset);
|
||||
}
|
||||
|
||||
if (camera->buffers[i].data == MAP_FAILED) {
|
||||
@@ -792,7 +803,8 @@ get_subdev_modes(MPCamera *camera, bool (*check)(MPCamera *, MPCameraMode *))
|
||||
frame.pad = 0;
|
||||
frame.code = fmt.code;
|
||||
frame.which = V4L2_SUBDEV_FORMAT_TRY;
|
||||
if (xioctl(camera->subdev_fd, VIDIOC_SUBDEV_ENUM_FRAME_SIZE,
|
||||
if (xioctl(camera->subdev_fd,
|
||||
VIDIOC_SUBDEV_ENUM_FRAME_SIZE,
|
||||
&frame) == -1) {
|
||||
if (errno != EINVAL) {
|
||||
errno_printerr(
|
||||
@@ -875,7 +887,8 @@ get_video_modes(MPCamera *camera, bool (*check)(MPCamera *, MPCameraMode *))
|
||||
struct v4l2_frmsizeenum frame = {};
|
||||
frame.index = frame_index;
|
||||
frame.pixel_format = fmt.pixelformat;
|
||||
if (xioctl(camera->video_fd, VIDIOC_ENUM_FRAMESIZES,
|
||||
if (xioctl(camera->video_fd,
|
||||
VIDIOC_ENUM_FRAMESIZES,
|
||||
&frame) == -1) {
|
||||
if (errno != EINVAL) {
|
||||
errno_printerr("VIDIOC_ENUM_FRAMESIZES");
|
||||
@@ -1199,7 +1212,8 @@ mp_camera_list_controls(MPCamera *camera)
|
||||
};
|
||||
|
||||
strcpy(control.name, ctrl.name);
|
||||
memcpy(control.dimensions, ctrl.dims,
|
||||
memcpy(control.dimensions,
|
||||
ctrl.dims,
|
||||
sizeof(uint32_t) * V4L2_CTRL_MAX_DIMS);
|
||||
|
||||
MPControlList *new_item = malloc(sizeof(MPControlList));
|
||||
@@ -1261,7 +1275,8 @@ mp_camera_query_control(MPCamera *camera, uint32_t id, MPControl *control)
|
||||
control->element_size = ctrl.elem_size;
|
||||
control->element_count = ctrl.elems;
|
||||
control->dimensions_count = ctrl.nr_of_dims;
|
||||
memcpy(control->dimensions, ctrl.dims,
|
||||
memcpy(control->dimensions,
|
||||
ctrl.dims,
|
||||
sizeof(uint32_t) * V4L2_CTRL_MAX_DIMS);
|
||||
}
|
||||
return true;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <linux/v4l2-subdev.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
typedef enum {
|
||||
MP_PIXEL_FMT_UNSUPPORTED,
|
||||
|
@@ -1,14 +1,14 @@
|
||||
#include "camera_config.h"
|
||||
|
||||
#include "ini.h"
|
||||
#include "config.h"
|
||||
#include "ini.h"
|
||||
#include "matrix.h"
|
||||
#include <assert.h>
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <glib.h>
|
||||
#include <assert.h>
|
||||
|
||||
static struct mp_camera_config cameras[MP_MAX_CAMERAS];
|
||||
static size_t num_cameras = 0;
|
||||
@@ -37,8 +37,10 @@ find_config(char *conffile)
|
||||
}
|
||||
|
||||
// Check for a config file in XDG_CONFIG_HOME
|
||||
sprintf(conffile, "%s/megapixels/config/%s.ini",
|
||||
g_get_user_config_dir(), buf);
|
||||
sprintf(conffile,
|
||||
"%s/megapixels/config/%s.ini",
|
||||
g_get_user_config_dir(),
|
||||
buf);
|
||||
if (access(conffile, F_OK) != -1) {
|
||||
printf("Found config file at %s\n", conffile);
|
||||
return true;
|
||||
@@ -80,7 +82,9 @@ strtoint(const char *nptr, char **endptr, int base)
|
||||
}
|
||||
|
||||
static bool
|
||||
config_handle_camera_mode(const char *prefix, MPCameraMode *mode, const char *name,
|
||||
config_handle_camera_mode(const char *prefix,
|
||||
MPCameraMode *mode,
|
||||
const char *name,
|
||||
const char *value)
|
||||
{
|
||||
int prefix_length = strlen(prefix);
|
||||
@@ -109,7 +113,9 @@ config_handle_camera_mode(const char *prefix, MPCameraMode *mode, const char *na
|
||||
}
|
||||
|
||||
static int
|
||||
config_ini_handler(void *user, const char *section, const char *name,
|
||||
config_ini_handler(void *user,
|
||||
const char *section,
|
||||
const char *name,
|
||||
const char *value)
|
||||
{
|
||||
if (strcmp(section, "device") == 0) {
|
||||
@@ -144,10 +150,10 @@ config_ini_handler(void *user, const char *section, const char *name,
|
||||
|
||||
struct mp_camera_config *cc = &cameras[index];
|
||||
|
||||
if (config_handle_camera_mode("capture-", &cc->capture_mode, name,
|
||||
value)) {
|
||||
} else if (config_handle_camera_mode("preview-", &cc->preview_mode,
|
||||
name, value)) {
|
||||
if (config_handle_camera_mode(
|
||||
"capture-", &cc->capture_mode, name, value)) {
|
||||
} else if (config_handle_camera_mode(
|
||||
"preview-", &cc->preview_mode, name, value)) {
|
||||
} else if (strcmp(name, "rotate") == 0) {
|
||||
cc->rotate = strtoint(value, NULL, 10);
|
||||
} else if (strcmp(name, "mirrored") == 0) {
|
||||
@@ -179,18 +185,28 @@ config_ini_handler(void *user, const char *section, const char *name,
|
||||
}
|
||||
g_strfreev(linkdefs);
|
||||
} else if (strcmp(name, "colormatrix") == 0) {
|
||||
sscanf(value, "%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
||||
cc->colormatrix + 0, cc->colormatrix + 1,
|
||||
cc->colormatrix + 2, cc->colormatrix + 3,
|
||||
cc->colormatrix + 4, cc->colormatrix + 5,
|
||||
cc->colormatrix + 6, cc->colormatrix + 7,
|
||||
sscanf(value,
|
||||
"%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
||||
cc->colormatrix + 0,
|
||||
cc->colormatrix + 1,
|
||||
cc->colormatrix + 2,
|
||||
cc->colormatrix + 3,
|
||||
cc->colormatrix + 4,
|
||||
cc->colormatrix + 5,
|
||||
cc->colormatrix + 6,
|
||||
cc->colormatrix + 7,
|
||||
cc->colormatrix + 8);
|
||||
} else if (strcmp(name, "forwardmatrix") == 0) {
|
||||
sscanf(value, "%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
||||
cc->forwardmatrix + 0, cc->forwardmatrix + 1,
|
||||
cc->forwardmatrix + 2, cc->forwardmatrix + 3,
|
||||
cc->forwardmatrix + 4, cc->forwardmatrix + 5,
|
||||
cc->forwardmatrix + 6, cc->forwardmatrix + 7,
|
||||
sscanf(value,
|
||||
"%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
||||
cc->forwardmatrix + 0,
|
||||
cc->forwardmatrix + 1,
|
||||
cc->forwardmatrix + 2,
|
||||
cc->forwardmatrix + 3,
|
||||
cc->forwardmatrix + 4,
|
||||
cc->forwardmatrix + 5,
|
||||
cc->forwardmatrix + 6,
|
||||
cc->forwardmatrix + 7,
|
||||
cc->forwardmatrix + 8);
|
||||
} else if (strcmp(name, "whitelevel") == 0) {
|
||||
cc->whitelevel = strtoint(value, NULL, 10);
|
||||
|
@@ -12,7 +12,10 @@ bool
|
||||
mp_find_device_path(struct media_v2_intf_devnode devnode, char *path, int length)
|
||||
{
|
||||
char uevent_path[256];
|
||||
snprintf(uevent_path, 256, "/sys/dev/char/%d:%d/uevent", devnode.major,
|
||||
snprintf(uevent_path,
|
||||
256,
|
||||
"/sys/dev/char/%d:%d/uevent",
|
||||
devnode.major,
|
||||
devnode.minor);
|
||||
|
||||
FILE *f = fopen(uevent_path, "r");
|
||||
@@ -151,7 +154,9 @@ mp_device_close(MPDevice *device)
|
||||
}
|
||||
|
||||
bool
|
||||
mp_device_setup_link(MPDevice *device, uint32_t source_pad_id, uint32_t sink_pad_id,
|
||||
mp_device_setup_link(MPDevice *device,
|
||||
uint32_t source_pad_id,
|
||||
uint32_t sink_pad_id,
|
||||
bool enabled)
|
||||
{
|
||||
const struct media_v2_pad *source_pad =
|
||||
|
10
src/device.h
10
src/device.h
@@ -5,8 +5,8 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
bool mp_find_device_path(struct media_v2_intf_devnode devnode, char *path,
|
||||
int length);
|
||||
bool
|
||||
mp_find_device_path(struct media_v2_intf_devnode devnode, char *path, int length);
|
||||
|
||||
typedef struct _MPDevice MPDevice;
|
||||
|
||||
@@ -15,8 +15,10 @@ MPDevice *mp_device_open(const char *path);
|
||||
MPDevice *mp_device_new(int fd);
|
||||
void mp_device_close(MPDevice *device);
|
||||
|
||||
bool mp_device_setup_link(MPDevice *device, uint32_t source_pad_id,
|
||||
uint32_t sink_pad_id, bool enabled);
|
||||
bool mp_device_setup_link(MPDevice *device,
|
||||
uint32_t source_pad_id,
|
||||
uint32_t sink_pad_id,
|
||||
bool enabled);
|
||||
|
||||
const struct media_device_info *mp_device_get_info(const MPDevice *device);
|
||||
const struct media_v2_entity *mp_device_find_entity(const MPDevice *device,
|
||||
|
44
src/flash.c
44
src/flash.c
@@ -1,10 +1,10 @@
|
||||
#include "flash.h"
|
||||
|
||||
#include "gtk/gtk.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
typedef enum {
|
||||
FLASH_TYPE_LED,
|
||||
@@ -68,11 +68,15 @@ dbus_brightness_init(GObject *src, GAsyncResult *res, gpointer *user_data)
|
||||
void
|
||||
mp_flash_gtk_init(GDBusConnection *conn)
|
||||
{
|
||||
g_dbus_proxy_new(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
|
||||
g_dbus_proxy_new(conn,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
NULL,
|
||||
"org.gnome.SettingsDaemon.Power",
|
||||
"/org/gnome/SettingsDaemon/Power",
|
||||
"org.gnome.SettingsDaemon.Power.Screen", NULL,
|
||||
(GAsyncReadyCallback)dbus_brightness_init, NULL);
|
||||
"org.gnome.SettingsDaemon.Power.Screen",
|
||||
NULL,
|
||||
(GAsyncReadyCallback)dbus_brightness_init,
|
||||
NULL);
|
||||
|
||||
// Create a full screen full white window as a flash
|
||||
GtkWidget *window = gtk_window_new();
|
||||
@@ -120,11 +124,17 @@ mp_flash_free(MPFlash *flash)
|
||||
static void
|
||||
set_display_brightness(int brightness)
|
||||
{
|
||||
g_dbus_proxy_call(
|
||||
dbus_brightness_proxy, "org.freedesktop.DBus.Properties.Set",
|
||||
g_variant_new("(ssv)", "org.gnome.SettingsDaemon.Power.Screen",
|
||||
"Brightness", g_variant_new("i", brightness)),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
|
||||
g_dbus_proxy_call(dbus_brightness_proxy,
|
||||
"org.freedesktop.DBus.Properties.Set",
|
||||
g_variant_new("(ssv)",
|
||||
"org.gnome.SettingsDaemon.Power.Screen",
|
||||
"Brightness",
|
||||
g_variant_new("i", brightness)),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -162,12 +172,16 @@ show_display_flash(MPFlash *flash)
|
||||
if (!dbus_brightness_proxy)
|
||||
return false;
|
||||
|
||||
g_dbus_proxy_call(
|
||||
dbus_brightness_proxy, "org.freedesktop.DBus.Properties.Get",
|
||||
g_variant_new("(ss)", "org.gnome.SettingsDaemon.Power.Screen",
|
||||
g_dbus_proxy_call(dbus_brightness_proxy,
|
||||
"org.freedesktop.DBus.Properties.Get",
|
||||
g_variant_new("(ss)",
|
||||
"org.gnome.SettingsDaemon.Power.Screen",
|
||||
"Brightness"),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1, NULL,
|
||||
(GAsyncReadyCallback)brightness_received, NULL);
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)brightness_received,
|
||||
NULL);
|
||||
|
||||
set_display_brightness(100);
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
#include "gl_util.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gio/gio.h>
|
||||
#include <gmodule.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <gio/gio.h>
|
||||
#include <gmodule.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
void
|
||||
gl_util_check_error(const char *file, int line)
|
||||
@@ -43,7 +43,9 @@ gl_util_check_error(const char *file, int line)
|
||||
}
|
||||
|
||||
GLuint
|
||||
gl_util_load_shader(const char *resource, GLenum type, const char **extra_sources,
|
||||
gl_util_load_shader(const char *resource,
|
||||
GLenum type,
|
||||
const char **extra_sources,
|
||||
size_t num_extra)
|
||||
{
|
||||
GdkGLContext *context = gdk_gl_context_get_current();
|
||||
@@ -65,9 +67,13 @@ gl_util_load_shader(const char *resource, GLenum type, const char **extra_source
|
||||
int major, minor;
|
||||
gdk_gl_context_get_version(context, &major, &minor);
|
||||
char context_info_buf[128];
|
||||
snprintf(context_info_buf, 128,
|
||||
snprintf(context_info_buf,
|
||||
128,
|
||||
"#define %s\n#define GL_%d\n#define GL_%d_%d\n",
|
||||
is_es ? "GL_ES" : "GL_NO_ES", major, major, minor);
|
||||
is_es ? "GL_ES" : "GL_NO_ES",
|
||||
major,
|
||||
major,
|
||||
minor);
|
||||
|
||||
gsize glib_size = 0;
|
||||
const GLchar *source = g_bytes_get_data(bytes, &glib_size);
|
||||
@@ -187,7 +193,9 @@ gl_util_new_quad()
|
||||
glGenBuffers(1, &buffer);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(quad_data), quad_data,
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
sizeof(quad_data),
|
||||
quad_data,
|
||||
GL_STATIC_DRAW);
|
||||
check_gl();
|
||||
|
||||
@@ -205,13 +213,17 @@ gl_util_bind_quad(GLuint buffer)
|
||||
assert(context);
|
||||
|
||||
if (gdk_gl_context_get_use_es(context)) {
|
||||
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE, 2, GL_FLOAT, 0, 0,
|
||||
quad_data);
|
||||
glVertexAttribPointer(
|
||||
GL_UTIL_VERTEX_ATTRIBUTE, 2, GL_FLOAT, 0, 0, quad_data);
|
||||
check_gl();
|
||||
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
||||
check_gl();
|
||||
|
||||
glVertexAttribPointer(GL_UTIL_TEX_COORD_ATTRIBUTE, 2, GL_FLOAT, 0, 0,
|
||||
glVertexAttribPointer(GL_UTIL_TEX_COORD_ATTRIBUTE,
|
||||
2,
|
||||
GL_FLOAT,
|
||||
0,
|
||||
0,
|
||||
quad_data + 8);
|
||||
check_gl();
|
||||
glEnableVertexAttribArray(GL_UTIL_TEX_COORD_ATTRIBUTE);
|
||||
@@ -220,13 +232,17 @@ gl_util_bind_quad(GLuint buffer)
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
check_gl();
|
||||
|
||||
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE, 2, GL_FLOAT,
|
||||
GL_FALSE, 0, 0);
|
||||
glVertexAttribPointer(
|
||||
GL_UTIL_VERTEX_ATTRIBUTE, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
||||
check_gl();
|
||||
|
||||
glVertexAttribPointer(GL_UTIL_TEX_COORD_ATTRIBUTE, 2, GL_FLOAT,
|
||||
GL_FALSE, 0, (void *)(8 * sizeof(float)));
|
||||
glVertexAttribPointer(GL_UTIL_TEX_COORD_ATTRIBUTE,
|
||||
2,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
0,
|
||||
(void *)(8 * sizeof(float)));
|
||||
glEnableVertexAttribArray(GL_UTIL_TEX_COORD_ATTRIBUTE);
|
||||
check_gl();
|
||||
}
|
||||
|
@@ -9,8 +9,10 @@
|
||||
#define check_gl() gl_util_check_error(__FILE__, __LINE__)
|
||||
void gl_util_check_error(const char *file, int line);
|
||||
|
||||
GLuint gl_util_load_shader(const char *resource, GLenum type,
|
||||
const char **extra_sources, size_t num_extra);
|
||||
GLuint gl_util_load_shader(const char *resource,
|
||||
GLenum type,
|
||||
const char **extra_sources,
|
||||
size_t num_extra);
|
||||
GLuint gl_util_link_program(GLuint *shaders, size_t num_shaders);
|
||||
|
||||
GLuint gl_util_new_quad();
|
||||
|
@@ -31,9 +31,13 @@ gles2_debayer_new(MPPixelFormat format)
|
||||
|
||||
GLuint shaders[] = {
|
||||
gl_util_load_shader("/org/postmarketos/Megapixels/debayer.vert",
|
||||
GL_VERTEX_SHADER, NULL, 0),
|
||||
GL_VERTEX_SHADER,
|
||||
NULL,
|
||||
0),
|
||||
gl_util_load_shader("/org/postmarketos/Megapixels/debayer.frag",
|
||||
GL_FRAGMENT_SHADER, NULL, 0),
|
||||
GL_FRAGMENT_SHADER,
|
||||
NULL,
|
||||
0),
|
||||
};
|
||||
|
||||
GLuint program = gl_util_link_program(shaders, 2);
|
||||
@@ -77,10 +81,14 @@ gles2_debayer_use(GLES2Debayer *self)
|
||||
}
|
||||
|
||||
void
|
||||
gles2_debayer_configure(GLES2Debayer *self, const uint32_t dst_width,
|
||||
const uint32_t dst_height, const uint32_t src_width,
|
||||
const uint32_t src_height, const uint32_t rotation,
|
||||
const bool mirrored, const float *colormatrix,
|
||||
gles2_debayer_configure(GLES2Debayer *self,
|
||||
const uint32_t dst_width,
|
||||
const uint32_t dst_height,
|
||||
const uint32_t src_width,
|
||||
const uint32_t src_height,
|
||||
const uint32_t rotation,
|
||||
const bool mirrored,
|
||||
const float *colormatrix,
|
||||
const uint8_t blacklevel)
|
||||
{
|
||||
glViewport(0, 0, dst_width, dst_height);
|
||||
@@ -113,8 +121,8 @@ gles2_debayer_configure(GLES2Debayer *self, const uint32_t dst_width,
|
||||
for (int j = 0; j < 3; ++j)
|
||||
transposed[i + j * 3] = colormatrix[j + i * 3];
|
||||
|
||||
glUniformMatrix3fv(self->uniform_color_matrix, 1, GL_FALSE,
|
||||
transposed);
|
||||
glUniformMatrix3fv(
|
||||
self->uniform_color_matrix, 1, GL_FALSE, transposed);
|
||||
} else {
|
||||
static const GLfloat identity[9] = {
|
||||
// clang-format off
|
||||
@@ -123,8 +131,8 @@ gles2_debayer_configure(GLES2Debayer *self, const uint32_t dst_width,
|
||||
0, 0, 1,
|
||||
// clang-format on
|
||||
};
|
||||
glUniformMatrix3fv(self->uniform_color_matrix, 1, GL_FALSE,
|
||||
identity);
|
||||
glUniformMatrix3fv(
|
||||
self->uniform_color_matrix, 1, GL_FALSE, identity);
|
||||
}
|
||||
check_gl();
|
||||
}
|
||||
@@ -134,8 +142,8 @@ gles2_debayer_process(GLES2Debayer *self, GLuint dst_id, GLuint source_id)
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, self->frame_buffer);
|
||||
glBindTexture(GL_TEXTURE_2D, dst_id);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||
dst_id, 0);
|
||||
glFramebufferTexture2D(
|
||||
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_id, 0);
|
||||
check_gl();
|
||||
|
||||
assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
|
||||
|
@@ -10,10 +10,14 @@ void gles2_debayer_free(GLES2Debayer *self);
|
||||
|
||||
void gles2_debayer_use(GLES2Debayer *self);
|
||||
|
||||
void gles2_debayer_configure(GLES2Debayer *self, const uint32_t dst_width,
|
||||
const uint32_t dst_height, const uint32_t src_width,
|
||||
const uint32_t src_height, const uint32_t rotation,
|
||||
const bool mirrored, const float *colormatrix,
|
||||
void gles2_debayer_configure(GLES2Debayer *self,
|
||||
const uint32_t dst_width,
|
||||
const uint32_t dst_height,
|
||||
const uint32_t src_width,
|
||||
const uint32_t src_height,
|
||||
const uint32_t rotation,
|
||||
const bool mirrored,
|
||||
const float *colormatrix,
|
||||
const uint8_t blacklevel);
|
||||
|
||||
void gles2_debayer_process(GLES2Debayer *self, GLuint dst_id, GLuint source_id);
|
||||
|
@@ -147,7 +147,8 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
|
||||
|
||||
info->video_fd = open(dev_name, O_RDWR);
|
||||
if (info->video_fd == -1) {
|
||||
g_printerr("Could not open %s: %s\n", dev_name,
|
||||
g_printerr("Could not open %s: %s\n",
|
||||
dev_name,
|
||||
strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -175,8 +176,10 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
|
||||
info->pad_id = pad->id;
|
||||
|
||||
// Make sure the camera starts out as disabled
|
||||
mp_device_setup_link(dev_info->device, info->pad_id,
|
||||
dev_info->interface_pad_id, false);
|
||||
mp_device_setup_link(dev_info->device,
|
||||
info->pad_id,
|
||||
dev_info->interface_pad_id,
|
||||
false);
|
||||
|
||||
const struct media_v2_interface *interface =
|
||||
mp_device_find_entity_interface(dev_info->device,
|
||||
@@ -189,7 +192,8 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
|
||||
|
||||
info->fd = open(info->dev_fname, O_RDWR);
|
||||
if (info->fd == -1) {
|
||||
g_printerr("Could not open %s: %s\n", info->dev_fname,
|
||||
g_printerr("Could not open %s: %s\n",
|
||||
info->dev_fname,
|
||||
strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -203,14 +207,14 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
|
||||
mp_camera_set_mode(info->camera, &mode);
|
||||
|
||||
// Trigger continuous auto focus if the sensor supports it
|
||||
if (mp_camera_query_control(info->camera, V4L2_CID_FOCUS_AUTO,
|
||||
NULL)) {
|
||||
if (mp_camera_query_control(
|
||||
info->camera, V4L2_CID_FOCUS_AUTO, NULL)) {
|
||||
info->has_auto_focus_continuous = true;
|
||||
mp_camera_control_set_bool_bg(info->camera,
|
||||
V4L2_CID_FOCUS_AUTO, true);
|
||||
mp_camera_control_set_bool_bg(
|
||||
info->camera, V4L2_CID_FOCUS_AUTO, true);
|
||||
}
|
||||
if (mp_camera_query_control(info->camera, V4L2_CID_AUTO_FOCUS_START,
|
||||
NULL)) {
|
||||
if (mp_camera_query_control(
|
||||
info->camera, V4L2_CID_AUTO_FOCUS_START, NULL)) {
|
||||
info->has_auto_focus_start = true;
|
||||
}
|
||||
|
||||
@@ -343,8 +347,8 @@ capture(MPPipeline *pipeline, const void *data)
|
||||
|
||||
// Disable the autogain/exposure while taking the burst
|
||||
mp_camera_control_set_int32(info->camera, V4L2_CID_AUTOGAIN, 0);
|
||||
mp_camera_control_set_int32(info->camera, V4L2_CID_EXPOSURE_AUTO,
|
||||
V4L2_EXPOSURE_MANUAL);
|
||||
mp_camera_control_set_int32(
|
||||
info->camera, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL);
|
||||
|
||||
// Change camera mode for capturing
|
||||
mp_process_pipeline_sync();
|
||||
@@ -383,8 +387,10 @@ release_buffer(MPPipeline *pipeline, const uint32_t *buffer_index)
|
||||
void
|
||||
mp_io_pipeline_release_buffer(uint32_t buffer_index)
|
||||
{
|
||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)release_buffer,
|
||||
&buffer_index, sizeof(uint32_t));
|
||||
mp_pipeline_invoke(pipeline,
|
||||
(MPPipelineCallback)release_buffer,
|
||||
&buffer_index,
|
||||
sizeof(uint32_t));
|
||||
}
|
||||
|
||||
static pid_t focus_continuous_task = 0;
|
||||
@@ -422,19 +428,21 @@ update_controls()
|
||||
}
|
||||
|
||||
if (current_controls.gain_is_manual != desired_controls.gain_is_manual) {
|
||||
mp_camera_control_set_bool_bg(info->camera, V4L2_CID_AUTOGAIN,
|
||||
mp_camera_control_set_bool_bg(info->camera,
|
||||
V4L2_CID_AUTOGAIN,
|
||||
!desired_controls.gain_is_manual);
|
||||
}
|
||||
|
||||
if (desired_controls.gain_is_manual &&
|
||||
current_controls.gain != desired_controls.gain) {
|
||||
mp_camera_control_set_int32_bg(info->camera, info->gain_ctrl,
|
||||
desired_controls.gain);
|
||||
mp_camera_control_set_int32_bg(
|
||||
info->camera, info->gain_ctrl, desired_controls.gain);
|
||||
}
|
||||
|
||||
if (current_controls.exposure_is_manual !=
|
||||
desired_controls.exposure_is_manual) {
|
||||
mp_camera_control_set_int32_bg(info->camera, V4L2_CID_EXPOSURE_AUTO,
|
||||
mp_camera_control_set_int32_bg(info->camera,
|
||||
V4L2_CID_EXPOSURE_AUTO,
|
||||
desired_controls.exposure_is_manual ?
|
||||
V4L2_EXPOSURE_MANUAL :
|
||||
V4L2_EXPOSURE_AUTO);
|
||||
@@ -442,8 +450,8 @@ update_controls()
|
||||
|
||||
if (desired_controls.exposure_is_manual &&
|
||||
current_controls.exposure != desired_controls.exposure) {
|
||||
mp_camera_control_set_int32_bg(info->camera, V4L2_CID_EXPOSURE,
|
||||
desired_controls.exposure);
|
||||
mp_camera_control_set_int32_bg(
|
||||
info->camera, V4L2_CID_EXPOSURE, desired_controls.exposure);
|
||||
}
|
||||
|
||||
current_controls = desired_controls;
|
||||
@@ -494,7 +502,8 @@ on_frame(MPBuffer buffer, void *_data)
|
||||
// Restore the auto exposure and gain if needed
|
||||
if (!current_controls.exposure_is_manual) {
|
||||
mp_camera_control_set_int32_bg(
|
||||
info->camera, V4L2_CID_EXPOSURE_AUTO,
|
||||
info->camera,
|
||||
V4L2_CID_EXPOSURE_AUTO,
|
||||
V4L2_EXPOSURE_AUTO);
|
||||
}
|
||||
|
||||
@@ -539,8 +548,10 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
|
||||
|
||||
mp_process_pipeline_sync();
|
||||
mp_camera_stop_capture(info->camera);
|
||||
mp_device_setup_link(dev_info->device, info->pad_id,
|
||||
dev_info->interface_pad_id, false);
|
||||
mp_device_setup_link(dev_info->device,
|
||||
info->pad_id,
|
||||
dev_info->interface_pad_id,
|
||||
false);
|
||||
}
|
||||
|
||||
if (capture_source) {
|
||||
@@ -554,8 +565,10 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
|
||||
struct camera_info *info = &cameras[camera->index];
|
||||
struct device_info *dev_info = &devices[info->device_index];
|
||||
|
||||
mp_device_setup_link(dev_info->device, info->pad_id,
|
||||
dev_info->interface_pad_id, true);
|
||||
mp_device_setup_link(dev_info->device,
|
||||
info->pad_id,
|
||||
dev_info->interface_pad_id,
|
||||
true);
|
||||
|
||||
mode = camera->preview_mode;
|
||||
mp_camera_set_mode(info->camera, &mode);
|
||||
@@ -599,7 +612,8 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
|
||||
desired_controls.exposure = state->exposure;
|
||||
|
||||
has_changed = has_changed ||
|
||||
memcmp(&previous_desired, &desired_controls,
|
||||
memcmp(&previous_desired,
|
||||
&desired_controls,
|
||||
sizeof(struct control_state)) != 0 ||
|
||||
flash_enabled != state->flash_enabled;
|
||||
|
||||
@@ -614,6 +628,8 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
|
||||
void
|
||||
mp_io_pipeline_update_state(const struct mp_io_pipeline_state *state)
|
||||
{
|
||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)update_state, state,
|
||||
mp_pipeline_invoke(pipeline,
|
||||
(MPPipelineCallback)update_state,
|
||||
state,
|
||||
sizeof(struct mp_io_pipeline_state));
|
||||
}
|
||||
|
247
src/main.c
247
src/main.c
@@ -154,8 +154,11 @@ mp_main_update_state(const struct mp_main_state *state)
|
||||
struct mp_main_state *state_copy = malloc(sizeof(struct mp_main_state));
|
||||
*state_copy = *state;
|
||||
|
||||
g_main_context_invoke_full(g_main_context_default(), G_PRIORITY_DEFAULT_IDLE,
|
||||
(GSourceFunc)update_state, state_copy, free);
|
||||
g_main_context_invoke_full(g_main_context_default(),
|
||||
G_PRIORITY_DEFAULT_IDLE,
|
||||
(GSourceFunc)update_state,
|
||||
state_copy,
|
||||
free);
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -178,8 +181,11 @@ set_zbar_result(MPZBarScanResult *result)
|
||||
void
|
||||
mp_main_set_zbar_result(MPZBarScanResult *result)
|
||||
{
|
||||
g_main_context_invoke_full(g_main_context_default(), G_PRIORITY_DEFAULT_IDLE,
|
||||
(GSourceFunc)set_zbar_result, result, NULL);
|
||||
g_main_context_invoke_full(g_main_context_default(),
|
||||
G_PRIORITY_DEFAULT_IDLE,
|
||||
(GSourceFunc)set_zbar_result,
|
||||
result,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -196,8 +202,11 @@ set_preview(MPProcessPipelineBuffer *buffer)
|
||||
void
|
||||
mp_main_set_preview(MPProcessPipelineBuffer *buffer)
|
||||
{
|
||||
g_main_context_invoke_full(g_main_context_default(), G_PRIORITY_DEFAULT_IDLE,
|
||||
(GSourceFunc)set_preview, buffer, NULL);
|
||||
g_main_context_invoke_full(g_main_context_default(),
|
||||
G_PRIORITY_DEFAULT_IDLE,
|
||||
(GSourceFunc)set_preview,
|
||||
buffer,
|
||||
NULL);
|
||||
}
|
||||
|
||||
struct capture_completed_args {
|
||||
@@ -229,8 +238,11 @@ mp_main_capture_completed(GdkTexture *thumb, const char *fname)
|
||||
malloc(sizeof(struct capture_completed_args));
|
||||
args->thumb = thumb;
|
||||
args->fname = g_strdup(fname);
|
||||
g_main_context_invoke_full(g_main_context_default(), G_PRIORITY_DEFAULT_IDLE,
|
||||
(GSourceFunc)capture_completed, args, free);
|
||||
g_main_context_invoke_full(g_main_context_default(),
|
||||
G_PRIORITY_DEFAULT_IDLE,
|
||||
(GSourceFunc)capture_completed,
|
||||
args,
|
||||
free);
|
||||
}
|
||||
|
||||
static GLuint blit_program;
|
||||
@@ -259,9 +271,13 @@ preview_realize(GtkGLArea *area)
|
||||
|
||||
GLuint blit_shaders[] = {
|
||||
gl_util_load_shader("/org/postmarketos/Megapixels/blit.vert",
|
||||
GL_VERTEX_SHADER, NULL, 0),
|
||||
GL_VERTEX_SHADER,
|
||||
NULL,
|
||||
0),
|
||||
gl_util_load_shader("/org/postmarketos/Megapixels/blit.frag",
|
||||
GL_FRAGMENT_SHADER, NULL, 0),
|
||||
GL_FRAGMENT_SHADER,
|
||||
NULL,
|
||||
0),
|
||||
};
|
||||
|
||||
blit_program = gl_util_link_program(blit_shaders, 2);
|
||||
@@ -274,9 +290,13 @@ preview_realize(GtkGLArea *area)
|
||||
|
||||
GLuint solid_shaders[] = {
|
||||
gl_util_load_shader("/org/postmarketos/Megapixels/solid.vert",
|
||||
GL_VERTEX_SHADER, NULL, 0),
|
||||
GL_VERTEX_SHADER,
|
||||
NULL,
|
||||
0),
|
||||
gl_util_load_shader("/org/postmarketos/Megapixels/solid.frag",
|
||||
GL_FRAGMENT_SHADER, NULL, 0),
|
||||
GL_FRAGMENT_SHADER,
|
||||
NULL,
|
||||
0),
|
||||
};
|
||||
|
||||
solid_program = gl_util_link_program(solid_shaders, 2);
|
||||
@@ -409,18 +429,28 @@ preview_draw(GtkGLArea *area, GdkGLContext *ctx, gpointer data)
|
||||
}
|
||||
|
||||
if (gtk_gl_area_get_use_es(area)) {
|
||||
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE, 2,
|
||||
GL_FLOAT, 0, 0, vertices);
|
||||
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE,
|
||||
2,
|
||||
GL_FLOAT,
|
||||
0,
|
||||
0,
|
||||
vertices);
|
||||
check_gl();
|
||||
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
||||
check_gl();
|
||||
} else {
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
|
||||
vertices, GL_STREAM_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
sizeof(vertices),
|
||||
vertices,
|
||||
GL_STREAM_DRAW);
|
||||
check_gl();
|
||||
|
||||
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE, 2,
|
||||
GL_FLOAT, GL_FALSE, 0, 0);
|
||||
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE,
|
||||
2,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
0,
|
||||
0);
|
||||
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
||||
check_gl();
|
||||
}
|
||||
@@ -467,7 +497,8 @@ run_open_last_action(GSimpleAction *action, GVariant *param, gpointer user_data)
|
||||
}
|
||||
sprintf(uri, "file://%s", last_path);
|
||||
if (!g_app_info_launch_default_for_uri(uri, NULL, &error)) {
|
||||
g_printerr("Could not launch image viewer for '%s': %s\n", uri,
|
||||
g_printerr("Could not launch image viewer for '%s': %s\n",
|
||||
uri,
|
||||
error->message);
|
||||
}
|
||||
}
|
||||
@@ -494,12 +525,21 @@ run_capture_action(GSimpleAction *action, GVariant *param, gpointer user_data)
|
||||
void
|
||||
run_about_action(GSimpleAction *action, GVariant *param, GApplication *app)
|
||||
{
|
||||
gtk_show_about_dialog(NULL, "program-name", "Megapixels", "title",
|
||||
"Megapixels", "logo-icon-name",
|
||||
"org.postmarketos.Megapixels", "comments",
|
||||
"The postmarketOS camera application", "website",
|
||||
"https://sr.ht/~martijnbraam/megapixels", "version",
|
||||
VERSION, "license-type", GTK_LICENSE_GPL_3_0_ONLY,
|
||||
gtk_show_about_dialog(NULL,
|
||||
"program-name",
|
||||
"Megapixels",
|
||||
"title",
|
||||
"Megapixels",
|
||||
"logo-icon-name",
|
||||
"org.postmarketos.Megapixels",
|
||||
"comments",
|
||||
"The postmarketOS camera application",
|
||||
"website",
|
||||
"https://sr.ht/~martijnbraam/megapixels",
|
||||
"version",
|
||||
VERSION,
|
||||
"license-type",
|
||||
GTK_LICENSE_GPL_3_0_ONLY,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -564,24 +604,35 @@ on_zbar_code_tapped(GtkWidget *widget, const MPZBarCode *code)
|
||||
|
||||
if (data_is_url) {
|
||||
dialog = gtk_message_dialog_new(
|
||||
GTK_WINDOW(gtk_widget_get_root(widget)), flags,
|
||||
GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
|
||||
"Found a URL '%s' encoded in a %s.", code->data, code->type);
|
||||
gtk_dialog_add_buttons(GTK_DIALOG(dialog), "_Open URL",
|
||||
GTK_RESPONSE_YES, NULL);
|
||||
GTK_WINDOW(gtk_widget_get_root(widget)),
|
||||
flags,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_NONE,
|
||||
"Found a URL '%s' encoded in a %s.",
|
||||
code->data,
|
||||
code->type);
|
||||
gtk_dialog_add_buttons(
|
||||
GTK_DIALOG(dialog), "_Open URL", GTK_RESPONSE_YES, NULL);
|
||||
} else {
|
||||
dialog = gtk_message_dialog_new(
|
||||
GTK_WINDOW(gtk_widget_get_root(widget)), flags,
|
||||
GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
|
||||
"Found data encoded in a %s.", code->type);
|
||||
GTK_WINDOW(gtk_widget_get_root(widget)),
|
||||
flags,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_NONE,
|
||||
"Found data encoded in a %s.",
|
||||
code->type);
|
||||
gtk_message_dialog_format_secondary_markup(
|
||||
GTK_MESSAGE_DIALOG(dialog), "<small>%s</small>", code->data);
|
||||
}
|
||||
gtk_dialog_add_buttons(GTK_DIALOG(dialog), "_Copy", GTK_RESPONSE_ACCEPT,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL, NULL);
|
||||
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
|
||||
"_Copy",
|
||||
GTK_RESPONSE_ACCEPT,
|
||||
"_Cancel",
|
||||
GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
|
||||
g_signal_connect(dialog, "response", G_CALLBACK(on_zbar_dialog_response),
|
||||
data);
|
||||
g_signal_connect(
|
||||
dialog, "response", G_CALLBACK(on_zbar_dialog_response), data);
|
||||
|
||||
gtk_widget_show(GTK_WIDGET(dialog));
|
||||
}
|
||||
@@ -607,7 +658,9 @@ preview_pressed(GtkGestureClick *gesture, int n_press, double x, double y)
|
||||
for (uint8_t i = 0; i < zbar_result->size; ++i) {
|
||||
MPZBarCode *code = &zbar_result->codes[i];
|
||||
|
||||
if (check_point_inside_bounds(zbar_x, zbar_y, code->bounds_x,
|
||||
if (check_point_inside_bounds(zbar_x,
|
||||
zbar_y,
|
||||
code->bounds_x,
|
||||
code->bounds_y)) {
|
||||
on_zbar_code_tapped(widget, code);
|
||||
return;
|
||||
@@ -685,9 +738,14 @@ update_scale(GtkToggleButton *button, GtkScale *scale)
|
||||
}
|
||||
|
||||
static void
|
||||
open_controls(GtkWidget *parent, const char *title_name, double min_value,
|
||||
double max_value, double current, bool auto_enabled,
|
||||
void (*set_fn)(double), void (*set_auto_fn)(bool))
|
||||
open_controls(GtkWidget *parent,
|
||||
const char *title_name,
|
||||
double min_value,
|
||||
double max_value,
|
||||
double current,
|
||||
bool auto_enabled,
|
||||
void (*set_fn)(double),
|
||||
void (*set_auto_fn)(bool))
|
||||
{
|
||||
GtkBuilder *builder = gtk_builder_new_from_resource(
|
||||
"/org/postmarketos/Megapixels/controls-popover.ui");
|
||||
@@ -711,12 +769,16 @@ open_controls(GtkWidget *parent, const char *title_name, double min_value,
|
||||
gtk_toggle_button_set_active(auto_button, auto_enabled);
|
||||
update_scale(auto_button, scale);
|
||||
|
||||
g_signal_connect(adjustment, "value-changed",
|
||||
G_CALLBACK(on_controls_scale_changed), set_fn);
|
||||
g_signal_connect(adjustment, "value-changed", G_CALLBACK(update_value),
|
||||
value_label);
|
||||
g_signal_connect(auto_button, "toggled",
|
||||
G_CALLBACK(on_auto_controls_toggled), set_auto_fn);
|
||||
g_signal_connect(adjustment,
|
||||
"value-changed",
|
||||
G_CALLBACK(on_controls_scale_changed),
|
||||
set_fn);
|
||||
g_signal_connect(
|
||||
adjustment, "value-changed", G_CALLBACK(update_value), value_label);
|
||||
g_signal_connect(auto_button,
|
||||
"toggled",
|
||||
G_CALLBACK(on_auto_controls_toggled),
|
||||
set_auto_fn);
|
||||
g_signal_connect(auto_button, "toggled", G_CALLBACK(update_scale), scale);
|
||||
|
||||
gtk_widget_set_parent(GTK_WIDGET(popover), parent);
|
||||
@@ -745,7 +807,13 @@ set_gain_auto(bool is_auto)
|
||||
static void
|
||||
open_iso_controls(GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
open_controls(button, "ISO", 0, gain_max, gain, !gain_is_manual, set_gain,
|
||||
open_controls(button,
|
||||
"ISO",
|
||||
0,
|
||||
gain_max,
|
||||
gain,
|
||||
!gain_is_manual,
|
||||
set_gain,
|
||||
set_gain_auto);
|
||||
}
|
||||
|
||||
@@ -771,8 +839,14 @@ set_shutter_auto(bool is_auto)
|
||||
static void
|
||||
open_shutter_controls(GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
open_controls(button, "Shutter", 1.0, 360.0, exposure, !exposure_is_manual,
|
||||
set_shutter, set_shutter_auto);
|
||||
open_controls(button,
|
||||
"Shutter",
|
||||
1.0,
|
||||
360.0,
|
||||
exposure,
|
||||
!exposure_is_manual,
|
||||
set_shutter,
|
||||
set_shutter_auto);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -881,17 +955,28 @@ display_config_received(GDBusConnection *conn, GAsyncResult *res, gpointer user_
|
||||
static void
|
||||
update_screen_rotation(GDBusConnection *conn)
|
||||
{
|
||||
g_dbus_connection_call(conn, "org.gnome.Mutter.DisplayConfig",
|
||||
g_dbus_connection_call(conn,
|
||||
"org.gnome.Mutter.DisplayConfig",
|
||||
"/org/gnome/Mutter/DisplayConfig",
|
||||
"org.gnome.Mutter.DisplayConfig", "GetResources",
|
||||
NULL, NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL,
|
||||
(GAsyncReadyCallback)display_config_received, NULL);
|
||||
"org.gnome.Mutter.DisplayConfig",
|
||||
"GetResources",
|
||||
NULL,
|
||||
NULL,
|
||||
G_DBUS_CALL_FLAGS_NO_AUTO_START,
|
||||
-1,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)display_config_received,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
on_screen_rotate(GDBusConnection *conn, const gchar *sender_name,
|
||||
const gchar *object_path, const gchar *interface_name,
|
||||
const gchar *signal_name, GVariant *parameters, gpointer user_data)
|
||||
on_screen_rotate(GDBusConnection *conn,
|
||||
const gchar *sender_name,
|
||||
const gchar *object_path,
|
||||
const gchar *interface_name,
|
||||
const gchar *signal_name,
|
||||
GVariant *parameters,
|
||||
gpointer user_data)
|
||||
{
|
||||
update_screen_rotation(conn);
|
||||
}
|
||||
@@ -899,8 +984,10 @@ on_screen_rotate(GDBusConnection *conn, const gchar *sender_name,
|
||||
static void
|
||||
activate(GtkApplication *app, gpointer data)
|
||||
{
|
||||
g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme",
|
||||
TRUE, NULL);
|
||||
g_object_set(gtk_settings_get_default(),
|
||||
"gtk-application-prefer-dark-theme",
|
||||
TRUE,
|
||||
NULL);
|
||||
|
||||
GdkDisplay *display = gdk_display_get_default();
|
||||
GtkIconTheme *icon_theme = gtk_icon_theme_get_for_display(display);
|
||||
@@ -910,7 +997,8 @@ activate(GtkApplication *app, gpointer data)
|
||||
gtk_css_provider_load_from_resource(
|
||||
provider, "/org/postmarketos/Megapixels/camera.css");
|
||||
gtk_style_context_add_provider_for_display(
|
||||
display, GTK_STYLE_PROVIDER(provider),
|
||||
display,
|
||||
GTK_STYLE_PROVIDER(provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
GtkBuilder *builder = gtk_builder_new_from_resource(
|
||||
@@ -947,19 +1035,19 @@ activate(GtkApplication *app, gpointer data)
|
||||
gtk_widget_add_controller(preview, GTK_EVENT_CONTROLLER(click));
|
||||
|
||||
g_signal_connect(iso_button, "clicked", G_CALLBACK(open_iso_controls), NULL);
|
||||
g_signal_connect(shutter_button, "clicked",
|
||||
G_CALLBACK(open_shutter_controls), NULL);
|
||||
g_signal_connect(flash_button, "clicked", G_CALLBACK(flash_button_clicked),
|
||||
NULL);
|
||||
g_signal_connect(
|
||||
shutter_button, "clicked", G_CALLBACK(open_shutter_controls), NULL);
|
||||
g_signal_connect(
|
||||
flash_button, "clicked", G_CALLBACK(flash_button_clicked), NULL);
|
||||
|
||||
// Setup actions
|
||||
create_simple_action(app, "capture", G_CALLBACK(run_capture_action));
|
||||
create_simple_action(app, "switch-camera",
|
||||
G_CALLBACK(run_camera_switch_action));
|
||||
create_simple_action(app, "open-settings",
|
||||
G_CALLBACK(run_open_settings_action));
|
||||
create_simple_action(app, "close-settings",
|
||||
G_CALLBACK(run_close_settings_action));
|
||||
create_simple_action(
|
||||
app, "switch-camera", G_CALLBACK(run_camera_switch_action));
|
||||
create_simple_action(
|
||||
app, "open-settings", G_CALLBACK(run_open_settings_action));
|
||||
create_simple_action(
|
||||
app, "close-settings", G_CALLBACK(run_close_settings_action));
|
||||
create_simple_action(app, "open-last", G_CALLBACK(run_open_last_action));
|
||||
create_simple_action(app, "open-photos", G_CALLBACK(run_open_photos_action));
|
||||
create_simple_action(app, "about", G_CALLBACK(run_about_action));
|
||||
@@ -974,7 +1062,10 @@ activate(GtkApplication *app, gpointer data)
|
||||
|
||||
// Setup settings
|
||||
settings = g_settings_new("org.postmarketos.Megapixels");
|
||||
g_settings_bind(settings, "save-raw", setting_dng_button, "active",
|
||||
g_settings_bind(settings,
|
||||
"save-raw",
|
||||
setting_dng_button,
|
||||
"active",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
setting_save_dng = g_settings_get_boolean(settings, "save-raw");
|
||||
@@ -982,10 +1073,16 @@ activate(GtkApplication *app, gpointer data)
|
||||
// Listen for phosh rotation
|
||||
GDBusConnection *conn =
|
||||
g_application_get_dbus_connection(G_APPLICATION(app));
|
||||
g_dbus_connection_signal_subscribe(
|
||||
conn, NULL, "org.gnome.Mutter.DisplayConfig", "MonitorsChanged",
|
||||
"/org/gnome/Mutter/DisplayConfig", NULL, G_DBUS_SIGNAL_FLAGS_NONE,
|
||||
&on_screen_rotate, NULL, NULL);
|
||||
g_dbus_connection_signal_subscribe(conn,
|
||||
NULL,
|
||||
"org.gnome.Mutter.DisplayConfig",
|
||||
"MonitorsChanged",
|
||||
"/org/gnome/Mutter/DisplayConfig",
|
||||
NULL,
|
||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||
&on_screen_rotate,
|
||||
NULL,
|
||||
NULL);
|
||||
update_screen_rotation(conn);
|
||||
|
||||
// Initialize display flash
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "camera_config.h"
|
||||
#include "zbar_pipeline.h"
|
||||
#include "process_pipeline.h"
|
||||
#include "gtk/gtk.h"
|
||||
#include "process_pipeline.h"
|
||||
#include "zbar_pipeline.h"
|
||||
|
||||
struct mp_main_state {
|
||||
const struct mp_camera_config *camera;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include "pipeline.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib-unix.h>
|
||||
#include <assert.h>
|
||||
#include <glib-unix.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
struct _MPPipeline {
|
||||
GMainContext *main_context;
|
||||
@@ -45,8 +45,10 @@ invoke_impl(struct invoke_args *args)
|
||||
}
|
||||
|
||||
void
|
||||
mp_pipeline_invoke(MPPipeline *pipeline, MPPipelineCallback callback,
|
||||
const void *data, size_t size)
|
||||
mp_pipeline_invoke(MPPipeline *pipeline,
|
||||
MPPipelineCallback callback,
|
||||
const void *data,
|
||||
size_t size)
|
||||
{
|
||||
if (pthread_self() != pipeline->thread) {
|
||||
struct invoke_args *args = malloc(sizeof(struct invoke_args) + size);
|
||||
@@ -59,7 +61,9 @@ mp_pipeline_invoke(MPPipeline *pipeline, MPPipelineCallback callback,
|
||||
|
||||
g_main_context_invoke_full(pipeline->main_context,
|
||||
G_PRIORITY_DEFAULT,
|
||||
(GSourceFunc)invoke_impl, args, free);
|
||||
(GSourceFunc)invoke_impl,
|
||||
args,
|
||||
free);
|
||||
} else {
|
||||
callback(pipeline, data);
|
||||
}
|
||||
@@ -79,8 +83,11 @@ mp_pipeline_sync(MPPipeline *pipeline)
|
||||
g_mutex_init(&mutex);
|
||||
g_mutex_lock(&mutex);
|
||||
|
||||
g_main_context_invoke_full(pipeline->main_context, G_PRIORITY_LOW,
|
||||
(GSourceFunc)unlock_mutex, &mutex, NULL);
|
||||
g_main_context_invoke_full(pipeline->main_context,
|
||||
G_PRIORITY_LOW,
|
||||
(GSourceFunc)unlock_mutex,
|
||||
&mutex,
|
||||
NULL);
|
||||
g_mutex_lock(&mutex);
|
||||
g_mutex_unlock(&mutex);
|
||||
|
||||
@@ -118,8 +125,10 @@ on_capture(int fd, GIOCondition condition, struct capture_source_args *args)
|
||||
|
||||
// Not thread safe
|
||||
GSource *
|
||||
mp_pipeline_add_capture_source(MPPipeline *pipeline, MPCamera *camera,
|
||||
void (*callback)(MPBuffer, void *), void *user_data)
|
||||
mp_pipeline_add_capture_source(MPPipeline *pipeline,
|
||||
MPCamera *camera,
|
||||
void (*callback)(MPBuffer, void *),
|
||||
void *user_data)
|
||||
{
|
||||
int video_fd = mp_camera_get_video_fd(camera);
|
||||
GSource *video_source = g_unix_fd_source_new(video_fd, G_IO_IN);
|
||||
|
@@ -9,12 +9,15 @@ typedef struct _MPPipeline MPPipeline;
|
||||
typedef void (*MPPipelineCallback)(MPPipeline *, const void *);
|
||||
|
||||
MPPipeline *mp_pipeline_new();
|
||||
void mp_pipeline_invoke(MPPipeline *pipeline, MPPipelineCallback callback,
|
||||
const void *data, size_t size);
|
||||
void mp_pipeline_invoke(MPPipeline *pipeline,
|
||||
MPPipelineCallback callback,
|
||||
const void *data,
|
||||
size_t size);
|
||||
// Wait until all pending tasks have completed
|
||||
void mp_pipeline_sync(MPPipeline *pipeline);
|
||||
void mp_pipeline_free(MPPipeline *pipeline);
|
||||
|
||||
GSource *mp_pipeline_add_capture_source(MPPipeline *pipeline, MPCamera *camera,
|
||||
GSource *mp_pipeline_add_capture_source(MPPipeline *pipeline,
|
||||
MPCamera *camera,
|
||||
void (*callback)(MPBuffer, void *),
|
||||
void *user_data);
|
||||
|
@@ -1,15 +1,15 @@
|
||||
#include "process_pipeline.h"
|
||||
|
||||
#include "pipeline.h"
|
||||
#include "zbar_pipeline.h"
|
||||
#include "io_pipeline.h"
|
||||
#include "main.h"
|
||||
#include "config.h"
|
||||
#include "gles2_debayer.h"
|
||||
#include <tiffio.h>
|
||||
#include "io_pipeline.h"
|
||||
#include "main.h"
|
||||
#include "pipeline.h"
|
||||
#include "zbar_pipeline.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <math.h>
|
||||
#include <tiffio.h>
|
||||
|
||||
#include "gl_util.h"
|
||||
#include <sys/mman.h>
|
||||
@@ -59,12 +59,19 @@ static void
|
||||
register_custom_tiff_tags(TIFF *tif)
|
||||
{
|
||||
static const TIFFFieldInfo custom_fields[] = {
|
||||
{ TIFFTAG_FORWARDMATRIX1, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, 1, 1,
|
||||
{ TIFFTAG_FORWARDMATRIX1,
|
||||
-1,
|
||||
-1,
|
||||
TIFF_SRATIONAL,
|
||||
FIELD_CUSTOM,
|
||||
1,
|
||||
1,
|
||||
"ForwardMatrix1" },
|
||||
};
|
||||
|
||||
// Add missing dng fields
|
||||
TIFFMergeFieldInfo(tif, custom_fields,
|
||||
TIFFMergeFieldInfo(tif,
|
||||
custom_fields,
|
||||
sizeof(custom_fields) / sizeof(custom_fields[0]));
|
||||
}
|
||||
|
||||
@@ -238,14 +245,18 @@ init_gl(MPPipeline *pipeline, GdkSurface **surface)
|
||||
int major, minor;
|
||||
gdk_gl_context_get_version(context, &major, &minor);
|
||||
|
||||
printf("Initialized %s %d.%d\n", is_es ? "OpenGL ES" : "OpenGL", major,
|
||||
printf("Initialized %s %d.%d\n",
|
||||
is_es ? "OpenGL ES" : "OpenGL",
|
||||
major,
|
||||
minor);
|
||||
}
|
||||
|
||||
void
|
||||
mp_process_pipeline_init_gl(GdkSurface *surface)
|
||||
{
|
||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)init_gl, &surface,
|
||||
mp_pipeline_invoke(pipeline,
|
||||
(MPPipelineCallback)init_gl,
|
||||
&surface,
|
||||
sizeof(GdkSurface *));
|
||||
}
|
||||
|
||||
@@ -283,12 +294,19 @@ process_image_for_preview(const uint8_t *image)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, mode.width, mode.height, 0,
|
||||
GL_LUMINANCE, GL_UNSIGNED_BYTE, image);
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_LUMINANCE,
|
||||
mode.width,
|
||||
mode.height,
|
||||
0,
|
||||
GL_LUMINANCE,
|
||||
GL_UNSIGNED_BYTE,
|
||||
image);
|
||||
check_gl();
|
||||
|
||||
gles2_debayer_process(gles2_debayer, output_buffer->texture_id,
|
||||
input_texture);
|
||||
gles2_debayer_process(
|
||||
gles2_debayer, output_buffer->texture_id, input_texture);
|
||||
check_gl();
|
||||
|
||||
glFinish();
|
||||
@@ -320,8 +338,13 @@ process_image_for_preview(const uint8_t *image)
|
||||
|
||||
uint32_t *data = g_malloc_n(size, 1);
|
||||
|
||||
glReadPixels(0, 0, output_buffer_width, output_buffer_height,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
glReadPixels(0,
|
||||
0,
|
||||
output_buffer_width,
|
||||
output_buffer_height,
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
data);
|
||||
check_gl();
|
||||
|
||||
// Flip vertically
|
||||
@@ -337,10 +360,12 @@ process_image_for_preview(const uint8_t *image)
|
||||
}
|
||||
}
|
||||
|
||||
thumb = gdk_memory_texture_new(
|
||||
output_buffer_width, output_buffer_height,
|
||||
GDK_MEMORY_R8G8B8A8, g_bytes_new_take(data, size),
|
||||
output_buffer_width * sizeof(uint32_t));
|
||||
thumb = gdk_memory_texture_new(output_buffer_width,
|
||||
output_buffer_height,
|
||||
GDK_MEMORY_R8G8B8A8,
|
||||
g_bytes_new_take(data, size),
|
||||
output_buffer_width *
|
||||
sizeof(uint32_t));
|
||||
}
|
||||
|
||||
return thumb;
|
||||
@@ -397,7 +422,9 @@ process_image_for_capture(const uint8_t *image, int count)
|
||||
TIFFSetField(tif, TIFFTAG_DNGVERSION, "\001\001\0\0");
|
||||
TIFFSetField(tif, TIFFTAG_DNGBACKWARDVERSION, "\001\0\0\0");
|
||||
char uniquecameramodel[255];
|
||||
sprintf(uniquecameramodel, "%s %s", mp_get_device_make(),
|
||||
sprintf(uniquecameramodel,
|
||||
"%s %s",
|
||||
mp_get_device_make(),
|
||||
mp_get_device_model());
|
||||
TIFFSetField(tif, TIFFTAG_UNIQUECAMERAMODEL, uniquecameramodel);
|
||||
if (camera->colormatrix[0]) {
|
||||
@@ -426,7 +453,8 @@ process_image_for_capture(const uint8_t *image, int count)
|
||||
TIFFSetField(tif, TIFFTAG_SUBFILETYPE, 0);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, mode.width);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, mode.height);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE,
|
||||
TIFFSetField(tif,
|
||||
TIFFTAG_BITSPERSAMPLE,
|
||||
mp_pixel_format_bits_per_pixel(mode.pixel_format));
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CFA);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
@@ -458,7 +486,8 @@ process_image_for_capture(const uint8_t *image, int count)
|
||||
(void *)image +
|
||||
(row * mp_pixel_format_width_to_bytes(
|
||||
mode.pixel_format, mode.width)),
|
||||
row, 0);
|
||||
row,
|
||||
0);
|
||||
}
|
||||
TIFFWriteDirectory(tif);
|
||||
|
||||
@@ -471,13 +500,14 @@ process_image_for_capture(const uint8_t *image, int count)
|
||||
TIFFSetField(tif, EXIFTAG_EXPOSUREPROGRAM, 1);
|
||||
}
|
||||
|
||||
TIFFSetField(tif, EXIFTAG_EXPOSURETIME,
|
||||
TIFFSetField(tif,
|
||||
EXIFTAG_EXPOSURETIME,
|
||||
(mode.frame_interval.numerator /
|
||||
(float)mode.frame_interval.denominator) /
|
||||
((float)mode.height / (float)exposure));
|
||||
if (camera->iso_min && camera->iso_max) {
|
||||
uint16_t isospeed = remap(gain - 1, 0, gain_max, camera->iso_min,
|
||||
camera->iso_max);
|
||||
uint16_t isospeed = remap(
|
||||
gain - 1, 0, gain_max, camera->iso_min, camera->iso_max);
|
||||
TIFFSetField(tif, EXIFTAG_ISOSPEEDRATINGS, 1, &isospeed);
|
||||
}
|
||||
TIFFSetField(tif, EXIFTAG_FLASH, 0);
|
||||
@@ -491,7 +521,8 @@ process_image_for_capture(const uint8_t *image, int count)
|
||||
TIFFSetField(tif, EXIFTAG_FOCALLENGTH, camera->focallength);
|
||||
}
|
||||
if (camera->focallength && camera->cropfactor) {
|
||||
TIFFSetField(tif, EXIFTAG_FOCALLENGTHIN35MMFILM,
|
||||
TIFFSetField(tif,
|
||||
EXIFTAG_FOCALLENGTHIN35MMFILM,
|
||||
(short)(camera->focallength * camera->cropfactor));
|
||||
}
|
||||
uint64_t exif_offset = 0;
|
||||
@@ -540,14 +571,19 @@ process_capture_burst(GdkTexture *thumb)
|
||||
strftime(timestamp, 30, "%Y%m%d%H%M%S", &tim);
|
||||
|
||||
if (g_get_user_special_dir(G_USER_DIRECTORY_PICTURES) != NULL) {
|
||||
sprintf(capture_fname, "%s/IMG%s",
|
||||
sprintf(capture_fname,
|
||||
"%s/IMG%s",
|
||||
g_get_user_special_dir(G_USER_DIRECTORY_PICTURES),
|
||||
timestamp);
|
||||
} else if (getenv("XDG_PICTURES_DIR") != NULL) {
|
||||
sprintf(capture_fname, "%s/IMG%s", getenv("XDG_PICTURES_DIR"),
|
||||
sprintf(capture_fname,
|
||||
"%s/IMG%s",
|
||||
getenv("XDG_PICTURES_DIR"),
|
||||
timestamp);
|
||||
} else {
|
||||
sprintf(capture_fname, "%s/Pictures/IMG%s", getenv("HOME"),
|
||||
sprintf(capture_fname,
|
||||
"%s/Pictures/IMG%s",
|
||||
getenv("HOME"),
|
||||
timestamp);
|
||||
}
|
||||
|
||||
@@ -557,12 +593,18 @@ process_capture_burst(GdkTexture *thumb)
|
||||
}
|
||||
|
||||
// Start post-processing the captured burst
|
||||
g_print("Post process %s to %s.ext (save-dng %s)\n", burst_dir,
|
||||
capture_fname, save_dng_s);
|
||||
g_print("Post process %s to %s.ext (save-dng %s)\n",
|
||||
burst_dir,
|
||||
capture_fname,
|
||||
save_dng_s);
|
||||
GError *error = NULL;
|
||||
GSubprocess *proc = g_subprocess_new(G_SUBPROCESS_FLAGS_STDOUT_PIPE, &error,
|
||||
processing_script, burst_dir,
|
||||
capture_fname, save_dng_s, NULL);
|
||||
GSubprocess *proc = g_subprocess_new(G_SUBPROCESS_FLAGS_STDOUT_PIPE,
|
||||
&error,
|
||||
processing_script,
|
||||
burst_dir,
|
||||
capture_fname,
|
||||
save_dng_s,
|
||||
NULL);
|
||||
|
||||
if (!proc) {
|
||||
g_printerr("Failed to spawn postprocess process: %s\n",
|
||||
@@ -587,9 +629,12 @@ process_image(MPPipeline *pipeline, const MPBuffer *buffer)
|
||||
memcpy(image, buffer->data, size);
|
||||
mp_io_pipeline_release_buffer(buffer->index);
|
||||
|
||||
MPZBarImage *zbar_image =
|
||||
mp_zbar_image_new(image, mode.pixel_format, mode.width, mode.height,
|
||||
camera_rotation, camera->mirrored);
|
||||
MPZBarImage *zbar_image = mp_zbar_image_new(image,
|
||||
mode.pixel_format,
|
||||
mode.width,
|
||||
mode.height,
|
||||
camera_rotation,
|
||||
camera->mirrored);
|
||||
mp_zbar_pipeline_process_image(mp_zbar_image_ref(zbar_image));
|
||||
|
||||
#ifdef PROFILE_PROCESS
|
||||
@@ -641,7 +686,9 @@ mp_process_pipeline_process_image(MPBuffer buffer)
|
||||
|
||||
++frames_received;
|
||||
|
||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)process_image, &buffer,
|
||||
mp_pipeline_invoke(pipeline,
|
||||
(MPPipelineCallback)process_image,
|
||||
&buffer,
|
||||
sizeof(MPBuffer));
|
||||
}
|
||||
|
||||
@@ -684,16 +731,27 @@ on_output_changed()
|
||||
|
||||
for (size_t i = 0; i < NUM_BUFFERS; ++i) {
|
||||
glBindTexture(GL_TEXTURE_2D, output_buffers[i].texture_id);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, output_buffer_width,
|
||||
output_buffer_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
output_buffer_width,
|
||||
output_buffer_height,
|
||||
0,
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
gles2_debayer_configure(
|
||||
gles2_debayer, output_buffer_width, output_buffer_height, mode.width,
|
||||
mode.height, camera->rotate, camera->mirrored,
|
||||
gles2_debayer,
|
||||
output_buffer_width,
|
||||
output_buffer_height,
|
||||
mode.width,
|
||||
mode.height,
|
||||
camera->rotate,
|
||||
camera->mirrored,
|
||||
camera->previewmatrix[0] == 0 ? NULL : camera->previewmatrix,
|
||||
camera->blacklevel);
|
||||
}
|
||||
@@ -757,7 +815,9 @@ update_state(MPPipeline *pipeline, const struct mp_process_pipeline_state *state
|
||||
void
|
||||
mp_process_pipeline_update_state(const struct mp_process_pipeline_state *new_state)
|
||||
{
|
||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)update_state, new_state,
|
||||
mp_pipeline_invoke(pipeline,
|
||||
(MPPipelineCallback)update_state,
|
||||
new_state,
|
||||
sizeof(struct mp_process_pipeline_state));
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
#include "zbar_pipeline.h"
|
||||
|
||||
#include "pipeline.h"
|
||||
#include "main.h"
|
||||
#include "io_pipeline.h"
|
||||
#include <zbar.h>
|
||||
#include "main.h"
|
||||
#include "pipeline.h"
|
||||
#include <assert.h>
|
||||
#include <zbar.h>
|
||||
|
||||
struct _MPZBarImage {
|
||||
uint8_t *data;
|
||||
@@ -102,7 +102,9 @@ map_coords(int *x, int *y, int width, int height, int rotation, bool mirrored)
|
||||
}
|
||||
|
||||
static MPZBarCode
|
||||
process_symbol(const MPZBarImage *image, int width, int height,
|
||||
process_symbol(const MPZBarImage *image,
|
||||
int width,
|
||||
int height,
|
||||
const zbar_symbol_t *symbol)
|
||||
{
|
||||
if (image->rotation == 90 || image->rotation == 270) {
|
||||
@@ -147,8 +149,12 @@ process_symbol(const MPZBarImage *image, int width, int height,
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < 4; ++i) {
|
||||
map_coords(&code.bounds_x[i], &code.bounds_y[i], width, height,
|
||||
image->rotation, image->mirrored);
|
||||
map_coords(&code.bounds_x[i],
|
||||
&code.bounds_y[i],
|
||||
width,
|
||||
height,
|
||||
image->rotation,
|
||||
image->mirrored);
|
||||
}
|
||||
|
||||
const char *data = zbar_symbol_get_data(symbol);
|
||||
@@ -187,7 +193,9 @@ process_image(MPPipeline *pipeline, MPZBarImage **_image)
|
||||
zbar_image_t *zbar_image = zbar_image_create();
|
||||
zbar_image_set_format(zbar_image, zbar_fourcc('Y', '8', '0', '0'));
|
||||
zbar_image_set_size(zbar_image, width, height);
|
||||
zbar_image_set_data(zbar_image, data, width * height * sizeof(uint8_t),
|
||||
zbar_image_set_data(zbar_image,
|
||||
data,
|
||||
width * height * sizeof(uint8_t),
|
||||
zbar_image_free_data);
|
||||
|
||||
int res = zbar_scan_image(scanner, zbar_image);
|
||||
@@ -227,13 +235,19 @@ mp_zbar_pipeline_process_image(MPZBarImage *image)
|
||||
|
||||
++frames_received;
|
||||
|
||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)process_image, &image,
|
||||
mp_pipeline_invoke(pipeline,
|
||||
(MPPipelineCallback)process_image,
|
||||
&image,
|
||||
sizeof(MPZBarImage *));
|
||||
}
|
||||
|
||||
MPZBarImage *
|
||||
mp_zbar_image_new(uint8_t *data, MPPixelFormat pixel_format, int width, int height,
|
||||
int rotation, bool mirrored)
|
||||
mp_zbar_image_new(uint8_t *data,
|
||||
MPPixelFormat pixel_format,
|
||||
int width,
|
||||
int height,
|
||||
int rotation,
|
||||
bool mirrored)
|
||||
{
|
||||
MPZBarImage *image = malloc(sizeof(MPZBarImage));
|
||||
image->data = data;
|
||||
|
@@ -21,7 +21,11 @@ void mp_zbar_pipeline_stop();
|
||||
|
||||
void mp_zbar_pipeline_process_image(MPZBarImage *image);
|
||||
|
||||
MPZBarImage *mp_zbar_image_new(uint8_t *data, MPPixelFormat pixel_format, int width,
|
||||
int height, int rotation, bool mirrored);
|
||||
MPZBarImage *mp_zbar_image_new(uint8_t *data,
|
||||
MPPixelFormat pixel_format,
|
||||
int width,
|
||||
int height,
|
||||
int rotation,
|
||||
bool mirrored);
|
||||
MPZBarImage *mp_zbar_image_ref(MPZBarImage *image);
|
||||
void mp_zbar_image_unref(MPZBarImage *image);
|
||||
|
@@ -94,8 +94,8 @@ main(int argc, char *argv[])
|
||||
const struct media_v2_pad *pad =
|
||||
mp_device_get_pad_from_entity(
|
||||
device, entities[i].id);
|
||||
mp_device_setup_link(device, pad->id, sink_pad->id,
|
||||
false);
|
||||
mp_device_setup_link(
|
||||
device, pad->id, sink_pad->id, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,8 +134,10 @@ main(int argc, char *argv[])
|
||||
list = mp_control_list_next(list)) {
|
||||
MPControl *c = mp_control_list_get(list);
|
||||
|
||||
printf(" %32s id:%s type:%s default:%d\n", c->name,
|
||||
mp_control_id_to_str(c->id), mp_control_type_to_str(c->type),
|
||||
printf(" %32s id:%s type:%s default:%d\n",
|
||||
c->name,
|
||||
mp_control_id_to_str(c->id),
|
||||
mp_control_type_to_str(c->type),
|
||||
c->default_value);
|
||||
}
|
||||
|
||||
@@ -150,8 +152,11 @@ main(int argc, char *argv[])
|
||||
for (MPCameraModeList *list = modes; list;
|
||||
list = mp_camera_mode_list_next(list)) {
|
||||
MPCameraMode *m = mp_camera_mode_list_get(list);
|
||||
printf(" %dx%d interval:%d/%d fmt:%s\n", m->width, m->height,
|
||||
m->frame_interval.numerator, m->frame_interval.denominator,
|
||||
printf(" %dx%d interval:%d/%d fmt:%s\n",
|
||||
m->width,
|
||||
m->height,
|
||||
m->frame_interval.numerator,
|
||||
m->frame_interval.denominator,
|
||||
mp_pixel_format_to_str(m->pixel_format));
|
||||
|
||||
// Skip really slow framerates
|
||||
|
@@ -22,7 +22,9 @@ main(int argc, char *argv[])
|
||||
size_t num = mp_device_get_num_entities(device);
|
||||
printf(" Entities (%ld):\n", num);
|
||||
for (int i = 0; i < num; ++i) {
|
||||
printf(" %d %s (%d)\n", entities[i].id, entities[i].name,
|
||||
printf(" %d %s (%d)\n",
|
||||
entities[i].id,
|
||||
entities[i].name,
|
||||
entities[i].function);
|
||||
}
|
||||
|
||||
@@ -31,8 +33,10 @@ main(int argc, char *argv[])
|
||||
num = mp_device_get_num_interfaces(device);
|
||||
printf(" Interfaces (%ld):\n", num);
|
||||
for (int i = 0; i < num; ++i) {
|
||||
printf(" %d (%d - %d) devnode %d:%d\n", interfaces[i].id,
|
||||
interfaces[i].intf_type, interfaces[i].flags,
|
||||
printf(" %d (%d - %d) devnode %d:%d\n",
|
||||
interfaces[i].id,
|
||||
interfaces[i].intf_type,
|
||||
interfaces[i].flags,
|
||||
interfaces[i].devnode.major,
|
||||
interfaces[i].devnode.minor);
|
||||
}
|
||||
@@ -41,16 +45,21 @@ main(int argc, char *argv[])
|
||||
num = mp_device_get_num_pads(device);
|
||||
printf(" Pads (%ld):\n", num);
|
||||
for (int i = 0; i < num; ++i) {
|
||||
printf(" %d for device:%d (%d)\n", pads[i].id,
|
||||
pads[i].entity_id, pads[i].flags);
|
||||
printf(" %d for device:%d (%d)\n",
|
||||
pads[i].id,
|
||||
pads[i].entity_id,
|
||||
pads[i].flags);
|
||||
}
|
||||
|
||||
const struct media_v2_link *links = mp_device_get_links(device);
|
||||
num = mp_device_get_num_links(device);
|
||||
printf(" Links (%ld):\n", num);
|
||||
for (int i = 0; i < num; ++i) {
|
||||
printf(" %d from:%d to:%d (%d)\n", links[i].id,
|
||||
links[i].source_id, links[i].sink_id, links[i].flags);
|
||||
printf(" %d from:%d to:%d (%d)\n",
|
||||
links[i].id,
|
||||
links[i].source_id,
|
||||
links[i].sink_id,
|
||||
links[i].flags);
|
||||
}
|
||||
|
||||
list = mp_device_list_next(list);
|
||||
|
Reference in New Issue
Block a user