diff --git a/tools/chatgui/src/call_video_decoder.cpp b/tools/chatgui/src/call_video_decoder.cpp index 1854769c..09adcfa7 100644 --- a/tools/chatgui/src/call_video_decoder.cpp +++ b/tools/chatgui/src/call_video_decoder.cpp @@ -274,10 +274,10 @@ call_video_caps CallVideoDecoder::capabilities(const std::atomic* running) 4000000, (uint8_t)profile}; unsigned sent = 0, received = 0; bool valid = true, outputBeforeEos = false; const int64_t start = call_video_playout_now_us(); - // Pacing нужен до первого выхода для измерения pipeline, затем проверяем drain принятых входов. - while (valid && call_video_playout_now_us() - start < 1500000) { + // Pacing измеряет pipeline до первого выхода; остальные из восьми кадров проверяются без пауз. + while (valid && received < 8 && call_video_playout_now_us() - start < 1500000) { if (cancelled()) return {}; - if (!outputBeforeEos && sent < 8 && call_video_playout_now_us() - start >= sent * 1000000ll / fps) { + if (sent < 8 && (outputBeforeEos || call_video_playout_now_us() - start >= sent * 1000000ll / fps)) { input.frame_id = sent + 1; input.pts_us = 1000000 + sent * 1000000ll / fps; int result = decoder.submit(input); if (result < 0) valid = false; else if (result) ++sent; } @@ -289,11 +289,10 @@ call_video_caps CallVideoDecoder::capabilities(const std::atomic* running) if (!decoder.m->eos) outputBeforeEos = true; ++received; } - if ((outputBeforeEos || sent == 8) && decoder.finish() < 0) valid = false; - if (decoder.m->eos && received == sent) break; - if (valid) QThread::usleep(1000); + if (sent == 8 && decoder.finish() < 0) valid = false; + if (valid && received < 8) QThread::usleep(1000); } - valid = valid && sent && received == sent && outputBeforeEos; + valid = valid && received == 8 && outputBeforeEos; DEBUG_INFO(DEBUG_CATEGORY_CALL, "video decoder probe codec=%u profile=%u size=%ux%u fps=%u backend=%d " "valid=%d inputs=%u outputs=%u pipeline=%u elapsed_us=%lld", codec, profile, w, h, fps, int(backend), valid, sent, received, decoder.pipelineFrames(), diff --git a/tools/chatgui/tests/test_call_video_gpu.cpp b/tools/chatgui/tests/test_call_video_gpu.cpp index 139cb186..c144a92d 100644 --- a/tools/chatgui/tests/test_call_video_gpu.cpp +++ b/tools/chatgui/tests/test_call_video_gpu.cpp @@ -25,10 +25,10 @@ static QByteArray selected; static unsigned opened = 0, software = 0; static int depth = 1; static bool burst = false, badReplacement = false, badProbe = false; -struct DecodePending { std::deque frames; bool eos = false; unsigned inputs = 0; }; +struct DecodePending { std::deque frames; bool eos = false; unsigned inputs = 0, outputs = 0; }; static std::map decoderContexts; static bool delayedDecoder = false; -static unsigned probeInputs = 0, probeOutputs = 0, probeMaxInputs = 0; +static unsigned probeInputs = 0, probeOutputs = 0, probeMaxInputs = 0, probeFirstInputs = 0; extern "C" const AVCodec* __real_avcodec_find_encoder_by_name(const char*); extern "C" const AVCodec* __wrap_avcodec_find_encoder_by_name(const char* name) { @@ -133,6 +133,7 @@ extern "C" int __wrap_avcodec_receive_frame(AVCodecContext* context, AVFrame* ou if (result < 0 && result != AVERROR(EAGAIN) && result != AVERROR_EOF) return result; if (state.frames.empty()) return result; if (!state.eos && state.frames.size() <= 2) return AVERROR(EAGAIN); + if (!state.outputs++) probeFirstInputs = std::max(probeFirstInputs, state.inputs); ++probeOutputs; av_frame_move_ref(output, state.frames.front()); av_frame_free(&state.frames.front()); state.frames.pop_front(); return 0; } @@ -143,7 +144,7 @@ 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 = delayedDecoder = false; - probeInputs = probeOutputs = probeMaxInputs = 0; + probeInputs = probeOutputs = probeMaxInputs = probeFirstInputs = 0; QVERIFY(contexts.empty()); QVERIFY(decoderContexts.empty()); } void cleanup() { QVERIFY(contexts.empty()); QVERIFY(decoderContexts.empty()); } @@ -156,7 +157,8 @@ private slots: QCOMPARE(limit.profiles, uint8_t(3)); QCOMPARE(limit.fps, uint16_t(60)); QCOMPARE(limit.width, uint16_t(1920)); QCOMPARE(limit.height, uint16_t(1920)); } - QVERIFY(probeInputs > 0); QCOMPARE(probeMaxInputs, 3u); QCOMPARE(probeOutputs, probeInputs); + QCOMPARE(probeInputs, 48u * 8); QCOMPARE(probeMaxInputs, 8u); QCOMPARE(probeFirstInputs, 3u); + QCOMPARE(probeOutputs, probeInputs); const unsigned before = probeInputs; const auto cached = CallVideoDecoder::capabilities(); QCOMPARE(cached.decode[0].profiles, caps.decode[0].profiles); QCOMPARE(probeInputs, before);