From 881f82dd33fe8d13e731bfe04077d3abcd149fa3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 12 Dec 2012 00:43:50 +0100 Subject: vd_lavc: use refcounting Note that if the codec doesn't support DR1, the image has to be copied. There is no other way to guarantee that the image will be valid after decoding the next image. The only important codec that doesn't support DR1 yet is rawvideo. It's likely that ffmpeg/Libav will fix this at some time. For now, this decoder uses an evil hack and puts pointers to the packet data into the returned frame. This means the image will actually get invalid as soon as the corresponding video packet is free'd, so copying the image is the only reasonable thing anyway. --- video/decode/lavc_dr1.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'video/decode/lavc_dr1.c') diff --git a/video/decode/lavc_dr1.c b/video/decode/lavc_dr1.c index 1049b6105a..34aad2e030 100644 --- a/video/decode/lavc_dr1.c +++ b/video/decode/lavc_dr1.c @@ -190,6 +190,11 @@ void mp_buffer_unref(struct FrameBuffer *buf) mp_buffer_pool_free(&pool); } +bool mp_buffer_is_unique(struct FrameBuffer *buf) +{ + return buf->refcount == 1; +} + void mp_codec_release_buffer(AVCodecContext *s, AVFrame *frame) { FrameBuffer *buf = frame->opaque; -- cgit v1.2.3