Commit Graph
100 Commits
Author SHA1 Message Date
gnattu 86198a7c8d fix deint typos 2026-07-01 16:26:36 +08:00
gnattu 25dcadf62c fix d3d11 helper patch creation 2026-07-01 16:26:36 +08:00
gnattu a5117dbcff adding ff_scale_adjust_dimensions to scale_d3d11 2026-07-01 16:26:36 +08:00
gnattu bfc89c9e74 extract d3d11 common helpers 2026-07-01 16:26:36 +08:00
gnattu ea5ac4f540 make d3d11 dep check more robust 2026-07-01 16:26:36 +08:00
gnattu 1873d31a64 avfilter/d3d11: add output copy options to shader filters 2026-07-01 16:26:36 +08:00
gnattu e251df31b4 avfilter/d3d11: add overlay output copy option 2026-07-01 16:26:36 +08:00
gnattu 2a67eed989 avfilter/d3d11: add tonemap/transpose/deint/scale filters 2026-07-01 16:26:36 +08:00
gnattu 8e98438a41 avfilter(scale_vt): fix broken macro place for scale_vt patch
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.
2026-06-11 00:47:28 +08:00
gnattu f10c96449a avcodec: add dtsx detection for dts hra
The magic sync word is taken from https://github.com/MediaArea/MediaInfoLib/commit/a58e2a2000d0236652dde9e6e0462cb0408aad28
2026-05-30 01:53:12 +08:00
gnattu d1b0170bf1 Use EOTF from BT 2446 Method B for HLG tonemap
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>
2026-05-28 10:57:06 +08:00
gnattu cd5c2c42a7 msys2: workaround buggy strndup in libass for MinGW 2026-04-14 00:06:45 +08:00
gnattu 64674b2474 Bump version to 7.1.3-5 2026-04-05 20:25:43 +08:00
gnattu e0f403dfdb ffprobe: avoid runaway only_first_vframe probing
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.
2026-04-04 12:30:10 +08:00
gnattu 12010c446d add safe bail out for fisrt-vframe ffprobe opt
The only_firsrt_vframe option was broken when a video stream is sparse,
starts late, is corrupt, or keeps feeding non-decodable packets.
My test videos are too good to not revealing this, but our users would
have files that is in an unideal state which make this option to read
forever untill EOF, and when the file is huge enough or a livestream,
This option would hang the probing for a long time.

This adds a few safeguard to bail out after a reasonable amount of
packets have being decoded.
2026-03-23 02:18:49 +08:00
gnattu eeab90828e fix file path 2025-10-13 16:47:16 +08:00
gnattu 990261a678 fix file path 2025-10-13 16:03:21 +08:00
gnattu 3e42599339 pin nasm to v2 on macOS build 2025-10-11 02:37:20 +08:00
gnattu 4a8b70f922 bump dav1d to include nasm v3 fix 2025-10-07 05:30:13 +08:00
gnattu d9911b19f3 uninstall pinned cmake first 2025-09-05 16:12:26 +08:00
gnattu 1e880ca673 let homebrew install coreutils instead 2025-09-05 15:34:40 +08:00
gnattu e35dcb1a11 Add nproc alias for macOS builder 2025-09-05 13:03:50 +08:00
gnattu a7d180fd21 fix lame host config 2025-07-20 18:23:49 +08:00
gnattu 4d42bc5b3a Cross compile x86_64 macOS build on arm64 runner
GitHub officially deprecates the last x86_64 based public standard
x86_64 macOS runner and this runner will be fully unavailable on
November 14, 2025.
2025-07-20 17:32:17 +08:00
gnattu aa1a346fff Add windows arm builder, disable gcc build for windows 2025-06-14 23:38:51 +08:00
gnattu fbee6773a0 rename patch 2025-06-08 16:27:55 +08:00
gnattu c5c4146d16 lavc/videotoolbox: don't return external error for invalid vt frame
Some video sources are not reliable and will contain frames that
is not decodable with hardware accelerators. Current ffmpeg's
scheduling has low tolarance for decoder errors it does not understand.

Just return 0 after unref the frame instead so that ffmpeg will no
longer abort early due to videotoolbox is not able to decode a frame.
2025-06-08 04:19:55 +08:00
gnattu 30dc67ad75 avfilter/tonemap_opencl: use MKTAG macro 2025-05-15 11:18:25 +08:00
gnattu d337d39a59 avfilter/tonemap_opencl: add scalar reshaping for qcom gpu 2025-05-14 17:24:27 +08:00
gnattu dcbf6cbbd9 avfilter/tonemap_opencl: explitly convert float4 2025-05-12 19:27:57 +08:00
gnattu 60e253d7a4 avfilter/tonemap_opencl: reduce memory load for mmr reshaping on p/t channel 2025-05-12 11:07:28 +08:00
gnattu 55bf543940 avfilter/tonemap_opencl: use macro to reduce duplication 2025-05-12 00:10:34 +08:00
gnattu 01866d77af avfilter/tonemap_opencl: vectorize dovi reshaping
avfilter/tonemap_opencl: vectorize Dolby Vision reshaping

Vectorize the Dolby Vision reshaping process to handle 4 pixels at a time, similar
to what is used in the tone mapping stage. This change allows us to read the dovi
buffer once and reuse parameters for 4 pixels which reduces memory load.
Most of the pipeline, including the common polynomial reshaping, benefits from
vectorization. The only exceptions are the coefficients lookup for intensity channel
and MMR reshaping: intensity lookup remains scalar because it processes 4 vec4
values that must be handled sequentially, and MMR reshaping cannot be vectorized
due to its inter-channel dot products.
With this optimization, 4K60 Dolby Vision tone mapping is now reliably achievable
on the RK3588.
2025-05-11 22:01:56 +08:00
gnattu e34b5cb73f avfilter/tonemap_opencl: manually unroll ipt loop
This is requried for GPU platforms with unideal compilers like
Qualcomm GPUs on Windows. When the compiler unrolls the IPT
reshaping loop badly the performance suffers a lot. Unroll it by
hand mitigates this, and I noticed no performance difference on
arm mali.
2025-05-11 13:32:32 +08:00
gnattu d56e9b8a47 ffprobe: always use ifile->nb_streams for first vframe option
The global static nb_streams is dynamic and can be extended to a
number that would cause out of bounds access. Always use the
nb_streams from the input file structure and stop rescaling our
checking bitmask with the dynamic nb_streams. This should still
work for all video files.
2025-05-08 06:05:13 +08:00
gnattu 9203c4ad94 Remove all armhf build configs 2025-05-08 01:37:32 +08:00
gnattu 11ac3cb82c Remove 32bit arm runners
The support for 32bit arm CPU is discontinued for 10.11. Remove the
runners for now.
2025-05-08 00:32:19 +08:00
gnattu 7aef430762 avfilter/tonemapx: use cpu friendly conditional assignments
The orignial logic ported from the GPU shader uses (fused) multiply
and add to compute the dovi coefficients. But we are not actually
blending the values, and we are selecting all lanes based on one
boolean condition, a simple conditional assignment is much faster
on CPU.

This commit also uses casting instead of extraction to get the low 128b
for the avx code path. Casting is free but extraction is an instruction
with 3-cycle latency.
2025-05-07 17:33:31 +08:00
gnattu 5d4b800f2a Fix CMake4.0+ on macOS 2025-05-07 15:11:48 +08:00
gnattu 6dc1b41e6a avfilter/tonemap_opencl: always use eotf for lms2rgb
This actually improves the quality of the lut. The old problem is
due to an rkmpp bug, not the use of eotf.
2025-05-06 10:00:10 +08:00
gnattu e1a20ed375 avfilter/tonmap_opencl: handle overbrightness correctly in 3dlut
The old capping will use the second brightest cube instead of the
brightest one. The new capping will always use the brightest cube
and the values will be cancelled out during calculation, and only
the raw value of the brightest corner will left.

This is slightly slower as it introdced two more scalar ops, but
should still be fast enough.
2025-05-06 09:56:51 +08:00
gnattu a86c465349 avfilter/tonemap_opencl: fix comment style 2025-05-04 08:11:39 +08:00
gnattu 867289f004 avfilter/tonemap_opencl: reduce compute and memory load of 3dlut 2025-05-01 14:59:45 +08:00
gnattu b0c28f8997 lavc/huffyuvdsp: disable gcc vectorization
GCC vectorization with avx will break unit tests for this dsp
2025-04-15 15:11:12 +08:00
gnattu 1cd8fd143a avfilter/tonemap_cuda: properly return value 2025-03-23 03:51:27 +08:00
gnattu d23fec2487 avfilter/tonemap_*: use preinit function 2025-03-23 02:31:07 +08:00
gnattu b078b0f6d6 avfilter/tonemap_*: fix lost tonemap param during dovi re-init
For certain video inputs, the dolby vision metadata could be
missing on the first few frames which would cause the filter to
re-initialize itself for the first frame containing the dovi metadata.

This re-init behavior would mistakenly re-interpret the current
set param as user input which will create unwanted results due to
wrong tone mapping parameters. Fix this by using a separate value
for calculated param and never change the user input.
2025-03-22 13:07:14 +08:00
gnattu 0d8c33be63 avfilter/tonemap_cuda: fix typo 2025-03-21 22:13:18 +08:00
gnattu 5a20713010 avfilter/tonemap_*: clip input range for bt2390 2025-03-21 12:20:24 +08:00
gnattu 6e1d4d9072 avfilter/tonemap_opencl: code cleanup
Signed-off-by: gnattu <gnattuoc@me.com>
2025-02-12 07:19:30 +08:00
gnattu 24e835df21 avfilter/tonemap_opencl: implement tradeoff mode as 3dlut
This reworks the current tradeoff mode, which used to be a single
1D LUT for linearization, which is not fast enough on slow GPUs.
Instead, this makes the entire tonemap process a 3D LUT lookup.
This implementation first generates a 65x65x65 LUT on the GPU,
which has a similar compute cost to a single 400p frame. Then, it
uses tetrahedral interpolation to apply the LUT to the actual frame.
The interpolation quality is quite decent, and the interpolation
errors are very hard to notice unless in extreme conditions.

Signed-off-by: gnattu <gnattuoc@me.com>
2025-02-12 07:19:30 +08:00
gnattu fce96f7d1f fftools/ffprobe: handle multiple video streams 2025-01-21 17:38:12 +08:00
gnattu a7f3388119 fftools/ffprobe: add only_first_vframe option to show first video frame
Currently, ffprobe can only read frames at a specific interval,
and users have no options to select only video frames without
explicitly selecting a stream. This option instructs show_frames
to pick the first video frame and prints its information.
This will be useful for extracting tricky metadata, such as the
HDR10plus ST2094 metadata.
2025-01-21 17:38:10 +08:00
gnattu 0cc3603ade lavc/bsf/hevc_metadata: always remove dovi at the end of au
In rare edge cases the looping removal might leave some frames
with dovi metadata not removed for hevc. Always remove at the
end of au can also improve performance, and this is what the
upstream dovi_rpu is doing as well.
2025-01-16 20:01:40 +08:00
gnattu cde1084760 builder: just append optimization flags 2024-12-21 19:47:17 +08:00
gnattu 453273efa5 Fix indent 2024-12-21 00:44:23 +08:00
gnattu 3756ca70c5 builder: use fPIC for Linux libopus 2024-12-21 00:39:41 +08:00
gnattu 80bf279816 builder: use custom fork of libNE10 2024-12-20 23:04:33 +08:00
gnattu 71adc796a8 avfilter/tonemapx: require 10bit output for hdr 2024-12-20 22:42:51 +08:00
gnattu ef6fd8570b builder: set explicit optimization CFLAGS for opus 2024-12-20 21:58:50 +08:00
gnattu 191e8f6cba builder: explict set traget arch for libne10 2024-12-20 15:26:34 +08:00
gnattu 25f1cc2611 Add NE10 to enable more neon optimization for libopus
Unlike on x86, where libopus provides inline assembly, most of the
performance optimizations for ARM Neon are implemented in the NE10
library. We need to build it separately for optimal performance on
arm64 targets.
2024-12-20 15:13:59 +08:00
gnattu 9ccb771f76 avfilter/tonemapx: fix register type casting for neon 2024-12-20 12:53:42 +08:00
gnattu d1e0837533 avfilter/tonemapx: add dovi to hdr10 support
This adds a reshape-only mode for Dolby Vision videos without
a compatibility layer. In this mode, only Dolby Vision reshaping
will be performed, and the output will still be in SMPTE 2084
transfer.

The GPU-based filters already support this mode. This will be
useful in the future when we implement HDR transcoding.
2024-12-20 12:09:52 +08:00
gnattu a6686a4f31 fftools/ffmpeg_mux_init: default to input timebase for streamcopy
Stop trying to invent some "framerate-based" timebase when there is no
reason to think the stream is CFR at all.

This is a backport of upstream commit 10185e2d4c1e9839bc58a1d6a63c861677b13fd0
2024-12-10 15:00:38 +08:00
gnattu de15b28213 avformat/assenc: do not copy null terminator
The `par->extradata` buffer filled from some matroska files may be
null terminated, and use `ffio_write_lines` using the full buffer
length will copy this null character into the output files. This
results in a file in which there is a null terminator after the
header, but preceeding the actual content of the subtitle file.
Treat this buffer as a string and write line with the text length of this buffer to skip the null character.

Regression from 7bf1b9b
2024-11-26 14:05:29 +08:00
gnattu 44f786665b builder: use github as libisl mirror for ct-ng
The old sourceforge mirror is not reliable and ct-ng is recommending
using github as the mirror for libisl
2024-11-19 07:50:35 +08:00
gnattu 672861f34d avcodec/videotoolbox: backport AV1 hardware acceleration 2024-11-15 16:25:02 +08:00
gnattu 6b59d00772 lavc/videotoolbox: remove opengl compatability key
We are not using OpenGL and this compatability key could introduce
performance penalty on some Macs. Performance difference is neglible
on Apple Silicon but on old Intel Macs like the 2018 MacBook Air,
decoding performance could be reduced by 15% as the IOSurface might
make extra frame copies to reshape the pixel buffer.
2024-10-23 23:46:11 +08:00
gnattu 142e51bc22 avcodec/audiotoolboxenc: fix 7.1 channel mapping and sample rate
Both AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK and AV_CHANNEL_LAYOUT_7POINT1
should be mapped to kAudioChannelLayoutTag_AAC_7_1_B, otherwise neither
the back surround channel nor the side surround channel has sound.

aac_at has stricter sample rate than other encoders which should be
spcified to enable auto resampling.

alac with sample rate higher than 38400 will not play on Apple devices,
although higher sample rates are accepted by the encoder

All encoders provided by AudioToolbox can handle 32bit integer samples,
enable that for all encoders.
2024-10-23 02:11:17 +08:00
gnattu 1733fb8802 builder: use locked version for rust 2024-10-23 00:16:04 +08:00
gnattu ef477e9ded builder: use rust 1.81 2024-10-22 23:52:20 +08:00
gnattu 7107cc2e4f builder: don't use cargo-c 0.10.5 2024-10-22 23:44:02 +08:00
gnattu e4152b2631 avcodec/mpegtsenc: optimize check order 2024-10-22 23:06:35 +08:00
gnattu 1920af5630 avformat: make dovi config check public 2024-10-22 18:20:37 +08:00
gnattu 8e5841cd79 avformat: validate dovi config in muxers 2024-10-21 11:13:15 +08:00
gnattu 547d233809 bsf/av1_metadata: add remove_dovi and remove_hdr10plus 2024-10-16 19:08:08 +08:00
gnattu 15dd01d2d4 bsf/hevc_metadata: fix documentation or remove_dovi 2024-10-16 19:05:36 +08:00
gnattu 6c1cdd3043 remove redundant log 2024-10-15 13:53:37 +08:00
gnattu 75ab7952a3 avcodec/hevc_metadata: only remove side config once 2024-10-15 12:23:18 +08:00
gnattu ba9dd312ef also remove dovi config 2024-10-15 08:48:59 +08:00
gnattu 2906612df2 avcodec: add remove_dovi and remove_hdr10plus option to hevc_metadata bsf 2024-10-15 07:43:16 +08:00
gnattu 96edc7d0b2 avfilter/tonemap_opencl: cleanup leftover 2024-10-14 13:49:53 +08:00
gnattu 4c121420ab avfilter/tonemap_[opencl,cuda]: extend precision for constants 2024-10-14 07:46:54 +08:00
gnattu 7dd58ae4d3 avfilter/tonemap_opencl: print more digits to header 2024-10-13 22:43:34 +08:00
gnattu 81e35eae8d avfilter/tonemap_[opencl,cuda]: use macro 2024-10-13 18:57:20 +08:00
gnattu 669c8de111 avfilter/tonemap_*: better documentation for constants 2024-10-13 16:53:37 +08:00
gnattu 1dd26f0a4a lavc/videotoolboxenc: always set pixel buffer info 2024-10-12 16:40:46 +08:00
gnattu 4a02f81771 avfilter/tonemap_*: fix quantization errors for tv range handling 2024-10-12 16:39:47 +08:00
gnattu 2fdd1c5a0f avfilter/tonemapx: fix more range handling 2024-10-09 14:13:38 +08:00
gnattu 030e52469f avfilter/tonemapx: remove P016 support 2024-10-05 17:38:45 +08:00
gnattu 9ee0991f64 avfilter/tonemapx: stablize dovi handling 2024-10-05 16:27:30 +08:00
gnattu 6cbbce0257 avfilter/tonemapx: fix p010 overflow
Need to perform bit shift before saturation move to prevent overflow
2024-10-05 15:23:36 +08:00
gnattu 040ec3d720 avfilter/tonemap_cuda: use more stable range conversion 2024-10-04 11:06:39 +08:00
gnattu f1e8b1eede avfilter/tonemap_opencl: use more stable range conversion 2024-10-04 11:05:41 +08:00
gnattu aeb7a215d4 avfilter/tonemapx: fix typo 2024-10-04 03:54:07 +08:00
gnattu 5c04683679 avfilter/tonemap**: use more stable range and peak handling 2024-10-04 02:48:39 +08:00
gnattu 813ec07b84 avfilter/tonemapx: use fma neon intrinsics
No observable performance difference observed, and some compilers
even generate the same instructions for mla and fma intrinsics.

This is just a cleanup to always use fma for float32 for consistency.
2024-09-29 20:39:41 +08:00
gnattu 20affbb8d2 avfilter/transpose_vt: fix build on xcode 16
Xcode 16 marks VTPixelRotationSessionRef as macOS 13+ only type as well.
As it is technically only a pointer, use type void* in the struct and cast to VTPixelRotationSessionRef
when using.
2024-09-26 17:48:26 +08:00
gnattu 666d8625ba hevc: add 12bit videotoolbox decoding support 2024-09-18 13:17:04 +08:00