summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-08-04 18:05:44 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-10-07 22:36:04 +0200
commit2ec62b1ca60cf7e387412ae0e651a86aac62e75b (patch)
tree81e713b775fc1bc7c3afac95fb9cfc418d2f1ae1 /libavcodec/utils.c
parent452089ee23312ceab28baf9f83fb7dff472e7d82 (diff)
avcodec/pthread_frame: Use RefStruct API for ThreadFrame.progress
Avoids allocations and error checks and allows to remove cleanup code for earlier allocations. Also avoids casts and indirections. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 8807a8c2b6..e7af60be98 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -40,6 +40,7 @@
#include "codec_par.h"
#include "decode.h"
#include "hwconfig.h"
+#include "refstruct.h"
#include "thread.h"
#include "threadframe.h"
#include "internal.h"
@@ -880,11 +881,8 @@ int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
av_assert0(!dst->progress);
- if (src->progress &&
- !(dst->progress = av_buffer_ref(src->progress))) {
- ff_thread_release_ext_buffer(dst->owner[0], dst);
- return AVERROR(ENOMEM);
- }
+ if (src->progress)
+ dst->progress = ff_refstruct_ref(src->progress);
return 0;
}
@@ -901,11 +899,7 @@ int ff_thread_replace_frame(AVCodecContext *avctx, ThreadFrame *dst,
if (ret < 0)
return ret;
- ret = av_buffer_replace(&dst->progress, src->progress);
- if (ret < 0) {
- ff_thread_release_ext_buffer(dst->owner[0], dst);
- return ret;
- }
+ ff_refstruct_replace(&dst->progress, src->progress);
return 0;
}