Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter NALs globally #1403

Merged
merged 7 commits into from
Jan 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use AMFBufferPtr instead of composing FramePacket
deiteris committed Jan 26, 2023
commit 42bff72444353d7fa5ccb24b453f40b946dea8c9
16 changes: 7 additions & 9 deletions alvr/server/cpp/platform/linux/EncodePipelineAMF.cpp
Original file line number Diff line number Diff line change
@@ -458,23 +458,25 @@ void EncodePipelineAMF::PushFrame(uint64_t targetTimestampNs, bool idr)

bool EncodePipelineAMF::GetEncoded(FramePacket &packet)
{
m_framePacket = {nullptr, 0, 0};
m_frameBuffer = NULL;
if (m_hasQueryTimeout) {
m_pipeline->Run();
} else {
uint32_t timeout = 4 * 1000; // 1 second
while (m_framePacket.data == nullptr && --timeout != 0) {
while (m_frameBuffer == NULL && --timeout != 0) {
std::this_thread::sleep_for(std::chrono::microseconds(250));
m_pipeline->Run();
}
}

if (m_framePacket.data == nullptr) {
if (m_frameBuffer == NULL) {
Error("Timed out waiting for encoder data");
return false;
}

packet = m_framePacket;
packet.data = reinterpret_cast<uint8_t *>(m_frameBuffer->GetNative());
packet.size = static_cast<int>(m_frameBuffer->GetSize());
packet.pts = m_targetTimestampNs;

uint64_t query;
VK_CHECK(vkGetQueryPoolResults(m_render->m_dev, m_queryPool, 0, 1, sizeof(uint64_t), &query, sizeof(uint64_t), VK_QUERY_RESULT_64_BIT));
@@ -498,11 +500,7 @@ void EncodePipelineAMF::SetBitrate(int64_t bitrate)

void EncodePipelineAMF::Receive(amf::AMFDataPtr data)
{
amf::AMFBufferPtr buffer(data); // query for buffer interface

m_framePacket.data = reinterpret_cast<uint8_t *>(buffer->GetNative());
m_framePacket.size = static_cast<int>(buffer->GetSize());
m_framePacket.pts = m_targetTimestampNs;
m_frameBuffer = amf::AMFBufferPtr(data); // query for buffer interface
}

void EncodePipelineAMF::ApplyFrameProperties(const amf::AMFSurfacePtr &surface, bool insertIDR)
2 changes: 1 addition & 1 deletion alvr/server/cpp/platform/linux/EncodePipelineAMF.h
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ class EncodePipelineAMF : public EncodePipeline
int m_bitrateInMBits;

bool m_hasQueryTimeout = false;
FramePacket m_framePacket = {nullptr, 0, 0};
amf::AMFBufferPtr m_frameBuffer;
uint64_t m_targetTimestampNs;
};