|
1 | | -From 80e3f410d1ad8807bd4a9f4d5cdf7a7b3c5962ce Mon Sep 17 00:00:00 2001 |
| 1 | +From 3248aee7fc94304cd5f41afa8dc502d92ae080ef Mon Sep 17 00:00:00 2001 |
2 | 2 | From: Jing Sun < [email protected]> |
3 | 3 | Date: Wed, 21 Nov 2018 11:33:04 +0800 |
4 | 4 | Subject: [PATCH 1/1] lavc/svt_hevc: add libsvt hevc encoder wrapper |
|
11 | 11 | configure | 4 + |
12 | 12 | libavcodec/Makefile | 1 + |
13 | 13 | libavcodec/allcodecs.c | 1 + |
14 | | - libavcodec/libsvt_hevc.c | 497 +++++++++++++++++++++++++++++++++++++++++++++++ |
15 | | - 4 files changed, 503 insertions(+) |
| 14 | + libavcodec/libsvt_hevc.c | 515 +++++++++++++++++++++++++++++++++++++++++++++++ |
| 15 | + 4 files changed, 521 insertions(+) |
16 | 16 | create mode 100644 libavcodec/libsvt_hevc.c |
17 | 17 |
|
18 | 18 | diff --git a/configure b/configure |
@@ -77,10 +77,10 @@ index d2f9a39..d8788a7 100644 |
77 | 77 | extern AVCodec ff_libvo_amrwbenc_encoder; |
78 | 78 | diff --git a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c |
79 | 79 | new file mode 100644 |
80 | | -index 0000000..24ab0ff |
| 80 | +index 0000000..77eae48 |
81 | 81 | --- /dev/null |
82 | 82 | +++ b/libavcodec/libsvt_hevc.c |
83 | | -@@ -0,0 +1,497 @@ |
| 83 | +@@ -0,0 +1,515 @@ |
84 | 84 | +/* |
85 | 85 | +* Scalable Video Technology for HEVC encoder library plugin |
86 | 86 | +* |
@@ -142,6 +142,7 @@ index 0000000..24ab0ff |
142 | 142 | + int asm_type; |
143 | 143 | + int forced_idr; |
144 | 144 | + int la_depth; |
| 145 | ++ int thread_count; |
145 | 146 | +} SvtContext; |
146 | 147 | + |
147 | 148 | +static int error_mapping(EB_ERRORTYPE svt_ret) |
@@ -282,6 +283,20 @@ index 0000000..24ab0ff |
282 | 283 | + if (svt_enc->la_depth != -1) |
283 | 284 | + param->lookAheadDistance = svt_enc->la_depth; |
284 | 285 | + |
| 286 | ++ if ((svt_enc->thread_count > 0) && |
| 287 | ++ (svt_enc->thread_count < (EB_THREAD_COUNT_MIN_CORE * EB_THREAD_COUNT_FACTOR))) { |
| 288 | ++ param->threadCount = EB_THREAD_COUNT_MIN_CORE * EB_THREAD_COUNT_FACTOR; |
| 289 | ++ av_log(avctx, AV_LOG_WARNING, "Thread count is set too small, forced to %"PRId32"\n", |
| 290 | ++ param->threadCount); |
| 291 | ++ } else if (svt_enc->thread_count % EB_THREAD_COUNT_MIN_CORE) { |
| 292 | ++ param->threadCount = (svt_enc->thread_count + EB_THREAD_COUNT_MIN_CORE - 1) |
| 293 | ++ / EB_THREAD_COUNT_MIN_CORE * EB_THREAD_COUNT_MIN_CORE; |
| 294 | ++ av_log(avctx, AV_LOG_DEBUG, "Thread count is rounded to %"PRId32"\n", |
| 295 | ++ param->threadCount); |
| 296 | ++ } else { |
| 297 | ++ param->threadCount = svt_enc->thread_count; |
| 298 | ++ } |
| 299 | ++ |
285 | 300 | + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) |
286 | 301 | + param->codeVpsSpsPps = 0; |
287 | 302 | + else |
@@ -525,6 +540,9 @@ index 0000000..24ab0ff |
525 | 540 | + { "sc_detection", "Scene change detection", OFFSET(scd), |
526 | 541 | + AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE }, |
527 | 542 | + |
| 543 | ++ { "thread_count", "Number of threads [0: Auto, 96: Min]", OFFSET(thread_count), |
| 544 | ++ AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE }, |
| 545 | ++ |
528 | 546 | + { "tier", "Set tier (general_tier_flag)", OFFSET(tier), |
529 | 547 | + AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, "tier" }, |
530 | 548 | + { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "tier" }, |
@@ -565,7 +583,7 @@ index 0000000..24ab0ff |
565 | 583 | + .init = eb_enc_init, |
566 | 584 | + .encode2 = eb_encode_frame, |
567 | 585 | + .close = eb_enc_close, |
568 | | -+ .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, |
| 586 | ++ .capabilities = AV_CODEC_CAP_DELAY, |
569 | 587 | + .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, |
570 | 588 | + AV_PIX_FMT_YUV420P10, |
571 | 589 | + AV_PIX_FMT_YUV422P, |
|
0 commit comments