summaryrefslogtreecommitdiff
path: root/libavdevice
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2008-12-17 23:51:19 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2008-12-17 23:51:19 +0000
commit406c5808541dc5e1b5abf639a198807e07f9b7db (patch)
tree4abfca111649a9080583ba8644ce66a1714a6cdb /libavdevice
parent9580ba267673e9593c23eb24a3d8769ef9f501f4 (diff)
downloadffmpeg-406c5808541dc5e1b5abf639a198807e07f9b7db.tar.gz
Replace the width and height fields in VideoData with a struct
video_window video_win field. Originally committed as revision 16198 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/v4l.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/libavdevice/v4l.c b/libavdevice/v4l.c
index ac1aaec210..1978ab4bb2 100644
--- a/libavdevice/v4l.c
+++ b/libavdevice/v4l.c
@@ -38,12 +38,12 @@ typedef struct {
int fd;
int frame_format; /* see VIDEO_PALETTE_xxx */
int use_mmap;
- int width, height;
AVRational time_base;
int64_t time_frame;
int frame_size;
struct video_capability video_cap;
struct video_audio audio_saved;
+ struct video_window video_win;
uint8_t *video_buf;
struct video_mbuf gb_buffers;
struct video_mmap gb_buf;
@@ -70,7 +70,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
{
VideoData *s = s1->priv_data;
AVStream *st;
- int width, height;
int video_fd, frame_size;
int desired_palette, desired_depth;
struct video_tuner tuner;
@@ -89,24 +88,19 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
}
s->time_base = ap->time_base;
- width = ap->width;
- height = ap->height;
-
- if((unsigned)width > 32767 || (unsigned)height > 32767) {
+ if((unsigned)ap->width > 32767 || (unsigned)ap->height > 32767) {
av_log(s1, AV_LOG_ERROR, "Capture size is out of range: %dx%d\n",
- width, height);
-
+ ap->width, ap->height);
return -1;
}
+ s->video_win.width = ap->width;
+ s->video_win.height = ap->height;
st = av_new_stream(s1, 0);
if (!st)
return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
- s->width = width;
- s->height = height;
-
video_fd = open(s1->filename, O_RDWR);
if (video_fd < 0) {
av_log(s1, AV_LOG_ERROR, "%s: %s\n", s1->filename, strerror(errno));
@@ -176,17 +170,14 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
if (ioctl(video_fd,VIDIOCGMBUF,&s->gb_buffers) < 0) {
/* try to use read based access */
- struct video_window win;
int val;
- win.x = 0;
- win.y = 0;
- win.width = width;
- win.height = height;
- win.chromakey = -1;
- win.flags = 0;
+ s->video_win.x = 0;
+ s->video_win.y = 0;
+ s->video_win.chromakey = -1;
+ s->video_win.flags = 0;
- ioctl(video_fd, VIDIOCSWIN, &win);
+ ioctl(video_fd, VIDIOCSWIN, s->video_win);
s->frame_format = pict.palette;
@@ -209,8 +200,8 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
/* start to grab the first frame */
s->gb_buf.frame = s->gb_frame % s->gb_buffers.frames;
- s->gb_buf.height = height;
- s->gb_buf.width = width;
+ s->gb_buf.height = s->video_win.height;
+ s->gb_buf.width = s->video_win.width;
s->gb_buf.format = pict.palette;
if (ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf) < 0) {
@@ -232,7 +223,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
for (j = 0; j < vformat_num; j++) {
if (s->frame_format == video_formats[j].palette) {
- frame_size = width * height * video_formats[j].depth / 8;
+ frame_size = s->video_win.width * s->video_win.height * video_formats[j].depth / 8;
st->codec->pix_fmt = video_formats[j].pix_fmt;
break;
}
@@ -246,8 +237,8 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_RAWVIDEO;
- st->codec->width = width;
- st->codec->height = height;
+ st->codec->width = s->video_win.width;
+ st->codec->height = s->video_win.height;
st->codec->time_base = s->time_base;
st->codec->bit_rate = frame_size * 1/av_q2d(st->codec->time_base) * 8;