41 #define HWND_MESSAGE ((HWND) -3)
58 switch(biCompression) {
59 case MKTAG(
'U',
'Y',
'V',
'Y'):
61 case MKTAG(
'Y',
'U',
'Y',
'2'):
63 case MKTAG(
'I',
'4',
'2',
'0'):
86 switch(biCompression) {
87 case MKTAG(
'd',
'v',
's',
'd'):
89 case MKTAG(
'M',
'J',
'P',
'G'):
90 case MKTAG(
'm',
'j',
'p',
'g'):
96 #define dstruct(pctx, sname, var, type) \
97 av_log(pctx, AV_LOG_DEBUG, #var":\t%"type"\n", sname->var)
102 dstruct(
s, cparms, dwRequestMicroSecPerFrame,
"lu");
103 dstruct(
s, cparms, fMakeUserHitOKToCapture,
"d");
104 dstruct(
s, cparms, wPercentDropForError,
"u");
106 dstruct(
s, cparms, dwIndexSize,
"lu");
107 dstruct(
s, cparms, wChunkGranularity,
"u");
108 dstruct(
s, cparms, fUsingDOSMemory,
"d");
109 dstruct(
s, cparms, wNumVideoRequested,
"u");
110 dstruct(
s, cparms, fCaptureAudio,
"d");
111 dstruct(
s, cparms, wNumAudioRequested,
"u");
113 dstruct(
s, cparms, fAbortLeftMouse,
"d");
114 dstruct(
s, cparms, fAbortRightMouse,
"d");
115 dstruct(
s, cparms, fLimitEnabled,
"d");
116 dstruct(
s, cparms, wTimeLimit,
"u");
117 dstruct(
s, cparms, fMCIControl,
"d");
118 dstruct(
s, cparms, fStepMCIDevice,
"d");
119 dstruct(
s, cparms, dwMCIStartTime,
"lu");
120 dstruct(
s, cparms, dwMCIStopTime,
"lu");
121 dstruct(
s, cparms, fStepCaptureAt2x,
"d");
122 dstruct(
s, cparms, wStepCaptureAverageFrames,
"u");
123 dstruct(
s, cparms, dwAudioBufferSize,
"lu");
124 dstruct(
s, cparms, fDisableWriteCache,
"d");
125 dstruct(
s, cparms, AVStreamMaster,
"u");
133 dstruct(
s, vhdr, dwBufferLength,
"lu");
134 dstruct(
s, vhdr, dwBytesUsed,
"lu");
135 dstruct(
s, vhdr, dwTimeCaptured,
"lu");
138 dstruct(
s, vhdr, dwReserved[0],
"lu");
139 dstruct(
s, vhdr, dwReserved[1],
"lu");
140 dstruct(
s, vhdr, dwReserved[2],
"lu");
141 dstruct(
s, vhdr, dwReserved[3],
"lu");
153 dstruct(
s, bih, biCompression,
"lu");
155 (
char*) &bih->biCompression);
157 dstruct(
s, bih, biXPelsPerMeter,
"lu");
158 dstruct(
s, bih, biYPelsPerMeter,
"lu");
160 dstruct(
s, bih, biClrImportant,
"lu");
166 static const uint8_t dropscore[4] = { 62, 75, 87, 100 };
168 unsigned int buffer_fullness = (
ctx->curbufsize*100)/
s->max_picture_buffer;
170 if(dropscore[++
ctx->frame_num%ndropscores] <= buffer_fullness) {
172 "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
204 pktl_next->
pkt.
pts = vdhdr->dwTimeCaptured;
205 memcpy(pktl_next->
pkt.
data, vdhdr->lpData, vdhdr->dwBytesUsed);
207 for(ppktl = &
ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->
next);
210 ctx->curbufsize += vdhdr->dwBytesUsed;
212 SetEvent(
ctx->event);
213 ReleaseMutex(
ctx->mutex);
217 ReleaseMutex(
ctx->mutex);
227 SendMessage(
ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
228 SendMessage(
ctx->hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);
229 DestroyWindow(
ctx->hwnd);
232 CloseHandle(
ctx->mutex);
234 CloseHandle(
ctx->event);
254 BITMAPINFO *bi =
NULL;
261 if (!strcmp(
s->url,
"list")) {
262 for (devnum = 0; devnum <= 9; devnum++) {
263 char driver_name[256];
264 char driver_ver[256];
265 ret = capGetDriverDescription(devnum,
266 driver_name,
sizeof(driver_name),
267 driver_ver,
sizeof(driver_ver));
284 devnum = atoi(
s->url);
286 ret = SendMessage(
ctx->hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
289 DestroyWindow(
ctx->hwnd);
293 SendMessage(
ctx->hwnd, WM_CAP_SET_OVERLAY, 0, 0);
294 SendMessage(
ctx->hwnd, WM_CAP_SET_PREVIEW, 0, 0);
296 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0,
303 SetWindowLongPtr(
ctx->hwnd, GWLP_USERDATA, (LONG_PTR)
s);
312 bisize = SendMessage(
ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
320 ret = SendMessage(
ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
332 if (
ctx->video_size) {
339 bi->bmiHeader.biWidth =
w;
340 bi->bmiHeader.biHeight =
h;
346 bi->bmiHeader.biWidth = 320;
347 bi->bmiHeader.biHeight = 240;
348 bi->bmiHeader.biPlanes = 1;
349 bi->bmiHeader.biBitCount = 12;
350 bi->bmiHeader.biCompression =
MKTAG(
'I',
'4',
'2',
'0');
351 bi->bmiHeader.biSizeImage = 115200;
355 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
361 biCompression = bi->bmiHeader.biCompression;
362 biBitCount = bi->bmiHeader.biBitCount;
365 ret = SendMessage(
ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP,
sizeof(cparms),
373 cparms.dwRequestMicroSecPerFrame =
374 (framerate_q.
den*1000000) / framerate_q.
num;
375 cparms.fAbortLeftMouse = 0;
376 cparms.fAbortRightMouse = 0;
377 cparms.fCaptureAudio = 0;
378 cparms.vKeyAbort = 0;
380 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP,
sizeof(cparms),
389 par->
width = bi->bmiHeader.biWidth;
390 par->
height = bi->bmiHeader.biHeight;
402 if(biCompression == BI_RGB) {
427 ret = SendMessage(
ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
451 ctx->pktl =
ctx->pktl->next;
454 ResetEvent(
ctx->event);
455 ReleaseMutex(
ctx->mutex);
470 #define OFFSET(x) offsetof(struct vfw_ctx, x)
471 #define DEC AV_OPT_FLAG_DECODING_PARAM
491 .priv_data_size =
sizeof(
struct vfw_ctx),