1 /*
2 * Copyright (c) 2000,2001 Fabrice Bellard
3 * Copyright (c) 2006 Luca Abeni
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 /**
23 * @file
24 * Video4Linux2 grab interface
25 *
26 * Part of this file is based on the V4L2 video capture example
27 * (http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html)
28 *
29 * Thanks to Michael Niedermayer for providing the mapping between
30 * V4L2_PIX_FMT_* and AV_PIX_FMT_*
31 */
32
34 #include <dirent.h>
35
36 #if CONFIG_LIBV4L2
37 #include <libv4l2.h>
38 #endif
39
41
42 #define V4L_ALLFORMATS 3
43 #define V4L_RAWFORMATS 1
44 #define V4L_COMPFORMATS 2
45
46 /**
47 * Return timestamps to the user exactly as returned by the kernel
48 */
49 #define V4L_TS_DEFAULT 0
50 /**
51 * Autodetect the kind of timestamps returned by the kernel and convert to
52 * absolute (wall clock) timestamps.
53 */
55 /**
56 * Assume kernel timestamps are from the monotonic clock and convert to
57 * absolute timestamps.
58 */
59 #define V4L_TS_MONO2ABS 2
60
61 /**
62 * Once the kind of timestamps returned by the kernel have been detected,
63 * the value of the timefilter (NULL or not) determines whether a conversion
64 * takes place.
65 */
66 #define V4L_TS_CONVERT_READY V4L_TS_DEFAULT
67
79
91
93 int (*
open_f)(
const char *file,
int oflag, ...);
96 int (*
ioctl_f)(
int fd,
unsigned long int request, ...);
100 };
101
105 };
106
108 {
110 struct v4l2_capability cap;
111 int fd;
112 int err;
114
115 #define SET_WRAPPERS(prefix) do { \
116 s->open_f = prefix ## open; \
117 s->close_f = prefix ## close; \
118 s->dup_f = prefix ## dup; \
119 s->ioctl_f = prefix ## ioctl; \
120 s->read_f = prefix ## read; \
121 s->mmap_f = prefix ## mmap; \
122 s->munmap_f = prefix ## munmap; \
123 } while (0)
124
126 #if CONFIG_LIBV4L2
128 #else
131 #endif
132 } else {
134 }
135
136 #define v4l2_open s->open_f
137 #define v4l2_close s->close_f
138 #define v4l2_dup s->dup_f
139 #define v4l2_ioctl s->ioctl_f
140 #define v4l2_read s->read_f
141 #define v4l2_mmap s->mmap_f
142 #define v4l2_munmap s->munmap_f
143
145 flags |= O_NONBLOCK;
146 }
147
149 if (fd < 0) {
153 return err;
154 }
155
156 if (
v4l2_ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0) {
161 }
162
164 fd, cap.capabilities);
165
166 if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
170 }
171
172 if (!(cap.capabilities & V4L2_CAP_STREAMING)) {
174 "The device does not support the streaming I/O method.\n");
177 }
178
179 return fd;
180
183 return err;
184 }
185
187 uint32_t pixelformat)
188 {
190 struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
191 int res = 0;
192
193 fmt.fmt.pix.width = *
width;
194 fmt.fmt.pix.height = *
height;
195 fmt.fmt.pix.pixelformat = pixelformat;
196 fmt.fmt.pix.field = V4L2_FIELD_ANY;
197
198 /* Some drivers will fail and return EINVAL when the pixelformat
199 is not supported (even if type field is valid and supported) */
202
203 if ((*width != fmt.fmt.pix.width) || (*height != fmt.fmt.pix.height)) {
205 "The V4L2 driver changed the video from %dx%d to %dx%d\n",
206 *width, *height, fmt.fmt.pix.width, fmt.fmt.pix.height);
207 *width = fmt.fmt.pix.width;
208 *height = fmt.fmt.pix.height;
209 }
210
211 if (pixelformat != fmt.fmt.pix.pixelformat) {
213 "The V4L2 driver changed the pixel format "
214 "from 0x%08X to 0x%08X\n",
215 pixelformat, fmt.fmt.pix.pixelformat);
217 }
218
219 if (fmt.fmt.pix.field == V4L2_FIELD_INTERLACED) {
221 "The V4L2 driver is using the interlaced mode\n");
223 }
224
225 return res;
226 }
227
229 {
230 int res;
231 v4l2_std_id std;
232
234 if (res < 0)
235 return 0;
236 if (std & V4L2_STD_NTSC)
237 return 0;
238
239 return 1;
240 }
241
242 #if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE
243 static void list_framesizes(
AVFormatContext *ctx, uint32_t pixelformat)
244 {
246 struct v4l2_frmsizeenum vfse = { .pixel_format = pixelformat };
247
248 while(!
v4l2_ioctl(s->
fd, VIDIOC_ENUM_FRAMESIZES, &vfse)) {
249 switch (vfse.type) {
250 case V4L2_FRMSIZE_TYPE_DISCRETE:
252 vfse.discrete.width, vfse.discrete.height);
253 break;
254 case V4L2_FRMSIZE_TYPE_CONTINUOUS:
255 case V4L2_FRMSIZE_TYPE_STEPWISE:
257 vfse.stepwise.min_width,
258 vfse.stepwise.max_width,
259 vfse.stepwise.step_width,
260 vfse.stepwise.min_height,
261 vfse.stepwise.max_height,
262 vfse.stepwise.step_height);
263 }
264 vfse.index++;
265 }
266 }
267 #endif
268
270 {
272 struct v4l2_fmtdesc vfd = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
273
277
278 vfd.index++;
279
280 if (!(vfd.flags & V4L2_FMT_FLAG_COMPRESSED) &&
284 fmt_name ? fmt_name : "Unsupported",
285 vfd.description);
286 } else if (vfd.flags & V4L2_FMT_FLAG_COMPRESSED &&
290 desc ? desc->
name :
"Unsupported",
291 vfd.description);
292 } else {
293 continue;
294 }
295
296 #ifdef V4L2_FMT_FLAG_EMULATED
297 if (vfd.flags & V4L2_FMT_FLAG_EMULATED)
299 #endif
300 #if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE
301 list_framesizes(ctx, vfd.pixelformat);
302 #endif
304 }
305 }
306
308 {
309 int ret;
311 struct v4l2_standard standard;
312
314 return;
315
316 for (standard.index = 0; ; standard.index++) {
320 break;
321 } else {
323 return;
324 }
325 }
327 standard.index, (uint64_t)standard.id, standard.name);
328 }
329 }
330
332 {
333 int i, res;
335 struct v4l2_requestbuffers req = {
336 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
338 .memory = V4L2_MEMORY_MMAP
339 };
340
344 return res;
345 }
346
347 if (req.count < 2) {
350 }
356 }
362 }
363
364 for (i = 0; i < req.count; i++) {
365 struct v4l2_buffer buf = {
366 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
367 .index = i,
368 .memory = V4L2_MEMORY_MMAP
369 };
373 return res;
374 }
375
379 "buf_len[%d] = %d < expected frame size %d\n",
382 }
384 PROT_READ | PROT_WRITE, MAP_SHARED,
385 s->
fd, buf.m.offset);
386
390 return res;
391 }
392 }
393
394 return 0;
395 }
396
397 #if FF_API_DESTRUCT_PACKET
399 {
401 }
402 #endif
403
405 {
406 int res = 0;
407
411 } else {
413 }
414
415 return res;
416 }
417
419 {
420 struct v4l2_buffer buf = { 0 };
421 struct buff_data *buf_descriptor = opaque;
423
424 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
425 buf.memory = V4L2_MEMORY_MMAP;
426 buf.index = buf_descriptor->
index;
428
430 }
431
432 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
433 static int64_t av_gettime_monotonic(void)
434 {
436 }
437 #endif
438
440 {
442 int64_t now;
443
446 ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 *
AV_TIME_BASE) {
449 return 0;
450 }
451 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
453 now = av_gettime_monotonic();
455 (ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 *
AV_TIME_BASE)) {
459 /* microseconds instead of seconds, MHz instead of Hz */
464 return 0;
465 }
466 }
467 #endif
470 }
471
473 {
475
478 if (r < 0)
480 }
481 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
484 int64_t nowm = av_gettime_monotonic();
488 }
489 #endif
490 return 0;
491 }
492
494 {
496 struct v4l2_buffer buf = {
497 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
498 .memory = V4L2_MEMORY_MMAP
499 };
500 int res;
501
503
504 /* FIXME: Some special treatment might be needed in case of loss of signal... */
505 while ((res =
v4l2_ioctl(s->
fd, VIDIOC_DQBUF, &buf)) < 0 && (errno == EINTR));
506 if (res < 0) {
507 if (errno == EAGAIN)
509
513 return res;
514 }
515
519 }
521 // always keep at least one buffer queued
523
524 #ifdef V4L2_BUF_FLAG_ERROR
525 if (buf.flags & V4L2_BUF_FLAG_ERROR) {
527 "Dequeued v4l2 buffer contains corrupted data (%d bytes).\n",
528 buf.bytesused);
529 buf.bytesused = 0;
530 } else
531 #endif
532 {
533 /* CPIA is a compressed format and we don't know the exact number of bytes
534 * used by a frame, so set it here as the driver announces it. */
537
540 "Dequeued v4l2 buffer contains %d bytes, but %d were expected. Flags: 0x%08X.\n",
544 }
545 }
546
547 /* Image is at s->buff_start[buf.index] */
549 /* when we start getting low on queued buffers, fall back on copying data */
551 if (res < 0) {
554 return res;
555 }
557
559 if (res) {
561 return res;
562 }
563 } else {
565
567 pkt->
size = buf.bytesused;
568 #if FF_API_DESTRUCT_PACKET
570 pkt->
destruct = dummy_release_buffer;
572 #endif
573
575 if (!buf_descriptor) {
576 /* Something went wrong... Since av_malloc() failed, we cannot even
577 * allocate a buffer for memcpying into it
578 */
581
583 }
584 buf_descriptor->index = buf.index;
585 buf_descriptor->s =
s;
586
588 buf_descriptor, 0);
594 }
595 }
596 pkt->
pts = buf.timestamp.tv_sec * INT64_C(1000000) + buf.timestamp.tv_usec;
598
600 }
601
603 {
605 enum v4l2_buf_type
type;
606 int i, res;
607
608 for (i = 0; i < s->
buffers; i++) {
609 struct v4l2_buffer buf = {
610 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
611 .index = i,
612 .memory = V4L2_MEMORY_MMAP
613 };
614
619 return res;
620 }
621 }
623
624 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
629 return res;
630 }
631
632 return 0;
633 }
634
636 {
637 enum v4l2_buf_type
type;
638 int i;
639
640 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
641 /* We do not check for the result, because we could
642 * not do anything about it anyway...
643 */
645 for (i = 0; i < s->
buffers; i++) {
647 }
650 }
651
653 {
655 struct v4l2_standard standard = { 0 };
656 struct v4l2_streamparm streamparm = { 0 };
657 struct v4l2_fract *tpf;
659 int i, ret;
660
665 return ret;
666 }
667
670 ret = 0;
672 /* set tv standard */
673 for (i = 0; ; i++) {
674 standard.index = i;
677 break;
678 }
680 break;
681 }
682 if (ret < 0) {
684 return ret;
685 }
686
687 if (
v4l2_ioctl(s->
fd, VIDIOC_S_STD, &standard.id) < 0) {
690 return ret;
691 }
692 } else {
694 "This device does not support any standard\n");
695 }
696 }
697
698 /* get standard */
700 tpf = &standard.frameperiod;
701 for (i = 0; ; i++) {
702 standard.index = i;
706 #ifdef ENODATA
708 #endif
709 ) {
710 tpf = &streamparm.parm.capture.timeperframe;
711 break;
712 }
714 return ret;
715 }
716 if (standard.id == s->
std_id) {
718 "Current standard: %s, id: %"PRIx64", frameperiod: %d/%d\n",
719 standard.name, (uint64_t)standard.id, tpf->numerator, tpf->denominator);
720 break;
721 }
722 }
723 } else {
724 tpf = &streamparm.parm.capture.timeperframe;
725 }
726
727 streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
728 if (
v4l2_ioctl(s->
fd, VIDIOC_G_PARM, &streamparm) < 0) {
731 return ret;
732 }
733
734 if (framerate_q.
num && framerate_q.
den) {
735 if (streamparm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) {
736 tpf = &streamparm.parm.capture.timeperframe;
737
739 framerate_q.
den, framerate_q.
num);
740 tpf->numerator = framerate_q.
den;
741 tpf->denominator = framerate_q.
num;
742
743 if (
v4l2_ioctl(s->
fd, VIDIOC_S_PARM, &streamparm) < 0) {
747 return ret;
748 }
749
750 if (framerate_q.
num != tpf->denominator ||
751 framerate_q.
den != tpf->numerator) {
753 "The driver changed the time per frame from "
754 "%d/%d to %d/%d\n",
755 framerate_q.
den, framerate_q.
num,
756 tpf->numerator, tpf->denominator);
757 }
758 } else {
760 "The driver does not permit changing the time per frame\n");
761 }
762 }
763 if (tpf->denominator > 0 && tpf->numerator > 0) {
767 } else
769
770 return 0;
771 }
772
777 uint32_t *desired_format,
779 {
780 int ret, i;
781
783
784 if (*desired_format) {
785 ret =
device_init(ctx, width, height, *desired_format);
786 if (ret < 0) {
787 *desired_format = 0;
789 return ret;
790 }
791 }
792
793 if (!*desired_format) {
800
802 ret =
device_init(ctx, width, height, *desired_format);
803 if (ret >= 0)
804 break;
805 else if (ret !=
AVERROR(EINVAL))
806 return ret;
807 *desired_format = 0;
808 }
809 }
810
811 if (*desired_format == 0) {
813 "codec '%s' (id %d), pixel format '%s' (id %d)\n",
817 }
818 }
819
822 return ret;
823 }
824
826 {
829 return 0;
830 }
831
833 {
836 int res = 0;
837 uint32_t desired_format;
840 struct v4l2_input input = { 0 };
841
843 if (!st)
845
846 #if CONFIG_LIBV4L2
847 /* silence libv4l2 logging. if fopen() fails v4l2_log_file will be NULL
848 and errors will get sent to stderr */
850 v4l2_log_file = fopen("/dev/null", "w");
851 #endif
852
856
858 /* set video input */
864 }
865 } else {
866 /* get current video input */
871 }
872 }
873
874 /* enum input */
880 }
882 av_log(ctx,
AV_LOG_DEBUG,
"Current input_channel: %d, input_name: %s, input_std: %"PRIx64
"\n",
883 s->
channel, input.name, (uint64_t)input.std);
884
889 }
890
895 }
896
898
901
902 if (codec)
904
906
910
913 }
914 }
915
917 struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
918
920 "Querying the device for the current frame size\n");
926 }
927
928 s->
width = fmt.fmt.pix.width;
929 s->
height = fmt.fmt.pix.height;
931 "Setting frame size to %dx%d\n", s->
width, s->
height);
932 }
933
935 if (res < 0)
937
938 /* If no pixel_format was specified, the codec_id was not known up
939 * until now. Set video_codec_id in the context, as codec_id will
940 * not be available outside this function
941 */
944
947
949
952
956
960
962
970 }
971 if (desired_format == V4L2_PIX_FMT_YVU420)
973 else if (desired_format == V4L2_PIX_FMT_YVU410)
979
980 return 0;
981
984 return res;
985 }
986
988 {
990 #if FF_API_CODED_FRAME
994 #endif
995 int res;
996
999 return res;
1000 }
1001
1002 #if FF_API_CODED_FRAME
1005 frame->interlaced_frame = 1;
1007 }
1009 #endif
1010
1012 }
1013
1015 {
1017
1020 "close.\n");
1021
1023
1025 return 0;
1026 }
1027
1029 {
1030 return !strncmp(name, "video", 5) ||
1031 !strncmp(name, "radio", 5) ||
1032 !strncmp(name, "vbi", 3) ||
1033 !strncmp(name, "v4l-subdev", 10);
1034 }
1035
1037 {
1039 DIR *dir;
1040 struct dirent *entry;
1042 struct v4l2_capability cap;
1043 int ret = 0;
1044
1045 if (!device_list)
1047
1048 dir = opendir("/dev");
1049 if (!dir) {
1052 return ret;
1053 }
1054 while ((entry = readdir(dir))) {
1056 continue;
1057
1060 continue;
1061
1066 }
1067
1069 if (!device) {
1072 }
1078 }
1079
1083
1086 continue;
1087
1089 if (device) {
1093 }
1097 break;
1098 }
1099 closedir(dir);
1100 return ret;
1101 }
1102
1103 #define OFFSET(x) offsetof(struct video_data, x)
1104 #define DEC AV_OPT_FLAG_DECODING_PARAM
1105
1108 {
"channel",
"set TV channel, used only by frame grabber",
OFFSET(channel),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, INT_MAX,
DEC },
1113
1114 {
"list_formats",
"list available formats and exit",
OFFSET(list_format),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX,
DEC,
"list_formats" },
1118
1119 {
"list_standards",
"list supported standards and exit",
OFFSET(list_standard),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1,
DEC,
"list_standards" },
1120 {
"all",
"show all supported standards",
OFFSET(list_standard),
AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0,
DEC,
"list_standards" },
1121
1122 {
"timestamps",
"set type of timestamps for grabbed frames",
OFFSET(ts_mode),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2,
DEC,
"timestamps" },
1123 {
"ts",
"set type of timestamps for grabbed frames",
OFFSET(ts_mode),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2,
DEC,
"timestamps" },
1127 {
"use_libv4l2",
"use libv4l2 (v4l-utils) conversion functions",
OFFSET(use_libv4l2),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1,
DEC },
1129 };
1130
1137 };
1138
1140 .
name =
"video4linux2,v4l2",
1150 };
int(* open_f)(const char *file, int oflag,...)
Structure describes basic parameters of the device.
#define avpriv_atomic_int_add_and_fetch
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat pix_fmt
void av_free_packet(AVPacket *pkt)
Free a packet.
This structure describes decoded (raw) audio or video data.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
ptrdiff_t const GLvoid * data
ssize_t(* read_f)(int fd, void *buffer, size_t n)
char * device_description
human friendly name
static int device_init(AVFormatContext *ctx, int *width, int *height, uint32_t pixelformat)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
char * pixel_format
Set by a private option.
char * device_name
device name, format depends on device
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int enqueue_buffer(struct video_data *s, struct v4l2_buffer *buf)
static int device_try_init(AVFormatContext *ctx, enum AVPixelFormat pix_fmt, int *width, int *height, uint32_t *desired_format, enum AVCodecID *codec_id)
static void list_formats(AVFormatContext *ctx, int type)
uint32_t ff_fmt_ff2v4l(enum AVPixelFormat pix_fmt, enum AVCodecID codec_id)
double ff_timefilter_eval(TimeFilter *self, double delta)
Evaluate the filter at a specified time.
const struct fmt_map ff_fmt_conversion_table[]
volatile int buffers_queued
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_assert0(cond)
assert() equivalent, that is always enabled.
#define V4L_TS_ABS
Autodetect the kind of timestamps returned by the kernel and convert to absolute (wall clock) timesta...
Opaque type representing a time filter state.
static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
static int init_convert_timestamp(AVFormatContext *ctx, int64_t ts)
attribute_deprecated void(* destruct)(struct AVPacket *)
unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt)
Return a value representing the fourCC code associated to the pixel format pix_fmt, or 0 if no associated fourCC code can be found.
enum AVStreamParseType need_parsing
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
static int v4l2_read_header(AVFormatContext *ctx)
static int mmap_start(AVFormatContext *ctx)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
static const int desired_video_buffers
static double av_q2d(AVRational a)
Convert rational to double.
int flags
Flags modifying the (de)muxer behaviour.
static int v4l2_is_v4l_dev(const char *name)
#define AV_LOG_VERBOSE
Detailed information.
#define V4L_TS_DEFAULT
Return timestamps to the user exactly as returned by the kernel.
static int v4l2_set_parameters(AVFormatContext *ctx)
static int device_open(AVFormatContext *ctx)
enum AVCodecID video_codec_id
Forced video codec_id.
static int first_field(const struct video_data *s)
#define V4L_TS_CONVERT_READY
Once the kind of timestamps returned by the kernel have been detected, the value of the timefilter (N...
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_list)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define avpriv_atomic_int_get
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const AVOption options[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
AVDeviceInfo ** devices
list of autodetected devices
static const uint8_t offset[127][2]
AVRational avg_frame_rate
Average framerate.
#define V4L_TS_MONO2ABS
Assume kernel timestamps are from the monotonic clock and convert to absolute timestamps.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
AVCodecContext * codec
Codec context associated with this stream.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int bit_rate
the average bitrate
char filename[1024]
input or output filename
#define AV_TIME_BASE
Internal time base represented as integer.
static void list_standards(AVFormatContext *ctx)
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
int width
picture width / height.
static int convert_timestamp(AVFormatContext *ctx, int64_t *ts)
static void mmap_close(struct video_data *s)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
int list_format
Set by a private option.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int64_t av_gettime(void)
Get the current time in microseconds.
#define SET_WRAPPERS(prefix)
#define AV_LOG_INFO
Standard information.
TimeFilter * ff_timefilter_new(double time_base, double period, double bandwidth)
Create a new Delay Locked Loop time filter.
enum AVMediaType codec_type
char * av_strdup(const char *s)
Duplicate the string s.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
BYTE int const BYTE int int int height
Describe the class of an AVClass context structure.
static int v4l2_read_close(AVFormatContext *ctx)
rational number numerator/denominator
const char * name
Name of the codec described by this descriptor.
offset must point to two consecutive integers
This structure contains the data a format has to probe a file.
int list_standard
Set by a private option.
static int mmap_init(AVFormatContext *ctx)
This struct describes the properties of a single codec described by an AVCodecID. ...
static const AVClass v4l2_class
static int v4l2_read_packet(AVFormatContext *ctx, AVPacket *pkt)
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
double ff_timefilter_update(TimeFilter *self, double system_time, double period)
Update the filter.
#define FF_DISABLE_DEPRECATION_WARNINGS
char * framerate
Set by a private option.
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
enum AVCodecID ff_fmt_v4l2codec(uint32_t v4l2_fmt)
#define FF_ENABLE_DEPRECATION_WARNINGS
void * priv_data
Format private data.
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height)
Calculate the size in bytes that a picture of the given width and height would occupy if stored in th...
enum AVPixelFormat ff_fmt_v4l2ff(uint32_t v4l2_fmt, enum AVCodecID codec_id)
AVInputFormat ff_v4l2_demuxer
static void mmap_release_buffer(void *opaque, uint8_t *data)
#define av_malloc_array(a, b)
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
int(* munmap_f)(void *_start, size_t length)
static int v4l2_read_probe(AVProbeData *p)
#define MKTAG(a, b, c, d)
AVRational r_frame_rate
Real base framerate of the stream.
int nb_devices
number of autodetected devices
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 ...
int(* ioctl_f)(int fd, unsigned long int request,...)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...