diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2008-06-07 00:49:03 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2008-06-07 00:49:03 +0000 |
commit | 2940b38ef2488f3ad84421cab0f7dc1c13f043fb (patch) | |
tree | 5219f9b014e14ef939d57ee0e92c7409ad4e6b3c /libavformat/ffmenc.c | |
parent | c07d64c8900e845271f81285968d0791613ff6c7 (diff) | |
download | ffmpeg-2940b38ef2488f3ad84421cab0f7dc1c13f043fb.tar.gz |
fix pts handling in ffm
Originally committed as revision 13683 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/ffmenc.c')
-rw-r--r-- | libavformat/ffmenc.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c index e4f7adf540..c07beb989d 100644 --- a/libavformat/ffmenc.c +++ b/libavformat/ffmenc.c @@ -92,7 +92,6 @@ static int ffm_write_header(AVFormatContext *s) { FFMContext *ffm = s->priv_data; AVStream *st; - FFMStream *fst; ByteIOContext *pb = s->pb; AVCodecContext *codec; int bit_rate, i; @@ -116,11 +115,7 @@ static int ffm_write_header(AVFormatContext *s) /* list of streams */ for(i=0;i<s->nb_streams;i++) { st = s->streams[i]; - fst = av_mallocz(sizeof(FFMStream)); - if (!fst) - goto fail; av_set_pts_info(st, 64, 1, 1000000); - st->priv_data = fst; codec = st->codec; /* generic info */ @@ -176,13 +171,14 @@ static int ffm_write_header(AVFormatContext *s) default: return -1; } - /* hack to have real time */ - if (ffm_nopts) - fst->pts = 0; - else - fst->pts = av_gettime(); } + /* hack to have real time */ + if (ffm_nopts) + ffm->start_time = 0; + else + ffm->start_time = av_gettime(); + /* flush until end of block reached */ while ((url_ftell(pb) % ffm->packet_size) != 0) put_byte(pb, 0); @@ -198,22 +194,16 @@ static int ffm_write_header(AVFormatContext *s) ffm->first_packet = 1; return 0; - fail: - for(i=0;i<s->nb_streams;i++) { - st = s->streams[i]; - av_freep(&st->priv_data); - } - return -1; } static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt) { + FFMContext *ffm = s->priv_data; AVStream *st = s->streams[pkt->stream_index]; - FFMStream *fst = st->priv_data; int64_t pts; uint8_t header[FRAME_HEADER_SIZE]; - pts = fst->pts; + pts = ffm->start_time + pkt->pts; /* packet size & key_frame */ header[0] = pkt->stream_index; header[1] = 0; @@ -224,7 +214,6 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt) ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1); ffm_write_data(s, pkt->data, pkt->size, pts, 0); - fst->pts += pkt->duration; return 0; } |