Accept valid HEVC PPS flags and verify call GPU probes fully

This commit is contained in:
evgeny committed 2026-10-18 17:19:57 +02:00
1 parent 35685927c0
commit 5bfef9f8ac
2 files changed
+50 -16

No files matched your search

+15 -3
View File
@@ -7,6 +7,7 @@
#include <deque>
extern "C" {
#include "../../../src/stream/stream_media.h"
#include "../../../src/call/call_video_bitstream.h"
#ifdef HAVE_FFMPEG
#include <libavcodec/avcodec.h>
#include <libavcodec/bsf.h>
@@ -86,6 +87,14 @@ AVPixelFormat softwareFormat(const AVCodec* codec, bool hardware = false) {
bool verifiedProfile(const LiveVideoConfig& config, const QList<LiveEncodedFrame>& output) {
if (output.size() != 1 || !output.front().key) return false;
const auto& data = output.front().data;
call_video_format format{1, uint16_t(config.width), uint16_t(config.height), uint16_t(config.fps),
uint16_t(config.rotation), uint8_t(config.codec), uint8_t(config.level), uint32_t(config.bitrate),
uint8_t(config.codec == STREAM_MEDIA_H264 ? CALL_VIDEO_CONSTRAINED_BASELINE : CALL_VIDEO_MAIN)};
if (call_video_check_key(&format, reinterpret_cast<const uint8_t*>(data.constData()), data.size())) {
DEBUG_ERROR(DEBUG_CATEGORY_VIDEO, "live call KEY verification failed codec=%d size=%dx%d level=%d bytes=%lld",
config.codec, config.width, config.height, config.level, (long long)data.size());
return false;
}
const uint8_t *header, *frame; size_t headerSize, frameSize;
if (stream_media_key_parse(reinterpret_cast<const uint8_t*>(data.constData()), data.size(),
&header, &headerSize, &frame, &frameSize) != STREAM_OK) return false;
@@ -284,6 +293,12 @@ bool LiveVideoEncoder::open(const LiveVideoConfig& config, Backend backend) {
return false;
}
verified = {frame};
if (constrained && !verifiedProfile(config, verified)) {
m->error = "Encoder output violates the call bitstream contract";
DEBUG_WARN(DEBUG_CATEGORY_VIDEO, "call GPU probe rejected KEY name=%s pts=%llu attempt=%d",
name.constData(), (unsigned long long)pts, attempt);
return false;
}
if (constrained) DEBUG_DEBUG(DEBUG_CATEGORY_VIDEO,
"call GPU probe name=%s pts=%llu pipeline_frames=%d time_base=%d/%d",
name.constData(), (unsigned long long)pts, attempt, c->time_base.num, c->time_base.den);
@@ -316,9 +331,6 @@ bool LiveVideoEncoder::open(const LiveVideoConfig& config, Backend backend) {
break;
}
}
if (constrained && !verifiedProfile(config, output)) {
m->error = "Encoder output violates the requested profile"; break;
}
continue;
}
DEBUG_INFO(DEBUG_CATEGORY_VIDEO,