shared/media-playback: Unref sw_frame before reuse

By not performing an unref on sw_frame before using it again, a memory
"leak" was being created if the frame had side data. This removes a
previously-added check that optionally unrefs sw_frame, and just does
it every tick.

Co-authored-by: pkviet <pkv@obsproject.com>
This commit is contained in:
tt2468
2024-08-03 16:31:02 -07:00
committed by Lain
co-authored by pkviet
parent 19abab097d
commit 7b2a6351b0
+1 -10
View File
@@ -337,16 +337,7 @@ static int decode_packet(struct mp_decode *d, int *got_frame)
return ret;
}
/* does not check for color format or other parameter changes which would require frame buffer realloc */
if (d->sw_frame->data[0] &&
(d->sw_frame->width != d->hw_frame->width ||
d->sw_frame->height != d->hw_frame->height)) {
blog(LOG_DEBUG,
"MP: hardware frame size changed from %dx%d to %dx%d. reallocating frame",
d->sw_frame->width, d->sw_frame->height,
d->hw_frame->width, d->hw_frame->height);
av_frame_unref(d->sw_frame);
}
av_frame_unref(d->sw_frame);
int err = av_hwframe_transfer_data(d->sw_frame, d->hw_frame, 0);
if (err == 0) {