Skip to content

Commit 3b2a941

Browse files
committed
avcodec/decode: Only use ff_progress_frame_get_buffer() with blank input
All users (namely HEVC) that use ff_progress_frame_alloc() should just use ff_thread_get_buffer(). Using ff_progress_frame_get_buffer() is not a must; it is merely a convenience wrapper. Signed-off-by: Andreas Rheinhardt <[email protected]>
1 parent 29b85cd commit 3b2a941

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

libavcodec/decode.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,14 +1761,9 @@ int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f)
17611761

17621762
int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int flags)
17631763
{
1764-
int ret;
1765-
1766-
check_progress_consistency(f);
1767-
if (!f->f) {
1768-
ret = ff_progress_frame_alloc(avctx, f);
1769-
if (ret < 0)
1770-
return ret;
1771-
}
1764+
int ret = ff_progress_frame_alloc(avctx, f);
1765+
if (ret < 0)
1766+
return ret;
17721767

17731768
ret = ff_thread_get_buffer(avctx, f->progress->f, flags);
17741769
if (ret < 0) {

libavcodec/hevc/refs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "hevc.h"
3030
#include "hevcdec.h"
3131
#include "progressframe.h"
32+
#include "thread.h"
3233
#include "libavutil/refstruct.h"
3334

3435
void ff_hevc_unref_frame(HEVCFrame *frame, int flags)
@@ -157,10 +158,9 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l)
157158
}
158159
}
159160

160-
ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
161-
AV_GET_BUFFER_FLAG_REF);
161+
ret = ff_thread_get_buffer(s->avctx, frame->f, AV_GET_BUFFER_FLAG_REF);
162162
if (ret < 0)
163-
return NULL;
163+
goto fail;
164164

165165
frame->rpl = av_refstruct_allocz(s->pkt.nb_nals * sizeof(*frame->rpl));
166166
if (!frame->rpl)

libavcodec/progressframe.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,17 @@ void ff_progress_frame_report(ProgressFrame *f, int progress);
102102
void ff_progress_frame_await(const ProgressFrame *f, int progress);
103103

104104
/**
105-
* This function allocates ProgressFrame.f
106-
* May be called before ff_progress_frame_get_buffer() in the cases where the
107-
* AVFrame needs to be accessed before the ff_thread_get_buffer() call in
108-
* ff_progress_frame_alloc().
105+
* This function sets up the ProgressFrame, i.e. ProgressFrame.f
106+
* and ProgressFrame.progress. ProgressFrame.f will be blank
107+
* (as if from av_frame_alloc() or av_frame_unref()) on success.
109108
*
110109
* @note: This must only be called by codecs with the
111110
* FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
112111
*/
113112
int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f);
114113

115114
/**
116-
* This function sets up the ProgressFrame, i.e. allocates ProgressFrame.f
117-
* if needed, and also calls ff_thread_get_buffer() on the frame.
115+
* Wrapper around ff_progress_frame_alloc() and ff_thread_get_buffer().
118116
*
119117
* @note: This must only be called by codecs with the
120118
* FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.

0 commit comments

Comments
 (0)