Unified · Split
| @@ -1725,7 +1725,7 @@ static void check_progress_consistency(const ProgressFrame *f) · 1724 unmodified lines | ||
| 1725 | 1725 | av_assert1(!f->progress || f->progress->f == f->f); |
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | −static int progress_frame_get(AVCodecContext *avctx, ProgressFrame *f) | |
| 1728 | +int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f) | |
| 1729 | 1729 | { |
| 1730 | 1730 | FFRefStructPool *pool = avctx->internal->progress_frame_pool; |
| 1731 | 1731 | |
| @@ -1743,9 +1743,12 @@ int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int fl · 11 unmodified lines | ||
| 1743 | 1743 | { |
| 1744 | 1744 | int ret; |
| 1745 | 1745 | |
| 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 | + } | |
| 1749 | 1752 | |
| 1750 | 1753 | ret = ff_thread_get_buffer(avctx, f->progress->f, flags); |
| 1751 | 1754 | if (ret < 0) { |
| @@ -102,12 +102,24 @@ 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 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(). | |
| 107 | 109 | * |
| 108 | 110 | * @note: This must only be called by codecs with the |
| 109 | 111 | * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap. |
| 110 | 112 | */ |
| 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 | + */ | |
| 111 | 123 | int ff_progress_frame_get_buffer(struct AVCodecContext *avctx, |
| 112 | 124 | ProgressFrame *f, int flags); |
| 113 | 125 | |