summaryrefslogtreecommitdiffstats
path: root/libmpdemux/muxer.c
diff options
context:
space:
mode:
authormichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-01-26 19:32:07 +0000
committermichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-01-26 19:32:07 +0000
commite6338c5858795c42ca45afbabe8b765d8050db58 (patch)
treea7fd45468aa20213219dbcd0e7b57cf9ceae628c /libmpdemux/muxer.c
parent24f25bfa8153252b87327f7fff5358b791ef4c2d (diff)
downloadmpv-e6338c5858795c42ca45afbabe8b765d8050db58.tar.bz2
mpv-e6338c5858795c42ca45afbabe8b765d8050db58.tar.xz
change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17488 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/muxer.c')
-rw-r--r--libmpdemux/muxer.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/libmpdemux/muxer.c b/libmpdemux/muxer.c
index e2da4efa3b..0a075886e6 100644
--- a/libmpdemux/muxer.c
+++ b/libmpdemux/muxer.c
@@ -52,9 +52,12 @@ muxer_t *muxer_new_muxer(int type,FILE *f){
/* buffer frames until we either:
* (a) have at least one frame from each stream
* (b) run out of memory */
-void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags) {
+void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double dts, double pts) {
+ if(dts == MP_NOPTS_VALUE) dts= s->timer;
+ if(pts == MP_NOPTS_VALUE) pts= s->timer; // this is wrong
+
if (s->muxer->muxbuf_skip_buffer) {
- s->muxer->cont_write_chunk(s, len, flags);
+ s->muxer->cont_write_chunk(s, len, flags, dts, pts);
}
else {
int num = s->muxer->muxbuf_num++;
@@ -70,7 +73,8 @@ void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags) {
/* buffer this frame */
buf->stream = s;
- buf->timer = s->timer;
+ buf->dts= dts;
+ buf->pts= pts;
buf->len = len;
buf->flags = flags;
buf->buffer = malloc(len * sizeof (unsigned char));
@@ -89,11 +93,6 @@ void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags) {
/* see if we can flush buffer now */
if (s->muxer->muxbuf_skip_buffer) {
- muxbuf_t *tmp_buf = malloc(sizeof(muxbuf_t));
- if (!tmp_buf) {
- mp_msg(MSGT_MUXER, MSGL_FATAL, MSGTR_MuxbufMallocErr);
- return;
- }
mp_msg(MSGT_MUXER, MSGL_V, MSGTR_MuxbufSending, s->muxer->muxbuf_num);
/* fix parameters for all streams */
@@ -109,23 +108,23 @@ void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags) {
/* send all buffered frames to muxer */
for (num = 0; num < s->muxer->muxbuf_num; ++num) {
+ muxbuf_t tmp_buf;
buf = s->muxer->muxbuf + num;
s = buf->stream;
/* 1. save timer and buffer (might have changed by now) */
- tmp_buf->timer = s->timer;
- tmp_buf->buffer = s->buffer;
+ tmp_buf.dts = s->timer;
+ tmp_buf.buffer = s->buffer;
/* 2. move stored timer and buffer into stream and mux it */
- s->timer = buf->timer;
+ s->timer = buf->dts;
s->buffer = buf->buffer;
- s->muxer->cont_write_chunk(s, buf->len, buf->flags);
+ s->muxer->cont_write_chunk(s, buf->len, buf->flags, buf->dts, buf->pts);
/* 3. restore saved timer and buffer */
- s->timer = tmp_buf->timer;
- s->buffer = tmp_buf->buffer;
+ s->timer = tmp_buf.dts;
+ s->buffer = tmp_buf.buffer;
}
- free(tmp_buf);
free(s->muxer->muxbuf);
s->muxer->muxbuf_num = 0;