42#define HWND_MESSAGE ((HWND) -3)
59 switch(biCompression) {
60 case MKTAG(
'U',
'Y',
'V',
'Y'):
62 case MKTAG(
'Y',
'U',
'Y',
'2'):
64 case MKTAG(
'I',
'4',
'2',
'0'):
87 switch(biCompression) {
88 case MKTAG(
'd',
'v',
's',
'd'):
90 case MKTAG(
'M',
'J',
'P',
'G'):
91 case MKTAG(
'm',
'j',
'p',
'g'):
97#define dstruct(pctx, sname, var, type) \
98 av_log(pctx, AV_LOG_DEBUG, #var":\t%"type"\n", sname->var)
103 dstruct(
s, cparms, dwRequestMicroSecPerFrame,
"lu");
104 dstruct(
s, cparms, fMakeUserHitOKToCapture,
"d");
105 dstruct(
s, cparms, wPercentDropForError,
"u");
107 dstruct(
s, cparms, dwIndexSize,
"lu");
108 dstruct(
s, cparms, wChunkGranularity,
"u");
109 dstruct(
s, cparms, fUsingDOSMemory,
"d");
110 dstruct(
s, cparms, wNumVideoRequested,
"u");
111 dstruct(
s, cparms, fCaptureAudio,
"d");
112 dstruct(
s, cparms, wNumAudioRequested,
"u");
114 dstruct(
s, cparms, fAbortLeftMouse,
"d");
115 dstruct(
s, cparms, fAbortRightMouse,
"d");
116 dstruct(
s, cparms, fLimitEnabled,
"d");
117 dstruct(
s, cparms, wTimeLimit,
"u");
118 dstruct(
s, cparms, fMCIControl,
"d");
119 dstruct(
s, cparms, fStepMCIDevice,
"d");
120 dstruct(
s, cparms, dwMCIStartTime,
"lu");
121 dstruct(
s, cparms, dwMCIStopTime,
"lu");
122 dstruct(
s, cparms, fStepCaptureAt2x,
"d");
123 dstruct(
s, cparms, wStepCaptureAverageFrames,
"u");
124 dstruct(
s, cparms, dwAudioBufferSize,
"lu");
125 dstruct(
s, cparms, fDisableWriteCache,
"d");
126 dstruct(
s, cparms, AVStreamMaster,
"u");
134 dstruct(
s, vhdr, dwBufferLength,
"lu");
135 dstruct(
s, vhdr, dwBytesUsed,
"lu");
136 dstruct(
s, vhdr, dwTimeCaptured,
"lu");
139 dstruct(
s, vhdr, dwReserved[0],
"lu");
140 dstruct(
s, vhdr, dwReserved[1],
"lu");
141 dstruct(
s, vhdr, dwReserved[2],
"lu");
142 dstruct(
s, vhdr, dwReserved[3],
"lu");
154 dstruct(
s, bih, biCompression,
"lu");
156 (
char*) &bih->biCompression);
158 dstruct(
s, bih, biXPelsPerMeter,
"lu");
159 dstruct(
s, bih, biYPelsPerMeter,
"lu");
161 dstruct(
s, bih, biClrImportant,
"lu");
167 static const uint8_t dropscore[4] = { 62, 75, 87, 100 };
169 unsigned int buffer_fullness = (
ctx->curbufsize*100)/
s->max_picture_buffer;
171 if(dropscore[++
ctx->frame_num%ndropscores] <= buffer_fullness) {
173 "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
205 pktl_next->
pkt.
pts = vdhdr->dwTimeCaptured;
206 memcpy(pktl_next->
pkt.
data, vdhdr->lpData, vdhdr->dwBytesUsed);
208 for(ppktl = &
ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->
next);
211 ctx->curbufsize += vdhdr->dwBytesUsed;
213 SetEvent(
ctx->event);
214 ReleaseMutex(
ctx->mutex);
218 ReleaseMutex(
ctx->mutex);
228 SendMessage(
ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
229 SendMessage(
ctx->hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);
230 DestroyWindow(
ctx->hwnd);
233 CloseHandle(
ctx->mutex);
235 CloseHandle(
ctx->event);
255 BITMAPINFO *bi =
NULL;
262 if (!strcmp(
s->url,
"list")) {
263 for (devnum = 0; devnum <= 9; devnum++) {
264 char driver_name[256];
265 char driver_ver[256];
266 ret = capGetDriverDescription(devnum,
267 driver_name,
sizeof(driver_name),
268 driver_ver,
sizeof(driver_ver));
285 devnum = atoi(
s->url);
287 ret = SendMessage(
ctx->hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
290 DestroyWindow(
ctx->hwnd);
294 SendMessage(
ctx->hwnd, WM_CAP_SET_OVERLAY, 0, 0);
295 SendMessage(
ctx->hwnd, WM_CAP_SET_PREVIEW, 0, 0);
297 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0,
304 SetWindowLongPtr(
ctx->hwnd, GWLP_USERDATA, (LONG_PTR)
s);
313 bisize = SendMessage(
ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
321 ret = SendMessage(
ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
333 if (
ctx->video_size) {
340 bi->bmiHeader.biWidth =
w;
341 bi->bmiHeader.biHeight =
h;
347 bi->bmiHeader.biWidth = 320;
348 bi->bmiHeader.biHeight = 240;
349 bi->bmiHeader.biPlanes = 1;
350 bi->bmiHeader.biBitCount = 12;
351 bi->bmiHeader.biCompression =
MKTAG(
'I',
'4',
'2',
'0');
352 bi->bmiHeader.biSizeImage = 115200;
356 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
362 biCompression = bi->bmiHeader.biCompression;
363 biBitCount = bi->bmiHeader.biBitCount;
366 ret = SendMessage(
ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP,
sizeof(cparms),
374 cparms.dwRequestMicroSecPerFrame =
375 (framerate_q.
den*1000000) / framerate_q.
num;
376 cparms.fAbortLeftMouse = 0;
377 cparms.fAbortRightMouse = 0;
378 cparms.fCaptureAudio = 0;
379 cparms.vKeyAbort = 0;
381 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP,
sizeof(cparms),
390 par->
width = bi->bmiHeader.biWidth;
391 par->
height = bi->bmiHeader.biHeight;
403 if(biCompression == BI_RGB) {
428 ret = SendMessage(
ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
452 ctx->pktl =
ctx->pktl->next;
455 ResetEvent(
ctx->event);
456 ReleaseMutex(
ctx->mutex);
466 ctx->curbufsize -=
pkt->size;
471#define OFFSET(x) offsetof(struct vfw_ctx, x)
472#define DEC AV_OPT_FLAG_DECODING_PARAM
480 .class_name =
"VFW indev",
492 .priv_data_size =
sizeof(
struct vfw_ctx),
const FFInputFormat ff_vfwcap_demuxer
static AVFormatContext * ctx
Main libavdevice API header.
static int read_header(FFV1Context *f, RangeCoder *c)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT
#define MKTAG(a, b, c, d)
Memory handling functions.
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.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)3R 3G 2B(lsb)
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_RGB4
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
#define AV_PIX_FMT_RGB555
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
This struct describes the properties of an encoded stream.
int extradata_size
Size of the extradata content in bytes.
int height
The height of the video frame in pixels.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
int width
The width of the video frame in pixels.
enum AVMediaType codec_type
General type of the encoded data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational avg_frame_rate
Average framerate.
struct PacketListEntry * next
char * video_size
A string describing video size, set by a private option.
char * framerate
Set by a private option.
static void dump_videohdr(AVFormatContext *s, VIDEOHDR *vhdr)
static int vfw_read_close(AVFormatContext *s)
#define dstruct(pctx, sname, var, type)
static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt)
static enum AVPixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount)
static void dump_bih(AVFormatContext *s, BITMAPINFOHEADER *bih)
static int vfw_read_header(AVFormatContext *s)
static void dump_captureparms(AVFormatContext *s, CAPTUREPARMS *cparms)
static int shall_we_drop(AVFormatContext *s)
static enum AVCodecID vfw_codecid(DWORD biCompression)
static const AVClass vfw_class
#define WaitForSingleObject(a, b)