mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-10 00:22:33 +00:00
testffmpeg: use SDL_test to parse arguments and track memory
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL3/SDL_main.h>
|
#include <SDL3/SDL_main.h>
|
||||||
|
#include <SDL3/SDL_test.h>
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
@@ -765,6 +766,11 @@ static void HandleAudioFrame(AVFrame *frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_usage(SDLTest_CommonState *state, const char *argv0) {
|
||||||
|
static const char *options[] = { "[--sprites N]", "[--software]", "video_file", NULL };
|
||||||
|
SDLTest_CommonLogUsage(state, argv0, options);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char *file = NULL;
|
const char *file = NULL;
|
||||||
@@ -784,24 +790,44 @@ int main(int argc, char *argv[])
|
|||||||
Uint32 window_flags;
|
Uint32 window_flags;
|
||||||
SDL_bool flushing = SDL_FALSE;
|
SDL_bool flushing = SDL_FALSE;
|
||||||
SDL_bool decoded = SDL_FALSE;
|
SDL_bool decoded = SDL_FALSE;
|
||||||
|
SDLTest_CommonState *state;
|
||||||
|
|
||||||
|
/* Initialize test framework */
|
||||||
|
state = SDLTest_CommonCreateState(argv, 0);
|
||||||
|
|
||||||
/* Enable standard application logging */
|
/* Enable standard application logging */
|
||||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||||
|
|
||||||
for (i = 1; i < argc; ++i) {
|
|
||||||
if (SDL_strcmp(argv[i], "--sprites") == 0 && argv[i+1]) {
|
/* Parse commandline */
|
||||||
num_sprites = SDL_atoi(argv[i+1]);
|
for (i = 1; i < argc;) {
|
||||||
++i;
|
int consumed;
|
||||||
} else if (SDL_strcmp(argv[i], "--software") == 0) {
|
|
||||||
software_only = SDL_TRUE;
|
consumed = SDLTest_CommonArg(state, i);
|
||||||
} else {
|
if (!consumed) {
|
||||||
/* We'll try to open this as a media file */
|
if (SDL_strcmp(argv[i], "--sprites") == 0 && argv[i+1]) {
|
||||||
file = argv[i];
|
num_sprites = SDL_atoi(argv[i+1]);
|
||||||
break;
|
consumed = 2;
|
||||||
|
} else if (SDL_strcmp(argv[i], "--software") == 0) {
|
||||||
|
software_only = SDL_TRUE;
|
||||||
|
consumed = 1;
|
||||||
|
} else if (!file) {
|
||||||
|
/* We'll try to open this as a media file */
|
||||||
|
file = argv[i];
|
||||||
|
consumed = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (consumed <= 0) {
|
||||||
|
print_usage(state, argv[0]);
|
||||||
|
return_code = 1;
|
||||||
|
goto quit;
|
||||||
|
}
|
||||||
|
|
||||||
|
i += consumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Usage: %s [--sprites N] video_file\n", argv[0]);
|
print_usage(state, argv[0]);
|
||||||
return_code = 1;
|
return_code = 1;
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
@@ -1022,5 +1048,6 @@ quit:
|
|||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
SDLTest_CommonDestroyState(state);
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user