Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8039 hidnplayr 1
// OGG vorbis for KolibriOS in native shared COFF library format.
2
 
3
// https://github.com/nothings/stb/blob/master/stb_vorbis.c
4
 
5
// Some functions to allow us building without any external libs
6
 
7
#include 
8
 
9
void* memset(void *base, int val, size_t len)
10
{
11
   int i;
12
   for (i=0; i < len; ++i) ((char *) base)[i] = val;
13
}
14
 
15
int memcmp(const void *p1, const void *p2, size_t len)
16
{
17
   unsigned char *q1 = (unsigned char *) p1;
18
   unsigned char *q2 = (unsigned char *) p2;
19
   int i;
20
   for (i=0; i < len; ++i)
21
      if (q1[i] < q2[i]) return -1;
22
      else if (q1[i] > q2[i]) return 1;
23
   return 0;
24
}
25
 
26
void* memcpy(void *dest, const void *src, size_t num)
27
{
28
   int i;
29
   for (i=0; i < num; ++i)
30
      ((char *)dest)[i] = ((char *) src)[i];
31
}
32
 
33
double powerd (double x, int y)
34
{
35
    double temp;
36
    if (y == 0)
37
    return 1;
38
    temp = powerd (x, y / 2);
39
    if ((y % 2) == 0) {
40
        return temp * temp;
41
    } else {
42
        if (y > 0)
43
            return x * temp * temp;
44
        else
45
            return (temp * temp) / x;
46
    }
47
}
48
 
49
double ldexp(double Value, int Exponent)
50
{
51
    return((Value * powerd(2.0, Exponent)));
52
}
53
 
54
#include "qsort.c"
55
 
56
// For building with mingw compiler
57
__attribute__((externally_visible)) void __chkstk_ms(){
58
	return;
59
}
60
 
61
# define assert(expr)                ((void) (0))
62
 
63
// Actual stb_vorbis related stuff starts here
64
 
65
#define STB_VORBIS_NO_STDIO 1
66
#define STB_VORBIS_NO_CRT 1
67
//#define STB_VORBIS_NO_PULLDATA_API 1
68
 
69
#include "stb_vorbis.c"
70
 
71
// KolibriOS type EXPORTS header
72
 
73
int __stdcall libInit(){
74
      return 1;
75
}
76
 
77
typedef struct{
78
  char *name;
79
  void *f;
80
}export_t;
81
 
82
char szLibInit[]   			="lib_init";
83
char szVersion[]			="version";
84
char szPushDataOpen[]   	="pushdata_open";
85
char szPushDataDecode[] 	="pushdata_decode";
86
char szPushDataFlush[] 		="pushdata_flush";
87
//char szConvertSamplesShort[] = "convert_samples_short";
88
char szConvertSamplesShortInterleaved[] = "convert_channels_short_interleaved";
89
 
90
__attribute__((externally_visible))  export_t EXPORTS[] __asm__("EXPORTS") =
91
  {
92
	{ szLibInit,		libInit },
93
	{ szVersion,		(void*)0x00010001 },
94
    { szPushDataOpen,	stb_vorbis_open_pushdata },
95
    { szPushDataDecode, stb_vorbis_decode_frame_pushdata },
96
	{ szPushDataFlush, 	stb_vorbis_flush_pushdata},
97
	//{ szConvertSamplesShort, convert_samples_short},
98
	{ szConvertSamplesShortInterleaved, convert_channels_short_interleaved},
99
 
100
    { NULL, NULL },
101
  };
102
 
103
// End of file