3 * Copyright (C) 2005-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 * http://www.gnu.org/copyleft/gpl.html
23 #if (defined HAVE_CONFIG_H) && (!defined WIN32)
26 #include "DynamicDll.h"
27 #include "utils/log.h"
31 #ifndef __STDC_CONSTANT_MACROS
32 #define __STDC_CONSTANT_MACROS
34 #ifndef __STDC_LIMIT_MACROS
35 #define __STDC_LIMIT_MACROS
38 #pragma warning(disable:4244)
41 #if (defined USE_EXTERNAL_FFMPEG)
42 #if (defined HAVE_LIBAVUTIL_AVUTIL_H)
43 #include <libavutil/avutil.h>
44 #elif (defined HAVE_FFMPEG_AVUTIL_H)
45 #include <ffmpeg/avutil.h>
47 #if (defined HAVE_LIBPOSTPROC_POSTPROCESS_H)
48 #include <libpostproc/postprocess.h>
49 #elif (defined HAVE_POSTPROC_POSTPROCESS_H)
50 #include <postproc/postprocess.h>
53 #include "libavutil/avutil.h"
54 #include "libpostproc/postprocess.h"
58 #include "utils/CPUInfo.h"
60 inline int PPCPUFlags()
62 unsigned int cpuFeatures = g_cpuInfo.GetCPUFeatures();
65 if (cpuFeatures & CPU_FEATURE_MMX)
66 flags |= PP_CPU_CAPS_MMX;
67 if (cpuFeatures & CPU_FEATURE_MMX2)
68 flags |= PP_CPU_CAPS_MMX2;
69 if (cpuFeatures & CPU_FEATURE_3DNOW)
70 flags |= PP_CPU_CAPS_3DNOW;
71 if (cpuFeatures & CPU_FEATURE_ALTIVEC)
72 flags |= PP_CPU_CAPS_ALTIVEC;
77 class DllPostProcInterface
80 virtual ~DllPostProcInterface() {}
81 virtual void pp_postprocess(uint8_t * src[3], int srcStride[3], uint8_t * dst[3], int dstStride[3],
82 int horizontalSize, int verticalSize, QP_STORE_T *QP_store, int QP_stride,
83 pp_mode *mode, pp_context *ppContext, int pict_type)=0;
84 virtual pp_mode *pp_get_mode_by_name_and_quality(char *name, int quality)=0;
85 virtual void pp_free_mode(pp_mode *mode)=0;
86 virtual pp_context *pp_get_context(int width, int height, int flags)=0;
87 virtual void pp_free_context(pp_context *ppContext)=0;
90 #if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
93 class DllPostProc : public DllDynamic, DllPostProcInterface
97 virtual ~DllPostProc() {}
98 virtual void pp_postprocess(uint8_t * src[3], int srcStride[3], uint8_t * dst[3], int dstStride[3],
99 int horizontalSize, int verticalSize, QP_STORE_T *QP_store, int QP_stride,
100 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); }
101 virtual pp_mode *pp_get_mode_by_name_and_quality(char *name, int quality) { return ::pp_get_mode_by_name_and_quality(name, quality); }
102 virtual void pp_free_mode(pp_mode *mode) { ::pp_free_mode(mode); }
103 virtual pp_context *pp_get_context(int width, int height, int flags) { return ::pp_get_context(width, height, flags); }
104 virtual void pp_free_context(pp_context *ppContext) { ::pp_free_context(ppContext); }
107 virtual bool ResolveExports() { return true; }
108 virtual bool Load() {
109 CLog::Log(LOGDEBUG, "DllPostProc: Using libpostproc system library");
112 virtual void Unload() {}
116 class DllPostProc : public DllDynamic, DllPostProcInterface
118 DECLARE_DLL_WRAPPER(DllPostProc, DLL_PATH_LIBPOSTPROC)
119 DEFINE_METHOD11(void, pp_postprocess, (uint8_t* p1[3], int p2[3], uint8_t * p3[3], int p4[3],
120 int p5, int p6, QP_STORE_T *p7, int p8,
121 pp_mode *p9, pp_context *p10, int p11))
122 DEFINE_METHOD2(pp_mode*, pp_get_mode_by_name_and_quality, (char *p1, int p2))
123 DEFINE_METHOD1(void, pp_free_mode, (pp_mode *p1))
124 DEFINE_METHOD3(pp_context*, pp_get_context, (int p1, int p2, int p3))
125 DEFINE_METHOD1(void, pp_free_context, (pp_context *p1))
127 BEGIN_METHOD_RESOLVE()
128 RESOLVE_METHOD(pp_postprocess)
129 RESOLVE_METHOD(pp_get_mode_by_name_and_quality)
130 RESOLVE_METHOD(pp_free_mode)
131 RESOLVE_METHOD(pp_get_context)
132 RESOLVE_METHOD(pp_free_context)