Huge update - Fixed memory leak, read description

changed frames to unreference instead of allocate and free on the load frame loop, changed frameConvert to use vCodecCtx data, added reinit and dealt with memory leak from it, adjusted the destructor
This commit is contained in:
2025-10-24 02:09:21 +03:00
parent cf8575a5c4
commit c424ec2c65
2 changed files with 58 additions and 36 deletions

View File

@@ -104,6 +104,13 @@ private:
Flags videoFlags;
uint16_t ID = 0;
// Frames
_ffmpeg::AVFrame *frame = _ffmpeg::av_frame_alloc(),
*convertedFrame = _ffmpeg::av_frame_alloc(),
*audioFrame = _ffmpeg::av_frame_alloc(),
*convertedAudioFrame = _ffmpeg::av_frame_alloc();
_ffmpeg::AVPacket *packet = _ffmpeg::av_packet_alloc();
// Time specific
uint32_t currentFrameNumber = 0;
double timeBase = 0, clock = 0;
@@ -132,8 +139,7 @@ private:
std::pair<double, Containers::Array<char>> loadNextFrame();
inline void frameDebug(_ffmpeg::AVFrame *frame);
inline void frameSetScaleSAR(_ffmpeg::AVFrame *frame);
inline void frameConvert(_ffmpeg::AVFrame *sourceFrame,
_ffmpeg::AVFrame *convertedFrame);
inline void frameConvert();
inline void frameFlip(_ffmpeg::AVFrame *frame);
inline void restartVideo();
@@ -142,6 +148,8 @@ private:
void loadTexture(Containers::Array<char> data);
void loadTexture(ImageView2D image);
Image2D loadImage(Containers::Array<char> data);
void reinitSound();
};
inline Video::Flags operator|(Video::Flags x, Video::Flags y) {