Fix:
[mplayer/glamo.git] / libmpdemux / muxer_rawvideo.c
blobfda4eb8bacd1d24a02e4ba9e8bad8df8c176b038
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <inttypes.h>
6 #include <unistd.h>
8 #include "config.h"
9 #include "version.h"
11 //#include "stream.h"
12 //#include "demuxer.h"
13 //#include "stheader.h"
14 #include "aviheader.h"
15 #include "ms_hdr.h"
17 #include "bswap.h"
19 #include "muxer.h"
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;
40 muxer->avih.dwStreams++;
41 return s;
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);
53 static void rawvideofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts, double pts){
54 muxer_t *muxer=s->muxer;
56 // write out the chunk:
57 if (s->type == MUXER_TYPE_VIDEO)
58 write_rawvideo_chunk(muxer->file,len,s->buffer); /* unsigned char */
60 // if((unsigned int)len>s->h.dwSuggestedBufferSize) s->h.dwSuggestedBufferSize=len;
64 static void rawvideofile_write_header(muxer_t *muxer){
65 return;
68 static void rawvideofile_write_index(muxer_t *muxer){
69 return;
72 int muxer_init_muxer_rawvideo(muxer_t *muxer){
73 muxer->cont_new_stream = &rawvideofile_new_stream;
74 muxer->cont_write_chunk = &rawvideofile_write_chunk;
75 muxer->cont_write_header = &rawvideofile_write_header;
76 muxer->cont_write_index = &rawvideofile_write_index;
77 return 1;