Cover HEVC PPS flags and incompatible AMF startup output
This commit is contained in:
1 parent
f8827a9466
commit
aedb0e6170
2 files changed
+72
-3
No files matched your search
@@ -23,7 +23,7 @@ static std::map<AVCodecContext*, Pending> contexts;
|
||||
static QByteArray selected;
|
||||
static unsigned opened = 0, software = 0;
|
||||
static int depth = 1;
|
||||
static bool burst = false, badReplacement = false;
|
||||
static bool burst = false, badReplacement = false, badProbe = false;
|
||||
|
||||
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) {
|
||||
@@ -56,6 +56,17 @@ extern "C" int __wrap_avcodec_open2(AVCodecContext* context, const AVCodec* code
|
||||
parameters += QByteArray::number(h264 || selected.endsWith("_qsv") ? context->level : context->level / 3);
|
||||
av_dict_set(options, h264 ? "x264-params" : "x265-params", parameters.constData(), 0);
|
||||
int result = __real_avcodec_open2(context, codec, options);
|
||||
if (result >= 0 && !h264 && selected.endsWith("_amf")) {
|
||||
// AMF разрешает dependent segments в PPS. Первый слайс остаётся независимым, CABAC не меняется.
|
||||
auto* data = context->extradata;
|
||||
for (int i = 0; i + 5 < context->extradata_size; ++i) {
|
||||
if (!data[i] && !data[i + 1] && data[i + 2] == 1 && data[i + 3] == 68) {
|
||||
if (data[i + 5] != 0xc0) return AVERROR_INVALIDDATA;
|
||||
data[i + 5] |= 0x20;
|
||||
if (badProbe) data[i + 4] = 2; // Неподдерживаемый temporal_id: отбрасывается общим call verifier.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result >= 0) contexts[context].serial = ++opened;
|
||||
return result;
|
||||
}
|
||||
@@ -93,12 +104,19 @@ class GpuTest : public QObject {
|
||||
Q_OBJECT
|
||||
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 = false; QVERIFY(contexts.empty()); }
|
||||
void init() { selected.clear(); opened = software = 0; depth = 1; burst = badReplacement = badProbe = false; QVERIFY(contexts.empty()); }
|
||||
void cleanup() { QVERIFY(contexts.empty()); }
|
||||
void gpuOnly() {
|
||||
CallVideoEncoder encoder; call_video_format format{1, 640, 360, 30, 0, 1, 31, 4000000, 2};
|
||||
QVERIFY(!encoder.open(format, 1000000)); QCOMPARE(software, 0u);
|
||||
}
|
||||
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));
|
||||
QVERIFY2(encoder.error().contains("call bitstream contract"), qPrintable(encoder.error()));
|
||||
QCOMPARE(software, 0u);
|
||||
}
|
||||
void pipeline_data() {
|
||||
QTest::addColumn<QByteArray>("backend"); QTest::addColumn<bool>("batch"); QTest::addColumn<bool>("reject");
|
||||
for (auto name : {"h264_nvenc", "hevc_nvenc", "h264_amf", "hevc_amf", "h264_qsv", "hevc_qsv"})
|
||||
|
||||
Reference in new issue
Block a user