Commit Graph

242 Commits

Author SHA1 Message Date
Alejandro Criado-Pérez
543683aa4c Corrections on cpp and h files 2023-08-13 01:27:19 +02:00
Isaac Connor
c510745317 Allow specifying width and height so that we can scale to alower res 2023-08-02 13:56:06 -04:00
Isaac Connor
4b20109b69 Use the same open semantics regardless of blocking or non so that we always have an fd to lock. Fixes logging of unable to lock jpeg in streaming with buffering 2023-07-25 16:35:28 -04:00
Isaac Connor
15d9ec32de Add advisory locking around image writing. So that someone can potentially wait for the image to be fully written to. Hopefully will resolve issues with zmes and incomplete images 2023-07-13 14:25:56 -04:00
Isaac Connor
2b34fa67db Add jpeg writing from YUV subpixelformat 2023-06-09 16:42:33 -04:00
Isaac Connor
1d51f1b146 Fix missing c_str() 2023-02-02 12:16:43 -05:00
Isaac Connor
9a999d1465 replace const char * with std::string and save filename in the object when created by filename. Long term, we may represent an image by filename and load the image on demand. For potential use with sendfile. 2023-02-01 14:31:59 -05:00
Isaac Connor
ae66782ddb Use 32byte aligned buffer size when allocating an image buffer to make ffmpeg happy. Fixes a crash when width = 1080. When linesizes are different, copy line by line instead of the whole buffer all at once. 2022-11-30 13:18:13 -05:00
Isaac Connor
658ca44c32 Don't panic if no font file found. Perhaps we can continue with diminished function 2022-10-14 14:04:06 -04:00
Isaac Connor
8558ade8f1 Merge branch 'master' into misc_fixes 2022-08-25 18:33:06 -04:00
Doug Nazar
74f8e43b12 Cast operand to larger destination size to avoid possible overflow issues. 2022-07-31 00:48:27 -04:00
Doug Nazar
f4dd897ef4 Convert AVFrame* to custom unique_ptr (av_frame_ptr).
Switch all owning AVFrame* variables to av_frame_ptr for
automatic cleanup.

Use AVBufferRef to store frame data in AVFrame where appropriate
so that it can be freed automatically with it's AVFrame.

Handle allocation errors.
2022-07-30 13:21:11 -04:00
Doug Nazar
3b21153757 Fix various printf formats for 32bit, 32bit w/_FILE_OFFSET_BITS=64 and 64-bit 2022-07-16 03:18:18 -04:00
Isaac Connor
e6de9c3e01 A polygon must have 3 vertices at minimum 2022-07-14 10:06:26 -04:00
Isaac Connor
59577133ef parenthesis 2022-06-08 23:28:54 -04:00
Isaac Connor
0fcc237fd5 Only call update_function_pointers if size might have changed 2022-06-07 17:19:54 -04:00
Isaac Connor
678abad57c remove debug 2022-06-07 11:58:32 -04:00
Isaac Connor
02cca8e57b Handle no vertices in Fill. Prevents crash when a zone is entirely outside the image 2022-05-17 15:05:08 -04:00
Isaac Connor
0cdb926e9e Remove unused variable 2022-05-10 09:30:13 -04:00
Isaac Connor
442dff3f8a Implement a Scale(new_width, new_height) using sw_scale. 2022-05-06 11:43:35 -04:00
Isaac Connor
db2854a7ac Improve error message when sws_scale fails 2022-05-04 10:00:40 -04:00
Isaac Connor
cc1368ba2c Move code for AVPixFormat to .cpp instead .h. Add const's so we can use it on cost Image * vars 2022-03-26 20:31:33 -04:00
Isaac Connor
fc541ac57d fix potential double lock of jpeg mutex 2022-02-18 17:11:18 -05:00
Isaac Connor
28f3cb18e4 Make std function warning into a debug. Warning will happen if they are actually used 2022-02-18 15:59:00 -05:00
Isaac Connor
91b536b868 Change the test for slow functions to mod4. The unrolled and SSE function work on 4 pixels at a time or 16 or 12 bytes depending on colours.This will improve cpu use on resolutions like 1280x800 2022-02-14 09:43:48 -05:00
Isaac Connor
6e7e6d9e8e small code cleanup, add Warnings when using slow blend functions. 2022-02-11 18:06:43 -05:00
Isaac Connor
4d90a816f8 Put a lock around jpeg writing. libjpeg is not thread safe 2022-01-25 16:22:33 -05:00
Isaac Connor
dec440ead1 Unset holdbuffer so that when we connect, we reset the shm buffer pointer. cleanup initializers in Image 2022-01-19 15:01:37 -05:00
Isaac Connor
a0c34f0d96 Fix. cppcheck was wrong about divider being able to go into deeper scope. 2022-01-10 18:33:01 -05:00
Isaac Connor
f0c6413dc8 solve ccpcheck complaints 2022-01-09 14:43:23 -05:00
Isaac Connor
0119ff46aa Remove redundant debug 2021-11-03 17:03:54 -04:00
Isaac Connor
58f933ba1e Add missing update_function_pointers so that we use SSE blend functions. Significantly reduces cpu use in motion detection. 2021-09-13 15:03:42 -04:00
Peter Keresztes Schmidt
5fda85bf2e Image: Codestyle changes 2021-09-12 11:38:44 +02:00
Peter Keresztes Schmidt
ecf6cc80aa Image: Fix Wclobbered warnings
From C99 spec:
[...]  objects of automatic storage duration that are local to the function containing the invocation of the corresponding setjmp macro that do not have volatile-qualified type and have been changed between the setjmp invocation and longjmp call are indeterminate

Remove the variables in question or pass them as const refs.
2021-09-12 11:36:51 +02:00
Peter Keresztes Schmidt
80b08a2075 Convert path buffers depending on PATH_MAX to std::string 2021-07-06 10:33:17 +02:00
Peter Keresztes Schmidt
ff8c9f67c1 Image: Convert API to std::chrono
Utils: Remove TimespecDiff. It is not used anymore
2021-06-13 14:50:16 +02:00
Peter Keresztes Schmidt
46155942c1 Misc: Rename namespace ZM to zm
We had a mixture of both spellings. Unify it according to our code-style.
2021-06-06 19:11:11 +02:00
Peter Keresztes Schmidt
2d71743372 FFmpeg: Remove code paths required only by 2.8 and older
With Xenial support dropped we require FFmpeg 3.2 and newer.
2021-06-05 20:40:12 +02:00
Peter Keresztes Schmidt
339cfd49bc Image: Remove std::vector out-of-bounds access when filling polygons
While iterating through `active_edges` we call `std::next`. If the current
iterator is `.end()` we are accessing out-of-bound memory.
Make sure we always have a valid iterator past `it` in the loop.

Follow-up on 6642ca4515
2021-05-29 19:58:19 +02:00
Peter Keresztes Schmidt
c0017a5263 Image: Move Edge class to its own namespace
The Edge class is an implementation detail of the scan-line polygon filling algorithm.
Tuck it away in the newly created PolygonFill namespace.
2021-05-17 20:20:33 +02:00
Peter Keresztes Schmidt
6642ca4515 Image: Eliminate VLAs from polygon fill algorithm implementation 2021-05-17 20:16:55 +02:00
Peter Keresztes Schmidt
63cea992a0 Image: Fix a dynamic-stack-buffer-overflow when filling polygons
Make sure we don't read past the end of global_edges when i = 0.
We are moving the elements backwards so at most n_global_edges - 1 elements can be moved.

==6818==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0x7ffff888ae00 at pc 0x7fe4fd7be8ae bp 0x7ffff888ac90 sp 0x7ffff888a440
READ of size 96 at 0x7ffff888ae00 thread T0
    #0 0x7fe4fd7be8ad in __interceptor_memmove (/lib/x86_64-linux-gnu/libasan.so.5+0x378ad)
    #1 0x56524b2dba31 in Image::Fill(unsigned int, int, Polygon const&) /root/zoneminder/src/zm_image.cpp:2514
    #2 0x56524af55530 in Monitor::DumpZoneImage(char const*) /root/zoneminder/src/zm_monitor.cpp:1510
    #3 0x56524aeb38cb in main /root/zoneminder/src/zmu.cpp:574
    #4 0x7fe4fb2b009a in __libc_start_main ../csu/libc-start.c:308
    #5 0x56524aeb87a9 in _start (/root/zoneminder/cmake-build-relwithdebinfo-remote/src/zmu+0xf87a9)
2021-05-16 19:41:45 +02:00
Peter Keresztes Schmidt
29488900a1 Box: Make range calculations mathematically correct 2021-05-16 19:41:45 +02:00
Peter Keresztes Schmidt
5af6d6af3d Polygon: Use std::vector to store the vertices 2021-05-16 16:42:58 +02:00
Peter Keresztes Schmidt
8f685b3d66 Box+Poly: Remove direct accessors to {Hi,Lo}{X,Y} 2021-05-16 16:42:58 +02:00
Peter Keresztes Schmidt
e6c159fb70 Vector2: Make coordinate components public
The components were already unconditionally/without side-effects writable. Let's make them public so we don't need the setters.
2021-05-16 16:42:58 +02:00
Peter Keresztes Schmidt
60db1c2eaf Coord: Rename to Vector2
The class is not only used to represent coordinates but also lengths in XY.
Vector2 is a more fitting/general name for this purpose.
2021-05-14 20:14:50 +02:00
Isaac Connor
bc6ba0a772 Merge branch 'master' of github.com:ZoneMinder/zoneminder 2021-05-03 13:18:51 -04:00
Isaac Connor
8bd876d8c8 improve warning message to include the values that don't match 2021-05-03 13:18:39 -04:00
Isaac Connor
90dff85e40 Only default to BGRA when colours are > 1. 2021-05-03 13:17:58 -04:00