summaryrefslogtreecommitdiff
path: root/libavformat/matroskadec.c
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2008-09-28 23:06:25 +0000
committerAurelien Jacobs <aurel@gnuage.org>2008-09-28 23:06:25 +0000
commitd5e34dcb727c0888924fafaa260f9524742a8813 (patch)
tree28d07f0199721677d25a1c61beb282e719d97c8a /libavformat/matroskadec.c
parent3df2be9fa7365646f22a93cfde1e4097467f498e (diff)
downloadffmpeg-d5e34dcb727c0888924fafaa260f9524742a8813.tar.gz
matroskadec: merge ASS events which share the same pts in the same AVPavket
Originally committed as revision 15455 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r--libavformat/matroskadec.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 42f570c6f7..a0e259c3b5 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -205,6 +205,7 @@ typedef struct {
/* the packet queue */
AVPacket **packets;
int num_packets;
+ AVPacket *prev_pkt;
int done;
int has_cluster_id;
@@ -964,6 +965,15 @@ static void matroska_fix_ass_packet(MatroskaDemuxContext *matroska,
}
}
+static void matroska_merge_packets(AVPacket *out, AVPacket *in)
+{
+ out->data = av_realloc(out->data, out->size+in->size);
+ memcpy(out->data+out->size, in->data, in->size);
+ out->size += in->size;
+ av_destruct_packet(in);
+ av_free(in);
+}
+
static void matroska_convert_tags(AVFormatContext *s, EbmlList *list)
{
MatroskaTag *tags = list->elem;
@@ -1629,7 +1639,14 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
if (st->codec->codec_id == CODEC_ID_SSA)
matroska_fix_ass_packet(matroska, pkt, duration);
+ if (matroska->prev_pkt &&
+ matroska->prev_pkt->pts == timecode &&
+ matroska->prev_pkt->stream_index == st->index)
+ matroska_merge_packets(matroska->prev_pkt, pkt);
+ else {
dynarray_add(&matroska->packets, &matroska->num_packets, pkt);
+ matroska->prev_pkt = pkt;
+ }
}
if (timecode != AV_NOPTS_VALUE)
@@ -1649,6 +1666,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska)
MatroskaBlock *blocks;
int i, res;
offset_t pos = url_ftell(matroska->ctx->pb);
+ matroska->prev_pkt = NULL;
if (matroska->has_cluster_id){
/* For the first cluster we parse, its ID was already read as
part of matroska_read_header(), so don't read it again */