Mercurial > mplayer.hg
annotate libmpdemux/muxer_rawvideo.c @ 16805:50fb26acbcba
processing audio is sometimes essential for a/v sync, so 1000l to
whoever made rawvideo muxer disable audio!!
with this patch, audio is processed but simply thrown away by the
muxer. various 'error' conditions in rawvideo muxer are removed to
make it work. feel free to re-add them if they can be done without
breaking anything, but do not use printf !!!!
btw old behavior can be obtained by manually specifying -nosound.
author | rfelker |
---|---|
date | Wed, 19 Oct 2005 05:44:27 +0000 |
parents | 70c446099f40 |
children | 6ff3379a0862 |
rev | line source |
---|---|
12016 | 1 |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
4 #include <string.h> | |
5 #include <inttypes.h> | |
6 #include <unistd.h> | |
7 | |
8 #include "config.h" | |
9 #include "../version.h" | |
10 | |
11 //#include "stream.h" | |
12 //#include "demuxer.h" | |
13 //#include "stheader.h" | |
13183 | 14 #include "aviheader.h" |
15 #include "ms_hdr.h" | |
12016 | 16 |
17 #include "bswap.h" | |
18 | |
19 #include "muxer.h" | |
20 | |
21 static muxer_stream_t* rawvideofile_new_stream(muxer_t *muxer,int type){ | |
22 muxer_stream_t* s; | |
23 if (!muxer) return NULL; | |
24 s=malloc(sizeof(muxer_stream_t)); | |
25 memset(s,0,sizeof(muxer_stream_t)); | |
26 if(!s) return NULL; // no mem!? | |
27 muxer->streams[muxer->avih.dwStreams]=s; | |
28 s->type=type; | |
29 s->id=muxer->avih.dwStreams; | |
30 s->timer=0.0; | |
31 s->size=0; | |
32 s->muxer=muxer; | |
33 switch(type){ | |
34 case MUXER_TYPE_VIDEO: | |
35 s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c'); | |
36 s->h.fccType=streamtypeVIDEO; | |
37 if(!muxer->def_v) muxer->def_v=s; | |
38 break; | |
39 } | |
40 muxer->avih.dwStreams++; | |
41 return s; | |
42 } | |
43 | |
44 static void write_rawvideo_chunk(FILE *f,int len,void* data){ | |
45 if(len>0){ | |
46 if(data){ | |
47 // DATA | |
48 fwrite(data,len,1,f); | |
49 } | |
50 } | |
51 } | |
52 | |
53 static void rawvideofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){ | |
54 muxer_t *muxer=s->muxer; | |
55 | |
56 // write out the chunk: | |
16805
50fb26acbcba
processing audio is sometimes essential for a/v sync, so 1000l to
rfelker
parents:
14753
diff
changeset
|
57 if (s->type == MUXER_TYPE_VIDEO) |
12016 | 58 write_rawvideo_chunk(muxer->file,len,s->buffer); /* unsigned char */ |
59 | |
60 // alter counters: | |
61 if(s->h.dwSampleSize){ | |
62 // CBR | |
63 s->h.dwLength+=len/s->h.dwSampleSize; | |
64 if(len%s->h.dwSampleSize) printf("Warning! len isn't divisable by samplesize!\n"); | |
65 } else { | |
66 // VBR | |
67 s->h.dwLength++; | |
68 } | |
69 s->timer=(double)s->h.dwLength*s->h.dwScale/s->h.dwRate; | |
70 s->size+=len; | |
71 // if((unsigned int)len>s->h.dwSuggestedBufferSize) s->h.dwSuggestedBufferSize=len; | |
72 | |
73 } | |
74 | |
75 static void rawvideofile_write_header(muxer_t *muxer){ | |
76 return; | |
77 } | |
78 | |
79 static void rawvideofile_write_index(muxer_t *muxer){ | |
80 return; | |
81 } | |
82 | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
13183
diff
changeset
|
83 int muxer_init_muxer_rawvideo(muxer_t *muxer){ |
12016 | 84 muxer->cont_new_stream = &rawvideofile_new_stream; |
85 muxer->cont_write_chunk = &rawvideofile_write_chunk; | |
86 muxer->cont_write_header = &rawvideofile_write_header; | |
87 muxer->cont_write_index = &rawvideofile_write_index; | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
13183
diff
changeset
|
88 return 1; |
12016 | 89 } |