Mercurial > mplayer.hg
annotate loader/dmo/DMO_AudioDecoder.c @ 26212:876d2f3f71f9
10l: Really disable coreaudio where intended.
author | diego |
---|---|
date | Sat, 15 Mar 2008 09:28:33 +0000 |
parents | 2c8cdb9123b8 |
children | f20a11161e62 |
rev | line source |
---|---|
8325 | 1 /******************************************************** |
2 | |
3 DirectShow audio decoder | |
4 Copyright 2001 Eugene Kuznetsov (divx@euro.ru) | |
5 | |
6 *********************************************************/ | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
7 #include "config.h" |
22607
b99edbf76db4
Use explicit path for headers from the dshow/ subdirectory.
diego
parents:
22001
diff
changeset
|
8 #include "dshow/libwin32.h" |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
9 #ifdef WIN32_LOADER |
8451 | 10 #include "ldt_keeper.h" |
8325 | 11 #endif |
12 | |
13 #include "DMO_Filter.h" | |
14 #include "DMO_AudioDecoder.h" | |
15 | |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
23429
diff
changeset
|
16 struct DMO_AudioDecoder |
8325 | 17 { |
18 DMO_MEDIA_TYPE m_sOurType, m_sDestType; | |
19 DMO_Filter* m_pDMO_Filter; | |
20 char* m_sVhdr; | |
21 char* m_sVhdr2; | |
22 int m_iFlushed; | |
23 }; | |
24 | |
25 #include "DMO_AudioDecoder.h" | |
26 | |
27 #include <string.h> | |
28 #include <stdio.h> | |
29 #include <stdlib.h> | |
30 | |
17978 | 31 #include "../../mp_msg.h" |
32 | |
8325 | 33 typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**); |
17977
f70772d02eaa
Convert printfs in aviprint.c to mp_msg and give the information printing
diego
parents:
9967
diff
changeset
|
34 extern void print_wave_header(WAVEFORMATEX *h, int verbose_level); |
8325 | 35 |
36 DMO_AudioDecoder * DMO_AudioDecoder_Open(char* dllname, GUID* guid, WAVEFORMATEX* wf,int out_channels) | |
37 //DMO_AudioDecoder * DMO_AudioDecoder_Create(const CodecInfo * info, const WAVEFORMATEX* wf) | |
38 { | |
39 DMO_AudioDecoder *this; | |
40 int sz; | |
41 WAVEFORMATEX* pWF; | |
42 | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
43 #ifdef WIN32_LOADER |
8325 | 44 Setup_LDT_Keeper(); |
45 Setup_FS_Segment(); | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
46 #endif |
8325 | 47 |
48 this = malloc(sizeof(DMO_AudioDecoder)); | |
49 | |
50 this->m_iFlushed=1; | |
51 | |
52 sz = 18 + wf->cbSize; | |
53 this->m_sVhdr = malloc(sz); | |
54 memcpy(this->m_sVhdr, wf, sz); | |
55 this->m_sVhdr2 = malloc(18); | |
56 memcpy(this->m_sVhdr2, this->m_sVhdr, 18); | |
57 | |
58 pWF = (WAVEFORMATEX*)this->m_sVhdr2; | |
59 pWF->wFormatTag = 1; | |
60 pWF->wBitsPerSample = 16; | |
61 pWF->nChannels = out_channels; | |
62 pWF->nBlockAlign = 2*pWF->nChannels; //pWF->nChannels * (pWF->wBitsPerSample + 7) / 8; | |
63 pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec; | |
64 pWF->cbSize = 0; | |
65 | |
66 memset(&this->m_sOurType, 0, sizeof(this->m_sOurType)); | |
67 this->m_sOurType.majortype=MEDIATYPE_Audio; | |
68 this->m_sOurType.subtype=MEDIASUBTYPE_PCM; | |
69 this->m_sOurType.subtype.f1=wf->wFormatTag; | |
70 this->m_sOurType.formattype=FORMAT_WaveFormatEx; | |
71 this->m_sOurType.lSampleSize=wf->nBlockAlign; | |
72 this->m_sOurType.bFixedSizeSamples=1; | |
73 this->m_sOurType.bTemporalCompression=0; | |
74 this->m_sOurType.cbFormat=sz; | |
75 this->m_sOurType.pbFormat=this->m_sVhdr; | |
76 | |
77 memset(&this->m_sDestType, 0, sizeof(this->m_sDestType)); | |
78 this->m_sDestType.majortype=MEDIATYPE_Audio; | |
79 this->m_sDestType.subtype=MEDIASUBTYPE_PCM; | |
80 this->m_sDestType.formattype=FORMAT_WaveFormatEx; | |
81 this->m_sDestType.bFixedSizeSamples=1; | |
82 this->m_sDestType.bTemporalCompression=0; | |
83 this->m_sDestType.lSampleSize=pWF->nBlockAlign; | |
84 this->m_sDestType.cbFormat=18; //pWF->cbSize; | |
85 this->m_sDestType.pbFormat=this->m_sVhdr2; | |
86 | |
17977
f70772d02eaa
Convert printfs in aviprint.c to mp_msg and give the information printing
diego
parents:
9967
diff
changeset
|
87 print_wave_header((WAVEFORMATEX *)this->m_sVhdr, MSGL_V); |
f70772d02eaa
Convert printfs in aviprint.c to mp_msg and give the information printing
diego
parents:
9967
diff
changeset
|
88 print_wave_header((WAVEFORMATEX *)this->m_sVhdr2, MSGL_V); |
8325 | 89 |
90 this->m_pDMO_Filter = DMO_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType); | |
91 if( !this->m_pDMO_Filter ) { | |
92 free(this); | |
93 return NULL; | |
94 } | |
95 | |
96 return this; | |
97 } | |
98 | |
99 void DMO_AudioDecoder_Destroy(DMO_AudioDecoder *this) | |
100 { | |
101 free(this->m_sVhdr); | |
102 free(this->m_sVhdr2); | |
103 DMO_Filter_Destroy(this->m_pDMO_Filter); | |
104 free(this); | |
105 } | |
106 | |
107 int DMO_AudioDecoder_Convert(DMO_AudioDecoder *this, const void* in_data, unsigned int in_size, | |
108 void* out_data, unsigned int out_size, | |
109 unsigned int* size_read, unsigned int* size_written) | |
110 { | |
111 DMO_OUTPUT_DATA_BUFFER db; | |
112 CMediaBuffer* bufferin; | |
8451 | 113 unsigned long written = 0; |
114 unsigned long read = 0; | |
8325 | 115 int r = 0; |
116 | |
117 if (!in_data || !out_data) | |
118 return -1; | |
119 | |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
120 #ifdef WIN32_LOADER |
8325 | 121 Setup_FS_Segment(); |
9967
b0d1b415320c
cygwin support patch by Sascha Sommer and some fixes by me
alex
parents:
8451
diff
changeset
|
122 #endif |
8325 | 123 |
124 //m_pDMO_Filter->m_pMedia->vt->Lock(m_pDMO_Filter->m_pMedia, 1); | |
125 bufferin = CMediaBufferCreate(in_size, (void*)in_data, in_size, 1); | |
126 r = this->m_pDMO_Filter->m_pMedia->vt->ProcessInput(this->m_pDMO_Filter->m_pMedia, 0, | |
127 (IMediaBuffer*)bufferin, | |
128 (this->m_iFlushed) ? DMO_INPUT_DATA_BUFFERF_SYNCPOINT : 0, | |
129 0, 0); | |
130 if (r == 0){ | |
131 ((IMediaBuffer*)bufferin)->vt->GetBufferAndLength((IMediaBuffer*)bufferin, 0, &read); | |
132 this->m_iFlushed = 0; | |
133 } | |
134 | |
135 ((IMediaBuffer*)bufferin)->vt->Release((IUnknown*)bufferin); | |
136 | |
137 //printf("RESULTA: %d 0x%x %ld %d %d\n", r, r, read, m_iFlushed, out_size); | |
138 if (r == 0 || (unsigned)r == DMO_E_NOTACCEPTING){ | |
139 unsigned long status = 0; | |
140 /* something for process */ | |
141 db.rtTimestamp = 0; | |
142 db.rtTimelength = 0; | |
143 db.dwStatus = 0; | |
144 db.pBuffer = (IMediaBuffer*) CMediaBufferCreate(out_size, out_data, 0, 0); | |
145 //printf("OUTSIZE %d\n", out_size); | |
146 r = this->m_pDMO_Filter->m_pMedia->vt->ProcessOutput(this->m_pDMO_Filter->m_pMedia, | |
147 0, 1, &db, &status); | |
148 | |
149 ((IMediaBuffer*)db.pBuffer)->vt->GetBufferAndLength((IMediaBuffer*)db.pBuffer, 0, &written); | |
150 ((IMediaBuffer*)db.pBuffer)->vt->Release((IUnknown*)db.pBuffer); | |
151 | |
152 //printf("RESULTB: %d 0x%x %ld\n", r, r, written); | |
153 //printf("Converted %d -> %d\n", in_size, out_size); | |
154 } | |
155 else if (in_size > 0) | |
156 printf("ProcessInputError r:0x%x=%d\n", r, r); | |
157 | |
158 if (size_read) | |
159 *size_read = read; | |
160 if (size_written) | |
161 *size_written = written; | |
162 return r; | |
163 } | |
164 | |
165 int DMO_AudioDecoder_GetSrcSize(DMO_AudioDecoder *this, int dest_size) | |
166 { | |
167 // unsigned long inputs, outputs; | |
168 // Setup_FS_Segment(); | |
169 // this->m_pDMO_Filter->m_pMedia->vt->GetOutputSizeInfo(this->m_pDMO_Filter->m_pMedia, 0, &inputs, &outputs); | |
170 return ((WAVEFORMATEX*)this->m_sVhdr)->nBlockAlign*4; | |
171 } |