Skip to content
Snippets Groups Projects
  1. Jan 04, 2022
  2. Dec 17, 2021
  3. Sep 29, 2021
  4. Sep 19, 2021
  5. Apr 07, 2021
    • Andreas Rheinhardt's avatar
      avcodec/rv34, mpegvideo: Fix segfault upon frame size change error · 9abda136
      Andreas Rheinhardt authored
      
      The RealVideo 3.0 and 4.0 decoders call ff_mpv_common_init() only during
      their init function and not during decode_frame(); when the size of the
      frame changes, they call ff_mpv_common_frame_size_change(). Yet upon
      error, said function calls ff_mpv_common_end() which frees the whole
      MpegEncContext and not only those parts that
      ff_mpv_common_frame_size_change() reinits. As a result, the context will
      never be usable again; worse, because decode_frame() contains no check
      for whether the context is initialized or not, it is presumed that it is
      initialized, leading to segfaults. Basically the same happens if
      rv34_decoder_realloc() fails.
      
      This commit fixes this by only resetting the parts that
      ff_mpv_common_frame_size_change() changes upon error and by actually
      checking whether the context is in need of reinitialization in
      ff_rv34_decode_frame().
      
      Reviewed-by: default avatarMichael Niedermayer <michael@niedermayer.cc>
      Signed-off-by: default avatarAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
      9abda136
    • Andreas Rheinhardt's avatar
    • Andreas Rheinhardt's avatar
      avcodec/mpegvideo: Fix memleak upon allocation error · ff0706cd
      Andreas Rheinhardt authored
      
      When slice-threading is used, ff_mpv_common_init() duplicates
      the first MpegEncContext and allocates some buffers for each
      MpegEncContext (the first as well as the copies). But the count of
      allocated MpegEncContexts is not updated until after everything has
      been allocated and if an error happens after the first one has been
      allocated, only the first one is freed; the others leak.
      
      This commit fixes this: The count is now set before the copies are
      allocated. Furthermore, the copies are now created and initialized
      before the first MpegEncContext, so that the buffers exclusively owned
      by each MpegEncContext are still NULL in the src MpegEncContext so
      that no double-free happens upon allocation failure.
      
      Given that this effectively touches every line of the init code,
      it has also been factored out in a function of its own in order to
      remove code duplication with the same code in
      ff_mpv_common_frame_size_change() (which was never called when using
      more than one slice (and if it were, there would be potential
      double-frees)).
      
      Reviewed-by: default avatarMichael Niedermayer <michael@niedermayer.cc>
      Signed-off-by: default avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      ff0706cd
    • Andreas Rheinhardt's avatar
      Revert "avcodec: add FF_CODEC_CAP_INIT_CLEANUP for all codecs which use ff_mpv_common_init()" · d4b9e117
      Andreas Rheinhardt authored
      
      This mostly reverts commit 4b2863ff.
      Said commit removed the freeing code from ff_mpv_common_init(),
      ff_mpv_common_frame_size_change() and ff_mpeg_framesize_alloc() and
      instead added the FF_CODEC_CAP_INIT_CLEANUP to several codecs that use
      ff_mpv_common_init(). This introduced several bugs:
      
      a) Several decoders using ff_mpv_common_init() in their init function were
      forgotten: This affected FLV, Intel H.263, RealVideo 3.0 and V4.0 as well as
      VC-1/WMV3.
      b) ff_mpv_common_init() is not only called from the init function of
      codecs, it is also called from AVCodec.decode functions. If an error
      happens after an allocation has succeeded, it can lead to memleaks;
      furthermore, it is now possible for the MpegEncContext to be marked as
      initialized even when ff_mpv_common_init() returns an error and this can
      lead to segfaults because decoders that call ff_mpv_common_init() when
      decoding a frame can mistakenly think that the MpegEncContext has been
      properly initialized. This can e.g. happen with H.261 or MPEG-4.
      c) Removing code for freeing from ff_mpeg_framesize_alloc() (which can't
      be called from any init function) can lead to segfaults because the
      check for whether it needs to allocate consists of checking whether the
      first of the buffers allocated there has been allocated. This part has
      already been fixed in 76cea1d2.
      d) ff_mpv_common_frame_size_change() can also not be reached from any
      AVCodec.init function; yet the changes can e.g. lead to segfaults with
      decoders using ff_h263_decode_frame() upon allocation failure, because
      the MpegEncContext will upon return be flagged as both initialized and
      not in need of reinitialization (granted, the fact that
      ff_h263_decode_frame() clears context_reinit before the context has been
      reinited is a bug in itself). With the earlier version, the context
      would be cleaned upon failure and it would be attempted to initialize
      the context again in the next call to ff_h263_decode_frame().
      
      While a) could be fixed by adding the missing FF_CODEC_CAP_INIT_CLEANUP,
      keeping the current approach would entail adding cleanup code to several
      other places because of b). Therefore ff_mpv_common_init() is again made
      to clean up after itself; the changes to the wmv2 decoder and the SVQ1
      encoder have not been reverted: The former fixed a memleak, the latter
      allowed to remove cleanup code.
      
      Fixes: double free
      Fixes: ff_free_picture_tables.mp4
      Fixes: ff_mpeg_update_thread_context.mp4
      Fixes: decode_colskip.mp4
      Fixes: memset.mp4
      
      Reviewed-by: default avatarMichael Niedermayer <michael@niedermayer.cc>
      Signed-off-by: default avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      d4b9e117
  6. Mar 31, 2021
  7. Jan 01, 2021
    • Anton Khirnov's avatar
      mpegvideo: use the AVVideoEncParams API for exporting QP tables · baecaa16
      Anton Khirnov authored
      Do it only when requested with the AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS
      flag.
      
      Drop previous code using the long-deprecated AV_FRAME_DATA_QP_TABLE*
      API. Temporarily disable fate-filter-pp, fate-filter-pp7,
      fate-filter-spp. They will be reenabled once these filters are converted
      in following commits.
      baecaa16
  8. Dec 31, 2020
  9. Jun 14, 2020
  10. Jun 12, 2020
  11. May 09, 2020
  12. Mar 16, 2020
  13. Mar 14, 2020
  14. Dec 14, 2018
  15. Aug 25, 2018
  16. May 30, 2018
  17. Apr 02, 2018
  18. Dec 11, 2017
  19. Nov 07, 2017
  20. Nov 06, 2017
  21. Oct 23, 2017
  22. Oct 04, 2017
  23. Aug 25, 2017
Loading