1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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
This commit is contained in:
Stefano Sabatini 2008-12-17 23:51:19 +00:00
parent 9580ba2676
commit 406c580854

View File

@ -38,12 +38,12 @@ typedef struct {
int fd; int fd;
int frame_format; /* see VIDEO_PALETTE_xxx */ int frame_format; /* see VIDEO_PALETTE_xxx */
int use_mmap; int use_mmap;
int width, height;
AVRational time_base; AVRational time_base;
int64_t time_frame; int64_t time_frame;
int frame_size; int frame_size;
struct video_capability video_cap; struct video_capability video_cap;
struct video_audio audio_saved; struct video_audio audio_saved;
struct video_window video_win;
uint8_t *video_buf; uint8_t *video_buf;
struct video_mbuf gb_buffers; struct video_mbuf gb_buffers;
struct video_mmap gb_buf; struct video_mmap gb_buf;
@ -70,7 +70,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
{ {
VideoData *s = s1->priv_data; VideoData *s = s1->priv_data;
AVStream *st; AVStream *st;
int width, height;
int video_fd, frame_size; int video_fd, frame_size;
int desired_palette, desired_depth; int desired_palette, desired_depth;
struct video_tuner tuner; struct video_tuner tuner;
@ -89,24 +88,19 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
} }
s->time_base = ap->time_base; s->time_base = ap->time_base;
width = ap->width; if((unsigned)ap->width > 32767 || (unsigned)ap->height > 32767) {
height = ap->height;
if((unsigned)width > 32767 || (unsigned)height > 32767) {
av_log(s1, AV_LOG_ERROR, "Capture size is out of range: %dx%d\n", av_log(s1, AV_LOG_ERROR, "Capture size is out of range: %dx%d\n",
width, height); ap->width, ap->height);
return -1; return -1;
} }
s->video_win.width = ap->width;
s->video_win.height = ap->height;
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);
if (!st) if (!st)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ 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); video_fd = open(s1->filename, O_RDWR);
if (video_fd < 0) { if (video_fd < 0) {
av_log(s1, AV_LOG_ERROR, "%s: %s\n", s1->filename, strerror(errno)); 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) { if (ioctl(video_fd,VIDIOCGMBUF,&s->gb_buffers) < 0) {
/* try to use read based access */ /* try to use read based access */
struct video_window win;
int val; int val;
win.x = 0; s->video_win.x = 0;
win.y = 0; s->video_win.y = 0;
win.width = width; s->video_win.chromakey = -1;
win.height = height; s->video_win.flags = 0;
win.chromakey = -1;
win.flags = 0;
ioctl(video_fd, VIDIOCSWIN, &win); ioctl(video_fd, VIDIOCSWIN, s->video_win);
s->frame_format = pict.palette; s->frame_format = pict.palette;
@ -209,8 +200,8 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
/* start to grab the first frame */ /* start to grab the first frame */
s->gb_buf.frame = s->gb_frame % s->gb_buffers.frames; s->gb_buf.frame = s->gb_frame % s->gb_buffers.frames;
s->gb_buf.height = height; s->gb_buf.height = s->video_win.height;
s->gb_buf.width = width; s->gb_buf.width = s->video_win.width;
s->gb_buf.format = pict.palette; s->gb_buf.format = pict.palette;
if (ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf) < 0) { 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++) { for (j = 0; j < vformat_num; j++) {
if (s->frame_format == video_formats[j].palette) { 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; st->codec->pix_fmt = video_formats[j].pix_fmt;
break; break;
} }
@ -246,8 +237,8 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st->codec->codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec->width = width; st->codec->width = s->video_win.width;
st->codec->height = height; st->codec->height = s->video_win.height;
st->codec->time_base = s->time_base; st->codec->time_base = s->time_base;
st->codec->bit_rate = frame_size * 1/av_q2d(st->codec->time_base) * 8; st->codec->bit_rate = frame_size * 1/av_q2d(st->codec->time_base) * 8;