Mercurial > mplayer.hg
annotate loader/dshow/cmediasample.c @ 24182:8d6ad131c010
Split lschunks function further, it is simply too huge to do any useful changes (e.g. for
more proper support for multi-codec tracks).
author | reimar |
---|---|
date | Sat, 25 Aug 2007 18:09:00 +0000 |
parents | 3d1b23cf3d08 |
children | bf37d4ba4b65 |
rev | line source |
---|---|
15166
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
1 /* |
18783 | 2 * Modified for use with MPlayer, detailed changelog at |
3 * http://svn.mplayerhq.hu/mplayer/trunk/ | |
15166
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
4 * $Id$ |
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
5 */ |
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
6 |
1545 | 7 #include "cmediasample.h" |
22305
3d1b23cf3d08
Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
22028
diff
changeset
|
8 #include "mediatype.h" |
2069 | 9 #include "wine/winerror.h" |
168 | 10 #include <stdio.h> |
11 #include <string.h> | |
7386 | 12 #include <stdlib.h> |
1545 | 13 |
8292 | 14 /* |
15 * currently hack to make some extra room for DS Acel codec which | |
16 * seems to overwrite allocated memory - FIXME better later | |
17 * check the buffer allocation | |
18 */ | |
19 static const int SAFETY_ACEL = 1024; | |
20 | |
22028 | 21 /** |
22 * \brief IPin::QueryInternalConnections (retries pin's internal connections) | |
23 * | |
24 * \param[in] This pointer to IPin interface | |
25 * \param[out] apPin Array that receives pins, internally connected to this | |
26 * \param[in,out] nPint Size of an array | |
27 * | |
28 * \return S_OK - success | |
29 * \return S_FALSE - pin rejects media type | |
30 * \return E_NOTIMPL - not implemented | |
31 * | |
32 */ | |
3056 | 33 static long STDCALL CMediaSample_QueryInterface(IUnknown* This, |
7386 | 34 /* [in] */ const GUID* iid, |
1545 | 35 /* [iid_is][out] */ void **ppv) |
168 | 36 { |
3056 | 37 Debug printf("CMediaSample_QueryInterface(%p) called\n", This); |
1545 | 38 if (!ppv) |
39 return E_INVALIDARG; | |
3056 | 40 if (memcmp(iid, &IID_IUnknown, sizeof(*iid)) == 0) |
168 | 41 { |
3056 | 42 *ppv = (void*)This; |
43 ((IMediaSample*) This)->vt->AddRef(This); | |
168 | 44 return 0; |
45 } | |
3056 | 46 if (memcmp(iid, &IID_IMediaSample, sizeof(*iid)) == 0) |
168 | 47 { |
3056 | 48 *ppv = (void*)This; |
49 ((IMediaSample*) This)->vt->AddRef(This); | |
168 | 50 return 0; |
51 } | |
1545 | 52 return E_NOINTERFACE; |
168 | 53 } |
54 | |
22028 | 55 /** |
56 * \brief IUnknown::AddRef (increases reference counter for interface) | |
57 * | |
58 * \param[in] This pointer to IUnknown class | |
59 * | |
60 * \return new value of reference counter | |
61 * | |
62 * \remarks | |
63 * Return value should be used only for debug purposes | |
64 * | |
65 */ | |
1545 | 66 static long STDCALL CMediaSample_AddRef(IUnknown* This) |
168 | 67 { |
3056 | 68 Debug printf("CMediaSample_AddRef(%p) called\n", This); |
168 | 69 ((CMediaSample*)This)->refcount++; |
70 return 0; | |
71 } | |
1545 | 72 |
22028 | 73 /** |
74 * \brief CMediaSample destructor | |
75 * | |
76 * \param[in] This pointer to CMediaSample object | |
77 * | |
78 */ | |
3056 | 79 void CMediaSample_Destroy(CMediaSample* This) |
80 { | |
81 | |
82 Debug printf("CMediaSample_Destroy(%p) called (ref:%d)\n", This, This->refcount); | |
83 free(This->vt); | |
84 free(This->own_block); | |
22305
3d1b23cf3d08
Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
22028
diff
changeset
|
85 FreeMediaType(&(This->media_type)); |
3056 | 86 free(This); |
87 } | |
88 | |
22028 | 89 /** |
90 * \brief IUnknown::Release (desreases reference counter for interface) | |
91 * | |
92 * \param[in] This pointer to IUnknown class | |
93 * | |
94 * \return new value of reference counter | |
95 * | |
96 * \remarks | |
97 * When reference counter reaches zero calls destructor | |
98 * Return value should be used only for debug purposes | |
99 * | |
100 */ | |
1545 | 101 static long STDCALL CMediaSample_Release(IUnknown* This) |
168 | 102 { |
3467 | 103 CMediaSample* parent = (CMediaSample*)This; |
3056 | 104 Debug printf("CMediaSample_Release(%p) called (new ref:%d)\n", |
1545 | 105 This, ((CMediaSample*)This)->refcount-1); |
3467 | 106 |
107 if (--((CMediaSample*) This)->refcount == 0) | |
3056 | 108 { |
1545 | 109 parent->all->vt->ReleaseBuffer((IMemAllocator*)(parent->all), |
110 (IMediaSample*)This); | |
3056 | 111 } |
168 | 112 return 0; |
113 } | |
1545 | 114 |
22028 | 115 /** |
116 * \brief IMediaSample::GetPointer (retrieves a read/write pointer to the media sample's buffer) | |
117 * | |
118 * \param[in] This pointer to CMediaSample object | |
119 * \param[out] address of variable that receives pointer to sample's buffer | |
120 * | |
121 * \return S_OK success | |
122 * \return apropriate error otherwise | |
123 * | |
124 * \note The calles should not free or reallocate buffer | |
125 * | |
126 */ | |
3467 | 127 static HRESULT STDCALL CMediaSample_GetPointer(IMediaSample* This, |
128 /* [out] */ BYTE** ppBuffer) | |
168 | 129 { |
3467 | 130 Debug printf("CMediaSample_GetPointer(%p) called -> %p, size: %d %d\n", This, ((CMediaSample*) This)->block, ((CMediaSample*)This)->actual_size, ((CMediaSample*)This)->size); |
1545 | 131 if (!ppBuffer) |
132 return E_INVALIDARG; | |
3467 | 133 *ppBuffer = (BYTE*) ((CMediaSample*) This)->block; |
168 | 134 return 0; |
135 } | |
136 | |
22028 | 137 /** |
138 * \brief IMediaSample::GetSize (retrieves a size of buffer in bytes) | |
139 * | |
140 * \param[in] This pointer to CMediaSample object | |
141 * | |
142 * \return size of buffer in bytes | |
143 * | |
144 */ | |
1545 | 145 static long STDCALL CMediaSample_GetSize(IMediaSample * This) |
168 | 146 { |
3467 | 147 Debug printf("CMediaSample_GetSize(%p) called -> %d\n", This, ((CMediaSample*) This)->size); |
148 return ((CMediaSample*) This)->size; | |
168 | 149 } |
150 | |
22028 | 151 /** |
152 * \brief IMediaSample::GetTime (retrieves a stream time at wich sample sould start and finish) | |
153 * | |
154 * \param[in] This pointer to CMediaSample object | |
155 * \param[out] pTimeStart pointer to variable that receives start time | |
156 * \param[out] pTimeEnd pointer to variable that receives end time | |
157 * | |
158 * \return S_OK success | |
159 * \return VFW_E_NO_STOP_TIME The sample has valid start time, but no stop time | |
160 * \return VFW_E_SAMPLE_TIME_NOT_SET The sample is not time-stamped | |
161 * | |
162 * \remarks | |
163 * Both values are relative to stream time | |
164 * | |
165 */ | |
1545 | 166 static HRESULT STDCALL CMediaSample_GetTime(IMediaSample * This, |
167 /* [out] */ REFERENCE_TIME *pTimeStart, | |
168 /* [out] */ REFERENCE_TIME *pTimeEnd) | |
168 | 169 { |
8292 | 170 Debug printf("CMediaSample_GetTime(%p) called (UNIMPLEMENTED)\n", This); |
168 | 171 return E_NOTIMPL; |
172 } | |
173 | |
22028 | 174 /** |
175 * \brief IMediaSample::SetTime (sets a stream time at wich sample sould start and finish) | |
176 * | |
177 * \param[in] This pointer to CMediaSample object | |
178 * \param[out] pTimeStart pointer to variable that contains start time | |
179 * \param[out] pTimeEnd pointer to variable that contains end time | |
180 * | |
181 * \return S_OK success | |
182 * \return apropriate error otherwise | |
183 * | |
184 * \remarks | |
185 * Both values are relative to stream time | |
186 * To invalidate the stream times set pTimeStart and pTimeEnd to NULL. this will cause | |
187 * IMEdiaSample::GetTime to return VFW_E_SAMPLE_TIME_NOT_SET | |
188 * | |
189 */ | |
1545 | 190 static HRESULT STDCALL CMediaSample_SetTime(IMediaSample * This, |
191 /* [in] */ REFERENCE_TIME *pTimeStart, | |
192 /* [in] */ REFERENCE_TIME *pTimeEnd) | |
168 | 193 { |
8292 | 194 Debug printf("CMediaSample_SetTime(%p) called (UNIMPLEMENTED)\n", This); |
168 | 195 return E_NOTIMPL; |
196 } | |
197 | |
22028 | 198 /** |
199 * \brief IMediaSample::IsSyncPoint (determines if start of this sample is sync point) | |
200 * | |
201 * \param[in] This pointer to CMediaSample object | |
202 * | |
203 * \return S_OK start of this sample is sync point | |
204 * \return S_FALSE start of this sample is not sync point | |
205 * | |
206 * \remarks | |
207 * If bTemporalCompression of AM_MEDIA_TYPE is FALSE, all samples are sync points. | |
208 * | |
209 */ | |
1545 | 210 static HRESULT STDCALL CMediaSample_IsSyncPoint(IMediaSample * This) |
168 | 211 { |
3056 | 212 Debug printf("CMediaSample_IsSyncPoint(%p) called\n", This); |
1545 | 213 if (((CMediaSample*)This)->isSyncPoint) |
214 return 0; | |
168 | 215 return 1; |
216 } | |
217 | |
22028 | 218 /** |
219 * \brief IMediaSample::SetSyncPoint (specifies if start of this sample is sync point) | |
220 * | |
221 * \param[in] This pointer to CMediaSample object | |
222 * \param[in] bIsSyncPoint specifies whether this is sync point or not | |
223 * | |
224 * \return S_OK success | |
225 * \return apropriate error code otherwise | |
226 * | |
227 */ | |
1545 | 228 static HRESULT STDCALL CMediaSample_SetSyncPoint(IMediaSample * This, |
229 long bIsSyncPoint) | |
168 | 230 { |
3056 | 231 Debug printf("CMediaSample_SetSyncPoint(%p) called\n", This); |
3467 | 232 ((CMediaSample*)This)->isSyncPoint = bIsSyncPoint; |
168 | 233 return 0; |
234 } | |
235 | |
22028 | 236 /** |
237 * \brief IMediaSample::IsPreroll (determines if this sample is preroll sample) | |
238 * | |
239 * \param[in] This pointer to CMediaSample object | |
240 * | |
241 * \return S_OK if this sample is preroll sample | |
242 * \return S_FALSE if this sample is not preroll sample | |
243 * | |
244 * \remarks | |
245 * Preroll samples are processed but not displayed. They are lokated in media stream | |
246 * before displayable samples. | |
247 * | |
248 */ | |
1545 | 249 static HRESULT STDCALL CMediaSample_IsPreroll(IMediaSample * This) |
168 | 250 { |
3056 | 251 Debug printf("CMediaSample_IsPreroll(%p) called\n", This); |
1545 | 252 |
253 if (((CMediaSample*)This)->isPreroll) | |
168 | 254 return 0;//S_OK |
1545 | 255 |
256 return 1;//S_FALSE | |
168 | 257 } |
258 | |
22028 | 259 /** |
260 * \brief IMediaSample::SetPreroll (specifies if this sample is preroll sample) | |
261 * | |
262 * \param[in] This pointer to CMediaSample object | |
263 * \param[in] bIsPreroll specifies whether this sample is preroll sample or not | |
264 * | |
265 * \return S_OK success | |
266 * \return apropriate error code otherwise | |
267 * | |
268 * \remarks | |
269 * Preroll samples are processed but not displayed. They are lokated in media stream | |
270 * before displayable samples. | |
271 * | |
272 */ | |
1545 | 273 static HRESULT STDCALL CMediaSample_SetPreroll(IMediaSample * This, |
274 long bIsPreroll) | |
168 | 275 { |
3056 | 276 Debug printf("CMediaSample_SetPreroll(%p) called\n", This); |
168 | 277 ((CMediaSample*)This)->isPreroll=bIsPreroll; |
278 return 0; | |
279 } | |
280 | |
22028 | 281 /** |
282 * \brief IMediaSample::GetActualDataLength (retrieves the length of valid data in the buffer) | |
283 * | |
284 * \param[in] This pointer to CMediaSample object | |
285 * | |
286 * \return length of valid data in buffer in bytes | |
287 * | |
288 */ | |
3056 | 289 static long STDCALL CMediaSample_GetActualDataLength(IMediaSample* This) |
168 | 290 { |
3056 | 291 Debug printf("CMediaSample_GetActualDataLength(%p) called -> %d\n", This, ((CMediaSample*)This)->actual_size); |
168 | 292 return ((CMediaSample*)This)->actual_size; |
293 } | |
294 | |
22028 | 295 /** |
296 * \brief IMediaSample::SetActualDataLength (specifies the length of valid data in the buffer) | |
297 * | |
298 * \param[in] This pointer to CMediaSample object | |
299 * \param[in] __MIDL_0010 length of data in sample in bytes | |
300 * | |
301 * \return S_OK success | |
302 * \return VFW_E_BUFFER_OVERFLOW length specified by parameter is larger than buffer size | |
303 * | |
304 */ | |
3056 | 305 static HRESULT STDCALL CMediaSample_SetActualDataLength(IMediaSample* This, |
1545 | 306 long __MIDL_0010) |
168 | 307 { |
3467 | 308 CMediaSample* cms = (CMediaSample*)This; |
3056 | 309 Debug printf("CMediaSample_SetActualDataLength(%p, %ld) called\n", This, __MIDL_0010); |
8292 | 310 |
3467 | 311 if (__MIDL_0010 > cms->size) |
168 | 312 { |
3467 | 313 char* c = cms->own_block; |
8292 | 314 Debug printf("CMediaSample - buffer overflow %ld %d %p %p\n", |
3467 | 315 __MIDL_0010, ((CMediaSample*)This)->size, cms->own_block, cms->block); |
8292 | 316 cms->own_block = (char*) realloc(cms->own_block, (size_t) __MIDL_0010 + SAFETY_ACEL); |
3467 | 317 if (c == cms->block) |
318 cms->block = cms->own_block; | |
319 cms->size = __MIDL_0010; | |
168 | 320 } |
3467 | 321 cms->actual_size = __MIDL_0010; |
168 | 322 return 0; |
323 } | |
324 | |
22028 | 325 /** |
326 * \brief IMediaSample::GetMediaType (retrieves media type, if it changed from previous sample) | |
327 * | |
328 * \param[in] This pointer to CMediaSample object | |
329 * \param[out] ppMediaType address of variable that receives pointer to AM_MEDIA_TYPE. | |
330 * | |
331 * \return S_OK success | |
332 * \return S_FALSE Media type was not changed from previous sample | |
333 * \return E_OUTOFMEMORY Insufficient memory | |
334 * | |
335 * \remarks | |
336 * If media type is not changed from previous sample, ppMediaType is null | |
337 * If method returns S_OK caller should free memory allocated for structure | |
338 * including pbFormat block | |
339 */ | |
3056 | 340 static HRESULT STDCALL CMediaSample_GetMediaType(IMediaSample* This, |
341 AM_MEDIA_TYPE** ppMediaType) | |
168 | 342 { |
3056 | 343 AM_MEDIA_TYPE* t; |
344 Debug printf("CMediaSample_GetMediaType(%p) called\n", This); | |
168 | 345 if(!ppMediaType) |
1545 | 346 return E_INVALIDARG; |
168 | 347 if(!((CMediaSample*)This)->type_valid) |
348 { | |
349 *ppMediaType=0; | |
350 return 1; | |
351 } | |
3056 | 352 |
353 t = &((CMediaSample*)This)->media_type; | |
9964 | 354 // if(t.pbFormat)free(t.pbFormat); |
22305
3d1b23cf3d08
Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
22028
diff
changeset
|
355 *ppMediaType=CreateMediaType(t); |
3056 | 356 // *ppMediaType=0; //media type was not changed |
1545 | 357 return 0; |
168 | 358 } |
359 | |
22028 | 360 /** |
361 * \brief IMediaType::SetMediaType (specifies media type for sample) | |
362 * | |
363 * \param[in] This pointer to CMediaSample object | |
364 * \param[in] pMediaType pointer to AM_MEDIA_TYPE specifies new media type | |
365 * | |
366 * \return S_OK success | |
367 * \return E_OUTOFMEMORY insufficient memory | |
368 * | |
369 */ | |
1545 | 370 static HRESULT STDCALL CMediaSample_SetMediaType(IMediaSample * This, |
371 AM_MEDIA_TYPE *pMediaType) | |
168 | 372 { |
3056 | 373 AM_MEDIA_TYPE* t; |
374 Debug printf("CMediaSample_SetMediaType(%p) called\n", This); | |
1545 | 375 if (!pMediaType) |
376 return E_INVALIDARG; | |
3056 | 377 t = &((CMediaSample*)This)->media_type; |
22305
3d1b23cf3d08
Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
22028
diff
changeset
|
378 FreeMediaType(t); |
3d1b23cf3d08
Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
22028
diff
changeset
|
379 CopyMediaType(t,pMediaType); |
3467 | 380 ((CMediaSample*) This)->type_valid=1; |
1545 | 381 |
168 | 382 return 0; |
383 } | |
384 | |
22028 | 385 /** |
386 * \brief IMediaSample::IsDiscontinuity (determines if this sample represents data break | |
387 * in stream) | |
388 * | |
389 * \param[in] This pointer to CMediaSample object | |
390 * | |
391 * \return S_OK if this sample is break in data stream | |
392 * \return S_FALSE otherwise | |
393 * | |
394 * \remarks | |
395 * Discontinuity occures when filter seeks to different place in the stream or when drops | |
396 * samples. | |
397 * | |
398 */ | |
1545 | 399 static HRESULT STDCALL CMediaSample_IsDiscontinuity(IMediaSample * This) |
168 | 400 { |
3056 | 401 Debug printf("CMediaSample_IsDiscontinuity(%p) called\n", This); |
3467 | 402 return ((CMediaSample*) This)->isDiscontinuity; |
168 | 403 } |
404 | |
22028 | 405 /** |
406 * \brief IMediaSample::IsDiscontinuity (specifies whether this sample represents data break | |
407 * in stream) | |
408 * | |
409 * \param[in] This pointer to CMediaSample object | |
410 * \param[in] bDiscontinuity if TRUE this sample represents discontinuity with previous sample | |
411 * | |
412 * \return S_OK success | |
413 * \return apropriate error code otherwise | |
414 * | |
415 */ | |
1545 | 416 static HRESULT STDCALL CMediaSample_SetDiscontinuity(IMediaSample * This, |
417 long bDiscontinuity) | |
168 | 418 { |
3467 | 419 Debug printf("CMediaSample_SetDiscontinuity(%p) called (%ld)\n", This, bDiscontinuity); |
420 ((CMediaSample*) This)->isDiscontinuity = bDiscontinuity; | |
421 return 0; | |
1545 | 422 } |
423 | |
22028 | 424 /** |
425 * \brief IMediaSample::GetMediaTime (retrieves the media times of this sample) | |
426 * | |
427 * \param[in] This pointer to CMediaSample object | |
428 * \param[out] pTimeStart pointer to variable that receives start time | |
429 * \param[out] pTimeEnd pointer to variable that receives end time | |
430 * | |
431 * \return S_OK success | |
432 * \return VFW_E_MEDIA_TIME_NOT_SET The sample is not time-stamped | |
433 * | |
434 */ | |
1545 | 435 static HRESULT STDCALL CMediaSample_GetMediaTime(IMediaSample * This, |
436 /* [out] */ LONGLONG *pTimeStart, | |
437 /* [out] */ LONGLONG *pTimeEnd) | |
438 { | |
3056 | 439 Debug printf("CMediaSample_GetMediaTime(%p) called\n", This); |
3467 | 440 if (pTimeStart) |
441 *pTimeStart = ((CMediaSample*) This)->time_start; | |
442 if (pTimeEnd) | |
443 *pTimeEnd = ((CMediaSample*) This)->time_end; | |
444 return 0; | |
1545 | 445 } |
446 | |
22028 | 447 /** |
448 * \brief IMediaSample::GetMediaTime (retrieves the media times of this sample) | |
449 * | |
450 * \param[in] This pointer to CMediaSample object | |
451 * \param[out] pTimeStart pointer to variable that specifies start time | |
452 * \param[out] pTimeEnd pointer to variable that specifies end time | |
453 * | |
454 * \return S_OK success | |
455 * \return apropriate error code otherwise | |
456 * | |
457 * \remarks | |
458 * To invalidate the media times set pTimeStart and pTimeEnd to NULL. this will cause | |
459 * IMEdiaSample::GetTime to return VFW_E_MEDIA_TIME_NOT_SET | |
460 */ | |
1545 | 461 static HRESULT STDCALL CMediaSample_SetMediaTime(IMediaSample * This, |
462 /* [in] */ LONGLONG *pTimeStart, | |
463 /* [in] */ LONGLONG *pTimeEnd) | |
464 { | |
3056 | 465 Debug printf("CMediaSample_SetMediaTime(%p) called\n", This); |
3467 | 466 if (pTimeStart) |
467 ((CMediaSample*) This)->time_start = *pTimeStart; | |
468 if (pTimeEnd) | |
469 ((CMediaSample*) This)->time_end = *pTimeEnd; | |
470 return 0; | |
168 | 471 } |
472 | |
22028 | 473 /** |
474 * \brief CMediaSample::SetPointer (extension for direct memory write of decompressed data) | |
475 * | |
476 * \param[in] This pointer to CMediaSample object | |
477 * \param[in] pointer pointer to an external buffer to store data to | |
478 * | |
479 */ | |
3056 | 480 static void CMediaSample_SetPointer(CMediaSample* This, char* pointer) |
168 | 481 { |
3056 | 482 Debug printf("CMediaSample_SetPointer(%p) called -> %p\n", This, pointer); |
483 if (pointer) | |
484 This->block = pointer; | |
485 else | |
486 This->block = This->own_block; | |
487 } | |
1545 | 488 |
22028 | 489 /** |
490 * \brief CMediaSample::SetPointer (resets pointer to external buffer with internal one) | |
491 * | |
492 * \param[in] This pointer to CMediaSample object | |
493 * | |
494 */ | |
3056 | 495 static void CMediaSample_ResetPointer(CMediaSample* This) |
496 { | |
497 Debug printf("CMediaSample_ResetPointer(%p) called\n", This); | |
498 This->block = This->own_block; | |
168 | 499 } |
500 | |
22028 | 501 /** |
502 * \brief CMediaSample constructor | |
503 * | |
504 * \param[in] allocator IMemallocator interface of allocator to use | |
505 * \param[in] _size size of internal buffer | |
506 * | |
507 * \return pointer to CMediaSample object of NULL if error occured | |
508 * | |
509 */ | |
3056 | 510 CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int _size) |
168 | 511 { |
3467 | 512 CMediaSample* This = (CMediaSample*) malloc(sizeof(CMediaSample)); |
513 if (!This) | |
514 return NULL; | |
515 | |
516 // some hack here! | |
517 // it looks like Acelp decoder is actually accessing | |
518 // the allocated memory before it sets the new size for it ??? | |
519 // -- maybe it's being initialized with wrong parameters | |
520 // anyway this is fixes the problem somehow with some reserves | |
521 // | |
522 // using different trick for now - in DS_Audio modify sample size | |
523 //if (_size < 0x1000) | |
524 // _size = (_size + 0xfff) & ~0xfff; | |
525 | |
3056 | 526 This->vt = (IMediaSample_vt*) malloc(sizeof(IMediaSample_vt)); |
8292 | 527 This->own_block = (char*) malloc((size_t)_size + SAFETY_ACEL); |
3467 | 528 This->media_type.pbFormat = 0; |
529 | |
530 if (!This->vt || !This->own_block) | |
531 { | |
532 CMediaSample_Destroy(This); | |
533 return NULL; | |
534 } | |
3056 | 535 |
536 This->vt->QueryInterface = CMediaSample_QueryInterface; | |
537 This->vt->AddRef = CMediaSample_AddRef; | |
538 This->vt->Release = CMediaSample_Release; | |
539 This->vt->GetPointer = CMediaSample_GetPointer; | |
540 This->vt->GetSize = CMediaSample_GetSize; | |
541 This->vt->GetTime = CMediaSample_GetTime; | |
542 This->vt->SetTime = CMediaSample_SetTime; | |
543 This->vt->IsSyncPoint = CMediaSample_IsSyncPoint; | |
544 This->vt->SetSyncPoint = CMediaSample_SetSyncPoint; | |
545 This->vt->IsPreroll = CMediaSample_IsPreroll; | |
546 This->vt->SetPreroll = CMediaSample_SetPreroll; | |
547 This->vt->GetActualDataLength = CMediaSample_GetActualDataLength; | |
548 This->vt->SetActualDataLength = CMediaSample_SetActualDataLength; | |
549 This->vt->GetMediaType = CMediaSample_GetMediaType; | |
550 This->vt->SetMediaType = CMediaSample_SetMediaType; | |
551 This->vt->IsDiscontinuity = CMediaSample_IsDiscontinuity; | |
552 This->vt->SetDiscontinuity = CMediaSample_SetDiscontinuity; | |
553 This->vt->GetMediaTime = CMediaSample_GetMediaTime; | |
554 This->vt->SetMediaTime = CMediaSample_SetMediaTime; | |
555 | |
556 This->all = allocator; | |
557 This->size = _size; | |
558 This->refcount = 0; // increased by MemAllocator | |
559 This->actual_size = 0; | |
560 This->isPreroll = 0; | |
3467 | 561 This->isDiscontinuity = 1; |
562 This->time_start = 0; | |
563 This->time_end = 0; | |
3056 | 564 This->type_valid = 0; |
565 This->block = This->own_block; | |
566 | |
567 This->SetPointer = CMediaSample_SetPointer; | |
568 This->ResetPointer = CMediaSample_ResetPointer; | |
569 | |
570 Debug printf("CMediaSample_Create(%p) called - sample size %d, buffer %p\n", | |
571 This, This->size, This->block); | |
572 | |
573 return This; | |
168 | 574 } |