Libav
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 Libav.
6  *
7  * Libav 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  * Libav 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 Libav; 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 
27 #include "libavformat/avformat.h"
28 #include "libavformat/internal.h"
29 
30 // windows.h must no be included before winsock2.h, and libavformat internal
31 // headers may include winsock2.h
32 #include <windows.h>
33 // windows.h needs to be included before vfw.h
34 #include <vfw.h>
35 
36 /* Some obsolete versions of MinGW32 before 4.0.0 lack this. */
37 #ifndef HWND_MESSAGE
38 #define HWND_MESSAGE ((HWND) -3)
39 #endif
40 
41 struct vfw_ctx {
42  const AVClass *class;
43  HWND hwnd;
44  HANDLE mutex;
45  HANDLE event;
47  unsigned int curbufsize;
48  unsigned int frame_num;
49  char *video_size;
50  char *framerate;
51 };
52 
53 static enum AVPixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount)
54 {
55  switch(biCompression) {
56  case MKTAG('U', 'Y', 'V', 'Y'):
57  return AV_PIX_FMT_UYVY422;
58  case MKTAG('Y', 'U', 'Y', '2'):
59  return AV_PIX_FMT_YUYV422;
60  case MKTAG('I', '4', '2', '0'):
61  return AV_PIX_FMT_YUV420P;
62  case BI_RGB:
63  switch(biBitCount) { /* 1-8 are untested */
64  case 1:
65  return AV_PIX_FMT_MONOWHITE;
66  case 4:
67  return AV_PIX_FMT_RGB4;
68  case 8:
69  return AV_PIX_FMT_RGB8;
70  case 16:
71  return AV_PIX_FMT_RGB555;
72  case 24:
73  return AV_PIX_FMT_BGR24;
74  case 32:
75  return AV_PIX_FMT_RGB32;
76  }
77  }
78  return AV_PIX_FMT_NONE;
79 }
80 
81 static enum AVCodecID vfw_codecid(DWORD biCompression)
82 {
83  switch(biCompression) {
84  case MKTAG('d', 'v', 's', 'd'):
85  return AV_CODEC_ID_DVVIDEO;
86  case MKTAG('M', 'J', 'P', 'G'):
87  case MKTAG('m', 'j', 'p', 'g'):
88  return AV_CODEC_ID_MJPEG;
89  }
90  return AV_CODEC_ID_NONE;
91 }
92 
93 #define dstruct(pctx, sname, var, type) \
94  av_log(pctx, AV_LOG_DEBUG, #var":\t%"type"\n", sname->var)
95 
96 static void dump_captureparms(AVFormatContext *s, CAPTUREPARMS *cparms)
97 {
98  av_log(s, AV_LOG_DEBUG, "CAPTUREPARMS\n");
99  dstruct(s, cparms, dwRequestMicroSecPerFrame, "lu");
100  dstruct(s, cparms, fMakeUserHitOKToCapture, "d");
101  dstruct(s, cparms, wPercentDropForError, "u");
102  dstruct(s, cparms, fYield, "d");
103  dstruct(s, cparms, dwIndexSize, "lu");
104  dstruct(s, cparms, wChunkGranularity, "u");
105  dstruct(s, cparms, fUsingDOSMemory, "d");
106  dstruct(s, cparms, wNumVideoRequested, "u");
107  dstruct(s, cparms, fCaptureAudio, "d");
108  dstruct(s, cparms, wNumAudioRequested, "u");
109  dstruct(s, cparms, vKeyAbort, "u");
110  dstruct(s, cparms, fAbortLeftMouse, "d");
111  dstruct(s, cparms, fAbortRightMouse, "d");
112  dstruct(s, cparms, fLimitEnabled, "d");
113  dstruct(s, cparms, wTimeLimit, "u");
114  dstruct(s, cparms, fMCIControl, "d");
115  dstruct(s, cparms, fStepMCIDevice, "d");
116  dstruct(s, cparms, dwMCIStartTime, "lu");
117  dstruct(s, cparms, dwMCIStopTime, "lu");
118  dstruct(s, cparms, fStepCaptureAt2x, "d");
119  dstruct(s, cparms, wStepCaptureAverageFrames, "u");
120  dstruct(s, cparms, dwAudioBufferSize, "lu");
121  dstruct(s, cparms, fDisableWriteCache, "d");
122  dstruct(s, cparms, AVStreamMaster, "u");
123 }
124 
125 static void dump_videohdr(AVFormatContext *s, VIDEOHDR *vhdr)
126 {
127 #ifdef DEBUG
128  av_log(s, AV_LOG_DEBUG, "VIDEOHDR\n");
129  dstruct(s, vhdr, lpData, "p");
130  dstruct(s, vhdr, dwBufferLength, "lu");
131  dstruct(s, vhdr, dwBytesUsed, "lu");
132  dstruct(s, vhdr, dwTimeCaptured, "lu");
133  dstruct(s, vhdr, dwUser, "lu");
134  dstruct(s, vhdr, dwFlags, "lu");
135  dstruct(s, vhdr, dwReserved[0], "lu");
136  dstruct(s, vhdr, dwReserved[1], "lu");
137  dstruct(s, vhdr, dwReserved[2], "lu");
138  dstruct(s, vhdr, dwReserved[3], "lu");
139 #endif
140 }
141 
142 static void dump_bih(AVFormatContext *s, BITMAPINFOHEADER *bih)
143 {
144  av_log(s, AV_LOG_DEBUG, "BITMAPINFOHEADER\n");
145  dstruct(s, bih, biSize, "lu");
146  dstruct(s, bih, biWidth, "ld");
147  dstruct(s, bih, biHeight, "ld");
148  dstruct(s, bih, biPlanes, "d");
149  dstruct(s, bih, biBitCount, "d");
150  dstruct(s, bih, biCompression, "lu");
151  av_log(s, AV_LOG_DEBUG, " biCompression:\t\"%.4s\"\n",
152  (char*) &bih->biCompression);
153  dstruct(s, bih, biSizeImage, "lu");
154  dstruct(s, bih, biXPelsPerMeter, "lu");
155  dstruct(s, bih, biYPelsPerMeter, "lu");
156  dstruct(s, bih, biClrUsed, "lu");
157  dstruct(s, bih, biClrImportant, "lu");
158 }
159 
161 {
162  struct vfw_ctx *ctx = s->priv_data;
163  static const uint8_t dropscore[4] = { 62, 75, 87, 100 };
164  const int ndropscores = FF_ARRAY_ELEMS(dropscore);
165  unsigned int buffer_fullness = (ctx->curbufsize*100)/s->max_picture_buffer;
166 
167  if(dropscore[++ctx->frame_num%ndropscores] <= buffer_fullness) {
168  av_log(s, AV_LOG_ERROR,
169  "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
170  return 1;
171  }
172 
173  return 0;
174 }
175 
176 static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
177 {
178  AVFormatContext *s;
179  struct vfw_ctx *ctx;
180  AVPacketList **ppktl, *pktl_next;
181 
182  s = (AVFormatContext *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
183  ctx = s->priv_data;
184 
185  dump_videohdr(s, vdhdr);
186 
187  if(shall_we_drop(s))
188  return FALSE;
189 
190  WaitForSingleObject(ctx->mutex, INFINITE);
191 
192  pktl_next = av_mallocz(sizeof(AVPacketList));
193  if(!pktl_next)
194  goto fail;
195 
196  if(av_new_packet(&pktl_next->pkt, vdhdr->dwBytesUsed) < 0) {
197  av_free(pktl_next);
198  goto fail;
199  }
200 
201  pktl_next->pkt.pts = vdhdr->dwTimeCaptured;
202  memcpy(pktl_next->pkt.data, vdhdr->lpData, vdhdr->dwBytesUsed);
203 
204  for(ppktl = &ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->next);
205  *ppktl = pktl_next;
206 
207  ctx->curbufsize += vdhdr->dwBytesUsed;
208 
209  SetEvent(ctx->event);
210  ReleaseMutex(ctx->mutex);
211 
212  return TRUE;
213 fail:
214  ReleaseMutex(ctx->mutex);
215  return FALSE;
216 }
217 
219 {
220  struct vfw_ctx *ctx = s->priv_data;
222 
223  if(ctx->hwnd) {
224  SendMessage(ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
225  SendMessage(ctx->hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);
226  DestroyWindow(ctx->hwnd);
227  }
228  if(ctx->mutex)
229  CloseHandle(ctx->mutex);
230  if(ctx->event)
231  CloseHandle(ctx->event);
232 
233  pktl = ctx->pktl;
234  while (pktl) {
235  AVPacketList *next = pktl->next;
236  av_packet_unref(&pktl->pkt);
237  av_free(pktl);
238  pktl = next;
239  }
240 
241  return 0;
242 }
243 
245 {
246  struct vfw_ctx *ctx = s->priv_data;
247  AVCodecParameters *par;
248  AVStream *st;
249  int devnum;
250  int bisize;
251  BITMAPINFO *bi;
252  CAPTUREPARMS cparms;
253  DWORD biCompression;
254  WORD biBitCount;
255  int ret;
256  AVRational framerate_q;
257 
258  if (!strcmp(s->filename, "list")) {
259  for (devnum = 0; devnum <= 9; devnum++) {
260  char driver_name[256];
261  char driver_ver[256];
262  ret = capGetDriverDescription(devnum,
263  driver_name, sizeof(driver_name),
264  driver_ver, sizeof(driver_ver));
265  if (ret) {
266  av_log(s, AV_LOG_INFO, "Driver %d\n", devnum);
267  av_log(s, AV_LOG_INFO, " %s\n", driver_name);
268  av_log(s, AV_LOG_INFO, " %s\n", driver_ver);
269  }
270  }
271  return AVERROR(EIO);
272  }
273 
274  ctx->hwnd = capCreateCaptureWindow(NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0);
275  if(!ctx->hwnd) {
276  av_log(s, AV_LOG_ERROR, "Could not create capture window.\n");
277  return AVERROR(EIO);
278  }
279 
280  /* If atoi fails, devnum==0 and the default device is used */
281  devnum = atoi(s->filename);
282 
283  ret = SendMessage(ctx->hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
284  if(!ret) {
285  av_log(s, AV_LOG_ERROR, "Could not connect to device.\n");
286  DestroyWindow(ctx->hwnd);
287  return AVERROR(ENODEV);
288  }
289 
290  SendMessage(ctx->hwnd, WM_CAP_SET_OVERLAY, 0, 0);
291  SendMessage(ctx->hwnd, WM_CAP_SET_PREVIEW, 0, 0);
292 
293  ret = SendMessage(ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0,
294  (LPARAM) videostream_cb);
295  if(!ret) {
296  av_log(s, AV_LOG_ERROR, "Could not set video stream callback.\n");
297  goto fail_io;
298  }
299 
300  SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) s);
301 
302  st = avformat_new_stream(s, NULL);
303  if(!st) {
304  vfw_read_close(s);
305  return AVERROR(ENOMEM);
306  }
307 
308  /* Set video format */
309  bisize = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
310  if(!bisize)
311  goto fail_io;
312  bi = av_malloc(bisize);
313  if(!bi) {
314  vfw_read_close(s);
315  return AVERROR(ENOMEM);
316  }
317  ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
318  if(!ret)
319  goto fail_bi;
320 
321  dump_bih(s, &bi->bmiHeader);
322 
323 
324  if (ctx->video_size) {
325  ret = av_parse_video_size(&bi->bmiHeader.biWidth, &bi->bmiHeader.biHeight, ctx->video_size);
326  if (ret < 0) {
327  av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n");
328  goto fail_bi;
329  }
330  }
331 
332  if (0) {
333  /* For testing yet unsupported compressions
334  * Copy these values from user-supplied verbose information */
335  bi->bmiHeader.biWidth = 320;
336  bi->bmiHeader.biHeight = 240;
337  bi->bmiHeader.biPlanes = 1;
338  bi->bmiHeader.biBitCount = 12;
339  bi->bmiHeader.biCompression = MKTAG('I','4','2','0');
340  bi->bmiHeader.biSizeImage = 115200;
341  dump_bih(s, &bi->bmiHeader);
342  }
343 
344  ret = SendMessage(ctx->hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
345  if(!ret) {
346  av_log(s, AV_LOG_ERROR, "Could not set Video Format.\n");
347  goto fail_bi;
348  }
349 
350  biCompression = bi->bmiHeader.biCompression;
351  biBitCount = bi->bmiHeader.biBitCount;
352 
353  av_free(bi);
354 
355  /* Set sequence setup */
356  ret = SendMessage(ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP, sizeof(cparms),
357  (LPARAM) &cparms);
358  if(!ret)
359  goto fail_io;
360 
361  dump_captureparms(s, &cparms);
362 
363  cparms.fYield = 1; // Spawn a background thread
364  cparms.dwRequestMicroSecPerFrame =
365  (framerate_q.den*1000000) / framerate_q.num;
366  cparms.fAbortLeftMouse = 0;
367  cparms.fAbortRightMouse = 0;
368  cparms.fCaptureAudio = 0;
369  cparms.vKeyAbort = 0;
370 
371  ret = SendMessage(ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP, sizeof(cparms),
372  (LPARAM) &cparms);
373  if(!ret)
374  goto fail_io;
375 
376  st->avg_frame_rate = framerate_q;
377 
378  par = st->codecpar;
380  par->width = bi->bmiHeader.biWidth;
381  par->height = bi->bmiHeader.biHeight;
382  par->format = vfw_pixfmt(biCompression, biBitCount);
383  if (par->format == AV_PIX_FMT_NONE) {
384  par->codec_id = vfw_codecid(biCompression);
385  if (par->codec_id == AV_CODEC_ID_NONE) {
386  av_log(s, AV_LOG_ERROR, "Unknown compression type. "
387  "Please report verbose (-v 9) debug information.\n");
388  vfw_read_close(s);
389  return AVERROR_PATCHWELCOME;
390  }
391  par->bits_per_coded_sample = biBitCount;
392  } else {
394  if(biCompression == BI_RGB) {
395  par->bits_per_coded_sample = biBitCount;
397  if (par->extradata) {
398  par->extradata_size = 9;
399  memcpy(par->extradata, "BottomUp", 9);
400  }
401  }
402  }
403 
404  avpriv_set_pts_info(st, 32, 1, 1000);
405 
406  ctx->mutex = CreateMutex(NULL, 0, NULL);
407  if(!ctx->mutex) {
408  av_log(s, AV_LOG_ERROR, "Could not create Mutex.\n" );
409  goto fail_io;
410  }
411  ctx->event = CreateEvent(NULL, 1, 0, NULL);
412  if(!ctx->event) {
413  av_log(s, AV_LOG_ERROR, "Could not create Event.\n" );
414  goto fail_io;
415  }
416 
417  ret = SendMessage(ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
418  if(!ret) {
419  av_log(s, AV_LOG_ERROR, "Could not start capture sequence.\n" );
420  goto fail_io;
421  }
422 
423  return 0;
424 
425 fail_bi:
426  av_free(bi);
427 
428 fail_io:
429  vfw_read_close(s);
430  return AVERROR(EIO);
431 }
432 
434 {
435  struct vfw_ctx *ctx = s->priv_data;
437 
438  while(!pktl) {
439  WaitForSingleObject(ctx->mutex, INFINITE);
440  pktl = ctx->pktl;
441  if(ctx->pktl) {
442  *pkt = ctx->pktl->pkt;
443  ctx->pktl = ctx->pktl->next;
444  av_free(pktl);
445  }
446  ResetEvent(ctx->event);
447  ReleaseMutex(ctx->mutex);
448  if(!pktl) {
449  if(s->flags & AVFMT_FLAG_NONBLOCK) {
450  return AVERROR(EAGAIN);
451  } else {
452  WaitForSingleObject(ctx->event, INFINITE);
453  }
454  }
455  }
456 
457  ctx->curbufsize -= pkt->size;
458 
459  return pkt->size;
460 }
461 
462 #define OFFSET(x) offsetof(struct vfw_ctx, x)
463 #define DEC AV_OPT_FLAG_DECODING_PARAM
464 static const AVOption options[] = {
465  { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
466  { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC },
467  { NULL },
468 };
469 
470 static const AVClass vfw_class = {
471  .class_name = "VFW indev",
472  .item_name = av_default_item_name,
473  .option = options,
474  .version = LIBAVUTIL_VERSION_INT,
475 };
476 
478  .name = "vfwcap",
479  .long_name = NULL_IF_CONFIG_SMALL("VfW video capture"),
480  .priv_data_size = sizeof(struct vfw_ctx),
481  .read_header = vfw_read_header,
482  .read_packet = vfw_read_packet,
483  .read_close = vfw_read_close,
484  .flags = AVFMT_NOFILE,
485  .priv_class = &vfw_class,
486 };
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:78
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:62
AVOption.
Definition: opt.h:234
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:100
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:2986
static enum AVPixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount)
Definition: vfwcap.c:53
unsigned int max_picture_buffer
Maximum amount of memory in bytes to use for buffering frames obtained from realtime capture devices...
Definition: avformat.h:1124
static void dump_captureparms(AVFormatContext *s, CAPTUREPARMS *cparms)
Definition: vfwcap.c:96
#define HWND_MESSAGE
Definition: vfwcap.c:38
HANDLE mutex
Definition: vfwcap.c:44
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: avcodec.h:3483
int num
numerator
Definition: rational.h:44
int size
Definition: avcodec.h:1347
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
static int vfw_read_close(AVFormatContext *s)
Definition: vfwcap.c:218
#define FF_ARRAY_ELEMS(a)
static const AVClass vfw_class
Definition: vfwcap.c:470
This struct describes the properties of an encoded stream.
Definition: avcodec.h:3475
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:84
HWND hwnd
Definition: vfwcap.c:43
Format I/O context.
Definition: avformat.h:940
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:39
#define AVFMT_FLAG_NONBLOCK
Do not block when reading packets from input.
Definition: avformat.h:1054
unsigned int curbufsize
Definition: vfwcap.c:47
static void dump_videohdr(AVFormatContext *s, VIDEOHDR *vhdr)
Definition: vfwcap.c:125
uint8_t
int width
Video only.
Definition: avcodec.h:3525
AVOptions.
AVPacket pkt
Definition: avformat.h:1298
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:2648
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1051
uint8_t * data
Definition: avcodec.h:1346
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:84
static void dump_bih(AVFormatContext *s, BITMAPINFOHEADER *bih)
Definition: vfwcap.c:142
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:193
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:124
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Definition: mem.c:190
#define AVERROR(e)
Definition: error.h:43
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:148
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:145
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:3479
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:781
#define fail()
Definition: checkasm.h:80
int extradata_size
Size of the extradata content in bytes.
Definition: avcodec.h:3501
#define dstruct(pctx, sname, var, type)
Definition: vfwcap.c:93
common internal API header
char filename[1024]
input or output filename
Definition: avformat.h:1016
AVFormatContext * ctx
Definition: movenc.c:48
static enum AVCodecID vfw_codecid(DWORD biCompression)
Definition: vfwcap.c:81
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:62
HANDLE event
Definition: vfwcap.c:45
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
Stream structure.
Definition: avformat.h:705
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
Definition: error.h:57
static DWORD dwFlags
Definition: w32pthreads.h:184
NULL
Definition: eval.c:55
#define AV_LOG_INFO
Standard information.
Definition: log.h:135
av_default_item_name
Definition: dnxhdenc.c:55
unsigned int frame_num
Definition: vfwcap.c:48
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:347
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:242
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:60
Describe the class of an AVClass context structure.
Definition: log.h:34
rational number numerator/denominator
Definition: rational.h:43
static int vfw_read_header(AVFormatContext *s)
Definition: vfwcap.c:244
misc parsing utilities
AVInputFormat ff_vfwcap_demuxer
Definition: vfwcap.c:477
#define OFFSET(x)
Definition: vfwcap.c:462
Main libavformat public API header.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:59
struct AVPacketList * next
Definition: avformat.h:1299
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:412
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:68
char * framerate
Set by a private option.
Definition: vfwcap.c:50
AVPacketList * pktl
Definition: vfwcap.c:46
static const AVOption options[]
Definition: vfwcap.c:464
#define DEC
Definition: vfwcap.c:463
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:83
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:251
int den
denominator
Definition: rational.h:45
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: vfwcap.c:433
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:638
char * video_size
A string describing video size, set by a private option.
Definition: vfwcap.c:49
static int shall_we_drop(AVFormatContext *s)
Definition: vfwcap.c:160
void * priv_data
Format private data.
Definition: avformat.h:968
int bits_per_coded_sample
Definition: avcodec.h:3514
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: avcodec.h:3497
static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
Definition: vfwcap.c:176
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:529
AVCodecParameters * codecpar
Definition: avformat.h:831
Definition: vfwcap.c:41
#define MKTAG(a, b, c, d)
Definition: common.h:256
AVPixelFormat
Pixel format.
Definition: pixfmt.h:57
This structure stores compressed data.
Definition: avcodec.h:1323
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:211
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1339