diff options
89 files changed, 742 insertions, 3675 deletions
diff --git a/Makefile.in b/Makefile.in index 9128c3b866..002bb23269 100644 --- a/Makefile.in +++ b/Makefile.in @@ -35,7 +35,6 @@ DIRECTORY_ARCHIVES=$(DVDPLAYER_ARCHIVES) \ lib/libXDAAP/libxdaap.a \ lib/libhts/libhts.a \ lib/libsquish/libsquish.a \ - lib/xbmc-dll-symbols/dll-symbols.a \ xbmc/addons/addons.a \ xbmc/cdrip/cdrip.a \ xbmc/cores/AudioEngine/audioengine.a \ @@ -187,10 +186,6 @@ ifeq (@USE_OMXPLAYER@,1) DIRECTORY_ARCHIVES += xbmc/cores/omxplayer/omxplayer.a endif -ifeq (@USE_LIBAV_HACKS@,1) -DIRECTORY_ARCHIVES += lib/xbmc-libav-hacks/dll-libavhacks.a -endif - PAPCODECS_DIRS= \ lib/nosefart \ lib/timidity \ @@ -393,7 +388,6 @@ libaddon: exports $(MAKE) -C lib/addons/library.xbmc.gui $(MAKE) -C lib/addons/library.xbmc.pvr dvdpcodecs: dllloader - $(MAKE) -C lib $(MAKE) -C lib/libdvd ifeq (@USE_LIBSTAGEFRIGHT@,1) diff --git a/configure.in b/configure.in index c6ebeba3d9..df956b2a54 100644 --- a/configure.in +++ b/configure.in @@ -2517,7 +2517,6 @@ OUTPUT_FILES="Makefile \ xbmc/cores/Makefile \ xbmc/cores/VideoRenderers/Makefile \ xbmc/cores/dvdplayer/Makefile \ - lib/Makefile \ lib/libdvd/Makefile \ xbmc/cores/DllLoader/Makefile \ xbmc/cores/DllLoader/exports/Makefile \ diff --git a/lib/DllAvCodec.h b/lib/DllAvCodec.h deleted file mode 100644 index af13a15d52..0000000000 --- a/lib/DllAvCodec.h +++ /dev/null @@ -1,281 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#if (defined HAVE_CONFIG_H) && (!defined WIN32) - #include "config.h" -#endif -#include "DynamicDll.h" -#include "DllAvUtil.h" -#include "utils/log.h" - -extern "C" { -#ifndef HAVE_MMX -#define HAVE_MMX -#endif -#ifndef __STDC_CONSTANT_MACROS -#define __STDC_CONSTANT_MACROS -#endif -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS -#endif - -#ifndef __GNUC__ -#pragma warning(disable:4244) -#endif - -#if (defined USE_EXTERNAL_FFMPEG) - #include <libavcodec/avcodec.h> -#else - #include "libavcodec/avcodec.h" -#endif -} - -#include "threads/SingleLock.h" - -class DllAvCodecInterface -{ -public: - virtual ~DllAvCodecInterface() {} - virtual void avcodec_register_all(void)=0; - virtual void avcodec_flush_buffers(AVCodecContext *avctx)=0; - virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)=0; - virtual AVCodec *avcodec_find_decoder(enum AVCodecID id)=0; - virtual AVCodec *avcodec_find_encoder(enum AVCodecID id)=0; - virtual int avcodec_close_dont_call(AVCodecContext *avctx)=0; - virtual AVFrame *avcodec_alloc_frame(void)=0; - virtual int avpicture_fill(AVPicture *picture, uint8_t *ptr, PixelFormat pix_fmt, int width, int height)=0; - virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)=0; - virtual int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)=0; - virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)=0; - virtual int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)=0; - virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height)=0; - virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec)=0; - virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)=0; - virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec)=0; - virtual AVCodecParserContext *av_parser_init(int codec_id)=0; - virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, - int64_t pts, int64_t dts, int64_t pos)=0; - virtual void av_parser_close(AVCodecParserContext *s)=0; - virtual AVBitStreamFilterContext *av_bitstream_filter_init(const char *name)=0; - virtual int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, - AVCodecContext *avctx, const char *args, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe) =0; - virtual void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc) =0; - virtual void avpicture_free(AVPicture *picture)=0; - virtual void av_free_packet(AVPacket *pkt)=0; - virtual int avpicture_alloc(AVPicture *picture, PixelFormat pix_fmt, int width, int height)=0; - virtual enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt)=0; - virtual AVCodec *av_codec_next(AVCodec *c)=0; - virtual int av_dup_packet(AVPacket *pkt)=0; - virtual void av_init_packet(AVPacket *pkt)=0; - virtual int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, int buf_size, int align) = 0; - virtual void avcodec_free_frame(AVFrame **frame)=0; - virtual int av_codec_is_decoder(const AVCodec *codec)=0; - virtual AVDictionary* av_frame_get_metadata(const AVFrame* frame)=0; -}; - -#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG) - -// Use direct layer -class DllAvCodec : public DllDynamic, DllAvCodecInterface -{ -public: - static CCriticalSection m_critSection; - - virtual ~DllAvCodec() {} - virtual void avcodec_register_all() - { - CSingleLock lock(DllAvCodec::m_critSection); - ::avcodec_register_all(); - } - virtual void avcodec_flush_buffers(AVCodecContext *avctx) { ::avcodec_flush_buffers(avctx); } - virtual int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) - { - CSingleLock lock(DllAvCodec::m_critSection); - return ::avcodec_open2(avctx, codec, options); - } - virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) { *(volatile int *)0x0 = 0; return 0; } - virtual int avcodec_close_dont_call(AVCodecContext *avctx) { *(volatile int *)0x0 = 0; return 0; } - virtual AVCodec *avcodec_find_decoder(enum AVCodecID id) { return ::avcodec_find_decoder(id); } - virtual AVCodec *avcodec_find_encoder(enum AVCodecID id) { return ::avcodec_find_encoder(id); } - virtual int avcodec_close(AVCodecContext *avctx) - { - CSingleLock lock(DllAvCodec::m_critSection); - return ::avcodec_close(avctx); - } - virtual AVFrame *avcodec_alloc_frame() { return ::avcodec_alloc_frame(); } - virtual int avpicture_fill(AVPicture *picture, uint8_t *ptr, PixelFormat pix_fmt, int width, int height) { return ::avpicture_fill(picture, ptr, pix_fmt, width, height); } - virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) { return ::avcodec_decode_video2(avctx, picture, got_picture_ptr, avpkt); } - virtual int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio4(avctx, frame, got_frame_ptr, avpkt); } - virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { return ::avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, avpkt); } - virtual int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { return ::avcodec_encode_audio2(avctx, avpkt, frame, got_packet_ptr); } - virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height) { return ::avpicture_get_size(pix_fmt, width, height); } - virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec) { return ::avcodec_alloc_context3(codec); } - virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) { ::avcodec_string(buf, buf_size, enc, encode); } - virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec) { ::avcodec_get_context_defaults3(s, codec); } - - virtual AVCodecParserContext *av_parser_init(int codec_id) { return ::av_parser_init(codec_id); } - virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, - int64_t pts, int64_t dts, int64_t pos) - { - return ::av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, pos); - } - virtual void av_parser_close(AVCodecParserContext *s) { ::av_parser_close(s); } - - virtual AVBitStreamFilterContext *av_bitstream_filter_init(const char *name) { return ::av_bitstream_filter_init(name); } - virtual int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, - AVCodecContext *avctx, const char *args, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe) { return ::av_bitstream_filter_filter(bsfc, avctx, args, poutbuf, poutbuf_size, buf, buf_size, keyframe); } - virtual void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc) { ::av_bitstream_filter_close(bsfc); } - - virtual void avpicture_free(AVPicture *picture) { ::avpicture_free(picture); } - virtual void av_free_packet(AVPacket *pkt) { ::av_free_packet(pkt); } - virtual int avpicture_alloc(AVPicture *picture, PixelFormat pix_fmt, int width, int height) { return ::avpicture_alloc(picture, pix_fmt, width, height); } - virtual enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt) { return ::avcodec_default_get_format(s, fmt); } - virtual AVCodec *av_codec_next(AVCodec *c) { return ::av_codec_next(c); } - - virtual int av_dup_packet(AVPacket *pkt) { return ::av_dup_packet(pkt); } - virtual void av_init_packet(AVPacket *pkt) { return ::av_init_packet(pkt); } - virtual int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, int buf_size, int align) { return ::avcodec_fill_audio_frame(frame, nb_channels, sample_fmt, buf, buf_size, align); } - virtual void avcodec_free_frame(AVFrame **frame) { return ::avcodec_free_frame(frame); }; - virtual int av_codec_is_decoder(const AVCodec *codec) { return ::av_codec_is_decoder(codec); } - virtual AVDictionary* av_frame_get_metadata(const AVFrame* frame) { return ::av_frame_get_metadata(frame); } - - // DLL faking. - virtual bool ResolveExports() { return true; } - virtual bool Load() { -#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG) - CLog::Log(LOGDEBUG, "DllAvCodec: Using libavcodec system library"); -#endif - return true; - } - virtual void Unload() {} -}; -#else -class DllAvCodec : public DllDynamic, DllAvCodecInterface -{ - DECLARE_DLL_WRAPPER(DllAvCodec, DLL_PATH_LIBAVCODEC) - DEFINE_FUNC_ALIGNED1(void, __cdecl, avcodec_flush_buffers, AVCodecContext*) - DEFINE_FUNC_ALIGNED3(int, __cdecl, avcodec_open2_dont_call, AVCodecContext*, AVCodec *, AVDictionary **) - DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_video2, AVCodecContext*, AVFrame*, int*, AVPacket*) - DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_audio4, AVCodecContext*, AVFrame*, int*, AVPacket*) - DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_subtitle2, AVCodecContext*, AVSubtitle*, int*, AVPacket*) - DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_encode_audio2, AVCodecContext*, AVPacket*, const AVFrame*, int*) - DEFINE_FUNC_ALIGNED1(AVCodecContext*, __cdecl, avcodec_alloc_context3, AVCodec *) - DEFINE_FUNC_ALIGNED1(AVCodecParserContext*, __cdecl, av_parser_init, int) - DEFINE_FUNC_ALIGNED9(int, __cdecl, av_parser_parse2, AVCodecParserContext*,AVCodecContext*, uint8_t**, int*, const uint8_t*, int, int64_t, int64_t, int64_t) - DEFINE_METHOD1(int, av_dup_packet, (AVPacket *p1)) - DEFINE_METHOD1(void, av_init_packet, (AVPacket *p1)) - - LOAD_SYMBOLS(); - - DEFINE_METHOD0(void, avcodec_register_all_dont_call) - DEFINE_METHOD1(AVCodec*, avcodec_find_decoder, (enum AVCodecID p1)) - DEFINE_METHOD1(AVCodec*, avcodec_find_encoder, (enum AVCodecID p1)) - DEFINE_METHOD1(int, avcodec_close_dont_call, (AVCodecContext *p1)) - DEFINE_METHOD0(AVFrame*, avcodec_alloc_frame) - DEFINE_METHOD5(int, avpicture_fill, (AVPicture *p1, uint8_t *p2, PixelFormat p3, int p4, int p5)) - DEFINE_METHOD3(int, avpicture_get_size, (PixelFormat p1, int p2, int p3)) - DEFINE_METHOD4(void, avcodec_string, (char *p1, int p2, AVCodecContext *p3, int p4)) - DEFINE_METHOD2(void, avcodec_get_context_defaults3, (AVCodecContext *p1, AVCodec *p2)) - DEFINE_METHOD1(void, av_parser_close, (AVCodecParserContext *p1)) - DEFINE_METHOD1(void, avpicture_free, (AVPicture *p1)) - DEFINE_METHOD1(AVBitStreamFilterContext*, av_bitstream_filter_init, (const char *p1)) - DEFINE_METHOD8(int, av_bitstream_filter_filter, (AVBitStreamFilterContext* p1, AVCodecContext* p2, const char* p3, uint8_t** p4, int* p5, const uint8_t* p6, int p7, int p8)) - DEFINE_METHOD1(void, av_bitstream_filter_close, (AVBitStreamFilterContext *p1)) - DEFINE_METHOD1(void, av_free_packet, (AVPacket *p1)) - DEFINE_METHOD4(int, avpicture_alloc, (AVPicture *p1, PixelFormat p2, int p3, int p4)) - DEFINE_METHOD2(enum PixelFormat, avcodec_default_get_format, (struct AVCodecContext *p1, const enum PixelFormat *p2)) - DEFINE_METHOD6(int, avcodec_fill_audio_frame, (AVFrame* p1, int p2, enum AVSampleFormat p3, const uint8_t* p4, int p5, int p6)) - DEFINE_METHOD1(void, avcodec_free_frame, (AVFrame **p1)) - DEFINE_METHOD1(AVCodec*, av_codec_next, (AVCodec *p1)) - DEFINE_METHOD1(int, av_codec_is_decoder, (const AVCodec *p1)) - DEFINE_METHOD1(AVDictionary*, av_frame_get_metadata, (const AVFrame* p1)) - - BEGIN_METHOD_RESOLVE() - RESOLVE_METHOD(avcodec_flush_buffers) - RESOLVE_METHOD_RENAME(avcodec_open2,avcodec_open2_dont_call) - RESOLVE_METHOD_RENAME(avcodec_close,avcodec_close_dont_call) - RESOLVE_METHOD(avcodec_find_decoder) - RESOLVE_METHOD(avcodec_find_encoder) - RESOLVE_METHOD(avcodec_alloc_frame) - RESOLVE_METHOD_RENAME(avcodec_register_all, avcodec_register_all_dont_call) - RESOLVE_METHOD(avpicture_fill) - RESOLVE_METHOD(avcodec_decode_video2) - RESOLVE_METHOD(avcodec_decode_audio4) - RESOLVE_METHOD(avcodec_decode_subtitle2) - RESOLVE_METHOD(avcodec_encode_audio2) - RESOLVE_METHOD(avpicture_get_size) - RESOLVE_METHOD(avcodec_alloc_context3) - RESOLVE_METHOD(avcodec_string) - RESOLVE_METHOD(avcodec_get_context_defaults3) - RESOLVE_METHOD(av_parser_init) - RESOLVE_METHOD(av_parser_parse2) - RESOLVE_METHOD(av_parser_close) - RESOLVE_METHOD(av_bitstream_filter_init) - RESOLVE_METHOD(av_bitstream_filter_filter) - RESOLVE_METHOD(av_bitstream_filter_close) - RESOLVE_METHOD(avpicture_free) - RESOLVE_METHOD(avpicture_alloc) - RESOLVE_METHOD(av_free_packet) - RESOLVE_METHOD(avcodec_default_get_format) - RESOLVE_METHOD(av_codec_next) - RESOLVE_METHOD(av_dup_packet) - RESOLVE_METHOD(av_init_packet) - RESOLVE_METHOD(avcodec_fill_audio_frame) - RESOLVE_METHOD(avcodec_free_frame) - RESOLVE_METHOD(av_codec_is_decoder) - RESOLVE_METHOD(av_frame_get_metadata) - END_METHOD_RESOLVE() - - /* dependencies of libavcodec */ - DllAvUtil m_dllAvUtil; - -public: - static CCriticalSection m_critSection; - int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) - { - CSingleLock lock(DllAvCodec::m_critSection); - return avcodec_open2_dont_call(avctx,codec, options); - } - int avcodec_close(AVCodecContext *avctx) - { - CSingleLock lock(DllAvCodec::m_critSection); - return avcodec_close_dont_call(avctx); - } - void avcodec_register_all() - { - CSingleLock lock(DllAvCodec::m_critSection); - avcodec_register_all_dont_call(); - } - virtual bool Load() - { - if (!m_dllAvUtil.Load()) - return false; - return DllDynamic::Load(); - } -}; - -#endif diff --git a/lib/DllAvFilter.h b/lib/DllAvFilter.h deleted file mode 100644 index 6ef603a969..0000000000 --- a/lib/DllAvFilter.h +++ /dev/null @@ -1,313 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#if (defined HAVE_CONFIG_H) && (!defined WIN32) - #include "config.h" -#endif -#include "DynamicDll.h" -#include "DllAvCodec.h" -#include "DllAvFormat.h" -#include "DllSwResample.h" -#include "utils/log.h" - -extern "C" { -#ifndef HAVE_MMX -#define HAVE_MMX -#endif -#ifndef __STDC_CONSTANT_MACROS -#define __STDC_CONSTANT_MACROS -#endif - -#ifndef __GNUC__ -#pragma warning(disable:4244) -#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 -} - -#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,43,100) -#define LIBAVFILTER_AVFRAME_BASED -#endif - -#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(3,78,100) - #define HAVE_AVFILTER_GRAPH_PARSE_PTR -#endif - -#include "threads/SingleLock.h" - -class DllAvFilterInterface -{ -public: - virtual ~DllAvFilterInterface() {} - 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; - virtual AVFilter *avfilter_get_by_name(const char *name)=0; - 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; -#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_AVFRAME_BASED) - virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame *frame)=0; -#else - virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags)=0; - 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) || (defined USE_STATIC_FFMPEG) -// Use direct mapping -class DllAvFilter : public DllDynamic, DllAvFilterInterface -{ -public: - virtual ~DllAvFilter() {} - virtual void avfilter_free(AVFilterContext *filter) - { - CSingleLock lock(DllAvCodec::m_critSection); - ::avfilter_free(filter); - } - virtual void avfilter_graph_free(AVFilterGraph **graph) - { - CSingleLock lock(DllAvCodec::m_critSection); - ::avfilter_graph_free(graph); - } - void avfilter_register_all() - { - CSingleLock lock(DllAvCodec::m_critSection); - ::avfilter_register_all(); - } - virtual int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx) { return ::avfilter_graph_create_filter(filt_ctx, filt, name, args, opaque, graph_ctx); } - virtual AVFilter *avfilter_get_by_name(const char *name) { return ::avfilter_get_by_name(name); } - virtual AVFilterGraph *avfilter_graph_alloc() { return ::avfilter_graph_alloc(); } - virtual AVFilterInOut *avfilter_inout_alloc() - { - CSingleLock lock(DllAvCodec::m_critSection); - return ::avfilter_inout_alloc(); - } - virtual void avfilter_inout_free(AVFilterInOut **inout) - { - 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); - } -#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); - } -#if defined(LIBAVFILTER_AVFRAME_BASED) - virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame* frame) { return ::av_buffersrc_add_frame(buffer_filter, frame); } -#else - virtual int av_buffersrc_add_frame(AVFilterContext *buffer_filter, AVFrame* frame, int flags) { return ::av_buffersrc_add_frame(buffer_filter, frame, flags); } - 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() { -#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG) - CLog::Log(LOGDEBUG, "DllAvFilter: Using libavfilter system library"); -#endif - return true; - } - virtual void Unload() {} -}; -#else -class DllAvFilter : public DllDynamic, DllAvFilterInterface -{ - DECLARE_DLL_WRAPPER(DllAvFilter, DLL_PATH_LIBAVFILTER) - - LOAD_SYMBOLS() - - 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) - DEFINE_METHOD6(int, avfilter_graph_create_filter, (AVFilterContext **p1, AVFilter *p2, const char *p3, const char *p4, void *p5, AVFilterGraph *p6)) - DEFINE_METHOD1(AVFilter*, avfilter_get_by_name, (const char *p1)) - 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 *) -#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_AVFRAME_BASED) - DEFINE_METHOD2(int, av_buffersrc_add_frame, (AVFilterContext *p1, AVFrame *p2)) -#else - DEFINE_METHOD3(int, av_buffersrc_add_frame, (AVFilterContext *p1, AVFrame *p2, int p3)) - 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_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) - RESOLVE_METHOD(avfilter_graph_create_filter) - RESOLVE_METHOD(avfilter_get_by_name) - 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) - RESOLVE_METHOD(av_buffersrc_add_frame) -#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 */ - DllAvUtil m_dllAvUtil; - DllSwResample m_dllSwResample; - DllAvFormat m_dllAvFormat; - -public: - void avfilter_free(AVFilterContext *filter) - { - CSingleLock lock(DllAvCodec::m_critSection); - avfilter_free_dont_call(filter); - } - void avfilter_graph_free(AVFilterGraph **graph) - { - CSingleLock lock(DllAvCodec::m_critSection); - avfilter_graph_free_dont_call(graph); - } - void avfilter_register_all() - { - CSingleLock lock(DllAvCodec::m_critSection); - avfilter_register_all_dont_call(); - } - AVFilterInOut* avfilter_inout_alloc() - { - 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); - } -#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); - avfilter_inout_free_dont_call(inout); - } - int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx) - { - CSingleLock lock(DllAvCodec::m_critSection); - return avfilter_graph_config_dont_call(graphctx, log_ctx); - } - virtual bool Load() - { - if (!m_dllAvUtil.Load()) - return false; - if (!m_dllSwResample.Load()) - return false; - if (!m_dllAvFormat.Load()) - return false; - return DllDynamic::Load(); - } -}; -#endif diff --git a/lib/DllAvFormat.h b/lib/DllAvFormat.h deleted file mode 100644 index fc7e16658e..0000000000 --- a/lib/DllAvFormat.h +++ /dev/null @@ -1,322 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#if (defined HAVE_CONFIG_H) && (!defined WIN32) - #include "config.h" -#endif -#include "DynamicDll.h" -#include "DllAvCodec.h" - -extern "C" { -#ifndef HAVE_MMX -#define HAVE_MMX -#endif -#ifndef __STDC_CONSTANT_MACROS -#define __STDC_CONSTANT_MACROS -#endif -#ifndef __GNUC__ -#pragma warning(disable:4244) -#endif -#if (defined USE_EXTERNAL_FFMPEG) - #include <libavformat/avformat.h> - /* xbmc_read_frame_flush() is defined for us in lib/xbmc-dll-symbols/DllAvFormat.c */ - void xbmc_read_frame_flush(AVFormatContext *s); -#else - #include "libavformat/avformat.h" - #if defined(TARGET_DARWIN) || defined(USE_STATIC_FFMPEG) - void ff_read_frame_flush(AVFormatContext *s); // internal replacement - #define xbmc_read_frame_flush ff_read_frame_flush - #endif -#endif -} - -/* Flag introduced without a version bump */ -#ifndef AVSEEK_FORCE -#define AVSEEK_FORCE 0x20000 -#endif - -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(55,12,100) -#define AVFORMAT_HAS_STREAM_GET_R_FRAME_RATE -#endif - -typedef int64_t offset_t; - -class DllAvFormatInterface -{ -public: - virtual ~DllAvFormatInterface() {} - virtual void av_register_all_dont_call(void)=0; - virtual void avformat_network_init_dont_call(void)=0; - virtual void avformat_network_deinit_dont_call(void)=0; - virtual AVInputFormat *av_find_input_format(const char *short_name)=0; - virtual void avformat_close_input(AVFormatContext **s)=0; - virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt)=0; - virtual void av_read_frame_flush(AVFormatContext *s)=0; - virtual int av_read_play(AVFormatContext *s)=0; - virtual int av_read_pause(AVFormatContext *s)=0; - virtual int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)=0; -#if (!defined USE_EXTERNAL_FFMPEG) && (!defined TARGET_DARWIN) && (!defined USE_STATIC_FFMPEG) - virtual int avformat_find_stream_info_dont_call(AVFormatContext *ic, AVDictionary **options)=0; -#endif - virtual int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)=0; - virtual AVIOContext *avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, - int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), - int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), - offset_t (*seek)(void *opaque, offset_t offset, int whence))=0; - virtual AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened)=0; - virtual AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)=0; - virtual int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)=0; - virtual void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)=0; - virtual int avio_open(AVIOContext **s, const char *filename, int flags)=0; - virtual int avio_close(AVIOContext *s)=0; - virtual int avio_open_dyn_buf(AVIOContext **s)=0; - virtual int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)=0; - virtual offset_t avio_seek(AVIOContext *s, offset_t offset, int whence)=0; - virtual int avio_read(AVIOContext *s, unsigned char *buf, int size)=0; - virtual void avio_w8(AVIOContext *s, int b)=0; - virtual void avio_write(AVIOContext *s, const unsigned char *buf, int size)=0; - virtual void avio_wb24(AVIOContext *s, unsigned int val)=0; - virtual void avio_wb32(AVIOContext *s, unsigned int val)=0; - virtual void avio_wb16(AVIOContext *s, unsigned int val)=0; - virtual AVFormatContext *avformat_alloc_context(void)=0; - virtual int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat, const char *format_name, const char *filename) = 0; - virtual AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)=0; - virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type)=0; - virtual int avformat_write_header (AVFormatContext *s, AVDictionary **options)=0; - virtual int av_write_trailer(AVFormatContext *s)=0; - virtual int av_write_frame (AVFormatContext *s, AVPacket *pkt)=0; -#if defined(AVFORMAT_HAS_STREAM_GET_R_FRAME_RATE) - virtual AVRational av_stream_get_r_frame_rate(const AVStream *s)=0; -#endif -}; - -#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG) - -// Use direct mapping -class DllAvFormat : public DllDynamic, DllAvFormatInterface -{ -public: - virtual ~DllAvFormat() {} - virtual void av_register_all() - { - CSingleLock lock(DllAvCodec::m_critSection); - return ::av_register_all(); - } - virtual void av_register_all_dont_call() { *(volatile int* )0x0 = 0; } - virtual void avformat_network_init_dont_call() { *(volatile int* )0x0 = 0; } - virtual void avformat_network_deinit_dont_call() { *(volatile int* )0x0 = 0; } - virtual AVInputFormat *av_find_input_format(const char *short_name) { return ::av_find_input_format(short_name); } - virtual void avformat_close_input(AVFormatContext **s) { ::avformat_close_input(s); } - virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt) { return ::av_read_frame(s, pkt); } - virtual void av_read_frame_flush(AVFormatContext *s) { ::xbmc_read_frame_flush(s); } - virtual int av_read_play(AVFormatContext *s) { return ::av_read_play(s); } - virtual int av_read_pause(AVFormatContext *s) { return ::av_read_pause(s); } - virtual int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { return ::av_seek_frame(s, stream_index, timestamp, flags); } - virtual int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) - { - CSingleLock lock(DllAvCodec::m_critSection); - return ::avformat_find_stream_info(ic, options); - } - virtual int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options) - { return ::avformat_open_input(ps, filename, fmt, options); } - virtual AVIOContext *avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, - int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), - int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), - offset_t (*seek)(void *opaque, offset_t offset, int whence)) { return ::avio_alloc_context(buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); } - virtual AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened) {return ::av_probe_input_format(pd, is_opened); } - virtual AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max) {*score_max = 100; return ::av_probe_input_format(pd, is_opened); } // Use av_probe_input_format, this is not exported by ffmpeg's headers - virtual int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { return ::av_probe_input_buffer(pb, fmt, filename, logctx, offset, max_probe_size); } - virtual void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output) { ::av_dump_format(ic, index, url, is_output); } - virtual int avio_open(AVIOContext **s, const char *filename, int flags) { return ::avio_open(s, filename, flags); } - virtual int avio_close(AVIOContext *s) { return ::avio_close(s); } - virtual int avio_open_dyn_buf(AVIOContext **s) { return ::avio_open_dyn_buf(s); } - virtual int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { return ::avio_close_dyn_buf(s, pbuffer); } - virtual offset_t avio_seek(AVIOContext *s, offset_t offset, int whence) { return ::avio_seek(s, offset, whence); } - virtual int avio_read(AVIOContext *s, unsigned char *buf, int size) { return ::avio_read(s, buf, size); } - virtual void avio_w8(AVIOContext *s, int b) { ::avio_w8(s, b); } - virtual void avio_write(AVIOContext *s, const unsigned char *buf, int size) { ::avio_write(s, buf, size); } - virtual void avio_wb24(AVIOContext *s, unsigned int val) { ::avio_wb24(s, val); } - virtual void avio_wb32(AVIOContext *s, unsigned int val) { ::avio_wb32(s, val); } - virtual void avio_wb16(AVIOContext *s, unsigned int val) { ::avio_wb16(s, val); } - virtual AVFormatContext *avformat_alloc_context() { return ::avformat_alloc_context(); } - virtual int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat, const char *format_name, const char *filename){ return ::avformat_alloc_output_context2(ctx,oformat,format_name,filename); } - virtual AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c) { return ::avformat_new_stream(s, c); } - virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) { return ::av_guess_format(short_name, filename, mime_type); } - virtual int avformat_write_header (AVFormatContext *s, AVDictionary **options) { return ::avformat_write_header (s, options); } - virtual int av_write_trailer(AVFormatContext *s) { return ::av_write_trailer(s); } - virtual int av_write_frame (AVFormatContext *s, AVPacket *pkt) { return ::av_write_frame(s, pkt); } -#if defined(AVFORMAT_HAS_STREAM_GET_R_FRAME_RATE) - virtual AVRational av_stream_get_r_frame_rate(const AVStream *s) { return ::av_stream_get_r_frame_rate(s); } -#endif - - // DLL faking. - virtual bool ResolveExports() { return true; } - virtual bool Load() { -#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG) - CLog::Log(LOGDEBUG, "DllAvFormat: Using libavformat system library"); -#endif - CSingleLock lock(DllAvCodec::m_critSection); - if (++m_avformat_refcnt == 1) - ::avformat_network_init(); - return true; - } - virtual void Unload() { - CSingleLock lock(DllAvCodec::m_critSection); - if (--m_avformat_refcnt == 0) - ::avformat_network_deinit(); - } - -protected: - static int m_avformat_refcnt; -}; - -#else - -class DllAvFormat : public DllDynamic, DllAvFormatInterface -{ - DECLARE_DLL_WRAPPER(DllAvFormat, DLL_PATH_LIBAVFORMAT) - - LOAD_SYMBOLS() - - DEFINE_METHOD0(void, av_register_all_dont_call) - DEFINE_METHOD0(void, avformat_network_init_dont_call) - DEFINE_METHOD0(void, avformat_network_deinit_dont_call) - DEFINE_METHOD1(AVInputFormat*, av_find_input_format, (const char *p1)) - DEFINE_METHOD1(void, avformat_close_input, (AVFormatContext **p1)) - DEFINE_METHOD1(int, av_read_play, (AVFormatContext *p1)) - DEFINE_METHOD1(int, av_read_pause, (AVFormatContext *p1)) - DEFINE_METHOD1(void, av_read_frame_flush, (AVFormatContext *p1)) - DEFINE_FUNC_ALIGNED2(int, __cdecl, av_read_frame, AVFormatContext *, AVPacket *) - DEFINE_FUNC_ALIGNED4(int, __cdecl, av_seek_frame, AVFormatContext*, int, int64_t, int) - DEFINE_FUNC_ALIGNED2(int, __cdecl, avformat_find_stream_info_dont_call, AVFormatContext*, AVDictionary **) - DEFINE_FUNC_ALIGNED4(int, __cdecl, avformat_open_input, AVFormatContext **, const char *, AVInputFormat *, AVDictionary **) - DEFINE_FUNC_ALIGNED2(AVInputFormat*, __cdecl, av_probe_input_format, AVProbeData*, int) - DEFINE_FUNC_ALIGNED3(AVInputFormat*, __cdecl, av_probe_input_format2, AVProbeData*, int, int*) - DEFINE_FUNC_ALIGNED6(int, __cdecl, av_probe_input_buffer, AVIOContext *, AVInputFormat **, const char *, void *, unsigned int, unsigned int) - DEFINE_FUNC_ALIGNED3(int, __cdecl, avio_read, AVIOContext*, unsigned char *, int) - DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_w8, AVIOContext*, int) - DEFINE_FUNC_ALIGNED3(void, __cdecl, avio_write, AVIOContext*, const unsigned char *, int) - DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb24, AVIOContext*, unsigned int) - DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb32, AVIOContext*, unsigned int) - DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb16, AVIOContext*, unsigned int) - DEFINE_METHOD7(AVIOContext *, avio_alloc_context, (unsigned char *p1, int p2, int p3, void *p4, - int (*p5)(void *opaque, uint8_t *buf, int buf_size), - int (*p6)(void *opaque, uint8_t *buf, int buf_size), - offset_t (*p7)(void *opaque, offset_t offset, int whence))) - DEFINE_METHOD4(void, av_dump_format, (AVFormatContext *p1, int p2, const char *p3, int p4)) - DEFINE_METHOD3(int, avio_open, (AVIOContext **p1, const char *p2, int p3)) - DEFINE_METHOD1(int, avio_close, (AVIOContext *p1)) - DEFINE_METHOD1(int, avio_open_dyn_buf, (AVIOContext **p1)) - DEFINE_METHOD2(int, avio_close_dyn_buf, (AVIOContext *p1, uint8_t **p2)) - DEFINE_METHOD3(offset_t, avio_seek, (AVIOContext *p1, offset_t p2, int p3)) - DEFINE_METHOD0(AVFormatContext *, avformat_alloc_context) - DEFINE_METHOD4(int, avformat_alloc_output_context2, (AVFormatContext **p1, AVOutputFormat *p2, const char *p3, const char *p4)) - DEFINE_METHOD2(AVStream *, avformat_new_stream, (AVFormatContext *p1, AVCodec *p2)) - DEFINE_METHOD3(AVOutputFormat *, av_guess_format, (const char *p1, const char *p2, const char *p3)) - DEFINE_METHOD2(int, avformat_write_header , (AVFormatContext *p1, AVDictionary **p2)) - DEFINE_METHOD1(int, av_write_trailer, (AVFormatContext *p1)) - DEFINE_METHOD2(int, av_write_frame , (AVFormatContext *p1, AVPacket *p2)) -#if defined(AVFORMAT_HAS_STREAM_GET_R_FRAME_RATE) - DEFINE_METHOD1(AVRational, av_stream_get_r_frame_rate, (const AVStream *p1)) -#endif - BEGIN_METHOD_RESOLVE() - RESOLVE_METHOD_RENAME(av_register_all, av_register_all_dont_call) - RESOLVE_METHOD_RENAME(avformat_network_init, avformat_network_init_dont_call) - RESOLVE_METHOD_RENAME(avformat_network_deinit, avformat_network_deinit_dont_call) - RESOLVE_METHOD(av_find_input_format) - RESOLVE_METHOD(avformat_close_input) - RESOLVE_METHOD(av_read_frame) - RESOLVE_METHOD(av_read_play) - RESOLVE_METHOD(av_read_pause) - RESOLVE_METHOD(av_read_frame_flush) - RESOLVE_METHOD(av_seek_frame) - RESOLVE_METHOD_RENAME(avformat_find_stream_info, avformat_find_stream_info_dont_call) - RESOLVE_METHOD(avformat_open_input) - RESOLVE_METHOD(avio_alloc_context) - RESOLVE_METHOD(av_probe_input_format) - RESOLVE_METHOD(av_probe_input_format2) - RESOLVE_METHOD(av_probe_input_buffer) - RESOLVE_METHOD(av_dump_format) - RESOLVE_METHOD(avio_open) - RESOLVE_METHOD(avio_close) - RESOLVE_METHOD(avio_open_dyn_buf) - RESOLVE_METHOD(avio_close_dyn_buf) - RESOLVE_METHOD(avio_seek) - RESOLVE_METHOD(avio_read) - RESOLVE_METHOD(avio_w8) - RESOLVE_METHOD(avio_write) - RESOLVE_METHOD(avio_wb24) - RESOLVE_METHOD(avio_wb32) - RESOLVE_METHOD(avio_wb16) - RESOLVE_METHOD(avformat_alloc_context) - RESOLVE_METHOD(avformat_alloc_output_context2) - RESOLVE_METHOD(avformat_new_stream) - RESOLVE_METHOD(av_guess_format) - RESOLVE_METHOD(avformat_write_header) - RESOLVE_METHOD(av_write_trailer) - RESOLVE_METHOD(av_write_frame) -#if defined(AVFORMAT_HAS_STREAM_GET_R_FRAME_RATE) - RESOLVE_METHOD(av_stream_get_r_frame_rate) -#endif - END_METHOD_RESOLVE() - - /* dependencies of libavformat */ - DllAvCodec m_dllAvCodec; - // DllAvUtil loaded implicitely by m_dllAvCodec - -public: - void av_register_all() - { - CSingleLock lock(DllAvCodec::m_critSection); - av_register_all_dont_call(); - } - int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) - { - CSingleLock lock(DllAvCodec::m_critSection); - return avformat_find_stream_info_dont_call(ic, options); - } - - virtual bool Load() - { - if (!m_dllAvCodec.Load()) - return false; - bool loaded = DllDynamic::Load(); - - CSingleLock lock(DllAvCodec::m_critSection); - if (++m_avformat_refcnt == 1 && loaded) - avformat_network_init_dont_call(); - return loaded; - } - - virtual void Unload() - { - CSingleLock lock(DllAvCodec::m_critSection); - if (--m_avformat_refcnt == 0 && DllDynamic::IsLoaded()) - avformat_network_deinit_dont_call(); - - DllDynamic::Unload(); - } - -protected: - static int m_avformat_refcnt; -}; - -#endif diff --git a/lib/DllAvUtil.h b/lib/DllAvUtil.h deleted file mode 100644 index 0fcdf10679..0000000000 --- a/lib/DllAvUtil.h +++ /dev/null @@ -1,291 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#if (defined HAVE_CONFIG_H) && (!defined WIN32) - #include "config.h" -#endif -#include "DynamicDll.h" -#include "utils/log.h" - -#ifndef __GNUC__ -#pragma warning(push) -#pragma warning(disable:4244) -#endif - -extern "C" { -#if (defined USE_EXTERNAL_FFMPEG) - #include <libavutil/avutil.h> - // for av_get_default_channel_layout - #include <libavutil/audioconvert.h> - #include <libavutil/crc.h> - #include <libavutil/fifo.h> - // for LIBAVCODEC_VERSION_INT: - #include <libavcodec/avcodec.h> - // for enum AVSampleFormat - #include <libavutil/samplefmt.h> - #include <libavutil/opt.h> - #include <libavutil/mem.h> - #include <libavutil/mathematics.h> - #if (defined USE_LIBAV_HACKS) - #include "xbmc-libav-hacks/libav_hacks.h" - #endif -#else - #include "libavutil/avutil.h" - //for av_get_default_channel_layout - #include "libavutil/audioconvert.h" - #include "libavutil/crc.h" - #include "libavutil/opt.h" - #include "libavutil/mem.h" - #include "libavutil/fifo.h" - // for enum AVSampleFormat - #include "libavutil/samplefmt.h" -#endif -} - -#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(52,29,100) -#define AVFRAME_IN_LAVU -#endif - -#ifndef __GNUC__ -#pragma warning(pop) -#endif - -// calback used for logging -void ff_avutil_log(void* ptr, int level, const char* format, va_list va); - -class DllAvUtilInterface -{ -public: - virtual ~DllAvUtilInterface() {} - virtual void av_log_set_callback(void (*)(void*, int, const char*, va_list))=0; - virtual void *av_malloc(unsigned int size)=0; - virtual void *av_mallocz(unsigned int size)=0; - virtual void *av_realloc(void *ptr, unsigned int size)=0; - virtual void av_free(void *ptr)=0; - virtual void av_freep(void *ptr)=0; - virtual int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding)=0; - virtual int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)=0; - virtual int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size)=0; - virtual const AVCRC* av_crc_get_table(AVCRCId crc_id)=0; - virtual uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)=0; - virtual int av_opt_set(void *obj, const char *name, const char *val, int search_flags)=0; - virtual int av_opt_set_double(void *obj, const char *name, double val, int search_flags)=0; - virtual int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)=0; - virtual AVFifoBuffer *av_fifo_alloc(unsigned int size) = 0; - virtual void av_fifo_free(AVFifoBuffer *f) = 0; - virtual void av_fifo_reset(AVFifoBuffer *f) = 0; - virtual int av_fifo_size(AVFifoBuffer *f) = 0; - virtual int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)) = 0; - virtual int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)) = 0; - virtual char *av_strdup(const char *s)=0; - virtual int av_get_bytes_per_sample(enum AVSampleFormat p1) = 0; - virtual AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags) = 0; - virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)=0; - virtual void av_dict_free(AVDictionary **pm) = 0; - virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0; - virtual int64_t av_get_default_channel_layout(int nb_channels)=0; - virtual int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0; - virtual int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt) = 0; - 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; - virtual uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index) = 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) || (defined USE_STATIC_FFMPEG) -// Use direct layer -class DllAvUtilBase : public DllDynamic, DllAvUtilInterface -{ -public: - - virtual ~DllAvUtilBase() {} - virtual void av_log_set_callback(void (*foo)(void*, int, const char*, va_list)) { ::av_log_set_callback(foo); } - virtual void *av_malloc(unsigned int size) { return ::av_malloc(size); } - virtual void *av_mallocz(unsigned int size) { return ::av_mallocz(size); } - virtual void *av_realloc(void *ptr, unsigned int size) { return ::av_realloc(ptr, size); } - virtual void av_free(void *ptr) { ::av_free(ptr); } - virtual void av_freep(void *ptr) { ::av_freep(ptr); } - virtual int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding d) { return ::av_rescale_rnd(a, b, c, d); } - virtual int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) { return ::av_rescale_q(a, bq, cq); } - virtual int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size) { return ::av_crc_init(ctx, le, bits, poly, ctx_size); } - virtual const AVCRC* av_crc_get_table(AVCRCId crc_id) { return ::av_crc_get_table(crc_id); } - virtual uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length) { return ::av_crc(ctx, crc, buffer, length); } - virtual int av_opt_set(void *obj, const char *name, const char *val, int search_flags) { return ::av_opt_set(obj, name, val, search_flags); } - virtual int av_opt_set_double(void *obj, const char *name, double val, int search_flags) { return ::av_opt_set_double(obj, name, val, search_flags); } - virtual int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags) { return ::av_opt_set_int(obj, name, val, search_flags); } - virtual AVFifoBuffer *av_fifo_alloc(unsigned int size) {return ::av_fifo_alloc(size); } - virtual void av_fifo_free(AVFifoBuffer *f) { ::av_fifo_free(f); } - virtual void av_fifo_reset(AVFifoBuffer *f) { ::av_fifo_reset(f); } - virtual int av_fifo_size(AVFifoBuffer *f) { return ::av_fifo_size(f); } - virtual int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)) - { return ::av_fifo_generic_read(f, dest, buf_size, func); } - virtual int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)) - { return ::av_fifo_generic_write(f, src, size, func); } - virtual char *av_strdup(const char *s) { return ::av_strdup(s); } - virtual int av_get_bytes_per_sample(enum AVSampleFormat p1) - { return ::av_get_bytes_per_sample(p1); } - virtual AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags){ return ::av_dict_get(m, key, prev, flags); } - virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags) { return ::av_dict_set(pm, key, value, flags); } - virtual void av_dict_free(AVDictionary **pm) { ::av_dict_free(pm); } - virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) - { return ::av_samples_get_buffer_size(linesize, nb_channels, nb_samples, sample_fmt, align); } - virtual int64_t av_get_default_channel_layout(int nb_channels) { return ::av_get_default_channel_layout(nb_channels); } - virtual int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) - { return ::av_samples_alloc(audio_data, linesize, nb_channels, nb_samples, sample_fmt, align); } - virtual int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt) { return ::av_sample_fmt_is_planar(sample_fmt); } - virtual int av_get_channel_layout_channel_index (uint64_t channel_layout, uint64_t channel) { return ::av_get_channel_layout_channel_index(channel_layout, channel); } - 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) - { return ::av_samples_fill_arrays(audio_data, linesize, buf, nb_channels, nb_samples, 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); } - virtual uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index) - { return ::av_channel_layout_extract_channel(channel_layout, index); } -#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; } - virtual bool Load() { -#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG) - CLog::Log(LOGDEBUG, "DllAvUtilBase: Using libavutil system library"); -#endif - return true; - } - virtual void Unload() {} -}; - -#else - -class DllAvUtilBase : public DllDynamic, DllAvUtilInterface -{ - DECLARE_DLL_WRAPPER(DllAvUtilBase, DLL_PATH_LIBAVUTIL) - - LOAD_SYMBOLS() - - DEFINE_METHOD1(void, av_log_set_callback, (void (*p1)(void*, int, const char*, va_list))) - DEFINE_METHOD1(void*, av_malloc, (unsigned int p1)) - DEFINE_METHOD1(void*, av_mallocz, (unsigned int p1)) - DEFINE_METHOD2(void*, av_realloc, (void *p1, unsigned int p2)) - DEFINE_METHOD1(void, av_free, (void *p1)) - DEFINE_METHOD1(void, av_freep, (void *p1)) - DEFINE_METHOD4(int64_t, av_rescale_rnd, (int64_t p1, int64_t p2, int64_t p3, enum AVRounding p4)); - DEFINE_METHOD3(int64_t, av_rescale_q, (int64_t p1, AVRational p2, AVRational p3)); - DEFINE_METHOD1(const AVCRC*, av_crc_get_table, (AVCRCId p1)) - DEFINE_METHOD5(int, av_crc_init, (AVCRC *p1, int p2, int p3, uint32_t p4, int p5)); - DEFINE_METHOD4(uint32_t, av_crc, (const AVCRC *p1, uint32_t p2, const uint8_t *p3, size_t p4)); - DEFINE_METHOD4(int, av_opt_set, (void *p1, const char *p2, const char *p3, int p4)); - DEFINE_METHOD4(int, av_opt_set_double, (void *p1, const char *p2, double p3, int p4)) - DEFINE_METHOD4(int, av_opt_set_int, (void *p1, const char *p2, int64_t p3, int p4)) - DEFINE_METHOD1(AVFifoBuffer*, av_fifo_alloc, (unsigned int p1)) - DEFINE_METHOD1(void, av_fifo_free, (AVFifoBuffer *p1)) - DEFINE_METHOD1(void, av_fifo_reset, (AVFifoBuffer *p1)) - DEFINE_METHOD1(int, av_fifo_size, (AVFifoBuffer *p1)) - DEFINE_METHOD4(int, av_fifo_generic_read, (AVFifoBuffer *p1, void *p2, int p3, void (*p4)(void*, void*, int))) - DEFINE_METHOD4(int, av_fifo_generic_write, (AVFifoBuffer *p1, void *p2, int p3, int (*p4)(void*, void*, int))) - DEFINE_METHOD1(char*, av_strdup, (const char *p1)) - DEFINE_METHOD1(int, av_get_bytes_per_sample, (enum AVSampleFormat p1)) - DEFINE_METHOD4(AVDictionaryEntry *, av_dict_get, (AVDictionary *p1, const char *p2, const AVDictionaryEntry *p3, int p4)) - DEFINE_METHOD4(int, av_dict_set, (AVDictionary **p1, const char *p2, const char *p3, int p4)); - DEFINE_METHOD1(void, av_dict_free, (AVDictionary **p1)); - DEFINE_METHOD5(int, av_samples_get_buffer_size, (int *p1, int p2, int p3, enum AVSampleFormat p4, int p5)) - DEFINE_METHOD1(int64_t, av_get_default_channel_layout, (int p1)) - DEFINE_METHOD6(int, av_samples_alloc, (uint8_t **p1, int *p2, int p3, int p4, enum AVSampleFormat p5, int p6)) - DEFINE_METHOD1(int, av_sample_fmt_is_planar, (enum AVSampleFormat p1)) - 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)) - DEFINE_METHOD2(uint64_t, av_channel_layout_extract_channel, (uint64_t p1, int p2)) -#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() - RESOLVE_METHOD(av_log_set_callback) - RESOLVE_METHOD(av_malloc) - RESOLVE_METHOD(av_mallocz) - RESOLVE_METHOD(av_realloc) - RESOLVE_METHOD(av_free) - RESOLVE_METHOD(av_freep) - RESOLVE_METHOD(av_rescale_rnd) - RESOLVE_METHOD(av_rescale_q) - RESOLVE_METHOD(av_crc_init) - RESOLVE_METHOD(av_crc_get_table) - RESOLVE_METHOD(av_crc) - RESOLVE_METHOD(av_opt_set) - RESOLVE_METHOD(av_opt_set_double) - RESOLVE_METHOD(av_opt_set_int) - RESOLVE_METHOD(av_fifo_alloc) - RESOLVE_METHOD(av_fifo_free) - RESOLVE_METHOD(av_fifo_reset) - RESOLVE_METHOD(av_fifo_size) - RESOLVE_METHOD(av_fifo_generic_read) - RESOLVE_METHOD(av_fifo_generic_write) - RESOLVE_METHOD(av_strdup) - RESOLVE_METHOD(av_get_bytes_per_sample) - RESOLVE_METHOD(av_dict_get) - RESOLVE_METHOD(av_dict_set) - RESOLVE_METHOD(av_dict_free) - RESOLVE_METHOD(av_samples_get_buffer_size) - RESOLVE_METHOD(av_get_default_channel_layout) - RESOLVE_METHOD(av_samples_alloc) - RESOLVE_METHOD(av_sample_fmt_is_planar) - RESOLVE_METHOD(av_get_channel_layout_channel_index) - RESOLVE_METHOD(av_samples_fill_arrays) - RESOLVE_METHOD(av_samples_copy) - RESOLVE_METHOD(av_channel_layout_extract_channel) -#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() -}; - -#endif - -class DllAvUtil : public DllAvUtilBase -{ -public: - virtual bool Load() - { - if( DllAvUtilBase::Load() ) - { - DllAvUtilBase::av_log_set_callback(ff_avutil_log); - return true; - } - return false; - } -}; diff --git a/lib/DllPostProc.h b/lib/DllPostProc.h deleted file mode 100644 index ebba5e2f41..0000000000 --- a/lib/DllPostProc.h +++ /dev/null @@ -1,129 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#if (defined HAVE_CONFIG_H) && (!defined WIN32) - #include "config.h" -#endif -#include "DynamicDll.h" -#include "utils/log.h" - -extern "C" { -#define HAVE_MMX -#ifndef __STDC_CONSTANT_MACROS -#define __STDC_CONSTANT_MACROS -#endif -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS -#endif -#ifndef __GNUC__ -#pragma warning(disable:4244) -#endif - -#if (defined USE_EXTERNAL_FFMPEG) - #include <libavutil/avutil.h> - #include <libpostproc/postprocess.h> -#else - #include "libavutil/avutil.h" - #include "libpostproc/postprocess.h" -#endif -} - -#include "utils/CPUInfo.h" - -inline int PPCPUFlags() -{ - unsigned int cpuFeatures = g_cpuInfo.GetCPUFeatures(); - int flags = 0; - - if (cpuFeatures & CPU_FEATURE_MMX) - flags |= PP_CPU_CAPS_MMX; - if (cpuFeatures & CPU_FEATURE_MMX2) - flags |= PP_CPU_CAPS_MMX2; - if (cpuFeatures & CPU_FEATURE_3DNOW) - flags |= PP_CPU_CAPS_3DNOW; - if (cpuFeatures & CPU_FEATURE_ALTIVEC) - flags |= PP_CPU_CAPS_ALTIVEC; - - return flags; -} - -class DllPostProcInterface -{ -public: - virtual ~DllPostProcInterface() {} - virtual void pp_postprocess(uint8_t * src[3], int srcStride[3], uint8_t * dst[3], int dstStride[3], - int horizontalSize, int verticalSize, QP_STORE_T *QP_store, int QP_stride, - pp_mode *mode, pp_context *ppContext, int pict_type)=0; - virtual pp_mode *pp_get_mode_by_name_and_quality(char *name, int quality)=0; - virtual void pp_free_mode(pp_mode *mode)=0; - virtual pp_context *pp_get_context(int width, int height, int flags)=0; - virtual void pp_free_context(pp_context *ppContext)=0; -}; - -#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG) - -// We call directly. -class DllPostProc : public DllDynamic, DllPostProcInterface -{ -public: - - virtual ~DllPostProc() {} - virtual void pp_postprocess(uint8_t * src[3], int srcStride[3], uint8_t * dst[3], int dstStride[3], - int horizontalSize, int verticalSize, QP_STORE_T *QP_store, int QP_stride, - pp_mode *mode, pp_context *ppContext, int pict_type) { ::pp_postprocess((const uint8_t** )src, srcStride, dst, dstStride, horizontalSize, verticalSize, QP_store, QP_stride, mode, ppContext, pict_type); } - virtual pp_mode *pp_get_mode_by_name_and_quality(char *name, int quality) { return ::pp_get_mode_by_name_and_quality(name, quality); } - virtual void pp_free_mode(pp_mode *mode) { ::pp_free_mode(mode); } - virtual pp_context *pp_get_context(int width, int height, int flags) { return ::pp_get_context(width, height, flags); } - virtual void pp_free_context(pp_context *ppContext) { ::pp_free_context(ppContext); } - - // DLL faking. - virtual bool ResolveExports() { return true; } - virtual bool Load() { -#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG) - CLog::Log(LOGDEBUG, "DllPostProc: Using libpostproc system library"); -#endif - return true; - } - virtual void Unload() {} -}; - -#else -class DllPostProc : public DllDynamic, DllPostProcInterface -{ - DECLARE_DLL_WRAPPER(DllPostProc, DLL_PATH_LIBPOSTPROC) - DEFINE_METHOD11(void, pp_postprocess, (uint8_t* p1[3], int p2[3], uint8_t * p3[3], int p4[3], - int p5, int p6, QP_STORE_T *p7, int p8, - pp_mode *p9, pp_context *p10, int p11)) - DEFINE_METHOD2(pp_mode*, pp_get_mode_by_name_and_quality, (char *p1, int p2)) - DEFINE_METHOD1(void, pp_free_mode, (pp_mode *p1)) - DEFINE_METHOD3(pp_context*, pp_get_context, (int p1, int p2, int p3)) - DEFINE_METHOD1(void, pp_free_context, (pp_context *p1)) - - BEGIN_METHOD_RESOLVE() - RESOLVE_METHOD(pp_postprocess) - RESOLVE_METHOD(pp_get_mode_by_name_and_quality) - RESOLVE_METHOD(pp_free_mode) - RESOLVE_METHOD(pp_get_context) - RESOLVE_METHOD(pp_free_context) - END_METHOD_RESOLVE() -}; - -#endif diff --git a/lib/DllSwResample.h b/lib/DllSwResample.h deleted file mode 100644 index cd1452b0f4..0000000000 --- a/lib/DllSwResample.h +++ /dev/null @@ -1,131 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#if (defined HAVE_CONFIG_H) && (!defined WIN32) - #include "config.h" -#endif -#include "DynamicDll.h" -#include "utils/log.h" - -extern "C" { -#ifndef HAVE_MMX -#define HAVE_MMX -#endif -#ifndef __STDC_CONSTANT_MACROS -#define __STDC_CONSTANT_MACROS -#endif -#ifndef __GNUC__ -#pragma warning(disable:4244) -#endif -#if (defined USE_EXTERNAL_FFMPEG) - #if (defined USE_LIBAV_HACKS) - #include "xbmc-libav-hacks/libav_hacks.h" - #else - #include <libswresample/swresample.h> - #endif -#else - #include "libswresample/swresample.h" -#endif -} - -class DllSwResampleInterface -{ -public: - virtual ~DllSwResampleInterface() {} - virtual struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx)=0; - virtual int swr_init(struct SwrContext *s)=0; - virtual void swr_free(struct SwrContext **s)=0; - virtual int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, const uint8_t **in , int in_count)=0; - virtual int64_t swr_get_delay(struct SwrContext *s, int64_t base) = 0; - virtual int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map) = 0; - virtual int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride) = 0; - virtual int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance) = 0; -}; - -#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG) - -// Use direct mapping -class DllSwResample : public DllDynamic, DllSwResampleInterface -{ -public: - virtual ~DllSwResample() {} - - // DLL faking. - virtual bool ResolveExports() { return true; } - virtual bool Load() { -#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG) - CLog::Log(LOGDEBUG, "DllAvFormat: Using libswresample system library"); -#endif - return true; - } - virtual void Unload() {} - virtual struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx) { return ::swr_alloc_set_opts(s, out_ch_layout, out_sample_fmt, out_sample_rate, in_ch_layout, in_sample_fmt, in_sample_rate, log_offset, log_ctx); } - virtual int swr_init(struct SwrContext *s) { return ::swr_init(s); } - virtual void swr_free(struct SwrContext **s){ return ::swr_free(s); } - virtual int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, const uint8_t **in , int in_count){ return ::swr_convert(s, out, out_count, in, in_count); } - virtual int64_t swr_get_delay(struct SwrContext *s, int64_t base) { return ::swr_get_delay(s, base); } - virtual int swr_set_channel_mapping (struct SwrContext *s, const int *channel_map) { return ::swr_set_channel_mapping(s, channel_map); } - virtual int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride) { return ::swr_set_matrix(s, matrix, stride); } - virtual int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance) { return ::swr_set_compensation(s, sample_delta, compensation_distance); } -}; - -#else - -class DllSwResample : public DllDynamic, DllSwResampleInterface -{ - DECLARE_DLL_WRAPPER(DllSwResample, DLL_PATH_LIBSWRESAMPLE) - - LOAD_SYMBOLS() - - DEFINE_METHOD9(SwrContext*, swr_alloc_set_opts, (struct SwrContext *p1, int64_t p2, enum AVSampleFormat p3, int p4, int64_t p5, enum AVSampleFormat p6, int p7, int p8, void * p9)); - DEFINE_METHOD1(int, swr_init, (struct SwrContext *p1)) - DEFINE_METHOD1(void, swr_free, (struct SwrContext **p1)) - DEFINE_METHOD5(int, swr_convert, (struct SwrContext *p1, uint8_t **p2, int p3, const uint8_t **p4, int p5)) - DEFINE_METHOD2(int64_t, swr_get_delay, (struct SwrContext *p1, int64_t p2)) - DEFINE_METHOD2(int, swr_set_channel_mapping, (struct SwrContext *p1, const int *p2)) - DEFINE_METHOD3(int, swr_set_matrix, (struct SwrContext *p1, const double *p2, int p3)) - DEFINE_METHOD3(int, swr_set_compensation, (struct SwrContext *p1, int p2, int p3)) - - BEGIN_METHOD_RESOLVE() - RESOLVE_METHOD(swr_alloc_set_opts) - RESOLVE_METHOD(swr_init) - RESOLVE_METHOD(swr_free) - RESOLVE_METHOD(swr_convert) - RESOLVE_METHOD(swr_get_delay) - RESOLVE_METHOD(swr_set_channel_mapping) - RESOLVE_METHOD(swr_set_matrix) - RESOLVE_METHOD(swr_set_compensation) - END_METHOD_RESOLVE() - - /* dependencies of libavformat */ - DllAvUtil m_dllAvUtil; - -public: - - virtual bool Load() - { - if (!m_dllAvUtil.Load()) - return false; - return DllDynamic::Load(); - } -}; - -#endif diff --git a/lib/DllSwScale.h b/lib/DllSwScale.h deleted file mode 100644 index 97e3b400ed..0000000000 --- a/lib/DllSwScale.h +++ /dev/null @@ -1,153 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#if (defined HAVE_CONFIG_H) && (!defined WIN32) - #include "config.h" -#endif -#include "DynamicDll.h" -#include "DllAvUtil.h" -#include "utils/log.h" - -extern "C" { -#ifndef HAVE_MMX -#define HAVE_MMX -#endif - -#ifndef __STDC_CONSTANT_MACROS -#define __STDC_CONSTANT_MACROS -#endif - -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS -#endif - -#ifndef __GNUC__ -#pragma warning(disable:4244) -#endif - -#if (defined USE_EXTERNAL_FFMPEG) - #include <libswscale/swscale.h> -#else - #include "libswscale/swscale.h" -#endif -} - -#include "../xbmc/utils/CPUInfo.h" - -inline int SwScaleCPUFlags() -{ - unsigned int cpuFeatures = g_cpuInfo.GetCPUFeatures(); - int flags = 0; - - if (cpuFeatures & CPU_FEATURE_MMX) - flags |= SWS_CPU_CAPS_MMX; - if (cpuFeatures & CPU_FEATURE_MMX2) - flags |= SWS_CPU_CAPS_MMX2; - if (cpuFeatures & CPU_FEATURE_3DNOW) - flags |= SWS_CPU_CAPS_3DNOW; - if (cpuFeatures & CPU_FEATURE_ALTIVEC) - flags |= SWS_CPU_CAPS_ALTIVEC; - - return flags; -} - -class DllSwScaleInterface -{ -public: - virtual ~DllSwScaleInterface() {} - - virtual struct SwsContext *sws_getCachedContext(struct SwsContext *context, - int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, - SwsFilter *srcFilter, SwsFilter *dstFilter, double *param)=0; - - virtual struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, - SwsFilter *srcFilter, SwsFilter *dstFilter, double *param)=0; - - virtual int sws_scale(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, - int srcSliceH, uint8_t* dst[], int dstStride[])=0; - - virtual void sws_freeContext(struct SwsContext *context)=0; -}; - -#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG) - -// We call into this library directly. -class DllSwScale : public DllDynamic, public DllSwScaleInterface -{ -public: - virtual ~DllSwScale() {} - virtual struct SwsContext *sws_getCachedContext(struct SwsContext *context, - int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, - SwsFilter *srcFilter, SwsFilter *dstFilter, double *param) - { return ::sws_getCachedContext(context, srcW, srcH, (enum PixelFormat)srcFormat, dstW, dstH, (enum PixelFormat)dstFormat, flags, srcFilter, dstFilter, param); } - - virtual struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, - SwsFilter *srcFilter, SwsFilter *dstFilter, double *param) - { return ::sws_getContext(srcW, srcH, (enum PixelFormat)srcFormat, dstW, dstH, (enum PixelFormat)dstFormat, flags, srcFilter, dstFilter, param); } - - virtual int sws_scale(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, - int srcSliceH, uint8_t* dst[], int dstStride[]) - { return ::sws_scale(context, src, srcStride, srcSliceY, srcSliceH, dst, dstStride); } - virtual void sws_freeContext(struct SwsContext *context) { ::sws_freeContext(context); } - - // DLL faking. - virtual bool ResolveExports() { return true; } - virtual bool Load() { -#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG) - CLog::Log(LOGDEBUG, "DllSwScale: Using libswscale system library"); -#endif - return true; - } - virtual void Unload() {} -}; - -#else - -class DllSwScale : public DllDynamic, public DllSwScaleInterface -{ - DECLARE_DLL_WRAPPER(DllSwScale, DLL_PATH_LIBSWSCALE) - DEFINE_METHOD11(struct SwsContext *, sws_getCachedContext, ( struct SwsContext *p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, - SwsFilter * p9, SwsFilter * p10, double * p11)) - DEFINE_METHOD10(struct SwsContext *, sws_getContext, ( int p1, int p2, int p3, int p4, int p5, int p6, int p7, - SwsFilter * p8, SwsFilter * p9, double * p10)) - DEFINE_METHOD7(int, sws_scale, (struct SwsContext *p1, uint8_t** p2, int *p3, int p4, int p5, uint8_t **p6, int *p7)) - DEFINE_METHOD1(void, sws_freeContext, (struct SwsContext *p1)) - - BEGIN_METHOD_RESOLVE() - RESOLVE_METHOD(sws_getCachedContext) - RESOLVE_METHOD(sws_getContext) - RESOLVE_METHOD(sws_scale) - RESOLVE_METHOD(sws_freeContext) - END_METHOD_RESOLVE() - - /* dependency of libswscale */ - DllAvUtil m_dllAvUtil; - -public: - virtual bool Load() - { - if (!m_dllAvUtil.Load()) - return false; - return DllDynamic::Load(); - } -}; - -#endif diff --git a/lib/Makefile.in b/lib/Makefile.in deleted file mode 100644 index ca18a4ae31..0000000000 --- a/lib/Makefile.in +++ /dev/null @@ -1,103 +0,0 @@ -ARCH=@ARCH@ - -AR=@AR@ -LD=@LD@ -CC=@CC@ -CXX=@CXX@ -SYSDIR=@abs_top_srcdir@/system/players/dvdplayer - -ifeq (@USE_ANDROID@,1) -AVPREFIX=lib -else -AVPREFIX= -endif - -AVFORMAT_SO=$(AVPREFIX)avformat-54-$(ARCH).so -AVCODEC_SO=$(AVPREFIX)avcodec-54-$(ARCH).so -AVUTIL_SO=$(AVPREFIX)avutil-52-$(ARCH).so -AVFILTER_SO=$(AVPREFIX)avfilter-3-$(ARCH).so -SWSCALE_SO=$(AVPREFIX)swscale-2-$(ARCH).so -POSTPROC_SO=$(AVPREFIX)postproc-52-$(ARCH).so -SWRESAMPLE_SO=$(AVPREFIX)swresample-0-$(ARCH).so - -DIRS= -ifneq (@USE_EXTERNAL_FFMPEG@,1) - DIRS+=ffmpeg -endif - -LIBS= -ifneq (@USE_EXTERNAL_FFMPEG@,1) -ifneq (@USE_STATIC_FFMPEG@,1) - LIBS+=$(AVUTIL_SO) \ - $(AVCODEC_SO) \ - $(AVFORMAT_SO) \ - $(POSTPROC_SO) \ - $(AVFILTER_SO) \ - $(SWSCALE_SO) \ - $(SWRESAMPLE_SO) -endif -endif - -.PHONY: $(DIRS) codecs - -ifneq ($(findstring osx,$(ARCH)), osx) -ifneq (@USE_STATIC_FFMPEG@,1) - -codecs: $(addprefix $(SYSDIR)/, $(LIBS)); - -$(SYSDIR)/$(AVUTIL_SO): ffmpeg/libavutil/libavutil.so - cp ffmpeg/libavutil/libavutil.so $@ - -$(SYSDIR)/$(AVCODEC_SO): ffmpeg/libavcodec/libavcodec.so - cp ffmpeg/libavcodec/libavcodec.so $@ - -$(SYSDIR)/$(AVFORMAT_SO): ffmpeg/libavformat/libavformat.so - cp ffmpeg/libavformat/libavformat.so $@ - -$(SYSDIR)/$(AVFILTER_SO): ffmpeg/libavfilter/libavfilter.so - cp ffmpeg/libavfilter/libavfilter.so $@ - -$(SYSDIR)/$(SWSCALE_SO): ffmpeg/libswscale/libswscale.so - cp ffmpeg/libswscale/libswscale.so $@ - -$(SYSDIR)/$(POSTPROC_SO): ffmpeg/libpostproc/libpostproc.so - cp ffmpeg/libpostproc/libpostproc.so $@ - -$(SYSDIR)/$(SWRESAMPLE_SO): ffmpeg/libswresample/libswresample.so - cp ffmpeg/libswresample/libswresample.so $@ - -ffmpeg/libavutil/libavutil.so : ffmpeg; -ffmpeg/libavcodec/libavcodec.so : ffmpeg; -ffmpeg/libavformat/libavformat.so : ffmpeg; -ffmpeg/libavfilter/libavfilter.so : ffmpeg; -ffmpeg/libswscale/libswscale.so : ffmpeg; -ffmpeg/libpostproc/libpostproc.so : ffmpeg; -ffmpeg/libswresample/libswresample.so : ffmpeg; -endif -endif - -ifeq (@USE_STATIC_FFMPEG@,1) -ffmpeg/libavutil/libavutil.a : ffmpeg; -ffmpeg/libavcodec/libavcodec.a : ffmpeg; -ffmpeg/libavformat/libavformat.a : ffmpeg; -ffmpeg/libavfilter/libavfilter.a : ffmpeg; -ffmpeg/libswscale/libswscale.a : ffmpeg; -ffmpeg/libpostproc/libpostproc.a : ffmpeg; -ffmpeg/libswresample/libswresample.a : ffmpeg; -endif - -ffmpeg: - $(MAKE) -C $@ -ifeq ($(findstring osx,$(ARCH)), osx) - -$(AR) d ffmpeg/libavcodec/libavcodec.a log2_tab.o - -$(AR) d ffmpeg/libavformat/libavformat.a log2_tab.o - -$(AR) d ffmpeg/libswresample/libswresample.a log2_tab.o -endif - -clean: - rm -f $(addprefix $(SYSDIR)/, $(LIBS)) - for d in $(DIRS); do (if test -f "$$d/Makefile"; then ($(MAKE) -C "$$d" clean); fi ); done - -distclean: - rm -f $(addprefix $(SYSDIR)/, $(LIBS)) - for d in $(DIRS); do (if test -f "$$d/Makefile"; then ($(MAKE) -C "$$d" distclean || $(MAKE) -C "$$d" clean); fi ); done diff --git a/lib/xbmc-dll-symbols/DllAvFormat.c b/lib/xbmc-dll-symbols/DllAvFormat.c deleted file mode 100644 index a592a1ff8d..0000000000 --- a/lib/xbmc-dll-symbols/DllAvFormat.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * various utility functions used within FFmpeg - * Copyright (c) 2000, 2001, 2002 Fabrice Bellard - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Functions defined here are functions that cannot be resolved through the - * ffmpeg shared libraries, yet are used in XBMC. - */ - -#if (defined HAVE_CONFIG_H) && (!defined WIN32) - #include "config.h" -#endif -#if (defined USE_EXTERNAL_FFMPEG) -#include <libavformat/avformat.h> - -/* Taken from libavformat/utils.c */ -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54,0,0) -static void flush_packet_queue(AVFormatContext *s) -{ - AVPacketList *pktl; - - for(;;) { - pktl = s->packet_buffer; - if (!pktl) - break; - s->packet_buffer = pktl->next; - av_free_packet(&pktl->pkt); - av_free(pktl); - } - while(s->raw_packet_buffer){ - pktl = s->raw_packet_buffer; - s->raw_packet_buffer = pktl->next; - av_free_packet(&pktl->pkt); - av_free(pktl); - } - s->packet_buffer_end= - s->raw_packet_buffer_end= NULL; -#ifdef RAW_PACKET_BUFFER_SIZE - // Added on: 2009-06-25 - s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; -#endif -} -#else -static void free_packet_buffer(AVPacketList **pkt_buf, AVPacketList **pkt_buf_end) -{ - while (*pkt_buf) { - AVPacketList *pktl = *pkt_buf; - *pkt_buf = pktl->next; - av_free_packet(&pktl->pkt); - av_freep(&pktl); - } - *pkt_buf_end = NULL; -} -/* XXX: suppress the packet queue */ -static void flush_packet_queue(AVFormatContext *s) -{ - free_packet_buffer(&s->parse_queue, &s->parse_queue_end); - free_packet_buffer(&s->packet_buffer, &s->packet_buffer_end); - free_packet_buffer(&s->raw_packet_buffer, &s->raw_packet_buffer_end); - - s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; -} -#endif - -/* Taken from libavformat/utils.c - * Original name is ff_read_frame_flush - * */ -void xbmc_read_frame_flush(AVFormatContext *s) -{ - AVStream *st; - int i, j; - - flush_packet_queue(s); - -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54,0,0) - s->cur_st = NULL; -#endif - - /* for each stream, reset read state */ - for(i = 0; i < s->nb_streams; i++) { - st = s->streams[i]; - - if (st->parser) { - av_parser_close(st->parser); - st->parser = NULL; -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54,0,0) - av_free_packet(&st->cur_pkt); -#endif - } - st->last_IP_pts = AV_NOPTS_VALUE; -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54,0,0) - st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */ - st->reference_dts = AV_NOPTS_VALUE; - /* fail safe */ - st->cur_ptr = NULL; - st->cur_len = 0; -#else -#define RELATIVE_TS_BASE (INT64_MAX - (1LL<<48)) - if(st->first_dts == AV_NOPTS_VALUE) st->cur_dts = RELATIVE_TS_BASE; - else st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */ -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(55,0,0) - st->reference_dts = AV_NOPTS_VALUE; -#endif - - st->probe_packets = MAX_PROBE_PACKETS; -#endif - - for(j=0; j<MAX_REORDER_DELAY+1; j++) - st->pts_buffer[j]= AV_NOPTS_VALUE; - } -} -#endif /* (defined USE_EXTERNAL_FFMPEG) */ diff --git a/lib/xbmc-dll-symbols/Makefile b/lib/xbmc-dll-symbols/Makefile deleted file mode 100644 index d3e51983b6..0000000000 --- a/lib/xbmc-dll-symbols/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -SRCS = DllAvFormat.c - -LIB = dll-symbols.a - -include ../../Makefile.include --include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS))) diff --git a/lib/xbmc-libav-hacks/Makefile b/lib/xbmc-libav-hacks/Makefile deleted file mode 100644 index ca447d4581..0000000000 --- a/lib/xbmc-libav-hacks/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -SRCS = swresample.c alloc_output_context2.c buffersink.c accessors.c graphparser.c - -LIB = dll-libavhacks.a - -include ../../Makefile.include --include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS))) diff --git a/lib/xbmc-libav-hacks/accessors.c b/lib/xbmc-libav-hacks/accessors.c deleted file mode 100644 index 417bf32ea1..0000000000 --- a/lib/xbmc-libav-hacks/accessors.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "libav_hacks.h" - -AVDictionary *av_frame_get_metadata (const AVFrame *frame) -{ - return NULL; -} - -AVRational av_stream_get_r_frame_rate(const AVStream *s) -{ - AVRational zero; - zero.num = 0; - zero.den = 1; - return zero; -} diff --git a/lib/xbmc-libav-hacks/alloc_output_context2.c b/lib/xbmc-libav-hacks/alloc_output_context2.c deleted file mode 100644 index b0aa5eb4dd..0000000000 --- a/lib/xbmc-libav-hacks/alloc_output_context2.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Code copied from libavformat/mux.c - * - * Original license is: - * - * Copyright (c) 2000, 2001, 2002 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libav_hacks.h" - -#include <libavutil/avstring.h> - -int avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputFormat *oformat, - const char *format, const char *filename) -{ - AVFormatContext *s = avformat_alloc_context(); - int ret = 0; - - *avctx = NULL; - if (!s) - goto nomem; - - if (!oformat) { - if (format) { - oformat = av_guess_format(format, NULL, NULL); - if (!oformat) { - av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format); - ret = AVERROR(EINVAL); - goto error; - } - } else { - oformat = av_guess_format(NULL, filename, NULL); - if (!oformat) { - ret = AVERROR(EINVAL); - av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n", - filename); - goto error; - } - } - } - - s->oformat = oformat; - if (s->oformat->priv_data_size > 0) { - s->priv_data = av_mallocz(s->oformat->priv_data_size); - if (!s->priv_data) - goto nomem; - if (s->oformat->priv_class) { - *(const AVClass**)s->priv_data= s->oformat->priv_class; - av_opt_set_defaults(s->priv_data); - } - } else - s->priv_data = NULL; - - if (filename) - av_strlcpy(s->filename, filename, sizeof(s->filename)); - *avctx = s; - return 0; -nomem: - av_log(s, AV_LOG_ERROR, "Out of memory\n"); - ret = AVERROR(ENOMEM); -error: - avformat_free_context(s); - return ret; -} diff --git a/lib/xbmc-libav-hacks/buffersink.c b/lib/xbmc-libav-hacks/buffersink.c deleted file mode 100644 index e3fdd35e73..0000000000 --- a/lib/xbmc-libav-hacks/buffersink.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Code copied from libavfilter/buffersink.c - * - * Original license is: - * - * Copyright (c) 2011 Stefano Sabatini - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libav_hacks.h" - -AVBufferSinkParams *av_buffersink_params_alloc(void) -{ - static const int pixel_fmts[] = { AV_PIX_FMT_NONE }; - AVBufferSinkParams *params = av_malloc(sizeof(AVBufferSinkParams)); - if (!params) - return NULL; - - params->pixel_fmts = pixel_fmts; - return params; -} diff --git a/lib/xbmc-libav-hacks/graphparser.c b/lib/xbmc-libav-hacks/graphparser.c deleted file mode 100644 index ef52392e4d..0000000000 --- a/lib/xbmc-libav-hacks/graphparser.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copied code from libavfilter/graphparser.c - * - * Original license is: - * - * filter graph parser - * Copyright (c) 2008 Vitor Sessak - * Copyright (c) 2007 Bobby Bingham - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libav_hacks.h" - -#include <libavutil/avstring.h> -#include <libavutil/mem.h> - -#define WHITESPACES " \n\t" - -/** - * Link two filters together. - * - * @see avfilter_link() - */ -static int link_filter(AVFilterContext *src, int srcpad, - AVFilterContext *dst, int dstpad, - void *log_ctx) -{ - int ret; - if ((ret = avfilter_link(src, srcpad, dst, dstpad))) { - av_log(log_ctx, AV_LOG_ERROR, - "Cannot create the link %s:%d -> %s:%d\n", - src->filter->name, srcpad, dst->filter->name, dstpad); - return ret; - } - - return 0; -} - -/** - * Parse the name of a link, which has the format "[linkname]". - * - * @return a pointer (that need to be freed after use) to the name - * between parenthesis - */ -static char *parse_link_name(const char **buf, void *log_ctx) -{ - const char *start = *buf; - char *name; - (*buf)++; - - name = av_get_token(buf, "]"); - - if (!name[0]) { - av_log(log_ctx, AV_LOG_ERROR, - "Bad (empty?) label found in the following: \"%s\".\n", start); - goto fail; - } - - if (*(*buf)++ != ']') { - av_log(log_ctx, AV_LOG_ERROR, - "Mismatched '[' found in the following: \"%s\".\n", start); - fail: - av_freep(&name); - } - - return name; -} - -/** - * Create an instance of a filter, initialize and insert it in the - * filtergraph in *ctx. - * - * @param filt_ctx put here a filter context in case of successful creation and configuration, NULL otherwise. - * @param ctx the filtergraph context - * @param index an index which is supposed to be unique for each filter instance added to the filtergraph - * @param filt_name the name of the filter to create - * @param args the arguments provided to the filter during its initialization - * @param log_ctx the log context to use - * @return 0 in case of success, a negative AVERROR code otherwise - */ -static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index, - const char *filt_name, const char *args, void *log_ctx) -{ - AVFilter *filt; - char inst_name[30]; - char tmp_args[256]; - int ret; - - snprintf(inst_name, sizeof(inst_name), "Parsed_%s_%d", filt_name, index); - - filt = avfilter_get_by_name(filt_name); - - if (!filt) { - av_log(log_ctx, AV_LOG_ERROR, - "No such filter: '%s'\n", filt_name); - return AVERROR(EINVAL); - } - - *filt_ctx = avfilter_graph_alloc_filter(ctx, filt, inst_name); - if (!*filt_ctx) { - av_log(log_ctx, AV_LOG_ERROR, - "Error creating filter '%s'\n", filt_name); - return AVERROR(ENOMEM); - } - - if (!strcmp(filt_name, "scale") && args && !strstr(args, "flags") && - ctx->scale_sws_opts) { - snprintf(tmp_args, sizeof(tmp_args), "%s:%s", - args, ctx->scale_sws_opts); - args = tmp_args; - } - - ret = avfilter_init_str(*filt_ctx, args); - if (ret < 0) { - av_log(log_ctx, AV_LOG_ERROR, - "Error initializing filter '%s'", filt_name); - if (args) - av_log(log_ctx, AV_LOG_ERROR, " with args '%s'", args); - av_log(log_ctx, AV_LOG_ERROR, "\n"); - return ret; - } - - return 0; -} - -/** - * Parse a string of the form FILTER_NAME[=PARAMS], and create a - * corresponding filter instance which is added to graph with - * create_filter(). - * - * @param filt_ctx Pointer that is set to the created and configured filter - * context on success, set to NULL on failure. - * @param filt_ctx put here a pointer to the created filter context on - * success, NULL otherwise - * @param buf pointer to the buffer to parse, *buf will be updated to - * point to the char next after the parsed string - * @param index an index which is assigned to the created filter - * instance, and which is supposed to be unique for each filter - * instance added to the filtergraph - * @return 0 in case of success, a negative AVERROR code otherwise - */ -static int parse_filter(AVFilterContext **filt_ctx, const char **buf, AVFilterGraph *graph, - int index, void *log_ctx) -{ - char *opts = NULL; - char *name = av_get_token(buf, "=,;[\n"); - int ret; - - if (**buf == '=') { - (*buf)++; - opts = av_get_token(buf, "[],;\n"); - } - - ret = create_filter(filt_ctx, graph, index, name, opts, log_ctx); - av_free(name); - av_free(opts); - return ret; -} - -static AVFilterInOut *extract_inout(const char *label, AVFilterInOut **links) -{ - AVFilterInOut *ret; - - while (*links && (!(*links)->name || strcmp((*links)->name, label))) - links = &((*links)->next); - - ret = *links; - - if (ret) { - *links = ret->next; - ret->next = NULL; - } - - return ret; -} - -static void insert_inout(AVFilterInOut **inouts, AVFilterInOut *element) -{ - element->next = *inouts; - *inouts = element; -} - -static void append_inout(AVFilterInOut **inouts, AVFilterInOut **element) -{ - while (*inouts && (*inouts)->next) - inouts = &((*inouts)->next); - - if (!*inouts) - *inouts = *element; - else - (*inouts)->next = *element; - *element = NULL; -} - -static int link_filter_inouts(AVFilterContext *filt_ctx, - AVFilterInOut **curr_inputs, - AVFilterInOut **open_inputs, void *log_ctx) -{ - int pad, ret; - - for (pad = 0; pad < filt_ctx->nb_inputs; pad++) { - AVFilterInOut *p = *curr_inputs; - - if (p) { - *curr_inputs = (*curr_inputs)->next; - p->next = NULL; - } else if (!(p = av_mallocz(sizeof(*p)))) - return AVERROR(ENOMEM); - - if (p->filter_ctx) { - ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx); - av_free(p->name); - av_free(p); - if (ret < 0) - return ret; - } else { - p->filter_ctx = filt_ctx; - p->pad_idx = pad; - append_inout(open_inputs, &p); - } - } - - if (*curr_inputs) { - av_log(log_ctx, AV_LOG_ERROR, - "Too many inputs specified for the \"%s\" filter.\n", - filt_ctx->filter->name); - return AVERROR(EINVAL); - } - - pad = filt_ctx->nb_outputs; - while (pad--) { - AVFilterInOut *currlinkn = av_mallocz(sizeof(AVFilterInOut)); - if (!currlinkn) - return AVERROR(ENOMEM); - currlinkn->filter_ctx = filt_ctx; - currlinkn->pad_idx = pad; - insert_inout(curr_inputs, currlinkn); - } - - return 0; -} - -static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, - AVFilterInOut **open_outputs, void *log_ctx) -{ - AVFilterInOut *parsed_inputs = NULL; - int pad = 0; - - while (**buf == '[') { - char *name = parse_link_name(buf, log_ctx); - AVFilterInOut *match; - - if (!name) - return AVERROR(EINVAL); - - /* First check if the label is not in the open_outputs list */ - match = extract_inout(name, open_outputs); - - if (match) { - av_free(name); - } else { - /* Not in the list, so add it as an input */ - if (!(match = av_mallocz(sizeof(AVFilterInOut)))) { - av_free(name); - return AVERROR(ENOMEM); - } - match->name = name; - match->pad_idx = pad; - } - - append_inout(&parsed_inputs, &match); - - *buf += strspn(*buf, WHITESPACES); - pad++; - } - - append_inout(&parsed_inputs, curr_inputs); - *curr_inputs = parsed_inputs; - - return pad; -} - -static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, - AVFilterInOut **open_inputs, - AVFilterInOut **open_outputs, void *log_ctx) -{ - int ret, pad = 0; - - while (**buf == '[') { - char *name = parse_link_name(buf, log_ctx); - AVFilterInOut *match; - - AVFilterInOut *input = *curr_inputs; - - if (!name) - return AVERROR(EINVAL); - - if (!input) { - av_log(log_ctx, AV_LOG_ERROR, - "No output pad can be associated to link label '%s'.\n", name); - av_free(name); - return AVERROR(EINVAL); - } - *curr_inputs = (*curr_inputs)->next; - - /* First check if the label is not in the open_inputs list */ - match = extract_inout(name, open_inputs); - - if (match) { - if ((ret = link_filter(input->filter_ctx, input->pad_idx, - match->filter_ctx, match->pad_idx, log_ctx)) < 0) { - av_free(name); - return ret; - } - av_free(match->name); - av_free(name); - av_free(match); - av_free(input); - } else { - /* Not in the list, so add the first input as a open_output */ - input->name = name; - insert_inout(open_outputs, input); - } - *buf += strspn(*buf, WHITESPACES); - pad++; - } - - return pad; -} - -static int parse_sws_flags(const char **buf, AVFilterGraph *graph) -{ - char *p = strchr(*buf, ';'); - - if (strncmp(*buf, "sws_flags=", 10)) - return 0; - - if (!p) { - av_log(graph, AV_LOG_ERROR, "sws_flags not terminated with ';'.\n"); - return AVERROR(EINVAL); - } - - *buf += 4; // keep the 'flags=' part - - av_freep(&graph->scale_sws_opts); - if (!(graph->scale_sws_opts = av_mallocz(p - *buf + 1))) - return AVERROR(ENOMEM); - av_strlcpy(graph->scale_sws_opts, *buf, p - *buf + 1); - - *buf = p + 1; - return 0; -} - -int avfilter_graph_parse_ptr(AVFilterGraph *graph, const char *filters, - AVFilterInOut **open_inputs_ptr, AVFilterInOut **open_outputs_ptr, - void *log_ctx) -{ - int index = 0, ret = 0; - char chr = 0; - - AVFilterInOut *curr_inputs = NULL; - AVFilterInOut *open_inputs = open_inputs_ptr ? *open_inputs_ptr : NULL; - AVFilterInOut *open_outputs = open_outputs_ptr ? *open_outputs_ptr : NULL; - - if ((ret = parse_sws_flags(&filters, graph)) < 0) - goto end; - - do { - AVFilterContext *filter; - const char *filterchain = filters; - filters += strspn(filters, WHITESPACES); - - if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0) - goto end; - - if ((ret = parse_filter(&filter, &filters, graph, index, log_ctx)) < 0) - goto end; - - if (filter->input_count == 1 && !curr_inputs && !index) { - /* First input pad, assume it is "[in]" if not specified */ - const char *tmp = "[in]"; - if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0) - goto end; - } - - if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx)) < 0) - goto end; - - if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs, - log_ctx)) < 0) - goto end; - - filters += strspn(filters, WHITESPACES); - chr = *filters++; - - if (chr == ';' && curr_inputs) { - av_log(log_ctx, AV_LOG_ERROR, - "Invalid filterchain containing an unlabelled output pad: \"%s\"\n", - filterchain); - ret = AVERROR(EINVAL); - goto end; - } - index++; - } while (chr == ',' || chr == ';'); - - if (chr) { - av_log(log_ctx, AV_LOG_ERROR, - "Unable to parse graph description substring: \"%s\"\n", - filters - 1); - ret = AVERROR(EINVAL); - goto end; - } - - if (curr_inputs) { - /* Last output pad, assume it is "[out]" if not specified */ - const char *tmp = "[out]"; - if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs, - log_ctx)) < 0) - goto end; - } - -end: - /* clear open_in/outputs only if not passed as parameters */ - if (open_inputs_ptr) *open_inputs_ptr = open_inputs; - else avfilter_inout_free(&open_inputs); - if (open_outputs_ptr) *open_outputs_ptr = open_outputs; - else avfilter_inout_free(&open_outputs); - avfilter_inout_free(&curr_inputs); - - if (ret < 0) { - while (graph->nb_filters) - avfilter_free(graph->filters[0]); - av_freep(&graph->filters); - } - return ret; -} diff --git a/lib/xbmc-libav-hacks/libav_hacks.h b/lib/xbmc-libav-hacks/libav_hacks.h deleted file mode 100644 index f81e29efa9..0000000000 --- a/lib/xbmc-libav-hacks/libav_hacks.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#ifndef __LIBAV_HACKS_H -#define __LIBAV_HACKS_H - -#include <libavutil/avutil.h> -#include <libavutil/opt.h> -#include <libavresample/avresample.h> -#include <libavformat/avformat.h> -#include <libavfilter/avfilter.h> - -#if LIBAVUTIL_VERSION_MICRO >= 100 -#error "You should not enable libav hacks when building against FFmpeg." -#endif - -#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52,8,0) -#error "Your libav version is too old. Please update to libav-10 or git master." -#endif - -// libavutil - -#define AVFRAME_IN_LAVU - -#define AV_CODEC_ID_OTF AV_CODEC_ID_TTF -#define AV_CODEC_ID_SUBRIP AV_CODEC_ID_FIRST_SUBTITLE - -AVDictionary *av_frame_get_metadata (const AVFrame *frame); - -// libavformat - -int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat, - const char *format_name, const char *filename); - -#define AVFORMAT_HAS_STREAM_GET_R_FRAME_RATE - -AVRational av_stream_get_r_frame_rate(const AVStream *s); - -// libavresample - -#define SwrContext AVAudioResampleContext - -struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, - int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, - int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, - int log_offset, void *log_ctx); - -int swr_init(struct SwrContext *s); - -void swr_free(struct SwrContext **s); - -int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, - const uint8_t **in , int in_count); - -int64_t swr_get_delay(struct SwrContext *s, int64_t base); - -int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map); - -int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride); - -int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance); - -// libavfilter - -#define LIBAVFILTER_AVFRAME_BASED - -typedef struct { - const enum AVPixelFormat *pixel_fmts; ///< list of allowed pixel formats, terminated by AV_PIX_FMT_NONE -} AVBufferSinkParams; - -AVBufferSinkParams *av_buffersink_params_alloc(void); - -#define HAVE_AVFILTER_GRAPH_PARSE_PTR - -int avfilter_graph_parse_ptr(AVFilterGraph *graph, const char *filters, - AVFilterInOut **inputs, AVFilterInOut **outputs, - void *log_ctx); - -#endif diff --git a/lib/xbmc-libav-hacks/pkgconfig/libswresample.pc b/lib/xbmc-libav-hacks/pkgconfig/libswresample.pc deleted file mode 100644 index 1319d85ea5..0000000000 --- a/lib/xbmc-libav-hacks/pkgconfig/libswresample.pc +++ /dev/null @@ -1,4 +0,0 @@ -Name: libswresample to libavresample -Version: 0 -Description: Hack to provide libswresample through libavresample -Requires: libavresample diff --git a/lib/xbmc-libav-hacks/swresample.c b/lib/xbmc-libav-hacks/swresample.c deleted file mode 100644 index f674ef7eec..0000000000 --- a/lib/xbmc-libav-hacks/swresample.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "libav_hacks.h" - -#include <libavutil/mathematics.h> -#include <libavutil/opt.h> - -struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, - int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, - int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, - int log_offset, void *log_ctx) -{ - AVAudioResampleContext *ret = avresample_alloc_context(); - av_opt_set_int(ret, "out_channel_layout", out_ch_layout , 0); - av_opt_set_int(ret, "out_sample_fmt" , out_sample_fmt , 0); - av_opt_set_int(ret, "out_sample_rate" , out_sample_rate, 0); - av_opt_set_int(ret, "in_channel_layout" , in_ch_layout , 0); - av_opt_set_int(ret, "in_sample_fmt" , in_sample_fmt , 0); - av_opt_set_int(ret, "in_sample_rate" , in_sample_rate , 0); - return ret; -} - - -int swr_init(struct SwrContext *s) -{ - return avresample_open(s); -} - -void swr_free(struct SwrContext **s) -{ - avresample_close(*s); - *s = NULL; -} - -int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, - const uint8_t **in , int in_count) -{ - return avresample_convert(s, out, 0, out_count, (uint8_t**)in, 0,in_count); -} - -int64_t swr_get_delay(struct SwrContext *s, int64_t base) -{ - int64_t in_sr, out_sr; - av_opt_get_int(s, "in_sample_rate", 0, &in_sr); - av_opt_get_int(s, "out_sample_rate", 0, &out_sr); - return av_rescale_rnd(avresample_available(s), base, out_sr, AV_ROUND_UP) + av_rescale_rnd(avresample_get_delay(s), base, in_sr, AV_ROUND_UP); -} - -int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map) -{ - return avresample_set_channel_mapping(s, channel_map); -} - -int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride) -{ - return avresample_set_matrix(s, matrix, stride); -} - -int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance) -{ - return avresample_set_compensation(s, sample_delta, compensation_distance); -} diff --git a/xbmc/addons/AddonCallbacksCodec.cpp b/xbmc/addons/AddonCallbacksCodec.cpp index 711cc5c6bd..8ae1e4effc 100644 --- a/xbmc/addons/AddonCallbacksCodec.cpp +++ b/xbmc/addons/AddonCallbacksCodec.cpp @@ -21,10 +21,13 @@ #include "Application.h" #include "Addon.h" #include "AddonCallbacksCodec.h" -#include "DllAvCodec.h" -#include "DllAvFormat.h" #include "utils/StringUtils.h" +extern "C" { +#include "libavcodec/avcodec.h" +#include "libavformat/avformat.h" +} + namespace ADDON { class CCodecIds @@ -57,23 +60,12 @@ public: private: CCodecIds(void) { - DllAvCodec dllAvCodec; - DllAvFormat dllAvFormat; - - // load ffmpeg and register formats - if (!dllAvCodec.Load() || !dllAvFormat.Load()) - { - CLog::Log(LOGWARNING, "failed to load ffmpeg"); - return; - } - dllAvFormat.av_register_all(); - // get ids and names AVCodec* codec = NULL; xbmc_codec_t tmp; - while ((codec = dllAvCodec.av_codec_next(codec))) + while ((codec = av_codec_next(codec))) { - if (dllAvCodec.av_codec_is_decoder(codec)) + if (av_codec_is_decoder(codec)) { tmp.codec_type = (xbmc_codec_type_t)codec->type; tmp.codec_id = codec->id; diff --git a/xbmc/cdrip/EncoderFFmpeg.cpp b/xbmc/cdrip/EncoderFFmpeg.cpp index 0f20c5f3ee..c6756e7354 100644 --- a/xbmc/cdrip/EncoderFFmpeg.cpp +++ b/xbmc/cdrip/EncoderFFmpeg.cpp @@ -58,19 +58,15 @@ CEncoderFFmpeg::CEncoderFFmpeg(): bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int iInBits) { - if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load() || !m_dllAvFormat.Load() || !m_dllSwResample.Load()) return false; - m_dllAvFormat.av_register_all(); - m_dllAvCodec.avcodec_register_all(); - CStdString filename = URIUtils::GetFileName(strFile); - if(m_dllAvFormat.avformat_alloc_output_context2(&m_Format,NULL,NULL,filename.c_str())) + if(avformat_alloc_output_context2(&m_Format,NULL,NULL,filename.c_str())) { CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Unable to guess the output format for the file %s", filename.c_str()); return false; } AVCodec *codec; - codec = m_dllAvCodec.avcodec_find_encoder(m_Format->oformat->audio_codec); + codec = avcodec_find_encoder(m_Format->oformat->audio_codec); if (!codec) { @@ -78,10 +74,10 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int return false; } - m_Format->pb = m_dllAvFormat.avio_alloc_context(m_BCBuffer, sizeof(m_BCBuffer), AVIO_FLAG_WRITE, this, NULL, avio_write_callback, avio_seek_callback); + m_Format->pb = avio_alloc_context(m_BCBuffer, sizeof(m_BCBuffer), AVIO_FLAG_WRITE, this, NULL, avio_write_callback, avio_seek_callback); if (!m_Format->pb) { - m_dllAvUtil.av_freep(&m_Format); + av_freep(&m_Format); CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to allocate ByteIOContext"); return false; } @@ -89,11 +85,11 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int m_Format->bit_rate = CSettings::Get().GetInt("audiocds.bitrate") * 1000; /* add a stream to it */ - m_Stream = m_dllAvFormat.avformat_new_stream(m_Format, codec); + m_Stream = avformat_new_stream(m_Format, codec); if (!m_Stream) { - m_dllAvUtil.av_freep(&m_Format->pb); - m_dllAvUtil.av_freep(&m_Format); + av_freep(&m_Format->pb); + av_freep(&m_Format); CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to allocate AVStream context"); return false; } @@ -105,7 +101,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int m_CodecCtx->bit_rate = m_Format->bit_rate; m_CodecCtx->sample_rate = iInRate; m_CodecCtx->channels = iInChannels; - m_CodecCtx->channel_layout = m_dllAvUtil.av_get_default_channel_layout(iInChannels); + m_CodecCtx->channel_layout = av_get_default_channel_layout(iInChannels); m_CodecCtx->time_base.num = 1; m_CodecCtx->time_base.den = iInRate; /* Allow experimental encoders (like FFmpeg builtin AAC encoder) */ @@ -123,9 +119,9 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int case 16: m_InFormat = AV_SAMPLE_FMT_S16; break; case 32: m_InFormat = AV_SAMPLE_FMT_S32; break; default: - m_dllAvUtil.av_freep(&m_Stream); - m_dllAvUtil.av_freep(&m_Format->pb); - m_dllAvUtil.av_freep(&m_Format); + av_freep(&m_Stream); + av_freep(&m_Format->pb); + av_freep(&m_Format); return false; } @@ -134,30 +130,30 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int m_NeedConversion = (m_OutFormat != m_InFormat); - if (m_OutFormat <= AV_SAMPLE_FMT_NONE || m_dllAvCodec.avcodec_open2(m_CodecCtx, codec, NULL)) + if (m_OutFormat <= AV_SAMPLE_FMT_NONE || avcodec_open2(m_CodecCtx, codec, NULL)) { CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to open the codec %s", codec->long_name ? codec->long_name : codec->name); - m_dllAvUtil.av_freep(&m_Stream); - m_dllAvUtil.av_freep(&m_Format->pb); - m_dllAvUtil.av_freep(&m_Format); + av_freep(&m_Stream); + av_freep(&m_Format->pb); + av_freep(&m_Format); return false; } /* calculate how many bytes we need per frame */ m_NeededFrames = m_CodecCtx->frame_size; - m_NeededBytes = m_dllAvUtil.av_samples_get_buffer_size(NULL, iInChannels, m_NeededFrames, m_InFormat, 0); - m_Buffer = (uint8_t*)m_dllAvUtil.av_malloc(m_NeededBytes); + m_NeededBytes = av_samples_get_buffer_size(NULL, iInChannels, m_NeededFrames, m_InFormat, 0); + m_Buffer = (uint8_t*)av_malloc(m_NeededBytes); m_BufferSize = 0; - m_BufferFrame = m_dllAvCodec.avcodec_alloc_frame(); + m_BufferFrame = avcodec_alloc_frame(); if(!m_BufferFrame || !m_Buffer) { CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to allocate necessary buffers"); - if(m_BufferFrame) m_dllAvCodec.avcodec_free_frame(&m_BufferFrame); - if(m_Buffer) m_dllAvUtil.av_freep(&m_Buffer); - m_dllAvUtil.av_freep(&m_Stream); - m_dllAvUtil.av_freep(&m_Format->pb); - m_dllAvUtil.av_freep(&m_Format); + if(m_BufferFrame) avcodec_free_frame(&m_BufferFrame); + if(m_Buffer) av_freep(&m_Buffer); + av_freep(&m_Stream); + av_freep(&m_Format->pb); + av_freep(&m_Format); return false; } @@ -165,59 +161,59 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int m_BufferFrame->format = m_InFormat; m_BufferFrame->channel_layout = m_CodecCtx->channel_layout; - m_dllAvCodec.avcodec_fill_audio_frame(m_BufferFrame, iInChannels, m_InFormat, m_Buffer, m_NeededBytes, 0); + avcodec_fill_audio_frame(m_BufferFrame, iInChannels, m_InFormat, m_Buffer, m_NeededBytes, 0); if(m_NeedConversion) { - m_SwrCtx = m_dllSwResample.swr_alloc_set_opts(NULL, + m_SwrCtx = swr_alloc_set_opts(NULL, m_CodecCtx->channel_layout, m_OutFormat, m_CodecCtx->sample_rate, m_CodecCtx->channel_layout, m_InFormat, m_CodecCtx->sample_rate, 0, NULL); - if(!m_SwrCtx || m_dllSwResample.swr_init(m_SwrCtx) < 0) + if(!m_SwrCtx || swr_init(m_SwrCtx) < 0) { CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to initialize the resampler"); - m_dllAvCodec.avcodec_free_frame(&m_BufferFrame); - m_dllAvUtil.av_freep(&m_Buffer); - m_dllAvUtil.av_freep(&m_Stream); - m_dllAvUtil.av_freep(&m_Format->pb); - m_dllAvUtil.av_freep(&m_Format); + avcodec_free_frame(&m_BufferFrame); + av_freep(&m_Buffer); + av_freep(&m_Stream); + av_freep(&m_Format->pb); + av_freep(&m_Format); return false; } - m_ResampledBufferSize = m_dllAvUtil.av_samples_get_buffer_size(NULL, iInChannels, m_NeededFrames, m_OutFormat, 0); - m_ResampledBuffer = (uint8_t*)m_dllAvUtil.av_malloc(m_ResampledBufferSize); - m_ResampledFrame = m_dllAvCodec.avcodec_alloc_frame(); + m_ResampledBufferSize = av_samples_get_buffer_size(NULL, iInChannels, m_NeededFrames, m_OutFormat, 0); + m_ResampledBuffer = (uint8_t*)av_malloc(m_ResampledBufferSize); + m_ResampledFrame = avcodec_alloc_frame(); if(!m_ResampledBuffer || !m_ResampledFrame) { CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to allocate a frame for resampling"); - if (m_ResampledFrame) m_dllAvCodec.avcodec_free_frame(&m_ResampledFrame); - if (m_ResampledBuffer) m_dllAvUtil.av_freep(&m_ResampledBuffer); - if (m_SwrCtx) m_dllSwResample.swr_free(&m_SwrCtx); - m_dllAvCodec.avcodec_free_frame(&m_BufferFrame); - m_dllAvUtil.av_freep(&m_Buffer); - m_dllAvUtil.av_freep(&m_Stream); - m_dllAvUtil.av_freep(&m_Format->pb); - m_dllAvUtil.av_freep(&m_Format); + if (m_ResampledFrame) avcodec_free_frame(&m_ResampledFrame); + if (m_ResampledBuffer) av_freep(&m_ResampledBuffer); + if (m_SwrCtx) swr_free(&m_SwrCtx); + avcodec_free_frame(&m_BufferFrame); + av_freep(&m_Buffer); + av_freep(&m_Stream); + av_freep(&m_Format->pb); + av_freep(&m_Format); return false; } m_ResampledFrame->nb_samples = m_NeededFrames; m_ResampledFrame->format = m_OutFormat; m_ResampledFrame->channel_layout = m_CodecCtx->channel_layout; - m_dllAvCodec.avcodec_fill_audio_frame(m_ResampledFrame, iInChannels, m_OutFormat, m_ResampledBuffer, m_ResampledBufferSize, 0); + avcodec_fill_audio_frame(m_ResampledFrame, iInChannels, m_OutFormat, m_ResampledBuffer, m_ResampledBufferSize, 0); } /* set input stream information and open the file */ if (!CEncoder::Init(strFile, iInChannels, iInRate, iInBits)) { CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to call CEncoder::Init"); - if (m_ResampledFrame ) m_dllAvCodec.avcodec_free_frame(&m_ResampledFrame); - if (m_ResampledBuffer) m_dllAvUtil.av_freep(&m_ResampledBuffer); - if (m_SwrCtx) m_dllSwResample.swr_free(&m_SwrCtx); - m_dllAvCodec.avcodec_free_frame(&m_BufferFrame); - m_dllAvUtil.av_freep(&m_Buffer); - m_dllAvUtil.av_freep(&m_Stream); - m_dllAvUtil.av_freep(&m_Format->pb); - m_dllAvUtil.av_freep(&m_Format); + if (m_ResampledFrame ) avcodec_free_frame(&m_ResampledFrame); + if (m_ResampledBuffer) av_freep(&m_ResampledBuffer); + if (m_SwrCtx) swr_free(&m_SwrCtx); + avcodec_free_frame(&m_BufferFrame); + av_freep(&m_Buffer); + av_freep(&m_Stream); + av_freep(&m_Format->pb); + av_freep(&m_Format); return false; } @@ -230,17 +226,17 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int SetTag("encoder" , "XBMC FFmpeg Encoder"); /* write the header */ - if (m_dllAvFormat.avformat_write_header(m_Format, NULL) != 0) + if (avformat_write_header(m_Format, NULL) != 0) { CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to write the header"); - if (m_ResampledFrame ) m_dllAvCodec.avcodec_free_frame(&m_ResampledFrame); - if (m_ResampledBuffer) m_dllAvUtil.av_freep(&m_ResampledBuffer); - if (m_SwrCtx) m_dllSwResample.swr_free(&m_SwrCtx); - m_dllAvCodec.avcodec_free_frame(&m_BufferFrame); - m_dllAvUtil.av_freep(&m_Buffer); - m_dllAvUtil.av_freep(&m_Stream); - m_dllAvUtil.av_freep(&m_Format->pb); - m_dllAvUtil.av_freep(&m_Format); + if (m_ResampledFrame ) avcodec_free_frame(&m_ResampledFrame); + if (m_ResampledBuffer) av_freep(&m_ResampledBuffer); + if (m_SwrCtx) swr_free(&m_SwrCtx); + avcodec_free_frame(&m_BufferFrame); + av_freep(&m_Buffer); + av_freep(&m_Stream); + av_freep(&m_Format->pb); + av_freep(&m_Format); return false; } @@ -251,7 +247,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int void CEncoderFFmpeg::SetTag(const CStdString tag, const CStdString value) { - m_dllAvUtil.av_dict_set(&m_Format->metadata, tag.c_str(), value.c_str(), 0); + av_dict_set(&m_Format->metadata, tag.c_str(), value.c_str(), 0); } int CEncoderFFmpeg::avio_write_callback(void *opaque, uint8_t *buf, int buf_size) @@ -296,13 +292,13 @@ bool CEncoderFFmpeg::WriteFrame() int encoded, got_output; AVFrame* frame; - m_dllAvCodec.av_init_packet(&m_Pkt); + av_init_packet(&m_Pkt); m_Pkt.data = NULL; m_Pkt.size = 0; if(m_NeedConversion) { - if (m_dllSwResample.swr_convert(m_SwrCtx, m_ResampledFrame->extended_data, m_NeededFrames, (const uint8_t**)m_BufferFrame->extended_data, m_NeededFrames) < 0) + if (swr_convert(m_SwrCtx, m_ResampledFrame->extended_data, m_NeededFrames, (const uint8_t**)m_BufferFrame->extended_data, m_NeededFrames) < 0) { CLog::Log(LOGERROR, "CEncoderFFmpeg::WriteFrame - Error resampling audio"); return false; @@ -311,7 +307,7 @@ bool CEncoderFFmpeg::WriteFrame() } else frame = m_BufferFrame; - encoded = m_dllAvCodec.avcodec_encode_audio2(m_CodecCtx, &m_Pkt, frame, &got_output); + encoded = avcodec_encode_audio2(m_CodecCtx, &m_Pkt, frame, &got_output); m_BufferSize = 0; @@ -323,15 +319,15 @@ bool CEncoderFFmpeg::WriteFrame() if (got_output) { if (m_CodecCtx->coded_frame && m_CodecCtx->coded_frame->pts != AV_NOPTS_VALUE) - m_Pkt.pts = m_dllAvUtil.av_rescale_q(m_CodecCtx->coded_frame->pts, m_Stream->time_base, m_CodecCtx->time_base); + m_Pkt.pts = av_rescale_q(m_CodecCtx->coded_frame->pts, m_Stream->time_base, m_CodecCtx->time_base); - if (m_dllAvFormat.av_write_frame(m_Format, &m_Pkt) < 0) { + if (av_write_frame(m_Format, &m_Pkt) < 0) { CLog::Log(LOGERROR, "CEncoderFFMmpeg::WriteFrame - Failed to write the frame data"); return false; } } - m_dllAvCodec.av_free_packet(&m_Pkt); + av_free_packet(&m_Pkt); return true; } @@ -348,34 +344,30 @@ bool CEncoderFFmpeg::Close() } /* Flush if needed */ - m_dllAvUtil.av_freep(&m_Buffer); - m_dllAvCodec.avcodec_free_frame(&m_BufferFrame); + av_freep(&m_Buffer); + avcodec_free_frame(&m_BufferFrame); - if (m_SwrCtx) m_dllSwResample.swr_free(&m_SwrCtx); - if (m_ResampledFrame ) m_dllAvCodec.avcodec_free_frame(&m_ResampledFrame); - if (m_ResampledBuffer) m_dllAvUtil.av_freep(&m_ResampledBuffer); + if (m_SwrCtx) swr_free(&m_SwrCtx); + if (m_ResampledFrame ) avcodec_free_frame(&m_ResampledFrame); + if (m_ResampledBuffer) av_freep(&m_ResampledBuffer); m_NeedConversion = false; WriteFrame(); /* write the trailer */ - m_dllAvFormat.av_write_trailer(m_Format); + av_write_trailer(m_Format); FlushStream(); FileClose(); /* cleanup */ - m_dllAvCodec.avcodec_close(m_CodecCtx); - m_dllAvUtil.av_freep(&m_Stream ); - m_dllAvUtil.av_freep(&m_Format->pb); - m_dllAvUtil.av_freep(&m_Format ); + avcodec_close(m_CodecCtx); + av_freep(&m_Stream ); + av_freep(&m_Format->pb); + av_freep(&m_Format ); } m_BufferSize = 0; - m_dllAvFormat.Unload(); - m_dllAvUtil .Unload(); - m_dllAvCodec .Unload(); - m_dllSwResample.Unload(); return true; } diff --git a/xbmc/cdrip/EncoderFFmpeg.h b/xbmc/cdrip/EncoderFFmpeg.h index a16c7e97c1..7155796d1b 100644 --- a/xbmc/cdrip/EncoderFFmpeg.h +++ b/xbmc/cdrip/EncoderFFmpeg.h @@ -22,10 +22,13 @@ */ #include "Encoder.h" -#include "DllAvFormat.h" -#include "DllAvCodec.h" -#include "DllAvUtil.h" -#include "DllSwResample.h" + +extern "C" { +#include "libavformat/avformat.h" +#include "libavcodec/avcodec.h" +#include "libavutil/avutil.h" +#include "libswresample/swresample.h" +} class CEncoderFFmpeg : public CEncoder { @@ -38,10 +41,6 @@ public: void AddTag(int key, const char* value); private: - DllAvCodec m_dllAvCodec; - DllAvUtil m_dllAvUtil; - DllAvFormat m_dllAvFormat; - DllSwResample m_dllSwResample; AVFormatContext *m_Format; AVCodecContext *m_CodecCtx; diff --git a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp index b91ed438c8..5d9e2fb371 100644 --- a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp +++ b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp @@ -46,10 +46,10 @@ CAEEncoderFFmpeg::CAEEncoderFFmpeg(): CAEEncoderFFmpeg::~CAEEncoderFFmpeg() { Reset(); - m_dllAvUtil.av_freep(&m_CodecCtx); - m_dllAvUtil.av_freep(&m_ResampBuffer); + av_freep(&m_CodecCtx); + av_freep(&m_ResampBuffer); if (m_SwrCtx) - m_dllSwResample.swr_free(&m_SwrCtx); + swr_free(&m_SwrCtx); } bool CAEEncoderFFmpeg::IsCompatible(AEAudioFormat format) @@ -102,11 +102,6 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format, bool allow_planar_input { Reset(); - if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load() || !m_dllSwResample.Load()) - return false; - - m_dllAvCodec.avcodec_register_all(); - bool ac3 = CSettings::Get().GetBool("audiooutput.ac3passthrough"); AVCodec *codec = NULL; @@ -119,7 +114,7 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format, bool allow_planar_input m_CodecID = AV_CODEC_ID_DTS; m_PackFunc = &CAEPackIEC61937::PackDTS_1024; m_BitRate = DTS_ENCODE_BITRATE; - codec = m_dllAvCodec.avcodec_find_encoder(m_CodecID); + codec = avcodec_find_encoder(m_CodecID); } #endif @@ -130,14 +125,14 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format, bool allow_planar_input m_CodecID = AV_CODEC_ID_AC3; m_PackFunc = &CAEPackIEC61937::PackAC3; m_BitRate = AC3_ENCODE_BITRATE; - codec = m_dllAvCodec.avcodec_find_encoder(m_CodecID); + codec = avcodec_find_encoder(m_CodecID); } /* check we got the codec */ if (!codec) return false; - m_CodecCtx = m_dllAvCodec.avcodec_alloc_context3(codec); + m_CodecCtx = avcodec_alloc_context3(codec); m_CodecCtx->bit_rate = m_BitRate; m_CodecCtx->sample_rate = format.m_sampleRate; m_CodecCtx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK; @@ -220,9 +215,9 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format, bool allow_planar_input m_CodecCtx->channels = BuildChannelLayout(m_CodecCtx->channel_layout, m_Layout); /* open the codec */ - if (m_dllAvCodec.avcodec_open2(m_CodecCtx, codec, NULL)) + if (avcodec_open2(m_CodecCtx, codec, NULL)) { - m_dllAvUtil.av_freep(&m_CodecCtx); + av_freep(&m_CodecCtx); return false; } @@ -239,11 +234,11 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format, bool allow_planar_input if (m_NeedConversion) { - m_SwrCtx = m_dllSwResample.swr_alloc_set_opts(NULL, + m_SwrCtx = swr_alloc_set_opts(NULL, m_CodecCtx->channel_layout, m_CodecCtx->sample_fmt, m_CodecCtx->sample_rate, m_CodecCtx->channel_layout, AV_SAMPLE_FMT_FLT, m_CodecCtx->sample_rate, 0, NULL); - if (!m_SwrCtx || m_dllSwResample.swr_init(m_SwrCtx) < 0) + if (!m_SwrCtx || swr_init(m_SwrCtx) < 0) { CLog::Log(LOGERROR, "CAEEncoderFFmpeg::Initialize - Failed to initialise resampler."); return false; @@ -284,14 +279,14 @@ int CAEEncoderFFmpeg::Encode(float *data, unsigned int frames) /* size of the buffer sent to the encoder: either from the input data or after * conversion, in all cases it is in the m_CodecCtx->sample_fmt format */ - int buf_size = m_dllAvUtil.av_samples_get_buffer_size(NULL, m_CodecCtx->channels, frames, m_CodecCtx->sample_fmt, 0); + int buf_size = av_samples_get_buffer_size(NULL, m_CodecCtx->channels, frames, m_CodecCtx->sample_fmt, 0); assert(buf_size>0); /* allocate the input frame * sadly, we have to alloc/dealloc it everytime since we have no guarantee the * data argument will be constant over iterated calls and the frame needs to * setup pointers inside data */ - frame = m_dllAvCodec.avcodec_alloc_frame(); + frame = avcodec_alloc_frame(); if (!frame) return 0; @@ -303,43 +298,43 @@ int CAEEncoderFFmpeg::Encode(float *data, unsigned int frames) { if (!m_ResampBuffer || buf_size > m_ResampBufferSize) { - m_ResampBuffer = (uint8_t*)m_dllAvUtil.av_realloc(m_ResampBuffer, buf_size); + m_ResampBuffer = (uint8_t*)av_realloc(m_ResampBuffer, buf_size); if (!m_ResampBuffer) { CLog::Log(LOGERROR, "CAEEncoderFFmpeg::Encode - Failed to allocate %i bytes buffer for resampling", buf_size); - m_dllAvCodec.avcodec_free_frame(&frame); + avcodec_free_frame(&frame); return 0; } m_ResampBufferSize = buf_size; } - m_dllAvCodec.avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt, m_ResampBuffer, buf_size, 0); + avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt, m_ResampBuffer, buf_size, 0); /* important note: the '&input' here works because we convert from a packed * format (ie, interleaved). If it were to be used to convert from planar * formats (ie, non-interleaved, which is not currently supported by AE), * we would need to adapt it or it would segfault. */ - if (m_dllSwResample.swr_convert(m_SwrCtx, frame->extended_data, frames, &input, frames) < 0) + if (swr_convert(m_SwrCtx, frame->extended_data, frames, &input, frames) < 0) { CLog::Log(LOGERROR, "CAEEncoderFFmpeg::Encode - Resampling failed"); - m_dllAvCodec.avcodec_free_frame(&frame); + avcodec_free_frame(&frame); return 0; } } else - m_dllAvCodec.avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt, + avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt, input, buf_size, 0); /* initialize the output packet */ - m_dllAvCodec.av_init_packet(&m_Pkt); + av_init_packet(&m_Pkt); m_Pkt.size = sizeof(m_Buffer) - IEC61937_DATA_OFFSET; m_Pkt.data = m_Buffer + IEC61937_DATA_OFFSET; /* encode it */ - int ret = m_dllAvCodec.avcodec_encode_audio2(m_CodecCtx, &m_Pkt, frame, &got_output); + int ret = avcodec_encode_audio2(m_CodecCtx, &m_Pkt, frame, &got_output); /* free temporary data */ - m_dllAvCodec.avcodec_free_frame(&frame); + avcodec_free_frame(&frame); if (ret < 0 || !got_output) { @@ -356,7 +351,7 @@ int CAEEncoderFFmpeg::Encode(float *data, unsigned int frames) } /* free the packet */ - m_dllAvCodec.av_free_packet(&m_Pkt); + av_free_packet(&m_Pkt); /* return the number of frames used */ return m_NeededFrames; @@ -374,7 +369,7 @@ int CAEEncoderFFmpeg::Encode(uint8_t *in, int in_size, uint8_t *out, int out_siz * sadly, we have to alloc/dealloc it everytime since we have no guarantee the * data argument will be constant over iterated calls and the frame needs to * setup pointers inside data */ - frame = m_dllAvCodec.avcodec_alloc_frame(); + frame = avcodec_alloc_frame(); if (!frame) return 0; @@ -382,19 +377,19 @@ int CAEEncoderFFmpeg::Encode(uint8_t *in, int in_size, uint8_t *out, int out_siz frame->format = m_CodecCtx->sample_fmt; frame->channel_layout = m_CodecCtx->channel_layout; - m_dllAvCodec.avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt, + avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt, in, in_size, 0); /* initialize the output packet */ - m_dllAvCodec.av_init_packet(&m_Pkt); + av_init_packet(&m_Pkt); m_Pkt.size = out_size - IEC61937_DATA_OFFSET; m_Pkt.data = out + IEC61937_DATA_OFFSET; /* encode it */ - int ret = m_dllAvCodec.avcodec_encode_audio2(m_CodecCtx, &m_Pkt, frame, &got_output); + int ret = avcodec_encode_audio2(m_CodecCtx, &m_Pkt, frame, &got_output); /* free temporary data */ - m_dllAvCodec.avcodec_free_frame(&frame); + avcodec_free_frame(&frame); if (ret < 0 || !got_output) { @@ -406,7 +401,7 @@ int CAEEncoderFFmpeg::Encode(uint8_t *in, int in_size, uint8_t *out, int out_siz m_PackFunc(NULL, m_Pkt.size, out); /* free the packet */ - m_dllAvCodec.av_free_packet(&m_Pkt); + av_free_packet(&m_Pkt); /* return the number of frames used */ return m_NeededFrames; diff --git a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.h b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.h index 4fb67c4525..dad3708ba4 100644 --- a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.h +++ b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.h @@ -23,11 +23,12 @@ #include "cores/AudioEngine/Utils/AERemap.h" #include "cores/AudioEngine/Utils/AEPackIEC61937.h" +extern "C" { +#include "libswresample/swresample.h" +} + /* ffmpeg re-defines this, so undef it to squash the warning */ #undef restrict -#include "DllAvCodec.h" -#include "DllAvFormat.h" -#include "DllSwResample.h" class CAEEncoderFFmpeg: public IAEEncoder { @@ -48,11 +49,6 @@ public: virtual int GetData(uint8_t **data); virtual double GetDelay(unsigned int bufferSize); private: - DllAvCodec m_dllAvCodec; - DllAvFormat m_dllAvFormat; - DllAvUtil m_dllAvUtil; - DllSwResample m_dllSwResample; - std::string m_CodecName; AVCodecID m_CodecID; unsigned int m_BitRate; diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp index ca156c8094..7e3a9a4507 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp @@ -178,10 +178,6 @@ void CActiveAE::Dispose() m_controlPort.Purge(); m_dataPort.Purge(); m_sink.Dispose(); - - m_dllAvFormat.Unload(); - m_dllAvCodec.Unload(); - m_dllAvUtil.Unload(); } //----------------------------------------------------------------------------- @@ -2041,7 +2037,7 @@ void CActiveAE::MixSounds(CSoundPacket &dstSample) int available_samples = it->sound->GetSound(false)->nb_samples - it->samples_played; int mix_samples = std::min(max_samples, available_samples); int start = it->samples_played * - m_dllAvUtil.av_get_bytes_per_sample(it->sound->GetSound(false)->config.fmt) * + av_get_bytes_per_sample(it->sound->GetSound(false)->config.fmt) * it->sound->GetSound(false)->config.channels / it->sound->GetSound(false)->planes; @@ -2125,13 +2121,6 @@ void CActiveAE::LoadSettings() bool CActiveAE::Initialize() { - if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load() || !m_dllAvFormat.Load()) - { - CLog::Log(LOGERROR,"CActiveAE::Initialize - failed to load ffmpeg libraries"); - return false; - } - m_dllAvFormat.av_register_all(); - Create(); Message *reply; if (m_controlPort.SendOutMessageSync(CActiveAEControlProtocol::INIT, @@ -2387,19 +2376,19 @@ void CActiveAE::OnAppFocusChange(bool focus) uint8_t **CActiveAE::AllocSoundSample(SampleConfig &config, int &samples, int &bytes_per_sample, int &planes, int &linesize) { uint8_t **buffer; - planes = m_dllAvUtil.av_sample_fmt_is_planar(config.fmt) ? config.channels : 1; + planes = av_sample_fmt_is_planar(config.fmt) ? config.channels : 1; buffer = new uint8_t*[planes]; // align buffer to 16 in order to be compatible with sse in CAEConvert - m_dllAvUtil.av_samples_alloc(buffer, &linesize, config.channels, + av_samples_alloc(buffer, &linesize, config.channels, samples, config.fmt, 16); - bytes_per_sample = m_dllAvUtil.av_get_bytes_per_sample(config.fmt); + bytes_per_sample = av_get_bytes_per_sample(config.fmt); return buffer; } void CActiveAE::FreeSoundSample(uint8_t **data) { - m_dllAvUtil.av_freep(data); + av_freep(data); delete [] data; } @@ -2443,9 +2432,9 @@ IAESound *CActiveAE::MakeSound(const std::string& file) } int fileSize = sound->GetFileSize(); - fmt_ctx = m_dllAvFormat.avformat_alloc_context(); - unsigned char* buffer = (unsigned char*)m_dllAvUtil.av_malloc(SOUNDBUFFER_SIZE+FF_INPUT_BUFFER_PADDING_SIZE); - io_ctx = m_dllAvFormat.avio_alloc_context(buffer, SOUNDBUFFER_SIZE, 0, + fmt_ctx = avformat_alloc_context(); + unsigned char* buffer = (unsigned char*)av_malloc(SOUNDBUFFER_SIZE+FF_INPUT_BUFFER_PADDING_SIZE); + io_ctx = avio_alloc_context(buffer, SOUNDBUFFER_SIZE, 0, sound, CActiveAESound::Read, NULL, CActiveAESound::Seek); io_ctx->max_packet_size = sound->GetChunkSize(); if(io_ctx->max_packet_size) @@ -2456,22 +2445,22 @@ IAESound *CActiveAE::MakeSound(const std::string& file) fmt_ctx->pb = io_ctx; - m_dllAvFormat.av_probe_input_buffer(io_ctx, &io_fmt, file.c_str(), NULL, 0, 0); + av_probe_input_buffer(io_ctx, &io_fmt, file.c_str(), NULL, 0, 0); if (!io_fmt) { - m_dllAvFormat.avformat_close_input(&fmt_ctx); + avformat_close_input(&fmt_ctx); delete sound; return NULL; } // find decoder - if (m_dllAvFormat.avformat_open_input(&fmt_ctx, file.c_str(), NULL, NULL) == 0) + if (avformat_open_input(&fmt_ctx, file.c_str(), NULL, NULL) == 0) { fmt_ctx->flags |= AVFMT_FLAG_NOPARSE; - if (m_dllAvFormat.avformat_find_stream_info(fmt_ctx, NULL) >= 0) + if (avformat_find_stream_info(fmt_ctx, NULL) >= 0) { dec_ctx = fmt_ctx->streams[0]->codec; - dec = m_dllAvCodec.avcodec_find_decoder(dec_ctx->codec_id); + dec = avcodec_find_decoder(dec_ctx->codec_id); config.sample_rate = dec_ctx->sample_rate; config.channels = dec_ctx->channels; config.channel_layout = dec_ctx->channel_layout; @@ -2479,39 +2468,39 @@ IAESound *CActiveAE::MakeSound(const std::string& file) } if (dec == NULL) { - m_dllAvFormat.avformat_close_input(&fmt_ctx); + avformat_close_input(&fmt_ctx); delete sound; return NULL; } - dec_ctx = m_dllAvCodec.avcodec_alloc_context3(dec); + dec_ctx = avcodec_alloc_context3(dec); dec_ctx->sample_rate = config.sample_rate; dec_ctx->channels = config.channels; if (!config.channel_layout) - config.channel_layout = m_dllAvUtil.av_get_default_channel_layout(config.channels); + config.channel_layout = av_get_default_channel_layout(config.channels); dec_ctx->channel_layout = config.channel_layout; AVPacket avpkt; AVFrame *decoded_frame = NULL; - decoded_frame = m_dllAvCodec.avcodec_alloc_frame(); + decoded_frame = avcodec_alloc_frame(); - if (m_dllAvCodec.avcodec_open2(dec_ctx, dec, NULL) >= 0) + if (avcodec_open2(dec_ctx, dec, NULL) >= 0) { bool init = false; // decode until eof - m_dllAvCodec.av_init_packet(&avpkt); + av_init_packet(&avpkt); int len; - while (m_dllAvFormat.av_read_frame(fmt_ctx, &avpkt) >= 0) + while (av_read_frame(fmt_ctx, &avpkt) >= 0) { int got_frame = 0; - len = m_dllAvCodec.avcodec_decode_audio4(dec_ctx, decoded_frame, &got_frame, &avpkt); + len = avcodec_decode_audio4(dec_ctx, decoded_frame, &got_frame, &avpkt); if (len < 0) { - m_dllAvCodec.avcodec_close(dec_ctx); - m_dllAvUtil.av_free(dec_ctx); - m_dllAvUtil.av_free(&decoded_frame); - m_dllAvFormat.avformat_close_input(&fmt_ctx); + avcodec_close(dec_ctx); + av_free(dec_ctx); + av_free(&decoded_frame); + avformat_close_input(&fmt_ctx); delete sound; return NULL; } @@ -2519,7 +2508,7 @@ IAESound *CActiveAE::MakeSound(const std::string& file) { if (!init) { - int samples = fileSize / m_dllAvUtil.av_get_bytes_per_sample(dec_ctx->sample_fmt) / config.channels; + int samples = fileSize / av_get_bytes_per_sample(dec_ctx->sample_fmt) / config.channels; config.fmt = dec_ctx->sample_fmt; config.bits_per_sample = dec_ctx->bits_per_coded_sample; sound->InitSound(true, config, samples); @@ -2529,12 +2518,12 @@ IAESound *CActiveAE::MakeSound(const std::string& file) decoded_frame->nb_samples, decoded_frame->linesize[0]); } } - m_dllAvCodec.avcodec_close(dec_ctx); + avcodec_close(dec_ctx); } - m_dllAvUtil.av_free(dec_ctx); - m_dllAvUtil.av_free(decoded_frame); - m_dllAvFormat.avformat_close_input(&fmt_ctx); + av_free(dec_ctx); + av_free(decoded_frame); + avformat_close_input(&fmt_ctx); sound->Finish(); diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h index 85966171d2..700098b257 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h @@ -31,9 +31,11 @@ #include <queue> // ffmpeg -#include "DllAvFormat.h" -#include "DllAvCodec.h" -#include "DllAvUtil.h" +extern "C" { +#include "libavformat/avformat.h" +#include "libavcodec/avcodec.h" +#include "libavutil/avutil.h" +} class IAESink; class IAEEncoder; @@ -347,11 +349,6 @@ protected: bool m_vizInitialized; CCriticalSection m_vizLock; - // ffmpeg - DllAvFormat m_dllAvFormat; - DllAvCodec m_dllAvCodec; - DllAvUtil m_dllAvUtil; - // polled via the interface float m_aeVolume; bool m_aeMuted; diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.h b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.h index 58205a4162..f8d0ba009e 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.h +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.h @@ -19,12 +19,15 @@ * */ -#include "DllAvUtil.h" -#include "DllSwResample.h" #include "cores/AudioEngine/Utils/AEAudioFormat.h" #include "cores/AudioEngine/Interfaces/AE.h" #include <deque> +extern "C" { +#include "libavutil/avutil.h" +#include "libswresample/swresample.h" +} + namespace ActiveAE { diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.cpp index e131f16916..6478f3a308 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.cpp @@ -19,24 +19,26 @@ */ #include "ActiveAEResample.h" +#include "utils/log.h" + +extern "C" { +#include "libavutil/channel_layout.h" +#include "libavutil/opt.h" +#include "libswresample/swresample.h" +} using namespace ActiveAE; CActiveAEResample::CActiveAEResample() { m_pContext = NULL; - m_loaded = false; - if (m_dllAvUtil.Load() && m_dllSwResample.Load()) - m_loaded = true; + m_loaded = true; } CActiveAEResample::~CActiveAEResample() { if (m_pContext) - m_dllSwResample.swr_free(&m_pContext); - - m_dllAvUtil.Unload(); - m_dllSwResample.Unload(); + swr_free(&m_pContext); } bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, bool upmix, bool normalize, CAEChannelInfo *remapLayout, AEQuality quality) @@ -56,11 +58,11 @@ bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst m_src_bits = src_bits; if (m_dst_chan_layout == 0) - m_dst_chan_layout = m_dllAvUtil.av_get_default_channel_layout(m_dst_channels); + m_dst_chan_layout = av_get_default_channel_layout(m_dst_channels); if (m_src_chan_layout == 0) - m_src_chan_layout = m_dllAvUtil.av_get_default_channel_layout(m_src_channels); + m_src_chan_layout = av_get_default_channel_layout(m_src_channels); - m_pContext = m_dllSwResample.swr_alloc_set_opts(NULL, m_dst_chan_layout, m_dst_fmt, m_dst_rate, + m_pContext = swr_alloc_set_opts(NULL, m_dst_chan_layout, m_dst_fmt, m_dst_rate, m_src_chan_layout, m_src_fmt, m_src_rate, 0, NULL); @@ -72,24 +74,24 @@ bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst if(quality == AE_QUALITY_HIGH) { - m_dllAvUtil.av_opt_set_double(m_pContext, "cutoff", 1.0, 0); - m_dllAvUtil.av_opt_set_int(m_pContext,"filter_size", 256, 0); + av_opt_set_double(m_pContext, "cutoff", 1.0, 0); + av_opt_set_int(m_pContext,"filter_size", 256, 0); } else if(quality == AE_QUALITY_MID) { // 0.97 is default cutoff so use (1.0 - 0.97) / 2.0 + 0.97 - m_dllAvUtil.av_opt_set_double(m_pContext, "cutoff", 0.985, 0); - m_dllAvUtil.av_opt_set_int(m_pContext,"filter_size", 64, 0); + av_opt_set_double(m_pContext, "cutoff", 0.985, 0); + av_opt_set_int(m_pContext,"filter_size", 64, 0); } else if(quality == AE_QUALITY_LOW) { - m_dllAvUtil.av_opt_set_double(m_pContext, "cutoff", 0.97, 0); - m_dllAvUtil.av_opt_set_int(m_pContext,"filter_size", 32, 0); + av_opt_set_double(m_pContext, "cutoff", 0.97, 0); + av_opt_set_int(m_pContext,"filter_size", 32, 0); } if (m_dst_fmt == AV_SAMPLE_FMT_S32 || m_dst_fmt == AV_SAMPLE_FMT_S32P) { - m_dllAvUtil.av_opt_set_int(m_pContext, "output_sample_bits", m_dst_bits, 0); + av_opt_set_int(m_pContext, "output_sample_bits", m_dst_bits, 0); } // tell resampler to clamp float values @@ -98,7 +100,7 @@ bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst (m_src_fmt == AV_SAMPLE_FMT_FLT || m_src_fmt == AV_SAMPLE_FMT_FLTP) && !remapLayout && normalize) { - m_dllAvUtil.av_opt_set_double(m_pContext, "rematrix_maxval", 1.0, 0); + av_opt_set_double(m_pContext, "rematrix_maxval", 1.0, 0); } if (remapLayout) @@ -118,10 +120,10 @@ bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst } } - m_dllAvUtil.av_opt_set_int(m_pContext, "out_channel_count", m_dst_channels, 0); - m_dllAvUtil.av_opt_set_int(m_pContext, "out_channel_layout", m_dst_chan_layout, 0); + av_opt_set_int(m_pContext, "out_channel_count", m_dst_channels, 0); + av_opt_set_int(m_pContext, "out_channel_layout", m_dst_chan_layout, 0); - if (m_dllSwResample.swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0) + if (swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0) { CLog::Log(LOGERROR, "CActiveAEResample::Init - setting channel matrix failed"); return false; @@ -133,7 +135,7 @@ bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst memset(m_rematrix, 0, sizeof(m_rematrix)); for (int out=0; out<m_dst_channels; out++) { - uint64_t out_chan = m_dllAvUtil.av_channel_layout_extract_channel(m_dst_chan_layout, out); + uint64_t out_chan = av_channel_layout_extract_channel(m_dst_chan_layout, out); switch(out_chan) { case AV_CH_FRONT_LEFT: @@ -159,14 +161,14 @@ bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst } } - if (m_dllSwResample.swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0) + if (swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0) { CLog::Log(LOGERROR, "CActiveAEResample::Init - setting channel matrix failed"); return false; } } - if(m_dllSwResample.swr_init(m_pContext) < 0) + if(swr_init(m_pContext) < 0) { CLog::Log(LOGERROR, "CActiveAEResample::Init - init resampler failed"); return false; @@ -178,7 +180,7 @@ int CActiveAEResample::Resample(uint8_t **dst_buffer, int dst_samples, uint8_t * { if (ratio != 1.0) { - if (m_dllSwResample.swr_set_compensation(m_pContext, + if (swr_set_compensation(m_pContext, (dst_samples*ratio-dst_samples)*m_dst_rate/m_src_rate, dst_samples*m_dst_rate/m_src_rate) < 0) { @@ -187,7 +189,7 @@ int CActiveAEResample::Resample(uint8_t **dst_buffer, int dst_samples, uint8_t * } } - int ret = m_dllSwResample.swr_convert(m_pContext, dst_buffer, dst_samples, (const uint8_t**)src_buffer, src_samples); + int ret = swr_convert(m_pContext, dst_buffer, dst_samples, (const uint8_t**)src_buffer, src_samples); if (ret < 0) { CLog::Log(LOGERROR, "CActiveAEResample::Resample - resample failed"); @@ -198,28 +200,28 @@ int CActiveAEResample::Resample(uint8_t **dst_buffer, int dst_samples, uint8_t * int64_t CActiveAEResample::GetDelay(int64_t base) { - return m_dllSwResample.swr_get_delay(m_pContext, base); + return swr_get_delay(m_pContext, base); } int CActiveAEResample::GetBufferedSamples() { - return m_dllAvUtil.av_rescale_rnd(m_dllSwResample.swr_get_delay(m_pContext, m_src_rate), + return av_rescale_rnd(swr_get_delay(m_pContext, m_src_rate), m_dst_rate, m_src_rate, AV_ROUND_UP); } int CActiveAEResample::CalcDstSampleCount(int src_samples, int dst_rate, int src_rate) { - return m_dllAvUtil.av_rescale_rnd(src_samples, dst_rate, src_rate, AV_ROUND_UP); + return av_rescale_rnd(src_samples, dst_rate, src_rate, AV_ROUND_UP); } int CActiveAEResample::GetSrcBufferSize(int samples) { - return m_dllAvUtil.av_samples_get_buffer_size(NULL, m_src_channels, samples, m_src_fmt, 1); + return av_samples_get_buffer_size(NULL, m_src_channels, samples, m_src_fmt, 1); } int CActiveAEResample::GetDstBufferSize(int samples) { - return m_dllAvUtil.av_samples_get_buffer_size(NULL, m_dst_channels, samples, m_dst_fmt, 1); + return av_samples_get_buffer_size(NULL, m_dst_channels, samples, m_dst_fmt, 1); } uint64_t CActiveAEResample::GetAVChannelLayout(CAEChannelInfo &info) @@ -342,5 +344,5 @@ uint64_t CActiveAEResample::GetAVChannel(enum AEChannel aechannel) int CActiveAEResample::GetAVChannelIndex(enum AEChannel aechannel, uint64_t layout) { - return m_dllAvUtil.av_get_channel_layout_channel_index(layout, GetAVChannel(aechannel)); + return av_get_channel_layout_channel_index(layout, GetAVChannel(aechannel)); } diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.h b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.h index 1e0e3426c7..9c89b1b15e 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.h +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.h @@ -19,13 +19,16 @@ * */ -#include "DllAvUtil.h" -#include "DllSwResample.h" #include "cores/AudioEngine/Utils/AEChannelInfo.h" #include "cores/AudioEngine/Utils/AEAudioFormat.h" #include "cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.h" #include "cores/AudioEngine/Interfaces/AE.h" +extern "C" { +#include "libavutil/avutil.h" +#include "libswresample/swresample.h" +} + namespace ActiveAE { @@ -49,8 +52,6 @@ public: int GetAVChannelIndex(enum AEChannel aechannel, uint64_t layout); protected: - DllAvUtil m_dllAvUtil; - DllSwResample m_dllSwResample; bool m_loaded; uint64_t m_src_chan_layout, m_dst_chan_layout; int m_src_rate, m_dst_rate; diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESound.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESound.cpp index b8805d3043..e3ca256856 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESound.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESound.cpp @@ -25,7 +25,10 @@ #include "ActiveAE.h" #include "ActiveAESound.h" #include "utils/log.h" -#include "DllAvUtil.h" + +extern "C" { +#include "libavutil/avutil.h" +} using namespace ActiveAE; using namespace XFILE; @@ -151,7 +154,7 @@ int CActiveAESound::Read(void *h, uint8_t* buf, int size) return pFile->Read(buf, size); } -offset_t CActiveAESound::Seek(void *h, offset_t pos, int whence) +int64_t CActiveAESound::Seek(void *h, int64_t pos, int whence) { CFile* pFile = static_cast<CActiveAESound*>(h)->m_pFile; if(whence == AVSEEK_SIZE) diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESound.h b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESound.h index 75227ab4a2..9324e1ecab 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESound.h +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESound.h @@ -56,7 +56,7 @@ public: bool IsSeekPosible() { return m_isSeekPosible; } static int Read(void *h, uint8_t* buf, int size); - static offset_t Seek(void *h, offset_t pos, int whence); + static int64_t Seek(void *h, int64_t pos, int whence); protected: std::string m_filename; diff --git a/xbmc/cores/AudioEngine/Interfaces/AEEncoder.h b/xbmc/cores/AudioEngine/Interfaces/AEEncoder.h index 7a9cf99170..d070d36a95 100644 --- a/xbmc/cores/AudioEngine/Interfaces/AEEncoder.h +++ b/xbmc/cores/AudioEngine/Interfaces/AEEncoder.h @@ -19,9 +19,12 @@ * */ -#include "DllAvCodec.h" #include "cores/AudioEngine/Utils/AEAudioFormat.h" +extern "C" { +#include "libavcodec/avcodec.h" +} + /** * IAEEncoder interface for on the fly audio compression */ diff --git a/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp b/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp index f0babde136..08e375bd4f 100644 --- a/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp +++ b/xbmc/cores/AudioEngine/Utils/AEStreamInfo.cpp @@ -19,6 +19,7 @@ */ #include "AEStreamInfo.h" +#include "utils/log.h" #define IEC61937_PREAMBLE1 0xF872 #define IEC61937_PREAMBLE2 0x4E1F @@ -85,13 +86,11 @@ CAEStreamInfo::CAEStreamInfo() : m_dataIsLE (false), m_packFunc (NULL) { - m_dllAvUtil.Load(); - m_dllAvUtil.av_crc_init(m_crcTrueHD, 0, 16, 0x2D, sizeof(m_crcTrueHD)); + av_crc_init(m_crcTrueHD, 0, 16, 0x2D, sizeof(m_crcTrueHD)); } CAEStreamInfo::~CAEStreamInfo() { - m_dllAvUtil.Unload(); } int CAEStreamInfo::AddData(uint8_t *data, unsigned int size, uint8_t **buffer/* = NULL */, unsigned int *bufferSize/* = 0 */) @@ -360,7 +359,7 @@ unsigned int CAEStreamInfo::SyncAC3(uint8_t *data, unsigned int size) crc_size = (framesize >> 1) + (framesize >> 3) - 1; if (crc_size <= size - skip) - if (m_dllAvUtil.av_crc(m_dllAvUtil.av_crc_get_table(AV_CRC_16_ANSI), 0, &data[2], crc_size * 2)) + if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &data[2], crc_size * 2)) continue; /* if we get here, we can sync */ @@ -668,7 +667,7 @@ unsigned int CAEStreamInfo::SyncTrueHD(uint8_t *data, unsigned int size) continue; /* verify the crc of the audio unit */ - uint16_t crc = m_dllAvUtil.av_crc(m_crcTrueHD, 0, data + 4, 24); + uint16_t crc = av_crc(m_crcTrueHD, 0, data + 4, 24); crc ^= (data[29] << 8) | data[28]; if (((data[31] << 8) | data[30]) != crc) continue; diff --git a/xbmc/cores/AudioEngine/Utils/AEStreamInfo.h b/xbmc/cores/AudioEngine/Utils/AEStreamInfo.h index 4d7bcddd6e..8fadab0d88 100644 --- a/xbmc/cores/AudioEngine/Utils/AEStreamInfo.h +++ b/xbmc/cores/AudioEngine/Utils/AEStreamInfo.h @@ -26,8 +26,12 @@ /* ffmpeg re-defines this, so undef it to squash the warning */ #undef restrict -#include "DllAvCodec.h" -#include "DllAvFormat.h" + +extern "C" { +#include "libavcodec/avcodec.h" +#include "libavformat/avformat.h" +#include "libavutil/crc.h" +} class CAEStreamInfo { @@ -67,8 +71,6 @@ public: CAEPackIEC61937::PackFunc GetPackFunc () { return m_packFunc ; } unsigned int GetBufferSize () { return m_bufferSize ; } private: - DllAvUtil m_dllAvUtil; - uint8_t m_buffer[MAX_IEC61937_PACKET]; unsigned int m_bufferSize; unsigned int m_skipBytes; diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp index 3b9851df9e..73eb193fc0 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp @@ -40,7 +40,6 @@ #include "guilib/Texture.h" #include "guilib/LocalizeStrings.h" #include "threads/SingleLock.h" -#include "DllSwScale.h" #include "utils/log.h" #include "utils/GLUtils.h" #include "utils/StringUtils.h" @@ -48,6 +47,11 @@ #include "RenderFormats.h" #include "cores/IPlayer.h" #include "cores/dvdplayer/DVDCodecs/DVDCodecUtils.h" +#include "cores/FFmpeg.h" + +extern "C" { +#include "libswscale/swscale.h" +} #ifdef HAVE_LIBVDPAU #include "cores/dvdplayer/DVDCodecs/Video/VDPAU.h" @@ -191,8 +195,6 @@ CLinuxRendererGL::CLinuxRendererGL() m_nonLinStretch = false; m_nonLinStretchGui = false; m_pixelRatio = 0.0f; - - m_dllSwScale = new DllSwScale; } CLinuxRendererGL::~CLinuxRendererGL() @@ -213,7 +215,7 @@ CLinuxRendererGL::~CLinuxRendererGL() if (m_context) { - m_dllSwScale->sws_freeContext(m_context); + sws_freeContext(m_context); m_context = NULL; } @@ -223,8 +225,6 @@ CLinuxRendererGL::~CLinuxRendererGL() delete m_pYUVShader; m_pYUVShader = NULL; } - - delete m_dllSwScale; } bool CLinuxRendererGL::ValidateRenderer() @@ -779,9 +779,6 @@ unsigned int CLinuxRendererGL::PreInit() // setup the background colour m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff; - if (!m_dllSwScale->Load()) - CLog::Log(LOGERROR,"CLinuxRendererGL::PreInit - failed to load rescale libraries!"); - return true; } @@ -1131,7 +1128,7 @@ void CLinuxRendererGL::UnInit() if (m_context) { - m_dllSwScale->sws_freeContext(m_context); + sws_freeContext(m_context); m_context = NULL; } @@ -3159,14 +3156,14 @@ void CLinuxRendererGL::ToRGBFrame(YV12Image* im, unsigned flipIndexPlane, unsign m_rgbBuffer = (BYTE*)glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB) + PBO_OFFSET; } - m_context = m_dllSwScale->sws_getCachedContext(m_context, - im->width, im->height, srcFormat, - im->width, im->height, PIX_FMT_BGRA, + m_context = sws_getCachedContext(m_context, + im->width, im->height, (AVPixelFormat)srcFormat, + im->width, im->height, (AVPixelFormat)PIX_FMT_BGRA, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL); uint8_t *dst[] = { m_rgbBuffer, 0, 0, 0 }; int dstStride[] = { (int)m_sourceWidth * 4, 0, 0, 0 }; - m_dllSwScale->sws_scale(m_context, src, srcStride, 0, im->height, dst, dstStride); + sws_scale(m_context, src, srcStride, 0, im->height, dst, dstStride); if (m_rgbPbo) { @@ -3239,9 +3236,9 @@ void CLinuxRendererGL::ToRGBFields(YV12Image* im, unsigned flipIndexPlaneTop, un m_rgbBuffer = (BYTE*)glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB) + PBO_OFFSET; } - m_context = m_dllSwScale->sws_getCachedContext(m_context, - im->width, im->height >> 1, srcFormat, - im->width, im->height >> 1, PIX_FMT_BGRA, + m_context = sws_getCachedContext(m_context, + im->width, im->height >> 1, (AVPixelFormat)srcFormat, + im->width, im->height >> 1, (AVPixelFormat)PIX_FMT_BGRA, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL); uint8_t *dstTop[] = { m_rgbBuffer, 0, 0, 0 }; uint8_t *dstBot[] = { m_rgbBuffer + m_sourceWidth * m_sourceHeight * 2, 0, 0, 0 }; @@ -3249,8 +3246,8 @@ void CLinuxRendererGL::ToRGBFields(YV12Image* im, unsigned flipIndexPlaneTop, un //convert each YUV field to an RGB field, the top field is placed at the top of the rgb buffer //the bottom field is placed at the bottom of the rgb buffer - m_dllSwScale->sws_scale(m_context, srcTop, srcStrideTop, 0, im->height >> 1, dstTop, dstStride); - m_dllSwScale->sws_scale(m_context, srcBot, srcStrideBot, 0, im->height >> 1, dstBot, dstStride); + sws_scale(m_context, srcTop, srcStrideTop, 0, im->height >> 1, dstTop, dstStride); + sws_scale(m_context, srcBot, srcStrideBot, 0, im->height >> 1, dstBot, dstStride); if (m_rgbPbo) { diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.h b/xbmc/cores/VideoRenderers/LinuxRendererGL.h index 63ea287f18..304017f127 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGL.h +++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.h @@ -112,8 +112,6 @@ extern YUVCOEF yuv_coef_bt709; extern YUVCOEF yuv_coef_ebu; extern YUVCOEF yuv_coef_smtp240m; -class DllSwScale; - class CLinuxRendererGL : public CBaseRenderer { public: @@ -312,7 +310,6 @@ protected: float m_clearColour; // software scale library (fallback if required gl version is not available) - DllSwScale *m_dllSwScale; BYTE *m_rgbBuffer; // if software scale is used, this will hold the result image unsigned int m_rgbBufferSize; GLuint m_rgbPbo; diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp index 30c06016a2..72eb725a5a 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp @@ -34,6 +34,7 @@ #include "utils/fastmemcpy.h" #include "utils/MathUtils.h" #include "utils/GLUtils.h" +#include "utils/log.h" #include "settings/AdvancedSettings.h" #include "settings/DisplaySettings.h" #include "settings/MediaSettings.h" @@ -43,7 +44,6 @@ #include "VideoShaders/VideoFilterShader.h" #include "windowing/WindowingFactory.h" #include "guilib/Texture.h" -#include "lib/DllSwScale.h" #include "../dvdplayer/DVDCodecs/Video/OpenMaxVideo.h" #include "threads/SingleLock.h" #include "RenderCapture.h" @@ -51,6 +51,10 @@ #include "xbmc/Application.h" #include "cores/IPlayer.h" +extern "C" { +#include "libswscale/swscale.h" +} + #if defined(__ARM_NEON__) #include "yuv2rgb.neon.h" #include "utils/CPUInfo.h" @@ -132,7 +136,6 @@ CLinuxRendererGLES::CLinuxRendererGLES() m_rgbBuffer = NULL; m_rgbBufferSize = 0; - m_dllSwScale = new DllSwScale; m_sw_context = NULL; m_NumYV12Buffers = 0; m_iLastRenderBuffer = 0; @@ -167,8 +170,6 @@ CLinuxRendererGLES::~CLinuxRendererGLES() delete m_pYUVShader; m_pYUVShader = NULL; } - - delete m_dllSwScale; } bool CLinuxRendererGLES::ValidateRenderTarget() @@ -607,9 +608,6 @@ unsigned int CLinuxRendererGLES::PreInit() // setup the background colour m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff; - if (!m_dllSwScale->Load()) - CLog::Log(LOGERROR,"CLinuxRendererGL::PreInit - failed to load rescale libraries!"); - return true; } @@ -837,9 +835,9 @@ void CLinuxRendererGLES::UnInit() for (int i = 0; i < NUM_BUFFERS; ++i) (this->*m_textureDelete)(i); - if (m_dllSwScale && m_sw_context) + if (m_sw_context) { - m_dllSwScale->sws_freeContext(m_sw_context); + sws_freeContext(m_sw_context); m_sw_context = NULL; } @@ -1684,7 +1682,7 @@ void CLinuxRendererGLES::UploadYV12Texture(int source) else #endif { - m_sw_context = m_dllSwScale->sws_getCachedContext(m_sw_context, + m_sw_context = sws_getCachedContext(m_sw_context, im->width, im->height, PIX_FMT_YUV420P, im->width, im->height, PIX_FMT_RGBA, SWS_FAST_BILINEAR, NULL, NULL, NULL); @@ -1693,7 +1691,7 @@ void CLinuxRendererGLES::UploadYV12Texture(int source) int srcStride[] = { im->stride[0], im->stride[1], im->stride[2], 0 }; uint8_t *dst[] = { m_rgbBuffer, 0, 0, 0 }; int dstStride[] = { m_sourceWidth*4, 0, 0, 0 }; - m_dllSwScale->sws_scale(m_sw_context, src, srcStride, 0, im->height, dst, dstStride); + sws_scale(m_sw_context, src, srcStride, 0, im->height, dst, dstStride); } } diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.h b/xbmc/cores/VideoRenderers/LinuxRendererGLES.h index 45e9c204a1..642cded0f0 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.h +++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.h @@ -115,9 +115,6 @@ extern YUVCOEF yuv_coef_bt709; extern YUVCOEF yuv_coef_ebu; extern YUVCOEF yuv_coef_smtp240m; -class DllSwScale; -struct SwsContext; - class CEvent; class CLinuxRendererGLES : public CBaseRenderer @@ -314,7 +311,6 @@ protected: float m_clearColour; // software scale libraries (fallback if required gl version is not available) - DllSwScale *m_dllSwScale; struct SwsContext *m_sw_context; BYTE *m_rgbBuffer; // if software scale is used, this will hold the result image unsigned int m_rgbBufferSize; diff --git a/xbmc/cores/VideoRenderers/WinRenderer.cpp b/xbmc/cores/VideoRenderers/WinRenderer.cpp index 48794a7f49..7e82dd4622 100644 --- a/xbmc/cores/VideoRenderers/WinRenderer.cpp +++ b/xbmc/cores/VideoRenderers/WinRenderer.cpp @@ -20,7 +20,7 @@ #ifdef HAS_DX -#include "DllSwScale.h" +#include "libswscale/swscale.h" #include "Util.h" #include "WinRenderer.h" #include "cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h" diff --git a/xbmc/cores/VideoRenderers/WinRenderer.h b/xbmc/cores/VideoRenderers/WinRenderer.h index 7486464dbc..63eb3cd81f 100644 --- a/xbmc/cores/VideoRenderers/WinRenderer.h +++ b/xbmc/cores/VideoRenderers/WinRenderer.h @@ -208,9 +208,6 @@ protected: std::vector<ERenderFormat> m_formats; // software scale libraries (fallback if required pixel shaders version is not available) - DllAvUtil *m_dllAvUtil; - DllAvCodec *m_dllAvCodec; - DllSwScale *m_dllSwScale; struct SwsContext *m_sw_scale_ctx; // Software rendering diff --git a/xbmc/cores/dvdplayer/DVDAudio.h b/xbmc/cores/dvdplayer/DVDAudio.h index 4328fc34e3..4e223838f7 100644 --- a/xbmc/cores/dvdplayer/DVDAudio.h +++ b/xbmc/cores/dvdplayer/DVDAudio.h @@ -30,7 +30,9 @@ #include "cores/AudioEngine/Utils/AEChannelInfo.h" class IAEStream; -#include "DllAvCodec.h" +extern "C" { +#include "libavcodec/avcodec.h" +} typedef struct stDVDAudioFrame DVDAudioFrame; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodec.h index 08839ee01c..baadb7921a 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodec.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodec.h @@ -30,7 +30,10 @@ #include "config.h" #endif #include <vector> -#include "DllAvCodec.h" + +extern "C" { +#include "libavcodec/avcodec.h" +} struct AVStream; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp index af897fec16..aeb3995ffa 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp @@ -59,19 +59,14 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options AVCodec* pCodec; m_bOpenedCodec = false; - if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load() || !m_dllSwResample.Load()) - return false; - - m_dllAvCodec.avcodec_register_all(); - - pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec); + pCodec = avcodec_find_decoder(hints.codec); if (!pCodec) { CLog::Log(LOGDEBUG,"CDVDAudioCodecFFmpeg::Open() Unable to find codec %d", hints.codec); return false; } - m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec); + m_pCodecContext = avcodec_alloc_context3(pCodec); m_pCodecContext->debug_mv = 0; m_pCodecContext->debug = 0; m_pCodecContext->workaround_bugs = 1; @@ -91,7 +86,7 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options if( hints.extradata && hints.extrasize > 0 ) { - m_pCodecContext->extradata = (uint8_t*)m_dllAvUtil.av_mallocz(hints.extrasize + FF_INPUT_BUFFER_PADDING_SIZE); + m_pCodecContext->extradata = (uint8_t*)av_mallocz(hints.extrasize + FF_INPUT_BUFFER_PADDING_SIZE); if(m_pCodecContext->extradata) { m_pCodecContext->extradata_size = hints.extrasize; @@ -99,14 +94,14 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options } } - if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) + if (avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) { CLog::Log(LOGDEBUG,"CDVDAudioCodecFFmpeg::Open() Unable to open codec"); Dispose(); return false; } - m_pFrame1 = m_dllAvCodec.avcodec_alloc_frame(); + m_pFrame1 = avcodec_alloc_frame(); m_bOpenedCodec = true; m_iSampleFormat = AV_SAMPLE_FMT_NONE; @@ -115,27 +110,23 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options void CDVDAudioCodecFFmpeg::Dispose() { - if (m_pFrame1) m_dllAvUtil.av_free(m_pFrame1); + if (m_pFrame1) av_free(m_pFrame1); m_pFrame1 = NULL; if (m_pConvert) - m_dllSwResample.swr_free(&m_pConvert); + swr_free(&m_pConvert); if (m_pBuffer2) - m_dllAvUtil.av_freep(&m_pBuffer2); + av_freep(&m_pBuffer2); if (m_pCodecContext) { - if (m_bOpenedCodec) m_dllAvCodec.avcodec_close(m_pCodecContext); + if (m_bOpenedCodec) avcodec_close(m_pCodecContext); m_bOpenedCodec = false; - m_dllAvUtil.av_free(m_pCodecContext); + av_free(m_pCodecContext); m_pCodecContext = NULL; } - m_dllAvCodec.Unload(); - m_dllAvUtil.Unload(); - m_dllSwResample.Unload(); - m_iBufferSize1 = 0; m_iBufferSize2 = 0; m_iBufferTotalSize2 = 0; @@ -150,10 +141,10 @@ int CDVDAudioCodecFFmpeg::Decode(uint8_t* pData, int iSize) m_iBufferSize2 = 0; AVPacket avpkt; - m_dllAvCodec.av_init_packet(&avpkt); + av_init_packet(&avpkt); avpkt.data = pData; avpkt.size = iSize; - iBytesUsed = m_dllAvCodec.avcodec_decode_audio4( m_pCodecContext + iBytesUsed = avcodec_decode_audio4( m_pCodecContext , m_pFrame1 , &got_frame , &avpkt); @@ -162,7 +153,7 @@ int CDVDAudioCodecFFmpeg::Decode(uint8_t* pData, int iSize) m_iBufferSize1 = 0; return iBytesUsed; } - m_iBufferSize1 = m_pFrame1->nb_samples * m_pCodecContext->channels * m_dllAvUtil.av_get_bytes_per_sample(m_pCodecContext->sample_fmt); + m_iBufferSize1 = m_pFrame1->nb_samples * m_pCodecContext->channels * av_get_bytes_per_sample(m_pCodecContext->sample_fmt); /* some codecs will attempt to consume more data than what we gave */ if (iBytesUsed > iSize) @@ -202,17 +193,17 @@ void CDVDAudioCodecFFmpeg::ConvertToFloat() if(m_pCodecContext->sample_fmt != AV_SAMPLE_FMT_FLT && m_iBufferSize1 > 0) { if(m_pConvert && (m_pCodecContext->sample_fmt != m_iSampleFormat || m_channels != m_pCodecContext->channels)) - m_dllSwResample.swr_free(&m_pConvert); + swr_free(&m_pConvert); if(!m_pConvert) { m_iSampleFormat = m_pCodecContext->sample_fmt; - m_pConvert = m_dllSwResample.swr_alloc_set_opts(NULL, - m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels), AV_SAMPLE_FMT_FLT, m_pCodecContext->sample_rate, - m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels), m_pCodecContext->sample_fmt, m_pCodecContext->sample_rate, + m_pConvert = swr_alloc_set_opts(NULL, + av_get_default_channel_layout(m_pCodecContext->channels), AV_SAMPLE_FMT_FLT, m_pCodecContext->sample_rate, + av_get_default_channel_layout(m_pCodecContext->channels), m_pCodecContext->sample_fmt, m_pCodecContext->sample_rate, 0, NULL); - if(!m_pConvert || m_dllSwResample.swr_init(m_pConvert) < 0) + if(!m_pConvert || swr_init(m_pConvert) < 0) { CLog::Log(LOGERROR, "CDVDAudioCodecFFmpeg::Decode - Unable to convert %d to AV_SAMPLE_FMT_FLT", m_pCodecContext->sample_fmt); m_iBufferSize1 = 0; @@ -221,10 +212,10 @@ void CDVDAudioCodecFFmpeg::ConvertToFloat() } } - int needed_buf_size = m_dllAvUtil.av_samples_get_buffer_size(NULL, m_pCodecContext->channels, m_pFrame1->nb_samples, AV_SAMPLE_FMT_FLT, 0); + int needed_buf_size = av_samples_get_buffer_size(NULL, m_pCodecContext->channels, m_pFrame1->nb_samples, AV_SAMPLE_FMT_FLT, 0); if(m_iBufferTotalSize2 < needed_buf_size) { - m_pBuffer2 = (uint8_t*)m_dllAvUtil.av_realloc(m_pBuffer2, needed_buf_size); + m_pBuffer2 = (uint8_t*)av_realloc(m_pBuffer2, needed_buf_size); if(!m_pBuffer2) { CLog::Log(LOGERROR, "CDVDAudioCodecFFmpeg::Decode - Unable to allocate a %i bytes buffer for resampling", needed_buf_size); @@ -237,7 +228,7 @@ void CDVDAudioCodecFFmpeg::ConvertToFloat() } int outsamples; - outsamples = m_dllSwResample.swr_convert(m_pConvert, &m_pBuffer2, m_iBufferTotalSize2, (const uint8_t**)m_pFrame1->extended_data, m_pFrame1->nb_samples); + outsamples = swr_convert(m_pConvert, &m_pBuffer2, m_iBufferTotalSize2, (const uint8_t**)m_pFrame1->extended_data, m_pFrame1->nb_samples); if(outsamples < 0) { @@ -253,7 +244,7 @@ void CDVDAudioCodecFFmpeg::ConvertToFloat() } m_iBufferSize1 = 0; - m_iBufferSize2 = m_pFrame1->nb_samples * m_pCodecContext->channels * m_dllAvUtil.av_get_bytes_per_sample(AV_SAMPLE_FMT_FLT); + m_iBufferSize2 = m_pFrame1->nb_samples * m_pCodecContext->channels * av_get_bytes_per_sample(AV_SAMPLE_FMT_FLT); } } @@ -276,7 +267,7 @@ int CDVDAudioCodecFFmpeg::GetData(uint8_t** dst) void CDVDAudioCodecFFmpeg::Reset() { - if (m_pCodecContext) m_dllAvCodec.avcodec_flush_buffers(m_pCodecContext); + if (m_pCodecContext) avcodec_flush_buffers(m_pCodecContext); m_iBufferSize1 = 0; m_iBufferSize2 = 0; m_iBuffered = 0; @@ -348,7 +339,7 @@ void CDVDAudioCodecFFmpeg::BuildChannelMap() else { CLog::Log(LOGINFO, "CDVDAudioCodecFFmpeg::GetChannelMap - FFmpeg reported %d channels, but the layout contains %d ignoring", m_pCodecContext->channels, bits); - layout = m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels); + layout = av_get_default_channel_layout(m_pCodecContext->channels); } m_channelLayout.Reset(); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h index 1646e00522..7d78516797 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h @@ -21,10 +21,13 @@ */ #include "DVDAudioCodec.h" -#include "DllAvCodec.h" -#include "DllAvFormat.h" -#include "DllAvUtil.h" -#include "DllSwResample.h" + +extern "C" { +#include "libavcodec/avcodec.h" +#include "libavformat/avformat.h" +#include "libavutil/avutil.h" +#include "libswresample/swresample.h" +} class CDVDAudioCodecFFmpeg : public CDVDAudioCodec { @@ -63,10 +66,6 @@ protected: int m_channels; uint64_t m_layout; - DllAvCodec m_dllAvCodec; - DllAvUtil m_dllAvUtil; - DllSwResample m_dllSwResample; - void BuildChannelMap(); void ConvertToFloat(); }; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp b/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp index 5443cb3425..46841a1dee 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp @@ -23,7 +23,11 @@ #include "cores/VideoRenderers/RenderManager.h" #include "utils/log.h" #include "utils/fastmemcpy.h" -#include "DllSwScale.h" +#include "cores/FFmpeg.h" + +extern "C" { +#include "libswscale/swscale.h" +} // allocate a new picture (PIX_FMT_YUV420P) DVDVideoPicture* CDVDCodecUtils::AllocatePicture(int iWidth, int iHeight) @@ -241,12 +245,6 @@ DVDVideoPicture* CDVDCodecUtils::ConvertToYUV422PackedPicture(DVDVideoPicture *p //if this is going to be used for anything else than testing the renderer //the library should not be loaded on every function call - DllSwScale dllSwScale; - if (!dllSwScale.Load()) - { - CLog::Log(LOGERROR,"CDVDCodecUtils::ConvertToYUY2Picture - failed to load rescale libraries!"); - } - else { // Perform the scaling. uint8_t* src[] = { pSrc->data[0], pSrc->data[1], pSrc->data[2], NULL }; @@ -260,11 +258,11 @@ DVDVideoPicture* CDVDCodecUtils::ConvertToYUV422PackedPicture(DVDVideoPicture *p else dstformat = PIX_FMT_YUYV422; - struct SwsContext *ctx = dllSwScale.sws_getContext(pSrc->iWidth, pSrc->iHeight, PIX_FMT_YUV420P, - pPicture->iWidth, pPicture->iHeight, dstformat, + struct SwsContext *ctx = sws_getContext(pSrc->iWidth, pSrc->iHeight, PIX_FMT_YUV420P, + pPicture->iWidth, pPicture->iHeight, (AVPixelFormat)dstformat, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL); - dllSwScale.sws_scale(ctx, src, srcStride, 0, pSrc->iHeight, dst, dstStride); - dllSwScale.sws_freeContext(ctx); + sws_scale(ctx, src, srcStride, 0, pSrc->iHeight, dst, dstStride); + sws_freeContext(ctx); } } else diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp index 805ee221e4..72b9bcaeaa 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp @@ -45,18 +45,14 @@ CDVDOverlayCodecFFmpeg::~CDVDOverlayCodecFFmpeg() bool CDVDOverlayCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) { - if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load()) return false; - - m_dllAvCodec.avcodec_register_all(); - - AVCodec* pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec); + AVCodec* pCodec = avcodec_find_decoder(hints.codec); if (!pCodec) { CLog::Log(LOGDEBUG,"%s - Unable to find codec %d", __FUNCTION__, hints.codec); return false; } - m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec); + m_pCodecContext = avcodec_alloc_context3(pCodec); m_pCodecContext->debug_mv = 0; m_pCodecContext->debug = 0; m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT; @@ -69,7 +65,7 @@ bool CDVDOverlayCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &optio if( hints.extradata && hints.extrasize > 0 ) { m_pCodecContext->extradata_size = hints.extrasize; - m_pCodecContext->extradata = (uint8_t*)m_dllAvUtil.av_mallocz(hints.extrasize + FF_INPUT_BUFFER_PADDING_SIZE); + m_pCodecContext->extradata = (uint8_t*)av_mallocz(hints.extrasize + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(m_pCodecContext->extradata, hints.extradata, hints.extrasize); // start parsing of extra data - create a copy to be safe and make it zero-terminating to avoid access violations! @@ -110,7 +106,7 @@ bool CDVDOverlayCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &optio delete[] parse_extra; } - if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) + if (avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) { CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to open codec"); return false; @@ -123,14 +119,11 @@ void CDVDOverlayCodecFFmpeg::Dispose() { if (m_pCodecContext) { - if (m_pCodecContext->codec) m_dllAvCodec.avcodec_close(m_pCodecContext); - m_dllAvUtil.av_free(m_pCodecContext); + if (m_pCodecContext->codec) avcodec_close(m_pCodecContext); + av_free(m_pCodecContext); m_pCodecContext = NULL; } FreeSubtitle(m_Subtitle); - - m_dllAvCodec.Unload(); - m_dllAvUtil.Unload(); } void CDVDOverlayCodecFFmpeg::FreeSubtitle(AVSubtitle& sub) @@ -139,13 +132,13 @@ void CDVDOverlayCodecFFmpeg::FreeSubtitle(AVSubtitle& sub) { if(sub.rects[i]) { - m_dllAvUtil.av_free(sub.rects[i]->pict.data[0]); - m_dllAvUtil.av_free(sub.rects[i]->pict.data[1]); - m_dllAvUtil.av_freep(&sub.rects[i]); + av_free(sub.rects[i]->pict.data[0]); + av_free(sub.rects[i]->pict.data[1]); + av_freep(&sub.rects[i]); } } if(sub.rects) - m_dllAvUtil.av_freep(&sub.rects); + av_freep(&sub.rects); sub.num_rects = 0; sub.start_display_time = 0; sub.end_display_time = 0; @@ -161,13 +154,13 @@ int CDVDOverlayCodecFFmpeg::Decode(DemuxPacket *pPacket) FreeSubtitle(m_Subtitle); AVPacket avpkt; - m_dllAvCodec.av_init_packet(&avpkt); + av_init_packet(&avpkt); avpkt.data = pPacket->pData; avpkt.size = pPacket->iSize; avpkt.pts = pPacket->pts == DVD_NOPTS_VALUE ? AV_NOPTS_VALUE : (int64_t)pPacket->pts; avpkt.dts = pPacket->dts == DVD_NOPTS_VALUE ? AV_NOPTS_VALUE : (int64_t)pPacket->dts; - len = m_dllAvCodec.avcodec_decode_subtitle2(m_pCodecContext, &m_Subtitle, &gotsub, &avpkt); + len = avcodec_decode_subtitle2(m_pCodecContext, &m_Subtitle, &gotsub, &avpkt); if (len < 0) { @@ -216,7 +209,7 @@ void CDVDOverlayCodecFFmpeg::Flush() FreeSubtitle(m_Subtitle); m_SubtitleIndex = -1; - m_dllAvCodec.avcodec_flush_buffers(m_pCodecContext); + avcodec_flush_buffers(m_pCodecContext); } CDVDOverlay* CDVDOverlayCodecFFmpeg::GetOverlay() @@ -309,9 +302,9 @@ CDVDOverlay* CDVDOverlayCodecFFmpeg::GetOverlay() for(int i=0;i<rect.nb_colors;i++) overlay->palette[i] = Endian_SwapLE32(((uint32_t *)rect.pict.data[1])[i]); - m_dllAvUtil.av_free(rect.pict.data[0]); - m_dllAvUtil.av_free(rect.pict.data[1]); - m_dllAvUtil.av_freep(&m_Subtitle.rects[m_SubtitleIndex]); + av_free(rect.pict.data[0]); + av_free(rect.pict.data[1]); + av_freep(&m_Subtitle.rects[m_SubtitleIndex]); m_SubtitleIndex++; return overlay; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.h b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.h index 3306d94a45..f84e9a4de2 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.h @@ -21,8 +21,11 @@ */ #include "DVDOverlayCodec.h" -#include "DllAvCodec.h" -#include "DllAvUtil.h" + +extern "C" { +#include "libavcodec/avcodec.h" +#include "libavutil/avutil.h" +} class CDVDOverlaySpu; class CDVDOverlayText; @@ -50,8 +53,4 @@ private: int m_width; int m_height; - - DllAvCodec m_dllAvCodec; - DllAvUtil m_dllAvUtil; - }; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecText.h b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecText.h index e4ee3fa8e8..4e3b2237d0 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecText.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecText.h @@ -21,7 +21,7 @@ */ #include "DVDOverlayCodec.h" -#include "DllAvCodec.h" +#include "libavcodec/avcodec.h" class CDVDOverlayText; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp index 7585636143..b6e1ed3e6a 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp @@ -36,9 +36,12 @@ #include "threads/Thread.h" #include "utils/log.h" #include "utils/fastmemcpy.h" -#include "DllSwScale.h" +extern "C" { +#include "libswscale/swscale.h" +} #include "utils/TimeUtils.h" #include "windowing/WindowingFactory.h" +#include "cores/FFmpeg.h" namespace BCM { @@ -248,7 +251,6 @@ protected: int m_aspectratio_x; int m_aspectratio_y; CEvent m_ready_event; - DllSwScale *m_dllSwScale; struct SwsContext *m_sw_scale_ctx; }; @@ -348,9 +350,6 @@ CMPCOutputThread::CMPCOutputThread(void *device, DllLibCrystalHD *dll, bool has_ m_aspectratio_y(1) { m_sw_scale_ctx = NULL; - m_dllSwScale = new DllSwScale; - m_dllSwScale->Load(); - if (g_Windowing.GetRenderQuirks() & RENDER_QUIRKS_YV12_PREFERED) m_output_YV12 = true; @@ -366,8 +365,7 @@ CMPCOutputThread::~CMPCOutputThread() delete m_FreeList.Pop(); if (m_sw_scale_ctx) - m_dllSwScale->sws_freeContext(m_sw_scale_ctx); - delete m_dllSwScale; + sws_freeContext(m_sw_scale_ctx); } unsigned int CMPCOutputThread::GetReadyCount(void) @@ -949,11 +947,11 @@ bool CMPCOutputThread::GetDecoderOutput(void) uint8_t* dst[] = { pBuffer->m_y_buffer_ptr, pBuffer->m_u_buffer_ptr, pBuffer->m_v_buffer_ptr, NULL }; int dstStride[] = { pBuffer->m_width, pBuffer->m_width/2, pBuffer->m_width/2, 0 }; - m_sw_scale_ctx = m_dllSwScale->sws_getCachedContext(m_sw_scale_ctx, + m_sw_scale_ctx = sws_getCachedContext(m_sw_scale_ctx, pBuffer->m_width, pBuffer->m_height, PIX_FMT_YUYV422, pBuffer->m_width, pBuffer->m_height, PIX_FMT_YUV420P, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL); - m_dllSwScale->sws_scale(m_sw_scale_ctx, src, srcStride, 0, pBuffer->m_height, dst, dstStride); + sws_scale(m_sw_scale_ctx, src, srcStride, 0, pBuffer->m_height, dst, dstStride); } break; default: diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h index f6751f4e6d..d82e4bbc62 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h @@ -21,13 +21,15 @@ */ #include "system.h" -#include "DllAvFormat.h" -#include "DllAvCodec.h" #include <vector> #include <string> #include "cores/VideoRenderers/RenderFormats.h" +extern "C" { +#include "libavcodec/avcodec.h" +} + struct DVDCodecAvailableType { AVCodecID codec; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCrystalHD.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCrystalHD.cpp index 7f6e1caaaa..373ae2c8d7 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCrystalHD.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCrystalHD.cpp @@ -22,7 +22,9 @@ #include "config.h" #elif defined(TARGET_WINDOWS) #include "system.h" -#include "DllAvCodec.h" +extern "C" { +#include "libavcodec/avcodec.h" +} #endif #if defined(HAVE_LIBCRYSTALHD) diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp index 9b6a34df86..7348d5f443 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp @@ -63,6 +63,13 @@ #endif #include "utils/StringUtils.h" +extern "C" { +#include "libavutil/opt.h" +#include "libavfilter/avfilter.h" +#include "libavfilter/buffersink.h" +#include "libavfilter/buffersrc.h" +} + using namespace boost; enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx @@ -72,7 +79,7 @@ enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx // if frame threading is enabled hw accel is not allowed if((EDECODEMETHOD) CSettings::Get().GetInt("videoplayer.decodingmethod") != VS_DECODEMETHOD_HARDWARE || !ctx->IsHardwareAllowed()) - return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt); + return avcodec_default_get_format(avctx, fmt); const PixelFormat * cur = fmt; while(*cur != PIX_FMT_NONE) @@ -134,7 +141,7 @@ enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx #endif cur++; } - return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt); + return avcodec_default_get_format(avctx, fmt); } CDVDVideoCodecFFmpeg::CDVDVideoCodecFFmpeg() : CDVDVideoCodec() @@ -144,11 +151,7 @@ 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; @@ -175,16 +178,6 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options { AVCodec* pCodec; - if(!m_dllAvUtil.Load() - || !m_dllAvCodec.Load() - || !m_dllSwScale.Load() - || !m_dllPostProc.Load() - || !m_dllAvFilter.Load() - ) return false; - - m_dllAvCodec.avcodec_register_all(); - m_dllAvFilter.avfilter_register_all(); - m_bSoftware = hints.software; m_iOrientation = hints.orientation; @@ -219,7 +212,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options } if(pCodec == NULL) - pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec); + pCodec = avcodec_find_decoder(hints.codec); if(pCodec == NULL) { @@ -230,7 +223,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Using codec: %s",pCodec->long_name ? pCodec->long_name : pCodec->name); if(m_pCodecContext == NULL) - m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec); + m_pCodecContext = avcodec_alloc_context3(pCodec); m_pCodecContext->opaque = (void*)this; m_pCodecContext->debug_mv = 0; @@ -276,7 +269,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options if( hints.extradata && hints.extrasize > 0 ) { m_pCodecContext->extradata_size = hints.extrasize; - m_pCodecContext->extradata = (uint8_t*)m_dllAvUtil.av_mallocz(hints.extrasize + FF_INPUT_BUFFER_PADDING_SIZE); + m_pCodecContext->extradata = (uint8_t*)av_mallocz(hints.extrasize + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(m_pCodecContext->extradata, hints.extradata, hints.extrasize); } @@ -293,7 +286,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options if (it->m_name == "surfaces") m_uSurfacesCount = std::atoi(it->m_value.c_str()); else - m_dllAvUtil.av_opt_set(m_pCodecContext, it->m_name.c_str(), it->m_value.c_str(), 0); + av_opt_set(m_pCodecContext, it->m_name.c_str(), it->m_value.c_str(), 0); } int num_threads = std::min(8 /*MAX_THREADS*/, g_cpuInfo.getCPUCount()); @@ -302,19 +295,17 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options || pCodec->id == AV_CODEC_ID_MPEG4 )) m_pCodecContext->thread_count = num_threads; - if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) + if (avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) { CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to open codec"); return false; } - m_pFrame = m_dllAvCodec.avcodec_alloc_frame(); + m_pFrame = avcodec_alloc_frame(); if (!m_pFrame) return false; -#if defined(LIBAVFILTER_AVFRAME_BASED) - m_pFilterFrame = m_dllAvUtil.av_frame_alloc(); + m_pFilterFrame = av_frame_alloc(); if (!m_pFilterFrame) return false; -#endif UpdateName(); return true; @@ -322,33 +313,26 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options void CDVDVideoCodecFFmpeg::Dispose() { - if (m_pFrame) m_dllAvUtil.av_free(m_pFrame); + if (m_pFrame) av_free(m_pFrame); m_pFrame = NULL; -#if defined(LIBAVFILTER_AVFRAME_BASED) - m_dllAvUtil.av_frame_free(&m_pFilterFrame); -#endif + av_frame_free(&m_pFilterFrame); if (m_pCodecContext) { - if (m_pCodecContext->codec) m_dllAvCodec.avcodec_close(m_pCodecContext); + if (m_pCodecContext->codec) avcodec_close(m_pCodecContext); if (m_pCodecContext->extradata) { - m_dllAvUtil.av_free(m_pCodecContext->extradata); + av_free(m_pCodecContext->extradata); m_pCodecContext->extradata = NULL; m_pCodecContext->extradata_size = 0; } - m_dllAvUtil.av_free(m_pCodecContext); + av_free(m_pCodecContext); m_pCodecContext = NULL; } SAFE_RELEASE(m_pHardware); FilterClose(); - - m_dllAvCodec.Unload(); - m_dllAvUtil.Unload(); - m_dllAvFilter.Unload(); - m_dllPostProc.Unload(); } void CDVDVideoCodecFFmpeg::SetDropState(bool bDrop) @@ -476,13 +460,13 @@ int CDVDVideoCodecFFmpeg::Decode(uint8_t* pData, int iSize, double dts, double p m_pCodecContext->reordered_opaque = pts_dtoi(pts); AVPacket avpkt; - m_dllAvCodec.av_init_packet(&avpkt); + av_init_packet(&avpkt); avpkt.data = pData; avpkt.size = iSize; /* We lie, but this flag is only used by pngdec.c. * Setting it correctly would allow CorePNG decoding. */ avpkt.flags = AV_PKT_FLAG_KEY; - len = m_dllAvCodec.avcodec_decode_video2(m_pCodecContext, m_pFrame, &iGotPicture, &avpkt); + len = avcodec_decode_video2(m_pCodecContext, m_pFrame, &iGotPicture, &avpkt); if(m_iLastKeyframe < m_pCodecContext->has_b_frames + 2) m_iLastKeyframe = m_pCodecContext->has_b_frames + 2; @@ -557,7 +541,7 @@ void CDVDVideoCodecFFmpeg::Reset() { m_started = false; m_iLastKeyframe = m_pCodecContext->has_b_frames; - m_dllAvCodec.avcodec_flush_buffers(m_pCodecContext); + avcodec_flush_buffers(m_pCodecContext); if (m_pHardware) m_pHardware->Reset(); @@ -571,14 +555,6 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture) 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 && m_pCodecContext->coded_width > (int)pDvdVideoPicture->iWidth - 10) @@ -592,10 +568,6 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture) /* use variable in the frame */ AVRational pixel_aspect = m_pFrame->sample_aspect_ratio; -#if !defined(LIBAVFILTER_AVFRAME_BASED) - if (m_pBufferRef) - pixel_aspect = m_pBufferRef->video->sample_aspect_ratio; -#endif if (pixel_aspect.num == 0) aspect_ratio = 0; @@ -620,7 +592,7 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture) if (!m_pFrame) return false; - AVDictionaryEntry * entry = m_dllAvUtil.av_dict_get(m_dllAvCodec.av_frame_get_metadata(m_pFrame), "stereo_mode", NULL, 0); + AVDictionaryEntry * entry = av_dict_get(av_frame_get_metadata(m_pFrame), "stereo_mode", NULL, 0); if(entry && entry->value) { strncpy(pDvdVideoPicture->stereo_mode, (const char*)entry->value, sizeof(pDvdVideoPicture->stereo_mode)); @@ -690,12 +662,7 @@ 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 -#endif - pix_fmt = (PixelFormat)m_pFrame->format; + pix_fmt = (PixelFormat)m_pFrame->format; pDvdVideoPicture->format = CDVDCodecUtils::EFormatFromPixfmt(pix_fmt); return true; @@ -718,14 +685,14 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters, bool scale) return 0; } - if (!(m_pFilterGraph = m_dllAvFilter.avfilter_graph_alloc())) + if (!(m_pFilterGraph = avfilter_graph_alloc())) { CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - unable to alloc filter graph"); return -1; } - AVFilter* srcFilter = m_dllAvFilter.avfilter_get_by_name("buffer"); - AVFilter* outFilter = m_dllAvFilter.avfilter_get_by_name("buffersink"); // should be last filter in the graph for now + AVFilter* srcFilter = avfilter_get_by_name("buffer"); + AVFilter* outFilter = avfilter_get_by_name("buffersink"); // should be last filter in the graph for now CStdString args = StringUtils::Format("%d:%d:%d:%d:%d:%d:%d", m_pCodecContext->width, @@ -736,64 +703,57 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters, bool scale) m_pCodecContext->sample_aspect_ratio.num, m_pCodecContext->sample_aspect_ratio.den); - if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterIn, srcFilter, "src", args, NULL, m_pFilterGraph)) < 0) + if ((result = avfilter_graph_create_filter(&m_pFilterIn, srcFilter, "src", args, NULL, m_pFilterGraph)) < 0) { CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - avfilter_graph_create_filter: src"); return result; } - buffersink_params = m_dllAvFilter.av_buffersink_params_alloc(); - buffersink_params->pixel_fmts = &m_formats[0]; -#ifdef FF_API_OLD_VSINK_API - if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, (void*)buffersink_params->pixel_fmts, m_pFilterGraph)) < 0) -#else - if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, buffersink_params, m_pFilterGraph)) < 0) -#endif + if ((result = avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, NULL, m_pFilterGraph)) < 0) { - m_dllAvUtil.av_freep(&buffersink_params); CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - avfilter_graph_create_filter: out"); return result; } - m_dllAvUtil.av_freep(&buffersink_params); + if ((result = av_opt_set_int_list(m_pFilterOut, "pix_fmts", &m_formats[0], AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN)) < 0) + { + CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - failed settings pix formats"); + return result; + } if (!filters.empty()) { - AVFilterInOut* outputs = m_dllAvFilter.avfilter_inout_alloc(); - AVFilterInOut* inputs = m_dllAvFilter.avfilter_inout_alloc(); + AVFilterInOut* outputs = avfilter_inout_alloc(); + AVFilterInOut* inputs = avfilter_inout_alloc(); - outputs->name = m_dllAvUtil.av_strdup("in"); + outputs->name = av_strdup("in"); outputs->filter_ctx = m_pFilterIn; outputs->pad_idx = 0; outputs->next = NULL; - inputs->name = m_dllAvUtil.av_strdup("out"); + inputs->name = av_strdup("out"); inputs->filter_ctx = m_pFilterOut; 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) -#else - if ((result = m_dllAvFilter.avfilter_graph_parse(m_pFilterGraph, (const char*)m_filters.c_str(), &inputs, &outputs, NULL)) < 0) -#endif + if ((result = avfilter_graph_parse_ptr(m_pFilterGraph, (const char*)m_filters.c_str(), &inputs, &outputs, NULL)) < 0) { CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - avfilter_graph_parse"); return result; } - m_dllAvFilter.avfilter_inout_free(&outputs); - m_dllAvFilter.avfilter_inout_free(&inputs); + avfilter_inout_free(&outputs); + avfilter_inout_free(&inputs); } else { - if ((result = m_dllAvFilter.avfilter_link(m_pFilterIn, 0, m_pFilterOut, 0)) < 0) + if ((result = avfilter_link(m_pFilterIn, 0, m_pFilterOut, 0)) < 0) { CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - avfilter_link"); return result; } } - if ((result = m_dllAvFilter.avfilter_graph_config(m_pFilterGraph, NULL)) < 0) + if ((result = avfilter_graph_config(m_pFilterGraph, NULL)) < 0) { CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - avfilter_graph_config"); return result; @@ -804,17 +764,9 @@ 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) { - m_dllAvFilter.avfilter_graph_free(&m_pFilterGraph); + avfilter_graph_free(&m_pFilterGraph); // Disposed by above code m_pFilterIn = NULL; @@ -828,19 +780,7 @@ int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame) if (frame) { -#if defined(LIBAVFILTER_AVFRAME_BASED) - // API changed in: - // ffmpeg: commit 7e350379f87e7f74420b4813170fe808e2313911 (28 Nov 2012) - // not released (post 1.2) - // libav: commit 7e350379f87e7f74420b4813170fe808e2313911 (28 Nov 2012) - // release v9 (5 January 2013) - result = m_dllAvFilter.av_buffersrc_add_frame(m_pFilterIn, frame); -#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); -#endif + result = av_buffersrc_add_frame(m_pFilterIn, frame); if (result < 0) { CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - av_buffersrc_add_frame"); @@ -848,8 +788,7 @@ int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame) } } -#if defined(LIBAVFILTER_AVFRAME_BASED) - result = m_dllAvFilter.av_buffersink_get_frame(m_pFilterOut, m_pFilterFrame); + result = av_buffersink_get_frame(m_pFilterOut, m_pFilterFrame); if(result == AVERROR(EAGAIN) || result == AVERROR_EOF) return VC_BUFFER; @@ -859,54 +798,10 @@ int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame) return VC_ERROR; } - m_dllAvUtil.av_frame_unref(m_pFrame); - m_dllAvUtil.av_frame_move_ref(m_pFrame, m_pFilterFrame); + av_frame_unref(m_pFrame); + av_frame_move_ref(m_pFrame, m_pFilterFrame); return VC_PICTURE; -#else - int frames; - - if(m_pBufferRef) - { - m_dllAvFilter.avfilter_unref_buffer(m_pBufferRef); - m_pBufferRef = NULL; - } - - if ((frames = m_dllAvFilter.av_buffersink_poll_frame(m_pFilterOut)) < 0) - { - CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - av_buffersink_poll_frame"); - return VC_ERROR; - } - - if (frames > 0) - { - - result = m_dllAvFilter.av_buffersink_get_buffer_ref(m_pFilterOut, &m_pBufferRef, 0); - if(!m_pBufferRef || result < 0) - { - CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - cur_buf"); - return VC_ERROR; - } - - if(frame == NULL) - m_pFrame->reordered_opaque = 0; - else - m_pFrame->repeat_pict = -(frames - 1); - - m_pFrame->interlaced_frame = m_pBufferRef->video->interlaced; - m_pFrame->top_field_first = m_pBufferRef->video->top_field_first; - - memcpy(m_pFrame->linesize, m_pBufferRef->linesize, 4*sizeof(int)); - memcpy(m_pFrame->data , m_pBufferRef->data , 4*sizeof(uint8_t*)); - - if(frames > 1) - return VC_PICTURE; - else - return VC_PICTURE | VC_BUFFER; - } - - 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 2287031660..ab5e565a1c 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h @@ -22,12 +22,17 @@ #include "DVDVideoCodec.h" #include "DVDResource.h" -#include "DllAvCodec.h" -#include "DllAvFormat.h" -#include "DllAvUtil.h" -#include "DllSwScale.h" -#include "DllAvFilter.h" -#include "DllPostProc.h" +#include <string> +#include "utils/StdString.h" + +extern "C" { +#include "libavfilter/avfilter.h" +#include "libavcodec/avcodec.h" +#include "libavformat/avformat.h" +#include "libavutil/avutil.h" +#include "libswscale/swscale.h" +#include "libpostproc/postprocess.h" +} class CCriticalSection; @@ -98,11 +103,7 @@ 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; @@ -113,12 +114,6 @@ protected: unsigned int m_uSurfacesCount; - DllAvCodec m_dllAvCodec; - DllAvUtil m_dllAvUtil; - DllSwScale m_dllSwScale; - DllAvFilter m_dllAvFilter; - DllPostProc m_dllPostProc; - std::string m_name; bool m_bSoftware; bool m_isHi10p; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp index 134f29b6c4..31a118d720 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp @@ -24,7 +24,7 @@ #include "system_gl.h" #include "DVDVideoCodecVDA.h" -#include "DllSwScale.h" +#include "libswscale/swscale.h" #include "DVDClock.h" #include "DVDStreamInfo.h" #include "cores/dvdplayer/DVDCodecs/DVDCodecUtils.h" @@ -137,7 +137,6 @@ CDVDVideoCodecVDA::CDVDVideoCodecVDA() : CDVDVideoCodec() pthread_mutex_init(&m_queue_mutex, NULL); m_bitstream = NULL; - m_dllSwScale = NULL; memset(&m_videobuffer, 0, sizeof(DVDVideoPicture)); m_DropPictures = false; m_decode_async = false; @@ -267,13 +266,6 @@ bool CDVDVideoCodecVDA::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) if (!m_use_cvBufferRef) { - m_dllSwScale = new DllSwScale; - if (!m_dllSwScale->Load()) - { - CFRelease(avcCData); - return false; - } - // allocate a YV12 DVDVideoPicture buffer. // first make sure all properties are reset. memset(&m_videobuffer, 0, sizeof(DVDVideoPicture)); @@ -394,9 +386,6 @@ void CDVDVideoCodecVDA::Dispose() if (m_bitstream) delete m_bitstream, m_bitstream = NULL; - - if (m_dllSwScale) - delete m_dllSwScale, m_dllSwScale = NULL; } void CDVDVideoCodecVDA::SetDropState(bool bDrop) @@ -553,7 +542,7 @@ void CDVDVideoCodecVDA::DisplayQueuePop(void) void CDVDVideoCodecVDA::UYVY422_to_YUV420P(uint8_t *yuv422_ptr, int yuv422_stride, DVDVideoPicture *picture) { // convert PIX_FMT_UYVY422 to PIX_FMT_YUV420P. - struct SwsContext *swcontext = m_dllSwScale->sws_getContext( + struct SwsContext *swcontext = sws_getContext( m_videobuffer.iWidth, m_videobuffer.iHeight, PIX_FMT_UYVY422, m_videobuffer.iWidth, m_videobuffer.iHeight, PIX_FMT_YUV420P, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL); @@ -565,15 +554,15 @@ void CDVDVideoCodecVDA::UYVY422_to_YUV420P(uint8_t *yuv422_ptr, int yuv422_strid uint8_t *dst[] = { picture->data[0], picture->data[1], picture->data[2], 0 }; int dstStride[] = { picture->iLineSize[0], picture->iLineSize[1], picture->iLineSize[2], 0 }; - m_dllSwScale->sws_scale(swcontext, src, srcStride, 0, picture->iHeight, dst, dstStride); - m_dllSwScale->sws_freeContext(swcontext); + sws_scale(swcontext, src, srcStride, 0, picture->iHeight, dst, dstStride); + sws_freeContext(swcontext); } } void CDVDVideoCodecVDA::BGRA_to_YUV420P(uint8_t *bgra_ptr, int bgra_stride, DVDVideoPicture *picture) { // convert PIX_FMT_BGRA to PIX_FMT_YUV420P. - struct SwsContext *swcontext = m_dllSwScale->sws_getContext( + struct SwsContext *swcontext = sws_getContext( m_videobuffer.iWidth, m_videobuffer.iHeight, PIX_FMT_BGRA, m_videobuffer.iWidth, m_videobuffer.iHeight, PIX_FMT_YUV420P, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL); @@ -585,8 +574,8 @@ void CDVDVideoCodecVDA::BGRA_to_YUV420P(uint8_t *bgra_ptr, int bgra_stride, DVDV uint8_t *dst[] = { picture->data[0], picture->data[1], picture->data[2], 0 }; int dstStride[] = { picture->iLineSize[0], picture->iLineSize[1], picture->iLineSize[2], 0 }; - m_dllSwScale->sws_scale(swcontext, src, srcStride, 0, picture->iHeight, dst, dstStride); - m_dllSwScale->sws_freeContext(swcontext); + sws_scale(swcontext, src, srcStride, 0, picture->iHeight, dst, dstStride); + sws_freeContext(swcontext); } } diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.h index b09577854d..eb9975ed80 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.h @@ -22,7 +22,6 @@ #include "DVDVideoCodec.h" #include <CoreVideo/CoreVideo.h> -class DllSwScale; class CBitstreamConverter; struct frame_queue; @@ -66,6 +65,5 @@ protected: CBitstreamConverter *m_bitstream; - DllSwScale *m_dllSwScale; DVDVideoPicture m_videobuffer; }; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp index c7651c4619..d55853af7a 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp @@ -27,13 +27,16 @@ #include "DVDStreamInfo.h" #include "DVDCodecUtils.h" #include "DVDVideoCodecVideoToolBox.h" -#include "lib/DllSwScale.h" -#include "lib/DllAvFormat.h" #include "settings/Settings.h" #include "utils/log.h" #include "utils/TimeUtils.h" #include "osx/DarwinUtils.h" +extern "C" { +#include "lib/libswscale/swscale.h" +#include "lib/libavformat/avformat.h" +} + #if defined(__cplusplus) extern "C" { @@ -436,7 +439,7 @@ typedef struct { uint8_t* decoderConfig; } quicktime_esds_t; -int quicktime_write_mp4_descr_length(DllAvFormat *av_format_ctx, AVIOContext *pb, int length, int compact) +int quicktime_write_mp4_descr_length(AVIOContext *pb, int length, int compact) { int i; uint8_t b; @@ -473,45 +476,45 @@ int quicktime_write_mp4_descr_length(DllAvFormat *av_format_ctx, AVIOContext *pb { b |= 0x80; } - av_format_ctx->avio_w8(pb, b); + avio_w8(pb, b); } return numBytes; } -void quicktime_write_esds(DllAvFormat *av_format_ctx, AVIOContext *pb, quicktime_esds_t *esds) +void quicktime_write_esds(AVIOContext *pb, quicktime_esds_t *esds) { - av_format_ctx->avio_w8(pb, 0); // Version - av_format_ctx->avio_wb24(pb, 0); // Flags + avio_w8(pb, 0); // Version + avio_wb24(pb, 0); // Flags // elementary stream descriptor tag - av_format_ctx->avio_w8(pb, 0x03); - quicktime_write_mp4_descr_length(av_format_ctx, pb, + avio_w8(pb, 0x03); + quicktime_write_mp4_descr_length(pb, 3 + 5 + (13 + 5 + esds->decoderConfigLen) + 3, false); // 3 bytes + 5 bytes for tag - av_format_ctx->avio_wb16(pb, esds->esid); - av_format_ctx->avio_w8(pb, esds->stream_priority); + avio_wb16(pb, esds->esid); + avio_w8(pb, esds->stream_priority); // decoder configuration description tag - av_format_ctx->avio_w8(pb, 0x04); - quicktime_write_mp4_descr_length(av_format_ctx, pb, + avio_w8(pb, 0x04); + quicktime_write_mp4_descr_length(pb, 13 + 5 + esds->decoderConfigLen, false); // 13 bytes + 5 bytes for tag - av_format_ctx->avio_w8(pb, esds->objectTypeId); // objectTypeIndication - av_format_ctx->avio_w8(pb, esds->streamType); // streamType - av_format_ctx->avio_wb24(pb, esds->bufferSizeDB); // buffer size - av_format_ctx->avio_wb32(pb, esds->maxBitrate); // max bitrate - av_format_ctx->avio_wb32(pb, esds->avgBitrate); // average bitrate + avio_w8(pb, esds->objectTypeId); // objectTypeIndication + avio_w8(pb, esds->streamType); // streamType + avio_wb24(pb, esds->bufferSizeDB); // buffer size + avio_wb32(pb, esds->maxBitrate); // max bitrate + avio_wb32(pb, esds->avgBitrate); // average bitrate // decoder specific description tag - av_format_ctx->avio_w8(pb, 0x05); - quicktime_write_mp4_descr_length(av_format_ctx, pb, esds->decoderConfigLen, false); - av_format_ctx->avio_write(pb, esds->decoderConfig, esds->decoderConfigLen); + avio_w8(pb, 0x05); + quicktime_write_mp4_descr_length(pb, esds->decoderConfigLen, false); + avio_write(pb, esds->decoderConfig, esds->decoderConfigLen); // sync layer configuration descriptor tag - av_format_ctx->avio_w8(pb, 0x06); // tag - av_format_ctx->avio_w8(pb, 0x01); // length - av_format_ctx->avio_w8(pb, 0x7F); // no SL + avio_w8(pb, 0x06); // tag + avio_w8(pb, 0x01); // length + avio_w8(pb, 0x7F); // no SL /* no IPI_DescrPointer */ /* no IP_IdentificationDataSet */ @@ -523,7 +526,7 @@ void quicktime_write_esds(DllAvFormat *av_format_ctx, AVIOContext *pb, quicktime } -quicktime_esds_t* quicktime_set_esds(DllAvFormat *av_format_ctx, const uint8_t * decoderConfig, int decoderConfigLen) +quicktime_esds_t* quicktime_set_esds(const uint8_t * decoderConfig, int decoderConfigLen) { // ffmpeg's codec->avctx->extradata, codec->avctx->extradata_size // are decoderConfig/decoderConfigLen @@ -652,8 +655,7 @@ const uint8_t *avc_find_startcode(const uint8_t *p, const uint8_t *end) return out; } -const int avc_parse_nal_units(DllAvFormat *av_format_ctx, - AVIOContext *pb, const uint8_t *buf_in, int size) +const int avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size) { const uint8_t *p = buf_in; const uint8_t *end = p + size; @@ -665,26 +667,25 @@ const int avc_parse_nal_units(DllAvFormat *av_format_ctx, { while (!*(nal_start++)); nal_end = avc_find_startcode(nal_start, end); - av_format_ctx->avio_wb32(pb, nal_end - nal_start); - av_format_ctx->avio_write(pb, nal_start, nal_end - nal_start); + avio_wb32(pb, nal_end - nal_start); + avio_write(pb, nal_start, nal_end - nal_start); size += 4 + nal_end - nal_start; nal_start = nal_end; } return size; } -const int avc_parse_nal_units_buf(DllAvUtil *av_util_ctx, DllAvFormat *av_format_ctx, - const uint8_t *buf_in, uint8_t **buf, int *size) +const int avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size) { AVIOContext *pb; - int ret = av_format_ctx->avio_open_dyn_buf(&pb); + int ret = avio_open_dyn_buf(&pb); if (ret < 0) return ret; - avc_parse_nal_units(av_format_ctx, pb, buf_in, *size); + avc_parse_nal_units(pb, buf_in, *size); - av_util_ctx->av_freep(buf); - *size = av_format_ctx->avio_close_dyn_buf(pb, buf); + av_freep(buf); + *size = avio_close_dyn_buf(pb, buf); return 0; } @@ -729,8 +730,7 @@ const int avc_parse_nal_units_buf(DllAvUtil *av_util_ctx, DllAvFormat *av_format field_pic_flag: 0 on the frames, (field_pic_flag: 1 would indicate a normal interlaced frame). */ -const int isom_write_avcc(DllAvUtil *av_util_ctx, DllAvFormat *av_format_ctx, - AVIOContext *pb, const uint8_t *data, int len) +const int isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len) { // extradata from bytestream h264, convert to avcC atom data for bitstream if (len > 6) @@ -742,7 +742,7 @@ const int isom_write_avcc(DllAvUtil *av_util_ctx, DllAvFormat *av_format_ctx, uint32_t sps_size=0, pps_size=0; uint8_t *sps=0, *pps=0; - int ret = avc_parse_nal_units_buf(av_util_ctx, av_format_ctx, data, &buf, &len); + int ret = avc_parse_nal_units_buf(data, &buf, &len); if (ret < 0) return ret; start = buf; @@ -769,26 +769,26 @@ const int isom_write_avcc(DllAvUtil *av_util_ctx, DllAvFormat *av_format_ctx, } assert(sps); - av_format_ctx->avio_w8(pb, 1); /* version */ - av_format_ctx->avio_w8(pb, sps[1]); /* profile */ - av_format_ctx->avio_w8(pb, sps[2]); /* profile compat */ - av_format_ctx->avio_w8(pb, sps[3]); /* level */ - av_format_ctx->avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */ - av_format_ctx->avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */ + avio_w8(pb, 1); /* version */ + avio_w8(pb, sps[1]); /* profile */ + avio_w8(pb, sps[2]); /* profile compat */ + avio_w8(pb, sps[3]); /* level */ + avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */ + avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */ - av_format_ctx->avio_wb16(pb, sps_size); - av_format_ctx->avio_write(pb, sps, sps_size); + avio_wb16(pb, sps_size); + avio_write(pb, sps, sps_size); if (pps) { - av_format_ctx->avio_w8(pb, 1); /* number of pps */ - av_format_ctx->avio_wb16(pb, pps_size); - av_format_ctx->avio_write(pb, pps, pps_size); + avio_w8(pb, 1); /* number of pps */ + avio_wb16(pb, pps_size); + avio_write(pb, pps, pps_size); } - av_util_ctx->av_free(start); + av_free(start); } else { - av_format_ctx->avio_write(pb, data, len); + avio_write(pb, data, len); } } return 0; @@ -1043,8 +1043,6 @@ CDVDVideoCodecVideoToolBox::CDVDVideoCodecVideoToolBox() : CDVDVideoCodec() m_convert_bytestream = false; m_convert_3byteTo4byteNALSize = false; - m_dllAvUtil = NULL; - m_dllAvFormat = NULL; memset(&m_videobuffer, 0, sizeof(DVDVideoPicture)); m_DropPictures = false; m_sort_time_offset = 0.0; @@ -1060,11 +1058,6 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o { if (CSettings::Get().GetBool("videoplayer.usevideotoolbox") && !hints.software) { - m_dllAvUtil = new DllAvUtil; - m_dllAvFormat = new DllAvFormat; - if (!m_dllAvUtil->Load() || !m_dllAvFormat->Load()) - return false; - int width = hints.width; int height = hints.height; int level = hints.level; @@ -1103,16 +1096,16 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o AVIOContext *pb; quicktime_esds_t *esds; - if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return false; - esds = quicktime_set_esds(m_dllAvFormat, extradata, extrasize); - quicktime_write_esds(m_dllAvFormat, pb, esds); + esds = quicktime_set_esds(extradata, extrasize); + quicktime_write_esds(pb, esds); // unhook from ffmpeg's extradata extradata = NULL; // extract the esds atom decoderConfig from extradata - extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata); + extrasize = avio_close_dyn_buf(pb, &extradata); free(esds->decoderConfig); free(esds); @@ -1120,7 +1113,7 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o kVTFormatMPEG4Video, width, height, extradata, extrasize, 'esds'); // done with the converted extradata, we MUST free using av_free - m_dllAvUtil->av_free(extradata); + av_free(extradata); } else { @@ -1188,21 +1181,21 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o // NAL reformating to bitstream format required AVIOContext *pb; - if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return false; m_convert_bytestream = true; // create a valid avcC atom data from ffmpeg's extradata - isom_write_avcc(m_dllAvUtil, m_dllAvFormat, pb, extradata, extrasize); + isom_write_avcc(pb, extradata, extrasize); // unhook from ffmpeg's extradata extradata = NULL; // extract the avcC atom data into extradata getting size into extrasize - extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata); + extrasize = avio_close_dyn_buf(pb, &extradata); // check for interlaced and get number of ref frames if (!validate_avcC_spc(extradata, extrasize, &m_max_ref_frames, &spsLevel, &spsProfile)) { - m_dllAvUtil->av_free(extradata); + av_free(extradata); return false; } @@ -1221,7 +1214,7 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o // Main@L3.2, VTB cannot handle greater than 4 ref frames (ie. flash video) CLog::Log(LOGNOTICE, "%s - Main@L3.2 detected, VTB cannot decode with %d ref frames", __FUNCTION__, m_max_ref_frames); - m_dllAvUtil->av_free(extradata); + av_free(extradata); return false; } @@ -1230,7 +1223,7 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o kVTFormatH264, width, height, extradata, extrasize, 'avcC'); // done with the new converted extradata, we MUST free using av_free - m_dllAvUtil->av_free(extradata); + av_free(extradata); CLog::Log(LOGNOTICE, "%s - created avcC atom of size(%d)", __FUNCTION__, extrasize); } else @@ -1314,17 +1307,6 @@ void CDVDVideoCodecVideoToolBox::Dispose() while (m_queue_depth) DisplayQueuePop(); - - if (m_dllAvUtil) - { - delete m_dllAvUtil; - m_dllAvUtil = NULL; - } - if (m_dllAvFormat) - { - delete m_dllAvFormat; - m_dllAvFormat = NULL; - } } void CDVDVideoCodecVideoToolBox::SetDropState(bool bDrop) @@ -1348,17 +1330,17 @@ int CDVDVideoCodecVideoToolBox::Decode(uint8_t* pData, int iSize, double dts, do if (m_convert_bytestream) { // convert demuxer packet from bytestream (AnnexB) to bitstream - if(m_dllAvFormat->avio_open_dyn_buf(&pb) < 0) + if(avio_open_dyn_buf(&pb) < 0) return VC_ERROR; - avc_parse_nal_units(m_dllAvFormat, pb, pData, iSize); - demux_size = m_dllAvFormat->avio_close_dyn_buf(pb, &demux_buff); + avc_parse_nal_units(pb, pData, iSize); + demux_size = avio_close_dyn_buf(pb, &demux_buff); sampleBuff = CreateSampleBufferFrom(m_fmt_desc, demux_buff, demux_size); } else if (m_convert_3byteTo4byteNALSize) { // convert demuxer packet from 3 byte NAL sizes to 4 byte - if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return VC_ERROR; uint32_t nal_size; @@ -1367,13 +1349,13 @@ int CDVDVideoCodecVideoToolBox::Decode(uint8_t* pData, int iSize, double dts, do while (nal_start < end) { nal_size = VDA_RB24(nal_start); - m_dllAvFormat->avio_wb32(pb, nal_size); + avio_wb32(pb, nal_size); nal_start += 3; - m_dllAvFormat->avio_write(pb, nal_start, nal_size); + avio_write(pb, nal_start, nal_size); nal_start += nal_size; } - demux_size = m_dllAvFormat->avio_close_dyn_buf(pb, &demux_buff); + demux_size = avio_close_dyn_buf(pb, &demux_buff); sampleBuff = CreateSampleBufferFrom(m_fmt_desc, demux_buff, demux_size); } else @@ -1384,7 +1366,7 @@ int CDVDVideoCodecVideoToolBox::Decode(uint8_t* pData, int iSize, double dts, do if (!sampleBuff) { if (demux_size) - m_dllAvUtil->av_free(demux_buff); + av_free(demux_buff); CLog::Log(LOGNOTICE, "%s - CreateSampleBufferFrom failed", __FUNCTION__); return VC_ERROR; } @@ -1404,7 +1386,7 @@ int CDVDVideoCodecVideoToolBox::Decode(uint8_t* pData, int iSize, double dts, do CFRelease(frameInfo); CFRelease(sampleBuff); if (demux_size) - m_dllAvUtil->av_free(demux_buff); + av_free(demux_buff); return VC_ERROR; // VTDecompressionSessionDecodeFrame returned 8969 (codecBadDataErr) // VTDecompressionSessionDecodeFrame returned -12350 @@ -1421,14 +1403,14 @@ int CDVDVideoCodecVideoToolBox::Decode(uint8_t* pData, int iSize, double dts, do CFRelease(frameInfo); CFRelease(sampleBuff); if (demux_size) - m_dllAvUtil->av_free(demux_buff); + av_free(demux_buff); return VC_ERROR; } CFRelease(frameInfo); CFRelease(sampleBuff); if (demux_size) - m_dllAvUtil->av_free(demux_buff); + av_free(demux_buff); } // TODO: queue depth is related to the number of reference frames in encoded h.264. diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.h index bfc083b666..d320886ae1 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.h @@ -39,8 +39,6 @@ typedef struct frame_queue { struct frame_queue *nextframe; } frame_queue; -class DllAvUtil; -class DllAvFormat; class CDVDVideoCodecVideoToolBox : public CDVDVideoCodec { public: @@ -80,9 +78,6 @@ protected: bool m_convert_bytestream; bool m_convert_3byteTo4byteNALSize; - - DllAvUtil *m_dllAvUtil; - DllAvFormat *m_dllAvFormat; }; #endif diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp index f993efbe23..a83b7d7d20 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp @@ -20,6 +20,7 @@ #include "DVDVideoPPFFmpeg.h" #include "utils/log.h" +#include "cores/FFmpeg.h" CDVDVideoPPFFmpeg::CDVDVideoPPFFmpeg(const CStdString& mType) { @@ -38,12 +39,12 @@ void CDVDVideoPPFFmpeg::Dispose() { if (m_pMode) { - m_dll.pp_free_mode(m_pMode); + pp_free_mode(m_pMode); m_pMode = NULL; } if(m_pContext) { - m_dll.pp_free_context(m_pContext); + pp_free_context(m_pContext); m_pContext = NULL; } @@ -63,14 +64,10 @@ void CDVDVideoPPFFmpeg::Dispose() m_iInitWidth = 0; m_iInitHeight = 0; - - m_dll.Unload(); } bool CDVDVideoPPFFmpeg::CheckInit(int iWidth, int iHeight) { - if (!m_dll.IsLoaded() && !m_dll.Load()) return false; - if(m_iInitWidth != iWidth || m_iInitHeight != iHeight) { if(m_pContext || m_pMode) @@ -78,12 +75,12 @@ bool CDVDVideoPPFFmpeg::CheckInit(int iWidth, int iHeight) Dispose(); } - m_pContext = m_dll.pp_get_context(m_pSource->iWidth, m_pSource->iHeight, PPCPUFlags() | PP_FORMAT_420); + m_pContext = pp_get_context(m_pSource->iWidth, m_pSource->iHeight, PPCPUFlags() | PP_FORMAT_420); m_iInitWidth = m_pSource->iWidth; m_iInitHeight = m_pSource->iHeight; - m_pMode = m_dll.pp_get_mode_by_name_and_quality((char *)m_sType.c_str(), PP_QUALITY_MAX); + m_pMode = pp_get_mode_by_name_and_quality((char *)m_sType.c_str(), PP_QUALITY_MAX); } @@ -134,7 +131,7 @@ bool CDVDVideoPPFFmpeg::Process(DVDVideoPicture* pPicture) int pict_type = (m_pSource->qscale_type != DVP_QSCALE_MPEG1) ? PP_PICT_TYPE_QP2 : 0; - m_dll.pp_postprocess(m_pSource->data, m_pSource->iLineSize, + pp_postprocess((const uint8_t**)m_pSource->data, m_pSource->iLineSize, m_pTarget->data, m_pTarget->iLineSize, m_pSource->iWidth, m_pSource->iHeight, m_pSource->qscale_table, m_pSource->qscale_stride, diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.h index 08bc6c23dc..5febe0b5b2 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.h @@ -21,7 +21,7 @@ */ #include "DVDVideoCodec.h" -#include "DllPostProc.h" +#include "utils/StdString.h" class CDVDVideoPPFFmpeg { @@ -52,8 +52,6 @@ protected: int m_iInitWidth, m_iInitHeight; bool CheckInit(int iWidth, int iHeight); bool CheckFrameBuffer(const DVDVideoPicture* pSource); - - DllPostProc m_dll; }; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.h index 3bafe92eb5..b0025edbc5 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.h @@ -19,7 +19,7 @@ */ #pragma once -#include "DllAvCodec.h" +#include "libavcodec/avcodec.h" #include "DVDCodecs/Video/DVDVideoCodecFFmpeg.h" #include "guilib/D3DResource.h" #include "threads/Event.h" diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVAHD.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVAHD.h index 22a9d39763..811841fb21 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVAHD.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVAHD.h @@ -19,7 +19,7 @@ */ #pragma once -#include "DllAvCodec.h" +#include "libavcodec/avcodec.h" #include "DVDCodecs/Video/DVDVideoCodecFFmpeg.h" #include "guilib/D3DResource.h" #include "threads/Event.h" diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp index bfefc9d899..47c84e60c5 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp @@ -24,6 +24,8 @@ #include "DVDVideoCodec.h" #include <boost/scoped_array.hpp> #include <boost/weak_ptr.hpp> +#include "utils/log.h" +#include "threads/SingleLock.h" #define CHECK(a) \ do { \ diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.h index a520e42901..9744c800bf 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.h @@ -21,7 +21,7 @@ #include "system_gl.h" -#include "DllAvCodec.h" +#include "libavcodec/avcodec.h" #include "DVDVideoCodecFFmpeg.h" #include <libavcodec/vaapi.h> #include <va/va.h> diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDA.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDA.h index c5e4714f65..a7cd60aeef 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDA.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDA.h @@ -21,7 +21,7 @@ #include "system_gl.h" -#include "DllAvCodec.h" +#include "libavcodec/avcodec.h" #include "DVDVideoCodecFFmpeg.h" struct vda_context; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp index b4d2d38fde..4656499d04 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp @@ -528,9 +528,6 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat fmt, unsigned m_DisplayState = VDPAU_OPEN; m_vdpauConfigured = false; - if (!m_dllAvUtil.Load()) - return false; - m_presentPicture = 0; { @@ -614,11 +611,9 @@ void CDecoder::Close() if (m_hwContext.bitstream_buffers_allocated) { - m_dllAvUtil.av_freep(&m_hwContext.bitstream_buffers); + av_freep(&m_hwContext.bitstream_buffers); } - m_dllAvUtil.Unload(); - if (m_vdpauConfig.context) m_vdpauConfig.context->Release(); m_vdpauConfig.context = 0; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h index 9f58e766f3..32d6cdb5eb 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h @@ -40,19 +40,15 @@ #include "system_gl.h" -#include "DllAvUtil.h" #include "DVDVideoCodec.h" #include "DVDVideoCodecFFmpeg.h" -#include "libavcodec/vdpau.h" #include <X11/Xlib.h> #include <X11/Xutil.h> #define GLX_GLXEXT_PROTOTYPES #include <GL/glx.h> -#include "DllAvUtil.h" #include "DVDVideoCodec.h" #include "DVDVideoCodecFFmpeg.h" -#include "libavcodec/vdpau.h" #include "threads/CriticalSection.h" #include "threads/SharedSection.h" #include "settings/VideoSettings.h" @@ -61,6 +57,12 @@ #include "threads/Thread.h" #include "utils/ActorProtocol.h" #include <list> +#include <map> + +extern "C" { +#include "libavutil/avutil.h" +#include "libavcodec/vdpau.h" +} using namespace Actor; @@ -611,7 +613,6 @@ protected: CCriticalSection m_DecoderSection; CEvent m_DisplayEvent; - DllAvUtil m_dllAvUtil; ThreadIdentifier m_decoderThread; bool m_vdpauConfigured; CVdpauConfig m_vdpauConfig; diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h index 6b3e9015f8..07b24ca67a 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h @@ -34,7 +34,10 @@ class CDVDInputStream; #if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS) #include "config.h" #endif -#include "DllAvCodec.h" + +extern "C" { +#include "libavcodec/avcodec.h" +} #ifndef __GNUC__ #pragma warning(pop) diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp index 4ce1b8731b..03fe65c65b 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp @@ -55,7 +55,7 @@ void CDemuxStreamAudioFFmpeg::GetStreamInfo(std::string& strInfo) { if(!m_stream) return; char temp[128]; - m_parent->m_dllAvCodec.avcodec_string(temp, 128, m_stream->codec, 0); + avcodec_string(temp, 128, m_stream->codec, 0); strInfo = temp; } @@ -81,7 +81,7 @@ void CDemuxStreamVideoFFmpeg::GetStreamInfo(std::string& strInfo) { if(!m_stream) return; char temp[128]; - m_parent->m_dllAvCodec.avcodec_string(temp, 128, m_stream->codec, 0); + avcodec_string(temp, 128, m_stream->codec, 0); strInfo = temp; } @@ -89,14 +89,12 @@ void CDemuxStreamSubtitleFFmpeg::GetStreamInfo(std::string& strInfo) { if(!m_stream) return; char temp[128]; - m_parent->m_dllAvCodec.avcodec_string(temp, 128, m_stream->codec, 0); + avcodec_string(temp, 128, m_stream->codec, 0); strInfo = temp; } // these need to be put somewhere that are compiled, we should have some better place for it -int DllAvFormat::m_avformat_refcnt = 0; -CCriticalSection DllAvCodec::m_critSection; static CCriticalSection m_logSection; std::map<uintptr_t, CStdString> g_logbuffer; @@ -190,7 +188,7 @@ static int dvd_file_write(URLContext *h, uint8_t* buf, int size) return -1; } */ -static offset_t dvd_file_seek(void *h, offset_t pos, int whence) +static int64_t dvd_file_seek(void *h, int64_t pos, int whence) { if(interrupt_cb(h)) return AVERROR_EXIT; @@ -248,14 +246,6 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) if (!pInput) return false; - if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load() || !m_dllAvFormat.Load()) { - CLog::Log(LOGERROR,"CDVDDemuxFFmpeg::Open - failed to load ffmpeg libraries"); - return false; - } - - // register codecs - m_dllAvFormat.av_register_all(); - m_pInput = pInput; strFile = m_pInput->GetFileName(); @@ -267,17 +257,17 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) /* check if we can get a hint from content */ if ( content.compare("video/x-vobsub") == 0 ) - iformat = m_dllAvFormat.av_find_input_format("mpeg"); + iformat = av_find_input_format("mpeg"); else if( content.compare("video/x-dvd-mpeg") == 0 ) - iformat = m_dllAvFormat.av_find_input_format("mpeg"); + iformat = av_find_input_format("mpeg"); else if( content.compare("video/x-mpegts") == 0 ) - iformat = m_dllAvFormat.av_find_input_format("mpegts"); + iformat = av_find_input_format("mpegts"); else if( content.compare("multipart/x-mixed-replace") == 0 ) - iformat = m_dllAvFormat.av_find_input_format("mjpeg"); + iformat = av_find_input_format("mjpeg"); } // open the demuxer - m_pFormatContext = m_dllAvFormat.avformat_alloc_context(); + m_pFormatContext = avformat_alloc_context(); m_pFormatContext->interrupt_callback = int_cb; // try to abort after 30 seconds @@ -298,26 +288,26 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) // try mmsh, then mmst url.SetProtocol("mmsh"); url.SetProtocolOptions(""); - result = m_dllAvFormat.avformat_open_input(&m_pFormatContext, url.Get().c_str(), iformat, &options); + result = avformat_open_input(&m_pFormatContext, url.Get().c_str(), iformat, &options); if (result < 0) { url.SetProtocol("mmst"); strFile = url.Get(); } } - if (result < 0 && m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0 ) + if (result < 0 && avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0 ) { CLog::Log(LOGDEBUG, "Error, could not open file %s", CURL::GetRedacted(strFile).c_str()); Dispose(); - m_dllAvUtil.av_dict_free(&options); + av_dict_free(&options); return false; } - m_dllAvUtil.av_dict_free(&options); + av_dict_free(&options); } else { - unsigned char* buffer = (unsigned char*)m_dllAvUtil.av_malloc(FFMPEG_FILE_BUFFER_SIZE); - m_ioContext = m_dllAvFormat.avio_alloc_context(buffer, FFMPEG_FILE_BUFFER_SIZE, 0, this, dvd_file_read, NULL, dvd_file_seek); + unsigned char* buffer = (unsigned char*)av_malloc(FFMPEG_FILE_BUFFER_SIZE); + m_ioContext = avio_alloc_context(buffer, FFMPEG_FILE_BUFFER_SIZE, 0, this, dvd_file_read, NULL, dvd_file_seek); m_ioContext->max_packet_size = m_pInput->GetBlockSize(); if(m_ioContext->max_packet_size) m_ioContext->max_packet_size *= FFMPEG_FILE_BUFFER_SIZE / m_ioContext->max_packet_size; @@ -332,7 +322,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) bool trySPDIFonly = (m_pInput->GetContent() == "audio/x-spdif-compressed"); if (!trySPDIFonly) - m_dllAvFormat.av_probe_input_buffer(m_ioContext, &iformat, strFile.c_str(), NULL, 0, 0); + av_probe_input_buffer(m_ioContext, &iformat, strFile.c_str(), NULL, 0, 0); // Use the more low-level code in case we have been built against an old // FFmpeg without the above av_probe_input_buffer(), or in case we only @@ -349,7 +339,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) pd.filename = strFile.c_str(); // read data using avformat's buffers - pd.buf_size = m_dllAvFormat.avio_read(m_ioContext, pd.buf, m_ioContext->max_packet_size ? m_ioContext->max_packet_size : m_ioContext->buffer_size); + pd.buf_size = avio_read(m_ioContext, pd.buf, m_ioContext->max_packet_size ? m_ioContext->max_packet_size : m_ioContext->buffer_size); if (pd.buf_size <= 0) { CLog::Log(LOGERROR, "%s - error reading from input stream, %s", __FUNCTION__, CURL::GetRedacted(strFile).c_str()); @@ -358,7 +348,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) memset(pd.buf+pd.buf_size, 0, AVPROBE_PADDING_SIZE); // restore position again - m_dllAvFormat.avio_seek(m_ioContext , 0, SEEK_SET); + avio_seek(m_ioContext , 0, SEEK_SET); // the advancedsetting is for allowing the user to force outputting the // 44.1 kHz DTS wav file as PCM, so that an A/V receiver can decode @@ -372,7 +362,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) // AC3 is always wrapped in iec61937 (ffmpeg "spdif"), while DTS // may be just padded. AVInputFormat *iformat2; - iformat2 = m_dllAvFormat.av_find_input_format("spdif"); + iformat2 = av_find_input_format("spdif"); if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4) { @@ -381,7 +371,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) else { // not spdif or no spdif demuxer, try dts - iformat2 = m_dllAvFormat.av_find_input_format("dts"); + iformat2 = av_find_input_format("dts"); if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4) { @@ -404,13 +394,13 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) /* check if we can get a hint from content */ if( content.compare("audio/aacp") == 0 ) - iformat = m_dllAvFormat.av_find_input_format("aac"); + iformat = av_find_input_format("aac"); else if( content.compare("audio/aac") == 0 ) - iformat = m_dllAvFormat.av_find_input_format("aac"); + iformat = av_find_input_format("aac"); else if( content.compare("video/flv") == 0 ) - iformat = m_dllAvFormat.av_find_input_format("flv"); + iformat = av_find_input_format("flv"); else if( content.compare("video/x-flv") == 0 ) - iformat = m_dllAvFormat.av_find_input_format("flv"); + iformat = av_find_input_format("flv"); } if (!iformat) @@ -430,7 +420,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) m_pFormatContext->pb = m_ioContext; - if (m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, NULL) < 0) + if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, NULL) < 0) { CLog::Log(LOGERROR, "%s - Error, could not open file %s", __FUNCTION__, CURL::GetRedacted(strFile).c_str()); Dispose(); @@ -458,7 +448,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) CLog::Log(LOGDEBUG, "%s - avformat_find_stream_info starting", __FUNCTION__); - int iErr = m_dllAvFormat.avformat_find_stream_info(m_pFormatContext, NULL); + int iErr = avformat_find_stream_info(m_pFormatContext, NULL); if (iErr < 0) { CLog::Log(LOGWARNING,"could not find codec parameters for %s", CURL::GetRedacted(strFile).c_str()); @@ -483,7 +473,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) m_pFormatContext->flags |= AVFMT_FLAG_NONBLOCK; // print some extra information - m_dllAvFormat.av_dump_format(m_pFormatContext, 0, strFile.c_str(), 0); + av_dump_format(m_pFormatContext, 0, strFile.c_str(), 0); UpdateCurrentPTS(); @@ -495,7 +485,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput) void CDVDDemuxFFmpeg::Dispose() { m_pkt.result = -1; - m_dllAvCodec.av_free_packet(&m_pkt.pkt); + av_free_packet(&m_pkt.pkt); if (m_pFormatContext) { @@ -504,13 +494,13 @@ void CDVDDemuxFFmpeg::Dispose() CLog::Log(LOGWARNING, "CDVDDemuxFFmpeg::Dispose - demuxer changed our byte context behind our back, possible memleak"); m_ioContext = m_pFormatContext->pb; } - m_dllAvFormat.avformat_close_input(&m_pFormatContext); + avformat_close_input(&m_pFormatContext); } if(m_ioContext) { - m_dllAvUtil.av_free(m_ioContext->buffer); - m_dllAvUtil.av_free(m_ioContext); + av_free(m_ioContext->buffer); + av_free(m_ioContext); } m_ioContext = NULL; @@ -520,10 +510,6 @@ void CDVDDemuxFFmpeg::Dispose() DisposeStreams(); m_pInput = NULL; - - m_dllAvFormat.Unload(); - m_dllAvCodec.Unload(); - m_dllAvUtil.Unload(); } void CDVDDemuxFFmpeg::Reset() @@ -537,12 +523,12 @@ void CDVDDemuxFFmpeg::Flush() { // naughty usage of an internal ffmpeg function if (m_pFormatContext) - m_dllAvFormat.av_read_frame_flush(m_pFormatContext); + av_read_frame_flush(m_pFormatContext); m_iCurrentPts = DVD_NOPTS_VALUE; m_pkt.result = -1; - m_dllAvCodec.av_free_packet(&m_pkt.pkt); + av_free_packet(&m_pkt.pkt); } void CDVDDemuxFFmpeg::Abort() @@ -558,12 +544,12 @@ void CDVDDemuxFFmpeg::SetSpeed(int iSpeed) if(m_speed != DVD_PLAYSPEED_PAUSE && iSpeed == DVD_PLAYSPEED_PAUSE) { m_pInput->Pause((double)m_iCurrentPts); - m_dllAvFormat.av_read_pause(m_pFormatContext); + av_read_pause(m_pFormatContext); } else if(m_speed == DVD_PLAYSPEED_PAUSE && iSpeed != DVD_PLAYSPEED_PAUSE) { m_pInput->Pause((double)m_iCurrentPts); - m_dllAvFormat.av_read_play(m_pFormatContext); + av_read_play(m_pFormatContext); } m_speed = iSpeed; @@ -604,10 +590,10 @@ AVDictionary *CDVDDemuxFFmpeg::GetFFMpegOptionsFromURL(const CURL &url) const CStdString &value = it->second; if (name.Equals("seekable")) - m_dllAvUtil.av_dict_set(&options, "seekable", value.c_str(), 0); + av_dict_set(&options, "seekable", value.c_str(), 0); else if (name.Equals("User-Agent")) { - m_dllAvUtil.av_dict_set(&options, "user-agent", value.c_str(), 0); + av_dict_set(&options, "user-agent", value.c_str(), 0); hasUserAgent = true; } else if (!name.Equals("auth") && !name.Equals("Encoding")) @@ -616,14 +602,14 @@ AVDictionary *CDVDDemuxFFmpeg::GetFFMpegOptionsFromURL(const CURL &url) } if (!hasUserAgent) // set default xbmc user-agent. - m_dllAvUtil.av_dict_set(&options, "user-agent", g_advancedSettings.m_userAgent.c_str(), 0); + av_dict_set(&options, "user-agent", g_advancedSettings.m_userAgent.c_str(), 0); if (!headers.empty()) - m_dllAvUtil.av_dict_set(&options, "headers", headers.c_str(), 0); + av_dict_set(&options, "headers", headers.c_str(), 0); std::string cookies; if (XFILE::CCurlFile::GetCookies(url, cookies)) - m_dllAvUtil.av_dict_set(&options, "cookies", cookies.c_str(), 0); + av_dict_set(&options, "cookies", cookies.c_str(), 0); } return options; @@ -676,7 +662,7 @@ DemuxPacket* CDVDDemuxFFmpeg::Read() // timeout reads after 100ms m_timeout.Set(20000); - m_pkt.result = m_dllAvFormat.av_read_frame(m_pFormatContext, &m_pkt.pkt); + m_pkt.result = av_read_frame(m_pFormatContext, &m_pkt.pkt); m_timeout.SetInfinite(); } @@ -715,7 +701,7 @@ DemuxPacket* CDVDDemuxFFmpeg::Read() CLog::Log(LOGERROR, "CDVDDemuxFFmpeg::Read() returned invalid packet and eof reached"); m_pkt.result = -1; - m_dllAvCodec.av_free_packet(&m_pkt.pkt); + av_free_packet(&m_pkt.pkt); } else { @@ -801,7 +787,7 @@ DemuxPacket* CDVDDemuxFFmpeg::Read() if(duration > stream->duration) { stream->duration = duration; - duration = m_dllAvUtil.av_rescale_rnd(stream->duration, (int64_t)stream->time_base.num * AV_TIME_BASE, stream->time_base.den, AV_ROUND_NEAR_INF); + duration = av_rescale_rnd(stream->duration, (int64_t)stream->time_base.num * AV_TIME_BASE, stream->time_base.den, AV_ROUND_NEAR_INF); if ((m_pFormatContext->duration == (int64_t)AV_NOPTS_VALUE) || (m_pFormatContext->duration != (int64_t)AV_NOPTS_VALUE && duration > m_pFormatContext->duration)) m_pFormatContext->duration = duration; @@ -813,7 +799,7 @@ DemuxPacket* CDVDDemuxFFmpeg::Read() pPacket->iStreamId = m_pkt.pkt.stream_index; } m_pkt.result = -1; - m_dllAvCodec.av_free_packet(&m_pkt.pkt); + av_free_packet(&m_pkt.pkt); } } } // end of lock scope @@ -870,7 +856,7 @@ bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts) time = 0; m_pkt.result = -1; - m_dllAvCodec.av_free_packet(&m_pkt.pkt); + av_free_packet(&m_pkt.pkt); CDVDInputStream::ISeekTime* ist = dynamic_cast<CDVDInputStream::ISeekTime*>(m_pInput); if (ist) @@ -903,7 +889,7 @@ bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts) int ret; { CSingleLock lock(m_critSection); - ret = m_dllAvFormat.av_seek_frame(m_pFormatContext, -1, seek_pts, backwords ? AVSEEK_FLAG_BACKWARD : 0); + ret = av_seek_frame(m_pFormatContext, -1, seek_pts, backwords ? AVSEEK_FLAG_BACKWARD : 0); if(ret >= 0) UpdateCurrentPTS(); @@ -928,13 +914,13 @@ bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts) bool CDVDDemuxFFmpeg::SeekByte(int64_t pos) { CSingleLock lock(m_critSection); - int ret = m_dllAvFormat.av_seek_frame(m_pFormatContext, -1, pos, AVSEEK_FLAG_BYTE); + int ret = av_seek_frame(m_pFormatContext, -1, pos, AVSEEK_FLAG_BYTE); if(ret >= 0) UpdateCurrentPTS(); m_pkt.result = -1; - m_dllAvCodec.av_free_packet(&m_pkt.pkt); + av_free_packet(&m_pkt.pkt); return (ret >= 0); } @@ -1081,8 +1067,8 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int iId) st->iBitRate = pStream->codec->bit_rate; st->iBitsPerSample = pStream->codec->bits_per_raw_sample; - if(m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0)) - st->m_description = m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0)->value; + if(av_dict_get(pStream->metadata, "title", NULL, 0)) + st->m_description = av_dict_get(pStream->metadata, "title", NULL, 0)->value; break; } @@ -1100,7 +1086,7 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int iId) st->bPTSInvalid = true; #if defined(AVFORMAT_HAS_STREAM_GET_R_FRAME_RATE) - AVRational r_frame_rate = m_dllAvFormat.av_stream_get_r_frame_rate(pStream); + AVRational r_frame_rate = av_stream_get_r_frame_rate(pStream); #else AVRational r_frame_rate = pStream->r_frame_rate; #endif @@ -1149,11 +1135,11 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int iId) st->iOrientation = 0; st->iBitsPerPixel = pStream->codec->bits_per_coded_sample; - AVDictionaryEntry *rtag = m_dllAvUtil.av_dict_get(pStream->metadata, "rotate", NULL, 0); + AVDictionaryEntry *rtag = av_dict_get(pStream->metadata, "rotate", NULL, 0); if (rtag) st->iOrientation = atoi(rtag->value); - rtag = m_dllAvUtil.av_dict_get(pStream->metadata, "stereo_mode", NULL, 0); + rtag = av_dict_get(pStream->metadata, "stereo_mode", NULL, 0); if (rtag && rtag->value) st->stereo_mode = rtag->value; @@ -1194,8 +1180,8 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int iId) CDemuxStreamSubtitleFFmpeg* st = new CDemuxStreamSubtitleFFmpeg(this, pStream); stream = st; - if(m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0)) - st->m_description = m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0)->value; + if(av_dict_get(pStream->metadata, "title", NULL, 0)) + st->m_description = av_dict_get(pStream->metadata, "title", NULL, 0)->value; break; } @@ -1208,7 +1194,7 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int iId) { std::string fileName = "special://temp/fonts/"; XFILE::CDirectory::Create(fileName); - AVDictionaryEntry *nameTag = m_dllAvUtil.av_dict_get(pStream->metadata, "filename", NULL, 0); + AVDictionaryEntry *nameTag = av_dict_get(pStream->metadata, "filename", NULL, 0); if (!nameTag) { CLog::Log(LOGERROR, "%s: TTF attachment has no name", __FUNCTION__); break; @@ -1249,7 +1235,7 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int iId) stream->pPrivate = pStream; stream->flags = (CDemuxStream::EFlags)pStream->disposition; - AVDictionaryEntry *langTag = m_dllAvUtil.av_dict_get(pStream->metadata, "language", NULL, 0); + AVDictionaryEntry *langTag = av_dict_get(pStream->metadata, "language", NULL, 0); if (langTag) strncpy(stream->language, langTag->value, 3); @@ -1380,7 +1366,7 @@ void CDVDDemuxFFmpeg::GetChapterName(std::string& strChapterName) if(chapterIdx <= 0) return; - AVDictionaryEntry *titleTag = m_dllAvUtil.av_dict_get(m_pFormatContext->chapters[chapterIdx-1]->metadata, + AVDictionaryEntry *titleTag = av_dict_get(m_pFormatContext->chapters[chapterIdx-1]->metadata, "title", NULL, 0); if (titleTag) strChapterName = titleTag->value; @@ -1461,7 +1447,7 @@ void CDVDDemuxFFmpeg::GetStreamCodecName(int iStreamId, CStdString &strName) } #endif - AVCodec *codec = m_dllAvCodec.avcodec_find_decoder(stream->codec); + AVCodec *codec = avcodec_find_decoder(stream->codec); if (codec) strName = codec->name; } diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h index aef5ab1864..34ddd576fb 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h @@ -21,15 +21,16 @@ */ #include "DVDDemux.h" -#include "DllAvFormat.h" -#include "DllAvCodec.h" -#include "DllAvUtil.h" - #include "threads/CriticalSection.h" #include "threads/SystemClock.h" - #include <map> +extern "C" { +#include "libavformat/avformat.h" +#include "libavcodec/avcodec.h" +#include "libavutil/avutil.h" +} + class CDVDDemuxFFmpeg; class CURL; @@ -139,10 +140,6 @@ protected: AVIOContext* m_ioContext; - DllAvFormat m_dllAvFormat; - DllAvCodec m_dllAvCodec; - DllAvUtil m_dllAvUtil; - double m_iCurrentPts; // used for stream length estimation bool m_bMatroska; bool m_bAVI; diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp index 7d0a732112..6c8e6db09d 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp @@ -47,12 +47,12 @@ void CDemuxStreamPVRInternal::DisposeParser() { if (m_parser) { - m_parent->m_dllAvCodec.av_parser_close(m_parser); + av_parser_close(m_parser); m_parser = NULL; } if (m_context) { - m_parent->m_dllAvCodec.avcodec_close(m_context); + avcodec_close(m_context); m_context = NULL; } } @@ -113,17 +113,8 @@ CDVDDemuxPVRClient::~CDVDDemuxPVRClient() bool CDVDDemuxPVRClient::Open(CDVDInputStream* pInput) { - if (!m_dllAvCodec.Load()) - { - CLog::Log(LOGWARNING, "%s could not load ffmpeg", __FUNCTION__); - return false; - } - Abort(); - // register codecs - m_dllAvCodec.avcodec_register_all(); - m_pInput = pInput; if (!g_PVRClients->GetPlayingClient(m_pvrClient)) return false; @@ -141,8 +132,6 @@ void CDVDDemuxPVRClient::Dispose() } m_pInput = NULL; - - m_dllAvCodec.Unload(); } void CDVDDemuxPVRClient::DisposeStream(int iStreamId) @@ -192,7 +181,7 @@ void CDVDDemuxPVRClient::ParsePacket(DemuxPacket* pkt) if(pvr->m_context == NULL) { - AVCodec *codec = m_dllAvCodec.avcodec_find_decoder(st->codec); + AVCodec *codec = avcodec_find_decoder(st->codec); if (codec == NULL) { CLog::Log(LOGERROR, "%s - can't find decoder", __FUNCTION__); @@ -200,7 +189,7 @@ void CDVDDemuxPVRClient::ParsePacket(DemuxPacket* pkt) return; } - pvr->m_context = m_dllAvCodec.avcodec_alloc_context3(codec); + pvr->m_context = avcodec_alloc_context3(codec); if(pvr->m_context == NULL) { CLog::Log(LOGERROR, "%s - can't allocate context", __FUNCTION__); @@ -231,7 +220,7 @@ void CDVDDemuxPVRClient::ParsePacket(DemuxPacket* pkt) uint8_t *outbuf = NULL; int outbuf_size = 0; - int len = m_dllAvCodec.av_parser_parse2(pvr->m_parser + int len = av_parser_parse2(pvr->m_parser , pvr->m_context, &outbuf, &outbuf_size , pkt->pData, pkt->iSize , (int64_t)(pkt->pts * DVD_TIME_BASE) @@ -347,7 +336,7 @@ void CDVDDemuxPVRClient::RequestStreams() if (!m_streams[i]) { st = new CDemuxStreamAudioPVRClient(this); - st->m_parser = m_dllAvCodec.av_parser_init(props.stream[i].iCodecId); + st->m_parser = av_parser_init(props.stream[i].iCodecId); if(st->m_parser) st->m_parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; } @@ -374,7 +363,7 @@ void CDVDDemuxPVRClient::RequestStreams() if (!m_streams[i]) { st = new CDemuxStreamVideoPVRClient(this); - st->m_parser = m_dllAvCodec.av_parser_init(props.stream[i].iCodecId); + st->m_parser = av_parser_init(props.stream[i].iCodecId); if(st->m_parser) st->m_parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; } diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h index 6ebf41e5a8..e5f603cd85 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h @@ -21,11 +21,13 @@ #include "DVDDemux.h" #include <map> -#include "DllAvCodec.h" -#include "DllAvFormat.h" - #include "pvr/addons/PVRClient.h" +extern "C" { +#include "libavcodec/avcodec.h" +#include "libavformat/avformat.h" +} + class CDVDDemuxPVRClient; struct PVR_STREAM_PROPERTIES; @@ -108,8 +110,6 @@ protected: CDemuxStream* m_streams[MAX_STREAMS]; // maximum number of streams that ffmpeg can handle boost::shared_ptr<PVR::CPVRClient> m_pvrClient; - DllAvCodec m_dllAvCodec; - private: void RequestStreams(); void ParsePacket(DemuxPacket* pPacket); diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxUtils.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxUtils.cpp index 811de23cf2..ab298b205d 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxUtils.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxUtils.cpp @@ -24,7 +24,10 @@ #include "DVDDemuxUtils.h" #include "DVDClock.h" #include "utils/log.h" -#include "DllAvCodec.h" + +extern "C" { +#include "libavcodec/avcodec.h" +} void CDVDDemuxUtils::FreeDemuxPacket(DemuxPacket* pPacket) { diff --git a/xbmc/cores/dvdplayer/DVDFileInfo.cpp b/xbmc/cores/dvdplayer/DVDFileInfo.cpp index fd104d9ebc..4670fe55db 100644 --- a/xbmc/cores/dvdplayer/DVDFileInfo.cpp +++ b/xbmc/cores/dvdplayer/DVDFileInfo.cpp @@ -46,9 +46,10 @@ #include "DVDCodecs/Video/DVDVideoCodecFFmpeg.h" #include "DVDDemuxers/DVDDemuxVobsub.h" -#include "DllAvCodec.h" -#include "DllSwScale.h" +#include "libavcodec/avcodec.h" +#include "libswscale/swscale.h" #include "filesystem/File.h" +#include "cores/FFmpeg.h" #include "TextureCache.h" #include "Util.h" #include "utils/LangCodeExpander.h" @@ -262,11 +263,8 @@ bool CDVDFileInfo::ExtractThumb(const CStdString &strPath, CTextureDetails &deta aspect = hint.aspect; unsigned int nHeight = (unsigned int)((double)g_advancedSettings.GetThumbSize() / aspect); - DllSwScale dllSwScale; - dllSwScale.Load(); - uint8_t *pOutBuf = new uint8_t[nWidth * nHeight * 4]; - struct SwsContext *context = dllSwScale.sws_getContext(picture.iWidth, picture.iHeight, + struct SwsContext *context = sws_getContext(picture.iWidth, picture.iHeight, PIX_FMT_YUV420P, nWidth, nHeight, PIX_FMT_BGRA, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL); if (context) @@ -276,8 +274,8 @@ bool CDVDFileInfo::ExtractThumb(const CStdString &strPath, CTextureDetails &deta uint8_t *dst[] = { pOutBuf, 0, 0, 0 }; int dstStride[] = { (int)nWidth*4, 0, 0, 0 }; int orientation = DegreeToOrientation(hint.orientation); - dllSwScale.sws_scale(context, src, srcStride, 0, picture.iHeight, dst, dstStride); - dllSwScale.sws_freeContext(context); + sws_scale(context, src, srcStride, 0, picture.iHeight, dst, dstStride); + sws_freeContext(context); details.width = nWidth; details.height = nHeight; @@ -285,7 +283,6 @@ bool CDVDFileInfo::ExtractThumb(const CStdString &strPath, CTextureDetails &deta bOk = true; } - dllSwScale.Unload(); delete [] pOutBuf; } } diff --git a/xbmc/cores/dvdplayer/DVDPlayer.cpp b/xbmc/cores/dvdplayer/DVDPlayer.cpp index 3a37dee87e..3f2e0dfc71 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayer.cpp @@ -51,7 +51,7 @@ #include "ApplicationMessenger.h" #include "filesystem/File.h" #include "pictures/Picture.h" -#include "DllSwScale.h" +#include "libswscale/swscale.h" #ifdef HAS_VIDEO_PLAYBACK #include "cores/VideoRenderers/RenderManager.h" #endif diff --git a/xbmc/cores/dvdplayer/DVDStreamInfo.h b/xbmc/cores/dvdplayer/DVDStreamInfo.h index 8aa9b95d63..5b3ee04fe6 100644 --- a/xbmc/cores/dvdplayer/DVDStreamInfo.h +++ b/xbmc/cores/dvdplayer/DVDStreamInfo.h @@ -25,7 +25,10 @@ #endif #include "DVDDemuxers/DVDDemux.h" -#include "DllAvCodec.h" + +extern "C" { +#include "libavcodec/avcodec.h" +} class CDemuxStream; diff --git a/xbmc/cores/omxplayer/OMXAudio.cpp b/xbmc/cores/omxplayer/OMXAudio.cpp index dd804124dc..17c7d46e27 100644 --- a/xbmc/cores/omxplayer/OMXAudio.cpp +++ b/xbmc/cores/omxplayer/OMXAudio.cpp @@ -41,6 +41,10 @@ #include "cores/AudioEngine/Utils/AEConvert.h" #include "cores/AudioEngine/AEFactory.h" +extern "C" { +#include "libavutil/crc.h" +} + using namespace std; static const uint16_t AC3Bitrates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640}; @@ -414,9 +418,6 @@ bool COMXAudio::Initialize(AEAudioFormat format, OMXClock *clock, CDVDStreamInfo Deinitialize(); - if(!m_dllAvUtil.Load()) - return false; - m_HWDecode = bUseHWDecode; m_Passthrough = bUsePassthrough; @@ -746,8 +747,6 @@ bool COMXAudio::Deinitialize() m_extradata = NULL; m_extrasize = 0; - m_dllAvUtil.Unload(); - while(!m_ampqueue.empty()) m_ampqueue.pop_front(); @@ -1543,7 +1542,7 @@ unsigned int COMXAudio::SyncAC3(BYTE* pData, unsigned int iSize) else crc_size = (framesize >> 1) + (framesize >> 3) - 1; if (crc_size <= iSize - skip) - if(m_dllAvUtil.av_crc(m_dllAvUtil.av_crc_get_table(AV_CRC_16_ANSI), 0, &pData[2], crc_size * 2)) + if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &pData[2], crc_size * 2)) continue; /* if we get here, we can sync */ diff --git a/xbmc/cores/omxplayer/OMXAudio.h b/xbmc/cores/omxplayer/OMXAudio.h index 804bd2aadc..1c53ac549d 100644 --- a/xbmc/cores/omxplayer/OMXAudio.h +++ b/xbmc/cores/omxplayer/OMXAudio.h @@ -36,12 +36,15 @@ #include "OMXClock.h" #include "OMXCore.h" -#include "DllAvCodec.h" -#include "DllAvUtil.h" #include "PCMRemap.h" #include "threads/CriticalSection.h" +extern "C" { +#include "libavcodec/avcodec.h" +#include "libavutil/avutil.h" +} + #define AUDIO_BUFFER_SECONDS 3 #define VIS_PACKET_SIZE 512 @@ -164,7 +167,6 @@ protected: COMXCoreTunel m_omx_tunnel_decoder; COMXCoreTunel m_omx_tunnel_splitter_analog; COMXCoreTunel m_omx_tunnel_splitter_hdmi; - DllAvUtil m_dllAvUtil; static void CheckOutputBufferSize(void **buffer, int *oldSize, int newSize); CCriticalSection m_critSection; diff --git a/xbmc/cores/omxplayer/OMXAudioCodec.h b/xbmc/cores/omxplayer/OMXAudioCodec.h index 04a4574169..59727e6834 100644 --- a/xbmc/cores/omxplayer/OMXAudioCodec.h +++ b/xbmc/cores/omxplayer/OMXAudioCodec.h @@ -26,7 +26,7 @@ #include "config.h" #endif #include <vector> -#include "DllAvCodec.h" +#include "libavcodec/avcodec.h" struct AVStream; diff --git a/xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp b/xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp index 5503a0ec5d..dd4c11fe46 100644 --- a/xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp +++ b/xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp @@ -44,7 +44,7 @@ COMXAudioCodecOMX::COMXAudioCodecOMX() COMXAudioCodecOMX::~COMXAudioCodecOMX() { - m_dllAvUtil.av_free(m_pBufferOutput); + av_free(m_pBufferOutput); m_pBufferOutput = NULL; m_iBufferOutputAlloced = 0; Dispose(); @@ -55,12 +55,7 @@ bool COMXAudioCodecOMX::Open(CDVDStreamInfo &hints) AVCodec* pCodec; m_bOpenedCodec = false; - if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load() || !m_dllSwResample.Load()) - return false; - - m_dllAvCodec.avcodec_register_all(); - - pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec); + pCodec = avcodec_find_decoder(hints.codec); if (!pCodec) { CLog::Log(LOGDEBUG,"COMXAudioCodecOMX::Open() Unable to find codec %d", hints.codec); @@ -68,7 +63,7 @@ bool COMXAudioCodecOMX::Open(CDVDStreamInfo &hints) } m_bFirstFrame = true; - m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec); + m_pCodecContext = avcodec_alloc_context3(pCodec); m_pCodecContext->debug_mv = 0; m_pCodecContext->debug = 0; m_pCodecContext->workaround_bugs = 1; @@ -89,18 +84,18 @@ bool COMXAudioCodecOMX::Open(CDVDStreamInfo &hints) if( hints.extradata && hints.extrasize > 0 ) { m_pCodecContext->extradata_size = hints.extrasize; - m_pCodecContext->extradata = (uint8_t*)m_dllAvUtil.av_mallocz(hints.extrasize + FF_INPUT_BUFFER_PADDING_SIZE); + m_pCodecContext->extradata = (uint8_t*)av_mallocz(hints.extrasize + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(m_pCodecContext->extradata, hints.extradata, hints.extrasize); } - if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) + if (avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) { CLog::Log(LOGDEBUG,"COMXAudioCodecOMX::Open() Unable to open codec"); Dispose(); return false; } - m_pFrame1 = m_dllAvCodec.avcodec_alloc_frame(); + m_pFrame1 = avcodec_alloc_frame(); m_bOpenedCodec = true; m_iSampleFormat = AV_SAMPLE_FMT_NONE; m_desiredSampleFormat = m_pCodecContext->sample_fmt == AV_SAMPLE_FMT_S16 ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_FLTP; @@ -109,26 +104,22 @@ bool COMXAudioCodecOMX::Open(CDVDStreamInfo &hints) void COMXAudioCodecOMX::Dispose() { - if (m_pFrame1) m_dllAvUtil.av_free(m_pFrame1); + if (m_pFrame1) av_free(m_pFrame1); m_pFrame1 = NULL; if (m_pConvert) - m_dllSwResample.swr_free(&m_pConvert); + swr_free(&m_pConvert); if (m_pCodecContext) { - if (m_pCodecContext->extradata) m_dllAvUtil.av_free(m_pCodecContext->extradata); + if (m_pCodecContext->extradata) av_free(m_pCodecContext->extradata); m_pCodecContext->extradata = NULL; - if (m_bOpenedCodec) m_dllAvCodec.avcodec_close(m_pCodecContext); + if (m_bOpenedCodec) avcodec_close(m_pCodecContext); m_bOpenedCodec = false; - m_dllAvUtil.av_free(m_pCodecContext); + av_free(m_pCodecContext); m_pCodecContext = NULL; } - m_dllAvCodec.Unload(); - m_dllAvUtil.Unload(); - m_dllSwResample.Unload(); - m_bGotFrame = false; } @@ -139,10 +130,10 @@ int COMXAudioCodecOMX::Decode(BYTE* pData, int iSize) AVPacket avpkt; m_bGotFrame = false; - m_dllAvCodec.av_init_packet(&avpkt); + av_init_packet(&avpkt); avpkt.data = pData; avpkt.size = iSize; - iBytesUsed = m_dllAvCodec.avcodec_decode_audio4( m_pCodecContext + iBytesUsed = avcodec_decode_audio4( m_pCodecContext , m_pFrame1 , &got_frame , &avpkt); @@ -176,15 +167,15 @@ int COMXAudioCodecOMX::GetData(BYTE** dst) return 0; int inLineSize, outLineSize; /* input audio is aligned */ - int inputSize = m_dllAvUtil.av_samples_get_buffer_size(&inLineSize, m_pCodecContext->channels, m_pFrame1->nb_samples, m_pCodecContext->sample_fmt, 0); + int inputSize = av_samples_get_buffer_size(&inLineSize, m_pCodecContext->channels, m_pFrame1->nb_samples, m_pCodecContext->sample_fmt, 0); /* output audio will be packed */ - int outputSize = m_dllAvUtil.av_samples_get_buffer_size(&outLineSize, m_pCodecContext->channels, m_pFrame1->nb_samples, m_desiredSampleFormat, 1); + int outputSize = av_samples_get_buffer_size(&outLineSize, m_pCodecContext->channels, m_pFrame1->nb_samples, m_desiredSampleFormat, 1); bool cont = !m_pFrame1->data[1] || (m_pFrame1->data[1] == m_pFrame1->data[0] + inLineSize && inLineSize == outLineSize && inLineSize * m_pCodecContext->channels == inputSize); if (m_iBufferOutputAlloced < outputSize) { - m_dllAvUtil.av_free(m_pBufferOutput); - m_pBufferOutput = (BYTE*)m_dllAvUtil.av_malloc(outputSize + FF_INPUT_BUFFER_PADDING_SIZE); + av_free(m_pBufferOutput); + m_pBufferOutput = (BYTE*)av_malloc(outputSize + FF_INPUT_BUFFER_PADDING_SIZE); m_iBufferOutputAlloced = outputSize; } *dst = m_pBufferOutput; @@ -194,21 +185,21 @@ int COMXAudioCodecOMX::GetData(BYTE** dst) { if(m_pConvert && (m_pCodecContext->sample_fmt != m_iSampleFormat || m_channels != m_pCodecContext->channels)) { - m_dllSwResample.swr_free(&m_pConvert); + swr_free(&m_pConvert); m_channels = m_pCodecContext->channels; } if(!m_pConvert) { m_iSampleFormat = m_pCodecContext->sample_fmt; - m_pConvert = m_dllSwResample.swr_alloc_set_opts(NULL, - m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels), + m_pConvert = swr_alloc_set_opts(NULL, + av_get_default_channel_layout(m_pCodecContext->channels), m_desiredSampleFormat, m_pCodecContext->sample_rate, - m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels), + av_get_default_channel_layout(m_pCodecContext->channels), m_pCodecContext->sample_fmt, m_pCodecContext->sample_rate, 0, NULL); - if(!m_pConvert || m_dllSwResample.swr_init(m_pConvert) < 0) + if(!m_pConvert || swr_init(m_pConvert) < 0) { CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to initialise convert format %d to %d", m_pCodecContext->sample_fmt, m_desiredSampleFormat); return 0; @@ -217,8 +208,8 @@ int COMXAudioCodecOMX::GetData(BYTE** dst) /* use unaligned flag to keep output packed */ uint8_t *out_planes[m_pCodecContext->channels]; - if(m_dllAvUtil.av_samples_fill_arrays(out_planes, NULL, m_pBufferOutput, m_pCodecContext->channels, m_pFrame1->nb_samples, m_desiredSampleFormat, 1) < 0 || - m_dllSwResample.swr_convert(m_pConvert, out_planes, m_pFrame1->nb_samples, (const uint8_t **)m_pFrame1->data, m_pFrame1->nb_samples) < 0) + if(av_samples_fill_arrays(out_planes, NULL, m_pBufferOutput, m_pCodecContext->channels, m_pFrame1->nb_samples, m_desiredSampleFormat, 1) < 0 || + swr_convert(m_pConvert, out_planes, m_pFrame1->nb_samples, (const uint8_t **)m_pFrame1->data, m_pFrame1->nb_samples) < 0) { CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to convert format %d to %d", (int)m_pCodecContext->sample_fmt, m_desiredSampleFormat); outputSize = 0; @@ -235,8 +226,8 @@ int COMXAudioCodecOMX::GetData(BYTE** dst) { /* copy to a contiguous buffer */ uint8_t *out_planes[m_pCodecContext->channels]; - if (m_dllAvUtil.av_samples_fill_arrays(out_planes, NULL, m_pBufferOutput, m_pCodecContext->channels, m_pFrame1->nb_samples, m_desiredSampleFormat, 1) < 0 || - m_dllAvUtil.av_samples_copy(out_planes, m_pFrame1->data, 0, 0, m_pFrame1->nb_samples, m_pCodecContext->channels, m_desiredSampleFormat) < 0 ) + if (av_samples_fill_arrays(out_planes, NULL, m_pBufferOutput, m_pCodecContext->channels, m_pFrame1->nb_samples, m_desiredSampleFormat, 1) < 0 || + av_samples_copy(out_planes, m_pFrame1->data, 0, 0, m_pFrame1->nb_samples, m_pCodecContext->channels, m_desiredSampleFormat) < 0 ) { outputSize = 0; } @@ -253,7 +244,7 @@ int COMXAudioCodecOMX::GetData(BYTE** dst) void COMXAudioCodecOMX::Reset() { - if (m_pCodecContext) m_dllAvCodec.avcodec_flush_buffers(m_pCodecContext); + if (m_pCodecContext) avcodec_flush_buffers(m_pCodecContext); m_bGotFrame = false; } @@ -302,7 +293,7 @@ uint64_t COMXAudioCodecOMX::GetChannelMap() else { CLog::Log(LOGINFO, "COMXAudioCodecOMX::GetChannelMap - FFmpeg reported %d channels, but the layout contains %d ignoring", m_pCodecContext->channels, bits); - layout = m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels); + layout = av_get_default_channel_layout(m_pCodecContext->channels); } return layout; } diff --git a/xbmc/cores/omxplayer/OMXAudioCodecOMX.h b/xbmc/cores/omxplayer/OMXAudioCodecOMX.h index 343465c564..edfcf31983 100644 --- a/xbmc/cores/omxplayer/OMXAudioCodecOMX.h +++ b/xbmc/cores/omxplayer/OMXAudioCodecOMX.h @@ -21,10 +21,13 @@ */ #include "cores/AudioEngine/Utils/AEAudioFormat.h" -#include "DllAvCodec.h" -#include "DllAvFormat.h" -#include "DllAvUtil.h" -#include "DllSwResample.h" + +extern "C" { +#include "libavcodec/avcodec.h" +#include "libavformat/avformat.h" +#include "libavutil/avutil.h" +#include "libswresample/swresample.h" +} #include "DVDStreamInfo.h" #include "linux/PlatformDefs.h" @@ -63,7 +66,4 @@ protected: bool m_bFirstFrame; bool m_bGotFrame; - DllAvCodec m_dllAvCodec; - DllAvUtil m_dllAvUtil; - DllSwResample m_dllSwResample; }; diff --git a/xbmc/cores/omxplayer/OMXPlayer.cpp b/xbmc/cores/omxplayer/OMXPlayer.cpp index 0b80be5191..502df4ae38 100644 --- a/xbmc/cores/omxplayer/OMXPlayer.cpp +++ b/xbmc/cores/omxplayer/OMXPlayer.cpp @@ -86,7 +86,7 @@ #include "ApplicationMessenger.h" #include "filesystem/File.h" #include "pictures/Picture.h" -#include "DllSwScale.h" +#include "libswscale/swscale.h" #ifdef HAS_VIDEO_PLAYBACK #include "cores/VideoRenderers/RenderManager.h" #endif diff --git a/xbmc/linux/OMXCore.h b/xbmc/linux/OMXCore.h index 54d35aa745..1b24fc11ee 100644 --- a/xbmc/linux/OMXCore.h +++ b/xbmc/linux/OMXCore.h @@ -48,7 +48,7 @@ (a).nVersion.s.nRevision = OMX_VERSION_REVISION; \ (a).nVersion.s.nStep = OMX_VERSION_STEP -#include "DllAvFormat.h" +#include "libavformat/avformat.h" #define OMX_MAX_PORTS 10 diff --git a/xbmc/music/karaoke/karaokevideobackground.cpp b/xbmc/music/karaoke/karaokevideobackground.cpp index 8652197718..ef08896c7f 100644 --- a/xbmc/music/karaoke/karaokevideobackground.cpp +++ b/xbmc/music/karaoke/karaokevideobackground.cpp @@ -24,15 +24,19 @@ #include "guilib/Texture.h" #include "guilib/GUITexture.h" #include "Application.h" -#include "DllAvFormat.h" -#include "DllAvCodec.h" -#include "DllAvUtil.h" -#include "DllSwScale.h" #include "filesystem/SpecialProtocol.h" #include "settings/AdvancedSettings.h" #include "settings/DisplaySettings.h" #include "video/FFmpegVideoDecoder.h" #include "system.h" +#include "utils/log.h" + +extern "C" { +#include "libavformat/avformat.h" +#include "libavcodec/avcodec.h" +#include "libavutil/avutil.h" +#include "libswscale/swscale.h" +} KaraokeVideoBackground::KaraokeVideoBackground() { diff --git a/xbmc/pictures/Picture.cpp b/xbmc/pictures/Picture.cpp index 93664149bd..384f2ce216 100644 --- a/xbmc/pictures/Picture.cpp +++ b/xbmc/pictures/Picture.cpp @@ -30,13 +30,17 @@ #include "filesystem/File.h" #include "utils/log.h" #include "utils/URIUtils.h" -#include "DllSwScale.h" #include "guilib/Texture.h" #include "guilib/imagefactory.h" +#include "cores/FFmpeg.h" #if defined(HAS_OMXPLAYER) #include "cores/omxplayer/OMXImage.h" #endif +extern "C" { +#include "libswscale/swscale.h" +} + using namespace XFILE; bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width, int height, int stride, const CStdString &thumbFile) @@ -230,9 +234,7 @@ void CPicture::GetScale(unsigned int width, unsigned int height, unsigned int &o bool CPicture::ScaleImage(uint8_t *in_pixels, unsigned int in_width, unsigned int in_height, unsigned int in_pitch, uint8_t *out_pixels, unsigned int out_width, unsigned int out_height, unsigned int out_pitch) { - DllSwScale dllSwScale; - dllSwScale.Load(); - struct SwsContext *context = dllSwScale.sws_getContext(in_width, in_height, PIX_FMT_BGRA, + struct SwsContext *context = sws_getContext(in_width, in_height, PIX_FMT_BGRA, out_width, out_height, PIX_FMT_BGRA, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL); @@ -243,8 +245,8 @@ bool CPicture::ScaleImage(uint8_t *in_pixels, unsigned int in_width, unsigned in if (context) { - dllSwScale.sws_scale(context, src, srcStride, 0, in_height, dst, dstStride); - dllSwScale.sws_freeContext(context); + sws_scale(context, src, srcStride, 0, in_height, dst, dstStride); + sws_freeContext(context); return true; } return false; diff --git a/xbmc/utils/BitstreamConverter.cpp b/xbmc/utils/BitstreamConverter.cpp index 80b4a22179..0f19376582 100644 --- a/xbmc/utils/BitstreamConverter.cpp +++ b/xbmc/utils/BitstreamConverter.cpp @@ -18,6 +18,9 @@ * */ +#include "utils/log.h" +#include "assert.h" + #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif @@ -285,8 +288,6 @@ CBitstreamConverter::CBitstreamConverter() m_extradata = NULL; m_extrasize = 0; m_convert_3byteTo4byteNALSize = false; - m_dllAvUtil = NULL; - m_dllAvFormat = NULL; m_convert_bytestream = false; m_sps_pps_context.sps_pps_data = NULL; } @@ -315,12 +316,8 @@ bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int if ( in_extradata[0] == 1 ) { CLog::Log(LOGINFO, "CBitstreamConverter::Open bitstream to annexb init"); - m_dllAvUtil = new DllAvUtil; - if (!m_dllAvUtil->Load()) - return false; - m_extrasize = in_extrasize; - m_extradata = (uint8_t*)m_dllAvUtil->av_malloc(in_extrasize); + m_extradata = (uint8_t*)av_malloc(in_extrasize); memcpy(m_extradata, in_extradata, in_extrasize); m_convert_bitstream = BitstreamConvertInit(m_extradata, m_extrasize); return true; @@ -328,10 +325,6 @@ bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int } else { - m_dllAvUtil = new DllAvUtil; - if (!m_dllAvUtil->Load()) - return false; - // valid avcC atom data always starts with the value 1 (version) if ( in_extradata[0] != 1 ) { @@ -341,12 +334,8 @@ bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int CLog::Log(LOGINFO, "CBitstreamConverter::Open annexb to bitstream init"); // video content is from x264 or from bytestream h264 (AnnexB format) // NAL reformating to bitstream format needed - m_dllAvFormat = new DllAvFormat; - if (!m_dllAvFormat->Load()) - return false; - AVIOContext *pb; - if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return false; m_convert_bytestream = true; // create a valid avcC atom data from ffmpeg's extradata @@ -354,13 +343,13 @@ bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int // unhook from ffmpeg's extradata in_extradata = NULL; // extract the avcC atom data into extradata then write it into avcCData for VDADecoder - in_extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &in_extradata); + in_extrasize = avio_close_dyn_buf(pb, &in_extradata); // make a copy of extradata contents - m_extradata = (uint8_t *)m_dllAvUtil->av_malloc(in_extrasize); + m_extradata = (uint8_t *)av_malloc(in_extrasize); memcpy(m_extradata, in_extradata, in_extrasize); m_extrasize = in_extrasize; // done with the converted extradata, we MUST free using av_free - m_dllAvUtil->av_free(in_extradata); + av_free(in_extradata); return true; } else @@ -376,21 +365,17 @@ bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int CLog::Log(LOGINFO, "CBitstreamConverter::Open annexb to bitstream init 3 byte to 4 byte nal"); // video content is from so silly encoder that think 3 byte NAL sizes // are valid, setup to convert 3 byte NAL sizes to 4 byte. - m_dllAvFormat = new DllAvFormat; - if (!m_dllAvFormat->Load()) - return false; - in_extradata[4] = 0xFF; m_convert_3byteTo4byteNALSize = true; - m_extradata = (uint8_t *)m_dllAvUtil->av_malloc(in_extrasize); + m_extradata = (uint8_t *)av_malloc(in_extrasize); memcpy(m_extradata, in_extradata, in_extrasize); m_extrasize = in_extrasize; return true; } } // valid avcC atom - m_extradata = (uint8_t*)m_dllAvUtil->av_malloc(in_extrasize); + m_extradata = (uint8_t*)av_malloc(in_extrasize); memcpy(m_extradata, in_extradata, in_extrasize); m_extrasize = in_extrasize; return true; @@ -407,14 +392,14 @@ bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int void CBitstreamConverter::Close(void) { if (m_sps_pps_context.sps_pps_data) - m_dllAvUtil->av_free(m_sps_pps_context.sps_pps_data), m_sps_pps_context.sps_pps_data = NULL; + av_free(m_sps_pps_context.sps_pps_data), m_sps_pps_context.sps_pps_data = NULL; if (m_convertBuffer) - m_dllAvUtil->av_free(m_convertBuffer), m_convertBuffer = NULL; + av_free(m_convertBuffer), m_convertBuffer = NULL; m_convertSize = 0; if (m_extradata) - m_dllAvUtil->av_free(m_extradata), m_extradata = NULL; + av_free(m_extradata), m_extradata = NULL; m_extrasize = 0; m_inputSize = 0; @@ -423,18 +408,13 @@ void CBitstreamConverter::Close(void) m_convert_bitstream = false; m_convert_bytestream = false; m_convert_3byteTo4byteNALSize = false; - - if (m_dllAvUtil) - delete m_dllAvUtil, m_dllAvUtil = NULL; - if (m_dllAvFormat) - delete m_dllAvFormat, m_dllAvFormat = NULL; } bool CBitstreamConverter::Convert(uint8_t *pData, int iSize) { if (m_convertBuffer) { - m_dllAvUtil->av_free(m_convertBuffer); + av_free(m_convertBuffer); m_convertBuffer = NULL; } m_inputSize = 0; @@ -487,7 +467,7 @@ bool CBitstreamConverter::Convert(uint8_t *pData, int iSize) { if(m_convertBuffer) { - m_dllAvUtil->av_free(m_convertBuffer); + av_free(m_convertBuffer); m_convertBuffer = NULL; } m_convertSize = 0; @@ -495,25 +475,25 @@ bool CBitstreamConverter::Convert(uint8_t *pData, int iSize) // convert demuxer packet from bytestream (AnnexB) to bitstream AVIOContext *pb; - if(m_dllAvFormat->avio_open_dyn_buf(&pb) < 0) + if(avio_open_dyn_buf(&pb) < 0) { return false; } m_convertSize = avc_parse_nal_units(pb, pData, iSize); - m_convertSize = m_dllAvFormat->avio_close_dyn_buf(pb, &m_convertBuffer); + m_convertSize = avio_close_dyn_buf(pb, &m_convertBuffer); } else if (m_convert_3byteTo4byteNALSize) { if(m_convertBuffer) { - m_dllAvUtil->av_free(m_convertBuffer); + av_free(m_convertBuffer); m_convertBuffer = NULL; } m_convertSize = 0; // convert demuxer packet from 3 byte NAL sizes to 4 byte AVIOContext *pb; - if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0) + if (avio_open_dyn_buf(&pb) < 0) return false; uint32_t nal_size; @@ -522,13 +502,13 @@ bool CBitstreamConverter::Convert(uint8_t *pData, int iSize) while (nal_start < end) { nal_size = BS_RB24(nal_start); - m_dllAvFormat->avio_wb16(pb, nal_size); + avio_wb16(pb, nal_size); nal_start += 3; - m_dllAvFormat->avio_write(pb, nal_start, nal_size); + avio_write(pb, nal_start, nal_size); nal_start += nal_size; } - m_convertSize = m_dllAvFormat->avio_close_dyn_buf(pb, &m_convertBuffer); + m_convertSize = avio_close_dyn_buf(pb, &m_convertBuffer); } return true; } @@ -611,14 +591,16 @@ bool CBitstreamConverter::BitstreamConvertInit(void *in_extradata, int in_extras total_size += unit_size + 4; if (total_size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE || - (extradata + 2 + unit_size) > ((uint8_t*)in_extradata + in_extrasize)) { - m_dllAvUtil->av_free(out); + (extradata + 2 + unit_size) > ((uint8_t*)in_extradata + in_extrasize)) + { + av_free(out); return false; } - tmp = m_dllAvUtil->av_realloc(out, total_size + FF_INPUT_BUFFER_PADDING_SIZE); - if (!tmp) { - m_dllAvUtil->av_free(out); - return false; + tmp = av_realloc(out, total_size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!tmp) + { + av_free(out); + return false; } out = (uint8_t*)tmp; memcpy(out + total_size - unit_size - 4, nalu_header, 4); @@ -698,7 +680,7 @@ bool CBitstreamConverter::BitstreamConvert(uint8_t* pData, int iSize, uint8_t ** return true; fail: - m_dllAvUtil->av_free(*poutbuf), *poutbuf = NULL; + av_free(*poutbuf), *poutbuf = NULL; *poutbuf_size = 0; return false; } @@ -715,7 +697,7 @@ void CBitstreamConverter::BitstreamAllocAndCopy( uint8_t **poutbuf, int *poutbuf void *tmp; *poutbuf_size += sps_pps_size + in_size + nal_header_size; - tmp = m_dllAvUtil->av_realloc(*poutbuf, *poutbuf_size); + tmp = av_realloc(*poutbuf, *poutbuf_size); if (!tmp) return; *poutbuf = (uint8_t*)tmp; @@ -750,8 +732,8 @@ const int CBitstreamConverter::avc_parse_nal_units(AVIOContext *pb, const uint8_ break; nal_end = avc_find_startcode(nal_start, end); - m_dllAvFormat->avio_wb32(pb, nal_end - nal_start); - m_dllAvFormat->avio_write(pb, nal_start, nal_end - nal_start); + avio_wb32(pb, nal_end - nal_start); + avio_write(pb, nal_start, nal_end - nal_start); size += 4 + nal_end - nal_start; nal_start = nal_end; } @@ -761,14 +743,14 @@ const int CBitstreamConverter::avc_parse_nal_units(AVIOContext *pb, const uint8_ const int CBitstreamConverter::avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size) { AVIOContext *pb; - int ret = m_dllAvFormat->avio_open_dyn_buf(&pb); + int ret = avio_open_dyn_buf(&pb); if (ret < 0) return ret; avc_parse_nal_units(pb, buf_in, *size); - m_dllAvUtil->av_freep(buf); - *size = m_dllAvFormat->avio_close_dyn_buf(pb, buf); + av_freep(buf); + *size = avio_close_dyn_buf(pb, buf); return 0; } @@ -813,26 +795,26 @@ const int CBitstreamConverter::isom_write_avcc(AVIOContext *pb, const uint8_t *d if (!sps || !pps || sps_size < 4 || sps_size > UINT16_MAX || pps_size > UINT16_MAX) assert(0); - m_dllAvFormat->avio_w8(pb, 1); /* version */ - m_dllAvFormat->avio_w8(pb, sps[1]); /* profile */ - m_dllAvFormat->avio_w8(pb, sps[2]); /* profile compat */ - m_dllAvFormat->avio_w8(pb, sps[3]); /* level */ - m_dllAvFormat->avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */ - m_dllAvFormat->avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */ + avio_w8(pb, 1); /* version */ + avio_w8(pb, sps[1]); /* profile */ + avio_w8(pb, sps[2]); /* profile compat */ + avio_w8(pb, sps[3]); /* level */ + avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */ + avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */ - m_dllAvFormat->avio_wb16(pb, sps_size); - m_dllAvFormat->avio_write(pb, sps, sps_size); + avio_wb16(pb, sps_size); + avio_write(pb, sps, sps_size); if (pps) { - m_dllAvFormat->avio_w8(pb, 1); /* number of pps */ - m_dllAvFormat->avio_wb16(pb, pps_size); - m_dllAvFormat->avio_write(pb, pps, pps_size); + avio_w8(pb, 1); /* number of pps */ + avio_wb16(pb, pps_size); + avio_write(pb, pps, pps_size); } - m_dllAvUtil->av_free(start); + av_free(start); } else { - m_dllAvFormat->avio_write(pb, data, len); + avio_write(pb, data, len); } } return 0; diff --git a/xbmc/utils/BitstreamConverter.h b/xbmc/utils/BitstreamConverter.h index d3ad34672a..c479a64eff 100644 --- a/xbmc/utils/BitstreamConverter.h +++ b/xbmc/utils/BitstreamConverter.h @@ -22,10 +22,13 @@ #define _BITSTREAMCONVERTER_H_ #include <stdint.h> -#include "DllAvUtil.h" -#include "DllAvFormat.h" -#include "DllAvFilter.h" -#include "DllAvCodec.h" + +extern "C" { +#include "libavutil/avutil.h" +#include "libavformat/avformat.h" +#include "libavfilter/avfilter.h" +#include "libavcodec/avcodec.h" +} typedef struct { int writer_le; @@ -200,8 +203,6 @@ protected: int m_extrasize; bool m_convert_3byteTo4byteNALSize; bool m_convert_bytestream; - DllAvUtil *m_dllAvUtil; - DllAvFormat *m_dllAvFormat; AVCodecID m_codec; }; diff --git a/xbmc/video/FFmpegVideoDecoder.cpp b/xbmc/video/FFmpegVideoDecoder.cpp index 155781299b..1df859f576 100644 --- a/xbmc/video/FFmpegVideoDecoder.cpp +++ b/xbmc/video/FFmpegVideoDecoder.cpp @@ -19,14 +19,16 @@ */ #include "system.h" -#include "DllAvFormat.h" -#include "DllAvCodec.h" -#include "DllAvUtil.h" -#include "DllSwScale.h" #include "guilib/Texture.h" #include "FFmpegVideoDecoder.h" +extern "C" { +#include "libavformat/avformat.h" +#include "libavcodec/avcodec.h" +#include "libavutil/avutil.h" +#include "libswscale/swscale.h" +} FFmpegVideoDecoder::FFmpegVideoDecoder() { @@ -35,61 +37,39 @@ FFmpegVideoDecoder::FFmpegVideoDecoder() m_pCodec = 0; m_pFrame = 0; m_pFrameRGB = 0; - - m_dllAvFormat = new DllAvFormat(); - m_dllAvCodec = new DllAvCodec(); - m_dllAvUtil = new DllAvUtil(); - m_dllSwScale = new DllSwScale(); } FFmpegVideoDecoder::~FFmpegVideoDecoder() { close(); - - delete m_dllAvFormat; - delete m_dllAvCodec; - delete m_dllAvUtil; - delete m_dllSwScale; } void FFmpegVideoDecoder::close() { // Free the YUV frame if ( m_pFrame ) - m_dllAvUtil->av_free( m_pFrame ); + av_free( m_pFrame ); // Free the RGB frame if ( m_pFrameRGB ) { - m_dllAvCodec->avpicture_free( m_pFrameRGB ); - m_dllAvUtil->av_free( m_pFrameRGB ); + avpicture_free( m_pFrameRGB ); + av_free( m_pFrameRGB ); } // Close the codec if ( m_pCodecCtx ) - m_dllAvCodec->avcodec_close( m_pCodecCtx ); + avcodec_close( m_pCodecCtx ); // Close the video file if ( m_pFormatCtx ) - m_dllAvFormat->avformat_close_input( &m_pFormatCtx ); + avformat_close_input( &m_pFormatCtx ); m_pFormatCtx = 0; m_pCodecCtx = 0; m_pCodec = 0; m_pFrame = 0; m_pFrameRGB = 0; - - if ( m_dllAvCodec->IsLoaded() ) - m_dllAvCodec->Unload(); - - if ( m_dllAvUtil->IsLoaded() ) - m_dllAvUtil->Unload(); - - if ( m_dllSwScale->IsLoaded() ) - m_dllSwScale->Unload(); - - if ( m_dllAvFormat->IsLoaded() ) - m_dllAvFormat->Unload(); } bool FFmpegVideoDecoder::isOpened() const @@ -108,7 +88,7 @@ double FFmpegVideoDecoder::getDuration() const double FFmpegVideoDecoder::getFramesPerSecond() const { #if defined(AVFORMAT_HAS_STREAM_GET_R_FRAME_RATE) - return m_pFormatCtx ? av_q2d( m_dllAvFormat->av_stream_get_r_frame_rate( m_pFormatCtx->streams[ m_videoStream ] ) ) : 0.0; + return m_pFormatCtx ? av_q2d( av_stream_get_r_frame_rate( m_pFormatCtx->streams[ m_videoStream ] ) ) : 0.0; #else return m_pFormatCtx ? av_q2d( m_pFormatCtx->streams[ m_videoStream ]->r_frame_rate ) : 0.0; #endif @@ -161,17 +141,8 @@ bool FFmpegVideoDecoder::open( const CStdString& filename ) // See http://dranger.com/ffmpeg/tutorial01.html close(); - if ( !m_dllAvUtil->Load() || !m_dllAvCodec->Load() || !m_dllSwScale->Load() || !m_dllAvFormat->Load() ) - { - m_errorMsg = "Failed to load FFMpeg libraries"; - return false; - } - - m_dllAvCodec->avcodec_register_all(); - m_dllAvFormat->av_register_all(); - // Open the video file - if ( m_dllAvFormat->avformat_open_input( &m_pFormatCtx, filename.c_str(), NULL, NULL ) < 0 ) + if ( avformat_open_input( &m_pFormatCtx, filename.c_str(), NULL, NULL ) < 0 ) { m_errorMsg = "Could not open the video file"; close(); @@ -179,7 +150,7 @@ bool FFmpegVideoDecoder::open( const CStdString& filename ) } // Retrieve the stream information - if ( m_dllAvFormat->avformat_find_stream_info( m_pFormatCtx, 0 ) < 0 ) + if ( avformat_find_stream_info( m_pFormatCtx, 0 ) < 0 ) { m_errorMsg = "Could not find the stream information"; close(); @@ -209,7 +180,7 @@ bool FFmpegVideoDecoder::open( const CStdString& filename ) m_pCodecCtx = m_pFormatCtx->streams[ m_videoStream ]->codec; // Find the decoder for the video stream - m_pCodec = m_dllAvCodec->avcodec_find_decoder( m_pCodecCtx->codec_id ); + m_pCodec = avcodec_find_decoder( m_pCodecCtx->codec_id ); if ( m_pCodec == NULL ) { @@ -219,7 +190,7 @@ bool FFmpegVideoDecoder::open( const CStdString& filename ) } // Open the codec - if ( m_dllAvCodec->avcodec_open2( m_pCodecCtx, m_pCodec, 0 ) < 0 ) + if ( avcodec_open2( m_pCodecCtx, m_pCodec, 0 ) < 0 ) { m_errorMsg = "Could not open the video decoder"; close(); @@ -227,7 +198,7 @@ bool FFmpegVideoDecoder::open( const CStdString& filename ) } // Allocate video frames - m_pFrame = m_dllAvCodec->avcodec_alloc_frame(); + m_pFrame = avcodec_alloc_frame(); if ( !m_pFrame ) { @@ -245,10 +216,10 @@ bool FFmpegVideoDecoder::seek( double time ) // Convert the frame number into time stamp int64_t timestamp = (int64_t) (time * AV_TIME_BASE * av_q2d( m_pFormatCtx->streams[ m_videoStream ]->time_base )); - if ( m_dllAvFormat->av_seek_frame( m_pFormatCtx, m_videoStream, timestamp, AVSEEK_FLAG_ANY ) < 0 ) + if ( av_seek_frame( m_pFormatCtx, m_videoStream, timestamp, AVSEEK_FLAG_ANY ) < 0 ) return false; - m_dllAvCodec->avcodec_flush_buffers( m_pCodecCtx ); + avcodec_flush_buffers( m_pCodecCtx ); return true; } @@ -263,21 +234,21 @@ bool FFmpegVideoDecoder::nextFrame( CBaseTexture * texture ) { if ( m_pFrameRGB ) { - m_dllAvCodec->avpicture_free( m_pFrameRGB ); - m_dllAvUtil->av_free( m_pFrameRGB ); + avpicture_free( m_pFrameRGB ); + av_free( m_pFrameRGB ); } m_frameRGBwidth = texture->GetWidth(); m_frameRGBheight = texture->GetHeight(); // Allocate the conversion frame and relevant picture - m_pFrameRGB = (AVPicture*)m_dllAvUtil->av_mallocz(sizeof(AVPicture)); + m_pFrameRGB = (AVPicture*)av_mallocz(sizeof(AVPicture)); if ( !m_pFrameRGB ) return false; // Due to a bug in swsscale we need to allocate one extra line of data - if ( m_dllAvCodec->avpicture_alloc( m_pFrameRGB, PIX_FMT_RGB32, m_frameRGBwidth, m_frameRGBheight + 1 ) < 0 ) + if ( avpicture_alloc( m_pFrameRGB, PIX_FMT_RGB32, m_frameRGBwidth, m_frameRGBheight + 1 ) < 0 ) return false; } @@ -287,13 +258,13 @@ bool FFmpegVideoDecoder::nextFrame( CBaseTexture * texture ) while ( true ) { // Read a frame - if ( m_dllAvFormat->av_read_frame( m_pFormatCtx, &packet ) < 0 ) + if ( av_read_frame( m_pFormatCtx, &packet ) < 0 ) return false; // Frame read failed (e.g. end of stream) if ( packet.stream_index == m_videoStream ) { // Is this a packet from the video stream -> decode video frame - m_dllAvCodec->avcodec_decode_video2( m_pCodecCtx, m_pFrame, &frameFinished, &packet ); + avcodec_decode_video2( m_pCodecCtx, m_pFrame, &frameFinished, &packet ); // Did we get a video frame? if ( frameFinished ) @@ -307,17 +278,17 @@ bool FFmpegVideoDecoder::nextFrame( CBaseTexture * texture ) } } - m_dllAvCodec->av_free_packet( &packet ); + av_free_packet( &packet ); } // We got the video frame, render it into the picture buffer - struct SwsContext * context = m_dllSwScale->sws_getContext( m_pCodecCtx->width, m_pCodecCtx->height, m_pCodecCtx->pix_fmt, + struct SwsContext * context = sws_getContext( m_pCodecCtx->width, m_pCodecCtx->height, m_pCodecCtx->pix_fmt, m_frameRGBwidth, m_frameRGBheight, PIX_FMT_RGB32, SWS_FAST_BILINEAR, NULL, NULL, NULL ); - m_dllSwScale->sws_scale( context, m_pFrame->data, m_pFrame->linesize, 0, m_pCodecCtx->height, + sws_scale( context, m_pFrame->data, m_pFrame->linesize, 0, m_pCodecCtx->height, m_pFrameRGB->data, m_pFrameRGB->linesize ); - m_dllSwScale->sws_freeContext( context ); - m_dllAvCodec->av_free_packet( &packet ); + sws_freeContext( context ); + av_free_packet( &packet ); // And into the texture texture->Update( m_frameRGBwidth, m_frameRGBheight, m_frameRGBwidth * 4, XB_FMT_A8R8G8B8, m_pFrameRGB->data[0], false ); diff --git a/xbmc/video/FFmpegVideoDecoder.h b/xbmc/video/FFmpegVideoDecoder.h index 718d487abb..5ce3f72ee8 100644 --- a/xbmc/video/FFmpegVideoDecoder.h +++ b/xbmc/video/FFmpegVideoDecoder.h @@ -24,15 +24,14 @@ #include "utils/StdString.h" class CBaseTexture; -class m_dllAvFormat; -class m_dllAvCodec; -class m_dllAvUtil; -class m_dllSwScale; +extern "C" { struct AVFormatContext; struct AVCodecContext; struct AVCodec; struct AVFrame; +struct AVPicture; +} /** * A simple FFMpeg-based background video decoder. @@ -141,10 +140,6 @@ public: private: bool readFrame( int frame ); - DllAvFormat *m_dllAvFormat; - DllAvCodec *m_dllAvCodec; - DllAvUtil *m_dllAvUtil; - DllSwScale *m_dllSwScale; AVFormatContext *m_pFormatCtx; AVCodecContext *m_pCodecCtx; AVCodec *m_pCodec; |