| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Video4Linux2 grab interface | 2 * Video4Linux2 grab interface |
| 3 * Copyright (c) 2000,2001 Fabrice Bellard | 3 * Copyright (c) 2000,2001 Fabrice Bellard |
| 4 * Copyright (c) 2006 Luca Abeni | 4 * Copyright (c) 2006 Luca Abeni |
| 5 * | 5 * |
| 6 * Part of this file is based on the V4L2 video capture example | 6 * Part of this file is based on the V4L2 video capture example |
| 7 * (http://v4l2spec.bytesex.org/v4l2spec/capture.c) | 7 * (http://v4l2spec.bytesex.org/v4l2spec/capture.c) |
| 8 * | 8 * |
| 9 * Thanks to Michael Niedermayer for providing the mapping between | 9 * Thanks to Michael Niedermayer for providing the mapping between |
| 10 * V4L2_PIX_FMT_* and PIX_FMT_* | 10 * V4L2_PIX_FMT_* and PIX_FMT_* |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 .ff_fmt = PIX_FMT_BGRA, | 132 .ff_fmt = PIX_FMT_BGRA, |
| 133 .codec_id = CODEC_ID_RAWVIDEO, | 133 .codec_id = CODEC_ID_RAWVIDEO, |
| 134 .v4l2_fmt = V4L2_PIX_FMT_BGR32, | 134 .v4l2_fmt = V4L2_PIX_FMT_BGR32, |
| 135 }, | 135 }, |
| 136 { | 136 { |
| 137 .ff_fmt = PIX_FMT_GRAY8, | 137 .ff_fmt = PIX_FMT_GRAY8, |
| 138 .codec_id = CODEC_ID_RAWVIDEO, | 138 .codec_id = CODEC_ID_RAWVIDEO, |
| 139 .v4l2_fmt = V4L2_PIX_FMT_GREY, | 139 .v4l2_fmt = V4L2_PIX_FMT_GREY, |
| 140 }, | 140 }, |
| 141 { | 141 { |
| 142 .ff_fmt = PIX_FMT_NV12, |
| 143 .codec_id = CODEC_ID_RAWVIDEO, |
| 144 .v4l2_fmt = V4L2_PIX_FMT_NV12, |
| 145 }, |
| 146 { |
| 142 .ff_fmt = PIX_FMT_NONE, | 147 .ff_fmt = PIX_FMT_NONE, |
| 143 .codec_id = CODEC_ID_MJPEG, | 148 .codec_id = CODEC_ID_MJPEG, |
| 144 .v4l2_fmt = V4L2_PIX_FMT_MJPEG, | 149 .v4l2_fmt = V4L2_PIX_FMT_MJPEG, |
| 145 }, | 150 }, |
| 146 { | 151 { |
| 147 .ff_fmt = PIX_FMT_NONE, | 152 .ff_fmt = PIX_FMT_NONE, |
| 148 .codec_id = CODEC_ID_MJPEG, | 153 .codec_id = CODEC_ID_MJPEG, |
| 149 .v4l2_fmt = V4L2_PIX_FMT_JPEG, | 154 .v4l2_fmt = V4L2_PIX_FMT_JPEG, |
| 150 }, | 155 }, |
| 151 }; | 156 }; |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 } | 622 } |
| 618 | 623 |
| 619 desired_format = device_try_init(s1, ap, &s->width, &s->height, &codec_id); | 624 desired_format = device_try_init(s1, ap, &s->width, &s->height, &codec_id); |
| 620 if (desired_format == 0) { | 625 if (desired_format == 0) { |
| 621 av_log(s1, AV_LOG_ERROR, "Cannot find a proper format for " | 626 av_log(s1, AV_LOG_ERROR, "Cannot find a proper format for " |
| 622 "codec_id %d, pix_fmt %d.\n", s1->video_codec_id, ap->pix_fmt); | 627 "codec_id %d, pix_fmt %d.\n", s1->video_codec_id, ap->pix_fmt); |
| 623 close(s->fd); | 628 close(s->fd); |
| 624 | 629 |
| 625 return AVERROR(EIO); | 630 return AVERROR(EIO); |
| 626 } | 631 } |
| 627 if (av_check_image_size(s->width, s->height, 0, s1) < 0) | 632 if (av_image_check_size(s->width, s->height, 0, s1) < 0) |
| 628 return AVERROR(EINVAL); | 633 return AVERROR(EINVAL); |
| 629 s->frame_format = desired_format; | 634 s->frame_format = desired_format; |
| 630 | 635 |
| 631 if( v4l2_set_parameters( s1, ap ) < 0 ) | 636 if( v4l2_set_parameters( s1, ap ) < 0 ) |
| 632 return AVERROR(EIO); | 637 return AVERROR(EIO); |
| 633 | 638 |
| 634 st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id); | 639 st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id); |
| 635 s->frame_size = avpicture_get_size(st->codec->pix_fmt, s->width, s->height); | 640 s->frame_size = avpicture_get_size(st->codec->pix_fmt, s->width, s->height); |
| 636 if (capabilities & V4L2_CAP_STREAMING) { | 641 if (capabilities & V4L2_CAP_STREAMING) { |
| 637 s->io_method = io_mmap; | 642 s->io_method = io_mmap; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 AVInputFormat v4l2_demuxer = { | 709 AVInputFormat v4l2_demuxer = { |
| 705 "video4linux2", | 710 "video4linux2", |
| 706 NULL_IF_CONFIG_SMALL("Video4Linux2 device grab"), | 711 NULL_IF_CONFIG_SMALL("Video4Linux2 device grab"), |
| 707 sizeof(struct video_data), | 712 sizeof(struct video_data), |
| 708 NULL, | 713 NULL, |
| 709 v4l2_read_header, | 714 v4l2_read_header, |
| 710 v4l2_read_packet, | 715 v4l2_read_packet, |
| 711 v4l2_read_close, | 716 v4l2_read_close, |
| 712 .flags = AVFMT_NOFILE, | 717 .flags = AVFMT_NOFILE, |
| 713 }; | 718 }; |
| OLD | NEW |