The setup macro should be in init function, not in configure
output function. Current placment would break scale_vt based
tone mapping as the output color parameters are never initialized
and cannot be mapped correctly.
We previously used the spec convention of Lw=1000 and gamma = 1.2
for HLG EOTF to linear space, but that mapping works terribly with
common tonemap operators as that would map too many of the area
above diffusion white and make the result overly bright.
In ITU report BT.2446-1 page 15, it recommends to use Lw=291 with
a gamma of 1.03 so that the mapped HLG diffusion white is at around
90% of SDR peak of BT.1886, or around 78nit. This compress most
of the signal into near SDR range before we apply any tonemap
operators, and it shows promising results.
This approach also requires least code change as we only need to
modify EOTF of HLG for each implementations.
Signed-off-by: gnattu <gnattuoc@me.com>
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
only_first_vframe originally waited for the first decoded frame from every
video stream. That breaks on files with multiple video streams where one
target stream never reaches "first frame seen" in this path.
For example, a Matroska file with one real HEVC video stream and two
attached-picture streams (PNG and JPEG). With -threads 1, all three streams
were marked finished quickly. With -threads 0, the attached PNG stream was
opened with auto threading, its only packet was consumed, but
avcodec_receive_frame() returned EAGAIN and no frame was emitted. Since that
stream had no second packet, it never became finished. ffprobe then kept
demuxing the rest of the file while waiting for all target video streams to
finish, which could read essentially to EOF and appear to consume unbounded
memory.
Fix this in two ways:
- exclude attached-picture streams from the only_first_vframe target set, so
the mode only waits for real video streams
- change the safety fallback from counting packets for unresolved target
streams to counting overall scanned packets, so even unknown future cases
still terminate instead of scanning forever
This preserves the intended "first real video frame" behavior while making the
mode safe for problematic multi-stream inputs.