aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/me_cmp.h
Commit message (Collapse)AuthorAgeFilesLines
* configure: Factor mpegvideoencdsp out of mpegvideoencAndreas Rheinhardt2025-06-211-5/+0
| | | | | | | This will allow to relax the dependency on mpegvideoenc for several codecs. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideoenc: Add MPVEncContextAndreas Rheinhardt2025-03-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many of the fields of MpegEncContext (which is also used by decoders) are actually only used by encoders. Therefore this commit adds a new encoder-only structure and moves all of the encoder-only fields to it except for those which require more explicit synchronisation between the main slice context and the other slice contexts. This synchronisation is currently mainly provided by ff_update_thread_context() which simply copies most of the main slice context over the other slice contexts. Fields which are moved to the new MPVEncContext no longer participate in this (which is desired, because it is horrible and for the fields b) below wasteful) which means that some fields can only be moved when explicit synchronisation code is added in later commits. More explicitly, this commit moves the following fields: a) Fields not copied by ff_update_duplicate_context(): dct_error_sum and dct_count; the former does not need synchronisation, the latter is synchronised in merge_context_after_encode(). b) Fields which do not change after initialisation (these fields could also be put into MPVMainEncContext at the cost of an indirection to access them): lambda_table, adaptive_quant, {luma,chroma}_elim_threshold, new_pic, fdsp, mpvencdsp, pdsp, {p,b_forw,b_back,b_bidir_forw,b_bidir_back,b_direct,b_field}_mv_table, [pb]_field_select_table, mb_{type,var,mean}, mc_mb_var, {min,max}_qcoeff, {inter,intra}_quant_bias, ac_esc_length, the *_vlc_length fields, the q_{intra,inter,chroma_intra}_matrix{,16}, dct_offset, mb_info, mjpeg_ctx, rtp_mode, rtp_payload_size, encode_mb, all function pointers, mpv_flags, quantizer_noise_shaping, frame_reconstruction_bitfield, error_rate and intra_penalty. c) Fields which are already (re)set explicitly: The PutBitContexts pb, tex_pb, pb2; dquant, skipdct, encoding_error, the statistics fields {mv,i_tex,p_tex,misc,last}_bits and i_count; last_mv_dir, esc_pos (reset when writing the header). d) Fields which are only used by encoders not supporting slice threading for which synchronisation doesn't matter: esc3_level_length and the remaining mb_info fields. e) coded_score: This field is only really used when FF_MPV_FLAG_CBP_RD is set (which implies trellis) and even then it is only used for non-intra blocks. For these blocks dct_quantize_trellis_c() either sets coded_score[n] or returns a last_non_zero value of -1 in which case coded_score will be reset in encode_mb_internal(). Therefore no old values are ever used. The MotionEstContext has not been moved yet. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/attributes_internal: Add EXTERN macro for extern+hiddenAndreas Rheinhardt2025-03-051-1/+1
| | | | | | | | This is inspired by the equivalent dav1d attribute introduced by Henrik Gramner in e4c4af02f3de5e6cea6f81272a2981c0fa7bae28. Also already use it to beautify declarations. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Remove leftover alpha declarationsAndreas Rheinhardt2025-03-051-1/+0
| | | | | | Forgotten in cdd139d760688b14849d02ee1907f68fe692c24e. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/me_cmp, motion_est: Sanitize permissible cmp_funcsAndreas Rheinhardt2024-06-201-1/+8
| | | | | | | | | Several of the potential choices of comparison functions need an initialized MpegEncContext (initialized for encoding, not only ff_mpv_common_init()) or they crash when called. Modify ff_set_cmp() to check for this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/me_cmp,dvenc,mpegvideo: Move ildct_cmp to its usersAndreas Rheinhardt2024-06-201-2/+0
| | | | | | | | | | | | MECmpContext.ildct_cmp is an array of function pointers that are not set by ff_me_cmp_init(), but that are set by users to one of the other arrays via ff_set_cmp(). Remove these pointers from MECmpContext and add pointers for the actually used functions to its users. (The DV encoder already did so.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/me_cmp, mpegvideo: Move frame_skip_cmp to MpegEncContextAndreas Rheinhardt2024-06-201-1/+0
| | | | | | | | | | | | | | | MECmpContext has several arrays of function pointers that are not set by ff_me_cmp_init(), but that are set by users to one of the other arrays via ff_set_cmp(). One of these other users is mpegvideo_enc; it is the only user of MECmpContext.frame_skip_cmp and it only uses one of these function pointers at all. This commit therefore moves this function pointer to MpegEncContext; and removes the array from MECmpContext. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/me_cmp, motion_est: Move me_(pre_)?_cmp etc. to MotionEstContextAndreas Rheinhardt2024-06-201-4/+0
| | | | | | | | | | | | | | | | MECmpContext has several arrays of function pointers that are not set by ff_me_cmp_init(), but that are set by users to one of the other arrays via ff_set_cmp(). One of these other users is the motion estimation API. It uses MECmpContext.(me_pre|me|me_sub|mb)_cmp. It is basically the only user of these arrays. This commit therefore moves these arrays to MotionEstContext; this has the additional advantage of making motion_est.c more independent from MpegEncContext. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/me_cmp: Constify ff_set_cmp()Andreas Rheinhardt2024-06-201-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/me_cmp: R-V V pix_abssunyuechi2024-02-211-0/+1
| | | | | | | | | | | | | | C908: pix_abs_0_0_c: 534.0 pix_abs_0_0_rvv_i32: 136.2 pix_abs_1_0_c: 287.7 pix_abs_1_0_rvv_i32: 125.2 sad_0_c: 534.0 sad_0_rvv_i32: 136.2 sad_1_c: 287.7 sad_1_rvv_i32: 125.2 Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
* avcodec/mp_cmp: reject invalid comparison function valuesJames Almer2023-04-141-1/+1
| | | | | | Fixes tickets #10306 and #10318. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/me_cmp: Mark ff_square_tab as hiddenAndreas Rheinhardt2022-10-091-1/+3
| | | | | | | | | | | ff_square_tab is always used with an offset; if this table is marked as hidden, the compiler can infer that it and therefore also ff_square_tab + 256 have a fixed offset from the code. This allows to avoid performing "+ 256" at runtime by baking it into the offset from the code to the table. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/me_cmp: Constify me_cmp_func buffer parametersAndreas Rheinhardt2022-07-311-3/+3
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/aarch64: motion estimation functions in neonSwinney, Jonathan2022-06-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | - ff_pix_abs16_neon - ff_pix_abs16_xy2_neon In direct micro benchmarks of these ff functions verses their C implementations, these functions performed as follows on AWS Graviton 3. ff_pix_abs16_neon: pix_abs_0_0_c: 141.1 pix_abs_0_0_neon: 19.6 ff_pix_abs16_xy2_neon: pix_abs_0_3_c: 269.1 pix_abs_0_3_neon: 39.3 Tested with: ./tests/checkasm/checkasm --test=motion --bench --disable-linux-perf Signed-off-by: Jonathan Swinney <jswinney@amazon.com> Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/me_cmp: Remove ff_check_alignment()Andreas Rheinhardt2021-01-211-2/+0
| | | | | | | | | | | | | | | | | The usage of a static variable presents a potential for data races and means that this function can't be used in init functions of codecs with FF_CODEC_CAP_INIT_THREADSAFE (unless of course one presumes that everything is alright in which case the error is not triggered; but then the whole function is pointless...). This makes the Snow decoder init-threadsafe as it already claims. Notice that this function has been removed in 2014 by Libav in commit 9103185bd116930f90b847090e66a64fa9971ce2, because only some codepaths are checked this way and because it only affects legacy compilers. The latter is of course even more true today. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/me_cmp: remove ff_me_cmp_init_static()Muhammad Faiz2018-02-051-3/+1
| | | | | | | Precalculate and constify ff_square_tab. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
* avcodec/me_cmp: Fix median_sad sizeMichael Niedermayer2016-11-271-1/+1
| | | | | | | Fixes out of array read Fixes: COV1396255 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/me_cmp: add median SAD compare functionStanislav Dolganov2016-08-221-0/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mips: MSA (MIPS-SIMD-Arch) optimizations for me_cmp functionsShivraj Patil2015-07-061-0/+1
| | | | | | | This patch adds MSA (MIPS-SIMD-Arch) optimizations for me_cmp functions in new file me_cmp_msa.c Signed-off-by: Shivraj Patil <shivraj.patil@imgtec.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Merge commit '9c12c6ff9539e926df0b2a2299e915ae71872600'Michael Niedermayer2014-11-241-1/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | * commit '9c12c6ff9539e926df0b2a2299e915ae71872600': motion_est: convert stride to ptrdiff_t Conflicts: libavcodec/me_cmp.c libavcodec/ppc/me_cmp.c libavcodec/x86/me_cmp_init.c See: 9c669672c7fd45ef1cad782ab551be438ceac6cd Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * motion_est: convert stride to ptrdiff_tVittorio Giovara2014-11-241-1/+2
| | | | | | | | | | CC: libav-stable@libav.org Bug-Id: CID 700556 / CID 700557 / CID 700558
* | Merge commit '2d60444331fca1910510038dd3817bea885c2367'Michael Niedermayer2014-07-171-4/+25
|/ | | | | | | | | | | | | | | | | | | | | | | | | * commit '2d60444331fca1910510038dd3817bea885c2367': dsputil: Split motion estimation compare bits off into their own context Conflicts: configure libavcodec/Makefile libavcodec/arm/Makefile libavcodec/dvenc.c libavcodec/error_resilience.c libavcodec/h264.h libavcodec/h264_slice.c libavcodec/me_cmp.c libavcodec/me_cmp.h libavcodec/motion_est.c libavcodec/motion_est_template.c libavcodec/mpeg4videoenc.c libavcodec/mpegvideo.c libavcodec/mpegvideo_enc.c libavcodec/x86/Makefile libavcodec/x86/me_cmp_init.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
* dsputil: Split motion estimation compare bits off into their own contextDiego Biurrun2014-07-171-0/+73