Verify actual bitstreams through asynchronous decoder API and CPU encoder fallback
This commit is contained in:
1 parent
5f45b38cfb
commit
f9348ce36f
2 files changed
+20
-11
No files matched your search
@@ -142,9 +142,10 @@ private slots:
|
||||
f.data = reinterpret_cast<const uint8_t*>(bytes.constData());
|
||||
f.format = {1, (uint16_t)actual.width, (uint16_t)actual.height, 30, 0, (uint8_t)codec,
|
||||
(uint8_t)actual.level, 4000000, (uint8_t)actual.profile};
|
||||
CallVideoDecoder decoder;
|
||||
CallVideoDecoder decoder(CallVideoDecoder::Backend::SoftwareOnly);
|
||||
for (unsigned i = 0; i < 4; ++i) { f.frame_id = i + 1; f.pts_us = 1000000 + i * 33333;
|
||||
QImage image; QVERIFY2(decoder.decode(f, image), qPrintable(name)); }
|
||||
QImage image; call_video_frame output{};
|
||||
QCOMPARE(decoder.submit(f), 1); QCOMPARE(decoder.receive(output, image), 1); QCOMPARE(output.pts_us, f.pts_us); }
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "hardware stream decoded file=%s", qPrintable(name));
|
||||
}
|
||||
}
|
||||
@@ -160,7 +161,7 @@ private slots:
|
||||
QVERIFY(call_video_format_supported(&sender, &receiver, &config));
|
||||
CallVideoEncoder encoder; QVERIFY2(encoder.open(config, 4000000, codec == 1 ? "libx264" : "libx265"), qPrintable(encoder.error()));
|
||||
Decoder decoder; QVERIFY(decoder.open(codec));
|
||||
CallVideoDecoder productionDecoder;
|
||||
CallVideoDecoder productionDecoder(CallVideoDecoder::Backend::SoftwareOnly);
|
||||
QImage image(config.width, config.height, QImage::Format_RGB32);
|
||||
uint32_t random = 1; unsigned completions = 0;
|
||||
for (int phase = 0; phase < 3; phase++) {
|
||||
@@ -195,7 +196,9 @@ private slots:
|
||||
call_video_frame wire{}; wire.call_id = 1; wire.frame_id = phase * 120 + frame + 1; wire.pts_us = pts;
|
||||
wire.format = config; wire.size = wire.length = output.data.size(); wire.flags = output.key ? CALL_VIDEO_KEY : 0;
|
||||
wire.data = reinterpret_cast<const uint8_t*>(output.data.constData());
|
||||
QImage rendered; QVERIFY(productionDecoder.decode(wire, rendered)); QCOMPARE(rendered.size(), image.size());
|
||||
QImage rendered; call_video_frame decodedFrame{};
|
||||
QCOMPARE(productionDecoder.submit(wire), 1); QCOMPARE(productionDecoder.receive(decodedFrame, rendered), 1);
|
||||
QCOMPARE(decodedFrame.pts_us, wire.pts_us); QCOMPARE(rendered.size(), image.size());
|
||||
QCOMPARE(decoder.frame->width, config.width); QCOMPARE(decoder.frame->height, config.height);
|
||||
QCOMPARE(decoder.frame->format, int(AV_PIX_FMT_YUV420P)); QCOMPARE(decoder.context->has_b_frames, 0);
|
||||
QCOMPARE(decoder.context->profile, codec == 1 ? AV_PROFILE_H264_CONSTRAINED_BASELINE : AV_PROFILE_HEVC_MAIN);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Настоящие software bitstream/decoder под GPU-границей FFmpeg: задержка, пачки,
|
||||
* PTS QSV 90kHz, AMF с периодическим IDR, отказ замены и запрет CPU fallback.
|
||||
* PTS QSV 90kHz, AMF с периодическим IDR, отказ замены и автоматический CPU fallback.
|
||||
* Драйвер не эмулируется: тест проверяет конвейер приложения, аппаратные прогоны нужны отдельно. */
|
||||
#include "../src/call_video_encoder.h"
|
||||
#include "../src/call_video_decoder.h"
|
||||
@@ -111,14 +111,18 @@ private slots:
|
||||
void initTestCase() { debug_config_init(); debug_set_level(DEBUG_LEVEL_WARN); av_log_set_level(AV_LOG_ERROR); }
|
||||
void init() { selected.clear(); opened = software = 0; depth = 1; burst = badReplacement = badProbe = false; QVERIFY(contexts.empty()); }
|
||||
void cleanup() { QVERIFY(contexts.empty()); }
|
||||
void gpuOnly() {
|
||||
void explicitGpuOnly() {
|
||||
CallVideoEncoder encoder; call_video_format format{1, 640, 360, 30, 0, 1, 31, 4000000, 2};
|
||||
QVERIFY(!encoder.open(format, 1000000)); QCOMPARE(software, 0u);
|
||||
QVERIFY(!encoder.open(format, 1000000, "h264_nvenc")); QCOMPARE(software, 0u);
|
||||
}
|
||||
void cpuFallback() {
|
||||
CallVideoEncoder encoder; call_video_format format{1, 640, 360, 30, 0, 1, 31, 4000000, 2};
|
||||
QVERIFY2(encoder.open(format, 1000000), qPrintable(encoder.error())); QVERIFY(software > 0);
|
||||
}
|
||||
void incompatibleProbe() {
|
||||
selected = "hevc_amf"; badProbe = true;
|
||||
CallVideoEncoder encoder; call_video_format format{1, 640, 360, 30, 0, 2, 93, 4000000, 1};
|
||||
QVERIFY(!encoder.open(format, 1000000));
|
||||
QVERIFY(!encoder.open(format, 1000000, "hevc_amf"));
|
||||
QVERIFY2(encoder.error().contains("call bitstream contract"), qPrintable(encoder.error()));
|
||||
QCOMPARE(software, 0u);
|
||||
}
|
||||
@@ -131,11 +135,12 @@ private slots:
|
||||
QVERIFY(encoder.encode(image, 1000000, true, output, completion));
|
||||
QVERIFY(encoder.encode(image, 1033333, false, output, completion));
|
||||
QCOMPARE(output.size(), 1); QCOMPARE(output.front().pts, uint64_t(1000000));
|
||||
CallVideoDecoder decoder; unsigned decodedCount = 0;
|
||||
CallVideoDecoder decoder(CallVideoDecoder::Backend::SoftwareOnly); unsigned decodedCount = 0;
|
||||
auto decode = [&](const LiveEncodedFrame& f) {
|
||||
call_video_frame wire{}; wire.call_id = 1; wire.frame_id = ++decodedCount; wire.pts_us = f.pts; wire.format = format;
|
||||
wire.data = reinterpret_cast<const uint8_t*>(f.data.constData()); wire.size = wire.length = f.data.size();
|
||||
wire.flags = f.key ? CALL_VIDEO_KEY : 0; QImage decoded; return decoder.decode(wire, decoded);
|
||||
wire.flags = f.key ? CALL_VIDEO_KEY : 0; QImage decoded; call_video_frame result{};
|
||||
return decoder.submit(wire) == 1 && decoder.receive(result, decoded) == 1 && result.pts_us == wire.pts_us;
|
||||
};
|
||||
QVERIFY(decode(output.front())); depth = 8; // GPU временно перестал выдавать output.
|
||||
for (unsigned i = 2; i < 9; ++i) {
|
||||
@@ -189,7 +194,8 @@ private slots:
|
||||
call_video_frame wire{}; wire.call_id = 1; wire.frame_id = ++shown; wire.pts_us = frame.pts;
|
||||
wire.format = format; wire.size = wire.length = frame.data.size(); wire.flags = frame.key ? CALL_VIDEO_KEY : 0;
|
||||
wire.data = reinterpret_cast<const uint8_t*>(frame.data.constData());
|
||||
QImage decoded; QVERIFY(decoder.decode(wire, decoded));
|
||||
QImage decoded; call_video_frame result{};
|
||||
QCOMPARE(decoder.submit(wire), 1); QCOMPARE(decoder.receive(result, decoded), 1); QCOMPARE(result.pts_us, wire.pts_us);
|
||||
last = frame.pts;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user