History

lavc: replace internal use of AV_CODEC_CAP_AUTO_THREADS with an internal cap

AV_CODEC_CAP_AUTO_THREADS was originally added in b4d44a45f9a to mark codecs that spawn threads internally and are able to select an optimal threads count by themselves (all such codecs are wrappers around external libraries). It is used by lavc generic code to check whether it should handle thread_count=0 itself or pass the zero directly to the codec implementation. Within this meaning, it is clearly supposed to be an internal cap rather than a public one, since from the viewpoint of a libavcodec user, lavc ALWAYS handles thread_count=0. Whether it happens in the generic code or within the codec internals is not a meaningful difference for the caller. External aspects of this flag will be dealt with in the following commit.

Anton Khirnov committed 5 years ago

Commit 8a129071 parent b60fe9518 files · +33 −13Browse files

Unified · Split

18 files
  1. libavcodec/internal.h +4 −0
  2. libavcodec/libaomdec.c +1 −0
  3. libavcodec/libaomenc.c +1 −0
  4. libavcodec/libdav1d.c +2 −1
  5. libavcodec/libdavs2.c +1 −0
  6. libavcodec/libkvazaar.c +2 −1
  7. libavcodec/libopenh264enc.c +2 −1
  8. libavcodec/librav1e.c +1 −1
  9. libavcodec/libsvtav1.c +1 −0
  10. libavcodec/libuavs3d.c +1 −0
  11. libavcodec/libvpxdec.c +2 −0
  12. libavcodec/libvpxenc.c +2 −0
  13. libavcodec/libx264.c +8 −7
  14. libavcodec/libx265.c +1 −0
  15. libavcodec/libxavs.c +1 −0
  16. libavcodec/libxavs2.c +1 −0
  17. libavcodec/pthread.c +1 −1
  18. libavcodec/utils.c +1 −1
libavcodec/internal.h+4−0
@@ -74,6 +74,10 @@ · 73 unmodified lines
7474 * uses ff_thread_report/await_progress().
7575 */
7676 #define FF_CODEC_CAP_ALLOCATE_PROGRESS (1 << 6)
77+/**
78+ * Codec handles avctx->thread_count == 0 (auto) internally.
79+ */
80+#define FF_CODEC_CAP_AUTO_THREADS (1 << 7)
7781
7882 /**
7983 * AVCodec.codec_tags termination value
libavcodec/libaomdec.c+1−0
@@ -237,6 +237,7 @@ AVCodec ff_libaom_av1_decoder = { · 236 unmodified lines
237237 .close = aom_free,
238238 .decode = aom_decode,
239239 .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1,
240+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
240241 .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
241242 .wrapper_name = "libaom",
242243 };
libavcodec/libaomenc.c+1−0
@@ -1346,6 +1346,7 @@ AVCodec ff_libaom_av1_encoder = { · 1345 unmodified lines
13461346 .encode2 = aom_encode,
13471347 .close = aom_free,
13481348 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
1349+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
13491350 .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
13501351 .priv_class = &class_aom,
13511352 .defaults = defaults,
libavcodec/libdav1d.c+2−1
@@ -485,7 +485,8 @@ AVCodec ff_libdav1d_decoder = { · 484 unmodified lines
485485 .flush = libdav1d_flush,
486486 .receive_frame = libdav1d_receive_frame,
487487 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
488− .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_SETS_PKT_DTS,
488+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_SETS_PKT_DTS |
489+ FF_CODEC_CAP_AUTO_THREADS,
489490 .priv_class = &libdav1d_class,
490491 .wrapper_name = "libdav1d",
491492 };
libavcodec/libdavs2.c+1−0
@@ -222,6 +222,7 @@ AVCodec ff_libdavs2_decoder = { · 221 unmodified lines
222222 .decode = davs2_decode_frame,
223223 .flush = davs2_flush,
224224 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
225+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
225226 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
226227 AV_PIX_FMT_NONE },
227228 .wrapper_name = "libdavs2",
libavcodec/libkvazaar.c+2−1
@@ -341,7 +341,8 @@ AVCodec ff_libkvazaar_encoder = { · 340 unmodified lines
341341 .encode2 = libkvazaar_encode,
342342 .close = libkvazaar_close,
343343
344− .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
344+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP |
345+ FF_CODEC_CAP_AUTO_THREADS,
345346
346347 .wrapper_name = "libkvazaar",
347348 };
libavcodec/libopenh264enc.c+2−1
@@ -448,7 +448,8 @@ AVCodec ff_libopenh264_encoder = { · 447 unmodified lines
448448 .encode2 = svc_encode_frame,
449449 .close = svc_encode_close,
450450 .capabilities = AV_CODEC_CAP_AUTO_THREADS,
451− .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
451+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP |
452+ FF_CODEC_CAP_AUTO_THREADS,
452453 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
453454 AV_PIX_FMT_NONE },
454455 .defaults = svc_enc_defaults,
libavcodec/librav1e.c+1−1
@@ -625,6 +625,6 @@ AVCodec ff_librav1e_encoder = { · 624 unmodified lines
625625 .defaults = librav1e_defaults,
626626 .pix_fmts = librav1e_pix_fmts,
627627 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
628− .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
628+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS,
629629 .wrapper_name = "librav1e",
630630 };
libavcodec/libsvtav1.c+1−0
@@ -561,6 +561,7 @@ AVCodec ff_libsvtav1_encoder = { · 560 unmodified lines
561561 .receive_packet = eb_receive_packet,
562562 .close = eb_enc_close,
563563 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
564+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
564565 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
565566 AV_PIX_FMT_YUV420P10,
566567 AV_PIX_FMT_NONE },
libavcodec/libuavs3d.c+1−0
@@ -254,6 +254,7 @@ AVCodec ff_libuavs3d_decoder = { · 253 unmodified lines
254254 .close = libuavs3d_end,
255255 .decode = libuavs3d_decode_frame,
256256 .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
257+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
257258 .flush = libuavs3d_flush,
258259 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
259260 AV_PIX_FMT_YUV420P10LE,
libavcodec/libvpxdec.c+2−0
@@ -362,6 +362,7 @@ AVCodec ff_libvpx_vp8_decoder = { · 361 unmodified lines
362362 .close = vpx_free,
363363 .decode = vpx_decode,
364364 .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1,
365+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
365366 .wrapper_name = "libvpx",
366367 };
367368 #endif /* CONFIG_LIBVPX_VP8_DECODER */
@@ -383,6 +384,7 @@ AVCodec ff_libvpx_vp9_decoder = { · 15 unmodified lines
383384 .close = vpx_free,
384385 .decode = vpx_decode,
385386 .capabilities = AV_CODEC_CAP_AUTO_THREADS,
387+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
386388 .init_static_data = ff_vp9_init_static,
387389 .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles),
388390 .wrapper_name = "libvpx",
libavcodec/libvpxenc.c+2−0
@@ -1871,6 +1871,7 @@ AVCodec ff_libvpx_vp8_encoder = { · 1870 unmodified lines
18711871 .encode2 = vpx_encode,
18721872 .close = vpx_free,
18731873 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
1874+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
18741875 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE },
18751876 .priv_class = &class_vp8,
18761877 .defaults = defaults,
@@ -1901,6 +1902,7 @@ AVCodec ff_libvpx_vp9_encoder = { · 24 unmodified lines
19011902 .encode2 = vpx_encode,
19021903 .close = vpx_free,
19031904 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
1905+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
19041906 .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles),
19051907 .priv_class = &class_vp9,
19061908 .defaults = defaults,
libavcodec/libx264.c+8−7
@@ -1204,6 +1204,7 @@ AVCodec ff_libx264_encoder = { · 1203 unmodified lines
12041204 .close = X264_close,
12051205 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS |
12061206 AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
1207+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
12071208 .priv_class = &x264_class,
12081209 .defaults = x264_defaults,
12091210 #if X264_BUILD < 153
@@ -1211,11 +1212,11 @@ AVCodec ff_libx264_encoder = { · 1 unmodified line
12111212 #else
12121213 .pix_fmts = pix_fmts_all,
12131214 #endif
1215+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS
12141216 #if X264_BUILD >= 158
1215− .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE,
1216−#else
1217− .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1217+ | FF_CODEC_CAP_INIT_THREADSAFE
12181218 #endif
1219+ ,
12191220 .wrapper_name = "libx264",
12201221 };
12211222 #endif
@@ -1242,11 +1243,11 @@ AVCodec ff_libx264rgb_encoder = { · 20 unmodified lines
12421243 .priv_class = &rgbclass,
12431244 .defaults = x264_defaults,
12441245 .pix_fmts = pix_fmts_8bit_rgb,
1246+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS
12451247 #if X264_BUILD >= 158
1246− .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE,
1247−#else
1248− .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1248+ | FF_CODEC_CAP_INIT_THREADSAFE
12491249 #endif
1250+ ,
12501251 .wrapper_name = "libx264",
12511252 };
12521253 #endif
@@ -1273,7 +1274,7 @@ AVCodec ff_libx262_encoder = { · 20 unmodified lines
12731274 .priv_class = &X262_class,
12741275 .defaults = x264_defaults,
12751276 .pix_fmts = pix_fmts_8bit,
1276− .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1277+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS,
12771278 .wrapper_name = "libx264",
12781279 };
12791280 #endif
libavcodec/libx265.c+1−0
@@ -702,5 +702,6 @@ AVCodec ff_libx265_encoder = { · 701 unmodified lines
702702 .defaults = x265_defaults,
703703 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS |
704704 AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
705+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
705706 .wrapper_name = "libx265",
706707 };
libavcodec/libxavs.c+1−0
@@ -476,6 +476,7 @@ AVCodec ff_libxavs_encoder = { · 475 unmodified lines
476476 .encode2 = XAVS_frame,
477477 .close = XAVS_close,
478478 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
479+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
479480 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
480481 .priv_class = &xavs_class,
481482 .defaults = xavs_defaults,
libavcodec/libxavs2.c+1−0
@@ -295,6 +295,7 @@ AVCodec ff_libxavs2_encoder = { · 294 unmodified lines
295295 .encode2 = xavs2_encode_frame,
296296 .close = xavs2_close,
297297 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
298+ .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
298299 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
299300 AV_PIX_FMT_NONE },
300301 .priv_class = &libxavs2,
libavcodec/pthread.c+1−1
@@ -56,7 +56,7 @@ static void validate_thread_parameters(AVCodecContext *avctx) · 55 unmodified lines
5656 } else if (avctx->codec->capabilities & AV_CODEC_CAP_SLICE_THREADS &&
5757 avctx->thread_type & FF_THREAD_SLICE) {
5858 avctx->active_thread_type = FF_THREAD_SLICE;
59− } else if (!(avctx->codec->capabilities & AV_CODEC_CAP_AUTO_THREADS)) {
59+ } else if (!(avctx->codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS)) {
6060 avctx->thread_count = 1;
6161 avctx->active_thread_type = 0;
6262 }
libavcodec/utils.c+1−1
@@ -761,7 +761,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 760 unmodified lines
761761 goto free_and_end;
762762 }
763763 }
764− if (!HAVE_THREADS && !(codec->capabilities & AV_CODEC_CAP_AUTO_THREADS))
764+ if (!HAVE_THREADS && !(codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS))
765765 avctx->thread_count = 1;
766766
767767 if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) {

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