refactor: video player code to video.c

This commit is contained in:
2026-05-26 12:19:25 +05:30
parent c96c361973
commit 433ccfb0fe
4 changed files with 241 additions and 224 deletions

34
src/video.h Normal file
View File

@@ -0,0 +1,34 @@
#ifndef VIDEO_H
#define VIDEO_H
#include <SDL2/SDL.h>
#include <stdbool.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
typedef struct VideoPlayer
{
AVFormatContext *format_ctx;
AVCodecContext *codec_ctx;
struct SwsContext *sws_ctx;
AVFrame *frame;
AVFrame *rgba_frame;
uint8_t *rgba_buffer;
int rgba_buffer_size;
int stream_index;
int width;
int height;
int frame_delay_ms;
Uint32 next_frame_tick;
SDL_Texture *texture;
} VideoPlayer;
bool has_video_extension(const char *path);
bool init_video_player(VideoPlayer *player, SDL_Renderer *renderer, const char *path);
void cleanup_video_player(VideoPlayer *player);
bool decode_next_frame(VideoPlayer *player);
#endif // VIDEO_H