diff options
author | wm4 <wm4@nowhere> | 2015-07-05 23:56:00 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-07-05 23:56:00 +0200 |
commit | 7b9d72658898574f4b001bcc496bf3532d4b3cc5 (patch) | |
tree | 9feae56717daaf423375a21ff6af29915655b895 /video/decode | |
parent | 34b223d730c97225accae4107a032c9b7ebf2194 (diff) | |
download | mpv-7b9d72658898574f4b001bcc496bf3532d4b3cc5.tar.bz2 mpv-7b9d72658898574f4b001bcc496bf3532d4b3cc5.tar.xz |
video: replace our own refcounting with libavutil's
mpv had refcounted frames before libav*, so we were not using
libavutil's facilities. Change this and drop our own code.
Since AVFrames are not actually refcounted, and only the image data
they reference, the semantics change a bit. This affects mainly
mp_image_pool, which was operating on whole images instead of buffers.
While we could work on AVBufferRefs instead (and use AVBufferPool),
this doesn't work for use with hardware decoding, which doesn't
map cleanly to FFmpeg's reference counting. But it worked out. One
weird consequence is that we still need our custom image data
allocation function (for normal image data), because AVFrame's uses
multiple buffers.
There also seems to be a timing-dependent problem with vaapi (the
pool appears to be "leaking" surfaces). I don't know if this is a new
problem, or whether the code changes just happened to cause it more
often. Raising the number of reserved surfaces seemed to fix it, but
since it appears to be timing dependent, and I couldn't find anything
wrong with the code, I'm just going to assume it's not a new bug.
Diffstat (limited to 'video/decode')
-rw-r--r-- | video/decode/vd_lavc.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 8320001e6b..125141b298 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -547,12 +547,6 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx, return AV_PIX_FMT_NONE; } -static void free_mpi(void *opaque, uint8_t *data) -{ - struct mp_image *mpi = opaque; - talloc_free(mpi); -} - static int get_buffer2_hwdec(AVCodecContext *avctx, AVFrame *pic, int flags) { struct dec_video *vd = avctx->opaque; @@ -591,9 +585,12 @@ static int get_buffer2_hwdec(AVCodecContext *avctx, AVFrame *pic, int flags) if (!mpi) return -1; - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { pic->data[i] = mpi->planes[i]; - pic->buf[0] = av_buffer_create(NULL, 0, free_mpi, mpi, 0); + pic->buf[i] = mpi->bufs[i]; + mpi->bufs[i] = NULL; + } + talloc_free(mpi); return 0; } |