aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/me_cmp.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/mpegvideo: Add missing headersAndreas Rheinhardt2025-07-031-0/+1
| | | | | | | These files currently rely on implicit inclusions of avassert.h and/or mathops.h via get_bits.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* configure: Factor mpegvideoencdsp out of mpegvideoencAndreas Rheinhardt2025-06-211-36/+0
| | | | | | | This will allow to relax the dependency on mpegvideoenc for several codecs. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideoenc: Constify vlc length pointeesAndreas Rheinhardt2025-03-261-2/+2
| | | | | | | These pointers point to static tables which must not be modified by anyone after they have been initialized. So constify the pointees. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideoenc: Add MPVEncContextAndreas Rheinhardt2025-03-261-50/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* avcodec/me_cmp: Fix type checkMichael Niedermayer2024-07-121-1/+1
| | | | | | | Fixes: CID1604375 Out-of-bounds read Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mpegvideo_enc: Only keep what is used from MECmpContextAndreas Rheinhardt2024-06-201-2/+2
| | | | | | | | | | A MECmpContext is quite big (792B here) and given how ff_update_duplicate_context() works, it is (unfortunately) copied quite frequently when using slice threading. Therefore keep only what is needed from MECmpContext and remove MECmpContext from MpegEncContext. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/me_cmp: Zero MECmpContext in ff_me_cmp_init()Andreas Rheinhardt2024-06-201-0/+2
| | | | | | | | | Not every function will be set, so zero the context to initialize everything. This also allows to remove an initialization in dvenc.c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/me_cmp, motion_est: Sanitize permissible cmp_funcsAndreas Rheinhardt2024-06-201-64/+52
| | | | | | | | | 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: Constify ff_set_cmp()Andreas Rheinhardt2024-06-201-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* libavcodec/alpha: remove DSP & support codeSean McGovern2024-06-131-2/+0
| | | | | | | | | | | | | | | | | | Introduced in 1992, the Alpha was a 64-bit RISC processor designed to replace the VAX CISC machines sold by Digital Equipment Corporation. After Digital was acquired by Compaq in 1998 -- who themselves would be later purchased by Hewlett-Packard, the architecture was phased out over the following decade. It became effectively defunct in 2007, the last publicly available processor being the Alpha 21364. FFmpeg has not added any DSP code for this architecture since lowres2 was introduced in 2012, and it is more than unlikely someone still wishes to maintain it. Remove the DSP and support code. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* avcodec/mpegvideo: Remove fast_dct_quantizeAndreas Rheinhardt2024-06-121-3/+3
| | | | | | | | It has been added in 3a87ac948f0cd95218e62d5a98b8b8d5e4c11366, but there was never an implementation different from the ordinary dct_quantize of it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/me_cmp: R-V V pix_abssunyuechi2024-02-211-0/+2
| | | | | | | | | | | | | | 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-2/+7
| | | | | | Fixes tickets #10306 and #10318. Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/aarch64: Add neon implementation for pix_median_abs16Hubert Mazur2022-09-211-2/+3
| | | | | | | | | | | | | Provide optimized implementation for pix_median_abs16 function. Performance comparison tests are shown below. - median_sad_0_c: 720.5 - median_sad_0_neon: 127.2 Benchmarks and tests run with checkasm tool on AWS Graviton 3. Signed-off-by: Hubert Mazur <hum@semihalf.com> Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/me_cmp: Remove now incorrect av_assert2()Andreas Rheinhardt2022-08-171-13/+0
| | | | | | | | | | | | Since d69d12a5b9236b9d2f1fd247ea452f84cdd1aaf9 these av_assert2() (or more exactly, the ones in hadamard8_diff8x8_c() and hadamard8_intra8x8_c()) are hit. So just remove all of these asserts. (If the test were improved to know which functions expect h == 8 and which support any value, the asserts could be readded at the appropriate places.) Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/me_cmp: Constify me_cmp_func buffer parametersAndreas Rheinhardt2022-07-311-40/+40
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/aarch64: motion estimation functions in neonSwinney, Jonathan2022-06-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | - 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>
* all: Replace if (ARCH_FOO) checks by #if ARCH_FOOAndreas Rheinhardt2022-06-151-10/+11
| | | | | | | | | | | | | | | | | | This is more spec-compliant because it does not rely on dead-code elimination by the compiler. Especially MSVC has problems with this, as can be seen in https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296373.html or https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/297022.html This commit does not eliminate every instance where we rely on dead code elimination: It only tackles branching to the initialization of arch-specific dsp code, not e.g. all uses of CONFIG_ and HAVE_ checks. But maybe it is already enough to compile FFmpeg with MSVC with whole-programm-optimizations enabled (if one does not disable too many components). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-161-0/+1
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/mpegvideo: Move encoder-only stuff to a new headerAndreas Rheinhardt2022-02-131-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/me_cmp: Remove ff_check_alignment()Andreas Rheinhardt2021-01-211-23/+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>
* lavu: move LOCAL_ALIGNED from internal.h to mem_internal.hAnton Khirnov2021-01-011-0/+1
| | | | That is a more appropriate place for it.
* simple_idct: Template functions to support an input bitdepth parameterKieran Kunhya2018-04-021-1/+1
|
* avcodec/me_cmp: remove ff_me_cmp_init_static()Muhammad Faiz2018-02-051-12/+38
| | | | | | | 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 crashes on ARM due to misalignmentMichael Niedermayer2017-08-211-5/+5
| | | | | | | | Adds a diff_pixels_unaligned() Fixes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=872503 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/me_cmp: add median SAD compare functionStanislav Dolganov2016-08-221-0/+76
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mips: MSA (MIPS-SIMD-Arch) optimizations for me_cmp functionsShivraj Patil2015-07-061-0/+2
| | | | | | | 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>
* avcodec/me_cmp: add () to protect avg*s argumentsMichael Niedermayer2015-02-161-2/+2
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Merge commit '9c12c6ff9539e926df0b2a2299e915ae71872600'Michael Niedermayer2014-11-241-57/+59
|\ | | | | | | | | | | | | | | | | | | | | | | | | * 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-57/+59
| | | | | | | | | | CC: libav-stable@libav.org Bug-Id: CID 700556 / CID 700557 / CID 700558
* | avcodec/me_cmp: restore author attribution and copyrightsMichael Niedermayer2014-07-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These where removed by libav in See: git show -C 2d60444331fca1910510038dd3817bea885c2367 diff --git a/libavcodec/dsputil.c b/libavcodec/me_cmp.c similarity index 98% rename from libavcodec/dsputil.c rename to libavcodec/me_cmp.c index ba71a99..9fcc937 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/me_cmp.c @@ -1,8 +1,4 @@ /* - * DSP utils - * Copyright (c) 2000, 2001 Fabrice Bellard - * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> - * * This file is part of Libav. * * Libav is free software; you can redistribute it and/or Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '2d60444331fca1910510038dd3817bea885c2367'Michael Niedermayer2014-07-171-39/+85
|/ | | | | | | | | | | | | | | | | | | | | | | | | * 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/+942