The MPEG encoder's size is set by the stream's first frame. When playback moved
on to an event from a monitor with another aspect ratio, PackImage scaled its
frames to that size and distorted them. Scale them to fit inside it, centred on
black, with even sizes and offsets so subsampled chroma stays aligned. The black
fill is done by hand because av_image_fill_black needs FFmpeg 4.2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A packed planar frame whose width is a multiple of 32, such as 32x16 YUV420P,
has the same luma stride as the 32-byte layout, so PackImage picked that layout
and then refused the image because it needs more bytes than the frame has. The
frame was dropped. Accept a layout only if it also fits Size(), so the packed
one is tried next.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each hint is its own request, so two sends for the same event, such as a
boundary 0 and then the event found by the refresh, could reach zms out of
order and leave it with the older one. The page now waits for the replies to
one send before starting the next; a zms restart drops that wait, since the
old commands went to the old process.
When zms stopped at the end of an event because the filter had nothing
further, or the hint came too late, a hint arriving afterwards was stored but
playback stayed paused, so an event recorded since was never played. A
SET_EVENT that names an event in the direction we stopped in now resumes
through the end-of-event wait, unless a user command came in between.
Give up on an unanswered neighbour lookup after 5s rather than 10s, so a
retry still arrives within zms's 10s wait.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PackImage assumed every Image has 32-byte-aligned rows. An Image that wraps a
caller's buffer is packed (width * colours), and one wrapping an AVFrame keeps
the frame's stride, so mapping them on a 32-byte stride read the wrong rows
and ran past the end of the buffer. Use LineSize() for packed formats, match it
against the 32-byte or packed layout for planar ones, and refuse a mapping
larger than Size().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gapless playback over zms follows the next/prev events the event view
sends with CMD_SET_EVENT. Reviewing the first version found these gaps:
- An event that ended before the UI's hint for it arrived fell back to
zms's same-monitor query and skipped the other monitors' events again.
The page needs a status poll and two requests to send that hint, and
at 10x a ten second event lasts one second. Once a UI has sent any
hint (ui_managed) zms never uses the same-monitor query: it holds on
the last frame, like a pause, until the hint arrives, and stops after
kHintWait (10s) if none does. Streams with no UI behave as before.
The choice is EventStream::ChooseNeighbour, a static so it is tested.
- A hinted event deleted since the UI found it fell back to the
same-monitor query, leaving the filter. It now stops there, as
stream.php already does for a target deleted before forwarding.
- MPEG streams copied each frame into encoder buffers sized for the
first frame's dimensions, format and packed stride. Text frames are
drawn in the monitor's colours (usually RGB32) while event frames are
RGB24, a frame from another monitor can be larger, and Image rows are
padded to 32 bytes, so all three overran those buffers. The scaling
added to StreamBase only handled size, and the live stream never set
the tracked size. VideoStream::EncodeImage now converts any Image to
the encoder's own size, format and stride with sws_scale, and every
MPEG path uses it; the tracking in StreamBase is gone.
- loadEventData kept the previous event's video decoder when the new
event had none, so a missing jpeg showed the previous camera's frame
under the new event. It now drops it.
- The MPEG path only read jpegs, so an event recorded as video only
streamed nothing. Both paths now take frames from loadFrameImage,
which falls back to the event's video as the jpeg path already did.
tests/zm_eventstream_hints.cpp covers the message decoding, which hint
applies to which event, ChooseNeighbour (including Id order
10(M1) 11(M2) 12(M1) 13(M2), which went 11 -> 13) and PackImage.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>