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
74 * uses ff_thread_report/await_progress().74 * uses ff_thread_report/await_progress().
75 */75 */
76#define FF_CODEC_CAP_ALLOCATE_PROGRESS (1 << 6)76#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)
77 81
78/**82/**
79 * AVCodec.codec_tags termination value83 * AVCodec.codec_tags termination value
libavcodec/libaomdec.c+1−0
@@ -237,6 +237,7 @@ AVCodec ff_libaom_av1_decoder = { · 236 unmodified lines
237 .close = aom_free,237 .close = aom_free,
238 .decode = aom_decode,238 .decode = aom_decode,
239 .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1,239 .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1,
240 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
240 .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),241 .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
241 .wrapper_name = "libaom",242 .wrapper_name = "libaom",
242};243};
libavcodec/libaomenc.c+1−0
@@ -1346,6 +1346,7 @@ AVCodec ff_libaom_av1_encoder = { · 1345 unmodified lines
1346 .encode2 = aom_encode,1346 .encode2 = aom_encode,
1347 .close = aom_free,1347 .close = aom_free,
1348 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,1348 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
1349 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
1349 .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),1350 .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
1350 .priv_class = &class_aom,1351 .priv_class = &class_aom,
1351 .defaults = defaults,1352 .defaults = defaults,
libavcodec/libdav1d.c+2−1
@@ -485,7 +485,8 @@ AVCodec ff_libdav1d_decoder = { · 484 unmodified lines
485 .flush = libdav1d_flush,485 .flush = libdav1d_flush,
486 .receive_frame = libdav1d_receive_frame,486 .receive_frame = libdav1d_receive_frame,
487 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,487 .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,
489 .priv_class = &libdav1d_class,490 .priv_class = &libdav1d_class,
490 .wrapper_name = "libdav1d",491 .wrapper_name = "libdav1d",
491};492};
libavcodec/libdavs2.c+1−0
@@ -222,6 +222,7 @@ AVCodec ff_libdavs2_decoder = { · 221 unmodified lines
222 .decode = davs2_decode_frame,222 .decode = davs2_decode_frame,
223 .flush = davs2_flush,223 .flush = davs2_flush,
224 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,224 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
225 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
225 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,226 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
226 AV_PIX_FMT_NONE },227 AV_PIX_FMT_NONE },
227 .wrapper_name = "libdavs2",228 .wrapper_name = "libdavs2",
libavcodec/libkvazaar.c+2−1
@@ -341,7 +341,8 @@ AVCodec ff_libkvazaar_encoder = { · 340 unmodified lines
341 .encode2 = libkvazaar_encode,341 .encode2 = libkvazaar_encode,
342 .close = libkvazaar_close,342 .close = libkvazaar_close,
343 343
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,
345 346
346 .wrapper_name = "libkvazaar",347 .wrapper_name = "libkvazaar",
347};348};
libavcodec/libopenh264enc.c+2−1
@@ -448,7 +448,8 @@ AVCodec ff_libopenh264_encoder = { · 447 unmodified lines
448 .encode2 = svc_encode_frame,448 .encode2 = svc_encode_frame,
449 .close = svc_encode_close,449 .close = svc_encode_close,
450 .capabilities = AV_CODEC_CAP_AUTO_THREADS,450 .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,
452 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,453 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
453 AV_PIX_FMT_NONE },454 AV_PIX_FMT_NONE },
454 .defaults = svc_enc_defaults,455 .defaults = svc_enc_defaults,
libavcodec/librav1e.c+1−1
@@ -625,6 +625,6 @@ AVCodec ff_librav1e_encoder = { · 624 unmodified lines
625 .defaults = librav1e_defaults,625 .defaults = librav1e_defaults,
626 .pix_fmts = librav1e_pix_fmts,626 .pix_fmts = librav1e_pix_fmts,
627 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,627 .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,
629 .wrapper_name = "librav1e",629 .wrapper_name = "librav1e",
630};630};
libavcodec/libsvtav1.c+1−0
@@ -561,6 +561,7 @@ AVCodec ff_libsvtav1_encoder = { · 560 unmodified lines
561 .receive_packet = eb_receive_packet,561 .receive_packet = eb_receive_packet,
562 .close = eb_enc_close,562 .close = eb_enc_close,
563 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,563 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
564 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
564 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,565 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
565 AV_PIX_FMT_YUV420P10,566 AV_PIX_FMT_YUV420P10,
566 AV_PIX_FMT_NONE },567 AV_PIX_FMT_NONE },
libavcodec/libuavs3d.c+1−0
@@ -254,6 +254,7 @@ AVCodec ff_libuavs3d_decoder = { · 253 unmodified lines
254 .close = libuavs3d_end,254 .close = libuavs3d_end,
255 .decode = libuavs3d_decode_frame,255 .decode = libuavs3d_decode_frame,
256 .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,256 .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
257 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
257 .flush = libuavs3d_flush,258 .flush = libuavs3d_flush,
258 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,259 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
259 AV_PIX_FMT_YUV420P10LE,260 AV_PIX_FMT_YUV420P10LE,
libavcodec/libvpxdec.c+2−0
@@ -362,6 +362,7 @@ AVCodec ff_libvpx_vp8_decoder = { · 361 unmodified lines
362 .close = vpx_free,362 .close = vpx_free,
363 .decode = vpx_decode,363 .decode = vpx_decode,
364 .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1,364 .capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1,
365 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
365 .wrapper_name = "libvpx",366 .wrapper_name = "libvpx",
366};367};
367#endif /* CONFIG_LIBVPX_VP8_DECODER */368#endif /* CONFIG_LIBVPX_VP8_DECODER */
@@ -383,6 +384,7 @@ AVCodec ff_libvpx_vp9_decoder = { · 15 unmodified lines
383 .close = vpx_free,384 .close = vpx_free,
384 .decode = vpx_decode,385 .decode = vpx_decode,
385 .capabilities = AV_CODEC_CAP_AUTO_THREADS,386 .capabilities = AV_CODEC_CAP_AUTO_THREADS,
387 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
386 .init_static_data = ff_vp9_init_static,388 .init_static_data = ff_vp9_init_static,
387 .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles),389 .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles),
388 .wrapper_name = "libvpx",390 .wrapper_name = "libvpx",
libavcodec/libvpxenc.c+2−0
@@ -1871,6 +1871,7 @@ AVCodec ff_libvpx_vp8_encoder = { · 1870 unmodified lines
1871 .encode2 = vpx_encode,1871 .encode2 = vpx_encode,
1872 .close = vpx_free,1872 .close = vpx_free,
1873 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,1873 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
1874 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
1874 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE },1875 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE },
1875 .priv_class = &class_vp8,1876 .priv_class = &class_vp8,
1876 .defaults = defaults,1877 .defaults = defaults,
@@ -1901,6 +1902,7 @@ AVCodec ff_libvpx_vp9_encoder = { · 24 unmodified lines
1901 .encode2 = vpx_encode,1902 .encode2 = vpx_encode,
1902 .close = vpx_free,1903 .close = vpx_free,
1903 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,1904 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
1905 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
1904 .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles),1906 .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles),
1905 .priv_class = &class_vp9,1907 .priv_class = &class_vp9,
1906 .defaults = defaults,1908 .defaults = defaults,
libavcodec/libx264.c+8−7
@@ -1204,6 +1204,7 @@ AVCodec ff_libx264_encoder = { · 1203 unmodified lines
1204 .close = X264_close,1204 .close = X264_close,
1205 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS |1205 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS |
1206 AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,1206 AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
1207 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
1207 .priv_class = &x264_class,1208 .priv_class = &x264_class,
1208 .defaults = x264_defaults,1209 .defaults = x264_defaults,
1209#if X264_BUILD < 1531210#if X264_BUILD < 153
@@ -1211,11 +1212,11 @@ AVCodec ff_libx264_encoder = { · 1 unmodified line
1211#else1212#else
1212 .pix_fmts = pix_fmts_all,1213 .pix_fmts = pix_fmts_all,
1213#endif1214#endif
1215 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS
1214#if X264_BUILD >= 1581216#if X264_BUILD >= 158
1215 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE,1217 | FF_CODEC_CAP_INIT_THREADSAFE
1216#else
1217 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1218#endif1218#endif
1219 ,
1219 .wrapper_name = "libx264",1220 .wrapper_name = "libx264",
1220};1221};
1221#endif1222#endif
@@ -1242,11 +1243,11 @@ AVCodec ff_libx264rgb_encoder = { · 20 unmodified lines
1242 .priv_class = &rgbclass,1243 .priv_class = &rgbclass,
1243 .defaults = x264_defaults,1244 .defaults = x264_defaults,
1244 .pix_fmts = pix_fmts_8bit_rgb,1245 .pix_fmts = pix_fmts_8bit_rgb,
1246 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS
1245#if X264_BUILD >= 1581247#if X264_BUILD >= 158
1246 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE,1248 | FF_CODEC_CAP_INIT_THREADSAFE
1247#else
1248 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1249#endif1249#endif
1250 ,
1250 .wrapper_name = "libx264",1251 .wrapper_name = "libx264",
1251};1252};
1252#endif1253#endif
@@ -1273,7 +1274,7 @@ AVCodec ff_libx262_encoder = { · 20 unmodified lines
1273 .priv_class = &X262_class,1274 .priv_class = &X262_class,
1274 .defaults = x264_defaults,1275 .defaults = x264_defaults,
1275 .pix_fmts = pix_fmts_8bit,1276 .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,
1277 .wrapper_name = "libx264",1278 .wrapper_name = "libx264",
1278};1279};
1279#endif1280#endif
libavcodec/libx265.c+1−0
@@ -702,5 +702,6 @@ AVCodec ff_libx265_encoder = { · 701 unmodified lines
702 .defaults = x265_defaults,702 .defaults = x265_defaults,
703 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS |703 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS |
704 AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,704 AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
705 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
705 .wrapper_name = "libx265",706 .wrapper_name = "libx265",
706};707};
libavcodec/libxavs.c+1−0
@@ -476,6 +476,7 @@ AVCodec ff_libxavs_encoder = { · 475 unmodified lines
476 .encode2 = XAVS_frame,476 .encode2 = XAVS_frame,
477 .close = XAVS_close,477 .close = XAVS_close,
478 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,478 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
479 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
479 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },480 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
480 .priv_class = &xavs_class,481 .priv_class = &xavs_class,
481 .defaults = xavs_defaults,482 .defaults = xavs_defaults,
libavcodec/libxavs2.c+1−0
@@ -295,6 +295,7 @@ AVCodec ff_libxavs2_encoder = { · 294 unmodified lines
295 .encode2 = xavs2_encode_frame,295 .encode2 = xavs2_encode_frame,
296 .close = xavs2_close,296 .close = xavs2_close,
297 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,297 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
298 .caps_internal = FF_CODEC_CAP_AUTO_THREADS,
298 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,299 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
299 AV_PIX_FMT_NONE },300 AV_PIX_FMT_NONE },
300 .priv_class = &libxavs2,301 .priv_class = &libxavs2,
libavcodec/pthread.c+1−1
@@ -56,7 +56,7 @@ static void validate_thread_parameters(AVCodecContext *avctx) · 55 unmodified lines
56 } else if (avctx->codec->capabilities & AV_CODEC_CAP_SLICE_THREADS &&56 } else if (avctx->codec->capabilities & AV_CODEC_CAP_SLICE_THREADS &&
57 avctx->thread_type & FF_THREAD_SLICE) {57 avctx->thread_type & FF_THREAD_SLICE) {
58 avctx->active_thread_type = FF_THREAD_SLICE;58 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)) {
60 avctx->thread_count = 1;60 avctx->thread_count = 1;
61 avctx->active_thread_type = 0;61 avctx->active_thread_type = 0;
62 }62 }
libavcodec/utils.c+1−1
@@ -761,7 +761,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 760 unmodified lines
761 goto free_and_end;761 goto free_and_end;
762 }762 }
763 }763 }
764 if (!HAVE_THREADS && !(codec->capabilities & AV_CODEC_CAP_AUTO_THREADS))764 if (!HAVE_THREADS && !(codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS))
765 avctx->thread_count = 1;765 avctx->thread_count = 1;
766 766
767 if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) {767 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