Mercurial > mplayer.hg
annotate libmpdemux/muxer_rawvideo.c @ 15555:806cd20f1c8f
Use the public sys/kbio.h header instead of messing with the MI headers, which
doesn't exist anymore on DragonFly. Approved by the FreeBSD ports maintainer.
patch by Joerg Sonnenberger <joerg - at - britannica - bec - de>
author | diego |
---|---|
date | Mon, 23 May 2005 21:24:47 +0000 |
parents | 70c446099f40 |
children | 50fb26acbcba |
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 if (type == MUXER_TYPE_AUDIO) { | |
25 printf("Rawvideo muxer does not support audio !\n"); | |
26 return NULL; | |
27 } | |
28 if(muxer->avih.dwStreams>=1){ | |
29 printf("Too many streams! Rawvideo muxer supports only one video stream !\n"); | |
30 return NULL; | |
31 } | |
32 s=malloc(sizeof(muxer_stream_t)); | |
33 memset(s,0,sizeof(muxer_stream_t)); | |
34 if(!s) return NULL; // no mem!? | |
35 muxer->streams[muxer->avih.dwStreams]=s; | |
36 s->type=type; | |
37 s->id=muxer->avih.dwStreams; | |
38 s->timer=0.0; | |
39 s->size=0; | |
40 s->muxer=muxer; | |
41 switch(type){ | |
42 case MUXER_TYPE_VIDEO: | |
43 s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c'); | |
44 s->h.fccType=streamtypeVIDEO; | |
45 if(!muxer->def_v) muxer->def_v=s; | |
46 break; | |
47 default: | |
48 printf("WarninG! unknown stream type: %d\n",type); | |
49 return NULL; | |
50 } | |
51 muxer->avih.dwStreams++; | |
52 return s; | |
53 } | |
54 | |
55 static void write_rawvideo_chunk(FILE *f,int len,void* data){ | |
56 if(len>0){ | |
57 if(data){ | |
58 // DATA | |
59 fwrite(data,len,1,f); | |
60 } | |
61 } | |
62 } | |
63 | |
64 static void rawvideofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){ | |
65 muxer_t *muxer=s->muxer; | |
66 | |
67 // write out the chunk: | |
68 write_rawvideo_chunk(muxer->file,len,s->buffer); /* unsigned char */ | |
69 | |
70 // alter counters: | |
71 if(s->h.dwSampleSize){ | |
72 // CBR | |
73 s->h.dwLength+=len/s->h.dwSampleSize; | |
74 if(len%s->h.dwSampleSize) printf("Warning! len isn't divisable by samplesize!\n"); | |
75 } else { | |
76 // VBR | |
77 s->h.dwLength++; | |
78 } | |
79 s->timer=(double)s->h.dwLength*s->h.dwScale/s->h.dwRate; | |
80 s->size+=len; | |
81 // if((unsigned int)len>s->h.dwSuggestedBufferSize) s->h.dwSuggestedBufferSize=len; | |
82 | |
83 } | |
84 | |
85 static void rawvideofile_write_header(muxer_t *muxer){ | |
86 return; | |
87 } | |
88 | |
89 static void rawvideofile_write_index(muxer_t *muxer){ | |
90 return; | |
91 } | |
92 | |
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
|
93 int muxer_init_muxer_rawvideo(muxer_t *muxer){ |
12016 | 94 muxer->cont_new_stream = &rawvideofile_new_stream; |
95 muxer->cont_write_chunk = &rawvideofile_write_chunk; | |
96 muxer->cont_write_header = &rawvideofile_write_header; | |
97 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
|
98 return 1; |
12016 | 99 } |