aboutsummaryrefslogtreecommitdiff
path: root/lib/DllAc3codec.h
blob: 509664a0614182136bb3fbab091f8dfac0c44d41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#pragma once

/*
 *      Copyright (C) 2005-2008 Team XBMC
 *      http://www.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
 *
 */

#if (defined HAVE_CONFIG_H) && (!defined WIN32)
  #include "config.h"
#endif
extern "C" {
#if (defined USE_EXTERNAL_LIBA52)
  #include <a52dec/a52.h>
  #include <a52dec/mm_accel.h>
#else
  #include "cores/dvdplayer/DVDCodecs/Audio/liba52/a52.h"
#endif
}
#include "DynamicDll.h"
#include "utils/log.h"

#ifdef USE_LIBA52_DECODER
#ifndef _LINUX
typedef unsigned __int32 uint32_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
#endif

#ifdef LIBA52_DOUBLE
typedef float convert_t;
#else
typedef sample_t convert_t;
#endif

#if (defined USE_EXTERNAL_LIBA52)

class DllAc3CodecInterface
{
public:
  virtual ~DllAc3CodecInterface() {}
  virtual a52_state_t * a52_init (uint32_t mm_accel)=0;
  virtual sample_t * a52_samples (a52_state_t * state)=0;
  virtual int a52_syncinfo (uint8_t * buf, int * flags,
          int * sample_rate, int * bit_rate)=0;
  virtual int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
           sample_t * level, sample_t bias)=0;
  virtual void a52_dynrng (a52_state_t * state,
         sample_t (* call) (sample_t, void *), void * data)=0;
  virtual int a52_block (a52_state_t * state)=0;
  virtual void a52_free (a52_state_t * state)=0;
};

class DllAc3Codec : public DllDynamic, DllAc3CodecInterface
{
public:
    virtual ~DllAc3Codec() {}
    virtual a52_state_t * a52_init (uint32_t mm_accel)
        { return ::a52_init (mm_accel); }
    virtual sample_t * a52_samples (a52_state_t * state)
        { return ::a52_samples (state); }
    virtual int a52_syncinfo (uint8_t * buf, int * flags,
            int * sample_rate, int * bit_rate)
        { return ::a52_syncinfo (buf, flags, sample_rate, bit_rate); }
    virtual int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
            sample_t * level, sample_t bias)
        { return ::a52_frame (state, buf, flags, level, bias); }
    virtual void a52_dynrng (a52_state_t * state,
            sample_t (* call) (sample_t, void *), void * data)
        { return ::a52_dynrng (state, call, data); }
    virtual int a52_block (a52_state_t * state)
        { return ::a52_block (state); }
    virtual void a52_free (a52_state_t * state)
        { return ::a52_free (state); }

    // DLL faking.
    virtual bool ResolveExports() { return true; }
    virtual bool Load() {
        CLog::Log(LOGDEBUG, "DllAc3Codec: Using liba52 system library");
        return true;
    }
    virtual void Unload() {}
};

#else

class DllAc3CodecInterface
{
public:
  virtual ~DllAc3CodecInterface() {}
  virtual a52_state_t * a52_init (uint32_t mm_accel)=0;
  virtual sample_t * a52_samples (a52_state_t * state)=0;
  virtual int a52_syncinfo (a52_state_t * state, uint8_t * buf, int * flags, int * sample_rate, int * bit_rate)=0;
  virtual int a52_frame (a52_state_t * state, uint8_t * buf, int * flags, level_t * level, sample_t bias)=0;
  virtual void a52_dynrng (a52_state_t * state, level_t (* call) (level_t, void *), void * data)=0;
  virtual int a52_block (a52_state_t * state)=0;
  virtual void a52_free (a52_state_t * state)=0;
};

class DllAc3Codec : public DllDynamic, DllAc3CodecInterface
{
  DECLARE_DLL_WRAPPER(DllAc3Codec, DLL_PATH_AC3_CODEC)
  DEFINE_METHOD1(a52_state_t *, a52_init, (uint32_t p1))
  DEFINE_METHOD1(sample_t *, a52_samples, (a52_state_t *p1))
  DEFINE_METHOD5(int, a52_syncinfo, (a52_state_t * p1, uint8_t * p2, int * p3, int * p4, int * p5))
  DEFINE_METHOD5(int, a52_frame, (a52_state_t * p1, uint8_t * p2, int * p3, level_t * p4, sample_t p5))
  DEFINE_METHOD3(void, a52_dynrng, (a52_state_t * p1, level_t (* p2) (level_t, void *), void * p3))
  DEFINE_METHOD1(int, a52_block, (a52_state_t * p1))
  DEFINE_METHOD1(void, a52_free, (a52_state_t * p1))
  BEGIN_METHOD_RESOLVE()
    RESOLVE_METHOD(a52_init)
    RESOLVE_METHOD(a52_samples)
    RESOLVE_METHOD(a52_syncinfo)
    RESOLVE_METHOD(a52_frame)
    RESOLVE_METHOD(a52_dynrng)
    RESOLVE_METHOD(a52_block)
    RESOLVE_METHOD(a52_free)
  END_METHOD_RESOLVE()
};

#endif /* (defined USE_EXTERNAL_LIBA52) */

#endif /* USE_LIBA52_DECODER */