ReactOS 0.4.15-dev-7958-gcd0bb1a
acmstream.c File Reference
#include <assert.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#include "mmsystem.h"
#include "vfw.h"
#include "msacm.h"
#include "avifile_private.h"
#include "wine/debug.h"
Include dependency graph for acmstream.c:

Go to the source code of this file.

Classes

struct  _IAVIStreamImpl
 

Macros

#define CONVERT_STREAM_to_THIS(a)
 
#define CONVERT_THIS_to_STREAM(a)
 

Typedefs

typedef struct _IAVIStreamImpl IAVIStreamImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (avifile)
 
static HRESULT AVIFILE_OpenCompressor (IAVIStreamImpl *This)
 
static IAVIStreamImplimpl_from_IAVIStream (IAVIStream *iface)
 
static HRESULT WINAPI ACMStream_fnQueryInterface (IAVIStream *iface, REFIID refiid, LPVOID *obj)
 
static ULONG WINAPI ACMStream_fnAddRef (IAVIStream *iface)
 
static ULONG WINAPI ACMStream_fnRelease (IAVIStream *iface)
 
static HRESULT WINAPI ACMStream_fnCreate (IAVIStream *iface, LPARAM lParam1, LPARAM lParam2)
 
static HRESULT WINAPI ACMStream_fnInfo (IAVIStream *iface, LPAVISTREAMINFOW psi, LONG size)
 
static LONG WINAPI ACMStream_fnFindSample (IAVIStream *iface, LONG pos, LONG flags)
 
static HRESULT WINAPI ACMStream_fnReadFormat (IAVIStream *iface, LONG pos, LPVOID format, LONG *formatsize)
 
static HRESULT WINAPI ACMStream_fnSetFormat (IAVIStream *iface, LONG pos, LPVOID format, LONG formatsize)
 
static HRESULT WINAPI ACMStream_fnRead (IAVIStream *iface, LONG start, LONG samples, LPVOID buffer, LONG buffersize, LPLONG bytesread, LPLONG samplesread)
 
static HRESULT WINAPI ACMStream_fnWrite (IAVIStream *iface, LONG start, LONG samples, LPVOID buffer, LONG buffersize, DWORD flags, LPLONG sampwritten, LPLONG byteswritten)
 
static HRESULT WINAPI ACMStream_fnDelete (IAVIStream *iface, LONG start, LONG samples)
 
static HRESULT WINAPI ACMStream_fnReadData (IAVIStream *iface, DWORD fcc, LPVOID lp, LPLONG lpread)
 
static HRESULT WINAPI ACMStream_fnWriteData (IAVIStream *iface, DWORD fcc, LPVOID lp, LONG size)
 
static HRESULT WINAPI ACMStream_fnSetInfo (IAVIStream *iface, LPAVISTREAMINFOW info, LONG infolen)
 
HRESULT AVIFILE_CreateACMStream (REFIID riid, LPVOID *ppv)
 

Variables

static const struct IAVIStreamVtbl iacmst
 

Macro Definition Documentation

◆ CONVERT_STREAM_to_THIS

#define CONVERT_STREAM_to_THIS (   a)
Value:
do { \
DWORD __bytes; \
acmStreamSize(This->has,*(a) * This->lpInFormat->nBlockAlign,\
&__bytes, ACM_STREAMSIZEF_SOURCE); \
*(a) = __bytes / This->lpOutFormat->nBlockAlign; } while(0)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define ACM_STREAMSIZEF_SOURCE
Definition: msacm.h:217

Definition at line 61 of file acmstream.c.

◆ CONVERT_THIS_to_STREAM

#define CONVERT_THIS_to_STREAM (   a)
Value:
do { \
DWORD __bytes; \
acmStreamSize(This->has,*(a) * This->lpOutFormat->nBlockAlign,\
*(a) = __bytes / This->lpInFormat->nBlockAlign; } while(0)
#define ACM_STREAMSIZEF_DESTINATION
Definition: msacm.h:218

Definition at line 67 of file acmstream.c.

Typedef Documentation

◆ IAVIStreamImpl

Function Documentation

◆ ACMStream_fnAddRef()

static ULONG WINAPI ACMStream_fnAddRef ( IAVIStream iface)
static

Definition at line 155 of file acmstream.c.

156{
159
160 TRACE("(%p) -> %d\n", iface, ref);
161
162 /* also add reference to the nested stream */
163 if (This->pStream != NULL)
164 IAVIStream_AddRef(This->pStream);
165
166 return ref;
167}
static IAVIStreamImpl * impl_from_IAVIStream(IAVIStream *iface)
Definition: acmstream.c:132
#define InterlockedIncrement
Definition: armddk.h:53
#define NULL
Definition: types.h:112
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59
#define IAVIStream_AddRef(p)
Definition: vfw.h:1176

◆ ACMStream_fnCreate()

static HRESULT WINAPI ACMStream_fnCreate ( IAVIStream iface,
LPARAM  lParam1,
LPARAM  lParam2 
)
static

Definition at line 217 of file acmstream.c.

219{
221
222 TRACE("(%p,0x%08lX,0x%08lX)\n", iface, lParam1, lParam2);
223
224 /* check for swapped parameters */
225 if ((LPVOID)lParam1 != NULL &&
226 ((LPAVICOMPRESSOPTIONS)lParam1)->fccType == streamtypeAUDIO) {
227 LPARAM tmp = lParam1;
228
229 lParam1 = lParam2;
230 lParam2 = tmp;
231 }
232
233 if ((LPVOID)lParam1 == NULL)
234 return AVIERR_BADPARAM;
235
236 IAVIStream_Info((PAVISTREAM)lParam1, &This->sInfo, sizeof(This->sInfo));
237 if (This->sInfo.fccType != streamtypeAUDIO)
238 return AVIERR_ERROR; /* error in registry or AVIMakeCompressedStream */
239
240 This->sInfo.fccHandler = 0; /* be paranoid */
241
242 /* FIXME: check ACM version? Which version does we need? */
243
244 if ((LPVOID)lParam2 != NULL) {
245 /* We only need the format from the compress-options */
246 if (((LPAVICOMPRESSOPTIONS)lParam2)->fccType == streamtypeAUDIO)
247 lParam2 = (LPARAM)((LPAVICOMPRESSOPTIONS)lParam2)->lpFormat;
248
249 if (((LPWAVEFORMATEX)lParam2)->wFormatTag != WAVE_FORMAT_PCM)
250 This->cbOutFormat = sizeof(WAVEFORMATEX) + ((LPWAVEFORMATEX)lParam2)->cbSize;
251 else
252 This->cbOutFormat = sizeof(PCMWAVEFORMAT);
253
254 This->lpOutFormat = HeapAlloc(GetProcessHeap(), 0, This->cbOutFormat);
255 if (This->lpOutFormat == NULL)
256 return AVIERR_MEMORY;
257
258 memcpy(This->lpOutFormat, (LPVOID)lParam2, This->cbOutFormat);
259 } else {
260 This->lpOutFormat = NULL;
261 This->cbOutFormat = 0;
262 }
263
264 This->pStream = (PAVISTREAM)lParam1;
265 IAVIStream_AddRef(This->pStream);
266
267 return AVIERR_OK;
268}
#define streamtypeAUDIO
Definition: aviriff.h:93
#define WAVE_FORMAT_PCM
Definition: constants.h:425
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _WAVEFORMATEX * LPWAVEFORMATEX
struct pcmwaveformat_tag PCMWAVEFORMAT
LPCWSTR lpFormat
Definition: trayclock.cpp:32
#define AVIERR_ERROR
Definition: vfw.h:1761
#define AVIERR_OK
Definition: vfw.h:1740
struct IAVIStream * PAVISTREAM
Definition: vfw.h:38
#define AVIERR_MEMORY
Definition: vfw.h:1745
#define IAVIStream_Info(p, a, b)
Definition: vfw.h:1180
#define AVIERR_BADPARAM
Definition: vfw.h:1748
LONG_PTR LPARAM
Definition: windef.h:208

◆ ACMStream_fnDelete()

static HRESULT WINAPI ACMStream_fnDelete ( IAVIStream iface,
LONG  start,
LONG  samples 
)
static

Definition at line 621 of file acmstream.c.

623{
625
626 TRACE("(%p,%d,%d)\n", iface, start, samples);
627
628 /* check parameters */
629 if (start < 0 || samples < 0)
630 return AVIERR_BADPARAM;
631
632 /* Delete before start of stream? */
633 if ((DWORD)(start + samples) < This->sInfo.dwStart)
634 return AVIERR_OK;
635
636 /* Delete after end of stream? */
637 if ((DWORD)start > This->sInfo.dwLength)
638 return AVIERR_OK;
639
640 /* For the rest we need write capability */
641 if ((This->sInfo.dwCaps & AVIFILECAPS_CANWRITE) == 0)
642 return AVIERR_READONLY;
643
644 /* A compressor is also necessary */
645 if (This->has == NULL)
646 return AVIERR_NOCOMPRESSOR;
647
648 /* map our positions to pStream positions */
651
652 return IAVIStream_Delete(This->pStream, start, samples);
653}
#define CONVERT_THIS_to_STREAM(a)
Definition: acmstream.c:67
GLuint start
Definition: gl.h:1545
GLsizei samples
Definition: glext.h:7006
#define AVIERR_NOCOMPRESSOR
Definition: vfw.h:1755
#define IAVIStream_Delete(p, a, b)
Definition: vfw.h:1186
#define AVIFILECAPS_CANWRITE
Definition: vfw.h:1061
#define AVIERR_READONLY
Definition: vfw.h:1756

◆ ACMStream_fnFindSample()

static LONG WINAPI ACMStream_fnFindSample ( IAVIStream iface,
LONG  pos,
LONG  flags 
)
static

Definition at line 297 of file acmstream.c.

299{
301
302 TRACE("(%p,%d,0x%08X)\n",iface,pos,flags);
303
304 if (flags & FIND_FROM_START) {
305 pos = This->sInfo.dwStart;
307 flags |= FIND_NEXT;
308 }
309
310 /* convert pos from our 'space' to This->pStream's one */
312
313 /* ask stream */
314 pos = IAVIStream_FindSample(This->pStream, pos, flags);
315
316 if (pos != -1) {
317 /* convert pos back to our 'space' if it's no size or physical pos */
318 if ((flags & FIND_RET) == 0)
320 }
321
322 return pos;
323}
#define CONVERT_STREAM_to_THIS(a)
Definition: acmstream.c:61
GLbitfield flags
Definition: glext.h:7161
#define FIND_NEXT
Definition: vfw.h:1118
#define FIND_PREV
Definition: vfw.h:1119
#define FIND_FROM_START
Definition: vfw.h:1120
#define FIND_RET
Definition: vfw.h:1127
#define IAVIStream_FindSample(p, a, b)
Definition: vfw.h:1181

◆ ACMStream_fnInfo()

static HRESULT WINAPI ACMStream_fnInfo ( IAVIStream iface,
LPAVISTREAMINFOW  psi,
LONG  size 
)
static

Definition at line 270 of file acmstream.c.

272{
274
275 TRACE("(%p,%p,%d)\n", iface, psi, size);
276
277 if (psi == NULL)
278 return AVIERR_BADPARAM;
279 if (size < 0)
280 return AVIERR_BADSIZE;
281
282 /* Need codec to correct some values in structure */
283 if (This->has == NULL) {
285
286 if (FAILED(hr))
287 return hr;
288 }
289
290 memcpy(psi, &This->sInfo, min(size, (LONG)sizeof(This->sInfo)));
291
292 if (size < (LONG)sizeof(This->sInfo))
294 return AVIERR_OK;
295}
static HRESULT AVIFILE_OpenCompressor(IAVIStreamImpl *This)
Definition: acmstream.c:73
GLsizeiptr size
Definition: glext.h:5919
#define FAILED(hr)
Definition: intsafe.h:51
#define min(a, b)
Definition: monoChain.cc:55
long LONG
Definition: pedump.c:60
HRESULT hr
Definition: shlfolder.c:183
#define AVIERR_BADSIZE
Definition: vfw.h:1749
#define AVIERR_BUFFERTOOSMALL
Definition: vfw.h:1758

◆ ACMStream_fnQueryInterface()

static HRESULT WINAPI ACMStream_fnQueryInterface ( IAVIStream iface,
REFIID  refiid,
LPVOID obj 
)
static

Definition at line 137 of file acmstream.c.

139{
141
142 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(refiid), obj);
143
144 if (IsEqualGUID(&IID_IUnknown, refiid) ||
145 IsEqualGUID(&IID_IAVIStream, refiid)) {
146 *obj = &This->IAVIStream_iface;
147 IAVIStream_AddRef(iface);
148
149 return S_OK;
150 }
151
152 return OLE_E_ENUM_NOMORE;
153}
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define OLE_E_ENUM_NOMORE
Definition: winerror.h:2616

◆ ACMStream_fnRead()

static HRESULT WINAPI ACMStream_fnRead ( IAVIStream iface,
LONG  start,
LONG  samples,
LPVOID  buffer,
LONG  buffersize,
LPLONG  bytesread,
LPLONG  samplesread 
)
static

Definition at line 405 of file acmstream.c.

409{
411
412 HRESULT hr;
413 DWORD size;
414
415 TRACE("(%p,%d,%d,%p,%d,%p,%p)\n", iface, start, samples, buffer,
416 buffersize, bytesread, samplesread);
417
418 /* clear return parameters if given */
419 if (bytesread != NULL)
420 *bytesread = 0;
421 if (samplesread != NULL)
422 *samplesread = 0;
423
424 /* Do we have our compressor? */
425 if (This->has == NULL) {
427
428 if (FAILED(hr))
429 return hr;
430 }
431
432 /* only need to pass through? */
433 if (This->cbInFormat == This->cbOutFormat &&
434 memcmp(This->lpInFormat, This->lpOutFormat, This->cbInFormat) == 0) {
435 return IAVIStream_Read(This->pStream, start, samples, buffer, buffersize,
436 bytesread, samplesread);
437 }
438
439 /* read as much as fit? */
440 if (samples == -1)
441 samples = buffersize / This->lpOutFormat->nBlockAlign;
442 /* limit to buffersize */
443 if (samples * This->lpOutFormat->nBlockAlign > buffersize)
444 samples = buffersize / This->lpOutFormat->nBlockAlign;
445
446 /* only return needed size? */
447 if (buffer == NULL || buffersize <= 0 || samples == 0) {
448 if (bytesread == NULL && samplesread == NULL)
449 return AVIERR_BADPARAM;
450
451 if (bytesread != NULL)
452 *bytesread = samples * This->lpOutFormat->nBlockAlign;
453 if (samplesread != NULL)
454 *samplesread = samples;
455
456 return AVIERR_OK;
457 }
458
459 /* map our positions to pStream positions */
461
462 /* our needed internal buffersize */
463 size = samples * This->lpInFormat->nBlockAlign;
464
465 /* Need to free destination buffer used for writing? */
466 if (This->acmStreamHdr.pbDst != NULL) {
467 HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbDst);
468 This->acmStreamHdr.pbDst = NULL;
469 This->acmStreamHdr.dwDstUser = 0;
470 }
471
472 /* need bigger source buffer? */
473 if (This->acmStreamHdr.pbSrc == NULL ||
474 This->acmStreamHdr.dwSrcUser < size) {
475 if (This->acmStreamHdr.pbSrc == NULL)
476 This->acmStreamHdr.pbSrc = HeapAlloc(GetProcessHeap(), 0, size);
477 else
478 This->acmStreamHdr.pbSrc = HeapReAlloc(GetProcessHeap(), 0, This->acmStreamHdr.pbSrc, size);
479 if (This->acmStreamHdr.pbSrc == NULL)
480 return AVIERR_MEMORY;
481 This->acmStreamHdr.dwSrcUser = size;
482 }
483
484 This->acmStreamHdr.cbStruct = sizeof(This->acmStreamHdr);
485 This->acmStreamHdr.cbSrcLengthUsed = 0;
486 This->acmStreamHdr.cbDstLengthUsed = 0;
487 This->acmStreamHdr.cbSrcLength = size;
488
489 /* read source data */
490 hr = IAVIStream_Read(This->pStream, start, -1, This->acmStreamHdr.pbSrc,
491 This->acmStreamHdr.cbSrcLength,
492 (LONG *)&This->acmStreamHdr.cbSrcLength, NULL);
493 if (FAILED(hr) || This->acmStreamHdr.cbSrcLength == 0)
494 return hr;
495
496 /* need to prepare stream? */
497 This->acmStreamHdr.pbDst = buffer;
498 This->acmStreamHdr.cbDstLength = buffersize;
499 if ((This->acmStreamHdr.fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED) == 0) {
500 if (acmStreamPrepareHeader(This->has, &This->acmStreamHdr, 0) != S_OK) {
501 This->acmStreamHdr.pbDst = NULL;
502 This->acmStreamHdr.cbDstLength = 0;
503 return AVIERR_COMPRESSOR;
504 }
505 }
506
507 /* now do the conversion */
508 /* FIXME: use ACM_CONVERTF_* flags */
509 if (acmStreamConvert(This->has, &This->acmStreamHdr, 0) != S_OK)
511
512 This->acmStreamHdr.pbDst = NULL;
513 This->acmStreamHdr.cbDstLength = 0;
514
515 /* fill out return parameters if given */
516 if (bytesread != NULL)
517 *bytesread = This->acmStreamHdr.cbDstLengthUsed;
518 if (samplesread != NULL)
519 *samplesread =
520 This->acmStreamHdr.cbDstLengthUsed / This->lpOutFormat->nBlockAlign;
521
522 return hr;
523}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define HeapReAlloc
Definition: compat.h:734
#define HeapFree(x, y, z)
Definition: compat.h:735
MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwPrepare)
Definition: stream.c:299
MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwConvert)
Definition: stream.c:89
GLuint buffer
Definition: glext.h:5915
#define ACMSTREAMHEADER_STATUSF_PREPARED
Definition: msacm.h:210
#define IAVIStream_Read(p, a, b, c, d, e, f)
Definition: vfw.h:1184
#define AVIERR_COMPRESSOR
Definition: vfw.h:1754

◆ ACMStream_fnReadData()

static HRESULT WINAPI ACMStream_fnReadData ( IAVIStream iface,
DWORD  fcc,
LPVOID  lp,
LPLONG  lpread 
)
static

Definition at line 655 of file acmstream.c.

657{
659
660 TRACE("(%p,0x%08X,%p,%p)\n", iface, fcc, lp, lpread);
661
662 assert(This->pStream != NULL);
663
664 return IAVIStream_ReadData(This->pStream, fcc, lp, lpread);
665}
#define assert(x)
Definition: debug.h:53
#define IAVIStream_ReadData(p, a, b, c)
Definition: vfw.h:1187

◆ ACMStream_fnReadFormat()

static HRESULT WINAPI ACMStream_fnReadFormat ( IAVIStream iface,
LONG  pos,
LPVOID  format,
LONG formatsize 
)
static

Definition at line 325 of file acmstream.c.

327{
329
330 TRACE("(%p,%d,%p,%p)\n", iface, pos, format, formatsize);
331
332 if (formatsize == NULL)
333 return AVIERR_BADPARAM;
334
335 if (This->has == NULL) {
337
338 if (FAILED(hr))
339 return hr;
340 }
341
342 /* only interested in needed buffersize? */
343 if (format == NULL || *formatsize <= 0) {
344 *formatsize = This->cbOutFormat;
345
346 return AVIERR_OK;
347 }
348
349 /* copy initial format (only as much as will fit) */
350 memcpy(format, This->lpOutFormat, min(*formatsize, This->cbOutFormat));
351 if (*formatsize < This->cbOutFormat) {
352 *formatsize = This->cbOutFormat;
354 }
355
356 *formatsize = This->cbOutFormat;
357 return AVIERR_OK;
358}
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546

◆ ACMStream_fnRelease()

static ULONG WINAPI ACMStream_fnRelease ( IAVIStream iface)
static

Definition at line 169 of file acmstream.c.

170{
173
174 TRACE("(%p) -> %d\n", iface, ref);
175
176 if (ref == 0) {
177 /* destruct */
178 if (This->has != NULL) {
179 if (This->acmStreamHdr.fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED)
180 acmStreamUnprepareHeader(This->has, &This->acmStreamHdr, 0);
181 acmStreamClose(This->has, 0);
182 This->has = NULL;
183 }
184 HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbSrc);
185 This->acmStreamHdr.pbSrc = NULL;
186 HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbDst);
187 This->acmStreamHdr.pbDst = NULL;
188 if (This->lpInFormat != NULL) {
189 HeapFree(GetProcessHeap(), 0, This->lpInFormat);
190 This->lpInFormat = NULL;
191 This->cbInFormat = 0;
192 }
193 if (This->lpOutFormat != NULL) {
194 HeapFree(GetProcessHeap(), 0, This->lpOutFormat);
195 This->lpOutFormat = NULL;
196 This->cbOutFormat = 0;
197 }
198 if (This->pStream != NULL) {
199 IAVIStream_Release(This->pStream);
200 This->pStream = NULL;
201 }
203
204 return 0;
205 }
206
207 /* also release reference to the nested stream */
208 if (This->pStream != NULL)
209 IAVIStream_Release(This->pStream);
210
211 return ref;
212}
#define InterlockedDecrement
Definition: armddk.h:52
MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
Definition: stream.c:65
MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwUnprepare)
Definition: stream.c:449
#define IAVIStream_Release(p)
Definition: vfw.h:1177

◆ ACMStream_fnSetFormat()

static HRESULT WINAPI ACMStream_fnSetFormat ( IAVIStream iface,
LONG  pos,
LPVOID  format,
LONG  formatsize 
)
static

Definition at line 360 of file acmstream.c.

362{
364
365 HRESULT hr;
366
367 TRACE("(%p,%d,%p,%d)\n", iface, pos, format, formatsize);
368
369 /* check parameters */
370 if (format == NULL || formatsize <= 0)
371 return AVIERR_BADPARAM;
372
373 /* Input format already known?
374 * Changing is unsupported, but be quiet if it's the same */
375 if (This->lpInFormat != NULL) {
376 if (This->cbInFormat != formatsize ||
377 memcmp(format, This->lpInFormat, formatsize) != 0)
378 return AVIERR_UNSUPPORTED;
379
380 return AVIERR_OK;
381 }
382
383 /* Does the nested stream support writing? */
384 if ((This->sInfo.dwCaps & AVIFILECAPS_CANWRITE) == 0)
385 return AVIERR_READONLY;
386
387 This->lpInFormat = HeapAlloc(GetProcessHeap(), 0, formatsize);
388 if (This->lpInFormat == NULL)
389 return AVIERR_MEMORY;
390 This->cbInFormat = formatsize;
391 memcpy(This->lpInFormat, format, formatsize);
392
393 /* initialize formats and get compressor */
395 if (FAILED(hr))
396 return hr;
397
399
400 /* tell the nested stream the new format */
401 return IAVIStream_SetFormat(This->pStream, pos, This->lpOutFormat,
402 This->cbOutFormat);
403}
#define IAVIStream_SetFormat(p, a, b, c)
Definition: vfw.h:1183
#define AVIERR_UNSUPPORTED
Definition: vfw.h:1743

◆ ACMStream_fnSetInfo()

static HRESULT WINAPI ACMStream_fnSetInfo ( IAVIStream iface,
LPAVISTREAMINFOW  info,
LONG  infolen 
)
static

Definition at line 679 of file acmstream.c.

681{
682 FIXME("(%p,%p,%d): stub\n", iface, info, infolen);
683
684 return E_FAIL;
685}
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_FAIL
Definition: ddrawi.h:102

◆ ACMStream_fnWrite()

static HRESULT WINAPI ACMStream_fnWrite ( IAVIStream iface,
LONG  start,
LONG  samples,
LPVOID  buffer,
LONG  buffersize,
DWORD  flags,
LPLONG  sampwritten,
LPLONG  byteswritten 
)
static

Definition at line 525 of file acmstream.c.

530{
532
533 HRESULT hr;
534 ULONG size;
535
536 TRACE("(%p,%d,%d,%p,%d,0x%08X,%p,%p)\n", iface, start, samples,
537 buffer, buffersize, flags, sampwritten, byteswritten);
538
539 /* clear return parameters if given */
540 if (sampwritten != NULL)
541 *sampwritten = 0;
542 if (byteswritten != NULL)
543 *byteswritten = 0;
544
545 /* check parameters */
546 if (buffer == NULL && (buffersize > 0 || samples > 0))
547 return AVIERR_BADPARAM;
548
549 /* Have we write capability? */
550 if ((This->sInfo.dwCaps & AVIFILECAPS_CANWRITE) == 0)
551 return AVIERR_READONLY;
552
553 /* also need a compressor */
554 if (This->has == NULL)
555 return AVIERR_NOCOMPRESSOR;
556
557 /* map our sizes to pStream sizes */
558 size = buffersize;
561
562 /* no bytes to write? -- short circuit */
563 if (size == 0) {
564 return IAVIStream_Write(This->pStream, -1, samples, buffer, size,
565 flags, sampwritten, byteswritten);
566 }
567
568 /* Need to free source buffer used for reading? */
569 if (This->acmStreamHdr.pbSrc != NULL) {
570 HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbSrc);
571 This->acmStreamHdr.pbSrc = NULL;
572 This->acmStreamHdr.dwSrcUser = 0;
573 }
574
575 /* Need bigger destination buffer? */
576 if (This->acmStreamHdr.pbDst == NULL ||
577 This->acmStreamHdr.dwDstUser < size) {
578 if (This->acmStreamHdr.pbDst == NULL)
579 This->acmStreamHdr.pbDst = HeapAlloc(GetProcessHeap(), 0, size);
580 else
581 This->acmStreamHdr.pbDst = HeapReAlloc(GetProcessHeap(), 0, This->acmStreamHdr.pbDst, size);
582 if (This->acmStreamHdr.pbDst == NULL)
583 return AVIERR_MEMORY;
584 This->acmStreamHdr.dwDstUser = size;
585 }
586 This->acmStreamHdr.cbStruct = sizeof(This->acmStreamHdr);
587 This->acmStreamHdr.cbSrcLengthUsed = 0;
588 This->acmStreamHdr.cbDstLengthUsed = 0;
589 This->acmStreamHdr.cbDstLength = This->acmStreamHdr.dwDstUser;
590
591 /* need to prepare stream? */
592 This->acmStreamHdr.pbSrc = buffer;
593 This->acmStreamHdr.cbSrcLength = buffersize;
594 if ((This->acmStreamHdr.fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED) == 0) {
595 if (acmStreamPrepareHeader(This->has, &This->acmStreamHdr, 0) != S_OK) {
596 This->acmStreamHdr.pbSrc = NULL;
597 This->acmStreamHdr.cbSrcLength = 0;
598 return AVIERR_COMPRESSOR;
599 }
600 }
601
602 /* now do the conversion */
603 /* FIXME: use ACM_CONVERTF_* flags */
604 if (acmStreamConvert(This->has, &This->acmStreamHdr, 0) != S_OK)
606 else
607 hr = AVIERR_OK;
608
609 This->acmStreamHdr.pbSrc = NULL;
610 This->acmStreamHdr.cbSrcLength = 0;
611
612 if (FAILED(hr))
613 return hr;
614
615 return IAVIStream_Write(This->pStream,-1,This->acmStreamHdr.cbDstLengthUsed /
616 This->lpOutFormat->nBlockAlign,This->acmStreamHdr.pbDst,
617 This->acmStreamHdr.cbDstLengthUsed,flags,sampwritten,
618 byteswritten);
619}
#define IAVIStream_Write(p, a, b, c, d, e, f, g)
Definition: vfw.h:1185

◆ ACMStream_fnWriteData()

static HRESULT WINAPI ACMStream_fnWriteData ( IAVIStream iface,
DWORD  fcc,
LPVOID  lp,
LONG  size 
)
static

Definition at line 667 of file acmstream.c.

669{
671
672 TRACE("(%p,0x%08x,%p,%d)\n", iface, fcc, lp, size);
673
674 assert(This->pStream != NULL);
675
676 return IAVIStream_WriteData(This->pStream, fcc, lp, size);
677}
#define IAVIStream_WriteData(p, a, b, c)
Definition: vfw.h:1188

◆ AVIFILE_CreateACMStream()

HRESULT AVIFILE_CreateACMStream ( REFIID  riid,
LPVOID ppv 
)

Definition at line 704 of file acmstream.c.

705{
706 IAVIStreamImpl *pstream;
707 HRESULT hr;
708
709 assert(riid != NULL && ppv != NULL);
710
711 *ppv = NULL;
712
714 if (pstream == NULL)
715 return AVIERR_MEMORY;
716
717 pstream->IAVIStream_iface.lpVtbl = &iacmst;
718
720 if (FAILED(hr))
721 HeapFree(GetProcessHeap(), 0, pstream);
722
723 return hr;
724}
static const struct IAVIStreamVtbl iacmst
Definition: acmstream.c:687
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
IAVIStream IAVIStream_iface
Definition: acmstream.c:41
#define IAVIStream_QueryInterface(p, a, b)
Definition: vfw.h:1175

Referenced by IClassFactory_fnCreateInstance().

◆ AVIFILE_OpenCompressor()

static HRESULT AVIFILE_OpenCompressor ( IAVIStreamImpl This)
static

Definition at line 73 of file acmstream.c.

74{
75 HRESULT hr;
76
77 /* pre-conditions */
78 assert(This != NULL);
79 assert(This->pStream != NULL);
80
81 if (This->has != NULL)
82 return AVIERR_OK;
83
84 if (This->lpInFormat == NULL) {
85 /* decode or encode the data from pStream */
86 hr = AVIStreamFormatSize(This->pStream, This->sInfo.dwStart, &This->cbInFormat);
87 if (FAILED(hr))
88 return hr;
89 This->lpInFormat = HeapAlloc(GetProcessHeap(), 0, This->cbInFormat);
90 if (This->lpInFormat == NULL)
91 return AVIERR_MEMORY;
92
93 hr = IAVIStream_ReadFormat(This->pStream, This->sInfo.dwStart,
94 This->lpInFormat, &This->cbInFormat);
95 if (FAILED(hr))
96 return hr;
97
98 if (This->lpOutFormat == NULL) {
99 /* we must decode to default format */
100 This->cbOutFormat = sizeof(PCMWAVEFORMAT);
101 This->lpOutFormat = HeapAlloc(GetProcessHeap(), 0, This->cbOutFormat);
102 if (This->lpOutFormat == NULL)
103 return AVIERR_MEMORY;
104
105 This->lpOutFormat->wFormatTag = WAVE_FORMAT_PCM;
106 if (acmFormatSuggest(NULL, This->lpInFormat, This->lpOutFormat,
107 This->cbOutFormat, ACM_FORMATSUGGESTF_WFORMATTAG) != S_OK)
108 return AVIERR_NOCOMPRESSOR;
109 }
110 } else if (This->lpOutFormat == NULL)
111 return AVIERR_ERROR; /* To what should I encode? */
112
113 if (acmStreamOpen(&This->has, NULL, This->lpInFormat, This->lpOutFormat,
115 return AVIERR_NOCOMPRESSOR;
116
117 /* update AVISTREAMINFO structure */
118 This->sInfo.dwSampleSize = This->lpOutFormat->nBlockAlign;
119 This->sInfo.dwScale = This->lpOutFormat->nBlockAlign;
120 This->sInfo.dwRate = This->lpOutFormat->nAvgBytesPerSec;
121 This->sInfo.dwQuality = (DWORD)ICQUALITY_DEFAULT;
122 SetRectEmpty(&This->sInfo.rcFrame);
123
124 /* convert positions and sizes to output format */
125 CONVERT_STREAM_to_THIS(&This->sInfo.dwStart);
126 CONVERT_STREAM_to_THIS(&This->sInfo.dwLength);
127 CONVERT_STREAM_to_THIS(&This->sInfo.dwSuggestedBufferSize);
128
129 return AVIERR_OK;
130}
MMRESULT WINAPI acmFormatSuggest(HACMDRIVER had, PWAVEFORMATEX pwfxSrc, PWAVEFORMATEX pwfxDst, DWORD cbwfxDst, DWORD fdwSuggest)
Definition: format.c:746
MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc, PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen)
Definition: stream.c:149
#define ACM_STREAMOPENF_NONREALTIME
Definition: msacm.h:215
#define ACM_FORMATSUGGESTF_WFORMATTAG
Definition: msacm.h:174
#define DWORD
Definition: nt_native.h:44
#define ICQUALITY_DEFAULT
Definition: vfw.h:278
#define IAVIStream_ReadFormat(p, a, b, c)
Definition: vfw.h:1182
#define AVIStreamFormatSize(pavi, lPos, plSize)
Definition: vfw.h:1436
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)

Referenced by ACMStream_fnInfo(), ACMStream_fnRead(), ACMStream_fnReadFormat(), and ACMStream_fnSetFormat().

◆ impl_from_IAVIStream()

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( avifile  )

Variable Documentation

◆ iacmst

const struct IAVIStreamVtbl iacmst
static
Initial value:
= {
}
static HRESULT WINAPI ACMStream_fnSetFormat(IAVIStream *iface, LONG pos, LPVOID format, LONG formatsize)
Definition: acmstream.c:360
static HRESULT WINAPI ACMStream_fnCreate(IAVIStream *iface, LPARAM lParam1, LPARAM lParam2)
Definition: acmstream.c:217
static HRESULT WINAPI ACMStream_fnWrite(IAVIStream *iface, LONG start, LONG samples, LPVOID buffer, LONG buffersize, DWORD flags, LPLONG sampwritten, LPLONG byteswritten)
Definition: acmstream.c:525
static HRESULT WINAPI ACMStream_fnReadFormat(IAVIStream *iface, LONG pos, LPVOID format, LONG *formatsize)
Definition: acmstream.c:325
static HRESULT WINAPI ACMStream_fnInfo(IAVIStream *iface, LPAVISTREAMINFOW psi, LONG size)
Definition: acmstream.c:270
static HRESULT WINAPI ACMStream_fnReadData(IAVIStream *iface, DWORD fcc, LPVOID lp, LPLONG lpread)
Definition: acmstream.c:655
static LONG WINAPI ACMStream_fnFindSample(IAVIStream *iface, LONG pos, LONG flags)
Definition: acmstream.c:297
static HRESULT WINAPI ACMStream_fnWriteData(IAVIStream *iface, DWORD fcc, LPVOID lp, LONG size)
Definition: acmstream.c:667
static HRESULT WINAPI ACMStream_fnQueryInterface(IAVIStream *iface, REFIID refiid, LPVOID *obj)
Definition: acmstream.c:137
static ULONG WINAPI ACMStream_fnRelease(IAVIStream *iface)
Definition: acmstream.c:169
static ULONG WINAPI ACMStream_fnAddRef(IAVIStream *iface)
Definition: acmstream.c:155
static HRESULT WINAPI ACMStream_fnRead(IAVIStream *iface, LONG start, LONG samples, LPVOID buffer, LONG buffersize, LPLONG bytesread, LPLONG samplesread)
Definition: acmstream.c:405
static HRESULT WINAPI ACMStream_fnSetInfo(IAVIStream *iface, LPAVISTREAMINFOW info, LONG infolen)
Definition: acmstream.c:679
static HRESULT WINAPI ACMStream_fnDelete(IAVIStream *iface, LONG start, LONG samples)
Definition: acmstream.c:621

Definition at line 687 of file acmstream.c.

Referenced by AVIFILE_CreateACMStream().