rawaudio muxer
authorranma <ranma@b3059339-0415-0410-9bf9-f77b7e298cf2>
Sun, 19 Jun 2005 09:12:44 +0000 (09:12 +0000)
committerranma <ranma@b3059339-0415-0410-9bf9-f77b7e298cf2>
Sun, 19 Jun 2005 09:12:44 +0000 (09:12 +0000)
git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@15755 b3059339-0415-0410-9bf9-f77b7e298cf2

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 [new file with mode: 0644]

index eadf439..940bfa1 100644 (file)
@@ -5900,6 +5900,8 @@ Gib ein AVI aus (Standard).
 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
 .
index 8867c33..81d0af3 100644 (file)
@@ -5697,6 +5697,8 @@ Encode to AVI.
 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
 .
index 2cfe168..682635e 100644 (file)
@@ -182,6 +182,7 @@ m_option_t of_conf[]={
        {"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 @@ m_option_t of_conf[]={
        "   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}
 };
index 7053c8d..597edac 100644 (file)
@@ -486,6 +486,13 @@ static char help_text[]=
 #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"
index 2bba485..2fa2fb5 100644 (file)
@@ -482,6 +482,13 @@ static char help_text[]=
 #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"
index c243f9d..89c3138 100644 (file)
@@ -185,6 +185,13 @@ static char help_text[]=
 #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"
index 051c8dd..97b118f 100644 (file)
@@ -3,7 +3,7 @@ LIBNAME = libmpdemux.a
 
 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 
index c3b4a4b..a3337f5 100644 (file)
@@ -41,6 +41,10 @@ muxer_t *muxer_new_muxer(int type,FILE *f){
       default:
        if(! muxer_init_muxer_avi(muxer))
          return NULL;
+      case MUXER_TYPE_RAWAUDIO:
+        if(! muxer_init_muxer_rawaudio(muxer))
+          return NULL;
+        break;
     }
     return muxer;
 }
index 28395d7..caa6068 100644 (file)
@@ -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_avi(muxer_t *);
 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 *);
diff --git a/libmpdemux/muxer_rawaudio.c b/libmpdemux/muxer_rawaudio.c
new file mode 100644 (file)
index 0000000..86cb7b9
--- /dev/null
@@ -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;
+}