History

avcodec/codec_internal: Remove FF_CODEC_CAP_ALLOCATE_PROGRESS

Before commit f025b8e110b36c1cdb4fb56c4cd57aeca1767b5b, every frame-threaded decoder used ThreadFrames, even when they did not have any inter-frame dependencies at all. In order to distinguish those decoders that need the AVBuffer for progress communication from those that do not (to avoid the allocation for the latter), the former decoders were marked with the FF_CODEC_CAP_ALLOCATE_PROGRESS internal codec cap. Yet distinguishing these two can be done in a more natural way: Don't use ThreadFrames when not needed and split ff_thread_get_buffer() into a core function that calls the user's get_buffer2 callback and a wrapper around it that also allocates the progress AVBuffer. This has been done in 02220b88fc38ef9dd4f2d519f5d3e4151258b60c and since that commit the ALLOCATE_PROGRESS cap was nearly redundant. The only exception was WebP and VP8. WebP can contain VP8 and uses the VP8 decoder directly (i.e. they share the same AVCodecContext). Both decoders are frame-threaded and VP8 has inter-frame dependencies (in general, not in valid WebP) and therefore the ALLOCATE_PROGRESS cap. In order to avoid allocating progress in case of a frame-threaded WebP decoder the cap and the check for the cap has been kept in place. Yet now the VP8 decoder has been switched to use ProgressFrames and therefore there is just no reason any more for this check and the cap. This commit therefore removes both. Also change the value of FF_CODEC_CAP_USES_PROGRESSFRAMES to leave no gaps.

Andreas Rheinhardt committed 3 years ago

Commit 2b46ae61 parent d7374ac11 files · +18 −36Browse files

Showing the changes to libavcodec (10 of 11 files). Show all

Unified · Split

10 files
  1. libavcodec/codec_internal.h +1 −6
  2. libavcodec/ffv1dec.c +1 −2
  3. libavcodec/h264dec.c +1 −1
  4. libavcodec/hevcdec.c +1 −1
  5. libavcodec/mpeg4videodec.c +1 −2
  6. libavcodec/pngdec.c +1 −2
  7. libavcodec/pthread_frame.c +5 −7
  8. libavcodec/rv30.c +0 −1
  9. libavcodec/rv40.c +0 −1
  10. libavcodec/tests/avcodec.c +0 −5
libavcodec/codec_internal.h+1−6
@@ -65,12 +65,7 @@ · 64 unmodified lines
6565 /**
6666 * The decoder might make use of the ProgressFrame API.
6767 */
68−#define FF_CODEC_CAP_USES_PROGRESSFRAMES (1 << 11)
69−/*
70− * The codec supports frame threading and has inter-frame dependencies, so it
71− * uses ff_thread_report/await_progress().
72− */
73−#define FF_CODEC_CAP_ALLOCATE_PROGRESS (1 << 6)
68+#define FF_CODEC_CAP_USES_PROGRESSFRAMES (1 << 6)
7469 /**
7570 * Codec handles avctx->thread_count == 0 (auto) internally.
7671 */
libavcodec/ffv1dec.c+1−2
@@ -1129,6 +1129,5 @@ const FFCodec ff_ffv1_decoder = { · 1128 unmodified lines
11291129 UPDATE_THREAD_CONTEXT(update_thread_context),
11301130 .p.capabilities = AV_CODEC_CAP_DR1 |
11311131 AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS,
1132− .caps_internal = FF_CODEC_CAP_INIT_CLEANUP |
1133− FF_CODEC_CAP_ALLOCATE_PROGRESS,
1132+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
11341133 };
libavcodec/h264dec.c+1−1
@@ -1164,7 +1164,7 @@ const FFCodec ff_h264_decoder = { · 1163 unmodified lines
11641164 NULL
11651165 },
11661166 .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING |
1167− FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP,
1167+ FF_CODEC_CAP_INIT_CLEANUP,
11681168 .flush = h264_decode_flush,
11691169 UPDATE_THREAD_CONTEXT(ff_h264_update_thread_context),
11701170 UPDATE_THREAD_CONTEXT_FOR_USER(ff_h264_update_thread_context_for_user),
libavcodec/hevcdec.c+1−1
@@ -3720,7 +3720,7 @@ const FFCodec ff_hevc_decoder = { · 3719 unmodified lines
37203720 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
37213721 AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS,
37223722 .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING |
3723− FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP,
3723+ FF_CODEC_CAP_INIT_CLEANUP,
37243724 .p.profiles = NULL_IF_CONFIG_SMALL(ff_hevc_profiles),
37253725 .hw_configs = (const AVCodecHWConfigInternal *const []) {
37263726 #if CONFIG_HEVC_DXVA2_HWACCEL
libavcodec/mpeg4videodec.c+1−2
@@ -3861,8 +3861,7 @@ const FFCodec ff_mpeg4_decoder = { · 3860 unmodified lines
38613861 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
38623862 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
38633863 AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS,
3864− .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
3865− FF_CODEC_CAP_ALLOCATE_PROGRESS,
3864+ .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
38663865 .flush = ff_mpeg_flush,
38673866 .p.max_lowres = 3,
38683867 .p.profiles = NULL_IF_CONFIG_SMALL(ff_mpeg4_video_profiles),
libavcodec/pngdec.c+1−2
@@ -1940,7 +1940,6 @@ const FFCodec ff_apng_decoder = { · 1939 unmodified lines
19401940 UPDATE_THREAD_CONTEXT(update_thread_context),
19411941 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
19421942 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP |
1943− FF_CODEC_CAP_ALLOCATE_PROGRESS |
19441943 FF_CODEC_CAP_ICC_PROFILES,
19451944 };
19461945 #endif
@@ -1958,7 +1957,7 @@ const FFCodec ff_png_decoder = { · 11 unmodified lines
19581957 UPDATE_THREAD_CONTEXT(update_thread_context),
19591958 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
19601959 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
1961− FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP |
1960+ FF_CODEC_CAP_INIT_CLEANUP |
19621961 FF_CODEC_CAP_ICC_PROFILES,
19631962 };
19641963 #endif
libavcodec/pthread_frame.c+5−7
@@ -991,14 +991,12 @@ int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags) · 990 unmodified lines
991991 if (!(avctx->active_thread_type & FF_THREAD_FRAME))
992992 return ff_get_buffer(avctx, f->f, flags);
993993
994− if (ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS) {
995− f->progress = ff_refstruct_allocz(sizeof(*f->progress));
996− if (!f->progress)
997− return AVERROR(ENOMEM);
994+ f->progress = ff_refstruct_allocz(sizeof(*f->progress));
995+ if (!f->progress)
996+ return AVERROR(ENOMEM);
998997
999− atomic_init(&f->progress->progress[0], -1);
1000− atomic_init(&f->progress->progress[1], -1);
1001− }
998+ atomic_init(&f->progress->progress[0], -1);
999+ atomic_init(&f->progress->progress[1], -1);
10021000
10031001 ret = ff_thread_get_buffer(avctx, f->f, flags);
10041002 if (ret)
libavcodec/rv30.c+0−1
@@ -304,5 +304,4 @@ const FFCodec ff_rv30_decoder = { · 303 unmodified lines
304304 AV_CODEC_CAP_FRAME_THREADS,
305305 .flush = ff_mpeg_flush,
306306 UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context),
307− .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS,
308307 };
libavcodec/rv40.c+0−1
@@ -582,5 +582,4 @@ const FFCodec ff_rv40_decoder = { · 581 unmodified lines
582582 AV_CODEC_CAP_FRAME_THREADS,
583583 .flush = ff_mpeg_flush,
584584 UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context),
585− .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS,
586585 };
libavcodec/tests/avcodec.c+0−5
@@ -142,7 +142,6 @@ int main(void){ · 141 unmodified lines
142142 }
143143 }
144144 if (codec2->caps_internal & (FF_CODEC_CAP_USES_PROGRESSFRAMES |
145− FF_CODEC_CAP_ALLOCATE_PROGRESS |
146145 FF_CODEC_CAP_SETS_PKT_DTS |
147146 FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
148147 FF_CODEC_CAP_EXPORTS_CROPPING |
@@ -172,10 +171,6 @@ int main(void){ · 23 unmodified lines
172171 AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE |
173172 AV_CODEC_CAP_ENCODER_FLUSH))
174173 ERR("Decoder %s has encoder-only capabilities\n");
175− if (codec2->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS &&
176− !(codec->capabilities & AV_CODEC_CAP_FRAME_THREADS))
177− ERR("Decoder %s wants allocated progress without supporting"
178− "frame threads\n");
179174 if (codec2->cb_type != FF_CODEC_CB_TYPE_DECODE &&
180175 codec2->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS)
181176 ERR("Decoder %s is marked as setting pkt_dts when it doesn't have"

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