History

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.

Andreas Rheinhardt committed 1 year ago

Commit 3b2a9411 parent 29b85cd3 files · +10 −17Browse files

Showing the changes to libavcodec (3 of 3 files). Show all

Unified · Split

3 files
  1. libavcodec/decode.c +3 −8
  2. libavcodec/hevc/refs.c +3 −3
  3. libavcodec/progressframe.h +4 −6
libavcodec/decode.c+3−8
@@ -1761,14 +1761,9 @@ int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f) · 1760 unmodified lines
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+3−3
@@ -29,6 +29,7 @@ · 28 unmodified lines
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) · 122 unmodified lines
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+4−6
@@ -102,10 +102,9 @@ void ff_progress_frame_report(ProgressFrame *f, int progress); · 101 unmodified lines
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.
@@ -113,8 +112,7 @@ void ff_progress_frame_await(const ProgressFrame *f, int progress); · 1 unmodified line
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.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t