changeset 15754:7b0599d9614a

rawaudio muxer
author ranma
date Sun, 19 Jun 2005 09:12:44 +0000
parents 76083e1c2540
children b1b06adc5cd3
files DOCS/man/de/mplayer.1 DOCS/man/en/mplayer.1 cfg-mencoder.h help/help_mp-de.h help/help_mp-en.h help/help_mp-ja.h libmpdemux/Makefile libmpdemux/muxer.c libmpdemux/muxer.h libmpdemux/muxer_rawaudio.c
diffstat 10 files changed, 116 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/de/mplayer.1	Sat Jun 18 23:16:57 2005 +0000
+++ b/DOCS/man/de/mplayer.1	Sun Jun 19 09:12:44 2005 +0000
@@ -5900,6 +5900,8 @@
 Gib ein MPEG aus.
 .IPs "\-of rawvideo"
 reiner (raw) Videostream (kein Muxing, nur ein Videostream)
+.IPs "\-of rawvideo"
+reiner (raw) Audiostream (kein Muxing, nur ein Audiostream)
 .RE
 .PD 1
 .
--- a/DOCS/man/en/mplayer.1	Sat Jun 18 23:16:57 2005 +0000
+++ b/DOCS/man/en/mplayer.1	Sun Jun 19 09:12:44 2005 +0000
@@ -5697,6 +5697,8 @@
 Encode to MPEG.
 .IPs "\-of rawvideo"
 raw video stream (no muxing \- one video stream only)
+.IPs "\-of rawaudio"
+raw audio stream (no muxing \- one audio stream only)
 .RE
 .PD 1
 .
--- a/cfg-mencoder.h	Sat Jun 18 23:16:57 2005 +0000
+++ b/cfg-mencoder.h	Sun Jun 19 09:12:44 2005 +0000
@@ -182,6 +182,7 @@
 	{"lavf", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_LAVF, NULL},
 #endif
 	{"rawvideo", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_RAWVIDEO, NULL},
+	{"rawaudio", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_RAWAUDIO, NULL},
 	{"help", "\nAvailable output formats:\n"
 	"   avi      - Microsoft Audio/Video Interleaved\n"
 	"   mpeg     - MPEG-1/2 system stream format\n"
@@ -189,6 +190,7 @@
 	"   lavf     - FFmpeg libavformat muxers\n"
 #endif
 	"   rawvideo - (video only, one stream only) raw stream, no muxing\n"
+	"   rawaudio - (audio 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/help/help_mp-de.h	Sat Jun 18 23:16:57 2005 +0000
+++ b/help/help_mp-de.h	Sun Jun 19 09:12:44 2005 +0000
@@ -486,6 +486,13 @@
 #define MSGTR_DVDnoVOBs "Kann VOB-Dateien des Titels  (VTS_%02d_1.VOB) nicht öffnen.\n"
 #define MSGTR_DVDopenOk "DVD erfolgreich geöffnet.\n"
 
+// muxer_*.c:
+#define MSGTR_TooManyStreams "Zu viele Streams!"
+#define MSGTR_RawMuxerOnlyOneStream "Der rawaudio-Muxer unterstützt nur einen Audiostream!\n"
+#define MSGTR_IgnoringVideoStream "Ignoriere Videostream!\n"
+#define MSGTR_UnknownStreamType "Warnung! Unbekannter Streamtyp: %d\n"
+#define MSGTR_WarningLenIsntDivisible "Warnung! 'len' ist nicht durch 'samplesize' teilbar!\n"
+
 // demuxer.c, demux_*.c:
 #define MSGTR_AudioStreamRedefined "Warnung! Audiostream-Header %d neu definiert!\n"
 #define MSGTR_VideoStreamRedefined "Warnung! Videostream-Header %d neu definiert!\n"
--- a/help/help_mp-en.h	Sat Jun 18 23:16:57 2005 +0000
+++ b/help/help_mp-en.h	Sun Jun 19 09:12:44 2005 +0000
@@ -482,6 +482,13 @@
 #define MSGTR_DVDnoVOBs "Cannot open title VOBS (VTS_%02d_1.VOB).\n"
 #define MSGTR_DVDopenOk "DVD successfully opened.\n"
 
+// muxer_*.c:
+#define MSGTR_TooManyStreams "Too many streams!"
+#define MSGTR_RawMuxerOnlyOneStream "Rawaudio muxer supports only one audio stream!\n"
+#define MSGTR_IgnoringVideoStream "Ignoring video stream!\n"
+#define MSGTR_UnknownStreamType "Warning! unknown stream type: %d\n"
+#define MSGTR_WarningLenIsntDivisible "Warning! len isn't divisible by samplesize!\n"
+
 // demuxer.c, demux_*.c:
 #define MSGTR_AudioStreamRedefined "WARNING: Audio stream header %d redefined.\n"
 #define MSGTR_VideoStreamRedefined "WARNING: Video stream header %d redefined.\n"
--- a/help/help_mp-ja.h	Sat Jun 18 23:16:57 2005 +0000
+++ b/help/help_mp-ja.h	Sun Jun 19 09:12:44 2005 +0000
@@ -185,6 +185,13 @@
 #define MSGTR_DVDnoVOBs "Cannot open title VOBS (VTS_%02d_1.VOB).\n"
 #define MSGTR_DVDopenOk "DVD¤ò³«¤¯¤³¤È¤ËÀ®¸ù¤·¤Þ¤·¤¿.\n"
 
+// muxer_*.c:
+#define MSGTR_TooManyStreams "¥¹¥È¥ê¡¼¥à¤¬Â¿²á¤®¤ë!"
+#define MSGTR_RawMuxerOnlyOneStream "Rawaudio muxer¤¬°ì¤Ä¤À¤±¤Î²»À¼¥¹¥È¥ê¡¼¥Þ¤ò¥µ¥Ý¡¼¥È¤·¤Þ¤¹!\n"
+#define MSGTR_IgnoringVideoStream "±ÇÁü¥¹¥È¥ê¡¼¥Þ¤òº¹¤·ÃÖ¤­¤Þ¤¹!\n"
+#define MSGTR_UnknownStreamType "·Ù¹ð: ̤ÃΤΥ¹¥È¥ê¡¼¥à¥¿¥¤¥×: %d\n"
+#define MSGTR_WarningLenIsntDivisible "·Ù¹ð: samplesize¤Çlen¤¬À°½ü¤Ç¤­¤Ê¤¤!\n"
+
 // demuxer.c, demux_*.c:
 #define MSGTR_AudioStreamRedefined "·Ù¹ð: Audio stream header %d redefined.\n"
 #define MSGTR_VideoStreamRedefined "·Ù¹ð: Video stream header %d redefined.\n"
--- a/libmpdemux/Makefile	Sat Jun 18 23:16:57 2005 +0000
+++ b/libmpdemux/Makefile	Sun Jun 19 09:12:44 2005 +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 stream_smb.c stream_vstream.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 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 demux_lavf.c demux_nsv.c demux_vqf.c stream_dvd.c stream_livedotcom.c demux_aac.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 stream_smb.c stream_vstream.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 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 muxer_rawaudio.c demux_lavf.c demux_nsv.c demux_vqf.c stream_dvd.c stream_livedotcom.c demux_aac.c
 ifeq ($(XMMS_PLUGINS),yes)
 SRCS += demux_xmms.c
 endif 
--- a/libmpdemux/muxer.c	Sat Jun 18 23:16:57 2005 +0000
+++ b/libmpdemux/muxer.c	Sun Jun 19 09:12:44 2005 +0000
@@ -41,6 +41,10 @@
       default:
 	if(! muxer_init_muxer_avi(muxer))
 	  return NULL;
+      case MUXER_TYPE_RAWAUDIO:
+        if(! muxer_init_muxer_rawaudio(muxer))
+          return NULL;
+        break;
     }
     return muxer;
 }
--- a/libmpdemux/muxer.h	Sat Jun 18 23:16:57 2005 +0000
+++ b/libmpdemux/muxer.h	Sun Jun 19 09:12:44 2005 +0000
@@ -8,6 +8,7 @@
 #define MUXER_TYPE_MPEG 1
 #define MUXER_TYPE_RAWVIDEO 2
 #define MUXER_TYPE_LAVF 3
+#define MUXER_TYPE_RAWAUDIO 4
 
 
 typedef struct {
@@ -85,3 +86,4 @@
 int muxer_init_muxer_mpeg(muxer_t *);
 int muxer_init_muxer_rawvideo(muxer_t *);
 int muxer_init_muxer_lavf(muxer_t *);
+int muxer_init_muxer_rawaudio(muxer_t *);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmpdemux/muxer_rawaudio.c	Sun Jun 19 09:12:44 2005 +0000
@@ -0,0 +1,82 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "help_mp.h"
+#include "mp_msg.h"
+
+#include "aviheader.h"
+#include "ms_hdr.h"
+
+#include "muxer.h"
+
+static muxer_stream_t* rawaudiofile_new_stream(muxer_t *muxer,int type){
+    muxer_stream_t* s;
+    if (!muxer) return NULL;
+    if(type==MUXER_TYPE_AUDIO && muxer->avih.dwStreams>=1){
+        mp_msg(MSGT_MUXER,MSGL_ERR,MSGTR_TooManyStreams" "MSGTR_RawMuxerOnlyOneStream);
+        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_AUDIO:
+        s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c');
+        s->h.fccType=streamtypeAUDIO;
+        muxer->avih.dwStreams++;
+        break;
+    case MUXER_TYPE_VIDEO:
+        mp_msg(MSGT_MUXER,MSGL_WARN,MSGTR_IgnoringVideoStream);
+        s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c');
+        s->h.fccType=streamtypeAUDIO;
+        break;
+    default:
+        mp_msg(MSGT_MUXER,MSGL_ERR,MSGTR_UnknownStreamType,type);
+        return NULL;
+    }
+    return s;
+}
+
+static void rawaudiofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){
+    muxer_t *muxer=s->muxer;
+
+    // write out the chunk:
+    if (s->type==MUXER_TYPE_AUDIO)
+        fwrite(s->buffer,len,1,muxer->file);
+
+    // alter counters:
+    if(s->h.dwSampleSize){
+        // CBR
+        s->h.dwLength+=len/s->h.dwSampleSize;
+        if(len%s->h.dwSampleSize)
+            mp_msg(MSGT_MUXER,MSGL_WARN,MSGTR_WarningLenIsntDivisible);
+    } else {
+        // VBR
+        s->h.dwLength++;
+    }
+    s->timer=(double)s->h.dwLength*s->h.dwScale/s->h.dwRate;
+    s->size+=len;
+}
+
+static void rawaudiofile_write_header(muxer_t *muxer){
+    return;
+}
+
+static void rawaudiofile_write_index(muxer_t *muxer){
+    return;
+}
+
+int muxer_init_muxer_rawaudio(muxer_t *muxer){
+    muxer->cont_new_stream = &rawaudiofile_new_stream;
+    muxer->cont_write_chunk = &rawaudiofile_write_chunk;
+    muxer->cont_write_header = &rawaudiofile_write_header;
+    muxer->cont_write_index = &rawaudiofile_write_index;
+    return 1;
+}