Commit Graph

231 Commits

Author SHA1 Message Date
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
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