FFmpeg
vfwcap.c
Go to the documentation of this file.
1 /*
2  * VFW capture interface
3  * Copyright (c) 2006-2008 Ramiro Polla
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/internal.h"
23 #include "libavutil/log.h"
24 #include "libavutil/opt.h"
25 #include "libavutil/parseutils.h"
26 
28 #include "libavformat/demux.h"
29 #include "libavformat/internal.h"
30 
31 // windows.h must no be included before winsock2.h, and libavformat internal
32 // headers may include winsock2.h
33 #include <windows.h>
34 // windows.h needs to be included before vfw.h
35 #include <vfw.h>
36 
37 #include "avdevice.h"
38 
39 /* Some obsolete versions of MinGW32 before 4.0.0 lack this. */
40 #ifndef HWND_MESSAGE
41 #define HWND_MESSAGE ((HWND) -3)
42 #endif
43 
44 struct vfw_ctx {
45  const AVClass *class;
46  HWND hwnd;
47  HANDLE mutex;
48  HANDLE event;
50  unsigned int curbufsize;
51  unsigned int frame_num;
52  char *video_size; /**< A string describing video size, set by a private option. */
53  char *framerate; /**< Set by a private option. */
54 };
55 
56 static enum AVPixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount)
57 {
58  switch(biCompression) {
59  case MKTAG('U', 'Y', 'V', 'Y'):
60  return AV_PIX_FMT_UYVY422;
61  case MKTAG('Y', 'U', 'Y', '2'):
62  return AV_PIX_FMT_YUYV422;
63  case MKTAG('I', '4', '2', '0'):
64  return AV_PIX_FMT_YUV420P;
65  case BI_RGB:
66  switch(biBitCount) { /* 1-8 are untested */
67  case 1:
68  return AV_PIX_FMT_MONOWHITE;
69  case 4:
70  return AV_PIX_FMT_RGB4;
71  case 8:
72  return AV_PIX_FMT_RGB8;
73  case 16:
74  return AV_PIX_FMT_RGB555;
75  case 24:
76  return AV_PIX_FMT_BGR24;
77  case 32:
78  return AV_PIX_FMT_RGB32;
79  }
80  }
81  return AV_PIX_FMT_NONE;
82 }
83 
84 static enum AVCodecID vfw_codecid(DWORD biCompression)
85 {
86  switch(biCompression) {
87  case MKTAG('d', 'v', 's', 'd'):
88  return AV_CODEC_ID_DVVIDEO;
89  case MKTAG('M', 'J', 'P', 'G'):
90  case MKTAG('m', 'j', 'p', 'g'):
91  return AV_CODEC_ID_MJPEG;
92  }
93  return AV_CODEC_ID_NONE;
94 }
95 
96 #define dstruct(pctx, sname, var, type) \
97  av_log(pctx, AV_LOG_DEBUG, #var":\t%"type"\n", sname->var)
98 
99 static void dump_captureparms(AVFormatContext *s, CAPTUREPARMS *cparms)
100 {
101  av_log(s, AV_LOG_DEBUG, "CAPTUREPARMS\n");
102  dstruct(s, cparms, dwRequestMicroSecPerFrame, "lu");
103  dstruct(s, cparms, fMakeUserHitOKToCapture, "d");
104  dstruct(s, cparms, wPercentDropForError, "u");
105  dstruct(s, cparms, fYield, "d");
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");
112  dstruct(s, cparms, vKeyAbort, "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");
126 }
127 
128 static void dump_videohdr(AVFormatContext *s, VIDEOHDR *vhdr)
129 {
130 #ifdef DEBUG
131  av_log(s, AV_LOG_DEBUG, "VIDEOHDR\n");
132  dstruct(s, vhdr, lpData, "p");
133  dstruct(s, vhdr, dwBufferLength, "lu");
134  dstruct(s, vhdr, dwBytesUsed, "lu");
135  dstruct(s, vhdr, dwTimeCaptured, "lu");
136  dstruct(s, vhdr, dwUser, "lu");
137  dstruct(s, vhdr, dwFlags, "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");
142 #endif
143 }
144 
145 static void dump_bih(AVFormatContext *s, BITMAPINFOHEADER *bih)
146 {
147  av_log(s, AV_LOG_DEBUG, "BITMAPINFOHEADER\n");
148  dstruct(s, bih, biSize, "lu");
149  dstruct(s, bih, biWidth, "ld");
150  dstruct(s, bih, biHeight, "ld");
151  dstruct(s, bih, biPlanes, "d");
152  dstruct(s, bih, biBitCount, "d");
153  dstruct(s, bih, biCompression, "lu");
154  av_log(s, AV_LOG_DEBUG, " biCompression:\t\"%.4s\"\n",
155  (char*) &bih->biCompression);
156  dstruct(s, bih, biSizeImage, "lu");
157  dstruct(s, bih, biXPelsPerMeter, "lu");
158  dstruct(s, bih, biYPelsPerMeter, "lu");
159  dstruct(s, bih, biClrUsed, "lu");
160  dstruct(s, bih, biClrImportant, "lu");
161 }
162 
164 {
165  struct vfw_ctx *ctx = s->priv_data;
166  static const uint8_t dropscore[4] = { 62, 75, 87, 100 };
167  const int ndropscores = FF_ARRAY_ELEMS(dropscore);
168  unsigned int buffer_fullness = (ctx->curbufsize*100)/s->max_picture_buffer;
169 
170  if(dropscore[++ctx->frame_num%ndropscores] <= buffer_fullness) {
172  "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
173  return 1;
174  }
175 
176  return 0;
177 }
178 
179 static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
180 {
182  struct vfw_ctx *ctx;
183  PacketListEntry **ppktl, *pktl_next;
184 
185  s = (AVFormatContext *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
186  ctx = s->priv_data;
187 
188  dump_videohdr(s, vdhdr);
189 
190  if(shall_we_drop(s))
191  return FALSE;
192 
193  WaitForSingleObject(ctx->mutex, INFINITE);
194 
195  pktl_next = av_mallocz(sizeof(*pktl_next));
196  if(!pktl_next)
197  goto fail;
198 
199  if(av_new_packet(&pktl_next->pkt, vdhdr->dwBytesUsed) < 0) {
200  av_free(pktl_next);
201  goto fail;
202  }
203 
204  pktl_next->pkt.pts = vdhdr->dwTimeCaptured;
205  memcpy(pktl_next->pkt.data, vdhdr->lpData, vdhdr->dwBytesUsed);
206 
207  for(ppktl = &ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->next);
208  *ppktl = pktl_next;
209 
210  ctx->curbufsize += vdhdr->dwBytesUsed;
211 
212  SetEvent(ctx->event);
213  ReleaseMutex(ctx->mutex);
214 
215  return TRUE;
216 fail:
217  ReleaseMutex(ctx->mutex);
218  return FALSE;
219 }
220 
222 {
223  struct vfw_ctx *ctx = s->priv_data;
225 
226  if(ctx->hwnd) {
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);
230  }
231  if(ctx->mutex)
232  CloseHandle(ctx->mutex);
233  if(ctx->event)
234  CloseHandle(ctx->event);
235 
236  pktl = ctx->pktl;
237  while (pktl) {
238  PacketListEntry *next = pktl->next;
240  av_free(pktl);
241  pktl = next;
242  }
243 
244  return 0;
245 }
246 
248 {
249  struct vfw_ctx *ctx = s->priv_data;
250  AVCodecParameters *par;
251  AVStream *st;
252  int devnum;
253  int bisize;
254  BITMAPINFO *bi = NULL;
255  CAPTUREPARMS cparms;
256  DWORD biCompression;
257  WORD biBitCount;
258  int ret;
259  AVRational framerate_q;
260 
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));
268  if (ret) {
269  av_log(s, AV_LOG_INFO, "Driver %d\n", devnum);
270  av_log(s, AV_LOG_INFO, " %s\n", driver_name);
271  av_log(s, AV_LOG_INFO, " %s\n", driver_ver);
272  }
273  }
274  return AVERROR(EIO);
275  }
276 
277  ctx->hwnd = capCreateCaptureWindow(NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0);
278  if(!ctx->hwnd) {
279  av_log(s, AV_LOG_ERROR, "Could not create capture window.\n");
280  return AVERROR(EIO);
281  }
282 
283  /* If atoi fails, devnum==0 and the default device is used */
284  devnum = atoi(s->url);
285 
286  ret = SendMessage(ctx->hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
287  if(!ret) {
288  av_log(s, AV_LOG_ERROR, "Could not connect to device.\n");
289  DestroyWindow(ctx->hwnd);
290  return AVERROR(ENODEV);
291  }
292 
293  SendMessage(ctx->hwnd, WM_CAP_SET_OVERLAY, 0, 0);
294  SendMessage(ctx->hwnd, WM_CAP_SET_PREVIEW, 0, 0);
295 
296  ret = SendMessage(ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0,
297  (LPARAM) videostream_cb);
298  if(!ret) {
299  av_log(s, AV_LOG_ERROR, "Could not set video stream callback.\n");
300  goto fail;
301  }
302 
303  SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) s);
304 
305  st = avformat_new_stream(s, NULL);
306  if(!st) {
307  vfw_read_close(s);
308  return AVERROR(ENOMEM);
309  }
310 
311  /* Set video format */
312  bisize = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
313  if(!bisize)
314  goto fail;
315  bi = av_malloc(bisize);
316  if(!bi) {
317  vfw_read_close(s);
318  return AVERROR(ENOMEM);
319  }
320  ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
321  if(!ret)
322  goto fail;
323 
324  dump_bih(s, &bi->bmiHeader);
325 
326  ret = av_parse_video_rate(&framerate_q, ctx->framerate);
327  if (ret < 0) {
328  av_log(s, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", ctx->framerate);
329  goto fail;
330  }
331 
332  if (ctx->video_size) {
333  int w, h;
334  ret = av_parse_video_size(&w, &h, ctx->video_size);
335  if (ret < 0) {
336  av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n");
337  goto fail;
338  }
339  bi->bmiHeader.biWidth = w;
340  bi->bmiHeader.biHeight = h;
341  }
342 
343  if (0) {
344  /* For testing yet unsupported compressions
345  * Copy these values from user-supplied verbose information */
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;
352  dump_bih(s, &bi->bmiHeader);
353  }
354 
355  ret = SendMessage(ctx->hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
356  if(!ret) {
357  av_log(s, AV_LOG_ERROR, "Could not set Video Format.\n");
358  goto fail;
359  }
360 
361  biCompression = bi->bmiHeader.biCompression;
362  biBitCount = bi->bmiHeader.biBitCount;
363 
364  /* Set sequence setup */
365  ret = SendMessage(ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP, sizeof(cparms),
366  (LPARAM) &cparms);
367  if(!ret)
368  goto fail;
369 
370  dump_captureparms(s, &cparms);
371 
372  cparms.fYield = 1; // Spawn a background thread
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;
379 
380  ret = SendMessage(ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP, sizeof(cparms),
381  (LPARAM) &cparms);
382  if(!ret)
383  goto fail;
384 
385  st->avg_frame_rate = framerate_q;
386 
387  par = st->codecpar;
389  par->width = bi->bmiHeader.biWidth;
390  par->height = bi->bmiHeader.biHeight;
391  par->format = vfw_pixfmt(biCompression, biBitCount);
392  if (par->format == AV_PIX_FMT_NONE) {
393  par->codec_id = vfw_codecid(biCompression);
394  if (par->codec_id == AV_CODEC_ID_NONE) {
395  avpriv_report_missing_feature(s, "This compression type");
396  vfw_read_close(s);
397  return AVERROR_PATCHWELCOME;
398  }
399  par->bits_per_coded_sample = biBitCount;
400  } else {
402  if(biCompression == BI_RGB) {
403  par->bits_per_coded_sample = biBitCount;
405  if (par->extradata) {
406  par->extradata_size = 9;
407  memcpy(par->extradata, "BottomUp", 9);
408  }
409  }
410  }
411 
412  av_freep(&bi);
413 
414  avpriv_set_pts_info(st, 32, 1, 1000);
415 
416  ctx->mutex = CreateMutex(NULL, 0, NULL);
417  if(!ctx->mutex) {
418  av_log(s, AV_LOG_ERROR, "Could not create Mutex.\n" );
419  goto fail;
420  }
421  ctx->event = CreateEvent(NULL, 1, 0, NULL);
422  if(!ctx->event) {
423  av_log(s, AV_LOG_ERROR, "Could not create Event.\n" );
424  goto fail;
425  }
426 
427  ret = SendMessage(ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
428  if(!ret) {
429  av_log(s, AV_LOG_ERROR, "Could not start capture sequence.\n" );
430  goto fail;
431  }
432 
433  return 0;
434 
435 fail:
436  av_freep(&bi);
437  vfw_read_close(s);
438  return AVERROR(EIO);
439 }
440 
442 {
443  struct vfw_ctx *ctx = s->priv_data;
445 
446  while(!pktl) {
447  WaitForSingleObject(ctx->mutex, INFINITE);
448  pktl = ctx->pktl;
449  if(ctx->pktl) {
450  *pkt = ctx->pktl->pkt;
451  ctx->pktl = ctx->pktl->next;
452  av_free(pktl);
453  }
454  ResetEvent(ctx->event);
455  ReleaseMutex(ctx->mutex);
456  if(!pktl) {
457  if(s->flags & AVFMT_FLAG_NONBLOCK) {
458  return AVERROR(EAGAIN);
459  } else {
460  WaitForSingleObject(ctx->event, INFINITE);
461  }
462  }
463  }
464 
465  ctx->curbufsize -= pkt->size;
466 
467  return pkt->size;
468 }
469 
470 #define OFFSET(x) offsetof(struct vfw_ctx, x)
471 #define DEC AV_OPT_FLAG_DECODING_PARAM
472 static const AVOption options[] = {
473  { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
474  { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC },
475  { NULL },
476 };
477 
478 static const AVClass vfw_class = {
479  .class_name = "VFW indev",
480  .item_name = av_default_item_name,
481  .option = options,
482  .version = LIBAVUTIL_VERSION_INT,
484 };
485 
487  .p.name = "vfwcap",
488  .p.long_name = NULL_IF_CONFIG_SMALL("VfW video capture"),
489  .p.flags = AVFMT_NOFILE,
490  .p.priv_class = &vfw_class,
491  .priv_data_size = sizeof(struct vfw_ctx),
493  .read_packet = vfw_read_packet,
494  .read_close = vfw_read_close,
495 };
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:427
dump_captureparms
static void dump_captureparms(AVFormatContext *s, CAPTUREPARMS *cparms)
Definition: vfwcap.c:99
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:69
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
vfw_pixfmt
static enum AVPixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount)
Definition: vfwcap.c:56
AVERROR
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
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
dump_videohdr
static void dump_videohdr(AVFormatContext *s, VIDEOHDR *vhdr)
Definition: vfwcap.c:128
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:47
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
AV_CODEC_ID_RAWVIDEO
@ AV_CODEC_ID_RAWVIDEO
Definition: codec_id.h:65
vfw_ctx::mutex
HANDLE mutex
Definition: vfwcap.c:47
vfw_read_packet
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: vfwcap.c:441
ff_vfwcap_demuxer
const FFInputFormat ff_vfwcap_demuxer
Definition: vfwcap.c:486
w
uint8_t w
Definition: llviddspenc.c:38
AVPacket::data
uint8_t * data
Definition: packet.h:522
AVOption
AVOption.
Definition: opt.h:346
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:832
AV_PIX_FMT_MONOWHITE
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
Definition: pixfmt.h:82
vfw_ctx::video_size
char * video_size
A string describing video size, set by a private option.
Definition: vfwcap.c:52
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: avformat.c:853
vfw_ctx::pktl
PacketListEntry * pktl
Definition: vfwcap.c:49
fail
#define fail()
Definition: checkasm.h:179
HWND_MESSAGE
#define HWND_MESSAGE
Definition: vfwcap.c:41
vfw_read_close
static int vfw_read_close(AVFormatContext *s)
Definition: vfwcap.c:221
AVRational::num
int num
Numerator.
Definition: rational.h:59
dump_bih
static void dump_bih(AVFormatContext *s, BITMAPINFOHEADER *bih)
Definition: vfwcap.c:145
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
s
#define s(width, name)
Definition: cbs_vp9.c:198
av_new_packet
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:98
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:553
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:134
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_RGB4
@ 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 ...
Definition: pixfmt.h:94
vfw_ctx::frame_num
unsigned int frame_num
Definition: vfwcap.c:51
vfw_ctx::event
HANDLE event
Definition: vfwcap.c:48
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
AVFormatContext
Format I/O context.
Definition: avformat.h:1255
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:766
framerate
float framerate
Definition: av1_levels.c:29
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:550
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
videostream_cb
static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
Definition: vfwcap.c:179
AV_PIX_FMT_YUYV422
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:74
options
static const AVOption options[]
Definition: vfwcap.c:472
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
vfw_read_header
static int vfw_read_header(AVFormatContext *s)
Definition: vfwcap.c:247
parseutils.h
AV_PIX_FMT_RGB8
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)3R 3G 2B(lsb)
Definition: pixfmt.h:93
AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT
Definition: log.h:41
PacketListEntry::next
struct PacketListEntry * next
Definition: packet_internal.h:29
OFFSET
#define OFFSET(x)
Definition: vfwcap.c:470
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:49
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:73
vfw_ctx::framerate
char * framerate
Set by a private option.
Definition: vfwcap.c:53
AVPacket::size
int size
Definition: packet.h:523
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
avpriv_report_missing_feature
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
PacketListEntry::pkt
AVPacket pkt
Definition: packet_internal.h:30
AVFMT_NOFILE
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:468
avdevice.h
FFInputFormat::p
AVInputFormat p
The public AVInputFormat.
Definition: demux.h:41
vfw_codecid
static enum AVCodecID vfw_codecid(DWORD biCompression)
Definition: vfwcap.c:84
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:451
av_parse_video_size
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.
Definition: parseutils.c:150
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
AV_CODEC_ID_MJPEG
@ AV_CODEC_ID_MJPEG
Definition: codec_id.h:59
av_parse_video_rate
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
Definition: parseutils.c:181
vfw_ctx::hwnd
HWND hwnd
Definition: vfwcap.c:46
PacketListEntry
Definition: packet_internal.h:28
log.h
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:515
internal.h
AVCodecParameters::height
int height
Definition: codec_par.h:135
AV_PIX_FMT_RGB555
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:466
AV_CODEC_ID_DVVIDEO
@ AV_CODEC_ID_DVVIDEO
Definition: codec_id.h:76
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
demux.h
AVFMT_FLAG_NONBLOCK
#define AVFMT_FLAG_NONBLOCK
Do not block when reading packets from input.
Definition: avformat.h:1409
vfw_ctx::curbufsize
unsigned int curbufsize
Definition: vfwcap.c:50
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:743
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
AV_PIX_FMT_UYVY422
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:88
shall_we_drop
static int shall_we_drop(AVFormatContext *s)
Definition: vfwcap.c:163
dstruct
#define dstruct(pctx, sname, var, type)
Definition: vfwcap.c:96
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
vfw_class
static const AVClass vfw_class
Definition: vfwcap.c:478
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVCodecParameters::bits_per_coded_sample
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:110
packet_internal.h
AVCodecParameters::format
int format
Definition: codec_par.h:92
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
vfw_ctx
Definition: vfwcap.c:44
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
AVPacket
This structure stores compressed data.
Definition: packet.h:499
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
FFInputFormat
Definition: demux.h:37
WaitForSingleObject
#define WaitForSingleObject(a, b)
Definition: w32pthreads.h:63
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
h
h
Definition: vp9dsp_template.c:2038
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
DEC
#define DEC
Definition: vfwcap.c:471