annotate libmpdemux/muxer.c @ 17065:cf6bfdf41143

Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
author reynaldo
date Tue, 29 Nov 2005 22:04:57 +0000
parents dd5be8f8d16d
children 60189cd9bbc8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
1
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
2 #include <stdio.h>
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
3 #include <stdlib.h>
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
4 #include <string.h>
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
5 #include <inttypes.h>
8591
35bfd508bf5f FreeBSD fix
nexus
parents: 8585
diff changeset
6 #include <unistd.h>
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
7
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
8 #include "config.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15794
diff changeset
9 #include "version.h"
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
10
12341
0db4a3a5b01d removed loader/ dependancy, imported some files from g2, also used patches from Dominik Mierzejewski
alex
parents: 12016
diff changeset
11 #include "aviheader.h"
0db4a3a5b01d removed loader/ dependancy, imported some files from g2, also used patches from Dominik Mierzejewski
alex
parents: 12016
diff changeset
12 #include "ms_hdr.h"
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
13
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
14 #include "muxer.h"
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: 12341
diff changeset
15 #include "stream.h"
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12341
diff changeset
16 #include "demuxer.h"
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12341
diff changeset
17 #include "mp_msg.h"
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12341
diff changeset
18 #include "help_mp.h"
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12341
diff changeset
19 #include "stheader.h"
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
20
9007
12fc55eb3373 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8591
diff changeset
21 muxer_t *muxer_new_muxer(int type,FILE *f){
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
22 muxer_t* muxer=malloc(sizeof(muxer_t));
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
23 memset(muxer,0,sizeof(muxer_t));
9007
12fc55eb3373 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8591
diff changeset
24 muxer->file = f;
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
25 switch (type) {
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
26 case MUXER_TYPE_MPEG:
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: 12341
diff changeset
27 if(! muxer_init_muxer_mpeg(muxer))
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12341
diff changeset
28 return NULL;
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
29 break;
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents: 9007
diff changeset
30 case MUXER_TYPE_RAWVIDEO:
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: 12341
diff changeset
31 if(! muxer_init_muxer_rawvideo(muxer))
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12341
diff changeset
32 return NULL;
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents: 9007
diff changeset
33 break;
15794
59e8dcea6d9e messed up ordering of cases, special delivery of Cola to Tobias
henry
parents: 15754
diff changeset
34 case MUXER_TYPE_RAWAUDIO:
59e8dcea6d9e messed up ordering of cases, special delivery of Cola to Tobias
henry
parents: 15754
diff changeset
35 if(! muxer_init_muxer_rawaudio(muxer))
59e8dcea6d9e messed up ordering of cases, special delivery of Cola to Tobias
henry
parents: 15754
diff changeset
36 return NULL;
59e8dcea6d9e messed up ordering of cases, special delivery of Cola to Tobias
henry
parents: 15754
diff changeset
37 break;
14757
7a2adc5e8928 initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents: 14753
diff changeset
38 #ifdef USE_LIBAVFORMAT
7a2adc5e8928 initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents: 14753
diff changeset
39 case MUXER_TYPE_LAVF:
7a2adc5e8928 initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents: 14753
diff changeset
40 if(! muxer_init_muxer_lavf(muxer))
7a2adc5e8928 initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents: 14753
diff changeset
41 return NULL;
7a2adc5e8928 initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents: 14753
diff changeset
42 break;
7a2adc5e8928 initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents: 14753
diff changeset
43 #endif
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
44 case MUXER_TYPE_AVI:
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
45 default:
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: 12341
diff changeset
46 if(! muxer_init_muxer_avi(muxer))
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12341
diff changeset
47 return NULL;
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
48 }
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
49 return muxer;
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents:
diff changeset
50 }
17023
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
51
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
52 /* buffer frames until we either:
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
53 * (a) have at least one frame from each stream
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
54 * (b) run out of memory */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
55 void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags) {
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
56 if (s->muxer->muxbuf_skip_buffer) {
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
57 s->muxer->cont_write_chunk(s, len, flags);
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
58 }
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
59 else {
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
60 int num = s->muxer->muxbuf_num++;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
61 muxbuf_t *buf, *tmp;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
62
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
63 tmp = realloc(s->muxer->muxbuf, (num+1) * sizeof(muxbuf_t));
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
64 if(!tmp) {
17065
cf6bfdf41143 Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
reynaldo
parents: 17023
diff changeset
65 mp_msg(MSGT_MUXER, MSGL_FATAL, MSGTR_MuxbufReallocErr);
17023
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
66 return;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
67 }
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
68 s->muxer->muxbuf = tmp;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
69 buf = s->muxer->muxbuf + num;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
70
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
71 /* buffer this frame */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
72 buf->stream = s;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
73 buf->timer = s->timer;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
74 buf->len = len;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
75 buf->flags = flags;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
76 buf->buffer = malloc(len * sizeof (unsigned char));
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
77 if (!buf->buffer) {
17065
cf6bfdf41143 Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
reynaldo
parents: 17023
diff changeset
78 mp_msg(MSGT_MUXER, MSGL_FATAL, MSGTR_MuxbufMallocErr);
17023
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
79 return;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
80 }
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
81 memcpy(buf->buffer, s->buffer, buf->len);
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
82 s->muxbuf_seen = 1;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
83
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
84 /* see if we need to keep buffering */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
85 s->muxer->muxbuf_skip_buffer = 1;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
86 for (num = 0; s->muxer->streams[num]; ++num)
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
87 if (!s->muxer->streams[num]->muxbuf_seen)
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
88 s->muxer->muxbuf_skip_buffer = 0;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
89
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
90 /* see if we can flush buffer now */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
91 if (s->muxer->muxbuf_skip_buffer) {
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
92 muxbuf_t *tmp_buf = malloc(sizeof(muxbuf_t));
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
93 if (!tmp_buf) {
17065
cf6bfdf41143 Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
reynaldo
parents: 17023
diff changeset
94 mp_msg(MSGT_MUXER, MSGL_FATAL, MSGTR_MuxbufMallocErr);
17023
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
95 return;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
96 }
17065
cf6bfdf41143 Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
reynaldo
parents: 17023
diff changeset
97 mp_msg(MSGT_MUXER, MSGL_V, MSGTR_MuxbufSending, s->muxer->muxbuf_num);
17023
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
98
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
99 /* fix parameters for all streams */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
100 for (num = 0; s->muxer->streams[num]; ++num) {
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
101 muxer_stream_t *str = s->muxer->streams[num];
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
102 if(str->muxer->fix_stream_parameters)
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
103 muxer_stream_fix_parameters(str->muxer, str);
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
104 }
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
105
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
106 /* write header */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
107 if (s->muxer->cont_write_header)
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
108 muxer_write_header(s->muxer);
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
109
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
110 /* send all buffered frames to muxer */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
111 for (num = 0; num < s->muxer->muxbuf_num; ++num) {
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
112 buf = s->muxer->muxbuf + num;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
113 s = buf->stream;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
114
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
115 /* 1. save timer and buffer (might have changed by now) */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
116 tmp_buf->timer = s->timer;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
117 tmp_buf->buffer = s->buffer;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
118
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
119 /* 2. move stored timer and buffer into stream and mux it */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
120 s->timer = buf->timer;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
121 s->buffer = buf->buffer;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
122 s->muxer->cont_write_chunk(s, buf->len, buf->flags);
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
123
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
124 /* 3. restore saved timer and buffer */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
125 s->timer = tmp_buf->timer;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
126 s->buffer = tmp_buf->buffer;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
127 }
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
128 free(tmp_buf);
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
129
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
130 free(s->muxer->muxbuf);
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
131 s->muxer->muxbuf_num = 0;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
132 }
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
133 }
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
134
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
135 /* this code moved directly from muxer_avi.c */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
136 // alter counters:
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
137 if(s->h.dwSampleSize){
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
138 // CBR
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
139 s->h.dwLength+=len/s->h.dwSampleSize;
17065
cf6bfdf41143 Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
reynaldo
parents: 17023
diff changeset
140 if(len%s->h.dwSampleSize) mp_msg(MSGT_MUXER, MSGL_WARN, MSGTR_WarningLenIsntDivisible);
17023
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
141 } else {
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
142 // VBR
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
143 s->h.dwLength++;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
144 }
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
145 s->timer=(double)s->h.dwLength*s->h.dwScale/s->h.dwRate;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
146 s->size+=len;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
147
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
148 return;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
149 }
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 17012
diff changeset
150