diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-02-06 14:49:23 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-02-09 17:22:35 +0100 |
commit | 02220b88fc38ef9dd4f2d519f5d3e4151258b60c (patch) | |
tree | 5ab09d5c019a822c0a839c6076bccff670986867 /libavcodec/h264_picture.c | |
parent | f025b8e110b36c1cdb4fb56c4cd57aeca1767b5b (diff) | |
download | ffmpeg-02220b88fc38ef9dd4f2d519f5d3e4151258b60c.tar.gz |
avcodec/thread: Don't use ThreadFrame when unnecessary
The majority of frame-threaded decoders (mainly the intra-only)
need exactly one part of ThreadFrame: The AVFrame. They don't
need the owners nor the progress, yet they had to use it because
ff_thread_(get|release)_buffer() requires it.
This commit changes this and makes these functions work with ordinary
AVFrames; the decoders that need the extra fields for progress
use ff_thread_(get|release)_ext_buffer() which work exactly
as ff_thread_(get|release)_buffer() used to do.
This also avoids some unnecessary allocations of progress AVBuffers,
namely for H.264 and HEVC film grain frames: These frames are not
used for synchronization and therefore don't need a ThreadFrame.
Also move the ThreadFrame structure as well as ff_thread_ref_frame()
to threadframe.h, the header for frame-threaded decoders with
inter-frame dependencies.
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/h264_picture.c')
-rw-r--r-- | libavcodec/h264_picture.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c index c7f5b64b99..2661ff4698 100644 --- a/libavcodec/h264_picture.c +++ b/libavcodec/h264_picture.c @@ -30,18 +30,19 @@ #include "avcodec.h" #include "h264dec.h" #include "mpegutils.h" +#include "thread.h" #include "threadframe.h" void ff_h264_unref_picture(H264Context *h, H264Picture *pic) { - int off = offsetof(H264Picture, tf_grain) + sizeof(pic->tf_grain); + int off = offsetof(H264Picture, f_grain) + sizeof(pic->f_grain); int i; if (!pic->f || !pic->f->buf[0]) return; ff_thread_release_ext_buffer(h->avctx, &pic->tf); - ff_thread_release_buffer(h->avctx, &pic->tf_grain); + ff_thread_release_buffer(h->avctx, pic->f_grain); av_buffer_unref(&pic->hwaccel_priv_buf); av_buffer_unref(&pic->qscale_table_buf); @@ -102,9 +103,7 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src) goto fail; if (src->needs_fg) { - av_assert0(src->tf_grain.f == src->f_grain); - dst->tf_grain.f = dst->f_grain; - ret = ff_thread_ref_frame(&dst->tf_grain, &src->tf_grain); + ret = av_frame_ref(dst->f_grain, src->f_grain); if (ret < 0) goto fail; } @@ -161,10 +160,8 @@ int ff_h264_replace_picture(H264Context *h, H264Picture *dst, const H264Picture goto fail; if (src->needs_fg) { - av_assert0(src->tf_grain.f == src->f_grain); - dst->tf_grain.f = dst->f_grain; - ff_thread_release_buffer(h->avctx, &dst->tf_grain); - ret = ff_thread_ref_frame(&dst->tf_grain, &src->tf_grain); + ff_thread_release_buffer(h->avctx, dst->f_grain); + ret = av_frame_ref(dst->f_grain, src->f_grain); if (ret < 0) goto fail; } |