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.
Showing the changes to libavcodec (3 of 3 files). Show all
Unified · Split
| @@ -1761,14 +1761,9 @@ int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f) · 1760 unmodified lines | |||
| 1761 | 1761 | ||
| 1762 | int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int flags) | 1762 | int 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) { |
| @@ -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 | ||
| 34 | void ff_hevc_unref_frame(HEVCFrame *frame, int flags) | 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 | 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) |
| @@ -102,10 +102,9 @@ void ff_progress_frame_report(ProgressFrame *f, int progress); · 101 unmodified lines | |||
| 102 | void ff_progress_frame_await(const ProgressFrame *f, int progress); | 102 | void ff_progress_frame_await(const ProgressFrame *f, int progress); |
| 103 | 103 | ||
| 104 | /** | 104 | /** |
| 105 | * This function allocates ProgressFrame.f | 105 | * This function sets up the ProgressFrame, i.e. ProgressFrame.f |
| 106 | * May be called before ff_progress_frame_get_buffer() in the cases where the | 106 | * and ProgressFrame.progress. ProgressFrame.f will be blank |
| 107 | * AVFrame needs to be accessed before the ff_thread_get_buffer() call in | 107 | * (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 the | 109 | * @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 | |||
| 113 | int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f); | 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 | 115 | * 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 the | 117 | * @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. |