Mercurial > mplayer.hg
changeset 2810:1f0bcdb49910
tv update
author | alex |
---|---|
date | Sun, 11 Nov 2001 01:44:54 +0000 |
parents | b8e0d8204ff2 |
children | 9b6aea4867fd |
files | libmpdemux/tv.c libmpdemux/tvi_v4l.c |
diffstat | 2 files changed, 46 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/tv.c Sun Nov 11 01:35:43 2001 +0000 +++ b/libmpdemux/tv.c Sun Nov 11 01:44:54 2001 +0000 @@ -42,7 +42,7 @@ /* fill demux->video and demux->audio */ 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_packet_t *dp_video = NULL; demux_stream_t *ds_audio = NULL; @@ -53,8 +53,8 @@ demux->filepos = -1; - seq++; - tvh->seq++; +// seq++; +// tvh->seq++; /* ================== ADD VIDEO PACKET =================== */ len_video = tvh->functions->get_video_framesize(tvh->priv); @@ -146,7 +146,7 @@ /* get IMGFMT_ */ 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; /* set FPS and FRAMETIME */
--- a/libmpdemux/tvi_v4l.c Sun Nov 11 01:35:43 2001 +0000 +++ b/libmpdemux/tvi_v4l.c Sun Nov 11 01:44:54 2001 +0000 @@ -32,13 +32,6 @@ "under development" }; -struct vid_fmt { - int fmtid; - int width; - int height; - int bytesperline; -}; - typedef struct { /* general */ char *video_device; @@ -81,16 +74,43 @@ static int palette2depth(int palette) { - if (palette == VIDEO_PALETTE_YUV420P) - return 12; - return 32; + switch(palette) + { + 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) { - if (format == IMGFMT_YV12) - return VIDEO_PALETTE_YUV420P; - return VIDEO_PALETTE_RGB24; + switch(format) + { + 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 @@ -220,7 +240,7 @@ { int i; - priv->fd = open(priv->video_device, O_RDONLY); + priv->fd = open(priv->video_device, O_RDWR); if (priv->fd == -1) { printf("v4l: unable to open '%s': %s\n", @@ -249,7 +269,7 @@ printf("priv->input: %d\n", priv->input); #endif - printf("Selected device: %s\n", priv->capability.name); + printf("Selected device: %s\n", priv->capability.name); printf(" Capabilites: "); for (i = 0; device_cap[i] != NULL; i++) if (priv->capability.type & (1 << i)) @@ -299,11 +319,6 @@ if (priv->mmap == -1) { 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; } printf("our buffer: %p\n", priv->mmap); @@ -441,7 +456,7 @@ (int)*(void **)arg = 1; return(TVI_CONTROL_TRUE); case TVI_CONTROL_VID_GET_BITS: - (int)*(void **)arg = 12; + (int)*(void **)arg = palette2depth(format2palette(priv->format)); return(TVI_CONTROL_TRUE); case TVI_CONTROL_VID_GET_WIDTH: (int)*(void **)arg = priv->width; @@ -451,8 +466,8 @@ int req_width = (int)*(void **)arg; printf("Requested width: %d\n", req_width); - if ((req_width > priv->capability.minwidth) && - (req_width < priv->capability.maxwidth)) + if ((req_width >= priv->capability.minwidth) && + (req_width <= priv->capability.maxwidth)) return(TVI_CONTROL_TRUE); return(TVI_CONTROL_FALSE); } @@ -467,8 +482,8 @@ int req_height = (int)*(void **)arg; printf("Requested height: %d\n", req_height); - if ((req_height > priv->capability.minheight) && - (req_height < priv->capability.maxheight)) + if ((req_height >= priv->capability.minheight) && + (req_height <= priv->capability.maxheight)) return(TVI_CONTROL_TRUE); return(TVI_CONTROL_FALSE); } @@ -654,7 +669,8 @@ 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++; printf("mmap: %p + offset: %d => %p\n",