1
0
Fork 0
Commit Graph

284 Commits

Author SHA1 Message Date
Ramiro Polla 713c6eba8d libavcodec/motion_est: fix penalty_factor for b frames
In direct_search() and ff_estimate_b_frame_motion(), penalty_factor
would be used before being initialized in estimate_motion_b(). Also,
the initialization would happen more than once unnecessarily.
2024-05-11 09:38:34 +02:00
James Almer 7c6e26a184 avcodec/mp_cmp: reject invalid comparison function values
Fixes tickets #10306 and #10318.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-14 10:04:47 -03:00
Andreas Rheinhardt bc109a53c7 avcodec/mpegpicture: Move mb_var, mc_mb_var and mb_mean to MpegEncCtx
These tables are only used by encoders and only for the current picture;
ergo they need not be put into the picture at all, but rather into
the encoder's context. They also don't need to be refcounted,
because there is only one owner.

In contrast to this, the earlier code refcounts them which
incurs unnecessary overhead. These references are not unreferenced
in ff_mpeg_unref_picture() (they are kept in order to have something
like a buffer pool), so that several buffers are kept at the same
time, although only one is needed, thereby wasting memory.

The code also propagates references to other pictures not part of
the pictures array (namely the copy of the current/next/last picture
in the MpegEncContext which get references of their own). These
references are not unreferenced in ff_mpeg_unref_picture() (the
buffers are probably kept in order to have something like a pool),
yet if the current picture is a B-frame, it gets unreferenced
at the end of ff_mpv_encode_picture() and its slot in the picture
array will therefore be reused the next time; but the copy of the
current picture also still has its references and therefore
these buffers will be made duplicated in order to make them writable
in the next call to ff_mpv_encode_picture(). This is of course
unnecessary.

Finally, ff_find_unused_picture() is supposed to just return
any unused picture and the code is supposed to work with it;
yet for the vsynth*-mpeg4-adap tests the result depends upon
the content of these buffers; given that this patchset
changes the content of these buffers (the initial content is now
the state of these buffers after encoding the last frame;
before this patch the buffers used came from the last picture
that occupied the same slot in the picture array) their ref-files
needed to be changed. This points to a bug somewhere (if one removes
the initialization, one gets uninitialized reads in
adaptive_quantization in ratecontrol.c).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-09 19:17:22 +02:00
Andreas Rheinhardt 34276b815b avcodec/motion_est: Constify pointers to frame data
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-31 03:56:32 +02:00
Andreas Rheinhardt abb85429f3 avcodec/me_cmp: Constify me_cmp_func buffer parameters
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-31 03:31:53 +02:00
Andreas Rheinhardt 37250f7f64 avcodec/mpegvideo: Make new_picture an ordinary AVFrame
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>
2022-04-01 17:02:54 +02:00
Andreas Rheinhardt 8b856a9e53 avcodec/motion_est: Constify mv-table parameters where possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-13 19:49:29 +01:00
Andreas Rheinhardt 746e7102be avcodec/mpegvideo: Move encoder-only stuff to a new header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-13 19:49:29 +01:00
Michael Niedermayer ce43e1c581 avcodec/motion_est: fix indention of ff_get_best_fcode()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-09 10:54:30 +01:00
Michael Niedermayer 634312a70f avcodec/motion_est: Fix xy indexing on range violation in ff_get_best_fcode()
This codepath seems untested, no testcases change

Found-by: <mkver>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-09 10:54:30 +01:00
Andreas Rheinhardt 27f22f3383 all: Remove unnecessary libavcodec/internal.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-08 06:16:26 +01:00
Andreas Rheinhardt 3ef65fd4d1 avcodec/motion_est: Fix invalid left shift of negative numbers
Affected many FATE-tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-04-01 14:50:25 +02:00
Andreas Rheinhardt 4a160cbef4 avcodec/motion_est, mpegvideo: Make pointers to static storage const
Modifying static storage must not happen because of multithreading
(except initialization of course), so add const to the pointed-to type
for pointers that point to static storage.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-31 12:44:12 +01:00
Ramiro Polla 531fbce0b2 mpegvideo_enc: add intra_penalty option for p frames
This option allows more control over the use of intra macroblocks in
predictive frames.

By using '-intra_penalty max', intra macroblocks are never used in
predictive frames.

It is useful for glitch artists to generate input material. This option
allows them to split and merge two video files while maintaining fluid
motion from the second video without having intra macroblocks restoring
chunks of the first video.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-24 19:45:17 +02:00
Marton Balint 483d029188 avcodec/motion_est: remove duplicate function
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-01-28 21:46:58 +01:00
James Almer bfab430856 Merge commit '94eed68ace9f2416af8457fcbf142b175928c06b'
* commit '94eed68ace9f2416af8457fcbf142b175928c06b':
  lavc: Drop deprecated options moved to private contexts

Merged-by: James Almer <jamrial@gmail.com>
2017-10-23 17:08:32 -03:00
Carl Eugen Hoyos b6a8396245 lavc/motion_est: Fix undefined negative left shifts. 2017-04-19 23:33:33 +02:00
Vittorio Giovara 94eed68ace lavc: Drop deprecated options moved to private contexts
Deprecated in 10/2014 and 07/2015.
2017-03-23 10:09:17 +01:00
Stanislav Dolganov 4edd74bd7c avcodec/me_cmp: add median SAD compare function
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-22 16:41:33 +02:00
Clément Bœsch 8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Derek Buitenhuis 1a12eb4a73 Merge commit '29c2d06d67724e994980045afa055c6c34611b30'
* commit '29c2d06d67724e994980045afa055c6c34611b30':
  cosmetics: Drop empty comment lines

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-24 17:31:44 +00:00
Diego Biurrun 29c2d06d67 cosmetics: Drop empty comment lines 2016-02-18 15:35:30 +01:00
Michael Niedermayer 5b4da8a38a avcodec/motion_est: Fix mv_penalty table size
Fixes out of array read

Found-by: Tyson Smith <twsmith@mozilla.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-05 18:10:34 +01:00
Ganesh Ajjanagadde b4f1636a4d lavc: typo fix cliping -> clipping, saftey -> safety
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-11 19:10:00 -05:00
Michael Niedermayer 94d68a41fa Merge commit '7c6eb0a1b7bf1aac7f033a7ec6d8cacc3b5c2615'
* commit '7c6eb0a1b7bf1aac7f033a7ec6d8cacc3b5c2615':
  lavc: AV-prefix all codec flags

Conflicts:
	doc/examples/muxing.c
	ffmpeg.c
	ffmpeg_opt.c
	ffplay.c
	libavcodec/aacdec.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.c
	libavcodec/ac3enc_float.c
	libavcodec/atrac1.c
	libavcodec/atrac3.c
	libavcodec/atrac3plusdec.c
	libavcodec/dcadec.c
	libavcodec/ffv1enc.c
	libavcodec/h264.c
	libavcodec/h264_loopfilter.c
	libavcodec/h264_mb.c
	libavcodec/imc.c
	libavcodec/libmp3lame.c
	libavcodec/libtheoraenc.c
	libavcodec/libtwolame.c
	libavcodec/libvpxenc.c
	libavcodec/libxavs.c
	libavcodec/libxvid.c
	libavcodec/mpeg12dec.c
	libavcodec/mpeg12enc.c
	libavcodec/mpegaudiodec_template.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/mpegvideo_motion.c
	libavcodec/nellymoserdec.c
	libavcodec/nellymoserenc.c
	libavcodec/nvenc.c
	libavcodec/on2avc.c
	libavcodec/options_table.h
	libavcodec/opus_celt.c
	libavcodec/pngenc.c
	libavcodec/ra288.c
	libavcodec/ratecontrol.c
	libavcodec/twinvq.c
	libavcodec/vc1_block.c
	libavcodec/vc1_loopfilter.c
	libavcodec/vc1_mc.c
	libavcodec/vc1dec.c
	libavcodec/vorbisdec.c
	libavcodec/vp3.c
	libavcodec/wma.c
	libavcodec/wmaprodec.c
	libavcodec/x86/hpeldsp_init.c
	libavcodec/x86/me_cmp_init.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 22:10:35 +02:00
Vittorio Giovara 7c6eb0a1b7 lavc: AV-prefix all codec flags
Convert doxygen to multiline and express bitfields more simply.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:58 +01:00
Vittorio Giovara 4b6b1082a7 lavc: Deprecate avctx.me_method
This option is extremely codec specific and only a few codecs employ it.
Move it to codec private options instead: mpegenc family supports only 3
values, xavs and x264 use 5, and xvid has a different metric entirely.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:56 +01:00
Michael Niedermayer 0b6f092ed3 Merge commit '4b6b1082a73907c7c3de2646c6398bc61320f2c6'
* commit '4b6b1082a73907c7c3de2646c6398bc61320f2c6':
  lavc: Deprecate avctx.me_method

Conflicts:
	doc/encoders.texi
	libavcodec/avcodec.h
	libavcodec/libx264.c
	libavcodec/motion_est.c
	libavcodec/options_table.h
	libavcodec/version.h

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 21:03:20 +02:00
Michael Niedermayer ac78014f0b avcodec/motion_est: Fix some undefined shifts
Fixes: asan_heap-oob_1dd60fd_1049_cov_4200102444_P4250048.MOV

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-01 15:42:07 +02:00
Michael Niedermayer 4eee685a21 avcodec/motion_est: Fix undefined shifts in cmp_inline()
Fixes: signal_sigsegv_35eac16_2762_cov_2704249783_missing_frames.avi

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-01 13:42:06 +02:00
Michael Niedermayer 0f69f02eb7 Merge commit '149fa0b7ac180fe1df48a2e379c560813555bf57'
* commit '149fa0b7ac180fe1df48a2e379c560813555bf57':
  mpegvideo: Move MotionEstContext and function declarations to a separate header

Conflicts:
	libavcodec/mpegvideo.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-01 01:30:01 +02:00
Vittorio Giovara 149fa0b7ac mpegvideo: Move MotionEstContext and function declarations to a separate header 2015-05-31 13:06:19 +02:00
Michael Niedermayer d9b264bc73 Merge commit '848e86f74d3e6e87fa592ee8ba8c184cc5fd9a42'
* commit '848e86f74d3e6e87fa592ee8ba8c184cc5fd9a42':
  mpegvideo: Drop flags and flags2

Conflicts:
	libavcodec/mpeg12dec.c
	libavcodec/mpeg12enc.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/mpegvideo_motion.c
	libavcodec/ratecontrol.c
	libavcodec/vc1_block.c
	libavcodec/vc1_loopfilter.c
	libavcodec/vc1_mc.c
	libavcodec/vc1dec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-22 20:24:41 +02:00
Vittorio Giovara 848e86f74d mpegvideo: Drop flags and flags2
They are just duplicates of AVCodecContext members so use those instead.
2015-05-22 15:34:39 +01:00
Michael Niedermayer 8f7b022c8c Merge commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25'
* commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25':
  lavc: Replace av_dlog and tprintf with internal macros

Conflicts:
	libavcodec/aacdec.c
	libavcodec/audio_frame_queue.c
	libavcodec/bitstream.c
	libavcodec/dcadec.c
	libavcodec/dnxhddec.c
	libavcodec/dvbsubdec.c
	libavcodec/dvdec.c
	libavcodec/dvdsubdec.c
	libavcodec/get_bits.h
	libavcodec/gifdec.c
	libavcodec/h264.h
	libavcodec/h264_cabac.c
	libavcodec/h264_cavlc.c
	libavcodec/h264_loopfilter.c
	libavcodec/h264_refs.c
	libavcodec/imc.c
	libavcodec/interplayvideo.c
	libavcodec/jpeglsdec.c
	libavcodec/libopencore-amr.c
	libavcodec/mjpegdec.c
	libavcodec/mpeg12dec.c
	libavcodec/mpegvideo_enc.c
	libavcodec/mpegvideo_parser.c
	libavcodec/pngdec.c
	libavcodec/ratecontrol.c
	libavcodec/rv10.c
	libavcodec/svq1dec.c
	libavcodec/vqavideo.c
	libavcodec/wmadec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-20 04:10:10 +02:00
Vittorio Giovara 0251c9be5a motion_est: Fix warning from zero_cmp() assignment
warning: incompatible
      pointer types assigning to 'me_cmp_func' (aka 'int (*)(struct
      MpegEncContext *, uint8_t *, uint8_t *, ptrdiff_t, int)') from 'int
      (MpegEncContext *, uint8_t *, uint8_t *, int, int)'
      [-Wincompatible-pointer-types]
2015-04-19 23:17:56 +01:00
Vittorio Giovara 6a85dfc830 lavc: Replace av_dlog and tprintf with internal macros 2015-04-19 12:41:59 +01:00
Paul B Mahol 021c0c5f52 avcodec/motion_est: remove unneeded #include, there are no assert() only av_assert*
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-02-01 11:15:20 +00:00
Michael Niedermayer b80106169a avcodec/motion_est: Set subcmp consistently for H261
Fixes Ticket3150

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-31 21:14:08 +01:00
Michael Niedermayer b50e003e1c avcodec/motion_est: use 2x8x8 for interlaced qpel
Fixes out of array read
Fixes Ticket4121

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-01 13:41:16 +01:00
Michael Niedermayer ea41e6d637 Merge commit '9c12c6ff9539e926df0b2a2299e915ae71872600'
* 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: 9c669672c7
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-24 12:13:00 +01:00
Michael Niedermayer 567ea2d64c Merge commit '240b22afe14ef477da1b439b9ed7bca6cc7d6c26'
* commit '240b22afe14ef477da1b439b9ed7bca6cc7d6c26':
  motion_est: remove dead code

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-04 21:10:02 +01:00
Vittorio Giovara 240b22afe1 motion_est: remove dead code
mb_type is initialized to 0 and never updated before the check.

Bug-Id: CID 1238782
2014-11-03 10:15:53 -05:00
Michael Niedermayer fb33bff990 Merge commit 'f929ab0569ff31ed5a59b0b0adb7ce09df3fca39'
* commit 'f929ab0569ff31ed5a59b0b0adb7ce09df3fca39':
  cosmetics: Write NULL pointer equality checks more compactly

Conflicts:
	cmdutils.c
	ffmpeg_opt.c
	ffplay.c
	libavcodec/dvbsub.c
	libavcodec/dvdsubdec.c
	libavcodec/dvdsubenc.c
	libavcodec/dxa.c
	libavcodec/libxvid_rc.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/rv10.c
	libavcodec/tiffenc.c
	libavcodec/utils.c
	libavcodec/vc1dec.c
	libavcodec/zmbv.c
	libavdevice/v4l2.c
	libavformat/matroskadec.c
	libavformat/movenc.c
	libavformat/sdp.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-15 21:00:50 +02:00
Gabriel Dume f929ab0569 cosmetics: Write NULL pointer equality checks more compactly
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2014-08-15 03:18:18 -07:00
Michael Niedermayer 8b395315a5 Merge commit '4fbb62a21bd04bf261da2382d5ba6c249c702af8'
* commit '4fbb62a21bd04bf261da2382d5ba6c249c702af8':
  mpegvideo: Move ME_MAP_* defines to the only place they are used

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-26 02:34:51 +02:00
Diego Biurrun 4fbb62a21b mpegvideo: Move ME_MAP_* defines to the only place they are used 2014-07-25 12:00:53 -07:00
Michael Niedermayer 3a2d1465c8 Merge commit '2d60444331fca1910510038dd3817bea885c2367'
* 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>
2014-07-17 23:27:40 +02:00
Diego Biurrun 2d60444331 dsputil: Split motion estimation compare bits off into their own context 2014-07-17 09:07:10 -07:00