annotate loader/dshow/cmediasample.c @ 6483:2dd9691fe6b8

YVU9,IF09,Y800 and Y8 support - and synced with mpxp
author alex
date Fri, 21 Jun 2002 17:31:02 +0000
parents e3bbf44dbab2
children 174e2a58b4cd
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: 713
diff changeset
1 #include "cmediasample.h"
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1545
diff changeset
2 #include "wine/winerror.h"
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
3 #include <stdio.h>
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
4 #include <string.h>
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
5
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
6 static long STDCALL CMediaSample_QueryInterface(IUnknown* This,
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
7 /* [in] */ IID* iid,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
8 /* [iid_is][out] */ void **ppv)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
9 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
10 Debug printf("CMediaSample_QueryInterface(%p) called\n", This);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
11 if (!ppv)
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
12 return E_INVALIDARG;
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
13 if (memcmp(iid, &IID_IUnknown, sizeof(*iid)) == 0)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
14 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
15 *ppv = (void*)This;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
16 ((IMediaSample*) This)->vt->AddRef(This);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
17 return 0;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
18 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
19 if (memcmp(iid, &IID_IMediaSample, sizeof(*iid)) == 0)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
20 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
21 *ppv = (void*)This;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
22 ((IMediaSample*) This)->vt->AddRef(This);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
23 return 0;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
24 }
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
25 return E_NOINTERFACE;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
26 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
27
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
28 static long STDCALL CMediaSample_AddRef(IUnknown* This)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
29 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
30 Debug printf("CMediaSample_AddRef(%p) called\n", This);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
31 ((CMediaSample*)This)->refcount++;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
32 return 0;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
33 }
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
34
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
35 void CMediaSample_Destroy(CMediaSample* This)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
36 {
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
37
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
38 Debug printf("CMediaSample_Destroy(%p) called (ref:%d)\n", This, This->refcount);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
39 free(This->vt);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
40 free(This->own_block);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
41 if (This->media_type.pbFormat)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
42 CoTaskMemFree(This->media_type.pbFormat);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
43 free(This);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
44 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
45
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
46 static long STDCALL CMediaSample_Release(IUnknown* This)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
47 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
48 CMediaSample* parent = (CMediaSample*)This;
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
49 Debug printf("CMediaSample_Release(%p) called (new ref:%d)\n",
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
50 This, ((CMediaSample*)This)->refcount-1);
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
51
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
52 if (--((CMediaSample*) This)->refcount == 0)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
53 {
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
54 parent->all->vt->ReleaseBuffer((IMemAllocator*)(parent->all),
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
55 (IMediaSample*)This);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
56 }
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
57 return 0;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
58 }
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
59
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
60 static HRESULT STDCALL CMediaSample_GetPointer(IMediaSample* This,
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
61 /* [out] */ BYTE** ppBuffer)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
62 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
63 Debug printf("CMediaSample_GetPointer(%p) called -> %p, size: %d %d\n", This, ((CMediaSample*) This)->block, ((CMediaSample*)This)->actual_size, ((CMediaSample*)This)->size);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
64 if (!ppBuffer)
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
65 return E_INVALIDARG;
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
66 *ppBuffer = (BYTE*) ((CMediaSample*) This)->block;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
67 return 0;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
68 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
69
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
70 static long STDCALL CMediaSample_GetSize(IMediaSample * This)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
71 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
72 Debug printf("CMediaSample_GetSize(%p) called -> %d\n", This, ((CMediaSample*) This)->size);
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
73 return ((CMediaSample*) This)->size;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
74 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
75
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
76 static HRESULT STDCALL CMediaSample_GetTime(IMediaSample * This,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
77 /* [out] */ REFERENCE_TIME *pTimeStart,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
78 /* [out] */ REFERENCE_TIME *pTimeEnd)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
79 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
80 Debug printf("CMediaSample_GetTime(%p) called (UNIMPLIMENTED)\n", This);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
81 return E_NOTIMPL;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
82 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
83
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
84 static HRESULT STDCALL CMediaSample_SetTime(IMediaSample * This,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
85 /* [in] */ REFERENCE_TIME *pTimeStart,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
86 /* [in] */ REFERENCE_TIME *pTimeEnd)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
87 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
88 Debug printf("CMediaSample_SetTime(%p) called (UNIMPLIMENTED)\n", This);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
89 return E_NOTIMPL;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
90 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
91
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
92 static HRESULT STDCALL CMediaSample_IsSyncPoint(IMediaSample * This)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
93 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
94 Debug printf("CMediaSample_IsSyncPoint(%p) called\n", This);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
95 if (((CMediaSample*)This)->isSyncPoint)
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
96 return 0;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
97 return 1;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
98 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
99
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
100 static HRESULT STDCALL CMediaSample_SetSyncPoint(IMediaSample * This,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
101 long bIsSyncPoint)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
102 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
103 Debug printf("CMediaSample_SetSyncPoint(%p) called\n", This);
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
104 ((CMediaSample*)This)->isSyncPoint = bIsSyncPoint;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
105 return 0;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
106 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
107
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
108 static HRESULT STDCALL CMediaSample_IsPreroll(IMediaSample * This)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
109 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
110 Debug printf("CMediaSample_IsPreroll(%p) called\n", This);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
111
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
112 if (((CMediaSample*)This)->isPreroll)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
113 return 0;//S_OK
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
114
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
115 return 1;//S_FALSE
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
116 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
117
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
118 static HRESULT STDCALL CMediaSample_SetPreroll(IMediaSample * This,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
119 long bIsPreroll)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
120 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
121 Debug printf("CMediaSample_SetPreroll(%p) called\n", This);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
122 ((CMediaSample*)This)->isPreroll=bIsPreroll;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
123 return 0;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
124 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
125
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
126 static long STDCALL CMediaSample_GetActualDataLength(IMediaSample* This)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
127 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
128 Debug printf("CMediaSample_GetActualDataLength(%p) called -> %d\n", This, ((CMediaSample*)This)->actual_size);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
129 return ((CMediaSample*)This)->actual_size;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
130 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
131
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
132 static HRESULT STDCALL CMediaSample_SetActualDataLength(IMediaSample* This,
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
133 long __MIDL_0010)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
134 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
135 CMediaSample* cms = (CMediaSample*)This;
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
136 Debug printf("CMediaSample_SetActualDataLength(%p, %ld) called\n", This, __MIDL_0010);
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
137 if (__MIDL_0010 > cms->size)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
138 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
139 char* c = cms->own_block;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
140 Debug printf(" CMediaSample - buffer overflow %ld %d %p %p\n",
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
141 __MIDL_0010, ((CMediaSample*)This)->size, cms->own_block, cms->block);
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
142 cms->own_block = realloc(cms->own_block, __MIDL_0010);
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
143 if (c == cms->block)
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
144 cms->block = cms->own_block;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
145 cms->size = __MIDL_0010;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
146 }
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
147 cms->actual_size = __MIDL_0010;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
148 return 0;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
149 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
150
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
151 static HRESULT STDCALL CMediaSample_GetMediaType(IMediaSample* This,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
152 AM_MEDIA_TYPE** ppMediaType)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
153 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
154 AM_MEDIA_TYPE* t;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
155 Debug printf("CMediaSample_GetMediaType(%p) called\n", This);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
156 if(!ppMediaType)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
157 return E_INVALIDARG;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
158 if(!((CMediaSample*)This)->type_valid)
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
159 {
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
160 *ppMediaType=0;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
161 return 1;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
162 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
163
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
164 t = &((CMediaSample*)This)->media_type;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
165 // if(t.pbFormat)CoTaskMemFree(t.pbFormat);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
166 (*ppMediaType) = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
167 **ppMediaType = *t;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
168 (*ppMediaType)->pbFormat = (char*)CoTaskMemAlloc(t->cbFormat);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
169 memcpy((*ppMediaType)->pbFormat, t->pbFormat, t->cbFormat);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
170 // *ppMediaType=0; //media type was not changed
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
171 return 0;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
172 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
173
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
174 static HRESULT STDCALL CMediaSample_SetMediaType(IMediaSample * This,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
175 AM_MEDIA_TYPE *pMediaType)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
176 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
177 AM_MEDIA_TYPE* t;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
178 Debug printf("CMediaSample_SetMediaType(%p) called\n", This);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
179 if (!pMediaType)
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
180 return E_INVALIDARG;
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
181 t = &((CMediaSample*)This)->media_type;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
182 if (t->pbFormat)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
183 CoTaskMemFree(t->pbFormat);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
184 t = pMediaType;
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
185 if (t->cbFormat)
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
186 {
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
187 t->pbFormat = (char*)CoTaskMemAlloc(t->cbFormat);
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
188 memcpy(t->pbFormat, pMediaType->pbFormat, t->cbFormat);
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
189 }
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
190 else
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
191 t->pbFormat = 0;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
192 ((CMediaSample*) This)->type_valid=1;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
193
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
194 return 0;
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
195 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
196
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
197 static HRESULT STDCALL CMediaSample_IsDiscontinuity(IMediaSample * This)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
198 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
199 Debug printf("CMediaSample_IsDiscontinuity(%p) called\n", This);
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
200 return ((CMediaSample*) This)->isDiscontinuity;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
201 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
202
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
203 static HRESULT STDCALL CMediaSample_SetDiscontinuity(IMediaSample * This,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
204 long bDiscontinuity)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
205 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
206 Debug printf("CMediaSample_SetDiscontinuity(%p) called (%ld)\n", This, bDiscontinuity);
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
207 ((CMediaSample*) This)->isDiscontinuity = bDiscontinuity;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
208 return 0;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
209 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
210
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
211 static HRESULT STDCALL CMediaSample_GetMediaTime(IMediaSample * This,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
212 /* [out] */ LONGLONG *pTimeStart,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
213 /* [out] */ LONGLONG *pTimeEnd)
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
214 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
215 Debug printf("CMediaSample_GetMediaTime(%p) called\n", This);
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
216 if (pTimeStart)
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
217 *pTimeStart = ((CMediaSample*) This)->time_start;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
218 if (pTimeEnd)
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
219 *pTimeEnd = ((CMediaSample*) This)->time_end;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
220 return 0;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
221 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
222
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
223 static HRESULT STDCALL CMediaSample_SetMediaTime(IMediaSample * This,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
224 /* [in] */ LONGLONG *pTimeStart,
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
225 /* [in] */ LONGLONG *pTimeEnd)
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
226 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
227 Debug printf("CMediaSample_SetMediaTime(%p) called\n", This);
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
228 if (pTimeStart)
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
229 ((CMediaSample*) This)->time_start = *pTimeStart;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
230 if (pTimeEnd)
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
231 ((CMediaSample*) This)->time_end = *pTimeEnd;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
232 return 0;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
233 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
234
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
235 // extension for direct memory write or decompressed data
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
236 static void CMediaSample_SetPointer(CMediaSample* This, char* pointer)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
237 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
238 Debug printf("CMediaSample_SetPointer(%p) called -> %p\n", This, pointer);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
239 if (pointer)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
240 This->block = pointer;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
241 else
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
242 This->block = This->own_block;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
243 }
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 713
diff changeset
244
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
245 static void CMediaSample_ResetPointer(CMediaSample* This)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
246 {
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
247 Debug printf("CMediaSample_ResetPointer(%p) called\n", This);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
248 This->block = This->own_block;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
249 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
250
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
251 CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int _size)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
252 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
253 CMediaSample* This = (CMediaSample*) malloc(sizeof(CMediaSample));
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
254 if (!This)
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
255 return NULL;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
256
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
257 // some hack here!
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
258 // it looks like Acelp decoder is actually accessing
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
259 // the allocated memory before it sets the new size for it ???
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
260 // -- maybe it's being initialized with wrong parameters
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
261 // anyway this is fixes the problem somehow with some reserves
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
262 //
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
263 // using different trick for now - in DS_Audio modify sample size
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
264 //if (_size < 0x1000)
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
265 // _size = (_size + 0xfff) & ~0xfff;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
266
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
267 This->vt = (IMediaSample_vt*) malloc(sizeof(IMediaSample_vt));
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
268 This->own_block = (char*) malloc(_size);
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
269 This->media_type.pbFormat = 0;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
270
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
271 if (!This->vt || !This->own_block)
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
272 {
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
273 CMediaSample_Destroy(This);
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
274 return NULL;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
275 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
276
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
277 This->vt->QueryInterface = CMediaSample_QueryInterface;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
278 This->vt->AddRef = CMediaSample_AddRef;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
279 This->vt->Release = CMediaSample_Release;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
280 This->vt->GetPointer = CMediaSample_GetPointer;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
281 This->vt->GetSize = CMediaSample_GetSize;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
282 This->vt->GetTime = CMediaSample_GetTime;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
283 This->vt->SetTime = CMediaSample_SetTime;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
284 This->vt->IsSyncPoint = CMediaSample_IsSyncPoint;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
285 This->vt->SetSyncPoint = CMediaSample_SetSyncPoint;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
286 This->vt->IsPreroll = CMediaSample_IsPreroll;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
287 This->vt->SetPreroll = CMediaSample_SetPreroll;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
288 This->vt->GetActualDataLength = CMediaSample_GetActualDataLength;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
289 This->vt->SetActualDataLength = CMediaSample_SetActualDataLength;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
290 This->vt->GetMediaType = CMediaSample_GetMediaType;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
291 This->vt->SetMediaType = CMediaSample_SetMediaType;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
292 This->vt->IsDiscontinuity = CMediaSample_IsDiscontinuity;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
293 This->vt->SetDiscontinuity = CMediaSample_SetDiscontinuity;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
294 This->vt->GetMediaTime = CMediaSample_GetMediaTime;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
295 This->vt->SetMediaTime = CMediaSample_SetMediaTime;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
296
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
297 This->all = allocator;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
298 This->size = _size;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
299 This->refcount = 0; // increased by MemAllocator
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
300 This->actual_size = 0;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
301 This->isPreroll = 0;
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
302 This->isDiscontinuity = 1;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
303 This->time_start = 0;
e3bbf44dbab2 avifile sync
arpi
parents: 3056
diff changeset
304 This->time_end = 0;
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
305 This->type_valid = 0;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
306 This->block = This->own_block;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
307
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
308 This->SetPointer = CMediaSample_SetPointer;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
309 This->ResetPointer = CMediaSample_ResetPointer;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
310
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
311 Debug printf("CMediaSample_Create(%p) called - sample size %d, buffer %p\n",
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
312 This, This->size, This->block);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
313
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2069
diff changeset
314 return This;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
315 }