changeset 12016:b962aaad2940

rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
author ranma
date Tue, 09 Mar 2004 14:46:34 +0000
parents d99a02f51a70
children 21e5cb258a95
files DOCS/man/en/mplayer.1 cfg-mencoder.h libmpdemux/Makefile libmpdemux/muxer.c libmpdemux/muxer.h libmpdemux/muxer_rawvideo.c mencoder.c
diffstat 7 files changed, 113 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Tue Mar 09 06:57:28 2004 +0000
+++ b/DOCS/man/en/mplayer.1	Tue Mar 09 14:46:34 2004 +0000
@@ -3840,6 +3840,8 @@
 encode to avi (default)
 .IPs "\-of mpeg"
 encode to mpeg
+.IPs "\-of rawvideo"
+raw video stream (no muxing - video only, one stream only)
 .RE
 .PD 1
 .
--- a/cfg-mencoder.h	Tue Mar 09 06:57:28 2004 +0000
+++ b/cfg-mencoder.h	Tue Mar 09 14:46:34 2004 +0000
@@ -151,9 +151,11 @@
 m_option_t of_conf[]={
 	{"avi", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_AVI, NULL},
 	{"mpeg", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_MPEG, NULL},
+	{"rawvideo", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_RAWVIDEO, NULL},
 	{"help", "\nAvailable output formats:\n"
 	"   avi      - Microsoft Audio/Video Interleaved\n"
 	"   mpeg     - MPEG-1 system stream format\n"
+	"   rawvideo - (video only, one stream only) raw stream, no muxing\n"
 	"\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
--- a/libmpdemux/Makefile	Tue Mar 09 06:57:28 2004 +0000
+++ b/libmpdemux/Makefile	Tue Mar 09 14:46:34 2004 +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_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.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_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.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_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.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_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c muxer_rawvideo.c
 ifeq ($(XMMS_PLUGINS),yes)
 SRCS += demux_xmms.c
 endif 
--- a/libmpdemux/muxer.c	Tue Mar 09 06:57:28 2004 +0000
+++ b/libmpdemux/muxer.c	Tue Mar 09 14:46:34 2004 +0000
@@ -22,6 +22,9 @@
       case MUXER_TYPE_MPEG:
 	muxer_init_muxer_mpeg(muxer);
 	break;
+      case MUXER_TYPE_RAWVIDEO:
+        muxer_init_muxer_rawvideo(muxer);
+	break;
       case MUXER_TYPE_AVI:
       default:
 	muxer_init_muxer_avi(muxer);
--- a/libmpdemux/muxer.h	Tue Mar 09 06:57:28 2004 +0000
+++ b/libmpdemux/muxer.h	Tue Mar 09 14:46:34 2004 +0000
@@ -6,6 +6,7 @@
 
 #define MUXER_TYPE_AVI 0
 #define MUXER_TYPE_MPEG 1
+#define MUXER_TYPE_RAWVIDEO 2
 
 #define MUXER_MPEG_BLOCKSIZE 2048	// 2048 or 2324 - ?
 
@@ -75,4 +76,4 @@
 
 void muxer_init_muxer_avi(muxer_t *);
 void muxer_init_muxer_mpeg(muxer_t *);
-
+void muxer_init_muxer_rawvideo(muxer_t *);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmpdemux/muxer_rawvideo.c	Tue Mar 09 14:46:34 2004 +0000
@@ -0,0 +1,99 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "../version.h"
+
+//#include "stream.h"
+//#include "demuxer.h"
+//#include "stheader.h"
+
+#include "wine/mmreg.h"
+#include "wine/avifmt.h"
+#include "wine/vfw.h"
+#include "bswap.h"
+
+#include "muxer.h"
+
+static muxer_stream_t* rawvideofile_new_stream(muxer_t *muxer,int type){
+    muxer_stream_t* s;
+    if (!muxer) return NULL;
+    if (type == MUXER_TYPE_AUDIO) {
+	printf("Rawvideo muxer does not support audio !\n");
+	return NULL;
+    }
+    if(muxer->avih.dwStreams>=1){
+	printf("Too many streams! Rawvideo muxer supports only one video stream !\n");
+	return NULL;
+    }
+    s=malloc(sizeof(muxer_stream_t));
+    memset(s,0,sizeof(muxer_stream_t));
+    if(!s) return NULL; // no mem!?
+    muxer->streams[muxer->avih.dwStreams]=s;
+    s->type=type;
+    s->id=muxer->avih.dwStreams;
+    s->timer=0.0;
+    s->size=0;
+    s->muxer=muxer;
+    switch(type){
+    case MUXER_TYPE_VIDEO:
+      s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c');
+      s->h.fccType=streamtypeVIDEO;
+      if(!muxer->def_v) muxer->def_v=s;
+      break;
+    default:
+      printf("WarninG! unknown stream type: %d\n",type);
+      return NULL;
+    }
+    muxer->avih.dwStreams++;
+    return s;
+}
+
+static void write_rawvideo_chunk(FILE *f,int len,void* data){
+    if(len>0){
+	if(data){
+	    // DATA
+	    fwrite(data,len,1,f);
+	}
+    }
+}
+
+static void rawvideofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){
+    muxer_t *muxer=s->muxer;
+
+    // write out the chunk:
+    write_rawvideo_chunk(muxer->file,len,s->buffer); /* unsigned char */
+
+    // alter counters:
+    if(s->h.dwSampleSize){
+	// CBR
+	s->h.dwLength+=len/s->h.dwSampleSize;
+	if(len%s->h.dwSampleSize) printf("Warning! len isn't divisable by samplesize!\n");
+    } else {
+	// VBR
+	s->h.dwLength++;
+    }
+    s->timer=(double)s->h.dwLength*s->h.dwScale/s->h.dwRate;
+    s->size+=len;
+    // if((unsigned int)len>s->h.dwSuggestedBufferSize) s->h.dwSuggestedBufferSize=len;
+
+}
+
+static void rawvideofile_write_header(muxer_t *muxer){
+    return;
+}
+
+static void rawvideofile_write_index(muxer_t *muxer){
+    return;
+}
+
+void muxer_init_muxer_rawvideo(muxer_t *muxer){
+  muxer->cont_new_stream = &rawvideofile_new_stream;
+  muxer->cont_write_chunk = &rawvideofile_write_chunk;
+  muxer->cont_write_header = &rawvideofile_write_header;
+  muxer->cont_write_index = &rawvideofile_write_index;
+}
--- a/mencoder.c	Tue Mar 09 06:57:28 2004 +0000
+++ b/mencoder.c	Tue Mar 09 14:46:34 2004 +0000
@@ -527,6 +527,10 @@
     mp_msg(MSGT_MENCODER,MSGL_INFO,"input fps will be interpreted as %5.2f instead\n", sh_video->fps);
   }
 
+  if(sh_audio && out_file_format==MUXER_TYPE_RAWVIDEO){
+      mp_msg(MSGT_MENCODER,MSGL_ERR,"Output file format RAWVIDEO does not support audio - disabling audio\n");
+      sh_audio=NULL;
+  }
   if(sh_audio && out_audio_codec<0){
     if(audio_id==-2)
 	mp_msg(MSGT_MENCODER,MSGL_ERR,"This demuxer doesn't support -nosound yet.\n");