[FFmpeg-devel] [PATCH 7/9] pthread_frame: do not run hwaccel decoding asynchronously unless it's safe

Michael Niedermayer michael at niedermayer.cc
Sun Mar 19 03:30:11 EET 2017


On Sat, Mar 18, 2017 at 09:56:04AM +0100, wm4 wrote:
> From: Anton Khirnov <anton at khirnov.net>
> 
> Certain hardware decoding APIs are not guaranteed to be thread-safe, so
> having the user access decoded hardware surfaces while the decoder is
> running in another thread can cause failures (this is mainly known to
> happen with DXVA2).
> 
> For such hwaccels, only allow the decoding thread to run while the user
> is inside a lavc decode call (avcodec_send_packet/receive_frame).
> 
> Merges Libav commit d4a91e65.
> 
> Signed-off-by: wm4 <nfxjfg at googlemail.com>
> ---
>  libavcodec/avcodec.h       |  5 +++++
>  libavcodec/hwaccel.h       | 24 +++++++++++++++++++++
>  libavcodec/pthread_frame.c | 52 ++++++++++++++++++++++++++++++++++++++++------
>  libavcodec/vaapi_h264.c    |  2 ++
>  libavcodec/vaapi_mpeg2.c   |  2 ++
>  libavcodec/vaapi_mpeg4.c   |  3 +++
>  libavcodec/vaapi_vc1.c     |  3 +++
>  libavcodec/vdpau_h264.c    |  2 ++
>  libavcodec/vdpau_hevc.c    |  2 ++
>  libavcodec/vdpau_mpeg12.c  |  3 +++
>  libavcodec/vdpau_mpeg4.c   |  2 ++
>  libavcodec/vdpau_vc1.c     |  3 +++
>  libavcodec/version.h       |  2 +-
>  13 files changed, 98 insertions(+), 7 deletions(-)
>  create mode 100644 libavcodec/hwaccel.h

breaks:
./ffmpeg -i tickets//4583/ffvp9_corruption.webm -f null -
https://trac.ffmpeg.org/raw-attachment/ticket/4583/ffvp9_corruption.webm

...
frame=  215 fps=0.0 q=-0.0 Lsize=N/A time=00:00:08.00 bitrate=N/A speed= 165x
video:104kB audio:1500kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
pthread_mutex_unlock failed with error: Operation not permitted
Aborted


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170319/b496646b/attachment.sig>


More information about the ffmpeg-devel mailing list