~ubuntu-branches/ubuntu/utopic/ffmpeg-debian/utopic

« back to all changes in this revision

Viewing changes to libavdevice/v4l2.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-01-20 09:20:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120092053-izz63p40hc98qfgp
Tags: 3:0.svn20090119-1ubuntu1
* merge from debian. LP: #318501
* new version fixes CVE-2008-3230, LP: #253767

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <sys/ioctl.h>
36
36
#include <sys/mman.h>
37
37
#include <sys/time.h>
38
 
#ifdef HAVE_SYS_VIDEOIO_H
 
38
#if HAVE_SYS_VIDEOIO_H
39
39
#include <sys/videoio.h>
40
40
#else
41
41
#include <asm/types.h>
57
57
    int frame_format; /* V4L2_PIX_FMT_* */
58
58
    enum io_method io_method;
59
59
    int width, height;
60
 
    int frame_rate;
61
 
    int frame_rate_base;
62
60
    int frame_size;
63
61
    int top_field_first;
64
62
 
509
507
    struct video_data *s = s1->priv_data;
510
508
    AVStream *st;
511
509
    int width, height;
512
 
    int res, frame_rate, frame_rate_base;
 
510
    int res;
513
511
    uint32_t desired_format, capabilities;
514
512
 
515
513
    if (ap->width <= 0 || ap->height <= 0) {
516
514
        av_log(s1, AV_LOG_ERROR, "Wrong size (%dx%d)\n", ap->width, ap->height);
517
515
        return -1;
518
516
    }
519
 
    if (ap->time_base.den <= 0) {
520
 
        av_log(s1, AV_LOG_ERROR, "Wrong time base (%d)\n", ap->time_base.den);
521
 
        return -1;
522
 
    }
523
517
 
524
518
    width = ap->width;
525
519
    height = ap->height;
526
 
    frame_rate = ap->time_base.den;
527
 
    frame_rate_base = ap->time_base.num;
528
 
 
529
 
    if((unsigned)width > 32767 || (unsigned)height > 32767) {
530
 
        av_log(s1, AV_LOG_ERROR, "Wrong size (%dx%d)\n", width, height);
531
 
 
 
520
 
 
521
    if(avcodec_check_dimensions(s1, ap->width, ap->height) < 0)
532
522
        return -1;
533
 
    }
534
523
 
535
524
    st = av_new_stream(s1, 0);
536
525
    if (!st) {
540
529
 
541
530
    s->width = width;
542
531
    s->height = height;
543
 
    s->frame_rate      = frame_rate;
544
 
    s->frame_rate_base = frame_rate_base;
545
532
 
546
533
    capabilities = 0;
547
534
    s->fd = device_open(s1, &capabilities);
602
589
    st->codec->codec_id = CODEC_ID_RAWVIDEO;
603
590
    st->codec->width = width;
604
591
    st->codec->height = height;
605
 
    st->codec->time_base.den = frame_rate;
606
 
    st->codec->time_base.num = frame_rate_base;
 
592
    st->codec->time_base.den = ap->time_base.den;
 
593
    st->codec->time_base.num = ap->time_base.num;
607
594
    st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8;
608
595
 
609
596
    return 0;
651
638
 
652
639
AVInputFormat v4l2_demuxer = {
653
640
    "video4linux2",
654
 
    NULL_IF_CONFIG_SMALL("video grab"),
 
641
    NULL_IF_CONFIG_SMALL("Video4Linux2 device grab"),
655
642
    sizeof(struct video_data),
656
643
    NULL,
657
644
    v4l2_read_header,