[vlc-commits] [Git][videolan/vlc][master] decomp: add Zstandard support

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Jan 16 06:12:13 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
272b3f85 by Rémi Denis-Courmont at 2024-01-15T18:59:09+02:00
decomp: add Zstandard support

- - - - -


2 changed files:

- NEWS
- modules/stream_filter/decomp.c


Changes:

=====================================
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


=====================================
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");
+}



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/272b3f85f474180b19ec17ab6e1b53ab4dddbc43

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/272b3f85f474180b19ec17ab6e1b53ab4dddbc43
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list