annotate libmpdemux/muxer_rawvideo.c @ 22371:45d4cffd5180

cosmetics, missing space patch by Zuxy Meng, zuxy dot meng ... gmail com
author ivo
date Thu, 01 Mar 2007 10:58:20 +0000
parents ca9da45d13e9
children 4d81dbdf46b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
1
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
2 #include <stdio.h>
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
3 #include <stdlib.h>
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
4 #include <string.h>
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
5 #include <inttypes.h>
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
6 #include <unistd.h>
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
7
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
8 #include "config.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16805
diff changeset
9 #include "version.h"
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
10
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
11 //#include "stream.h"
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
12 //#include "demuxer.h"
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
13 //#include "stheader.h"
13183
ca4c07c87e6f use correct headers
rathann
parents: 12016
diff changeset
14 #include "aviheader.h"
ca4c07c87e6f use correct headers
rathann
parents: 12016
diff changeset
15 #include "ms_hdr.h"
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
16
21660
ca9da45d13e9 muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents: 21421
diff changeset
17 #include "stream.h"
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
18 #include "muxer.h"
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
19
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
20 static muxer_stream_t* rawvideofile_new_stream(muxer_t *muxer,int type){
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
21 muxer_stream_t* s;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
22 if (!muxer) return NULL;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
23 s=malloc(sizeof(muxer_stream_t));
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
24 memset(s,0,sizeof(muxer_stream_t));
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
25 if(!s) return NULL; // no mem!?
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
26 muxer->streams[muxer->avih.dwStreams]=s;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
27 s->type=type;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
28 s->id=muxer->avih.dwStreams;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
29 s->timer=0.0;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
30 s->size=0;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
31 s->muxer=muxer;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
32 switch(type){
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
33 case MUXER_TYPE_VIDEO:
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
34 s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c');
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
35 s->h.fccType=streamtypeVIDEO;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
36 if(!muxer->def_v) muxer->def_v=s;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
37 break;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
38 }
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
39 muxer->avih.dwStreams++;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
40 return s;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
41 }
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
42
21660
ca9da45d13e9 muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents: 21421
diff changeset
43 static void write_rawvideo_chunk(stream_t *stream,int len,void* data){
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
44 if(len>0){
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
45 if(data){
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
46 // DATA
21660
ca9da45d13e9 muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents: 21421
diff changeset
47 stream_write_buffer(stream,data,len);
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
48 }
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
49 }
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
50 }
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
51
17487
fa17424b4c7b change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents: 17023
diff changeset
52 static void rawvideofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts, double pts){
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
53 muxer_t *muxer=s->muxer;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
54
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
55 // write out the chunk:
16805
50fb26acbcba processing audio is sometimes essential for a/v sync, so 1000l to
rfelker
parents: 14753
diff changeset
56 if (s->type == MUXER_TYPE_VIDEO)
21660
ca9da45d13e9 muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents: 21421
diff changeset
57 write_rawvideo_chunk(muxer->stream,len,s->buffer); /* unsigned char */
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
58
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
59 // if((unsigned int)len>s->h.dwSuggestedBufferSize) s->h.dwSuggestedBufferSize=len;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
60
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
61 }
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
62
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
63 static void rawvideofile_write_header(muxer_t *muxer){
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
64 return;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
65 }
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
66
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
67 static void rawvideofile_write_index(muxer_t *muxer){
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
68 return;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
69 }
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
70
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
71 int muxer_init_muxer_rawvideo(muxer_t *muxer){
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
72 muxer->cont_new_stream = &rawvideofile_new_stream;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
73 muxer->cont_write_chunk = &rawvideofile_write_chunk;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
74 muxer->cont_write_header = &rawvideofile_write_header;
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
75 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
76 return 1;
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents:
diff changeset
77 }