summaryrefslogtreecommitdiffstats
path: root/libavformat/matroskadec.c
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2008-05-13 23:32:13 +0000
committerAurelien Jacobs <aurel@gnuage.org>2008-05-13 23:32:13 +0000
commitfbb878ce0fa60cb84dfd821f4aa9687398c2c70a (patch)
tree7dbff7ba40fbccc6683cacbf0e5e3e185794b633 /libavformat/matroskadec.c
parent40a655e306d253b393f465a437be566d28f4b25e (diff)
downloadffmpeg-streaming-fbb878ce0fa60cb84dfd821f4aa9687398c2c70a.zip
ffmpeg-streaming-fbb878ce0fa60cb84dfd821f4aa9687398c2c70a.tar.gz
matroskadec: add support for zlib compressed tracks
Originally committed as revision 13151 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r--libavformat/matroskadec.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index e71ea3a..40dcc9c 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -35,6 +35,9 @@
#include "libavcodec/mpeg4audio.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/lzo.h"
+#ifdef CONFIG_ZLIB
+#include <zlib.h>
+#endif
typedef struct Track {
MatroskaTrackType type;
@@ -1500,6 +1503,9 @@ matroska_add_stream (MatroskaDemuxContext *matroska)
if ((res = ebml_read_uint(matroska, &id, &num)) < 0)
break;
if (num != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP &&
+#ifdef CONFIG_ZLIB
+ num != MATROSKA_TRACK_ENCODING_COMP_ZLIB &&
+#endif
num != MATROSKA_TRACK_ENCODING_COMP_LZO)
av_log(matroska->ctx, AV_LOG_ERROR,
"Unsupported compression algo");
@@ -2720,6 +2726,30 @@ matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size,
}
pkt_size -= olen;
break;
+#ifdef CONFIG_ZLIB
+ case MATROSKA_TRACK_ENCODING_COMP_ZLIB: {
+ z_stream zstream = {0};
+ pkt_data = NULL;
+ if (inflateInit(&zstream) != Z_OK)
+ continue;
+ zstream.next_in = data;
+ zstream.avail_in = lace_size[n];
+ do {
+ pkt_size *= 3;
+ pkt_data = av_realloc(pkt_data, pkt_size);
+ zstream.avail_out = pkt_size - zstream.total_out;
+ zstream.next_out = pkt_data + zstream.total_out;
+ result = inflate(&zstream, Z_NO_FLUSH);
+ } while (result==Z_OK && pkt_size<10000000);
+ pkt_size = zstream.total_out;
+ inflateEnd(&zstream);
+ if (result != Z_STREAM_END) {
+ av_free(pkt_data);
+ continue;
+ }
+ break;
+ }
+#endif
}
}
OpenPOWER on IntegriCloud