Removes implicit checks for "do I need to output the buffer now?".
Codesize with Clang 19 with -O3 decreased from 7136B to 6108B
(although asv2_put_level() is now inlined).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Up until now, the encoder replicated all the border pixels
for incomplete 16x16 macroblocks. In case the available width
or height is <= 8, some of the luma blocks of the MB
do not correspond to actual input, so that we should encode
them using the least amount of bits. Zeroing the block coefficients
(as this commit does) achieves this, replicating the pixels
and performing an FDCT does not.
This commit also removes the frame copying code for insufficiently
aligned dimensions.
The vsynth3-asv[12] FATE tests use a 34x34 input file and are
therefore affected by this. As the ref updates show, the size
and checksum of the encoded changes, yet the decoded output
stays the same.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Add three missing requirements on bitstream conformance from 7.4.3.19 of
H.266 (V3). Issue found using fuzzing.
Signed-off-by: Frank Plowman <post@frankplowman.com>
When called for palette-predicted CUs, boundary_strength could cause
undefined behaviour due to accessing uninitialised motion information.
The spec doesn't include this, but in the reference software it seems
the deblock strength is always set to 0 for palette CUs due to some
implementation details: perhaps this is a spec issue?
Signed-off-by: Frank Plowman <post@frankplowman.com>
In d5dbcc00d8, it was hoped that detection
of subpicture overlaps could be performed at the tile level, so as to
avoid introducing per-CTU checks. Unfortunately since that patch,
fuzzing has indicated there are some structures involving
pps_subpic_one_or_more_tiles_slice where tile-level checking is not
sufficient. Performing the check at the CTU level should (touch wood)
be the be-all and and-all of this, as CTUs are the lowest common
denominator of the picture partitioning.
Signed-off-by: Frank Plowman <post@frankplowman.com>
The issue is that state->cur[] is 8-bits, but a+b+1 can overflow
before being clipped to 0xF in the following line, causing an incorrect
state to be saved for the next symbol.
This solves numerous bitstream desyncs, particularly when coefficients
with magnitude greater than 127 are sent.
Don't use a 7.1 EAC3 input file for which our decoder is not
bitexact; instead just use the asynth-44100-8.wav file
which (as a 7.1 file) exhibits the same issue fixed by
1b3f4842c1.
(Either the encoder or the resampler are still not completely
bitexact, so we limit the number of frames output.)
Also switch to a framecrc test so that the output channel layout
is directly contained in the ref file.
Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Flipping can already be accomplished by setting the crop_w/h expressions to
their negative values, so together these options can implement any of the
common frame orientations.
io_open and io_close2 callbacks may use opaque pointer stored in the
context. They are already inherited, so opaque should also be passed
through.
Fixes IMF playback in mpv.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Pierre-Anthony Lemieux <pal@sandflow.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
The buffer references may not be writable at this point, as the decoder
calls get_buffer2() with the AV_GET_BUFFER_FLAG_REF flag.
Fixes races as reported by tsan, producing correct output regardless of
threading choices.
Signed-off-by: James Almer <jamrial@gmail.com>
Currently, planarRgbToplanarRgbWrapper() always sets the alpha value to 255,
without taking the bit depth into consideration.
This commit restricts the alpha value to the bit depth.
Currently, packed16togbra16() always sets the alpha value to 0xFFFF,
without taking the bit depth into consideration.
This causes a bug on x86, which can be reproduced with:
./libswscale/tests/swscale -unscaled 1 -src xyz12le -dst gbrap12be
The problem arises in ff_hscale14to15_4_ssse3(), in the conversion
from gbrap12be to yuva444p, which comes after the conversion from
xyz12le to gbrap12be.
It has something to do with pmaddwd not working on unsigned values.
There is some code to deal with 0xFFFF if the input has a bit depth of
16, but not for bit depths < 16.
We could fix ff_hscale14to15_4_ssse3() to also work correctly with
0xFFFF on bit depths < 16, or we could just not write 0xFFFF there in
the first place, which is what this commit does.
Currently, packed30togbra10() always sets the alpha value to 0xFFFF,
without taking the bit depth into consideration.
This commit restricts the alpha value to the bit depth.
Currently, planarCopyWrapper() assumes that src[3] must be NULL when
the source format has no alpha plane.
This commit updates the condition for filling the alpha plane based on
the number of components available in the source format as well.
The SLIBOBJS variable was introduced in 56572787ae but is no longer used.
Another variable, SHLIBOBJS, was introduced after SLIBOBJS, in 20b0d24c2f.
The functionality from SLIBOBJS was effectively migrated to SHLIBOBJS in b77fff47d0.
No code has used SLIBOBJS since.
This commit removes all remaining references to SLIBOBJS from the build system.
The issue is that there is an explicit lack of synchronization as only the very
first invocation writes symbols and updates the state, which other invocations
then store.
This commit will properly set the duration field of Opus AVPackets.
Currently, duration is set to 0 on Opus packets from the RTP demuxer.
The Ogg muxer depends on the duration field to properly compute the page granule
value. Without a proper duration, the granule will be wrong, and result in
negative pts values in ogg files.
See oggenc.c:657 (ogg_write_packet_internal)
This commit calculates using the opus_duration function, which was copied
from oggparseopus.c
I moved this functionality and the existing opus extradata functionality
(added by me in 6c24f2b) into a new rtpdec_opus.c file.
Reviewed-by: Tristan Matthews <tmatth@videolan.org>
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
The backwards scanning done for incomplete final packets should not
assume a specific alignment at the end of the file. Truncated files
result in hundreds of thousands of seeks if the final packet does not
fall on a specific byte boundary, which can be extremely slow.
For example, with HTTP, each backwards seek results in a separate
HTTP request.
This changes the scanning to check for the end tag 1 byte at a time
and buffers the last 1 MiB to avoid additional seek operations.
Co-authored-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Justin Ruggles <justinr@vimeo.com>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
ol->frame_rate is 0/0, so we need to calcalute the correct value based on
the il->frame_rate instead. Also adjust the time base, PTS and frame_duration
values accordingly. (Logic taken from vf_tinterlace.c)
- Query GPU caps for B-frame support and warn if unsupported.
- Make `-max_b_frames` optional
- Drop explicit `-pa_lookahead_buffer_depth` requirement in
adaptive mode.
This allows the compiler to remove the implicit "Do I need to output
the PutBitContext buffer here?" checks.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
The earlier code allowed callers to use arbitrary values as
symbols_size as long as no symbols were present.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This turned out to be very beneficial: For GCC 13, the codesize
of ac3_output_frame_header went down from 4522B to 1247B and
from 10762B to 9298B for eac3_output_frame_header. For Clang 17,
the numbers went down from 3923B to 2477B and from 8338B to 6548B
(always with -O3).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This will allow the compiler to optimize the "is the cache full?"
branches away from some put_bits().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Fixes a Clang warning when asserts are disabled:
"variable 'quant' is used uninitialized whenever switch default is taken
[-Wsometimes-uninitialized]"
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>