1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00
Go to file
Andreas Rheinhardt b645138a34 avcodec/mpegpicture: Don't copy unnecessarily, fix race
mpegvideo uses an array of Pictures and when it is done with using
them, it only unreferences them incompletely: Some buffers are kept
so that they can be reused lateron if the same slot in the Picture
array is reused, making this a sort of a bufferpool.
(Basically, a Picture is considered used if the AVFrame's buf is set.)
Yet given that other pieces of the decoder may have a reference to
these buffers, they need not be writable and are made writable using
av_buffer_make_writable() when preparing a new Picture. This involves
reading the buffer's data, although the old content of the buffer
need not be retained.

Worse, this read can be racy, because the buffer can be used by another
thread at the same time. This happens for Real Video 3 and 4.

This commit fixes this race by no longer copying the data;
instead the old buffer is replaced by a new, zero-allocated buffer.

(Here are the details of what happens with three or more decoding threads
when decoding rv30.rm from the FATE-suite as happens in the rv30 test:
The first decoding thread uses the first slot of its picture array
to store its current pic; update_thread_context copies this for the
second thread that decodes a P-frame. It uses the second slot in its
Picture array to store its P-frame. This arrangement is then copied
to the third decode thread, which decodes a B-frame. It uses the third
slot in its Picture array for its current frame.
update_thread_context copies this to the next thread. It unreferences
the third slot containing the other B-frame and then it reuses this
slot for its current frame. Because the pic array slots are only
incompletely unreferenced, the buffers of the previous B-frame are
still in there and they are not writable; in fact the previous
thread is concurrently writing to them, causing races when making
the buffer writable.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-15 18:10:31 +02:00
compat compat: add msvc windres wrapper 2022-08-13 14:42:52 +02:00
doc lavu/hwcontext_qsv: add loader field to AVQSVDeviceContext 2022-08-12 10:43:39 +08:00
ffbuild ffbuild/common: Fix CPPFLAGS applied for compiling C++ files 2022-05-24 21:30:52 +02:00
fftools fftools: add DPI awareness manifest 2022-08-13 14:42:52 +02:00
libavcodec avcodec/mpegpicture: Don't copy unnecessarily, fix race 2022-08-15 18:10:31 +02:00
libavdevice configure: always enable gnu_windres if available 2022-08-13 14:42:36 +02:00
libavfilter avfilter/vsrc_ddagrab: add options for more control over output format fallback 2022-08-13 15:22:14 +02:00
libavformat configure: always enable gnu_windres if available 2022-08-13 14:42:36 +02:00
libavutil avutil/hwcontext_d3d11va: add support for rgbaf16 pixel format 2022-08-13 15:21:59 +02:00
libpostproc configure: always enable gnu_windres if available 2022-08-13 14:42:36 +02:00
libswresample configure: always enable gnu_windres if available 2022-08-13 14:42:36 +02:00
libswscale configure: always enable gnu_windres if available 2022-08-13 14:42:36 +02:00
presets
tests lavu/pixfmt: add packed RGBA float16 format 2022-08-13 15:21:46 +02:00
tools tools/target_dec_fuzzer: set avctx->workaround_bugs flags 2022-07-26 09:15:16 -03:00
.gitattributes
.gitignore gitignore: add config_components.h 2022-03-17 18:35:41 -03:00
.mailmap
.travis.yml
Changelog lavc/vaapi_encode: enable 8bit 4:4:4 encoding for HEVC and VP9 2022-08-09 09:22:49 -07:00
configure compat: add msvc windres wrapper 2022-08-13 14:42:52 +02:00
CONTRIBUTING.md
COPYING.GPLv2
COPYING.GPLv3
COPYING.LGPLv2.1
COPYING.LGPLv3
CREDITS
INSTALL.md
LICENSE.md
MAINTAINERS MAINTAINERS: Add ED25519 key for signing my commits in the future 2022-08-09 21:57:31 +02:00
Makefile Makefile: Prompt for reconfigure on lavc/hwaccels.h modification 2022-07-01 00:34:38 +02:00
README.md
RELEASE RELEASE: update after 5.1 branch 2022-07-13 00:31:42 +02:00

FFmpeg README

FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata.

Libraries

  • libavcodec provides implementation of a wider range of codecs.
  • libavformat implements streaming protocols, container formats and basic I/O access.
  • libavutil includes hashers, decompressors and miscellaneous utility functions.
  • libavfilter provides means to alter decoded audio and video through a directed graph of connected filters.
  • libavdevice provides an abstraction to access capture and playback devices.
  • libswresample implements audio mixing and resampling routines.
  • libswscale implements color conversion and scaling routines.

Tools

  • ffmpeg is a command line toolbox to manipulate, convert and stream multimedia content.
  • ffplay is a minimalistic multimedia player.
  • ffprobe is a simple analysis tool to inspect multimedia content.
  • Additional small tools such as aviocat, ismindex and qt-faststart.

Documentation

The offline documentation is available in the doc/ directory.

The online documentation is available in the main website and in the wiki.

Examples

Coding examples are available in the doc/examples directory.

License

FFmpeg codebase is mainly LGPL-licensed with optional components licensed under GPL. Please refer to the LICENSE file for detailed information.

Contributing

Patches should be submitted to the ffmpeg-devel mailing list using git format-patch or git send-email. Github pull requests should be avoided because they are not part of our review process and will be ignored.