fix not considering the first camera spec
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Has been cancelled
ContinuousDelivery / windows (push) Has been cancelled
ContinuousDelivery / windows-asan (push) Has been cancelled
ContinuousDelivery / dumpsyms (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
ContinuousIntegration / linux (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled

deprio mjpeg hard (its broken on the current sdl release)
This commit is contained in:
Green Sky 2025-03-28 19:36:00 +01:00
parent a11581c836
commit 34fbf05fb3
No known key found for this signature in database
GPG Key ID: DBE05085D874AB4A
3 changed files with 16 additions and 3 deletions

View File

@ -50,12 +50,19 @@ std::shared_ptr<FrameStream2I<SDLVideoFrame>> SDLVideo2InputDevice::subscribe(vo
// choose a good spec, large res but <= 1080p
int speccount {0};
SDL_CameraSpec** specs = SDL_GetCameraSupportedFormats(_dev, &speccount);
if (specs != nullptr) {
if (specs != nullptr && speccount > 0) {
spec = *specs[speccount-1]; // start with last, as its usually the smallest
for (int spec_i = 1; spec_i < speccount; spec_i++) {
for (int spec_i = 0; spec_i < speccount; spec_i++) {
if (specs[spec_i]->height > 1080) {
continue;
}
if (spec.format == SDL_PIXELFORMAT_MJPG && spec.format != specs[spec_i]->format) {
// we hard prefer anything else over mjpg
spec = *specs[spec_i];
continue;
}
if (spec.height > specs[spec_i]->height) {
continue;
}
@ -67,14 +74,17 @@ std::shared_ptr<FrameStream2I<SDLVideoFrame>> SDLVideo2InputDevice::subscribe(vo
continue;
}
// HACK: prefer nv12 over yuy2, SDL has sse2 optimized conversion for our usecase
if (spec.format == SDL_PIXELFORMAT_NV12 && specs[spec_i]->format == SDL_PIXELFORMAT_YUY2) {
// HACK: prefer nv12 over yuy2
continue;
}
// seems to be better
spec = *specs[spec_i];
}
}
if (specs != nullptr) {
SDL_free(specs);
}

View File

@ -5,6 +5,7 @@
#include <SDL3/SDL.h>
#include <cstdint>
#include <cassert>
#include <memory>
// https://youtu.be/71Iw4Q74OaE
@ -36,6 +37,7 @@ struct SDLVideoFrame {
SDL_DuplicateSurface(other.surface.get()),
&SDL_DestroySurface
};
assert(surface);
}
}
SDLVideoFrame& operator=(const SDLVideoFrame& other) = delete;

View File

@ -18,6 +18,7 @@ struct PushConversionVideoStream : public RealStream {
~PushConversionVideoStream(void) {}
bool push(const SDLVideoFrame& value) override {
assert(value.surface);
SDL_Surface* surf = value.surface.get();
if (surf->format != _forced_format) {
//std::cerr << "PCVS: need to convert from " << SDL_GetPixelFormatName(surf->format) << " to " << SDL_GetPixelFormatName(_forced_format) << "\n";