mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:16:13 +00:00
matroskademux: Unify zlib/bzip2 decompress loops with the ones from qtdemux
Especially, simplify the code a bit.
This commit is contained in:
parent
6939399e96
commit
d3bc50bc8f
1 changed files with 23 additions and 19 deletions
|
@ -106,25 +106,27 @@ gst_matroska_decompress_data (GstMatroskaTrackEncoding * enc,
|
||||||
|
|
||||||
do {
|
do {
|
||||||
result = inflate (&zstream, Z_NO_FLUSH);
|
result = inflate (&zstream, Z_NO_FLUSH);
|
||||||
if (result != Z_OK && result != Z_STREAM_END) {
|
if (result == Z_STREAM_END) {
|
||||||
GST_WARNING ("zlib decompression failed.");
|
break;
|
||||||
g_free (new_data);
|
} else if (result != Z_OK) {
|
||||||
inflateEnd (&zstream);
|
GST_WARNING ("inflate() returned %d", result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
new_size += 4000;
|
|
||||||
|
new_size += 4096;
|
||||||
new_data = g_realloc (new_data, new_size);
|
new_data = g_realloc (new_data, new_size);
|
||||||
zstream.next_out = (Bytef *) (new_data + zstream.total_out);
|
zstream.next_out = (Bytef *) (new_data + zstream.total_out);
|
||||||
zstream.avail_out += 4000;
|
zstream.avail_out += 4096;
|
||||||
} while (zstream.avail_in != 0 && result != Z_STREAM_END);
|
} while (zstream.avail_in > 0);
|
||||||
|
|
||||||
if (result != Z_STREAM_END) {
|
if (result != Z_STREAM_END) {
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
goto out;
|
g_free (new_data);
|
||||||
} else {
|
} else {
|
||||||
new_size = zstream.total_out;
|
new_size = zstream.total_out;
|
||||||
inflateEnd (&zstream);
|
|
||||||
}
|
}
|
||||||
|
inflateEnd (&zstream);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
GST_WARNING ("zlib encoded tracks not supported.");
|
GST_WARNING ("zlib encoded tracks not supported.");
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
|
@ -157,25 +159,27 @@ gst_matroska_decompress_data (GstMatroskaTrackEncoding * enc,
|
||||||
|
|
||||||
do {
|
do {
|
||||||
result = BZ2_bzDecompress (&bzstream);
|
result = BZ2_bzDecompress (&bzstream);
|
||||||
if (result != BZ_OK && result != BZ_STREAM_END) {
|
if (result == BZ_STREAM_END) {
|
||||||
GST_WARNING ("bzip2 decompression failed.");
|
break;
|
||||||
g_free (new_data);
|
} else if (result != BZ_OK) {
|
||||||
BZ2_bzDecompressEnd (&bzstream);
|
GST_WARNING ("BZ2_bzDecompress() returned %d", result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
new_size += 4000;
|
|
||||||
|
new_size += 4096;
|
||||||
new_data = g_realloc (new_data, new_size);
|
new_data = g_realloc (new_data, new_size);
|
||||||
bzstream.next_out = (char *) (new_data + bzstream.total_out_lo32);
|
bzstream.next_out = (char *) (new_data + bzstream.total_out_lo32);
|
||||||
bzstream.avail_out += 4000;
|
bzstream.avail_out += 4096;
|
||||||
} while (bzstream.avail_in != 0 && result != BZ_STREAM_END);
|
} while (bzstream.avail_in > 0);
|
||||||
|
|
||||||
if (result != BZ_STREAM_END) {
|
if (result != BZ_STREAM_END) {
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
goto out;
|
g_free (new_data);
|
||||||
} else {
|
} else {
|
||||||
new_size = bzstream.total_out_lo32;
|
new_size = bzstream.total_out_lo32;
|
||||||
BZ2_bzDecompressEnd (&bzstream);
|
|
||||||
}
|
}
|
||||||
|
BZ2_bzDecompressEnd (&bzstream);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
GST_WARNING ("bzip2 encoded tracks not supported.");
|
GST_WARNING ("bzip2 encoded tracks not supported.");
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
|
@ -198,7 +202,7 @@ gst_matroska_decompress_data (GstMatroskaTrackEncoding * enc,
|
||||||
result = lzo1x_decode (new_data, &out_size, data, &orig_size);
|
result = lzo1x_decode (new_data, &out_size, data, &orig_size);
|
||||||
|
|
||||||
if (orig_size > 0) {
|
if (orig_size > 0) {
|
||||||
new_size += 4000;
|
new_size += 4096;
|
||||||
new_data = g_realloc (new_data, new_size);
|
new_data = g_realloc (new_data, new_size);
|
||||||
}
|
}
|
||||||
} while (orig_size > 0 && result == LZO_OUTPUT_FULL);
|
} while (orig_size > 0 && result == LZO_OUTPUT_FULL);
|
||||||
|
|
Loading…
Reference in a new issue