summaryrefslogtreecommitdiff
path: root/libavcodec/snowenc.c
Commit message (Collapse)AuthorAge
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-31
| | | | | | | | | | | There are lots of files that don't need it: The number of object files that actually need it went down from 2011 to 884 here. Keep it for external users in order to not cause breakages. Also improve the other headers a bit while just at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/avcodec: Deprecate AV_INPUT_BUFFER_MIN_SIZEAndreas Rheinhardt2024-02-21
| | | | | | | | | | | It used to be used with preallocated packet buffers with the old encode API, but said API is no more and therefore there is no reason for this to be public any more. So deprecate it and use an internal replacement for the encoders using it as an upper bound for the size of their headers. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-14
| | | | | | | | | | | | | | | | | | | | | | | | Makes it robust against adding fields before it, which will be useful in following commits. Majority of the patch generated by the following Coccinelle script: @@ typedef AVOption; identifier arr_name; initializer list il; initializer list[8] il1; expression tail; @@ AVOption arr_name[] = { il, { il1, - tail + .unit = tail }, ... }; with some manual changes, as the script: * has trouble with options defined inside macros * sometimes does not handle options under an #else branch * sometimes swallows whitespace
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-20
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-22
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/snow: Move encoder-only stuff out of SnowContextAndreas Rheinhardt2023-10-02
| | | | | | | | | Put it into an encoder-specific context with a SnowContext at its front. This also avoids having to include mpegvideo.h in snow.c and snowdec.c. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/snow: Move freeing encoder-only buffers to snowenc.cAndreas Rheinhardt2023-09-29
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/snow: Move initializing HpelDSPContext to snowenc.cAndreas Rheinhardt2023-09-29
| | | | | | Only used by the encoder. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/snow: Move decoder/encoder-only inline funcs to snow(dec|enc).cAndreas Rheinhardt2023-09-29
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/snow: Move initializing QpelDSPContext to snowenc.cAndreas Rheinhardt2023-09-29
| | | | | | Only used by the encoder. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/snow: Split ff_snow_get_buffer()Andreas Rheinhardt2023-09-28
| | | | | | | | | | | | The part of said function that is common to both encoder and decoder is negligible since c954cf1e1b766a0d1992d5be0a8be0055a8e1a6a and more than offset by the costs of "Am I an encoder?" checks. So move allocating the frames to the encoder and decoder directly. Also rename ff_snow_frame_start() to ff_snow_frames_prepare(), because a frame without a buffer has not been properly started. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* all: Use av_frame_replace() where appropriateAndreas Rheinhardt2023-09-10
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/internal: Don't auto-include emms.hAndreas Rheinhardt2023-09-04
| | | | | | Instead include emms.h wherever it is needed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: use the new AVFrame key_frame flag in all decoders and encodersJames Almer2023-05-04
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/mp_cmp: reject invalid comparison function valuesJames Almer2023-04-14
| | | | | | Fixes tickets #10306 and #10318. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME supportMichael Niedermayer2023-03-26
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/snowenc: Fix visual weight calculationMichael Niedermayer2023-03-26
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mpegvideo_enc: do not use AVFrame.*_picture_number for encodingMarton Balint2023-02-13
| | | | | | Move these fields to MPEGPicture instead and use that. Signed-off-by: Marton Balint <cus@passwd.hu>
* avcodec: add AVCodecContext.frame_num as 64 bit variant to frame_numberMarton Balint2023-02-13
| | | | | | | | | | Frame counters can overflow relatively easily (INT_MAX number of frames is slightly more than 1 year for 60 fps content), so make sure we use 64 bit values for them. Also deprecate the old 32 bit frame_number attribute. Signed-off-by: Marton Balint <cus@passwd.hu>
* lavc: support AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE in all no-delay encodersAnton Khirnov2023-01-29
| | | | Including fake-delay encoders marked with FF_CODEC_CAP_EOF_FLUSH.
* avcodec/mpegvideo: Allocate map and score_map buffers jointlyAndreas Rheinhardt2022-10-29
| | | | | | Reduces the amounts of allocs, frees and allocation checks. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/snowenc: Fix invalid left shift of negative numbersAndreas Rheinhardt2022-10-23
| | | | | | | Affected the vsynth(1|2|_lena)-snow(|-hpel) tests. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/snow: Move initializing MotionEstContext to snowenc.cAndreas Rheinhardt2022-10-12
| | | | | | | Only used by the encoder. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avocdec/snowenc: Fix left shift of negative numberAndreas Rheinhardt2022-09-27
| | | | | | | Fixes the vsynth(1|2|_lena)-snow-ll FATE-tests. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add macro to set AVCodec.long_nameAndreas Rheinhardt2022-09-03
| | | | | | | | It reduces typing: Before this patch, there were 105 codecs whose long_name-definition exceeded the 80 char line length limit. Now there are only nine of them. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Make ff_alloc_packet() based encoders accept user buffersAndreas Rheinhardt2022-08-27
| | | | | | | | | | | | | | | | | | Up until now, these encoders received non-refcounted packets (whose data was owned by the corresponding AVCodecContext) from ff_alloc_packet(); these packets were made refcounted lateron by av_packet_make_refcounted() generically. This commit makes these encoders accept user-supplied buffers by replacing av_packet_make_refcounted() with an equivalent function that is based upon get_encode_buffer(). (I am pretty certain that one can also set the flag for mpegvideo- based encoders, but I want to double-check this later. What is certain is that it reallocates the buffer owned by the AVCodecContext which should maybe be moved to encode.c, so that proresenc_kostya.c and ttaenc.c can make use of it, too.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegpicture: Move encoding_error and mb_var_sum to MpegEncCtxAndreas Rheinhardt2022-08-10
| | | | | | | | These fields are only ever set by the encoder for the current picture and for no other picture. So only one set of these values needs to exist, so move them to MpegEncContext. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Constify frame->data pointers for encoders where possibleAndreas Rheinhardt2022-08-05
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/snowenc: Don't pass int[2] as parameter declared as int[3]Andreas Rheinhardt2022-07-23
| | | | | | | | | | | | | | | | | | | | check_block_inter() currently does this when calling check_block(). This leads to a -Wstringop-overflow= warning when compiling with GCC 12.1. Given that the main part of the body of check_block() consists of an "if (intra) { ... } else { ... }" which is true iff check_block() is not called from check_block_inter(), it makes sense to fix this by just inlining check_block() check_block_inter() and turning check_block() into a new check_block_intra() (with the inter parts removed, of course). This should also not make much of a difference for the generated code given that both check_block() as well as check_block_inter() are already marked as av_always_inline, so this commit follows this route to fix the issue. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* 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/mpegvideo: Make new_picture an ordinary AVFrameAndreas Rheinhardt2022-04-01
| | | | | | | | | It is currently a "Picture", an mpegvideo-specific type that has a lot of baggage, all of which is unnecessary for new_picture, because only its embedded AVFrame is ever used. So just use an ordinary AVFrame. 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>
* avcodec/h263.h: Move encoder-only stuff to a new header h263enc.hAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegpicture: Decrease size of encoding_error arrayAndreas Rheinhardt2022-01-13
| | | | | | | | | | | | | The current size is AV_NUM_DATA_POINTERS (i.e. eight). This number is chosen in order to minimize the amount of allocations for AVFrame.extended_(data|buf) for audio; it is meaningless for video for which four is sufficient. So decrease this array in order to minimize what is copied in ff_mpeg_ref_picture() and at the places that copy a whole MpegEncContext. Also do the same for snowenc. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/snowenc: Remove redundant pixel format checkAndreas Rheinhardt2021-10-02
| | | | | | | ff_encode_preinit() already checked the pixel format via AVCodec.pix_fmts. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-20
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/encode: Always use intermediate buffer in ff_alloc_packet2()Andreas Rheinhardt2021-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, ff_alloc_packet2() has a min_size parameter: It is supposed to be a lower bound on the final size of the packet to allocate. If it is not too far from the upper bound (namely, if it is at least half the upper bound), then ff_alloc_packet2() already allocates the final, already refcounted packet; if it is not, then the packet is not refcounted and its data only points to a buffer owned by the AVCodecContext (in this case, the packet will be made refcounted in encode_simple_internal() in libavcodec/encode.c). The goal of this was to avoid data copies and intermediate buffers if one has a precise lower bound. Yet those encoders for which precise lower bounds exist have recently been switched to ff_get_encode_buffer() (which automatically allocates final buffers), leaving only two encoders to actually set the min_size to something else than zero (namely aliaspixenc and hapenc). Both of these encoders use a very low lower bound that is not helpful in any nontrivial case. This commit therefore removes the min_size parameter as well as the codepath in ff_alloc_packet2() for the allocation of final buffers. Furthermore, the function has been renamed to ff_alloc_packet() and moved to encode.h alongside ff_get_encode_buffer(). 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>
* avutil/frame: Remove deprecated AVFrame.errorAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in 1aa24df74c052a73175c43e57d35b4835e537ec8. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Remove deprecated AVCodecContext.coded_frameAndreas Rheinhardt2021-04-27
| | | | | | | | | | Deprecated in 40cf1bbacc6220a0aa6bed5c331871d43f9ce370. (The currently disabled filter vf_mcdeint and vf_uspp were users of this field; they have not been changed, so that whoever wants to fix them can see the state of these filters when they were disabled.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Remove private options from AVCodecContextAndreas Rheinhardt2021-04-27
| | | | | | | | | Several options that were too codec-specific were deprecated between 0e6c8532215790bbe560a9eea4f3cc82bb55cf92 and 0e9c4fe254073b209970df3e3cb84531bc388e99. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Remove deprecated stat-bits fieldsAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in 16216b713f9a21865cc07993961cf5d0ece24916. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/snowenc: Expose an option to set the rc_eq expressionAlexander Strasser2020-08-12
| | | | | | | | | | | | | | | Snow uses the ratecontrol module, but does not expose a way to set the rc_eq expression. The default expression, set in the ratecontrol module, will always be used. Make it possible to set rc_eq by adding an AVOption to snowenc. The option definition is mostly a copy from the mpegvideo common options definition of rc_eq (libavcodec/mpegvideo.h), with some minor style adjustments to be closer to the other snowenc option initializer expressions. Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
* avcodec/snow: ensure current_picture is writable before modifying its dataJames Almer2020-06-09
| | | | | | | | current_picture was not writable here because a reference existed in at least avctx->coded_frame, and potentially elsewhere if the caller created new ones from it. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/internal: move packet related functions to their own headerJames Almer2020-06-02
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/snowenc: Set mb_num to avoid ratecontrol floating point divisions by 0.0Michael Niedermayer2019-11-09
| | | | | | Fixes: Ticket7990 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/snowenc: Fix 2 undefined shiftsMichael Niedermayer2019-11-09
| | | | | | Fixes: Ticket7990 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/rangecoder: factorize termination version codeMichael Niedermayer2018-12-31
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>