|
|
|
|
@ -67,9 +67,14 @@ private slots:
|
|
|
|
|
for (uint32_t bitrate : {1000000u, 300000u, 4000000u}) { |
|
|
|
|
QVERIFY(encoder.requestBitrate(config.generation, ++request, bitrate)); |
|
|
|
|
LiveEncodedFrame output; CallVideoRateCompletion completion; |
|
|
|
|
QVERIFY2(encoder.encode(image, pts, true, output, completion), qPrintable(encoder.error())); |
|
|
|
|
QElapsedTimer deadline; deadline.start(); |
|
|
|
|
do { |
|
|
|
|
QVERIFY2(encoder.encode(image, pts, true, output, completion), qPrintable(encoder.error())); |
|
|
|
|
QVERIFY(decoder.decode(output)); pts += 33333; |
|
|
|
|
if (!completion.request) QTest::qWait(33); |
|
|
|
|
} while (!completion.request && deadline.elapsed() < 3000); |
|
|
|
|
QCOMPARE(completion.request, request); QCOMPARE(completion.bitrate, bitrate); |
|
|
|
|
QVERIFY(decoder.decode(output)); QCOMPARE(decoder.context->level, int(config.level)); |
|
|
|
|
QCOMPARE(decoder.context->level, int(config.level)); |
|
|
|
|
QCOMPARE(decoder.frame->width, 1280); QCOMPARE(decoder.frame->height, 720); |
|
|
|
|
pts += 1000000; |
|
|
|
|
} |
|
|
|
|
@ -112,7 +117,7 @@ private slots:
|
|
|
|
|
QImage image(config.width, config.height, QImage::Format_RGB32); |
|
|
|
|
uint32_t random = 1; unsigned completions = 0; |
|
|
|
|
for (int phase = 0; phase < 3; phase++) { |
|
|
|
|
uint64_t bytes = 0; uint32_t target = phase == 1 ? 300000 : 4000000; |
|
|
|
|
uint64_t bytes = 0; uint32_t target = phase == 1 ? 300000 : 4000000; qint64 longestEncode = 0; |
|
|
|
|
for (int frame = 0; frame < 120; frame++) { |
|
|
|
|
for (int y = 0; y < image.height(); y++) { |
|
|
|
|
auto* row = reinterpret_cast<QRgb*>(image.scanLine(y)); |
|
|
|
|
@ -128,7 +133,9 @@ private slots:
|
|
|
|
|
} |
|
|
|
|
uint64_t pts = 5000000 + (phase * 120 + frame) * 1000000ull / 30; |
|
|
|
|
LiveEncodedFrame output; CallVideoRateCompletion completion; |
|
|
|
|
QElapsedTimer encoding; encoding.start(); |
|
|
|
|
QVERIFY2(encoder.encode(image, pts, false, output, completion), qPrintable(encoder.error())); |
|
|
|
|
longestEncode = qMax(longestEncode, encoding.elapsed()); |
|
|
|
|
QCOMPARE(output.pts, pts); QCOMPARE(output.key, frame % 30 == 0); |
|
|
|
|
if (phase && frame == 30) { |
|
|
|
|
QCOMPARE(completion.generation, uint64_t(17)); QCOMPARE(completion.request, uint64_t(phase)); |
|
|
|
|
@ -146,10 +153,12 @@ private slots:
|
|
|
|
|
QCOMPARE(decoder.context->profile, codec == 1 ? AV_PROFILE_H264_CONSTRAINED_BASELINE : AV_PROFILE_HEVC_MAIN); |
|
|
|
|
QCOMPARE(decoder.context->level, config.level); |
|
|
|
|
if (frame >= 60) bytes += output.data.size(); |
|
|
|
|
// Подготовка идёт по реальным часам, capture PTS — по часам камеры.
|
|
|
|
|
if (phase && frame >= 7 && frame < 30) QTest::qWait(33); |
|
|
|
|
} |
|
|
|
|
uint64_t measured = bytes * 8 / 2; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CALL, "call encoder test codec=%d phase=%d target=%u measured=%llu", |
|
|
|
|
codec, phase, target, (unsigned long long)measured); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CALL, "call encoder test codec=%d phase=%d target=%u measured=%llu max_encode_ms=%lld", |
|
|
|
|
codec, phase, target, (unsigned long long)measured, (long long)longestEncode); |
|
|
|
|
QVERIFY(measured > target / 2 && measured < uint64_t(target) * 3 / 2); |
|
|
|
|
} |
|
|
|
|
QCOMPARE(completions, 2u); |
|
|
|
|
@ -172,7 +181,11 @@ private slots:
|
|
|
|
|
auto saved = output; QVERIFY(!encoder.encode(image, 166666, false, output, completion)); QCOMPARE(output.data, saved.data); |
|
|
|
|
// Пропуск capture-кадров не откладывает IDR на количество пропущенных кадров.
|
|
|
|
|
QVERIFY(encoder.requestBitrate(9, 2, 300000)); |
|
|
|
|
QVERIFY(encoder.encode(image, 1500000, false, output, completion)); |
|
|
|
|
uint64_t pts = 1500000; QElapsedTimer deadline; deadline.start(); |
|
|
|
|
do { |
|
|
|
|
QVERIFY(encoder.encode(image, pts, false, output, completion)); QVERIFY(output.key); pts += 1000000; |
|
|
|
|
if (!completion.request) QTest::qWait(33); |
|
|
|
|
} while (!completion.request && deadline.elapsed() < 3000); |
|
|
|
|
QCOMPARE(completion.request, uint64_t(2)); QCOMPARE(completion.bitrate, 300000u); QVERIFY(output.key); |
|
|
|
|
encoder.close(); QVERIFY(!encoder.requestBitrate(9, 3, 500000)); |
|
|
|
|
} |
|
|
|
|
|