1
mirror of https://github.com/mpv-player/mpv synced 2024-11-07 01:47:00 +01:00

tv update

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2811 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
alex 2001-11-11 01:44:54 +00:00
parent ff534f0810
commit a0cfaaf615
2 changed files with 46 additions and 30 deletions

View File

@ -42,7 +42,7 @@ int tv_param_input = 0; /* used in v4l and bttv */
/* fill demux->video and demux->audio */ /* fill demux->video and demux->audio */
int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh) int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh)
{ {
int seq = tvh->seq; int seq = tvh->seq++;
demux_stream_t *ds_video = NULL; demux_stream_t *ds_video = NULL;
demux_packet_t *dp_video = NULL; demux_packet_t *dp_video = NULL;
demux_stream_t *ds_audio = NULL; demux_stream_t *ds_audio = NULL;
@ -53,8 +53,8 @@ int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh)
demux->filepos = -1; demux->filepos = -1;
seq++; // seq++;
tvh->seq++; // tvh->seq++;
/* ================== ADD VIDEO PACKET =================== */ /* ================== ADD VIDEO PACKET =================== */
len_video = tvh->functions->get_video_framesize(tvh->priv); len_video = tvh->functions->get_video_framesize(tvh->priv);
@ -146,7 +146,7 @@ int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh)
/* get IMGFMT_ */ /* get IMGFMT_ */
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &sh_video->format); funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &sh_video->format);
if (IMGFMT_IS_RGB(sh_video->format) || IMGFMT_IS_BGR(sh_video->format)) // if (IMGFMT_IS_RGB(sh_video->format) || IMGFMT_IS_BGR(sh_video->format))
sh_video->format = 0x0; sh_video->format = 0x0;
/* set FPS and FRAMETIME */ /* set FPS and FRAMETIME */

View File

@ -32,13 +32,6 @@ static tvi_info_t info = {
"under development" "under development"
}; };
struct vid_fmt {
int fmtid;
int width;
int height;
int bytesperline;
};
typedef struct { typedef struct {
/* general */ /* general */
char *video_device; char *video_device;
@ -81,16 +74,43 @@ static const char *device_pal[] = {
static int palette2depth(int palette) static int palette2depth(int palette)
{ {
if (palette == VIDEO_PALETTE_YUV420P) switch(palette)
return 12; {
return 32; case VIDEO_PALETTE_RGB555:
return(15);
case VIDEO_PALETTE_RGB565:
return(16);
case VIDEO_PALETTE_RGB24:
return(24);
case VIDEO_PALETTE_RGB32:
return(32);
case VIDEO_PALETTE_YUV420P:
return(12);
case VIDEO_PALETTE_YUV422:
case VIDEO_PALETTE_UYVY:
return(16);
}
return(-1);
} }
static int format2palette(int format) static int format2palette(int format)
{ {
if (format == IMGFMT_YV12) switch(format)
return VIDEO_PALETTE_YUV420P; {
return VIDEO_PALETTE_RGB24; case IMGFMT_RGB15:
return(VIDEO_PALETTE_RGB555);
case IMGFMT_RGB16:
return(VIDEO_PALETTE_RGB565);
case IMGFMT_RGB24:
return(VIDEO_PALETTE_RGB24);
case IMGFMT_RGB32:
return(VIDEO_PALETTE_RGB32);
case IMGFMT_YV12:
return(VIDEO_PALETTE_YUV420P);
case IMGFMT_UYVY:
return(VIDEO_PALETTE_YUV422);
}
return(-1);
} }
#if 0 #if 0
@ -220,7 +240,7 @@ static int init(priv_t *priv, tvi_param_t *params)
{ {
int i; int i;
priv->fd = open(priv->video_device, O_RDONLY); priv->fd = open(priv->video_device, O_RDWR);
if (priv->fd == -1) if (priv->fd == -1)
{ {
printf("v4l: unable to open '%s': %s\n", printf("v4l: unable to open '%s': %s\n",
@ -299,11 +319,6 @@ static int init(priv_t *priv, tvi_param_t *params)
if (priv->mmap == -1) if (priv->mmap == -1)
{ {
printf("Unabel to map memory for buffers: %s\n", strerror(errno)); printf("Unabel to map memory for buffers: %s\n", strerror(errno));
priv->mmap = malloc(priv->mbuf.size); /* our buffer */
}
if (!priv->mmap)
{
printf("Unable to allocate memory for buffers: %s\n", strerror(errno));
goto err; goto err;
} }
printf("our buffer: %p\n", priv->mmap); printf("our buffer: %p\n", priv->mmap);
@ -441,7 +456,7 @@ static int control(priv_t *priv, int cmd, void *arg)
(int)*(void **)arg = 1; (int)*(void **)arg = 1;
return(TVI_CONTROL_TRUE); return(TVI_CONTROL_TRUE);
case TVI_CONTROL_VID_GET_BITS: case TVI_CONTROL_VID_GET_BITS:
(int)*(void **)arg = 12; (int)*(void **)arg = palette2depth(format2palette(priv->format));
return(TVI_CONTROL_TRUE); return(TVI_CONTROL_TRUE);
case TVI_CONTROL_VID_GET_WIDTH: case TVI_CONTROL_VID_GET_WIDTH:
(int)*(void **)arg = priv->width; (int)*(void **)arg = priv->width;
@ -451,8 +466,8 @@ static int control(priv_t *priv, int cmd, void *arg)
int req_width = (int)*(void **)arg; int req_width = (int)*(void **)arg;
printf("Requested width: %d\n", req_width); printf("Requested width: %d\n", req_width);
if ((req_width > priv->capability.minwidth) && if ((req_width >= priv->capability.minwidth) &&
(req_width < priv->capability.maxwidth)) (req_width <= priv->capability.maxwidth))
return(TVI_CONTROL_TRUE); return(TVI_CONTROL_TRUE);
return(TVI_CONTROL_FALSE); return(TVI_CONTROL_FALSE);
} }
@ -467,8 +482,8 @@ static int control(priv_t *priv, int cmd, void *arg)
int req_height = (int)*(void **)arg; int req_height = (int)*(void **)arg;
printf("Requested height: %d\n", req_height); printf("Requested height: %d\n", req_height);
if ((req_height > priv->capability.minheight) && if ((req_height >= priv->capability.minheight) &&
(req_height < priv->capability.maxheight)) (req_height <= priv->capability.maxheight))
return(TVI_CONTROL_TRUE); return(TVI_CONTROL_TRUE);
return(TVI_CONTROL_FALSE); return(TVI_CONTROL_FALSE);
} }
@ -654,7 +669,8 @@ static int grab_video_frame(priv_t *priv, char *buffer, int len)
return(0); return(0);
} }
ioctl(priv->fd, VIDIOCSYNC, &priv->buf[frame]); if (ioctl(priv->fd, VIDIOCSYNC, &priv->buf[frame]) == -1)
printf("ioctl sync failed: %s\n", strerror(errno));
priv->queue++; priv->queue++;
printf("mmap: %p + offset: %d => %p\n", printf("mmap: %p + offset: %d => %p\n",