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.
Unified · Split
| @@ -1761,14 +1761,9 @@ int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f) · 1760 unmodified lines | ||
| 1761 | 1761 | |
| 1762 | 1762 | int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int flags) |
| 1763 | 1763 | { |
| 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; | |
| 1772 | 1767 | |
| 1773 | 1768 | ret = ff_thread_get_buffer(avctx, f->progress->f, flags); |
| 1774 | 1769 | if (ret < 0) { |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "hevc.h" |
| 30 | 30 | #include "hevcdec.h" |
| 31 | 31 | #include "progressframe.h" |
| 32 | +#include "thread.h" | |
| 32 | 33 | #include "libavutil/refstruct.h" |
| 33 | 34 | |
| 34 | 35 | void 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 | − AV_GET_BUFFER_FLAG_REF); | |
| 161 | + ret = ff_thread_get_buffer(s->avctx, frame->f, AV_GET_BUFFER_FLAG_REF); | |
| 162 | 162 | if (ret < 0) |
| 163 | − return NULL; | |
| 163 | + goto fail; | |
| 164 | 164 | |
| 165 | 165 | frame->rpl = av_refstruct_allocz(s->pkt.nb_nals * sizeof(*frame->rpl)); |
| 166 | 166 | if (!frame->rpl) |
| @@ -102,10 +102,9 @@ void ff_progress_frame_report(ProgressFrame *f, int progress); · 101 unmodified lines | ||
| 102 | 102 | void ff_progress_frame_await(const ProgressFrame *f, int progress); |
| 103 | 103 | |
| 104 | 104 | /** |
| 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. | |
| 109 | 108 | * |
| 110 | 109 | * @note: This must only be called by codecs with the |
| 111 | 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 | ||
| 113 | 112 | int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f); |
| 114 | 113 | |
| 115 | 114 | /** |
| 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(). | |
| 118 | 116 | * |
| 119 | 117 | * @note: This must only be called by codecs with the |
| 120 | 118 | * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap. |