ReactOS 0.4.17-dev-806-gffa4164
extrachunk.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "mmsystem.h"
Include dependency graph for extrachunk.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _EXTRACHUNKS
 

Typedefs

typedef struct _EXTRACHUNKS EXTRACHUNKS
 
typedef struct _EXTRACHUNKSLPEXTRACHUNKS
 

Functions

HRESULT ReadExtraChunk (const EXTRACHUNKS *extra, FOURCC ckid, LPVOID lp, LPLONG size)
 
HRESULT WriteExtraChunk (LPEXTRACHUNKS extra, FOURCC ckid, LPCVOID lp, LONG size)
 
HRESULT ReadChunkIntoExtra (LPEXTRACHUNKS extra, HMMIO hmmio, const MMCKINFO *lpck)
 
HRESULT FindChunkAndKeepExtras (LPEXTRACHUNKS extra, HMMIO hmmio, MMCKINFO *lpck, MMCKINFO *lpckParent, UINT flags)
 

Typedef Documentation

◆ EXTRACHUNKS

◆ LPEXTRACHUNKS

Function Documentation

◆ FindChunkAndKeepExtras()

HRESULT FindChunkAndKeepExtras ( LPEXTRACHUNKS  extra,
HMMIO  hmmio,
MMCKINFO lpck,
MMCKINFO lpckParent,
UINT  flags 
)

Definition at line 135 of file extrachunk.c.

137{
138 FOURCC ckid;
139 FOURCC fccType;
140 MMRESULT mmr;
141
142 /* pre-conditions */
143 assert(extra != NULL);
144 assert(hmmio != NULL);
145 assert(lpck != NULL);
146
147 TRACE("({%p,%lu},%p,%p,%p,0x%X)\n", extra->lp, extra->cb, hmmio, lpck,
148 lpckParent, flags);
149
150 /* what chunk id and form/list type should we search? */
151 if (flags & MMIO_FINDCHUNK) {
152 ckid = lpck->ckid;
153 fccType = 0;
154 } else if (flags & MMIO_FINDLIST) {
155 ckid = FOURCC_LIST;
156 fccType = lpck->fccType;
157 } else if (flags & MMIO_FINDRIFF) {
158 ckid = FOURCC_RIFF;
159 fccType = lpck->fccType;
160 } else
161 ckid = fccType = (FOURCC)-1; /* collect everything into extra! */
162
163 TRACE(": find ckid=0x%08lX fccType=0x%08lX\n", ckid, fccType);
164
165 for (;;) {
166 mmr = mmioDescend(hmmio, lpck, lpckParent, 0);
167 if (mmr != MMSYSERR_NOERROR) {
168 /* No extra chunks in front of desired chunk? */
169 if (flags == 0 && mmr == MMIOERR_CHUNKNOTFOUND)
170 return AVIERR_OK;
171 else
172 return AVIERR_FILEREAD;
173 }
174
175 /* Have we found what we search for? */
176 if ((lpck->ckid == ckid) &&
177 (fccType == 0 || lpck->fccType == fccType))
178 return AVIERR_OK;
179
180 /* Skip padding chunks, the others put into the extrachunk-structure */
181 if (lpck->ckid == ckidAVIPADDING ||
182 lpck->ckid == mmioFOURCC('p','a','d','d'))
183 {
184 mmr = mmioAscend(hmmio, lpck, 0);
185 if (mmr != MMSYSERR_NOERROR) return AVIERR_FILEREAD;
186 }
187 else
188 {
189 HRESULT hr = ReadChunkIntoExtra(extra, hmmio, lpck);
190 if (FAILED(hr))
191 return hr;
192 }
193 }
194}
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define assert(_expr)
Definition: assert.h:32
MMRESULT WINAPI mmioAscend(HMMIO hmmio, LPMMCKINFO lpck, UINT uFlags)
Definition: mmio.c:1205
MMRESULT WINAPI mmioDescend(HMMIO hmmio, LPMMCKINFO lpck, const MMCKINFO *lpckParent, UINT uFlags)
Definition: mmio.c:1107
DWORD FOURCC
Definition: dmdls.h:25
HRESULT ReadChunkIntoExtra(LPEXTRACHUNKS extra, HMMIO hmmio, const MMCKINFO *lpck)
Definition: extrachunk.c:98
GLbitfield flags
Definition: glext.h:7161
@ extra
Definition: id3.c:95
#define FAILED(hr)
Definition: intsafe.h:51
#define FOURCC(a, b, c, d)
Definition: memtrack.h:4
#define MMIO_FINDRIFF
Definition: mmsystem.h:552
#define FOURCC_RIFF
Definition: mmsystem.h:564
#define MMIOERR_CHUNKNOTFOUND
Definition: mmsystem.h:517
UINT MMRESULT
Definition: mmsystem.h:964
#define MMIO_FINDCHUNK
Definition: mmsystem.h:551
#define FOURCC_LIST
Definition: mmsystem.h:565
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define mmioFOURCC(c0, c1, c2, c3)
Definition: mmsystem.h:38
#define MMIO_FINDLIST
Definition: mmsystem.h:553
#define TRACE(s)
Definition: solgame.cpp:4
FOURCC ckid
Definition: mmsystem.h:1509
FOURCC fccType
Definition: mmsystem.h:1511
#define AVIERR_FILEREAD
Definition: vfw.h:1751
#define ckidAVIPADDING
Definition: vfw.h:916
#define AVIERR_OK
Definition: vfw.h:1740

Referenced by AVIFILE_LoadFile().

◆ ReadChunkIntoExtra()

HRESULT ReadChunkIntoExtra ( LPEXTRACHUNKS  extra,
HMMIO  hmmio,
const MMCKINFO lpck 
)

Definition at line 98 of file extrachunk.c.

99{
100 LPDWORD lp;
101 DWORD cb;
102
103 /* pre-conditions */
104 assert(extra != NULL);
105 assert(hmmio != NULL);
106 assert(lpck != NULL);
107
108 cb = lpck->cksize + 2 * sizeof(DWORD);
109 cb += (cb & 1);
110
111 lp = _recalloc(extra->lp, 1, extra->cb + cb);
112 if (lp == NULL)
113 return AVIERR_MEMORY;
114
115 extra->lp = lp;
116 lp = (LPDWORD) ((LPBYTE)lp + extra->cb);
117 extra->cb += cb;
118
119 /* insert chunk-header in block */
120 lp[0] = lpck->ckid;
121 lp[1] = lpck->cksize;
122
123 if (lpck->cksize > 0) {
124 if (mmioSeek(hmmio, lpck->dwDataOffset, SEEK_SET) == -1)
125 return AVIERR_FILEREAD;
126 if (mmioRead(hmmio, (HPSTR)&lp[2], lpck->cksize) != (LONG)lpck->cksize)
127 return AVIERR_FILEREAD;
128 }
129
130 return AVIERR_OK;
131}
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
_ACRTIMP void *__cdecl _recalloc(void *, size_t, size_t) __WINE_ALLOC_SIZE(2
LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
Definition: mmio.c:836
LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
Definition: mmio.c:733
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SEEK_SET
Definition: jmemansi.c:26
char * HPSTR
Definition: mmsystem.h:1479
#define LPDWORD
Definition: nt_native.h:46
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
DWORD cksize
Definition: mmsystem.h:1510
DWORD dwDataOffset
Definition: mmsystem.h:1512
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t * LPDWORD
Definition: typedefs.h:59
#define AVIERR_MEMORY
Definition: vfw.h:1745

Referenced by AVIFILE_LoadFile(), and FindChunkAndKeepExtras().

◆ ReadExtraChunk()

HRESULT ReadExtraChunk ( const EXTRACHUNKS extra,
FOURCC  ckid,
LPVOID  lp,
LPLONG  size 
)

Definition at line 32 of file extrachunk.c.

33{
34 LPBYTE lp;
35 DWORD cb;
36
37 /* pre-conditions */
38 assert(extra != NULL);
39 assert(size != NULL);
40
41 lp = extra->lp;
42 cb = extra->cb;
43
44 if (lp != NULL) {
45 while (cb > 0) {
46 if (((FOURCC*)lp)[0] == ckid) {
47 /* found correct chunk */
48 if (lpData != NULL && *size > 0)
49 memcpy(lpData, lp + 2 * sizeof(DWORD),
50 min(((LPDWORD)lp)[1], *(LPDWORD)size));
51
52 *(LPDWORD)size = ((LPDWORD)lp)[1];
53
54 return AVIERR_OK;
55 } else {
56 /* skip to next chunk */
57 cb -= ((LPDWORD)lp)[1] + 2 * sizeof(DWORD);
58 lp += ((LPDWORD)lp)[1] + 2 * sizeof(DWORD);
59 }
60 }
61 }
62
63 /* wanted chunk doesn't exist */
64 *size = 0;
65
66 return AVIERR_NODATA;
67}
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
#define AVIERR_NODATA
Definition: vfw.h:1757

Referenced by IAVIFile_fnReadData(), and IAVIStream_fnReadData().

◆ WriteExtraChunk()

HRESULT WriteExtraChunk ( LPEXTRACHUNKS  extra,
FOURCC  ckid,
LPCVOID  lp,
LONG  size 
)

Definition at line 70 of file extrachunk.c.

71{
72 LPDWORD lp;
73
74 /* pre-conditions */
75 assert(extra != NULL);
76 assert(lpData != NULL);
77 assert(size > 0);
78
79 lp = _recalloc(extra->lp, 1, extra->cb + size + 2 * sizeof(DWORD));
80 if (lp == NULL)
81 return AVIERR_MEMORY;
82
83 extra->lp = lp;
84 lp = (LPDWORD) ((LPBYTE)lp + extra->cb);
85 extra->cb += size + 2 * sizeof(DWORD);
86
87 /* insert chunk-header in block */
88 lp[0] = ckid;
89 lp[1] = size;
90
91 if (lpData != NULL && size > 0)
92 memcpy(lp + 2, lpData, size);
93
94 return AVIERR_OK;
95}

Referenced by IAVIFile_fnWriteData(), and IAVIStream_fnWriteData().