Mercurial > mplayer.hg
changeset 9065:59805b2d220a
raw video demuxer, requested by Michael
(try mplayer -rawvideo on:cif mobile.cif)
author | arpi |
---|---|
date | Wed, 22 Jan 2003 23:51:04 +0000 |
parents | c1bafd401d78 |
children | 2fe45c1b6a2d |
files | DOCS/mplayer.1 cfg-common.h etc/codecs.conf libmpdemux/Makefile libmpdemux/demux_rawvideo.c libmpdemux/demuxer.c libmpdemux/demuxer.h |
diffstat | 7 files changed, 169 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/mplayer.1 Wed Jan 22 22:30:44 2003 +0000 +++ b/DOCS/mplayer.1 Wed Jan 22 23:51:04 2003 +0000 @@ -628,6 +628,33 @@ .PD 1 . .TP +.B \-rawvideo <option1:option2:...> +This option lets you play raw video files. +.br +Available options are: + +.PD 0 +.RSs +.IPs on\ \ \ +use raw video demuxer +.IPs fps=<value> +rate in frames per second, default 25.0 +.IPs sqcif|qcif|cif|4cif|pal|ntsc +set standard image size +.IPs w=<value> +image width in pixels +.IPs h=<value> +image height in pixels +.IPs y420|yv12|yuy2|y8 +set colorspace +.IPs format=<value> +colorspace (fourcc) in hex +.IPs size=<value> +frame size in bytes +.RE +.PD 1 +. +.TP .B \-rtsp-stream-over-tcp Used with 'rtsp://' URLs to specify that the resulting incoming RTP and RTCP packets be streamed over TCP (using the same TCP connection as RTSP).
--- a/cfg-common.h Wed Jan 22 22:30:44 2003 +0000 +++ b/cfg-common.h Wed Jan 22 23:51:04 2003 +0000 @@ -72,6 +72,7 @@ { "nohr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 1, 0, NULL}, { "rawaudio", &demux_rawaudio_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, + { "rawvideo", &demux_rawvideo_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, #ifdef HAVE_CDDA { "cdda", &cdda_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, @@ -224,6 +225,7 @@ /* defined in libmpdemux: */ extern int hr_mp3_seek; extern config_t demux_rawaudio_opts[]; +extern config_t demux_rawvideo_opts[]; extern config_t cdda_opts[]; extern char* audio_stream;
--- a/etc/codecs.conf Wed Jan 22 22:30:44 2003 +0000 +++ b/etc/codecs.conf Wed Jan 22 23:51:04 2003 +0000 @@ -663,7 +663,8 @@ videocodec i263 info "I263" status working - fourcc I263,i263,I420,i420 + fourcc I263,i263 +; fourcc I420,i420 fourcc vivo,VIVO I263 fourcc viv1 I263 driver vfw
--- a/libmpdemux/Makefile Wed Jan 22 22:30:44 2003 +0000 +++ b/libmpdemux/Makefile Wed Jan 22 23:51:04 2003 +0000 @@ -3,7 +3,7 @@ include ../config.mak -SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_pva.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c demux_smjpeg.c cue_read.c extension.c +SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_pva.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c demux_smjpeg.c cue_read.c extension.c ifeq ($(XMMS_PLUGINS),yes) SRCS += demux_xmms.c endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libmpdemux/demux_rawvideo.c Wed Jan 22 23:51:04 2003 +0000 @@ -0,0 +1,120 @@ + +#include "config.h" + +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> + +#include "../cfgparser.h" + +#include "stream.h" +#include "demuxer.h" +#include "stheader.h" + +#include "../libmpcodecs/img_format.h" + +int use_rawvideo = 0; +static int format = IMGFMT_I420; +static int size_id = 0; +static int width = 0; +static int height = 0; +static float fps = 25; +static int imgsize=0; + +config_t demux_rawvideo_opts[] = { + { "on", &use_rawvideo, CONF_TYPE_FLAG, 0,0, 1, NULL }, + // size: + { "w", &width, CONF_TYPE_INT,CONF_RANGE,1,8192, NULL }, + { "h", &height, CONF_TYPE_INT,CONF_RANGE,1,8192, NULL }, + { "sqcif", &size_id, CONF_TYPE_FLAG,0,0,1, NULL }, + { "qcif", &size_id, CONF_TYPE_FLAG,0,0,2, NULL }, + { "cif", &size_id, CONF_TYPE_FLAG,0,0,3, NULL }, + { "4cif", &size_id, CONF_TYPE_FLAG,0,0,4, NULL }, + { "pal", &size_id, CONF_TYPE_FLAG,0,0,5, NULL }, + { "ntsc", &size_id, CONF_TYPE_FLAG,0,0,6, NULL }, + // format: + { "format", &format, CONF_TYPE_INT, 0, 0 , 0, NULL }, + { "y420", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_I420, NULL }, + { "yv12", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_YV12, NULL }, + { "yuy2", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_YUY2, NULL }, + { "y8", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_Y8, NULL }, + // misc: + { "fps", &fps, CONF_TYPE_FLOAT,CONF_RANGE,0.001,1000, NULL }, + { "size", &imgsize, CONF_TYPE_INT, CONF_RANGE, 1 , 8192*8192*4, NULL }, + + {NULL, NULL, 0, 0, 0, 0, NULL} +}; + + +int demux_rawvideo_open(demuxer_t* demuxer) { + sh_video_t* sh_video; + + switch(size_id){ + case 1: width=128; height=96; break; + case 2: width=176; height=144; break; + case 3: width=352; height=288; break; + case 4: width=704; height=576; break; + case 5: width=720; height=576; break; + case 6: width=720; height=480; break; + } + if(!width || !height){ + mp_msg(MSGT_DEMUX,MSGL_ERR,"rawvideo: width or height not specified!\n"); + return 0; + } + + if(!imgsize) + switch(format){ + case IMGFMT_I420: + case IMGFMT_IYUV: + case IMGFMT_YV12: imgsize=width*height+2*(width>>1)*(height>>1);break; + case IMGFMT_YUY2: imgsize=width*height*2;break; + case IMGFMT_Y8: imgsize=width*height;break; + default: + mp_msg(MSGT_DEMUX,MSGL_ERR,"rawvideo: img size not specified and unknown format!\n"); + return 0; + } + + sh_video = new_sh_video(demuxer,0); + sh_video->format=format; + sh_video->fps=fps; + sh_video->frametime=1.0/fps; + sh_video->disp_w=width; + sh_video->disp_h=height; + sh_video->i_bps=fps*imgsize; + + demuxer->movi_start = demuxer->stream->start_pos; + demuxer->movi_end = demuxer->stream->end_pos; + + demuxer->video->sh = sh_video; + sh_video->ds = demuxer->video; + + return 1; +} + +int demux_rawvideo_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds) { + + if(demuxer->stream->eof) return 0; + if(ds!=demuxer->video) return 0; + + ds_read_packet(ds,demuxer->stream,imgsize,0,stream_tell(demuxer->stream),0x10); + + return 1; +} + +void demux_rawvideo_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){ + stream_t* s = demuxer->stream; + sh_video_t* sh_video = demuxer->video->sh; + off_t pos; + + pos = (flags & 1) ? demuxer->movi_start : stream_tell(s); + if(flags & 2) + pos += ((demuxer->movi_end - demuxer->movi_start)*rel_seek_secs); + else + pos += (rel_seek_secs*sh_video->i_bps); + + pos/=imgsize; + stream_seek(s,pos*imgsize); + sh_video->timer=pos * sh_video->frametime; +// printf("demux_rawvideo: streamtell=%d\n",(int)stream_tell(demuxer->stream)); +}
--- a/libmpdemux/demuxer.c Wed Jan 22 22:30:44 2003 +0000 +++ b/libmpdemux/demuxer.c Wed Jan 22 23:51:04 2003 +0000 @@ -280,6 +280,7 @@ extern int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds); extern int demux_ogg_fill_buffer(demuxer_t *d); extern int demux_rawaudio_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds); +extern int demux_rawvideo_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds); extern int demux_smjpeg_fill_buffer(demuxer_t* demux); int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){ @@ -318,6 +319,7 @@ case DEMUXER_TYPE_OGG: return demux_ogg_fill_buffer(demux); #endif case DEMUXER_TYPE_RAWAUDIO: return demux_rawaudio_fill_buffer(demux,ds); + case DEMUXER_TYPE_RAWVIDEO: return demux_rawvideo_fill_buffer(demux,ds); #ifdef STREAMING_LIVE_DOT_COM case DEMUXER_TYPE_RTP: return demux_rtp_fill_buffer(demux, ds); #endif @@ -540,6 +542,7 @@ extern int demux_audio_open(demuxer_t* demuxer); extern int demux_ogg_open(demuxer_t* demuxer); extern int demux_rawaudio_open(demuxer_t* demuxer); +extern int demux_rawvideo_open(demuxer_t* demuxer); extern int smjpeg_check_file(demuxer_t *demuxer); extern int demux_open_smjpeg(demuxer_t* demuxer); extern int bmp_check_file(demuxer_t *demuxer); @@ -548,6 +551,7 @@ extern demuxer_t* init_avi_with_ogg(demuxer_t* demuxer); extern int use_rawaudio; +extern int use_rawvideo; int extension_parsing=1; // 0=off 1=mixed (used only for unstable formats) @@ -575,6 +579,10 @@ demuxer = new_demuxer(stream,DEMUXER_TYPE_RAWAUDIO,audio_id,video_id,dvdsub_id); file_format = DEMUXER_TYPE_RAWAUDIO; } +if(use_rawvideo) { + demuxer = new_demuxer(stream,DEMUXER_TYPE_RAWVIDEO,audio_id,video_id,dvdsub_id); + file_format = DEMUXER_TYPE_RAWVIDEO; +} #ifdef USE_TV //=============== Try to open as TV-input: ================= @@ -920,6 +928,10 @@ demux_rawaudio_open(demuxer); break; } + case DEMUXER_TYPE_RAWVIDEO: { + demux_rawvideo_open(demuxer); + break; + } case DEMUXER_TYPE_MF: { if (!demux_open_mf(demuxer)) return NULL; break; @@ -1147,6 +1159,7 @@ extern void demux_demuxers_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); extern void demux_ogg_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); extern void demux_rawaudio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); +extern void demux_rawvideo_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); extern void demux_xmms_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){ @@ -1229,6 +1242,8 @@ #endif case DEMUXER_TYPE_RAWAUDIO: demux_rawaudio_seek(demuxer,rel_seek_secs,flags); break; + case DEMUXER_TYPE_RAWVIDEO: + demux_rawvideo_seek(demuxer,rel_seek_secs,flags); break; #ifdef HAVE_XMMS case DEMUXER_TYPE_XMMS: demux_xmms_seek(demuxer,rel_seek_secs,flags); break;
--- a/libmpdemux/demuxer.h Wed Jan 22 22:30:44 2003 +0000 +++ b/libmpdemux/demuxer.h Wed Jan 22 23:51:04 2003 +0000 @@ -34,11 +34,12 @@ #define DEMUXER_TYPE_PVA 23 #define DEMUXER_TYPE_SMJPEG 24 #define DEMUXER_TYPE_XMMS 25 +#define DEMUXER_TYPE_RAWVIDEO 26 // This should always match the higest demuxer type number. // Unless you want to disallow users to force the demuxer to some types #define DEMUXER_TYPE_MIN 0 -#define DEMUXER_TYPE_MAX 23 +#define DEMUXER_TYPE_MAX 26 #define DEMUXER_TYPE_DEMUXERS (1<<16) // A virtual demuxer type for the network code