Go to the documentation of this file.
39 #define HWND_MESSAGE ((HWND) -3)
56 switch(biCompression) {
57 case MKTAG(
'U',
'Y',
'V',
'Y'):
59 case MKTAG(
'Y',
'U',
'Y',
'2'):
61 case MKTAG(
'I',
'4',
'2',
'0'):
84 switch(biCompression) {
85 case MKTAG(
'd',
'v',
's',
'd'):
87 case MKTAG(
'M',
'J',
'P',
'G'):
88 case MKTAG(
'm',
'j',
'p',
'g'):
94 #define dstruct(pctx, sname, var, type) \
95 av_log(pctx, AV_LOG_DEBUG, #var":\t%"type"\n", sname->var)
100 dstruct(
s, cparms, dwRequestMicroSecPerFrame,
"lu");
101 dstruct(
s, cparms, fMakeUserHitOKToCapture,
"d");
102 dstruct(
s, cparms, wPercentDropForError,
"u");
104 dstruct(
s, cparms, dwIndexSize,
"lu");
105 dstruct(
s, cparms, wChunkGranularity,
"u");
106 dstruct(
s, cparms, fUsingDOSMemory,
"d");
107 dstruct(
s, cparms, wNumVideoRequested,
"u");
108 dstruct(
s, cparms, fCaptureAudio,
"d");
109 dstruct(
s, cparms, wNumAudioRequested,
"u");
111 dstruct(
s, cparms, fAbortLeftMouse,
"d");
112 dstruct(
s, cparms, fAbortRightMouse,
"d");
113 dstruct(
s, cparms, fLimitEnabled,
"d");
114 dstruct(
s, cparms, wTimeLimit,
"u");
115 dstruct(
s, cparms, fMCIControl,
"d");
116 dstruct(
s, cparms, fStepMCIDevice,
"d");
117 dstruct(
s, cparms, dwMCIStartTime,
"lu");
118 dstruct(
s, cparms, dwMCIStopTime,
"lu");
119 dstruct(
s, cparms, fStepCaptureAt2x,
"d");
120 dstruct(
s, cparms, wStepCaptureAverageFrames,
"u");
121 dstruct(
s, cparms, dwAudioBufferSize,
"lu");
122 dstruct(
s, cparms, fDisableWriteCache,
"d");
123 dstruct(
s, cparms, AVStreamMaster,
"u");
131 dstruct(
s, vhdr, dwBufferLength,
"lu");
132 dstruct(
s, vhdr, dwBytesUsed,
"lu");
133 dstruct(
s, vhdr, dwTimeCaptured,
"lu");
136 dstruct(
s, vhdr, dwReserved[0],
"lu");
137 dstruct(
s, vhdr, dwReserved[1],
"lu");
138 dstruct(
s, vhdr, dwReserved[2],
"lu");
139 dstruct(
s, vhdr, dwReserved[3],
"lu");
151 dstruct(
s, bih, biCompression,
"lu");
153 (
char*) &bih->biCompression);
155 dstruct(
s, bih, biXPelsPerMeter,
"lu");
156 dstruct(
s, bih, biYPelsPerMeter,
"lu");
158 dstruct(
s, bih, biClrImportant,
"lu");
164 static const uint8_t dropscore[4] = { 62, 75, 87, 100 };
166 unsigned int buffer_fullness = (
ctx->curbufsize*100)/
s->max_picture_buffer;
168 if(dropscore[++
ctx->frame_num%ndropscores] <= buffer_fullness) {
170 "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
202 pktl_next->
pkt.
pts = vdhdr->dwTimeCaptured;
203 memcpy(pktl_next->
pkt.
data, vdhdr->lpData, vdhdr->dwBytesUsed);
205 for(ppktl = &
ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->
next);
208 ctx->curbufsize += vdhdr->dwBytesUsed;
210 SetEvent(
ctx->event);
211 ReleaseMutex(
ctx->mutex);
215 ReleaseMutex(
ctx->mutex);
225 SendMessage(
ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
226 SendMessage(
ctx->hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);
227 DestroyWindow(
ctx->hwnd);
230 CloseHandle(
ctx->mutex);
232 CloseHandle(
ctx->event);
252 BITMAPINFO *bi =
NULL;
259 if (!strcmp(
s->url,
"list")) {
260 for (devnum = 0; devnum <= 9; devnum++) {
261 char driver_name[256];
262 char driver_ver[256];
263 ret = capGetDriverDescription(devnum,
264 driver_name,
sizeof(driver_name),
265 driver_ver,
sizeof(driver_ver));
282 devnum = atoi(
s->url);
284 ret = SendMessage(
ctx->hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
287 DestroyWindow(
ctx->hwnd);
291 SendMessage(
ctx->hwnd, WM_CAP_SET_OVERLAY, 0, 0);
292 SendMessage(
ctx->hwnd, WM_CAP_SET_PREVIEW, 0, 0);
294 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0,
301 SetWindowLongPtr(
ctx->hwnd, GWLP_USERDATA, (
LONG_PTR)
s);
310 bisize = SendMessage(
ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
318 ret = SendMessage(
ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
330 if (
ctx->video_size) {
337 bi->bmiHeader.biWidth =
w;
338 bi->bmiHeader.biHeight =
h;
344 bi->bmiHeader.biWidth = 320;
345 bi->bmiHeader.biHeight = 240;
346 bi->bmiHeader.biPlanes = 1;
347 bi->bmiHeader.biBitCount = 12;
348 bi->bmiHeader.biCompression =
MKTAG(
'I',
'4',
'2',
'0');
349 bi->bmiHeader.biSizeImage = 115200;
353 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
359 biCompression = bi->bmiHeader.biCompression;
360 biBitCount = bi->bmiHeader.biBitCount;
363 ret = SendMessage(
ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP,
sizeof(cparms),
371 cparms.dwRequestMicroSecPerFrame =
372 (framerate_q.
den*1000000) / framerate_q.
num;
373 cparms.fAbortLeftMouse = 0;
374 cparms.fAbortRightMouse = 0;
375 cparms.fCaptureAudio = 0;
376 cparms.vKeyAbort = 0;
378 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP,
sizeof(cparms),
387 par->
width = bi->bmiHeader.biWidth;
388 par->
height = bi->bmiHeader.biHeight;
400 if(biCompression == BI_RGB) {
425 ret = SendMessage(
ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
449 ctx->pktl =
ctx->pktl->next;
452 ResetEvent(
ctx->event);
453 ReleaseMutex(
ctx->mutex);
468 #define OFFSET(x) offsetof(struct vfw_ctx, x)
469 #define DEC AV_OPT_FLAG_DECODING_PARAM
487 .priv_data_size =
sizeof(
struct vfw_ctx),
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static void dump_captureparms(AVFormatContext *s, CAPTUREPARMS *cparms)
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
AVPixelFormat
Pixel format.
static enum AVPixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
enum AVMediaType codec_type
General type of the encoded data.
static void dump_videohdr(AVFormatContext *s, VIDEOHDR *vhdr)
This struct describes the properties of an encoded stream.
#define MKTAG(a, b, c, d)
struct AVPacketList * next
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt)
AVRational avg_frame_rate
Average framerate.
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
char * video_size
A string describing video size, set by a private option.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
static int vfw_read_close(AVFormatContext *s)
static void dump_bih(AVFormatContext *s, BITMAPINFOHEADER *bih)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
@ 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_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
static const AVOption options[]
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
static int vfw_read_header(AVFormatContext *s)
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT
AVCodecID
Identify the syntax and semantics of the bitstream.
int extradata_size
Size of the extradata content in bytes.
char * framerate
Set by a private option.
#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.
static enum AVCodecID vfw_codecid(DWORD biCompression)
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.
#define AV_LOG_INFO
Standard information.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
AVInputFormat ff_vfwcap_demuxer
#define AV_PIX_FMT_RGB555
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_INPUT_BUFFER_PADDING_SIZE
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
#define FF_ARRAY_ELEMS(a)
static int shall_we_drop(AVFormatContext *s)
#define dstruct(pctx, sname, var, type)
static const AVClass vfw_class
int bits_per_coded_sample
The number of bits per sample in the codedwords.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
#define WaitForSingleObject(a, b)