diff options
author | Alexis Ballier <aballier@gentoo.org> | 2013-08-01 13:14:42 -0700 |
---|---|---|
committer | Alexis Ballier <aballier@gentoo.org> | 2013-08-01 13:14:42 -0700 |
commit | da4921e697e209f07f392ae2429d67fe464dcef4 (patch) | |
tree | 19705a383ca83b63c2ae4508eec263613cefd051 | |
parent | 99eb03e24bd4e416528cbb18ce610c5dfebe711c (diff) | |
parent | b03b7b7c18bcc08570889652541c9d3071e5edad (diff) |
Merge pull request #3013 from aballier/avfilter_deprec
Modernize libavfilter usage
-rw-r--r-- | lib/DllAvFilter.h | 123 | ||||
-rw-r--r-- | lib/DllAvUtil.h | 35 | ||||
-rw-r--r-- | xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 62 | ||||
-rw-r--r-- | xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h | 4 |
4 files changed, 189 insertions, 35 deletions
diff --git a/lib/DllAvFilter.h b/lib/DllAvFilter.h index 0c38351a7a..4d5aeda58b 100644 --- a/lib/DllAvFilter.h +++ b/lib/DllAvFilter.h @@ -42,14 +42,20 @@ extern "C" { #endif #if (defined USE_EXTERNAL_FFMPEG) + #include <libavfilter/avfilter.h> #include <libavfilter/avfiltergraph.h> #include <libavfilter/buffersink.h> +#if LIBAVFILTER_VERSION_MICRO >= 100 && LIBAVFILTER_VERSION_INT < AV_VERSION_INT(3,43,100) #include <libavfilter/avcodec.h> +#endif #include <libavfilter/buffersrc.h> #else + #include "libavfilter/avfilter.h" #include "libavfilter/avfiltergraph.h" #include "libavfilter/buffersink.h" +#if LIBAVFILTER_VERSION_MICRO >= 100 && LIBAVFILTER_VERSION_INT < AV_VERSION_INT(3,43,100) #include "libavfilter/avcodec.h" +#endif #include "libavfilter/buffersrc.h" #endif } @@ -60,6 +66,18 @@ extern "C" { #define LIBAVFILTER_FROM_LIBAV #endif +#if ( defined(LIBAVFILTER_FROM_FFMPEG) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,43,100)) || \ + ( defined(LIBAVFILTER_FROM_LIBAV) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,5,0)) +#define LIBAVFILTER_AVFRAME_BASED +#endif + +#if ( defined(LIBAVFILTER_FROM_FFMPEG) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,78,100) ) + #define HAVE_AVFILTER_GRAPH_PARSE_PTR +#elif defined(LIBAVFILTER_FROM_LIBAV) + #define AVFILTER_GRAPH_PARSE_TAKES_SINGLE_PTR_ARG +#else + #define AVFILTER_GRAPH_PARSE_TAKES_PTR_PTR_ARG +#endif #include "threads/SingleLock.h" @@ -67,7 +85,6 @@ class DllAvFilterInterface { public: virtual ~DllAvFilterInterface() {} - virtual int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)=0; virtual void avfilter_free(AVFilterContext *filter)=0; virtual void avfilter_graph_free(AVFilterGraph **graph)=0; virtual int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)=0; @@ -75,21 +92,33 @@ public: virtual AVFilterGraph *avfilter_graph_alloc(void)=0; virtual AVFilterInOut *avfilter_inout_alloc()=0; virtual void avfilter_inout_free(AVFilterInOut **inout)=0; +#if defined(HAVE_AVFILTER_GRAPH_PARSE_PTR) + virtual int avfilter_graph_parse_ptr(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)=0; +#elif defined(AVFILTER_GRAPH_PARSE_TAKES_PTR_PTR_ARG) virtual int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)=0; +#else + virtual int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut *inputs, AVFilterInOut *outputs, void *log_ctx)=0; +#endif virtual int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)=0; #if (defined(LIBAVFILTER_FROM_LIBAV) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,5,0)) || \ (defined(LIBAVFILTER_FROM_FFMPEG) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,43,100)) virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame *frame)=0; -#elif defined(LIBAVFILTER_FROM_FFMPEG) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,72,105) - virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags)=0; #else - virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags)=0; + virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags)=0; #endif +#if !defined(LIBAVFILTER_AVFRAME_BASED) virtual void avfilter_unref_buffer(AVFilterBufferRef *ref)=0; +#endif virtual int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)=0; +#if defined(LIBAVFILTER_AVFRAME_BASED) + virtual int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame) = 0; +#else virtual int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, AVFilterBufferRef **bufref, int flags)=0; +#endif virtual AVBufferSinkParams *av_buffersink_params_alloc()=0; +#if !defined(LIBAVFILTER_AVFRAME_BASED) virtual int av_buffersink_poll_frame(AVFilterContext *ctx)=0; +#endif }; #if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) @@ -98,11 +127,6 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface { public: virtual ~DllAvFilter() {} - virtual int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name) - { - CSingleLock lock(DllAvCodec::m_critSection); - return ::avfilter_open(filter_ctx, filter, inst_name); - } virtual void avfilter_free(AVFilterContext *filter) { CSingleLock lock(DllAvCodec::m_critSection); @@ -131,11 +155,25 @@ public: CSingleLock lock(DllAvCodec::m_critSection); ::avfilter_inout_free(inout); } +#if defined(HAVE_AVFILTER_GRAPH_PARSE_PTR) + virtual int avfilter_graph_parse_ptr(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx) + { + CSingleLock lock(DllAvCodec::m_critSection); + return ::avfilter_graph_parse_ptr(graph, filters, inputs, outputs, log_ctx); + } +#elif defined(AVFILTER_GRAPH_PARSE_TAKES_PTR_PTR_ARG) virtual int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx) { CSingleLock lock(DllAvCodec::m_critSection); return ::avfilter_graph_parse(graph, filters, inputs, outputs, log_ctx); } +#else + virtual int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut *inputs, AVFilterInOut *outputs, void *log_ctx) + { + CSingleLock lock(DllAvCodec::m_critSection); + return ::avfilter_graph_parse(graph, filters, inputs, outputs, log_ctx); + } +#endif virtual int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx) { return ::avfilter_graph_config(graphctx, log_ctx); @@ -143,16 +181,22 @@ public: #if (defined(LIBAVFILTER_FROM_LIBAV) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,5,0)) || \ (defined(LIBAVFILTER_FROM_FFMPEG) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,43,100)) virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame* frame) { return ::av_buffersrc_add_frame(buffer_filter, frame); } -#elif defined(LIBAVFILTER_FROM_FFMPEG) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,72,105) - virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame* frame, int flags) { return ::av_buffersrc_add_frame(buffer_filter, frame, flags); } #else - virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, flags); } + virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame* frame, int flags) { return ::av_buffersrc_add_frame(buffer_filter, frame, flags); } #endif +#if !defined(LIBAVFILTER_AVFRAME_BASED) virtual void avfilter_unref_buffer(AVFilterBufferRef *ref) { ::avfilter_unref_buffer(ref); } +#endif virtual int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad) { return ::avfilter_link(src, srcpad, dst, dstpad); } +#if defined(LIBAVFILTER_AVFRAME_BASED) + virtual int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame) { return ::av_buffersink_get_frame(ctx, frame); } +#else virtual int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, AVFilterBufferRef **bufref, int flags) { return ::av_buffersink_get_buffer_ref(buffer_sink, bufref, flags); } +#endif virtual AVBufferSinkParams *av_buffersink_params_alloc() { return ::av_buffersink_params_alloc(); } +#if !defined(LIBAVFILTER_AVFRAME_BASED) virtual int av_buffersink_poll_frame(AVFilterContext *ctx) { return ::av_buffersink_poll_frame(ctx); } +#endif // DLL faking. virtual bool ResolveExports() { return true; } virtual bool Load() { @@ -170,7 +214,6 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface LOAD_SYMBOLS() - DEFINE_METHOD3(int, avfilter_open_dont_call, (AVFilterContext **p1, AVFilter *p2, const char *p3)) DEFINE_METHOD1(void, avfilter_free_dont_call, (AVFilterContext *p1)) DEFINE_METHOD1(void, avfilter_graph_free_dont_call, (AVFilterGraph **p1)) DEFINE_METHOD0(void, avfilter_register_all_dont_call) @@ -179,24 +222,35 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface DEFINE_METHOD0(AVFilterGraph*, avfilter_graph_alloc) DEFINE_METHOD0(AVFilterInOut*, avfilter_inout_alloc_dont_call) DEFINE_METHOD1(void, avfilter_inout_free_dont_call, (AVFilterInOut **p1)) +#if defined(HAVE_AVFILTER_GRAPH_PARSE_PTR) + DEFINE_FUNC_ALIGNED5(int, __cdecl, avfilter_graph_parse_ptr_dont_call, AVFilterGraph *, const char *, AVFilterInOut **, AVFilterInOut **, void *) +#elif defined(AVFILTER_GRAPH_PARSE_TAKES_PTR_PTR_ARG) DEFINE_FUNC_ALIGNED5(int, __cdecl, avfilter_graph_parse_dont_call, AVFilterGraph *, const char *, AVFilterInOut **, AVFilterInOut **, void *) +#else + DEFINE_FUNC_ALIGNED5(int, __cdecl, avfilter_graph_parse_dont_call, AVFilterGraph *, const char *, AVFilterInOut *, AVFilterInOut *, void *) +#endif DEFINE_FUNC_ALIGNED2(int, __cdecl, avfilter_graph_config_dont_call, AVFilterGraph *, void *) #if (defined(LIBAVFILTER_FROM_LIBAV) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,5,0)) || \ (defined(LIBAVFILTER_FROM_FFMPEG) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,43,100)) DEFINE_METHOD2(int, av_buffersrc_add_frame, (AVFilterContext *p1, AVFrame *p2)) -#elif defined(LIBAVFILTER_FROM_FFMPEG) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,72,105) - DEFINE_METHOD3(int, av_buffersrc_add_frame, (AVFilterContext *p1, AVFrame *p2, int p3)) #else - DEFINE_METHOD3(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int p3)) + DEFINE_METHOD3(int, av_buffersrc_add_frame, (AVFilterContext *p1, AVFrame *p2, int p3)) #endif +#if !defined(LIBAVFILTER_AVFRAME_BASED) DEFINE_METHOD1(void, avfilter_unref_buffer, (AVFilterBufferRef *p1)) +#endif DEFINE_METHOD4(int, avfilter_link, (AVFilterContext *p1, unsigned p2, AVFilterContext *p3, unsigned p4)) +#if defined(LIBAVFILTER_AVFRAME_BASED) + DEFINE_FUNC_ALIGNED2(int , __cdecl, av_buffersink_get_frame, AVFilterContext *, AVFrame *); +#else DEFINE_FUNC_ALIGNED3(int , __cdecl, av_buffersink_get_buffer_ref, AVFilterContext *, AVFilterBufferRef **, int); +#endif DEFINE_FUNC_ALIGNED0(AVBufferSinkParams*, __cdecl, av_buffersink_params_alloc); +#if !defined(LIBAVFILTER_AVFRAME_BASED) DEFINE_FUNC_ALIGNED1(int , __cdecl, av_buffersink_poll_frame, AVFilterContext *); +#endif BEGIN_METHOD_RESOLVE() - RESOLVE_METHOD_RENAME(avfilter_open, avfilter_open_dont_call) RESOLVE_METHOD_RENAME(avfilter_free, avfilter_free_dont_call) RESOLVE_METHOD_RENAME(avfilter_graph_free, avfilter_graph_free_dont_call) RESOLVE_METHOD_RENAME(avfilter_register_all, avfilter_register_all_dont_call) @@ -205,18 +259,26 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface RESOLVE_METHOD(avfilter_graph_alloc) RESOLVE_METHOD_RENAME(avfilter_inout_alloc, avfilter_inout_alloc_dont_call) RESOLVE_METHOD_RENAME(avfilter_inout_free, avfilter_inout_free_dont_call) +#if defined(HAVE_AVFILTER_GRAPH_PARSE_PTR) + RESOLVE_METHOD_RENAME(avfilter_graph_parse_ptr, avfilter_graph_parse_ptr_dont_call) +#else RESOLVE_METHOD_RENAME(avfilter_graph_parse, avfilter_graph_parse_dont_call) +#endif RESOLVE_METHOD_RENAME(avfilter_graph_config, avfilter_graph_config_dont_call) -#if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(3,0,0) - RESOLVE_METHOD(av_vsrc_buffer_add_frame) -#else RESOLVE_METHOD(av_buffersrc_add_frame) -#endif +#if !defined(LIBAVFILTER_AVFRAME_BASED) RESOLVE_METHOD(avfilter_unref_buffer) +#endif RESOLVE_METHOD(avfilter_link) +#if defined(LIBAVFILTER_AVFRAME_BASED) + RESOLVE_METHOD(av_buffersink_get_frame) +#else RESOLVE_METHOD(av_buffersink_get_buffer_ref) +#endif RESOLVE_METHOD(av_buffersink_params_alloc) +#if !defined(LIBAVFILTER_AVFRAME_BASED) RESOLVE_METHOD(av_buffersink_poll_frame) +#endif END_METHOD_RESOLVE() /* dependencies of libavfilter */ @@ -225,11 +287,6 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface DllAvFormat m_dllAvFormat; public: - int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name) - { - CSingleLock lock(DllAvCodec::m_critSection); - return avfilter_open_dont_call(filter_ctx, filter, inst_name); - } void avfilter_free(AVFilterContext *filter) { CSingleLock lock(DllAvCodec::m_critSection); @@ -250,11 +307,25 @@ public: CSingleLock lock(DllAvCodec::m_critSection); return avfilter_inout_alloc_dont_call(); } +#if defined(HAVE_AVFILTER_GRAPH_PARSE_PTR) + int avfilter_graph_parse_ptr(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx) + { + CSingleLock lock(DllAvCodec::m_critSection); + return avfilter_graph_parse_ptr_dont_call(graph, filters, inputs, outputs, log_ctx); + } +#elif defined(AVFILTER_GRAPH_PARSE_TAKES_PTR_PTR_ARG) int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx) { CSingleLock lock(DllAvCodec::m_critSection); return avfilter_graph_parse_dont_call(graph, filters, inputs, outputs, log_ctx); } +#else + int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut *inputs, AVFilterInOut *outputs, void *log_ctx) + { + CSingleLock lock(DllAvCodec::m_critSection); + return avfilter_graph_parse_dont_call(graph, filters, inputs, outputs, log_ctx); + } +#endif void avfilter_inout_free(AVFilterInOut **inout) { CSingleLock lock(DllAvCodec::m_critSection); diff --git a/lib/DllAvUtil.h b/lib/DllAvUtil.h index 937ba9ea4c..3181f5beb5 100644 --- a/lib/DllAvUtil.h +++ b/lib/DllAvUtil.h @@ -59,6 +59,17 @@ extern "C" { #endif } +#if LIBAVUTIL_VERSION_MICRO >= 100 + #define LIBAVUTIL_FROM_FFMPEG +#else + #define LIBAVUTIL_FROM_LIBAV +#endif + +#if (defined LIBAVUTIL_FROM_FFMPEG && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(52,29,100)) || \ + (defined LIBAVUTIL_FROM_LIBAV && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(52,8,0)) +#define AVFRAME_IN_LAVU +#endif + #ifndef __GNUC__ #pragma warning(pop) #endif @@ -102,6 +113,12 @@ public: virtual int av_get_channel_layout_channel_index (uint64_t channel_layout, uint64_t channel) = 0; virtual int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0; virtual int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt) = 0; +#if defined(AVFRAME_IN_LAVU) + virtual void av_frame_free(AVFrame **frame)=0; + virtual AVFrame *av_frame_alloc(void)=0; + virtual void av_frame_unref(AVFrame *frame)=0; + virtual void av_frame_move_ref(AVFrame *dst, AVFrame *src)=0; +#endif }; #if defined (USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) @@ -150,6 +167,12 @@ public: { return ::av_samples_fill_arrays(audio_data, linesize, buf, nb_channels, nb_samples, AVSampleFormat sample_fmt, align); } virtual int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt) { return ::av_samples_copy(dst, src, dst_offset, src_offset, nb_samples, nb_channels, sample_fmt); } +#if defined(AVFRAME_IN_LAVU) + virtual void av_frame_free(AVFrame **frame) { return ::av_frame_free(frame); } + virtual AVFrame *av_frame_alloc() { return ::av_frame_alloc(); } + virtual void av_frame_unref(AVFrame *frame) { return ::av_frame_unref(frame); } + virtual void av_frame_move_ref(AVFrame *dst, AVFrame *src) { return ::av_frame_move_ref(dst,src); } +#endif // DLL faking. virtual bool ResolveExports() { return true; } @@ -202,6 +225,12 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface DEFINE_METHOD2(int, av_get_channel_layout_channel_index, (uint64_t p1, uint64_t p2)) DEFINE_METHOD7(int, av_samples_fill_arrays, (uint8_t **p1, int *p2, const uint8_t *p3, int p4, int p5, enum AVSampleFormat p6, int p7)) DEFINE_METHOD7(int, av_samples_copy, (uint8_t **p1, uint8_t *const *p2, int p3, int p4, int p5, int p6, enum AVSampleFormat p7)) +#if defined(AVFRAME_IN_LAVU) + DEFINE_METHOD1(void, av_frame_free, (AVFrame **p1)) + DEFINE_METHOD0(AVFrame *, av_frame_alloc) + DEFINE_METHOD1(void, av_frame_unref, (AVFrame *p1)) + DEFINE_METHOD2(void, av_frame_move_ref, (AVFrame *p1, AVFrame* p2)) +#endif public: BEGIN_METHOD_RESOLVE() @@ -237,6 +266,12 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface RESOLVE_METHOD(av_get_channel_layout_channel_index) RESOLVE_METHOD(av_samples_fill_arrays) RESOLVE_METHOD(av_samples_copy) +#if defined(AVFRAME_IN_LAVU) + RESOLVE_METHOD(av_frame_free) + RESOLVE_METHOD(av_frame_alloc) + RESOLVE_METHOD(av_frame_unref) + RESOLVE_METHOD(av_frame_move_ref) +#endif END_METHOD_RESOLVE() }; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp index 5820dfebeb..12bad2719d 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp @@ -147,7 +147,11 @@ CDVDVideoCodecFFmpeg::CDVDVideoCodecFFmpeg() : CDVDVideoCodec() m_pFilterGraph = NULL; m_pFilterIn = NULL; m_pFilterOut = NULL; +#if defined(LIBAVFILTER_AVFRAME_BASED) + m_pFilterFrame = NULL; +#else m_pBufferRef = NULL; +#endif m_iPictureWidth = 0; m_iPictureHeight = 0; @@ -305,6 +309,11 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options m_pFrame = m_dllAvCodec.avcodec_alloc_frame(); if (!m_pFrame) return false; +#if defined(LIBAVFILTER_AVFRAME_BASED) + m_pFilterFrame = m_dllAvUtil.av_frame_alloc(); + if (!m_pFilterFrame) return false; +#endif + UpdateName(); return true; } @@ -314,6 +323,10 @@ void CDVDVideoCodecFFmpeg::Dispose() if (m_pFrame) m_dllAvUtil.av_free(m_pFrame); m_pFrame = NULL; +#if defined(LIBAVFILTER_AVFRAME_BASED) + m_dllAvUtil.av_frame_free(&m_pFilterFrame); +#endif + if (m_pCodecContext) { if (m_pCodecContext->codec) m_dllAvCodec.avcodec_close(m_pCodecContext); @@ -553,14 +566,16 @@ void CDVDVideoCodecFFmpeg::Reset() bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture) { - pDvdVideoPicture->iWidth = m_pCodecContext->width; - pDvdVideoPicture->iHeight = m_pCodecContext->height; + pDvdVideoPicture->iWidth = m_pFrame->width; + pDvdVideoPicture->iHeight = m_pFrame->height; +#if !defined(LIBAVFILTER_AVFRAME_BASED) if(m_pBufferRef) { pDvdVideoPicture->iWidth = m_pBufferRef->video->w; pDvdVideoPicture->iHeight = m_pBufferRef->video->h; } +#endif /* crop of 10 pixels if demuxer asked it */ if(m_pCodecContext->coded_width && m_pCodecContext->coded_width < (int)pDvdVideoPicture->iWidth @@ -574,13 +589,15 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture) double aspect_ratio; /* use variable in the frame */ - AVRational pixel_aspect = m_pCodecContext->sample_aspect_ratio; + AVRational pixel_aspect = m_pFrame->sample_aspect_ratio; +#if !defined(LIBAVFILTER_AVFRAME_BASED) if (m_pBufferRef) #if defined(LIBAVFILTER_FROM_FFMPEG) pixel_aspect = m_pBufferRef->video->sample_aspect_ratio; #else pixel_aspect = m_pBufferRef->video->pixel_aspect; #endif +#endif if (pixel_aspect.num == 0) aspect_ratio = 0; @@ -675,10 +692,12 @@ bool CDVDVideoCodecFFmpeg::GetPicture(DVDVideoPicture* pDvdVideoPicture) pDvdVideoPicture->extended_format = 0; PixelFormat pix_fmt; +#if !defined(LIBAVFILTER_AVFRAME_BASED) if(m_pBufferRef) pix_fmt = (PixelFormat)m_pBufferRef->format; else - pix_fmt = m_pCodecContext->pix_fmt; +#endif + pix_fmt = (PixelFormat)m_pFrame->format; pDvdVideoPicture->format = CDVDCodecUtils::EFormatFromPixfmt(pix_fmt); return true; @@ -756,7 +775,13 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters, bool scale) inputs->pad_idx = 0; inputs->next = NULL; +#if defined(HAVE_AVFILTER_GRAPH_PARSE_PTR) + if ((result = m_dllAvFilter.avfilter_graph_parse_ptr(m_pFilterGraph, (const char*)m_filters.c_str(), &inputs, &outputs, NULL)) < 0) +#elif defined(AVFILTER_GRAPH_PARSE_TAKES_PTR_PTR_ARG) if ((result = m_dllAvFilter.avfilter_graph_parse(m_pFilterGraph, (const char*)m_filters.c_str(), &inputs, &outputs, NULL)) < 0) +#else + if ((result = m_dllAvFilter.avfilter_graph_parse(m_pFilterGraph, (const char*)m_filters.c_str(), inputs, outputs, NULL)) < 0) +#endif { CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - avfilter_graph_parse"); return result; @@ -785,11 +810,13 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters, bool scale) void CDVDVideoCodecFFmpeg::FilterClose() { +#if !defined(LIBAVFILTER_AVFRAME_BASED) if(m_pBufferRef) { m_dllAvFilter.avfilter_unref_buffer(m_pBufferRef); m_pBufferRef = NULL; } +#endif if (m_pFilterGraph) { @@ -803,7 +830,7 @@ void CDVDVideoCodecFFmpeg::FilterClose() int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame) { - int result, frames; + int result; if (frame) { @@ -815,21 +842,37 @@ int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame) // libav: commit 7e350379f87e7f74420b4813170fe808e2313911 (28 Nov 2012) // release v9 (5 January 2013) result = m_dllAvFilter.av_buffersrc_add_frame(m_pFilterIn, frame); -#elif defined(LIBAVFILTER_FROM_FFMPEG) && LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,72,105) +#else // API changed in: // ffmpeg: commit 7bac2a78c2241df4bcc1665703bb71afd9a3e692 (28 Apr 2012) // release 0.11 (25 May 2012) result = m_dllAvFilter.av_buffersrc_add_frame(m_pFilterIn, frame, 0); -#else - result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, 0); #endif if (result < 0) { - CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - av_buffersrc_add_frame/av_vsrc_buffer_add_frame"); + CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - av_buffersrc_add_frame"); return VC_ERROR; } } +#if defined(LIBAVFILTER_AVFRAME_BASED) + result = m_dllAvFilter.av_buffersink_get_frame(m_pFilterOut, m_pFilterFrame); + + if(result == AVERROR(EAGAIN) || result == AVERROR_EOF) + return VC_BUFFER; + else if(result < 0) + { + CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - av_buffersink_get_frame"); + return VC_ERROR; + } + + m_dllAvUtil.av_frame_unref(m_pFrame); + m_dllAvUtil.av_frame_move_ref(m_pFrame, m_pFilterFrame); + + return VC_PICTURE; +#else + int frames; + if(m_pBufferRef) { m_dllAvFilter.avfilter_unref_buffer(m_pBufferRef); @@ -870,6 +913,7 @@ int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame) } return VC_BUFFER; +#endif } unsigned CDVDVideoCodecFFmpeg::GetConvergeCount() diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h index 28416e6fb8..c509339a91 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h @@ -99,7 +99,11 @@ protected: AVFilterGraph* m_pFilterGraph; AVFilterContext* m_pFilterIn; AVFilterContext* m_pFilterOut; +#if defined(LIBAVFILTER_AVFRAME_BASED) + AVFrame* m_pFilterFrame; +#else AVFilterBufferRef* m_pBufferRef; +#endif int m_iPictureWidth; int m_iPictureHeight; |