summaryrefslogtreecommitdiff
path: root/libavcodec/vc2enc_dwt.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/vc2enc_dwt: Fix left shifts of negative numbersAndreas Rheinhardt2022-10-041-4/+3
| | | | | | Fixes the vsynth(1|2|_lena)-vc2-(thaar|t5_3) FATE tests. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc2enc_dwt: Avoid NULL - 0Andreas Rheinhardt2022-02-111-2/+4
| | | | | | | It is sane, but UB. It could happen in case of allocation errors in vc2_encode_init(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/vc2enc_dwt: Avoid left-shifting a negative value.Carl Eugen Hoyos2019-08-111-1/+1
| | | | Fixes ticket #7985.
* vc2enc_dwt: pad the temporary buffer by the slice sizeRostislav Pehlivanov2017-11-091-3/+9
| | | | | | | | | | | | | | | Since non-Haar wavelets need to look into pixels outside the frame, we need to pad the buffer. The old factor of two seemed to be a workaround that fact and only padded to the left and bottom. This correctly pads by the slice size and as such reduces memory usage and potential exploits. Reported by Liu Bingchang. Ideally, there should be no temporary buffer but the encoder is designed to deinterleave the coefficients into the classical wavelet structure with the lower frequency values in the top left corner. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: add support for Haar wavelet transformsRostislav Pehlivanov2016-02-201-0/+46
| | | | | | | This commit adds support for the (simple, allowed in the spec, but inferior in quality) Haar wavelet transforms. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* avcodec: add a native SMPTE VC-2 HQ encoderRostislav Pehlivanov2016-02-101-0/+229
This commit adds a new encoder capable of creating BBC/SMPTE Dirac/VC-2 HQ profile files. Dirac is a wavelet based codec created by the BBC a little more than 10 years ago. Since then, wavelets have mostly gone out of style as they did not provide adequate encoding gains at lower bitrates. Dirac was a fully featured video codec equipped with perceptual masking, support for most popular pixel formats, interlacing, overlapped-block motion compensation, and other features. It found new life after being stripped of various features and standardized as the VC-2 codec by the SMPTE with an extra profile, the HQ profile that this encoder supports, added. The HQ profile was based off of the Low-Delay profile previously existing in Dirac. The profile forbids DC prediction and arithmetic coding to focus on high performance and low delay at higher bitrates. The standard bitrates for this profile vary but generally 1:4 compression is expected (~525 Mbps vs the 2200 Mbps for uncompressed 1080p50). The codec only supports I-frames, hence the high bitrates. The structure of this encoder is simple: do a DWT transform on the entire image, split it into multiple slices (specified by the user) and encode them in parallel. All of the slices are of the same size, making rate control and threading very trivial. Although only in C, this encoder is capable of 30 frames per second on an 4 core 8 threads Ivy Bridge. A lookup table is used to encode most of the coefficients. No code was used from the GSoC encoder from 2007 except for the 2 transform functions in diracenc_transforms.c. All other code was written from scratch. This encoder outperforms any other encoders in quality, usability and in features. Other existing implementations do not support 4 level transforms or 64x64 blocks (slices), which greatly increase compression. As previously said, the codec is meant for broadcasting, hence support for non-broadcasting image widths, heights, bit depths, aspect ratios, etc. are limited by the "level". Although this codec supports a few chroma subsamplings (420, 422, 444), signalling those is generally outside the specifications of the level used (3) and the reference decoder will outright refuse to read any image with such a flag signalled (it only supports 1920x1080 yuv422p10). However, most implementations will happily read files with alternate dimensions, framerates and formats signalled. Therefore, in order to encode files other than 1080p50 yuv422p10le, you need to provide an "-strict -2" argument to the command line. The FFmpeg decoder will happily read any files made with non-standard parameters, dimensions and subsamplings, and so will other implementations. IMO this should be "-strict -1", but I'll leave that up for discussion. There are still plenty of stuff to implement, for instance 5 more wavelet transforms are still in the specs and supported by the decoder. The encoder can be lossless, given a high enough bitrate. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>