This reverts commit 978a0821ee.
The stability of the negotiation process has never been studied
with multiple rounds.
It has always been documented to users that scale was the filter
to insert to manage format conversions. A second filter for
a specific type of conversion should never have been added:
the proper fix for the issue that this commit tried to fix is
to give scale the ability to handle premultiplication too.
Add a small synthetic TrueHD sample that exercises large MAT padding in
spdifenc. The sample covers both the input_timing path with padding above
MAT_FRAME_SIZE / 2 and the output_timing discontinuity path.
It also verifies queued MAT frame emission when one input packet completes
more than one MAT frame.
Signed-off-by: Nathan Lucas <nlucasgit@gmail.com>
Deprecate MMX. No change in performance. Also add test coverage in
checkasm.
pred8x8_dc_rv40_mmxext: 10.0 ( 1.24x)
pred8x8_dc_rv40_sse2: 10.0 ( 1.24x)
Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>
Remove the static supported_formats[] allowlist from hwcontext_cuda.
cuda_frames_get_constraints() now iterates all registered pixel formats
and includes every non-hwaccel, non-palette format. cuda_frames_init()
validates with av_pix_fmt_desc_get() instead of checking against the
allowlist.
Palette formats have a special-cased use of plane[1] for the palette itself
and it's not worth the hassle of supporting in an otherwise clean generic
copy loop.
Also add a roundtrip test that uploads a deterministic byte pattern to
CUDA, downloads it back, and verifies the data match. This tests all
non-hwaccel pixel formats. The test is gated on CONFIG_CUDA.
This fixes a 15+ year old bug.
The novelty check read its previous-frame envelope from
prev_energy_subshort after the sub-block loop had already overwritten
it with current-frame values, so early sub-blocks were compared
against the frame's own future instead of the past. That accident
suppressed short-period pitch trains well enough, but also suppressed
genuine onsets, and could not see pulse periods beyond ~12ms at all:
on quiet slow pulse trains (engine-idle buzz and the like) the ratio
test leaks sporadic isolated short excursions, each an audible click -
reported against this encoder since 2015, at every bitrate, and
immune to disabling every coding tool.
Keep a rolling two-frame history of HP sub-block peaks instead and
require an attack to tower over it: within ~12ms unconditionally
(pitch-rate trains), and within ~44ms when coming from steady
long-window state (slow trains, where an isolated short excursion can
only click). Dense irregular transients tower locally and reset
frames_since_short, so their block switching is untouched.
Stereo decisions are made per band before quantization, from the psy
model's spectra, and carry cross-frame memory (EMA-smoothed statistics,
per-grid mode banks, leave-hysteresis) so the image holds instead of
churning:
* M/S adopts content-driven and rate-free (side under half the mid);
for mid-dominant bands M/S is simply the better coding at every
rate, and a wandering L/R fraction reads as image instability.
* I/S competes with M/S above 6.1 kHz instead of only seeing M/S
rejects (which are exactly the wide bands it cannot render), and
engages under SUSTAINED strain only: the pressure ramp gated by the
lambda floor, so pressure spikes at a comfortable operating point
cannot flood it onto content where coding the side is affordable
and strictly better. Unengaged candidates fall back to M/S.
* Pairs whose joint-tool candidacy fraction stays low decouple:
block switching goes per-channel and M/S stops, matching how
independent coding wins on diffuse decorrelated content.
* PNS in a pair is reserved for clearly-wide bands (it renders
uncorrelated noise per channel).
Block switching for a pair is decided through the psy window_pair()
hook so common_window survives transients.
The NMR rate-to-bandwidth table is retuned upward at >= 48 kbps/ch to
track the bandwidth strong encoders deliver; both quality metrics
improve on a 16-clip battery and wider regresses. Lower rates are
unchanged.
Rate control: replace the integral servo with a stateless pressure
offset (exp2(-K*fill/R)) so a drained reservoir cannot wind up and
crater quality after loud stretches; slew-limit the final operating
lambda per frame (bits deviate instead, the reservoir absorbs); seed
the reservoir full at stream start; and track rate strain explicitly:
a long-frame lambda EMA against anchors that scale up when the achieved
distortion/mask ratio flags noise-class content (whose psy masks are
wholesale violated and lambda reads inflated), plus a lambda min-tracker
separating sustained starvation from transient spikes at a comfortable
operating point. The resulting pressure ramp gates every
pressure-adaptive tool from one place.
CPE budget pooling: solve both channels of a pair jointly under one
shared lambda against a pooled budget (NMRSlot defer/solve/commit)
instead of an equal per-channel split, which starved the mid/carrier
while the side gold-plated. Mono and VBR output are unchanged.
Transients: isolated onsets are coded uniformly finer across the short
run and repaid from steady stretches; dense-beat runs get a
starvation-scaled boost; a transition premask clamps START-frame
thresholds toward the previous long frame (an attack cannot mask
backwards).
Decision memory: marginal per-frame re-decisions oscillate audibly, so
every stateful choice now carries hysteresis - band zeroing, PNS
enter/leave with debounce (and near-masked bands staying noise until a
loudness guard), per-grid stereo mode banks that survive window
switches, and the short-TNS accept state.
TNS-covered bands price distortion by the synthesis filter's
re-amplification gain, so the trellis spends where noise will actually
be heard.
Reject negative recording durations for input and output -t before they reach streamcopy or trim handling. Keep -t 0 accepted.
Signed-off-by: 张永鹏 <roc63@outlook.com>
Replace the first-page packet scan with a direct use of the first
packet's duration as the timestamp offset (the Vorbis I spec
guarantees it produces no PCM output).
Track last_page_granule to correctly anchor EOS trimming regardless
of any initial granule offset. Track bos_pos to reinitialize parser
state at stream boundaries without resetting at page boundaries.
Restore the granule=0 workaround from ticket #3710 and handle
chained streams by clearing bos_pos when new headers are collected.
Vorbis I spec: https://xiph.org/vorbis/doc/Vorbis_I_spec.html
Older versions of Clang (17 and older) errored out on the previous
form like this:
./src/tests/checkasm/sw_ops.c:210:9: error: expected expression
210 | static_assert(sizeof(src0[1]) >= sizeof(uint32_t[256]), "palette plane too small");
| ^
/usr/include/assert.h:158:24: note: expanded from macro 'static_assert'
158 | # define static_assert _Static_assert
| ^
While newer versions of Clang merely warned about it:
./src/tests/checkasm/sw_ops.c:210:9: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]
210 | static_assert(sizeof(src0[1]) >= sizeof(uint32_t[256]), "palette plane too small");
| ^
/usr/include/assert.h:158:24: note: expanded from macro 'static_assert'
158 | # define static_assert _Static_assert
| ^
Instead of awkwardly reverse-engineering each uop to reflect
it back to the corresponding SwsOp, this leverages the new
compile_uops() API to directly test the uop in question.
This is not only vastly simpler but also fixes several major
shortcomings with the previous design, such as always having
to keep the reflection code in sync for any newly added uop,
or not testing uops that get translated to a packed shuffle
fast path.
The major downside is that arch-specific uops can now no longer
be tested against the C reference unless we specifically add
a C reference function for each relevant uop; and also, that the
packed shuffle fast path is currently no longer tested by checkasm.
(But this will be fixed by my upcoming pshufb uop series)
Another downside is that this effectively disables testing for e.g.
aarch64, since it does not yet use the uops architecture.
$ time checkasm --test=sw_ops --repeat=10 # 1.85s -> 1.39s
Signed-off-by: Niklas Haas <git@haasn.dev>
Rather than having two uops for the C reference code and a separate
uop for the x86 backend, we can just implement the C reference
using the same register-register assignment logic.
This results in only slightly worse codegen, since the compiler is
smart enough to eliminate the unnecessary copies.
The main downside is the fact that we need to allocate extra stack space
to back-fill the remaining (unused) pointers. In theory, we could do this
more efficiently by re-using unused *input* registers directly, but that
would require a lot of reliance on compile-time constant folding teasing
apart the entire register index tracking loop and duplicate check, so this
is a useful middle ground.
On platforms like x86, we still don't care about the PERMUTE vs
COPY distinction, but it's also harmless (2-3 extra lines to
instantiate the underlying MOVE macro on both uop variants).
Finally, we need to add a mask to the move uops to keep track of which
outputs are actually needed (especially for checkasm). Though it does result
in the rather unfortunate downside that it bloats the names of the uop
names.
The op lists change to reflect the new representation, e.g.:
rgb24 16x16 -> bgr24 16x16:
[ u8 +++X] SWS_OP_READ : 3 elem(s) packed >> 0
min: {0 0 0 _}, max: {255 255 255 _}
[ u8 +++X] SWS_OP_SWIZZLE : 2103
min: {0 0 0 _}, max: {255 255 255 _}
[ u8 XXXX] SWS_OP_WRITE : 3 elem(s) packed >> 0
('X' unused, 'z' byteswapped, '=' copied, '$' const, '+' integer, '0' zero)
translated micro-ops:
u8_read_packed_xyz
- u8_permute_zyxw
+ u8_permute_xyzw_txz_xzt
u8_write_packed_xyz
Signed-off-by: Niklas Haas <git@haasn.dev>
This reverts commit 7bc35b8426.
The aim of this patch can now be achieved via checkasm's
--function pattern matching.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Convert packed 24/32-bit RGB/BGR/RGBA/BGRA input to PAL8 using a per-frame palette
whose colors are placed on a face-centered cubic lattice (realized as the
scaled D3/D4 checkerboard lattice), with a user-supplied density controlling
the number of lattice steps spanning one color axis.
Only lattice points actually used by a frame enter its palette; if a frame
needs more than 256 of them, the filter will itearatively drop palettte
entries and reassign affected pixels until 256 color remain
lookup uses the Conway-Sloane rounding algorithm. Supported dithering
modes: none, ordered 8x8 bayer (swscale), Cluster & Void blue noise and
Floyd-Steinberg error diffusion.
Co-Authored-by: Fable-5
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
sizeof(16 * count) evaluates to 4 and thus only the first 4 bytes of aes
output was being compared. Removing the sizeof operator will ensure that
the whole output buffer will be compared.
When creating nested directories (e.g. /a/b/c), a genuine mkdir()
failure for an intermediate component was overwritten by later
attempts, making the original failure harder to diagnose.
Stop immediately on intermediate errors other than EEXIST, preserving
errno for the caller. Existing path components remain non-fatal, as
required by mkdir -p semantics. Add a regression test for creating a
child below an existing parent directory.
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
Since bc1a3bfd2c, missing reference
pictures are not replaced with generated pictures unless `-flags
show_corrupt` is used. For `ST_FOLL`/`LT_FOLL` reference pictures,
however, generation of missing references is required by the spec per
8.3.3. We should not require the `show_corrupt` flag to be used in
order to be spec-conformant, so this patch removes the `show_corrupt`
behaviour added in bc1a3bfd2c for
`ST_FOLL`/`LT_FOLL` references and instead unconditionally generates
reference pictures in these sets when unavailable
Fixes: NUT_A_ericsson_5
Fixes: RPS_D_ericsson_6
This is a temporary implementation until support for bitstream filter graphs is
generically added to the scheduler.
The dual track tests are as such changed so their output is not affected by builds
with liblcevc-dec enabled.
Signed-off-by: James Almer <jamrial@gmail.com>
When the blending factor was calculated to be 0, the hot path skipped
updating variables later emitted in metadata.
Fix the flow to ensure they are populated consistently.
Extend the FATE test suite to check metadata output.
Add a small self-contained lavfi test for the photosensitivity filter's
blend path. The graph produces one black RGB frame followed by two white
RGB frames, then runs:
photosensitivity=frames=2:threshold=95:blend=0.5
The threshold is chosen so that the first black-to-white transition
barely exceeds the detector limit. A full 8x8 RGB grid transition has
badness 64 * 3 * 255 = 48960, while threshold=95 gives 48640 for the
first checked history window. That forces the filter into the blend
branch without needing any external sample.
With blend=0.5, the runtime factor is 48640 / 48960 * 0.5, or about
0.4967. The fixed-point blender truncates this to an input-frame weight
of 127/256, so blending black toward white produces an RGB component
value of 126. The reference therefore records black, the blended gray
frame, and then the following accepted white frame.
This makes the otherwise cryptic CRCs tie directly to the blend
calculation and history update behavior.
Co-authored-by: Codex CLI <noreply@openai.com>
Add a new boolean option -update_filemtime to the image2 muxer that
sets each output file's modification time based on the creation_time
metadata plus the frame's PTS offset.
This is useful when extracting frames from dashcam or action camera
footage where wall-clock timestamps should be preserved on the output
files, allowing photo management tools to sort frames by capture time
without post-processing.
The option requires creation_time metadata to be set (via -metadata
creation_time=...). If not present, a warning is logged and the
option is silently disabled. When PTS is unavailable, the creation
time is used as-is without frame offset.
Uses utimes() on POSIX and _utime() on Windows to set file timestamps
with microsecond and second precision respectively.
Includes a FATE roundtrip test that writes frames with a known
creation_time, reads them back using the demuxer's -ts_from_file
option, and verifies the PTS values match the expected timestamps.
Closes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22537
Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
When encoding a stream with an amount of samples multiple of a block, the last
the last 256 samples would be lost as the encoders were not marked as
AV_CODEC_CAP_DELAY.
This can be easily reproduced with:
ffmpeg -f lavfi -i sine -ac 2 -af atrim=start_sample=0:end_sample=4608 -c:a eac3 -f framecrc -
Signed-off-by: James Almer <jamrial@gmail.com>
It is not used for normal builds and is more an auxiliary
dev tool; move the code into a new file, uops_macros_gen.c
to be built as a DEVPROG.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Test av_video_hint_alloc with 0, 1, and 4 rects, and
av_video_hint_create_side_data. Verifies that av_video_hint_rects
and av_video_hint_get_rect return pointers consistent with
rect_offset and rect_size, write/read-back of rect coordinates,
both hint type values, and OOM paths via av_max_alloc.
Coverage for libavutil/video_hint.c: 0.00% -> 82.05%
The remaining uncovered lines are the nb_rects overflow guard and
the av_buffer_create / av_frame_new_side_data_from_buf failure
cleanup paths, which av_max_alloc() cannot reach since it forces
the first allocation to fail.
Test all 5 public functions: av_mastering_display_metadata_alloc,
av_mastering_display_metadata_alloc_size, the create_side_data
variant, av_content_light_metadata_alloc, and its create_side_data
variant. Verifies the {0,1} rational defaults set by get_defaults(),
write/read-back of HDR metadata fields, frame side data attachment
for both mastering display and content light metadata, and OOM
paths via av_max_alloc.
Coverage for libavutil/mastering_display_metadata.c: 86.49% -> 100.00%
Test av_dovi_alloc, av_dovi_metadata_alloc, and av_dovi_find_level.
Verifies that the four inline offset-based accessors (get_header,
get_mapping, get_color, get_ext) return pointers consistent with
the offset fields, that find_level returns the first matching ext
block or NULL for a missing level, and OOM paths via av_max_alloc.
Coverage for libavutil/dovi_meta.c: 63.16% -> 100.00%
For AArch64, AV_CRC_32_IEEE_LE implementation has codepath which is triggered
when input buffer size is >= 8192. Thus to ensure sufficient test coverage,
size of the input buffer in the test file is being increased from 8192 to 16384.
This is in line with other encoders, and is needed by the matroska muxer
to properly signal end trimming samples.
gaplessenc-pcm-to-mov-aac changes as the mov muxer now uses this information
when writing the edit list, so the shorter frame duration is not needed.
Signed-off-by: James Almer <jamrial@gmail.com>