Mercurial > mplayer.hg
annotate loader/dshow/cmediasample.c @ 36699:51fccd9e0dc7
Simplify code.
CreatePopUpMenu() already provides a variable for the demuxer,
set by a call to mpctx_get_demuxer(). Use it.
author | ib |
---|---|
date | Fri, 07 Feb 2014 17:46:14 +0000 |
parents | 8fa2f43cb760 |
children |
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 */ |
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
5 |
1545 | 6 #include "cmediasample.h" |
22305
3d1b23cf3d08
Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
22028
diff
changeset
|
7 #include "mediatype.h" |
30170
008338d7679f
Drop -Iloader from CPPFLAGS for the loader subdirectory.
diego
parents:
29263
diff
changeset
|
8 #include "loader/wine/winerror.h" |
168 | 9 #include <stdio.h> |
10 #include <string.h> | |
7386 | 11 #include <stdlib.h> |
1545 | 12 |
8292 | 13 /* |
14 * currently hack to make some extra room for DS Acel codec which | |
15 * seems to overwrite allocated memory - FIXME better later | |
16 * check the buffer allocation | |
17 */ | |
18 static const int SAFETY_ACEL = 1024; | |
19 | |
22028 | 20 /** |
21 * \brief IPin::QueryInternalConnections (retries pin's internal connections) | |
22 * | |
23 * \param[in] This pointer to IPin interface | |
24 * \param[out] apPin Array that receives pins, internally connected to this | |
25 * \param[in,out] nPint Size of an array | |
26 * | |
27 * \return S_OK - success | |
28 * \return S_FALSE - pin rejects media type | |
29 * \return E_NOTIMPL - not implemented | |
30 * | |
31 */ | |
3056 | 32 static long STDCALL CMediaSample_QueryInterface(IUnknown* This, |
7386 | 33 /* [in] */ const GUID* iid, |
1545 | 34 /* [iid_is][out] */ void **ppv) |
168 | 35 { |
3056 | 36 Debug printf("CMediaSample_QueryInterface(%p) called\n", This); |
1545 | 37 if (!ppv) |
38 return E_INVALIDARG; | |
3056 | 39 if (memcmp(iid, &IID_IUnknown, sizeof(*iid)) == 0) |
168 | 40 { |
3056 | 41 *ppv = (void*)This; |
42 ((IMediaSample*) This)->vt->AddRef(This); | |
168 | 43 return 0; |
44 } | |
3056 | 45 if (memcmp(iid, &IID_IMediaSample, sizeof(*iid)) == 0) |
168 | 46 { |
3056 | 47 *ppv = (void*)This; |
48 ((IMediaSample*) This)->vt->AddRef(This); | |
168 | 49 return 0; |
50 } | |
1545 | 51 return E_NOINTERFACE; |
168 | 52 } |
53 | |
22028 | 54 /** |
55 * \brief IUnknown::AddRef (increases reference counter for interface) | |
56 * | |
57 * \param[in] This pointer to IUnknown class | |
58 * | |
59 * \return new value of reference counter | |
60 * | |
61 * \remarks | |
62 * Return value should be used only for debug purposes | |
63 * | |
64 */ | |
1545 | 65 static long STDCALL CMediaSample_AddRef(IUnknown* This) |
168 | 66 { |
3056 | 67 Debug printf("CMediaSample_AddRef(%p) called\n", This); |
168 | 68 ((CMediaSample*)This)->refcount++; |
69 return 0; | |
70 } | |
1545 | 71 |
22028 | 72 /** |
73 * \brief CMediaSample destructor | |
74 * | |
75 * \param[in] This pointer to CMediaSample object | |
76 * | |
77 */ | |
3056 | 78 void CMediaSample_Destroy(CMediaSample* This) |
79 { | |
80 | |
81 Debug printf("CMediaSample_Destroy(%p) called (ref:%d)\n", This, This->refcount); | |
82 free(This->vt); | |
83 free(This->own_block); | |
24347 | 84 if(((CMediaSample*)This)->type_valid) |
24408 | 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 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25849
diff
changeset
|
122 * \return apropriate error otherwise |
22028 | 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 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25849
diff
changeset
|
160 * \return VFW_E_SAMPLE_TIME_NOT_SET The sample is not time-stamped |
22028 | 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); |
30702 | 316 cms->own_block = 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 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25849
diff
changeset
|
337 * If method returns S_OK caller should free memory allocated for structure |
22028 | 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; | |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30702
diff
changeset
|
354 // 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; |
24347 | 378 if(((CMediaSample*)This)->type_valid) |
24408 | 379 FreeMediaType(t); |
22305
3d1b23cf3d08
Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
22028
diff
changeset
|
380 CopyMediaType(t,pMediaType); |
3467 | 381 ((CMediaSample*) This)->type_valid=1; |
1545 | 382 |
168 | 383 return 0; |
384 } | |
385 | |
22028 | 386 /** |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25849
diff
changeset
|
387 * \brief IMediaSample::IsDiscontinuity (determines if this sample represents data break |
22028 | 388 * in stream) |
389 * | |
390 * \param[in] This pointer to CMediaSample object | |
391 * | |
392 * \return S_OK if this sample is break in data stream | |
393 * \return S_FALSE otherwise | |
394 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25849
diff
changeset
|
395 * \remarks |
22028 | 396 * Discontinuity occures when filter seeks to different place in the stream or when drops |
397 * samples. | |
398 * | |
399 */ | |
1545 | 400 static HRESULT STDCALL CMediaSample_IsDiscontinuity(IMediaSample * This) |
168 | 401 { |
3056 | 402 Debug printf("CMediaSample_IsDiscontinuity(%p) called\n", This); |
3467 | 403 return ((CMediaSample*) This)->isDiscontinuity; |
168 | 404 } |
405 | |
22028 | 406 /** |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25849
diff
changeset
|
407 * \brief IMediaSample::IsDiscontinuity (specifies whether this sample represents data break |
22028 | 408 * in stream) |
409 * | |
410 * \param[in] This pointer to CMediaSample object | |
411 * \param[in] bDiscontinuity if TRUE this sample represents discontinuity with previous sample | |
412 * | |
413 * \return S_OK success | |
414 * \return apropriate error code otherwise | |
415 * | |
416 */ | |
1545 | 417 static HRESULT STDCALL CMediaSample_SetDiscontinuity(IMediaSample * This, |
418 long bDiscontinuity) | |
168 | 419 { |
3467 | 420 Debug printf("CMediaSample_SetDiscontinuity(%p) called (%ld)\n", This, bDiscontinuity); |
421 ((CMediaSample*) This)->isDiscontinuity = bDiscontinuity; | |
422 return 0; | |
1545 | 423 } |
424 | |
22028 | 425 /** |
426 * \brief IMediaSample::GetMediaTime (retrieves the media times of this sample) | |
427 * | |
428 * \param[in] This pointer to CMediaSample object | |
429 * \param[out] pTimeStart pointer to variable that receives start time | |
430 * \param[out] pTimeEnd pointer to variable that receives end time | |
431 * | |
432 * \return S_OK success | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25849
diff
changeset
|
433 * \return VFW_E_MEDIA_TIME_NOT_SET The sample is not time-stamped |
22028 | 434 * |
435 */ | |
1545 | 436 static HRESULT STDCALL CMediaSample_GetMediaTime(IMediaSample * This, |
437 /* [out] */ LONGLONG *pTimeStart, | |
438 /* [out] */ LONGLONG *pTimeEnd) | |
439 { | |
3056 | 440 Debug printf("CMediaSample_GetMediaTime(%p) called\n", This); |
3467 | 441 if (pTimeStart) |
442 *pTimeStart = ((CMediaSample*) This)->time_start; | |
443 if (pTimeEnd) | |
444 *pTimeEnd = ((CMediaSample*) This)->time_end; | |
445 return 0; | |
1545 | 446 } |
447 | |
22028 | 448 /** |
449 * \brief IMediaSample::GetMediaTime (retrieves the media times of this sample) | |
450 * | |
451 * \param[in] This pointer to CMediaSample object | |
452 * \param[out] pTimeStart pointer to variable that specifies start time | |
453 * \param[out] pTimeEnd pointer to variable that specifies end time | |
454 * | |
455 * \return S_OK success | |
456 * \return apropriate error code otherwise | |
457 * | |
458 * \remarks | |
459 * To invalidate the media times set pTimeStart and pTimeEnd to NULL. this will cause | |
460 * IMEdiaSample::GetTime to return VFW_E_MEDIA_TIME_NOT_SET | |
461 */ | |
1545 | 462 static HRESULT STDCALL CMediaSample_SetMediaTime(IMediaSample * This, |
463 /* [in] */ LONGLONG *pTimeStart, | |
464 /* [in] */ LONGLONG *pTimeEnd) | |
465 { | |
3056 | 466 Debug printf("CMediaSample_SetMediaTime(%p) called\n", This); |
3467 | 467 if (pTimeStart) |
468 ((CMediaSample*) This)->time_start = *pTimeStart; | |
469 if (pTimeEnd) | |
470 ((CMediaSample*) This)->time_end = *pTimeEnd; | |
471 return 0; | |
168 | 472 } |
473 | |
22028 | 474 /** |
475 * \brief CMediaSample::SetPointer (extension for direct memory write of decompressed data) | |
476 * | |
477 * \param[in] This pointer to CMediaSample object | |
478 * \param[in] pointer pointer to an external buffer to store data to | |
479 * | |
480 */ | |
3056 | 481 static void CMediaSample_SetPointer(CMediaSample* This, char* pointer) |
168 | 482 { |
3056 | 483 Debug printf("CMediaSample_SetPointer(%p) called -> %p\n", This, pointer); |
484 if (pointer) | |
485 This->block = pointer; | |
486 else | |
487 This->block = This->own_block; | |
488 } | |
1545 | 489 |
22028 | 490 /** |
491 * \brief CMediaSample::SetPointer (resets pointer to external buffer with internal one) | |
492 * | |
493 * \param[in] This pointer to CMediaSample object | |
494 * | |
495 */ | |
3056 | 496 static void CMediaSample_ResetPointer(CMediaSample* This) |
497 { | |
498 Debug printf("CMediaSample_ResetPointer(%p) called\n", This); | |
499 This->block = This->own_block; | |
168 | 500 } |
501 | |
22028 | 502 /** |
503 * \brief CMediaSample constructor | |
504 * | |
505 * \param[in] allocator IMemallocator interface of allocator to use | |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24408
diff
changeset
|
506 * \param[in] size size of internal buffer |
22028 | 507 * |
508 * \return pointer to CMediaSample object of NULL if error occured | |
509 * | |
510 */ | |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24408
diff
changeset
|
511 CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int size) |
168 | 512 { |
30702 | 513 CMediaSample* This = malloc(sizeof(CMediaSample)); |
3467 | 514 if (!This) |
515 return NULL; | |
516 | |
517 // some hack here! | |
518 // it looks like Acelp decoder is actually accessing | |
519 // the allocated memory before it sets the new size for it ??? | |
520 // -- maybe it's being initialized with wrong parameters | |
521 // anyway this is fixes the problem somehow with some reserves | |
522 // | |
523 // using different trick for now - in DS_Audio modify sample size | |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24408
diff
changeset
|
524 //if (size < 0x1000) |
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24408
diff
changeset
|
525 // size = (size + 0xfff) & ~0xfff; |
3467 | 526 |
30702 | 527 This->vt = malloc(sizeof(IMediaSample_vt)); |
528 This->own_block = malloc((size_t)size + SAFETY_ACEL); | |
3467 | 529 This->media_type.pbFormat = 0; |
24343 | 530 This->media_type.pUnk = 0; |
3467 | 531 |
532 if (!This->vt || !This->own_block) | |
533 { | |
534 CMediaSample_Destroy(This); | |
535 return NULL; | |
536 } | |
3056 | 537 |
538 This->vt->QueryInterface = CMediaSample_QueryInterface; | |
539 This->vt->AddRef = CMediaSample_AddRef; | |
540 This->vt->Release = CMediaSample_Release; | |
541 This->vt->GetPointer = CMediaSample_GetPointer; | |
542 This->vt->GetSize = CMediaSample_GetSize; | |
543 This->vt->GetTime = CMediaSample_GetTime; | |
544 This->vt->SetTime = CMediaSample_SetTime; | |
545 This->vt->IsSyncPoint = CMediaSample_IsSyncPoint; | |
546 This->vt->SetSyncPoint = CMediaSample_SetSyncPoint; | |
547 This->vt->IsPreroll = CMediaSample_IsPreroll; | |
548 This->vt->SetPreroll = CMediaSample_SetPreroll; | |
549 This->vt->GetActualDataLength = CMediaSample_GetActualDataLength; | |
550 This->vt->SetActualDataLength = CMediaSample_SetActualDataLength; | |
551 This->vt->GetMediaType = CMediaSample_GetMediaType; | |
552 This->vt->SetMediaType = CMediaSample_SetMediaType; | |
553 This->vt->IsDiscontinuity = CMediaSample_IsDiscontinuity; | |
554 This->vt->SetDiscontinuity = CMediaSample_SetDiscontinuity; | |
555 This->vt->GetMediaTime = CMediaSample_GetMediaTime; | |
556 This->vt->SetMediaTime = CMediaSample_SetMediaTime; | |
557 | |
558 This->all = allocator; | |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24408
diff
changeset
|
559 This->size = size; |
3056 | 560 This->refcount = 0; // increased by MemAllocator |
561 This->actual_size = 0; | |
562 This->isPreroll = 0; | |
3467 | 563 This->isDiscontinuity = 1; |
564 This->time_start = 0; | |
565 This->time_end = 0; | |
3056 | 566 This->type_valid = 0; |
567 This->block = This->own_block; | |
568 | |
569 This->SetPointer = CMediaSample_SetPointer; | |
570 This->ResetPointer = CMediaSample_ResetPointer; | |
571 | |
572 Debug printf("CMediaSample_Create(%p) called - sample size %d, buffer %p\n", | |
573 This, This->size, This->block); | |
574 | |
575 return This; | |
168 | 576 } |