Commit Graph

205 Commits

Author SHA1 Message Date
Andrey Skvortsov
886fea58bd zbar_pipeline: fix memory leak, when pixel format is unsupported 2025-05-31 10:09:51 +00:00
Andrey Skvortsov
928714595d process_pipeline: correctly handle empty stdout
When stdout is empty and end is zero. There are several incorrect read and write
access.

Valgrind reported following:

```
==70402== Invalid write of size 1
==70402==    at 0x11F626: post_process_finished (process_pipeline.c:1266)
==70402==    by 0x53D7C32: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D88D2: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D6627: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D7C32: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D7C6C: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x55D5344: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8400.1)
==70402==    by 0x55D7576: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8400.1)
==70402==    by 0x55D7CDF: g_main_context_iteration (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8400.1)
==70402==    by 0x5407EDC: g_application_run (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x11BB5F: main (main.c:1551)
==70402==  Address 0xb84651f is 1 bytes before a block of size 16 alloc'd
==70402==    at 0x484BDD0: realloc (vg_replace_malloc.c:1801)
==70402==    by 0x55DE761: g_realloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8400.1)
==70402==    by 0x53AE250: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53AE3C0: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53B6CFC: g_output_stream_write (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53B6E48: g_output_stream_write_all (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D65EA: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D7C32: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D88D2: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53B7D8A: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D7C32: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D88D2: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==
==70402== Invalid read of size 1
==70402==    at 0x11F642: post_process_finished (process_pipeline.c:1270)
==70402==    by 0x53D7C32: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D88D2: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D6627: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D7C32: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x53D7C6C: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x55D5344: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8400.1)
==70402==    by 0x55D7576: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8400.1)
==70402==    by 0x55D7CDF: g_main_context_iteration (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8400.1)
==70402==    by 0x5407EDC: g_application_run (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8400.1)
==70402==    by 0x11BB5F: main (main.c:1551)
```
2025-05-31 10:09:51 +00:00
Andrey Skvortsov
529e7841ab process_pipeline: replace sprintf with snprintf
to avoid potential buffer overflows
2025-05-31 10:09:51 +00:00
Andrey Skvortsov
f64782d9a5 main: fix memleak, when reading g_settings 2025-05-31 10:09:51 +00:00
Andrey Skvortsov
9567f00e01 process_pipeline: replace strcpy with snprintf
snprintf is always NULL-terminated in compare to strcpy.
2025-05-31 10:09:51 +00:00
Andrey Skvortsov
22549185f8 process_pipeline: fix memleak in save_jpeg
```
==70481== 7,680 bytes in 2 blocks are definitely lost in loss record 64,498 of 64,727
==70481==    at 0x4844818: malloc (vg_replace_malloc.c:446)
==70481==    by 0x11EDA5: save_jpeg (process_pipeline.c:1016)
==70481==    by 0x11F090: process_image_for_capture_yuv (process_pipeline.c:1078)
==70481==    by 0x11F5BC: process_image_for_capture (process_pipeline.c:1249)
==70481==    by 0x11FAB3: process_image (process_pipeline.c:1393)
```
2025-05-31 10:09:51 +00:00
Andrey Skvortsov
17228b1afa Add possibility to use hardware volume buttons to take a picture
On many mobile operating systems it's possible to take picture using
hardware volume buttons.
It's easier to hold the phone and take pictures this way. Additionally
it makes possible to use selfie stick (at least with jack plug).

To be able to handle volume buttons global system shortcuts, that
controls audio level has to be disabled.

gdk_toplevel_inhibit_system_shortcuts tells compositor to block system
keyboard shortcuts, when the camera app has focus. In all other cases
system shortcuts are working like before even if camera app is running
in background.
2025-05-31 10:05:58 +00:00
Andrey Skvortsov
4db24ddc5e Automatically rotate image based on accelerometer values
Device orientation is provided by net.hadess.SensorProxy
iio-proxy-service. If there is no accelerometer on target platform,
then window orientation from X11/wayland is used as before.
2025-05-19 13:42:21 +03:00
Andrey Skvortsov
6a7d2ec85e video: reset button icon to inactive after video processing
In current state after video is processed and saved button has
video-recording icon, that is confusing.

The change handles exit code of movie.sh script and depending on that
notifies UI to set video-inactive icon. video-recording icon is set,
when the user press button to activate video recording.
2025-04-08 22:51:27 +00:00
Andrey Skvortsov
4cbd8c2df7 process_pipeline.c: remove unused static variable 2025-04-08 22:51:27 +00:00
Andrey Skvortsov
6cfc9bfc05 video: fix missing directory on video capture
if photo was taken before, then temporary directory in tmpfs was clean
and removed after all files were processed. Internal burst_dir
variable contains old value for directory, that doesn't exist anymore.

Let's create new temporary directory, when video recording is started.
2025-04-08 22:51:27 +00:00
Andrey Skvortsov
883c16733d video: fix segmentation fault on video capture
If there was no picture capture or camera switch after application start, then
state_proc.configuration is uninitialized. If video capture is started
in this case, then segmentation fault happens.

Thread 8 "megapixels-pr" received signal SIGSEGV, Segmentation fault.
1085	        if (state_proc.configuration->make != NULL &&
(gdb) p state_proc.configuration
$1 = (libmegapixels_devconfig *) 0x0

state.configuration is set in update_state(), but set only after
init_controls(). After update_process_pipeline() is
called from init_controls() pipeline_change flag is reset and changes
after init_controls() (including state.configuration) are not applied to
state_proc. Removing update_process_pipeline from init_controls()
makes all settings to be applied at the end of update_state().
init_controls() is called only from update_state().
2025-04-08 22:38:06 +00:00
Martijn Braam
0b407957ed Fix loading the search paths for DCP files and add XDG_CONFIG_HOME as extra path 2025-04-04 02:24:48 +02:00
Egor Shestakov
970f320894 fix pointer type mistake in find_calibration loop 2025-03-20 16:10:41 +07:00
Egor Shestakov
e02b54ec57 add buffer size check in find_calibration
Drop find_calibration_by_model function that was occassionally,
as I suppose, marked not static.
2025-03-12 12:16:04 +00:00
Egor Shestakov
9b1ee0161d generalize find_calibration_by_model with a loop 2025-03-12 12:08:42 +00:00
Egor Shestakov
ae48e07f84 use libmegapixels_get_model in find_calibration 2025-03-12 12:08:09 +00:00
Egor Shestakov
29adecb84f use snprintf instead of sprintf in format_movie_name to prevent OOB 2025-03-07 18:47:06 +07:00
Egor Shestakov
2f2929800b initialize struct v4l2_plane in mp_camera_*_buffer functions
without it ioctl parameter points to uninitialized value
2025-02-11 21:18:43 +07:00
Egor Shestakov
ae1faec57d fix memory leak in process_aaa 2025-01-16 18:58:48 +07:00
Martijn Braam
541dd2f9c3 Add the other three YUV formats to the shader 2024-12-24 22:39:05 +01:00
Ferass El Hafidi
f5248b388e process_pipeline.c: fix call to libdng_write 2024-12-24 16:29:58 +00:00
Martijn Braam
79eab3fe1a Fix .jpg vs .jpeg file extension for YUV captures 2024-12-23 17:34:18 +01:00
Martijn Braam
8fbea82b2b Rewrite YUV processing pipeline.
Use a 4-channel texture instead for packed YUV data so
every pixel in the texture has all the 4:2:2 color data
available.
2024-12-23 17:29:46 +01:00
Martijn Braam
1b5a871641 Don't make the missing movie.sh file fatal 2024-12-23 15:40:34 +01:00
Takuya Wakazono
a9f6291c3e Explicitly declare function parameters for GCC 15 compatibility
In GCC 15, where C23 is the default, void foo() is equivalent to void
foo(void). Therefore, functions must explicitly declare their
parameters.
2024-11-30 22:38:05 +09:00
Kristian Vos
95ae684d9f Pass color/forward matrices to libdng 2024-11-04 18:44:28 +01:00
Kristian Vos
22fc1309c5 Fix wrong rotation being used for DNG 2024-11-04 15:04:30 +01:00
Kristian Vos
98ae16848c Fix preview not working after switching windows 2024-09-30 14:38:08 +02:00
Pavel Machek
bd1a19f66f ae: fix problem uncovered by alpine build 2024-09-07 23:04:32 +02:00
Pavel Machek
95f474076c ae: don't go over 1/100 sec exposure too easily 2024-09-07 22:52:31 +02:00
Pavel Machek
bfe76b7568 ui: disable for now, gtk does not like cross-calls 2024-09-07 22:52:30 +02:00
Pavel Machek
474b2db2c9 ui: display focus information, too. 2024-09-07 22:52:30 +02:00
Pavel Machek
cccfdb18c7 ui: take digital gain into consideration, too 2024-09-07 22:52:30 +02:00
Pavel Machek
13264d6b1c ui: display exposure/gain settings 2024-09-07 22:52:30 +02:00
Pavel Machek
9e4b760b77 ui: Add button with camera status. 2024-09-07 22:52:30 +02:00
Pavel Machek
47772bde2e ae: use gain/dgain minimum values 2024-09-07 22:52:30 +02:00
Pavel Machek
b5dbc416b5 ae: start using minimum values for controls, too 2024-09-07 22:52:30 +02:00
Pavel Machek
16092880d0 auto: display values in known units 2024-09-07 22:52:30 +02:00
Pavel Machek
eeca8fe4cc auto: cleanups 2024-09-07 22:52:30 +02:00
Pavel Machek
5fd1e09059 auto: tweak debugging 2024-09-07 22:52:30 +02:00
Pavel Machek
def6e19b5e ae: debugging note when out of options. 7.67 sec to "full dark". 2024-09-07 22:52:30 +02:00
Pavel Machek
8af8441bbd auto: use common functions when possible. 2024-09-07 22:52:30 +02:00
Pavel Machek
dcc73a1647 auto: Use helper function to set value. 2024-09-07 22:52:30 +02:00
Pavel Machek
d0e4e318c1 dgain: remove left-over debugging code 2024-09-03 14:18:34 +02:00
Pavel Machek
7c59259f27 dgain: Introduce digital gain 2024-09-03 13:12:23 +02:00
Pavel Machek
bbc077f528 af: if it improves on its own, likely scene or AE changed, and time to restart 2024-09-03 13:12:23 +02:00
Pavel Machek
d87c6263ed af: Port focus code from millipixels. 2024-09-03 13:12:23 +02:00
Kristian Vos
f8628a344c Don't call libmegapixels_open twice in a row in io_pipeline 2024-08-05 00:32:21 +00:00
Kristian Vos
8f37625309 Allow manually changing the focus using controls 2024-08-05 00:32:21 +00:00