fixed memory leak in thumbnail generation
This commit is contained in:
+11
-7
@@ -234,10 +234,6 @@ void PreviewGenerator::invalidate_media(const QString &error_msg)
|
||||
footage_->ready_lock.unlock();
|
||||
}
|
||||
|
||||
void thumb_data_cleanup(void *info) {
|
||||
delete [] static_cast<uint8_t*>(info);
|
||||
}
|
||||
|
||||
void PreviewGenerator::generate_waveform() {
|
||||
SwsContext* sws_ctx;
|
||||
SwrContext* swr_ctx;
|
||||
@@ -340,7 +336,6 @@ void PreviewGenerator::generate_waveform() {
|
||||
if (!s->preview_done) {
|
||||
int dstH = olive::CurrentConfig.thumbnail_resolution;
|
||||
int dstW = qRound(dstH * (float(temp_frame->width)/float(temp_frame->height)));
|
||||
uint8_t* data = new uint8_t[size_t(dstW*dstH*4)];
|
||||
|
||||
sws_ctx = sws_getContext(
|
||||
temp_frame->width,
|
||||
@@ -357,9 +352,18 @@ void PreviewGenerator::generate_waveform() {
|
||||
|
||||
int linesize[AV_NUM_DATA_POINTERS];
|
||||
linesize[0] = dstW*4;
|
||||
sws_scale(sws_ctx, temp_frame->data, temp_frame->linesize, 0, temp_frame->height, &data, linesize);
|
||||
|
||||
s->video_preview = QImage(data, dstW, dstH, linesize[0], QImage::Format_RGBA8888, thumb_data_cleanup);
|
||||
s->video_preview = QImage(dstW, dstH, QImage::Format_RGBA8888);
|
||||
uint8_t* data = s->video_preview.bits();
|
||||
|
||||
sws_scale(sws_ctx,
|
||||
temp_frame->data,
|
||||
temp_frame->linesize,
|
||||
0,
|
||||
temp_frame->height,
|
||||
&data,
|
||||
linesize);
|
||||
|
||||
s->make_square_thumb();
|
||||
|
||||
// is video interlaced?
|
||||
|
||||
Reference in New Issue
Block a user