Revert "testcamera: added support for Motion JPEG camera frames"

This reverts commit 5ccee77190.
This commit is contained in:
Sam Lantinga 2025-02-20 01:13:35 -08:00
parent 2e89c53ebc
commit f24f9d3bed
4 changed files with 3 additions and 8014 deletions

View file

@ -165,7 +165,6 @@ def find_symbols_in_file(file: pathlib.Path) -> int:
"include/SDL3",
"build-scripts/gen_audio_resampler_filter.c",
"build-scripts/gen_audio_channel_conversion.c",
"test/stb_image.h",
"test/win32/sdlprocdump.c",
]

View file

@ -392,7 +392,7 @@ add_sdl_test_executable(teststreaming NEEDS_RESOURCES TESTUTILS SOURCES teststre
add_sdl_test_executable(testtimer NONINTERACTIVE NONINTERACTIVE_ARGS --no-interactive NONINTERACTIVE_TIMEOUT 60 SOURCES testtimer.c)
add_sdl_test_executable(testurl SOURCES testurl.c)
add_sdl_test_executable(testver NONINTERACTIVE NOTRACKMEM SOURCES testver.c)
add_sdl_test_executable(testcamera MAIN_CALLBACKS NO_C90 SOURCES testcamera.c)
add_sdl_test_executable(testcamera MAIN_CALLBACKS SOURCES testcamera.c)
add_sdl_test_executable(testclipboard MAIN_CALLBACKS SOURCES testclipboard.c ${icon_bmp_header} DEPENDS generate-icon_bmp_header)
add_sdl_test_executable(testviewport NEEDS_RESOURCES TESTUTILS SOURCES testviewport.c)
add_sdl_test_executable(testwm SOURCES testwm.c)

File diff suppressed because it is too large Load diff

View file

@ -15,12 +15,6 @@
#include <SDL3/SDL_test.h>
#include <SDL3/SDL_test_common.h>
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_JPEG
#define STBI_NO_HDR
#define STBI_NO_LINEAR
#include "stb_image.h"
static SDL_Window *window = NULL;
static SDL_Renderer *renderer = NULL;
static SDLTest_CommonState *state = NULL;
@ -349,11 +343,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
/* Create texture with appropriate format */
SDL_PropertiesID props = SDL_CreateProperties();
if (frame_current->format == SDL_PIXELFORMAT_MJPG) {
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER, SDL_PIXELFORMAT_RGBA32);
} else {
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER, frame_current->format);
}
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER, colorspace);
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER, SDL_TEXTUREACCESS_STREAMING);
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER, frame_current->w);
@ -368,19 +358,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
/* Update SDL_Texture with last video frame (only once per new frame) */
if (frame_current && !texture_updated) {
if (frame_current->format == SDL_PIXELFORMAT_MJPG) {
/* Note: This is very slow if compiled without optimizations */
int w = 0, h = 0, format = 0;
stbi_uc *pixels = stbi_load_from_memory(frame_current->pixels, frame_current->pitch, &w, &h, &format, 4);
if (pixels) {
SDL_UpdateTexture(texture, NULL, pixels, frame_current->w * 4);
stbi_image_free(pixels);
} else {
SDL_Log("Couldn't decode JPEG: %s", stbi_failure_reason());
}
} else {
SDL_UpdateTexture(texture, NULL, frame_current->pixels, frame_current->pitch);
}
texture_updated = true;
}