Drop support for old ffmpeg header layout.
[vuplus_xbmc] / lib / DllPostProc.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://www.xbmc.org
5  *
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)
9  *  any later version.
10  *
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.
15  *
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
20  *
21  */
22
23 #if (defined HAVE_CONFIG_H) && (!defined WIN32)
24   #include "config.h"
25 #endif
26 #include "DynamicDll.h"
27 #include "utils/log.h"
28
29 extern "C" {
30 #define HAVE_MMX
31 #ifndef __STDC_CONSTANT_MACROS
32 #define __STDC_CONSTANT_MACROS
33 #endif
34 #ifndef __STDC_LIMIT_MACROS
35 #define __STDC_LIMIT_MACROS
36 #endif
37 #ifndef __GNUC__
38 #pragma warning(disable:4244)
39 #endif
40   
41 #if (defined USE_EXTERNAL_FFMPEG)
42   #include <libavutil/avutil.h>
43   #include <libpostproc/postprocess.h>
44 #else
45   #include "libavutil/avutil.h"
46   #include "libpostproc/postprocess.h"
47 #endif
48 }
49
50 #include "utils/CPUInfo.h"
51
52 inline int PPCPUFlags()
53 {
54   unsigned int cpuFeatures = g_cpuInfo.GetCPUFeatures();
55   int flags = 0;
56
57   if (cpuFeatures & CPU_FEATURE_MMX)
58     flags |= PP_CPU_CAPS_MMX;
59   if (cpuFeatures & CPU_FEATURE_MMX2)
60     flags |= PP_CPU_CAPS_MMX2;
61   if (cpuFeatures & CPU_FEATURE_3DNOW)
62     flags |= PP_CPU_CAPS_3DNOW;
63   if (cpuFeatures & CPU_FEATURE_ALTIVEC)
64     flags |= PP_CPU_CAPS_ALTIVEC;
65
66   return flags;
67 }
68
69 class DllPostProcInterface
70 {
71 public:
72    virtual ~DllPostProcInterface() {}
73   virtual void pp_postprocess(uint8_t * src[3], int srcStride[3], uint8_t * dst[3], int dstStride[3],
74                    int horizontalSize, int verticalSize, QP_STORE_T *QP_store,  int QP_stride,
75                            pp_mode *mode, pp_context *ppContext, int pict_type)=0;                 
76   virtual pp_mode *pp_get_mode_by_name_and_quality(char *name, int quality)=0;
77   virtual void pp_free_mode(pp_mode *mode)=0;
78   virtual pp_context *pp_get_context(int width, int height, int flags)=0;
79   virtual void pp_free_context(pp_context *ppContext)=0;
80 };
81
82 #if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) 
83
84 // We call directly.
85 class DllPostProc : public DllDynamic, DllPostProcInterface
86 {
87 public:
88   
89   virtual ~DllPostProc() {}
90   virtual void pp_postprocess(uint8_t * src[3], int srcStride[3], uint8_t * dst[3], int dstStride[3],
91                   int horizontalSize, int verticalSize, QP_STORE_T *QP_store,  int QP_stride,
92                   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); }             
93   virtual pp_mode *pp_get_mode_by_name_and_quality(char *name, int quality) { return ::pp_get_mode_by_name_and_quality(name, quality); }
94   virtual void pp_free_mode(pp_mode *mode) { ::pp_free_mode(mode); }
95   virtual pp_context *pp_get_context(int width, int height, int flags) { return ::pp_get_context(width, height, flags); }
96   virtual void pp_free_context(pp_context *ppContext) { ::pp_free_context(ppContext); }
97   
98   // DLL faking.
99   virtual bool ResolveExports() { return true; }
100   virtual bool Load() {
101     CLog::Log(LOGDEBUG, "DllPostProc: Using libpostproc system library");
102     return true;
103   }
104   virtual void Unload() {}
105 };
106
107 #else
108 class DllPostProc : public DllDynamic, DllPostProcInterface
109 {
110   DECLARE_DLL_WRAPPER(DllPostProc, DLL_PATH_LIBPOSTPROC)
111   DEFINE_METHOD11(void, pp_postprocess, (uint8_t* p1[3], int p2[3], uint8_t * p3[3], int p4[3],
112                       int p5, int p6, QP_STORE_T *p7,  int p8,
113                       pp_mode *p9, pp_context *p10, int p11))
114   DEFINE_METHOD2(pp_mode*, pp_get_mode_by_name_and_quality, (char *p1, int p2))
115   DEFINE_METHOD1(void, pp_free_mode, (pp_mode *p1))
116   DEFINE_METHOD3(pp_context*, pp_get_context, (int p1, int p2, int p3))
117   DEFINE_METHOD1(void, pp_free_context, (pp_context *p1))
118
119   BEGIN_METHOD_RESOLVE()
120     RESOLVE_METHOD(pp_postprocess)
121     RESOLVE_METHOD(pp_get_mode_by_name_and_quality)
122     RESOLVE_METHOD(pp_free_mode)
123     RESOLVE_METHOD(pp_get_context)
124     RESOLVE_METHOD(pp_free_context)
125   END_METHOD_RESOLVE()
126 };
127
128 #endif