annotate loader/dshow/DS_AudioDecoder.c @ 8193:83d3125cb382

A bit more sane range.
author rguyom
date Thu, 14 Nov 2002 21:57:34 +0000
parents 3898967fcc96
children 9533c26c0806
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
1 /********************************************************
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
2
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
3 DirectShow audio decoder
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
4 Copyright 2001 Eugene Kuznetsov (divx@euro.ru)
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
5
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
6 *********************************************************/
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
7
3946
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
8 #ifndef NOAVIFILE_HEADERS
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
9 #include "audiodecoder.h"
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
10 #include "except.h"
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
11 #else
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
12 #include "libwin32.h"
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
13 #endif
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
14
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
15 #include "DS_Filter.h"
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
16
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
17 struct _DS_AudioDecoder
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
18 {
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
19 WAVEFORMATEX in_fmt;
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
20 AM_MEDIA_TYPE m_sOurType, m_sDestType;
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
21 DS_Filter* m_pDS_Filter;
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
22 char* m_sVhdr;
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
23 char* m_sVhdr2;
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
24 };
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
25
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1545
diff changeset
26 #include "DS_AudioDecoder.h"
3946
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
27
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1545
diff changeset
28 #include <string.h>
ce45cce7f7a5 sync with avifile
arpi
parents: 1545
diff changeset
29 #include <stdio.h>
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
30 #include <stdlib.h>
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1545
diff changeset
31
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
32 #define __MODULE__ "DirectShow audio decoder"
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
33 const GUID FORMAT_WaveFormatEx = {
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
34 0x05589f81, 0xc356, 0x11CE,
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
35 { 0xBF, 0x01, 0x00, 0xAA, 0x00, 0x55, 0x59, 0x5A }
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
36 };
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
37 const GUID MEDIATYPE_Audio = {
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
38 0x73647561, 0x0000, 0x0010,
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
39 { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
40 };
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
41 const GUID MEDIASUBTYPE_PCM = {
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
42 0x00000001, 0x0000, 0x0010,
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
43 { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
44 };
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
45
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
46 typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**);
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
47
3444
0c0042de1f95 API changes - now fully compatible with C++ version
arpi
parents: 3063
diff changeset
48 DS_AudioDecoder * DS_AudioDecoder_Open(char* dllname, GUID* guid, WAVEFORMATEX* wf)
0c0042de1f95 API changes - now fully compatible with C++ version
arpi
parents: 3063
diff changeset
49 //DS_AudioDecoder * DS_AudioDecoder_Create(const CodecInfo * info, const WAVEFORMATEX* wf)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
50 {
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
51 DS_AudioDecoder *this;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
52 int sz;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
53 WAVEFORMATEX* pWF;
3444
0c0042de1f95 API changes - now fully compatible with C++ version
arpi
parents: 3063
diff changeset
54
0c0042de1f95 API changes - now fully compatible with C++ version
arpi
parents: 3063
diff changeset
55 Setup_LDT_Keeper();
0c0042de1f95 API changes - now fully compatible with C++ version
arpi
parents: 3063
diff changeset
56 Setup_FS_Segment();
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
57
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
58 this = malloc(sizeof(DS_AudioDecoder));
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
59
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
60 sz = 18 + wf->cbSize;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
61 this->m_sVhdr = malloc(sz);
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
62 memcpy(this->m_sVhdr, wf, sz);
3915
8f71d01a22d7 ACEL.P fixed (avifile sync)
arpi
parents: 3466
diff changeset
63 this->m_sVhdr2 = malloc(18);
8f71d01a22d7 ACEL.P fixed (avifile sync)
arpi
parents: 3466
diff changeset
64 memcpy(this->m_sVhdr2, this->m_sVhdr, 18);
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
65
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
66 pWF = (WAVEFORMATEX*)this->m_sVhdr2;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
67 pWF->wFormatTag = 1;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
68 pWF->wBitsPerSample = 16;
3915
8f71d01a22d7 ACEL.P fixed (avifile sync)
arpi
parents: 3466
diff changeset
69 pWF->nBlockAlign = pWF->nChannels * (pWF->wBitsPerSample + 7) / 8;
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
70 pWF->cbSize = 0;
3915
8f71d01a22d7 ACEL.P fixed (avifile sync)
arpi
parents: 3466
diff changeset
71 pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec;
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
72
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
73 memcpy(&this->in_fmt,wf,sizeof(WAVEFORMATEX));
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
74
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
75 memset(&this->m_sOurType, 0, sizeof(this->m_sOurType));
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
76 this->m_sOurType.majortype=MEDIATYPE_Audio;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
77 this->m_sOurType.subtype=MEDIASUBTYPE_PCM;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
78 this->m_sOurType.subtype.f1=wf->wFormatTag;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
79 this->m_sOurType.formattype=FORMAT_WaveFormatEx;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
80 this->m_sOurType.lSampleSize=wf->nBlockAlign;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
81 this->m_sOurType.bFixedSizeSamples=1;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
82 this->m_sOurType.bTemporalCompression=0;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
83 this->m_sOurType.pUnk=0;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
84 this->m_sOurType.cbFormat=sz;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
85 this->m_sOurType.pbFormat=this->m_sVhdr;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
86
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
87 memset(&this->m_sDestType, 0, sizeof(this->m_sDestType));
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
88 this->m_sDestType.majortype=MEDIATYPE_Audio;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
89 this->m_sDestType.subtype=MEDIASUBTYPE_PCM;
3915
8f71d01a22d7 ACEL.P fixed (avifile sync)
arpi
parents: 3466
diff changeset
90 // this->m_sDestType.subtype.f1=pWF->wFormatTag;
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
91 this->m_sDestType.formattype=FORMAT_WaveFormatEx;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
92 this->m_sDestType.bFixedSizeSamples=1;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
93 this->m_sDestType.bTemporalCompression=0;
3915
8f71d01a22d7 ACEL.P fixed (avifile sync)
arpi
parents: 3466
diff changeset
94 this->m_sDestType.lSampleSize=pWF->nBlockAlign;
3466
b6caac381405 avifile merge
arpi
parents: 3444
diff changeset
95 if (wf->wFormatTag == 0x130)
b6caac381405 avifile merge
arpi
parents: 3444
diff changeset
96 // ACEL hack to prevent memory corruption
b6caac381405 avifile merge
arpi
parents: 3444
diff changeset
97 // obviosly we are missing something here
b6caac381405 avifile merge
arpi
parents: 3444
diff changeset
98 this->m_sDestType.lSampleSize *= 288;
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
99 this->m_sDestType.pUnk=0;
3915
8f71d01a22d7 ACEL.P fixed (avifile sync)
arpi
parents: 3466
diff changeset
100 this->m_sDestType.cbFormat=18; //pWF->cbSize;
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
101 this->m_sDestType.pbFormat=this->m_sVhdr2;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
102
6139
3898967fcc96 some more output cosmetics, especially for vivo and mov demuxers
arpi
parents: 3946
diff changeset
103 //print_wave_header(this->m_sVhdr);
3898967fcc96 some more output cosmetics, especially for vivo and mov demuxers
arpi
parents: 3946
diff changeset
104 //print_wave_header(this->m_sVhdr2);
3915
8f71d01a22d7 ACEL.P fixed (avifile sync)
arpi
parents: 3466
diff changeset
105
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
106 /*try*/
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
107 {
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
108 ALLOCATOR_PROPERTIES props, props1;
3444
0c0042de1f95 API changes - now fully compatible with C++ version
arpi
parents: 3063
diff changeset
109 this->m_pDS_Filter = DS_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType);
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
110 if( !this->m_pDS_Filter ) {
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
111 free(this);
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
112 return NULL;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
113 }
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
114
3063
004e3199fee0 mplayer integration
arpi
parents: 3059
diff changeset
115 this->m_pDS_Filter->Start(this->m_pDS_Filter);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
116
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
117 props.cBuffers=1;
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
118 props.cbBuffer=this->m_sOurType.lSampleSize;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
119 props.cbAlign=props.cbPrefix=0;
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
120 this->m_pDS_Filter->m_pAll->vt->SetProperties(this->m_pDS_Filter->m_pAll, &props, &props1);
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
121 this->m_pDS_Filter->m_pAll->vt->Commit(this->m_pDS_Filter->m_pAll);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
122 }
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
123 /*
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
124 catch (FatalError& e)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
125 {
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
126 e.PrintAll();
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
127 delete[] m_sVhdr;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
128 delete[] m_sVhdr2;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
129 delete m_pDS_Filter;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
130 throw;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
131 }
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
132 */
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
133 return this;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
134 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
135
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
136 void DS_AudioDecoder_Destroy(DS_AudioDecoder *this)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
137 {
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
138 free(this->m_sVhdr);
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
139 free(this->m_sVhdr2);
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
140 DS_Filter_Destroy(this->m_pDS_Filter);
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
141 free(this);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
142 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
143
3946
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
144 int DS_AudioDecoder_Convert(DS_AudioDecoder *this, const void* in_data, unsigned int in_size,
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
145 void* out_data, unsigned int out_size,
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
146 unsigned int* size_read, unsigned int* size_written)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
147 {
3946
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
148 unsigned int written = 0;
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
149 unsigned int read = 0;
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
150
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
151 if (!in_data || !out_data)
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
152 return -1;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
153
3444
0c0042de1f95 API changes - now fully compatible with C++ version
arpi
parents: 3063
diff changeset
154 Setup_FS_Segment();
0c0042de1f95 API changes - now fully compatible with C++ version
arpi
parents: 3063
diff changeset
155
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
156 in_size -= in_size%this->in_fmt.nBlockAlign;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
157 while (in_size>0)
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
158 {
3946
c00db356082f headers cleanup
arpi
parents: 3915
diff changeset
159 unsigned int frame_size = 0;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
160 char* frame_pointer;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
161 IMediaSample* sample=0;
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
162 char* ptr;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
163 int result;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
164
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
165 // this->m_pOurOutput->SetFramePointer(out_data+written);
3063
004e3199fee0 mplayer integration
arpi
parents: 3059
diff changeset
166 this->m_pDS_Filter->m_pOurOutput->SetFramePointer(this->m_pDS_Filter->m_pOurOutput,&frame_pointer);
004e3199fee0 mplayer integration
arpi
parents: 3059
diff changeset
167 this->m_pDS_Filter->m_pOurOutput->SetFrameSizePointer(this->m_pDS_Filter->m_pOurOutput,(long*)&frame_size);
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
168 this->m_pDS_Filter->m_pAll->vt->GetBuffer(this->m_pDS_Filter->m_pAll, &sample, 0, 0, 0);
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
169 if (!sample)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
170 {
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1545
diff changeset
171 Debug printf("DS_AudioDecoder::Convert() Error: null sample\n");
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
172 break;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
173 }
3466
b6caac381405 avifile merge
arpi
parents: 3444
diff changeset
174 sample->vt->SetActualDataLength(sample, this->in_fmt.nBlockAlign);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
175 sample->vt->GetPointer(sample, (BYTE **)&ptr);
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
176 memcpy(ptr, (const uint8_t*)in_data + read, this->in_fmt.nBlockAlign);
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
177 sample->vt->SetSyncPoint(sample, 1);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
178 sample->vt->SetPreroll(sample, 0);
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
179 result = this->m_pDS_Filter->m_pImp->vt->Receive(this->m_pDS_Filter->m_pImp, sample);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
180 if (result)
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
181 Debug printf("DS_AudioDecoder::Convert() Error: putting data into input pin %x\n", result);
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
182 if ((written + frame_size) > out_size)
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
183 {
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
184 sample->vt->Release((IUnknown*)sample);
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
185 break;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
186 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
187 memcpy((uint8_t*)out_data + written, frame_pointer, frame_size);
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
188 sample->vt->Release((IUnknown*)sample);
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
189 read+=this->in_fmt.nBlockAlign;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
190 written+=frame_size;
3466
b6caac381405 avifile merge
arpi
parents: 3444
diff changeset
191 break;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
192 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
193 if (size_read)
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
194 *size_read = read;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
195 if (size_written)
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
196 *size_written = written;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
197 return 0;
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
198 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
199
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
200 int DS_AudioDecoder_GetSrcSize(DS_AudioDecoder *this, int dest_size)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
201 {
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
202 double efficiency =(double) this->in_fmt.nAvgBytesPerSec
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
203 / (this->in_fmt.nSamplesPerSec*this->in_fmt.nBlockAlign);
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
204 int frames = (int)(dest_size*efficiency);;
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
205
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
206 if (frames < 1)
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
207 frames = 1;
3059
24fa494bedb1 imported from xine
arpi
parents: 2072
diff changeset
208 return frames * this->in_fmt.nBlockAlign;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents:
diff changeset
209 }