diff options
author | wm4 <wm4@nowhere> | 2012-12-11 18:27:34 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-01-13 17:39:32 +0100 |
commit | a8e69707f71f334daa4cfa461d88db9bc8e7fc7c (patch) | |
tree | c01b3b8f5cd4a8679f0948e4dca2e519c8e7665b /video/decode/vd_lavc.c | |
parent | 58d196c07e4faae0e9e7c03c64029c5c36e03c9a (diff) | |
download | mpv-a8e69707f71f334daa4cfa461d88db9bc8e7fc7c.tar.bz2 mpv-a8e69707f71f334daa4cfa461d88db9bc8e7fc7c.tar.xz |
vd_lavc: add DR1 support
Replace libavcodec's native buffer allocation with code taken from
ffplay/ffmpeg's libavfilter support. The code in lavc_dr1.c is directly
copied from cmdutils.c. Note that this is quite arcane code, which
contains some workarounds for decoder bugs and the like. This is not
really a maintainance burden, since fixes from ffmpeg can be directly
applied to the code in lavc_dr1.c.
It's unknown why libavcodec doesn't provide such a function directly.
avcodec_default_get_buffer() can't be reused for various reasons.
There's some hope that the work known as The Evil Plan [1] will make
custom get_buffer implementations unneeded.
The DR1 support as of this commit does nothing. A future commit will
use it to implement ref-counting for mp_image (similar to how AVFrame
will be ref-counted with The Evil Plan.)
[1] http://lists.libav.org/pipermail/libav-devel/2012-December/039781.html
Diffstat (limited to 'video/decode/vd_lavc.c')
-rw-r--r-- | video/decode/vd_lavc.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 5c25b1fff3..ba015b0ad6 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -58,32 +58,12 @@ static const vd_info_t info = { }; #include "libavcodec/avcodec.h" +#include "lavc.h" #if AVPALETTE_SIZE > 1024 #error palette too large, adapt libmpcodecs/vf.c:vf_get_image #endif -#define MAX_NUM_MPI 50 - -typedef struct { - AVCodecContext *avctx; - AVFrame *pic; - struct mp_image export_mpi; - struct mp_image hwdec_mpi[MAX_NUM_MPI]; - struct hwdec *hwdec; - enum PixelFormat pix_fmt; - int do_dr1; - int vo_initialized; - int best_csp; - int qp_stat[32]; - double qp_sum; - double inv_qp_sum; - AVRational last_sample_aspect_ratio; - enum AVDiscard skip_frame; - int rawvideo_fmt; - AVCodec *software_fallback; -} vd_ffmpeg_ctx; - #include "core/m_option.h" static int init_avctx(sh_video_t *sh, AVCodec *lavc_codec, struct hwdec *hwdec); @@ -350,6 +330,9 @@ static int init_avctx(sh_video_t *sh, AVCodec *lavc_codec, struct hwdec *hwdec) avctx->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD; } + } else { + avctx->get_buffer = mp_codec_get_buffer; + avctx->release_buffer = mp_codec_release_buffer; } if (avctx->thread_count == 0) { @@ -492,6 +475,7 @@ static void uninit_avctx(sh_video_t *sh) av_freep(&avctx); avcodec_free_frame(&ctx->pic); + mp_buffer_pool_free(&ctx->dr1_buffer_pool); } static void uninit(sh_video_t *sh) |