Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 1 addition & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
.git* export-ignore
.hooks* export-ignore

*.sh crlf=input
newalpha crlf=input
newversion crlf=input

# Custom attribute to mark sources as using our C code style.
[attr]our-c-style whitespace=tab-in-indent,-blank-at-eol format.clang-format=8
[attr]our-c-style whitespace=tab-in-indent,-blank-at-eol

*.c our-c-style
*.h our-c-style
Expand All @@ -20,7 +19,3 @@ newversion crlf=input
*.cmake whitespace=tab-in-indent,-blank-at-eol

*.md whitespace=tab-in-indent conflict-marker-size=30

[attr]our-lfs filter=lfs diff=lfs merge=lfs -text

Data/** our-lfs
17 changes: 17 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: pre-commit

on:
pull_request:
branches: [wheel]
push:
branches: [wheel]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: pre-commit/action@v3.0.1
8 changes: 0 additions & 8 deletions .hooks-config.bash

This file was deleted.

13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Install: uv tool install pre-commit && pre-commit install
# Run on everything: pre-commit run --all-files
exclude: ^ThirdParty/
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.20
hooks:
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.5
hooks:
- id: clang-format
types_or: [c++, c]
4 changes: 1 addition & 3 deletions Streaming/Encode/vtkVideoEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class VTKSTREAMINGENCODE_EXPORT vtkVideoEncoder : public vtkObject
{
CBR, // MaxBitRate = MinBitRate = BitRate
VBR, // Bitrate may fluctuate within set minimum and maximum.
CQP, // no bitrate control. Set QuantizationParameter
CQP, // no bitrate control. Set QuantizationParameter
QP // Constant Quantization Parameter
};

Expand Down Expand Up @@ -229,7 +229,6 @@ class VTKSTREAMINGENCODE_EXPORT vtkVideoEncoder : public vtkObject
vtkGetMacro(QuantizationParameter, unsigned int);
///@}


///@{
/**
* Set/Get quantization parameter of an encoder.
Expand All @@ -250,7 +249,6 @@ class VTKSTREAMINGENCODE_EXPORT vtkVideoEncoder : public vtkObject
vtkGetMacro(MaxQuantizationParameter, unsigned int);
///@}


///@{
/**
* Set/Get bitrate of an encoder.
Expand Down
5 changes: 2 additions & 3 deletions Streaming/NvEncode/Testing/Cxx/TestNvEncoderGLMapResource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ int TestNvEncoderGLMapResource(int argc, char* argv[])
frame->Capture(renWin);

vtkNew<vtkNvEncoderGL> enc;
enc->SetOutputHandler([&success](VTKVideoEncoderResultType result) {
success = (result.first == VTKVideoProcessingStatusType::VTKVPStatus_Success);
});
enc->SetOutputHandler([&success](VTKVideoEncoderResultType result)
{ success = (result.first == VTKVideoProcessingStatusType::VTKVPStatus_Success); });
enc->SetCodec(VTKVideoCodecType::VTKVC_H264);
enc->SetGraphicsContext(renWin);
enc->SetWidth(w);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,29 @@ int TestNvEncoderGLPushReceiveDisplayIYUV(int argc, char* argv[])
#else
[&bitstream, &frameId, &success]
#endif
(VTKVideoEncoderResultType result) {
bitstream.clear();
for (const auto& packet : result.second)
(VTKVideoEncoderResultType result)
{
bitstream.clear();
for (const auto& packet : result.second)
{
auto data = reinterpret_cast<char*>(packet->GetData()->GetPointer(0));
auto size = packet->GetSize();
vtkLogF(INFO, "Recvd %d bytes", size);
for (int i = 0; i < size; ++i)
{
auto data = reinterpret_cast<char*>(packet->GetData()->GetPointer(0));
auto size = packet->GetSize();
vtkLogF(INFO, "Recvd %d bytes", size);
for (int i = 0; i < size; ++i)
{
bitstream.push_back(data[i]);
}
bitstream.push_back(data[i]);
}
#if WRITE_BITSTREAM
file.write((char*)bitstream.data(), bitstream.size());
file.write((char*)bitstream.data(), bitstream.size());
#endif
if (frameId > 0)
{
assert(bitstream.size() > 10);
success &= bitstream.size() > 10;
}
++frameId;
if (frameId > 0)
{
assert(bitstream.size() > 10);
success &= bitstream.size() > 10;
}
};
++frameId;
}
};

vtkNew<vtkNvEncoderGL> enc;
enc->SetOutputHandler(writeBitstream);
Expand All @@ -130,14 +131,16 @@ int TestNvEncoderGLPushReceiveDisplayIYUV(int argc, char* argv[])

vtkNew<vtkCallbackCommand> exitCallback;
exitCallback->SetClientData(enc);
exitCallback->SetCallback([](vtkObject* iren_ptr, unsigned long, void* enc_ptr, void*) {
// drain needs an opengl context so it can release the resources.
auto encoder = reinterpret_cast<vtkVideoEncoder*>(enc_ptr);
encoder->Drain();
auto iren = reinterpret_cast<vtkRenderWindowInteractor*>(iren_ptr);
encoder->Shutdown();
iren->TerminateApp();
});
exitCallback->SetCallback(
[](vtkObject* iren_ptr, unsigned long, void* enc_ptr, void*)
{
// drain needs an opengl context so it can release the resources.
auto encoder = reinterpret_cast<vtkVideoEncoder*>(enc_ptr);
encoder->Drain();
auto iren = reinterpret_cast<vtkRenderWindowInteractor*>(iren_ptr);
encoder->Shutdown();
iren->TerminateApp();
});
iren->AddObserver(vtkCommand::ExitEvent, exitCallback);

while (true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,29 @@ int TestNvEncoderGLPushReceiveDisplayNV12(int argc, char* argv[])
#else
[&bitstream, &frameId, &success]
#endif
(VTKVideoEncoderResultType result) {
bitstream.clear();
for (const auto& packet : result.second)
(VTKVideoEncoderResultType result)
{
bitstream.clear();
for (const auto& packet : result.second)
{
auto data = reinterpret_cast<char*>(packet->GetData()->GetPointer(0));
auto size = packet->GetSize();
vtkLogF(INFO, "Recvd %d bytes", size);
for (int i = 0; i < size; ++i)
{
auto data = reinterpret_cast<char*>(packet->GetData()->GetPointer(0));
auto size = packet->GetSize();
vtkLogF(INFO, "Recvd %d bytes", size);
for (int i = 0; i < size; ++i)
{
bitstream.push_back(data[i]);
}
bitstream.push_back(data[i]);
}
#if WRITE_BITSTREAM
file.write((char*)bitstream.data(), bitstream.size());
file.write((char*)bitstream.data(), bitstream.size());
#endif
if (frameId > 0)
{
assert(bitstream.size() > 10);
success &= bitstream.size() > 10;
}
++frameId;
if (frameId > 0)
{
assert(bitstream.size() > 10);
success &= bitstream.size() > 10;
}
};
++frameId;
}
};

vtkNew<vtkNvEncoderGL> enc;
enc->SetOutputHandler(writeBitstream);
Expand All @@ -130,14 +131,16 @@ int TestNvEncoderGLPushReceiveDisplayNV12(int argc, char* argv[])

vtkNew<vtkCallbackCommand> exitCallback;
exitCallback->SetClientData(enc);
exitCallback->SetCallback([](vtkObject* iren_ptr, unsigned long, void* enc_ptr, void*) {
// drain needs an opengl context so it can release the resources.
auto encoder = reinterpret_cast<vtkVideoEncoder*>(enc_ptr);
encoder->Drain();
auto iren = reinterpret_cast<vtkRenderWindowInteractor*>(iren_ptr);
encoder->Shutdown();
iren->TerminateApp();
});
exitCallback->SetCallback(
[](vtkObject* iren_ptr, unsigned long, void* enc_ptr, void*)
{
// drain needs an opengl context so it can release the resources.
auto encoder = reinterpret_cast<vtkVideoEncoder*>(enc_ptr);
encoder->Drain();
auto iren = reinterpret_cast<vtkRenderWindowInteractor*>(iren_ptr);
encoder->Shutdown();
iren->TerminateApp();
});
iren->AddObserver(vtkCommand::ExitEvent, exitCallback);

while (true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,29 @@ int TestNvEncoderGLPushReceiveDisplayRGBA32(int argc, char* argv[])
#else
[&bitstream, &frameId, &success]
#endif
(VTKVideoEncoderResultType result) {
bitstream.clear();
for (const auto& packet : result.second)
(VTKVideoEncoderResultType result)
{
bitstream.clear();
for (const auto& packet : result.second)
{
auto data = reinterpret_cast<char*>(packet->GetData()->GetPointer(0));
auto size = packet->GetSize();
vtkLogF(INFO, "Recvd %d bytes", size);
for (int i = 0; i < size; ++i)
{
auto data = reinterpret_cast<char*>(packet->GetData()->GetPointer(0));
auto size = packet->GetSize();
vtkLogF(INFO, "Recvd %d bytes", size);
for (int i = 0; i < size; ++i)
{
bitstream.push_back(data[i]);
}
bitstream.push_back(data[i]);
}
#if WRITE_BITSTREAM
file.write((char*)bitstream.data(), bitstream.size());
file.write((char*)bitstream.data(), bitstream.size());
#endif
if (frameId > 0)
{
assert(bitstream.size() > 10);
success &= bitstream.size() > 10;
}
++frameId;
if (frameId > 0)
{
assert(bitstream.size() > 10);
success &= bitstream.size() > 10;
}
};
++frameId;
}
};

vtkNew<vtkNvEncoderGL> enc;
enc->SetOutputHandler(writeBitstream);
Expand All @@ -130,14 +131,16 @@ int TestNvEncoderGLPushReceiveDisplayRGBA32(int argc, char* argv[])

vtkNew<vtkCallbackCommand> exitCallback;
exitCallback->SetClientData(enc);
exitCallback->SetCallback([](vtkObject* iren_ptr, unsigned long, void* enc_ptr, void*) {
// drain needs an opengl context so it can release the resources.
auto encoder = reinterpret_cast<vtkVideoEncoder*>(enc_ptr);
encoder->Drain();
auto iren = reinterpret_cast<vtkRenderWindowInteractor*>(iren_ptr);
encoder->Shutdown();
iren->TerminateApp();
});
exitCallback->SetCallback(
[](vtkObject* iren_ptr, unsigned long, void* enc_ptr, void*)
{
// drain needs an opengl context so it can release the resources.
auto encoder = reinterpret_cast<vtkVideoEncoder*>(enc_ptr);
encoder->Drain();
auto iren = reinterpret_cast<vtkRenderWindowInteractor*>(iren_ptr);
encoder->Shutdown();
iren->TerminateApp();
});
iren->AddObserver(vtkCommand::ExitEvent, exitCallback);

while (true)
Expand Down
37 changes: 19 additions & 18 deletions Streaming/NvEncode/Testing/Cxx/TestNvEncoderGLPushReceiveIYUV.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,29 @@ int TestNvEncoderGLPushReceiveIYUV(int argc, char* argv[])
#else
[&bitstream, &frameId, &success]
#endif
(VTKVideoEncoderResultType result) {
bitstream.clear();
for (const auto& packet : result.second)
(VTKVideoEncoderResultType result)
{
bitstream.clear();
for (const auto& packet : result.second)
{
auto data = reinterpret_cast<char*>(packet->GetData()->GetPointer(0));
auto size = packet->GetSize();
vtkLogF(INFO, "Recvd %d bytes", size);
for (int i = 0; i < size; ++i)
{
auto data = reinterpret_cast<char*>(packet->GetData()->GetPointer(0));
auto size = packet->GetSize();
vtkLogF(INFO, "Recvd %d bytes", size);
for (int i = 0; i < size; ++i)
{
bitstream.push_back(data[i]);
}
bitstream.push_back(data[i]);
}
#if WRITE_BITSTREAM
file.write((char*)bitstream.data(), bitstream.size());
file.write((char*)bitstream.data(), bitstream.size());
#endif
if (frameId > 0)
{
assert(bitstream.size() > 10);
success &= bitstream.size() > 10;
}
++frameId;
if (frameId > 0)
{
assert(bitstream.size() > 10);
success &= bitstream.size() > 10;
}
};
++frameId;
}
};

vtkNew<vtkNvEncoderGL> enc;
enc->SetOutputHandler(writeBitstream);
Expand Down
Loading
Loading