Mercurial > mplayer.hg
comparison libmpdemux/muxer_rawvideo.c @ 12016:b962aaad2940
rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
author | ranma |
---|---|
date | Tue, 09 Mar 2004 14:46:34 +0000 |
parents | |
children | ca4c07c87e6f |
comparison
equal
deleted
inserted
replaced
12015:d99a02f51a70 | 12016:b962aaad2940 |
---|---|
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" | |
14 | |
15 #include "wine/mmreg.h" | |
16 #include "wine/avifmt.h" | |
17 #include "wine/vfw.h" | |
18 #include "bswap.h" | |
19 | |
20 #include "muxer.h" | |
21 | |
22 static muxer_stream_t* rawvideofile_new_stream(muxer_t *muxer,int type){ | |
23 muxer_stream_t* s; | |
24 if (!muxer) return NULL; | |
25 if (type == MUXER_TYPE_AUDIO) { | |
26 printf("Rawvideo muxer does not support audio !\n"); | |
27 return NULL; | |
28 } | |
29 if(muxer->avih.dwStreams>=1){ | |
30 printf("Too many streams! Rawvideo muxer supports only one video stream !\n"); | |
31 return NULL; | |
32 } | |
33 s=malloc(sizeof(muxer_stream_t)); | |
34 memset(s,0,sizeof(muxer_stream_t)); | |
35 if(!s) return NULL; // no mem!? | |
36 muxer->streams[muxer->avih.dwStreams]=s; | |
37 s->type=type; | |
38 s->id=muxer->avih.dwStreams; | |
39 s->timer=0.0; | |
40 s->size=0; | |
41 s->muxer=muxer; | |
42 switch(type){ | |
43 case MUXER_TYPE_VIDEO: | |
44 s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c'); | |
45 s->h.fccType=streamtypeVIDEO; | |
46 if(!muxer->def_v) muxer->def_v=s; | |
47 break; | |
48 default: | |
49 printf("WarninG! unknown stream type: %d\n",type); | |
50 return NULL; | |
51 } | |
52 muxer->avih.dwStreams++; | |
53 return s; | |
54 } | |
55 | |
56 static void write_rawvideo_chunk(FILE *f,int len,void* data){ | |
57 if(len>0){ | |
58 if(data){ | |
59 // DATA | |
60 fwrite(data,len,1,f); | |
61 } | |
62 } | |
63 } | |
64 | |
65 static void rawvideofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){ | |
66 muxer_t *muxer=s->muxer; | |
67 | |
68 // write out the chunk: | |
69 write_rawvideo_chunk(muxer->file,len,s->buffer); /* unsigned char */ | |
70 | |
71 // alter counters: | |
72 if(s->h.dwSampleSize){ | |
73 // CBR | |
74 s->h.dwLength+=len/s->h.dwSampleSize; | |
75 if(len%s->h.dwSampleSize) printf("Warning! len isn't divisable by samplesize!\n"); | |
76 } else { | |
77 // VBR | |
78 s->h.dwLength++; | |
79 } | |
80 s->timer=(double)s->h.dwLength*s->h.dwScale/s->h.dwRate; | |
81 s->size+=len; | |
82 // if((unsigned int)len>s->h.dwSuggestedBufferSize) s->h.dwSuggestedBufferSize=len; | |
83 | |
84 } | |
85 | |
86 static void rawvideofile_write_header(muxer_t *muxer){ | |
87 return; | |
88 } | |
89 | |
90 static void rawvideofile_write_index(muxer_t *muxer){ | |
91 return; | |
92 } | |
93 | |
94 void muxer_init_muxer_rawvideo(muxer_t *muxer){ | |
95 muxer->cont_new_stream = &rawvideofile_new_stream; | |
96 muxer->cont_write_chunk = &rawvideofile_write_chunk; | |
97 muxer->cont_write_header = &rawvideofile_write_header; | |
98 muxer->cont_write_index = &rawvideofile_write_index; | |
99 } |