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

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
1761 1761
1762int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int flags)1762int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int flags)
1763{1763{
1764 int ret;1764 int ret = ff_progress_frame_alloc(avctx, f);
1765 1765 if (ret < 0)
1766 check_progress_consistency(f);1766 return ret;
1767 if (!f->f) {
1768 ret = ff_progress_frame_alloc(avctx, f);
1769 if (ret < 0)
1770 return ret;
1771 }
1772 1767
1773 ret = ff_thread_get_buffer(avctx, f->progress->f, flags);1768 ret = ff_thread_get_buffer(avctx, f->progress->f, flags);
1774 if (ret < 0) {1769 if (ret < 0) {
libavcodec/hevc/refs.c+3−3
@@ -29,6 +29,7 @@ · 28 unmodified lines
29#include "hevc.h"29#include "hevc.h"
30#include "hevcdec.h"30#include "hevcdec.h"
31#include "progressframe.h"31#include "progressframe.h"
32#include "thread.h"
32#include "libavutil/refstruct.h"33#include "libavutil/refstruct.h"
33 34
34void ff_hevc_unref_frame(HEVCFrame *frame, int flags)35void ff_hevc_unref_frame(HEVCFrame *frame, int flags)
@@ -157,10 +158,9 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l) · 122 unmodified lines
157 }158 }
158 }159 }
159 160
160 ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,161 ret = ff_thread_get_buffer(s->avctx, frame->f, AV_GET_BUFFER_FLAG_REF);
161 AV_GET_BUFFER_FLAG_REF);
162 if (ret < 0)162 if (ret < 0)
163 return NULL;163 goto fail;
164 164
165 frame->rpl = av_refstruct_allocz(s->pkt.nb_nals * sizeof(*frame->rpl));165 frame->rpl = av_refstruct_allocz(s->pkt.nb_nals * sizeof(*frame->rpl));
166 if (!frame->rpl)166 if (!frame->rpl)
libavcodec/progressframe.h+4−6
@@ -102,10 +102,9 @@ void ff_progress_frame_report(ProgressFrame *f, int progress); · 101 unmodified lines
102void ff_progress_frame_await(const ProgressFrame *f, int progress);102void ff_progress_frame_await(const ProgressFrame *f, int progress);
103 103
104/**104/**
105 * This function allocates ProgressFrame.f105 * This function sets up the ProgressFrame, i.e. ProgressFrame.f
106 * May be called before ff_progress_frame_get_buffer() in the cases where the106 * and ProgressFrame.progress. ProgressFrame.f will be blank
107 * AVFrame needs to be accessed before the ff_thread_get_buffer() call in107 * (as if from av_frame_alloc() or av_frame_unref()) on success.
108 * ff_progress_frame_alloc().
109 *108 *
110 * @note: This must only be called by codecs with the109 * @note: This must only be called by codecs with the
111 * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.110 * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
@@ -113,8 +112,7 @@ void ff_progress_frame_await(const ProgressFrame *f, int progress); · 1 unmodified line
113int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f);112int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f);
114 113
115/**114/**
116 * This function sets up the ProgressFrame, i.e. allocates ProgressFrame.f115 * Wrapper around ff_progress_frame_alloc() and ff_thread_get_buffer().
117 * if needed, and also calls ff_thread_get_buffer() on the frame.
118 *116 *
119 * @note: This must only be called by codecs with the117 * @note: This must only be called by codecs with the
120 * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.118 * 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