diff options
author | David Conrad <lessen42@gmail.com> | 2010-03-09 04:23:36 +0000 |
---|---|---|
committer | David Conrad <lessen42@gmail.com> | 2010-03-09 04:23:36 +0000 |
commit | f9ff7179ff901aa1e2721ff2d13482a792e6e82f (patch) | |
tree | 05fecf221bc1a843d9fa0008baad30b9ffd2445a /libavformat/matroskaenc.c | |
parent | 654b65d01229ad3016d34c4189d8b31f5981f570 (diff) | |
download | ffmpeg-streaming-f9ff7179ff901aa1e2721ff2d13482a792e6e82f.zip ffmpeg-streaming-f9ff7179ff901aa1e2721ff2d13482a792e6e82f.tar.gz |
mkvenc: Handle negative timestamps correctly
Originally committed as revision 22372 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r-- | libavformat/matroskaenc.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c0d4f1b..e26e31a 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -72,9 +72,9 @@ typedef struct MatroskaMuxContext { int64_t segment_uid; ebml_master cluster; int64_t cluster_pos; ///< file offset of the current cluster - uint64_t cluster_pts; + int64_t cluster_pts; int64_t duration_offset; - uint64_t duration; + int64_t duration; mkv_seekhead *main_seekhead; mkv_seekhead *cluster_seekhead; mkv_cues *cues; @@ -355,6 +355,9 @@ static int mkv_add_cuepoint(mkv_cues *cues, int stream, int64_t ts, int64_t clus if (entries == NULL) return AVERROR(ENOMEM); + if (ts < 0) + return 0; + entries[cues->num_entries ].pts = ts; entries[cues->num_entries ].tracknum = stream + 1; entries[cues->num_entries++].cluster_pos = cluster_pos - cues->segment_offset; @@ -883,8 +886,8 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) mkv->cluster_pos = url_ftell(s->pb); mkv->cluster = start_ebml_master(pb, MATROSKA_ID_CLUSTER, 0); - put_ebml_uint(pb, MATROSKA_ID_CLUSTERTIMECODE, ts); - mkv->cluster_pts = ts; + put_ebml_uint(pb, MATROSKA_ID_CLUSTERTIMECODE, FFMAX(0, ts)); + mkv->cluster_pts = FFMAX(0, ts); av_md5_update(mkv->md5_ctx, pkt->data, FFMIN(200, pkt->size)); } |