# HG changeset patch # User aurel # Date 1222643185 0 # Node ID 0ebebd2ba034fbf5a525ae7929e08ebeebb8261c # Parent f1a9ff04eb4b9e2010aba2e62a2557164846e128 matroskadec: merge ASS events which share the same pts in the same AVPavket diff -r f1a9ff04eb4b -r 0ebebd2ba034 matroskadec.c --- a/matroskadec.c Sun Sep 28 23:01:07 2008 +0000 +++ b/matroskadec.c Sun Sep 28 23:06:25 2008 +0000 @@ -205,6 +205,7 @@ /* the packet queue */ AVPacket **packets; int num_packets; + AVPacket *prev_pkt; int done; int has_cluster_id; @@ -964,6 +965,15 @@ } } +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 @@ 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 @@ 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 */