Finish decoder capability probes after first paced output and drain
This commit is contained in:
1 parent
7ae204ba4f
commit
8ad5c09474
2 files changed
+42
-9
No files matched your search
@@ -232,6 +232,7 @@ int CallVideoDecoder::receive(call_video_frame& f, QImage& image) {
|
||||
}
|
||||
|
||||
call_video_caps CallVideoDecoder::capabilities(const std::atomic<bool>* running) {
|
||||
const int64_t started = call_video_playout_now_us();
|
||||
static call_video_caps caps{};
|
||||
static std::mutex lock;
|
||||
static bool initialized = false;
|
||||
@@ -241,7 +242,11 @@ call_video_caps CallVideoDecoder::capabilities(const std::atomic<bool>* running)
|
||||
};
|
||||
std::unique_lock<std::mutex> guard(lock, std::defer_lock);
|
||||
while (!guard.try_lock()) { if (cancelled()) return {}; QThread::usleep(1000); }
|
||||
if (initialized) return caps;
|
||||
if (initialized) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "video decoder capabilities cache hit wait_us=%lld",
|
||||
(long long)(call_video_playout_now_us() - started));
|
||||
return caps;
|
||||
}
|
||||
call_video_caps probed{};
|
||||
for (unsigned codec = 1; codec <= 2; ++codec) {
|
||||
call_video_limit limit{};
|
||||
@@ -269,9 +274,10 @@ call_video_caps CallVideoDecoder::capabilities(const std::atomic<bool>* running)
|
||||
4000000, (uint8_t)profile};
|
||||
unsigned sent = 0, received = 0; bool valid = true, outputBeforeEos = false;
|
||||
const int64_t start = call_video_playout_now_us();
|
||||
while (valid && received < 8 && call_video_playout_now_us() - start < 1500000) {
|
||||
// Pacing нужен до первого выхода для измерения pipeline, затем проверяем drain принятых входов.
|
||||
while (valid && call_video_playout_now_us() - start < 1500000) {
|
||||
if (cancelled()) return {};
|
||||
if (sent < 8 && call_video_playout_now_us() - start >= sent * 1000000ll / fps) {
|
||||
if (!outputBeforeEos && sent < 8 && 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;
|
||||
}
|
||||
@@ -283,12 +289,15 @@ call_video_caps CallVideoDecoder::capabilities(const std::atomic<bool>* running)
|
||||
if (!decoder.m->eos) outputBeforeEos = true;
|
||||
++received;
|
||||
}
|
||||
if (sent == 8 && decoder.finish() < 0) valid = false;
|
||||
if (valid && received < 8) QThread::usleep(1000);
|
||||
if ((outputBeforeEos || sent == 8) && decoder.finish() < 0) valid = false;
|
||||
if (decoder.m->eos && received == sent) break;
|
||||
if (valid) QThread::usleep(1000);
|
||||
}
|
||||
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",
|
||||
codec, profile, w, h, fps, int(backend), valid, sent, received, decoder.pipelineFrames());
|
||||
valid = valid && sent && received == sent && 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(),
|
||||
(long long)(call_video_playout_now_us() - start));
|
||||
bothOrientations = valid; backendPipeline = std::max(backendPipeline, decoder.pipelineFrames());
|
||||
}
|
||||
|
||||
@@ -314,5 +323,7 @@ call_video_caps CallVideoDecoder::capabilities(const std::atomic<bool>* running)
|
||||
}
|
||||
}
|
||||
caps = probed; initialized = true;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "video decoder capabilities verified elapsed_us=%lld",
|
||||
(long long)(call_video_playout_now_us() - started));
|
||||
return caps;
|
||||
}
|
||||
Reference in new issue
Block a user