summaryrefslogtreecommitdiff
path: root/libavcodec/vc2enc.c
Commit message (Collapse)AuthorAge
* avcodec: Make init-threadsafety the defaultAndreas Rheinhardt2022-07-18
| | | | | | | | | | | and remove FF_CODEC_CAP_INIT_THREADSAFE All our native codecs are already init-threadsafe (only wrappers for external libraries and hwaccels are typically not marked as init-threadsafe yet), so it is only natural for this to also be the default state. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-05
| | | | | | | | | | | This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Rename AVCodecDefault->FFCodecDefaultAndreas Rheinhardt2022-03-21
| | | | | | | This structure is no longer declared in a public header, so using an FF-prefix is more appropriate. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-21
| | | | | | | | | | | | | | | | Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt2022-03-21
| | | | | | | | | | Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault. This reduces the amount of files that have to include internal.h (which comes with quite a lot of indirect inclusions), as e.g. most encoders don't need it. It is furthemore in preparation for moving the private part of AVCodec out of the public codec.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* libavcodec: Split version.hMartin Storsjö2022-03-16
| | | | | | | | | | | | | | This avoids including version.h in all source files, avoiding unnecessary rebuilds when the version number is bumped. Only version_major.h is included by the main header, which defines availability of e.g. FF_API_* macros, and which is bumped much less often. This isn't done for libavutil/version.h, because that header needs to be included essentially everywhere due to LIBAVUTIL_VERSION_INT being used wherever an AVClass is constructed. Signed-off-by: Martin Storsjö <martin@martin.st>
* Remove obsolete version.h inclusionsAndreas Rheinhardt2022-02-24
| | | | | | | Forgotten in e7bd47e657bbf9e1ce9915e93bc80cb1a29fb7f3. Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc2enc: Cleanup generically on allocation failureAndreas Rheinhardt2022-02-11
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vc2enc: Check for non negative slice boundsMichael Niedermayer2021-06-08
| | | | | | | Fixes: invalid shifts Fixes: Ticket 8221 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vc2enc: Allow user-supplied buffersAndreas Rheinhardt2021-05-15
| | | | | | | Trivial for an encoder that has a very good estimate of the size of the output packet in advance. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-27
| | | | | | | | | | Given that the AVCodec.next pointer has now been removed, most of the AVCodecs are not modified at all any more and can therefore be made const (as this patch does); the only exceptions are the very few codecs for external libraries that have a init_static_data callback. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/vc2enc: Actually zero paddingAndreas Rheinhardt2021-04-26
| | | | | | | | This encoder sets the min_size in ff_alloc_packet2(), so it can not rely on av_packet_make_refcounted() to zero the padding. Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* vc2enc: Add missing static to local variablesMark Thompson2021-02-02
|
* put_bits: make avpriv_put_string() lavc-localAnton Khirnov2020-10-28
| | | | | It has not been used outside of libavcodec since 20f325f320c6e18ee88983870d2a1fee94257293
* put_bits: make avpriv_align_put_bits() inlineAnton Khirnov2020-10-28
| | | | | | | | | This function is so extremely simple that it is preferable to make it inline rather than deal with all the complications arising from it being an exported symbol. Keep avpriv_align_put_bits() around until the next major bump to preserve ABI compatibility.
* avcodec, avfilter, avformat: Remove redundant avpriv_align_put_bitsAndreas Rheinhardt2020-08-01
| | | | | | | | flush_put_bits() already fills the bitstream with zeroes, so it is unnecessary to align the bitstream before. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* vc2enc: zero padding of the coefficient bufferLynne2019-12-17
| | | | | | | | | | Wavelet types with large amounts of overreading/writing like 9_7 would write into the padding at high wavelet depths, which would remain and be read by the next frame's transform and quickly cause artifacts to appear for subsequent frames. This fix affects all frames encoded with a non-power-of-two width, with the artifacts varying between non-observable to very noticeable, depending on encoder settings, so reencoding is advisable.
* vc2enc: properly promote operations to 64 bitsRostislav Pehlivanov2018-03-13
| | | | | | | | | | | On Windows machines, the UL suffix still means 32 bits. The only parts that need 64 bits are (1ULL << (m + 32)) and (t*qf + qf). Hence, use the proper ULL suffix for the former and just increase the type of the qf constant for the latter. No overflows can happen as long as these are done in 64 bits and the quantization table doesn't change. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: replace quantization LUT with a smaller division LUTRostislav Pehlivanov2018-03-10
| | | | | | | | | This commit replaces the huge and impractical LUT which converted coeffs and a quantizer to bits to encode and instead uses a standard multiplication and a shift to replace the division and then codes the values using the regular golomb coding functions. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* avcodec/vc2enc: prevent bitrate overshootsRostislav Pehlivanov2018-01-31
| | | | | | | The rounding caused by the size scaler wasn't compensated for and the slice sizes grew beyond what is allowed per frame. Signed-off-by: Rostislav Pehlivanov <rpehlivanov@obe.tv>
* avcodec/vc2enc: Clear coef_buf on allocationMichael Niedermayer2017-11-15
| | | | | | | | Fixes: Use of uninitialized memory Fixes: assertion failure Reviewed-by: <atomnuker> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* vc2enc_dwt: pad the temporary buffer by the slice sizeRostislav Pehlivanov2017-11-09
| | | | | | | | | | | | | | | 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>
* avcodec: remove remaining uses of avcodec_get_chroma_sub_sampleMartin Vignali2017-11-06
| | | | | | Replace them with av_pix_fmt_get_chroma_sub_sample. Signed-off-by: James Almer <jamrial@gmail.com>
* Revert "vc2enc: Calculate average slice quantiser correctly"Kieran Kunhya2017-11-04
| | | | This reverts commit 626d200e76e15487cff20992256a55919432b0b3.
* vc2enc: Calculate average slice quantiser correctlyKieran Kunhya2017-11-04
|
* vc2enc: decrease default strictness levelRostislav Pehlivanov2017-06-15
| | | | | | Given how incredibly limited the official specifications are (limiting all use to only the most common broadcasting formats), permit all supported inputs by default. This makes the encoder more useful.
* diractab: expose the maximum quantization index as a macroRostislav Pehlivanov2016-07-11
| | | | | | | Prevents having to have random magic values in the decoder and a separate macro in the encoder. Signed-off-by: Rostislav Pehlivanov <rpehlivanov@obe.tv>
* vc2enc: prevent random dataChristophe Gisquet2016-05-06
| | | | | | | | | | The slice prefix is 0 in the reference encoder and the decoder ignores it. Writing 0 there seems like the best temporary solution. The padding could have contained uninitialized data, but reference VC2 encoders put 0xFF there, hence the memset value. Overall this allows producing bistreams with no random data for use by fate.
* vc2enc: do not print the lavc version if the bitexact flag is enabledRostislav Pehlivanov2016-05-05
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: use 32x16 slices by defaultRostislav Pehlivanov2016-04-16
| | | | | | | Approximately 1.25 times faster than 64x32, visually and statistically improves quality. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: don't require interlacing for 1080p50/60 base video formatsRostislav Pehlivanov2016-04-16
| | | | | | Typo Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: optimize and simplify quantizationRostislav Pehlivanov2016-03-24
| | | | | | Everything except ORing the sign is now done in the LUT. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: simplify calc_slice_sizes()Rostislav Pehlivanov2016-03-23
| | | | Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: correctly zero out the slice size cacheRostislav Pehlivanov2016-03-23
| | | | Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: macro out slice size roundingRostislav Pehlivanov2016-03-23
| | | | Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: add non-experimental support for all video formats from specRostislav Pehlivanov2016-03-22
| | | | | | | | | Until now, for formats which were in the spec but not in the encoder's list of supported formats required the -strict -1 flag. This enables support for all video formats which are specified, all the way from QSIF525 to 8K. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: simplify count_hq_slice() and cachingRostislav Pehlivanov2016-03-21
| | | | | | The count_hq_slice() function is always used with a SliceArgs struct Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: fix segfaultRostislav Pehlivanov2016-03-21
| | | | | | | | Fixes trac bug #5353 Uninitialized memory for the initial quantization index Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: increase the starting value of the size scalerRostislav Pehlivanov2016-03-18
| | | | | | | In some cases this caused the slice size rounding to generate invalid slice sizes and overwrite some slices. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: minor cosmetic changesRostislav Pehlivanov2016-03-04
| | | | Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: remove useless alignment on slice encodingRostislav Pehlivanov2016-03-04
| | | | | | | | This was a leftover from before the slices were encoded in parallel. Since the put_bits context is initialized per slice aligning it aferwards is pointless. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: do not allocate packet until exact frame size is knownRostislav Pehlivanov2016-03-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit solves most of the crashes and issues with the encoder and the bitrate setting. Now the encoder will always allocate the absolute lowest amount of memory regardless of what the bitrate has been set to. Therefore if a user inputs a very low bitrate the encoder will use the maximum possible quantization (basically zero out all coefficients), allocate a packet and encode it. There is no coupling between the bitrate and the allocation size and so no crashes because the buffer isn't large enough. The maximum quantizer was raised to the size of the table now to both keep the overshoot at ridiculous bitrates low and to improve quality with higher bit depths (since the coefficients grow larger per transform quantizing them to the same relative level requires larger quantization indices). Since the quantization index start follows the previous quantization index for that slice, the quantization step was reduced to a static 1 to improve performance. Previously with quant/5 the step was usually set to 0 upon start (and was later clipped to 1), that isn't a big change. As the step size increases so does the amount of bits leftover and so the redistribution algorithm has to iterate more and thus waste more time. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: fix packet underallocation and minimum bitrate with interlacingRostislav Pehlivanov2016-03-01
| | | | | | | | | This was a regression introduced by commit e7345abe052 which enabled full use of the allocated packet but due to the overhead of using field coding the buffer was too small and triggered warnings and crashes. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: simplify slice cost cachingRostislav Pehlivanov2016-03-01
| | | | | | | The fact that now all quantization indices costs are cached justifies storing 20 more integers in a structure already allocated on heap. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: remove redundant put_padding() and use skip_put_bytes() insteadRostislav Pehlivanov2016-03-01
| | | | Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: redistribute leftover bytesRostislav Pehlivanov2016-02-28
| | | | | | | | | | | This commit redistributes the leftover bytes amongst the top 150 slices in terms of size (in the hopes that they'll be the ones pretty bitrate starved). A more perceptual method would probably need to cut bits off from slices which don't need much, but that'll be implemented later. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: allocate the DWT context with the current plane sizeRostislav Pehlivanov2016-02-28
| | | | | | Previously used the luma size only. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* 2enc: clip and warn when user bitrate set too lowRostislav Pehlivanov2016-02-28
| | | | | | | The encoder crashed on verly low bitrates since there wasn't enough space allocated. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: clip and warn when user bitrate set too lowRostislav Pehlivanov2016-02-28
| | | | | | | The encoder crashed on verly low bitrates since there wasn't enough space allocated. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vc2enc: carry over quantization index across frames as a starting pointRostislav Pehlivanov2016-02-28
| | | | | | | | Previously a global average was used. Using the previous quantizer resulted in a fairly significant speedup as slice size selection settled down quicker. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>