Browse Source

decomp: add Zstandard support

pull/162/head
Rémi Denis-Courmont 3 years ago
parent
commit
272b3f85f4
  1. 1
      NEWS
  2. 25
      modules/stream_filter/decomp.c

1
NEWS

@ -69,6 +69,7 @@ Access:
* Deprecates Audio CD CDDB lookups in favor of more accurate Musicbrainz
* Improved CD-TEXT and added Shift-JIS encoding support
* Support for YoutubeDL (where available).
* On-the-fly Zstandard (zstd) file decompression (where available).
Access output:
* Added support for the RIST (Reliable Internet Stream Transport) Protocol

25
modules/stream_filter/decomp.c

@ -46,12 +46,17 @@
static int OpenGzip (vlc_object_t *);
static int OpenBzip2 (vlc_object_t *);
static int OpenXZ (vlc_object_t *);
static int OpenZstd(vlc_object_t *);
static void Close (vlc_object_t *);
vlc_module_begin ()
set_subcategory (SUBCAT_INPUT_STREAM_FILTER)
set_capability ("stream_filter", 320)
set_description (N_("Zstandard decompression"))
set_callbacks (OpenZstd, Close)
add_submodule ()
set_description (N_("LZMA decompression"))
set_callbacks (OpenXZ, Close)
@ -396,3 +401,23 @@ static int OpenXZ (vlc_object_t *obj)
msg_Dbg (obj, "detected xz compressed stream");
return Open (stream, "xzcat");
}
/**
* Detects zstd file format
*/
static int OpenZstd(vlc_object_t *obj)
{
stream_t *stream = (stream_t *)obj;
const uint8_t *peek;
/* (Try to) parse the Zstd frame header (minimum size is 6 bytes) */
if (vlc_stream_Peek(stream->s, &peek, 6) < 6)
return VLC_ENOTSUP;
if (memcmp(peek, "\x28\xb5\x2f\xfd", 4)) /* magic number */
return VLC_ENOTSUP;
if (peek[4] & 0x08) /* reserved bit */
return VLC_ENOTSUP;
msg_Dbg(obj, "detected zstd compressed stream");
return Open(stream, "zstdcat");
}

Loading…
Cancel
Save