History

avcodec/decode: split ProgressFrame allocator into two functions

James Almer committed 2 years ago

Commit dbbf9a51 parent a48eba02 files · +21 −6Browse files

Unified · Split

2 files
  1. libavcodec/decode.c +7 −4
  2. libavcodec/progressframe.h +14 −2
libavcodec/decode.c+7−4
@@ -1725,7 +1725,7 @@ static void check_progress_consistency(const ProgressFrame *f) · 1724 unmodified lines
17251725 av_assert1(!f->progress || f->progress->f == f->f);
17261726 }
17271727
1728−static int progress_frame_get(AVCodecContext *avctx, ProgressFrame *f)
1728+int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f)
17291729 {
17301730 FFRefStructPool *pool = avctx->internal->progress_frame_pool;
17311731
@@ -1743,9 +1743,12 @@ int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int fl · 11 unmodified lines
17431743 {
17441744 int ret;
17451745
1746− ret = progress_frame_get(avctx, f);
1747− if (ret < 0)
1748− return ret;
1746+ check_progress_consistency(f);
1747+ if (!f->f) {
1748+ ret = ff_progress_frame_alloc(avctx, f);
1749+ if (ret < 0)
1750+ return ret;
1751+ }
17491752
17501753 ret = ff_thread_get_buffer(avctx, f->progress->f, flags);
17511754 if (ret < 0) {
libavcodec/progressframe.h+14−2
@@ -102,12 +102,24 @@ 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 sets up the ProgressFrame, i.e. gets ProgressFrame.f
106− * and also calls ff_thread_get_buffer() on the frame.
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().
107109 *
108110 * @note: This must only be called by codecs with the
109111 * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
110112 */
113+int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f);
114+
115+/**
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.
118+ *
119+ * @note: This must only be called by codecs with the
120+ * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
121+ * @see ff_progress_frame_alloc
122+ */
111123 int ff_progress_frame_get_buffer(struct AVCodecContext *avctx,
112124 ProgressFrame *f, int flags);
113125

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