32 #define HWND_MESSAGE ((HWND)-3)
52 switch(biCompression) {
53 case MKTAG(
'U',
'Y',
'V',
'Y'):
55 case MKTAG(
'Y',
'U',
'Y',
'2'):
57 case MKTAG(
'I',
'4',
'2',
'0'):
80 switch(biCompression) {
81 case MKTAG(
'd',
'v',
's',
'd'):
83 case MKTAG(
'M',
'J',
'P',
'G'):
84 case MKTAG(
'm',
'j',
'p',
'g'):
90 #define dstruct(pctx, sname, var, type) \
91 av_log(pctx, AV_LOG_DEBUG, #var":\t%"type"\n", sname->var)
96 dstruct(s, cparms, dwRequestMicroSecPerFrame,
"lu");
97 dstruct(s, cparms, fMakeUserHitOKToCapture,
"d");
98 dstruct(s, cparms, wPercentDropForError,
"u");
99 dstruct(s, cparms, fYield,
"d");
100 dstruct(s, cparms, dwIndexSize,
"lu");
101 dstruct(s, cparms, wChunkGranularity,
"u");
102 dstruct(s, cparms, fUsingDOSMemory,
"d");
103 dstruct(s, cparms, wNumVideoRequested,
"u");
104 dstruct(s, cparms, fCaptureAudio,
"d");
105 dstruct(s, cparms, wNumAudioRequested,
"u");
106 dstruct(s, cparms, vKeyAbort,
"u");
107 dstruct(s, cparms, fAbortLeftMouse,
"d");
108 dstruct(s, cparms, fAbortRightMouse,
"d");
109 dstruct(s, cparms, fLimitEnabled,
"d");
110 dstruct(s, cparms, wTimeLimit,
"u");
111 dstruct(s, cparms, fMCIControl,
"d");
112 dstruct(s, cparms, fStepMCIDevice,
"d");
113 dstruct(s, cparms, dwMCIStartTime,
"lu");
114 dstruct(s, cparms, dwMCIStopTime,
"lu");
115 dstruct(s, cparms, fStepCaptureAt2x,
"d");
116 dstruct(s, cparms, wStepCaptureAverageFrames,
"u");
117 dstruct(s, cparms, dwAudioBufferSize,
"lu");
118 dstruct(s, cparms, fDisableWriteCache,
"d");
119 dstruct(s, cparms, AVStreamMaster,
"u");
127 dstruct(s, vhdr, dwBufferLength,
"lu");
128 dstruct(s, vhdr, dwBytesUsed,
"lu");
129 dstruct(s, vhdr, dwTimeCaptured,
"lu");
130 dstruct(s, vhdr, dwUser,
"lu");
131 dstruct(s, vhdr, dwFlags,
"lu");
132 dstruct(s, vhdr, dwReserved[0],
"lu");
133 dstruct(s, vhdr, dwReserved[1],
"lu");
134 dstruct(s, vhdr, dwReserved[2],
"lu");
135 dstruct(s, vhdr, dwReserved[3],
"lu");
143 dstruct(s, bih, biWidth,
"ld");
144 dstruct(s, bih, biHeight,
"ld");
145 dstruct(s, bih, biPlanes,
"d");
146 dstruct(s, bih, biBitCount,
"d");
147 dstruct(s, bih, biCompression,
"lu");
149 (
char*) &bih->biCompression);
150 dstruct(s, bih, biSizeImage,
"lu");
151 dstruct(s, bih, biXPelsPerMeter,
"lu");
152 dstruct(s, bih, biYPelsPerMeter,
"lu");
153 dstruct(s, bih, biClrUsed,
"lu");
154 dstruct(s, bih, biClrImportant,
"lu");
160 const uint8_t dropscore[] = {62, 75, 87, 100};
164 if(dropscore[++ctx->
frame_num%ndropscores] <= buffer_fullness) {
166 "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
187 WaitForSingleObject(ctx->
mutex, INFINITE);
198 pktl_next->
pkt.
pts = vdhdr->dwTimeCaptured;
199 memcpy(pktl_next->
pkt.
data, vdhdr->lpData, vdhdr->dwBytesUsed);
201 for(ppktl = &ctx->
pktl ; *ppktl ; ppktl = &(*ppktl)->
next);
206 SetEvent(ctx->
event);
207 ReleaseMutex(ctx->
mutex);
211 ReleaseMutex(ctx->
mutex);
221 SendMessage(ctx->
hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
222 SendMessage(ctx->
hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);
223 DestroyWindow(ctx->
hwnd);
226 CloseHandle(ctx->
mutex);
228 CloseHandle(ctx->
event);
256 for (devnum = 0; devnum <= 9; devnum++) {
257 char driver_name[256];
258 char driver_ver[256];
259 ret = capGetDriverDescription(devnum,
260 driver_name,
sizeof(driver_name),
261 driver_ver,
sizeof(driver_ver));
280 ret = SendMessage(ctx->
hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
283 DestroyWindow(ctx->
hwnd);
287 SendMessage(ctx->
hwnd, WM_CAP_SET_OVERLAY, 0, 0);
288 SendMessage(ctx->
hwnd, WM_CAP_SET_PREVIEW, 0, 0);
290 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0,
297 SetWindowLongPtr(ctx->
hwnd, GWLP_USERDATA, (LONG_PTR) s);
306 bisize = SendMessage(ctx->
hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
314 ret = SendMessage(ctx->
hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
332 bi->bmiHeader.biWidth = 320;
333 bi->bmiHeader.biHeight = 240;
334 bi->bmiHeader.biPlanes = 1;
335 bi->bmiHeader.biBitCount = 12;
336 bi->bmiHeader.biCompression =
MKTAG(
'I',
'4',
'2',
'0');
337 bi->bmiHeader.biSizeImage = 115200;
341 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
347 biCompression = bi->bmiHeader.biCompression;
348 biBitCount = bi->bmiHeader.biBitCount;
353 ret = SendMessage(ctx->
hwnd, WM_CAP_GET_SEQUENCE_SETUP,
sizeof(cparms),
361 cparms.dwRequestMicroSecPerFrame =
362 (framerate_q.
den*1000000) / framerate_q.
num;
363 cparms.fAbortLeftMouse = 0;
364 cparms.fAbortRightMouse = 0;
365 cparms.fCaptureAudio = 0;
366 cparms.vKeyAbort = 0;
368 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_SEQUENCE_SETUP,
sizeof(cparms),
376 codec->
width = bi->bmiHeader.biWidth;
377 codec->
height = bi->bmiHeader.biHeight;
383 "Please report verbose (-v 9) debug information.\n");
390 if(biCompression ==
BI_RGB) {
413 ret = SendMessage(ctx->
hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
435 WaitForSingleObject(ctx->
mutex, INFINITE);
442 ResetEvent(ctx->
event);
443 ReleaseMutex(ctx->
mutex);
448 WaitForSingleObject(ctx->
event, INFINITE);
458 #define OFFSET(x) offsetof(struct vfw_ctx, x)
459 #define DEC AV_OPT_FLAG_DECODING_PARAM
476 .priv_data_size =
sizeof(
struct vfw_ctx),
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void av_free_packet(AVPacket *pkt)
Free a packet.
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
Parse str and put in width_ptr and height_ptr the detected values.
static enum AVPixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount)
unsigned int max_picture_buffer
Maximum amount of memory in bytes to use for buffering frames obtained from realtime capture devices...
static void dump_captureparms(AVFormatContext *s, CAPTUREPARMS *cparms)
static int vfw_read_close(AVFormatContext *s)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define FF_ARRAY_ELEMS(a)
static const AVClass vfw_class
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static void dump_videohdr(AVFormatContext *s, VIDEOHDR *vhdr)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
int flags
Flags modifying the (de)muxer behaviour.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
static void dump_bih(AVFormatContext *s, BITMAPINFOHEADER *bih)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_log(void *avcl, int level, const char *fmt,...)
AVCodecContext * codec
Codec context associated with this stream.
#define dstruct(pctx, sname, var, type)
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
char filename[1024]
input or output filename
int width
picture width / height.
static enum AVCodecID vfw_codecid(DWORD biCompression)
packed RGB 8:8:8, 24bpp, BGRBGR...
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
#define AV_LOG_INFO
Standard information.
enum AVMediaType codec_type
main external API structure.
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Describe the class of an AVClass context structure.
rational number numerator/denominator
static int vfw_read_header(AVFormatContext *s)
AVInputFormat ff_vfwcap_demuxer
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
struct AVPacketList * next
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
char * framerate
Set by a private option.
static const AVOption options[]
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
#define AV_PIX_FMT_RGB555
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt)
char * video_size
A string describing video size, set by a private option.
static int shall_we_drop(AVFormatContext *s)
void * priv_data
Format private data.
static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
#define MKTAG(a, b, c, d)
AVPixelFormat
Pixel format.
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...