annotate libmpcodecs/ad_qtaudio.c @ 8179:63a5e03f4346

Removed hard coded value for the length of the header separator. Used the value previous detected.
author bertrand
date Wed, 13 Nov 2002 09:02:55 +0000
parents 8703835345e3
children badd24741e4a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8008
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
1 #include <stdio.h>
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
2 #include <stdlib.h>
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
3 #include <unistd.h>
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
4 #include <inttypes.h>
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
5
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
6 #include "config.h"
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
7
8159
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
8 #ifdef USE_QTX_CODECS
8008
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
9
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
10 #include "ad_internal.h"
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
11 #include "bswap.h"
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
12
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
13 static ad_info_t info = {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
14 "QuickTime Audio Decoder",
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
15 "qtaudio",
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
16 "A'rpi",
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
17 "Sascha Sommer",
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
18 "uses win32 quicktime DLLs"
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
19 };
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
20
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
21 LIBAD_EXTERN(qtaudio)
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
22
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
23 typedef struct OpaqueSoundConverter* SoundConverter;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
24 typedef unsigned long OSType;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
25 typedef unsigned long UnsignedFixed;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
26 typedef uint8_t Byte;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
27 typedef struct SoundComponentData {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
28 long flags;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
29 OSType format;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
30 short numChannels;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
31 short sampleSize;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
32 UnsignedFixed sampleRate;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
33 long sampleCount;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
34 Byte * buffer;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
35 long reserved;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
36 }SoundComponentData;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
37
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
38 typedef int (__cdecl* LPFUNC1)(long flag);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
39 typedef int (__cdecl* LPFUNC2)(const SoundComponentData *, const SoundComponentData *,SoundConverter *);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
40 typedef int (__cdecl* LPFUNC3)(SoundConverter sc);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
41 typedef int (__cdecl* LPFUNC4)(void);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
42 typedef int (__cdecl* LPFUNC5)(SoundConverter sc, OSType selector,void * infoPtr);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
43 typedef int (__cdecl* LPFUNC6)(SoundConverter sc,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
44 unsigned long inputBytesTarget,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
45 unsigned long *inputFrames,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
46 unsigned long *inputBytes,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
47 unsigned long *outputBytes );
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
48 typedef int (__cdecl* LPFUNC7)(SoundConverter sc,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
49 const void *inputPtr,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
50 unsigned long inputFrames,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
51 void *outputPtr,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
52 unsigned long *outputFrames,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
53 unsigned long *outputBytes );
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
54 typedef int (__cdecl* LPFUNC8)(SoundConverter sc,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
55 void *outputPtr,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
56 unsigned long *outputFrames,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
57 unsigned long *outputBytes);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
58 typedef int (__cdecl* LPFUNC9)(SoundConverter sc) ;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
59
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
60 static HINSTANCE qtml_dll;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
61 static LPFUNC1 InitializeQTML;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
62 static LPFUNC2 SoundConverterOpen;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
63 static LPFUNC3 SoundConverterClose;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
64 static LPFUNC4 TerminateQTML;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
65 static LPFUNC5 SoundConverterSetInfo;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
66 static LPFUNC6 SoundConverterGetBufferSizes;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
67 static LPFUNC7 SoundConverterConvertBuffer;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
68 static LPFUNC8 SoundConverterEndConversion;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
69 static LPFUNC9 SoundConverterBeginConversion;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
70
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
71 #define siDecompressionParams 2002876005 // siDecompressionParams = FOUR_CHAR_CODE('wave')
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
72
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
73 HMODULE WINAPI LoadLibraryA(LPCSTR);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
74 FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
75 int WINAPI FreeLibrary(HMODULE);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
76
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
77 static int loader_init()
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
78 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
79
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
80 qtml_dll = LoadLibraryA("qtmlClient.dll");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
81 if( qtml_dll == NULL )
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
82 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
83 printf("failed loading dll\n" );
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
84 return 1;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
85 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
86 #if 1
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
87 InitializeQTML = (LPFUNC1)GetProcAddress(qtml_dll,"InitializeQTML");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
88 if ( InitializeQTML == NULL )
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
89 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
90 printf("failed geting proc address InitializeQTML\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
91 return 1;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
92 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
93 SoundConverterOpen = (LPFUNC2)GetProcAddress(qtml_dll,"SoundConverterOpen");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
94 if ( SoundConverterOpen == NULL )
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
95 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
96 printf("failed getting proc address SoundConverterOpen\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
97 return 1;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
98 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
99 SoundConverterClose = (LPFUNC3)GetProcAddress(qtml_dll,"SoundConverterClose");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
100 if ( SoundConverterClose == NULL )
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
101 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
102 printf("failed getting proc address SoundConverterClose\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
103 return 1;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
104 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
105 TerminateQTML = (LPFUNC4)GetProcAddress(qtml_dll,"TerminateQTML");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
106 if ( TerminateQTML == NULL )
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
107 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
108 printf("failed getting proc address TerminateQTML\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
109 return 1;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
110 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
111 SoundConverterSetInfo = (LPFUNC5)GetProcAddress(qtml_dll,"SoundConverterSetInfo");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
112 if ( SoundConverterSetInfo == NULL )
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
113 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
114 printf("failed getting proc address SoundConverterSetInfo\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
115 return 1;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
116 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
117 SoundConverterGetBufferSizes = (LPFUNC6)GetProcAddress(qtml_dll,"SoundConverterGetBufferSizes");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
118 if ( SoundConverterGetBufferSizes == NULL )
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
119 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
120 printf("failed getting proc address SoundConverterGetBufferSizes\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
121 return 1;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
122 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
123 SoundConverterConvertBuffer = (LPFUNC7)GetProcAddress(qtml_dll,"SoundConverterConvertBuffer");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
124 if ( SoundConverterConvertBuffer == NULL )
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
125 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
126 printf("failed getting proc address SoundConverterConvertBuffer1\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
127 return 1;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
128 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
129 SoundConverterEndConversion = (LPFUNC8)GetProcAddress(qtml_dll,"SoundConverterEndConversion");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
130 if ( SoundConverterEndConversion == NULL )
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
131 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
132 printf("failed getting proc address SoundConverterEndConversion\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
133 return 1;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
134 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
135 SoundConverterBeginConversion = (LPFUNC9)GetProcAddress(qtml_dll,"SoundConverterBeginConversion");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
136 if ( SoundConverterBeginConversion == NULL )
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
137 {
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
138 printf("failed getting proc address SoundConverterBeginConversion\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
139 return 1;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
140 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
141 printf("Standard init done you may now call supported functions\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
142 #endif
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
143 printf("loader_init DONE???\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
144 return 0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
145 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
146
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
147 static SoundConverter myConverter = NULL;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
148 static SoundComponentData InputFormatInfo,OutputFormatInfo;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
149
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
150 static int InFrameSize;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
151 static int OutFrameSize;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
152
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
153 static int preinit(sh_audio_t *sh){
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
154 int error;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
155 unsigned long FramesToGet=0; //how many frames the demuxer has to get
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
156 unsigned long InputBufferSize=0; //size of the input buffer
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
157 unsigned long OutputBufferSize=0; //size of the output buffer
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
158 unsigned long WantedBufferSize=0; //the size you want your buffers to be
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
159
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
160 printf("win32 libquicktime loader (c) Sascha Sommer\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
161
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
162 if(loader_init()) return 0; // failed to load DLL
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
163
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
164 printf("loader_init DONE!\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
165
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
166 #if 1
8159
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
167 error = InitializeQTML(6+16);
8008
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
168 printf("InitializeQTML:%i\n",error);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
169 if(error) return 0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
170
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
171 OutputFormatInfo.flags = InputFormatInfo.flags = 0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
172 OutputFormatInfo.sampleCount = InputFormatInfo.sampleCount = 0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
173 OutputFormatInfo.buffer = InputFormatInfo.buffer = NULL;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
174 OutputFormatInfo.reserved = InputFormatInfo.reserved = 0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
175 OutputFormatInfo.numChannels = InputFormatInfo.numChannels = sh->wf->nChannels;
8159
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
176 InputFormatInfo.sampleSize = sh->wf->wBitsPerSample;
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
177 OutputFormatInfo.sampleSize = 16;
8008
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
178 OutputFormatInfo.sampleRate = InputFormatInfo.sampleRate = sh->wf->nSamplesPerSec;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
179 InputFormatInfo.format = bswap_32(sh->format); //1363430706;///*1768775988;//*/1902406962;//qdm2//1768775988;//FOUR_CHAR_CODE('ima4');
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
180 OutputFormatInfo.format = 1313820229;// FOUR_CHAR_CODE('NONE');
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
181
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
182 error = SoundConverterOpen(&InputFormatInfo, &OutputFormatInfo, &myConverter);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
183 printf("SoundConverterOpen:%i\n",error);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
184 if(error) return 0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
185
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
186 if(sh->codecdata){
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
187 error = SoundConverterSetInfo(myConverter,siDecompressionParams,sh->codecdata);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
188 printf("SoundConverterSetInfo:%i\n",error);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
189 if(error) return 0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
190 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
191
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
192 WantedBufferSize=OutputFormatInfo.numChannels*OutputFormatInfo.sampleRate*2;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
193 error = SoundConverterGetBufferSizes(myConverter,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
194 WantedBufferSize,&FramesToGet,&InputBufferSize,&OutputBufferSize);
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 8008
diff changeset
195 printf("SoundConverterGetBufferSizes:%i\n",error);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 8008
diff changeset
196 printf("WantedBufferSize = %li\n",WantedBufferSize);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 8008
diff changeset
197 printf("InputBufferSize = %li\n",InputBufferSize);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 8008
diff changeset
198 printf("OutputBufferSize = %li\n",OutputBufferSize);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 8008
diff changeset
199 printf("FramesToGet = %li\n",FramesToGet);
8008
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
200
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
201 InFrameSize=InputBufferSize/FramesToGet;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
202 OutFrameSize=OutputBufferSize/FramesToGet;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
203
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
204 printf("FrameSize: %i -> %i\n",InFrameSize,OutFrameSize);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
205
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
206 error = SoundConverterBeginConversion(myConverter);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
207 printf("SoundConverterBeginConversion:%i\n",error);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
208 if(error) return 0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
209
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
210 sh->audio_out_minsize=OutputBufferSize;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
211 sh->audio_in_minsize=InputBufferSize;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
212
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
213 sh->channels=sh->wf->nChannels;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
214 sh->samplerate=sh->wf->nSamplesPerSec;
8159
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
215 sh->samplesize=2; //(sh->wf->wBitsPerSample+7)/8;
8008
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
216
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
217 sh->i_bps=sh->wf->nAvgBytesPerSec;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
218 //InputBufferSize*WantedBufferSize/OutputBufferSize;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
219
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
220 #endif
8159
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
221
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
222 if(sh->format==0x3343414D){
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
223 // MACE 3:1
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
224 sh->ds->ss_div = 2*3; // 1 samples/packet
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
225 sh->ds->ss_mul = sh->channels*2*1; // 1 bytes/packet
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
226 } else
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
227 if(sh->format==0x3643414D){
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
228 // MACE 6:1
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
229 sh->ds->ss_div = 2*6; // 1 samples/packet
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
230 sh->ds->ss_mul = sh->channels*2*1; // 1 bytes/packet
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
231 }
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
232
8008
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
233 return 1; // return values: 1=OK 0=ERROR
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
234 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
235
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
236 static int init(sh_audio_t *sh_audio){
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
237
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
238 return 1; // return values: 1=OK 0=ERROR
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
239 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
240
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
241 static void uninit(sh_audio_t *sh){
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
242 int error;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
243 unsigned long ConvertedFrames=0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
244 unsigned long ConvertedBytes=0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
245 error=SoundConverterEndConversion(myConverter,NULL,&ConvertedFrames,&ConvertedBytes);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
246 printf("SoundConverterEndConversion:%i\n",error);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
247 error = SoundConverterClose(myConverter);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
248 printf("SoundConverterClose:%i\n",error);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
249 error = TerminateQTML();
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
250 printf("TerminateQTML:%i\n",error);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
251 FreeLibrary( qtml_dll );
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
252 qtml_dll = NULL;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
253 printf("qt dll loader uninit done\n");
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
254 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
255
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
256 static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
257 int error;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
258 unsigned long FramesToGet=0; //how many frames the demuxer has to get
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
259 unsigned long InputBufferSize=0; //size of the input buffer
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
260 unsigned long ConvertedFrames=0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
261 unsigned long ConvertedBytes=0;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
262
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
263 FramesToGet=minlen/OutFrameSize;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
264 if(FramesToGet*OutFrameSize<minlen &&
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
265 (FramesToGet+1)*OutFrameSize<=maxlen) ++FramesToGet;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
266 if(FramesToGet*InFrameSize>sh->a_in_buffer_size)
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
267 FramesToGet=sh->a_in_buffer_size/InFrameSize;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
268
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
269 InputBufferSize=FramesToGet*InFrameSize;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
270
8159
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
271 // printf("FramesToGet = %li (%li -> %li bytes)\n",FramesToGet,
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
272 // InputBufferSize, FramesToGet*OutFrameSize);
8008
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
273
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
274 if(InputBufferSize>sh->a_in_buffer_len){
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
275 int x=demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len],
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
276 InputBufferSize-sh->a_in_buffer_len);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
277 if(x>0) sh->a_in_buffer_len+=x;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
278 if(InputBufferSize>sh->a_in_buffer_len)
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
279 FramesToGet=sh->a_in_buffer_len/InFrameSize; // not enough data!
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
280 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
281
8159
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
282 // printf("\nSoundConverterConvertBuffer(myConv=%p,inbuf=%p,frames=%d,outbuf=%p,&convframes=%p,&convbytes=%p)\n",
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
283 // myConverter,sh->a_in_buffer,FramesToGet,buf,&ConvertedFrames,&ConvertedBytes);
8008
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
284 error = SoundConverterConvertBuffer(myConverter,sh->a_in_buffer,
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
285 FramesToGet,buf,&ConvertedFrames,&ConvertedBytes);
8159
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
286 // printf("SoundConverterConvertBuffer:%i\n",error);
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
287 // printf("ConvertedFrames = %li\n",ConvertedFrames);
8703835345e3 fixed output bits per sample
arpi
parents: 8123
diff changeset
288 // printf("ConvertedBytes = %li\n",ConvertedBytes);
8008
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
289
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
290 InputBufferSize=(ConvertedBytes/OutFrameSize)*InFrameSize; // FIXME!!
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
291 sh->a_in_buffer_len-=InputBufferSize;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
292 if(sh->a_in_buffer_len<0) sh->a_in_buffer_len=0; // should not happen...
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
293 else if(sh->a_in_buffer_len>0){
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
294 memcpy(sh->a_in_buffer,&sh->a_in_buffer[InputBufferSize],sh->a_in_buffer_len);
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
295 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
296
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
297 return ConvertedBytes;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
298 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
299
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
300 static int control(sh_audio_t *sh,int cmd,void* arg, ...){
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
301 // various optional functions you MAY implement:
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
302 return CONTROL_UNKNOWN;
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
303 }
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
304
35d663ad0d95 qtaudio - audio decoder using win32 quicktime 5 dlls
arpi
parents:
diff changeset
305 #endif