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
Peter Keresztes Schmidt
e5ceed31cc
Image: Fix a typo introduced in 3f5dbb7780
2021-05-02 23:22:49 +02:00
Isaac Connor
3f5dbb7780
Default to rgba when subpixelorder is not specified
2021-05-02 14:07:29 -04:00
Isaac Connor
ad388e9fc5
Free up encodejpg_ccinfo in Deinitialize
2021-05-01 14:49:33 -04:00
Peter Keresztes Schmidt
68bedfe48f
Fix logging format string mismatches
...
* Remove SZFMTD format macro and use %zu instead for size_t. %zu is understood by every compiler nowadays.
2021-04-30 00:26:24 +02:00
Peter Keresztes Schmidt
36205258c0
Image: Fix crash in Annotate in GRAY8 and RGB24 mode
...
Actually advance the image buffer pointer by one image line when looping through the codepoint lines.
2021-04-27 21:11:50 +02:00
Peter Keresztes Schmidt
3020acf994
ZmFont: Store character padding in font file
...
The size/variant specific character padding should be stored with the font data.
Modify the FontBitmapHeader accordingly and introduce a version field in the FontFileHeader
so we are able to check we have a font file with the right structure associated with that version.
The version field is set to 1 in this changeset.
2021-04-25 23:13:21 +02:00
Peter Keresztes Schmidt
a918e8aeba
Image: Modernize Annotate method
2021-04-25 23:13:21 +02:00
Peter Keresztes Schmidt
0c939f45dd
ZmFont: Rework/modernize API
2021-04-25 23:13:21 +02:00
Isaac Connor
aad3b243c7
initialize padding
2021-04-20 14:10:33 -04:00
Isaac Connor
bb0741dc6f
Add missing initializers
2021-04-20 12:59:19 -04:00
Peter Keresztes Schmidt
4894c319cc
Image: Fix Wtype-limits warnings in zm_convert_yuyv_rgb
...
The intermediate values can be negative. Change the variables to be signed so the clamping later on works correctly.
2021-04-12 08:58:57 +02:00
Peter Keresztes Schmidt
11cfa86de3
Image: Fix Wtype-limits warnings in Annotate
...
line[c] is a char. There is no possibility for it to be larger than 0xff. Remove these checks.
2021-04-12 08:58:56 +02:00
Peter Keresztes Schmidt
b5f3682d4e
utils: some more reshuffling/grouping and formatting
2021-04-04 01:18:34 +02:00
Isaac Connor
bcd0e84a31
do sws_scale from decoded image to Image using a member context and avframe to save a few cycles
2021-04-01 13:22:57 -04:00
Isaac Connor
1c9bc5c27f
code doc and spacing
2021-04-01 11:51:18 -04:00
Peter Keresztes Schmidt
4e8c7d1f7c
Eliminate non-thread-safe calls to localtime
...
localtime uses an internal static storage to which a pointer is given as return value.
Due to this it is not safe to call localtime from multiple threads since the same static storage is used.
Use localtime_r instead which allows to pass in a tm struct.
Fixes:
https://github.com/ZoneMinder/zoneminder/security/code-scanning/24
https://github.com/ZoneMinder/zoneminder/security/code-scanning/25
https://github.com/ZoneMinder/zoneminder/security/code-scanning/26
https://github.com/ZoneMinder/zoneminder/security/code-scanning/27
https://github.com/ZoneMinder/zoneminder/security/code-scanning/28
https://github.com/ZoneMinder/zoneminder/security/code-scanning/30
https://github.com/ZoneMinder/zoneminder/security/code-scanning/31
https://github.com/ZoneMinder/zoneminder/security/code-scanning/33
https://github.com/ZoneMinder/zoneminder/security/code-scanning/58
https://github.com/ZoneMinder/zoneminder/security/code-scanning/59
https://github.com/ZoneMinder/zoneminder/security/code-scanning/63
https://github.com/ZoneMinder/zoneminder/security/code-scanning/64
https://github.com/ZoneMinder/zoneminder/security/code-scanning/65
2021-03-21 21:42:02 +01:00
Peter Keresztes Schmidt
d9568a98c0
Drop zm_thread which has been replaced by STL implementations
2021-03-04 10:55:46 +01:00
Isaac Connor
57585e4986
Not sure why raw_fd should be static...
2021-03-01 16:46:48 -05:00
Peter Keresztes Schmidt
76e6c468e8
rgb: Convert some constant defines to constexpr
...
Using defines interferes with fmt.
Also rename them according to the Google styleguide.
2021-03-01 00:38:21 +01:00
Isaac Connor
224fcd2cd3
Merge branch 'master' of github.com:ZoneMinder/zoneminder
2021-02-25 14:58:45 -05:00
Isaac Connor
d8e37945a3
TRY OUT SWS_POINT|SWS_BITEXACT scaling
2021-02-19 13:44:37 -05:00
Isaac Connor
d85e4121ef
set pts of dest_frame to make debug less confusing
2021-02-19 12:44:24 -05:00
Isaac Connor
0b0df96271
Merge branch 'master' of github.com:ZoneMinder/zoneminder
2021-02-18 16:05:10 -05:00
Isaac Connor
99264e4072
Fix swscale failing on resolution change. Fixes #3161
2021-02-12 11:55:25 -05:00
Isaac Connor
fab7efa003
Fix PrimeCapture on local cams. We need to be able to call it for each monitor
2021-02-09 20:29:37 -05:00
Peter Keresztes Schmidt
9dc3f15eac
Image: Replace qsort with std::sort
...
std::sort has stricter complexity requirements than qsort and can be better optimized
by the compiler due to templating.
2021-02-06 15:41:56 +01:00
Peter Keresztes Schmidt
0dbc39ee25
Cleanup and reorganize includes
...
With this commit a unified structure for includes is introduced.
The general rules:
* Only include what you need
* Include wherever possible in the cpp and forward-declare in the header
The includes are sorted in a local to global fashion. This means for the include order:
0. If cpp file: The corresponding h file and an empty line
1. Includes from the project sorted alphabetically
2. System/library includes sorted alphabetically
3. Conditional includes
2021-02-04 18:02:01 +01:00
Peter Keresztes Schmidt
5a57efdfe2
Replace deprecated C header includes with the C++ ones.
2021-02-04 05:39:03 +01:00
Isaac Connor
f868d92269
Fix colour shift in Crop function due to not multiplying x position by colours
2021-02-02 23:19:53 -05:00
Isaac Connor
7e469a28fa
remove redundant code, code style and remove some unnecessary multiplies
2021-02-02 23:19:53 -05:00
Isaac Connor
b47d2428da
Minor code, debugging improvements
2021-01-30 20:34:39 -05:00
Isaac Connor
7cc21b0d0b
Always load AvFrame to RGBA
2021-01-26 12:22:07 -05:00
Isaac Connor
0f7c46e2cc
Merge branch 'master' into zma_to_thread
2021-01-15 14:56:00 -05:00
hax0kartik
6845c2cab4
Fix padding issue in timestamp code
2021-01-15 11:46:30 +05:30
Isaac Connor
f3c4bb0027
Add AVBufferRef setup when Populating AVFrame from Image. This allows hwtranfer to work because it relies on AVBuffer AVFrame. Please note that we don't want AVBuffer to free the buffer so we pass an empty function to it.
2021-01-11 13:46:50 -05:00
Isaac Connor
9fb8e51ff2
Set imagePixFormat everywhere. Add PopulateFrame which creates and AVFrame pointing to the image's buffer. Will do this with proper refcounting eventually
2021-01-11 13:46:50 -05:00
Isaac Connor
ee8f940acf
Add some debug
2020-12-23 18:18:16 -05:00
Isaac Connor
39212d8ca0
Remove or increase debug level
2020-12-15 15:59:22 -05:00