Allocate the temp frame inside Assign, instead of keeping it around.

This commit is contained in:
Isaac Connor
2026-01-22 20:54:00 -05:00
parent 8d8a1dfdfb
commit bef2ea5b9e
2 changed files with 9 additions and 9 deletions

View File

@@ -348,11 +348,6 @@ bool Image::Assign(const AVFrame *frame) {
// Desired format
AVPixelFormat format = (AVPixelFormat)AVPixFormat();
av_frame_ptr dest_frame{av_frame_alloc()};
if (!dest_frame) {
Error("Unable to allocate destination frame");
return false;
}
sws_convert_context = sws_getCachedContext(
sws_convert_context,
frame->width, frame->height, (AVPixelFormat)frame->format,
@@ -364,13 +359,18 @@ bool Image::Assign(const AVFrame *frame) {
Error("Unable to create conversion context");
return false;
}
bool result = Assign(frame, sws_convert_context, dest_frame.get());
bool result = Assign(frame, sws_convert_context);
update_function_pointers();
return result;
} // end Image::Assign(const AVFrame *frame)
bool Image::Assign(const AVFrame *frame, SwsContext *convert_context, AVFrame *temp_frame) {
PopulateFrame(temp_frame);
bool Image::Assign(const AVFrame *frame, SwsContext *convert_context) {
av_frame_ptr temp_frame{av_frame_alloc()};
if (!temp_frame) {
Error("Unable to allocate destination frame");
return false;
}
PopulateFrame(temp_frame.get());
zm_dump_video_frame(frame, "source frame before convert");
temp_frame->pts = frame->pts;

View File

@@ -206,7 +206,7 @@ class Image {
const size_t buffer_size);
void Assign(const Image &image);
bool Assign(const AVFrame *frame);
bool Assign(const AVFrame *frame, SwsContext *convert_context, AVFrame *temp_frame);
bool Assign(const AVFrame *frame, SwsContext *convert_context);
void AssignDirect(
const unsigned int p_width,
const unsigned int p_height,