Release frame data as soon as possible

During a frame swap, one of the two frames involved can be released.
This commit is contained in:
Romain Vimont 2021-02-21 17:29:45 +01:00
parent 386f017ba9
commit eb7e1070cf

View file

@ -100,6 +100,7 @@ video_buffer_producer_offer_frame(struct video_buffer *vb) {
} }
} }
av_frame_unref(vb->pending_frame);
swap_frames(&vb->producer_frame, &vb->pending_frame); swap_frames(&vb->producer_frame, &vb->pending_frame);
bool skipped = !vb->pending_frame_consumed; bool skipped = !vb->pending_frame_consumed;
@ -122,6 +123,7 @@ video_buffer_consumer_take_frame(struct video_buffer *vb) {
vb->pending_frame_consumed = true; vb->pending_frame_consumed = true;
swap_frames(&vb->consumer_frame, &vb->pending_frame); swap_frames(&vb->consumer_frame, &vb->pending_frame);
av_frame_unref(vb->pending_frame);
if (vb->wait_consumer) { if (vb->wait_consumer) {
// unblock video_buffer_offer_decoded_frame() // unblock video_buffer_offer_decoded_frame()