Mercurial > libavformat.hg
changeset 3298:edabe3db2b6e libavformat
matroskadec: add support for bzlib compressed tracks
author | aurel |
---|---|
date | Thu, 15 May 2008 23:12:41 +0000 |
parents | df2df4c07d12 |
children | 80a497804aa8 |
files | matroskadec.c |
diffstat | 1 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/matroskadec.c Thu May 15 22:47:40 2008 +0000 +++ b/matroskadec.c Thu May 15 23:12:41 2008 +0000 @@ -38,6 +38,9 @@ #ifdef CONFIG_ZLIB #include <zlib.h> #endif +#ifdef CONFIG_BZLIB +#include <bzlib.h> +#endif typedef struct Track { MatroskaTrackType type; @@ -1506,6 +1509,9 @@ #ifdef CONFIG_ZLIB num != MATROSKA_TRACK_ENCODING_COMP_ZLIB && #endif +#ifdef CONFIG_BZLIB + num != MATROSKA_TRACK_ENCODING_COMP_BZLIB && +#endif num != MATROSKA_TRACK_ENCODING_COMP_LZO) av_log(matroska->ctx, AV_LOG_ERROR, "Unsupported compression algo\n"); @@ -2750,6 +2756,30 @@ break; } #endif +#ifdef CONFIG_BZLIB + case MATROSKA_TRACK_ENCODING_COMP_BZLIB: { + bz_stream bzstream = {0}; + pkt_data = NULL; + if (BZ2_bzDecompressInit(&bzstream, 0, 0) != BZ_OK) + continue; + bzstream.next_in = data; + bzstream.avail_in = lace_size[n]; + do { + pkt_size *= 3; + pkt_data = av_realloc(pkt_data, pkt_size); + bzstream.avail_out = pkt_size - bzstream.total_out_lo32; + bzstream.next_out = pkt_data + bzstream.total_out_lo32; + result = BZ2_bzDecompress(&bzstream); + } while (result==BZ_OK && pkt_size<10000000); + pkt_size = bzstream.total_out_lo32; + BZ2_bzDecompressEnd(&bzstream); + if (result != BZ_STREAM_END) { + av_free(pkt_data); + continue; + } + break; + } +#endif } }