diff options
| author | cooljqln <cooljqln@noreply.codeberg.org> | 2025-03-19 04:18:10 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2025-03-19 04:18:10 +0000 |
| commit | 5995b3a48e73a19248f3d15b96bdb27144eabca2 (patch) | |
| tree | c85ea1b5d86ff37276f37bc008993a8f940f1f6b /lib/wavpack/metadata.c | |
| parent | 34e7ce869b8d451e0586e96cc4dabbff8efb56d3 (diff) | |
| parent | 885eb1812c15263ad759741ad138cf7188fdf739 (diff) | |
| download | tangara-fw-5995b3a48e73a19248f3d15b96bdb27144eabca2.tar.gz | |
Merge pull request 'WavPack and APEv2 tags support' (#218) from ayumi/tangara-fw:wavpack into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/218
Diffstat (limited to 'lib/wavpack/metadata.c')
| -rw-r--r-- | lib/wavpack/metadata.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/lib/wavpack/metadata.c b/lib/wavpack/metadata.c new file mode 100644 index 00000000..b80e905a --- /dev/null +++ b/lib/wavpack/metadata.c @@ -0,0 +1,105 @@ +////////////////////////////////////////////////////////////////////////////
+// **** WAVPACK **** //
+// Hybrid Lossless Wavefile Compressor //
+// Copyright (c) 1998 - 2006 Conifer Software. //
+// All Rights Reserved. //
+// Distributed under the BSD Software License (see license.txt) //
+////////////////////////////////////////////////////////////////////////////
+
+// metadata.c
+
+// This module handles the metadata structure introduced in WavPack 4.0
+
+#include "wavpack.h"
+
+int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd)
+{
+ uchar tchar;
+
+ if (!wpc->infile (wpc->user_data, &wpmd->id, 1) || !wpc->infile (wpc->user_data, &tchar, 1))
+ return FALSE;
+
+ wpmd->byte_length = tchar << 1;
+
+ if (wpmd->id & ID_LARGE) {
+ wpmd->id &= ~ID_LARGE;
+
+ if (!wpc->infile (wpc->user_data, &tchar, 1))
+ return FALSE;
+
+ wpmd->byte_length += (int32_t) tchar << 9;
+
+ if (!wpc->infile (wpc->user_data, &tchar, 1))
+ return FALSE;
+
+ wpmd->byte_length += (int32_t) tchar << 17;
+ }
+
+ if (wpmd->id & ID_ODD_SIZE) {
+ wpmd->id &= ~ID_ODD_SIZE;
+ wpmd->byte_length--;
+ }
+
+ if (wpmd->byte_length && wpmd->byte_length <= sizeof (wpc->read_buffer)) {
+ uint32_t bytes_to_read = wpmd->byte_length + (wpmd->byte_length & 1);
+
+ if (wpc->infile (wpc->user_data, wpc->read_buffer, bytes_to_read) != (int32_t) bytes_to_read) {
+ wpmd->data = NULL;
+ return FALSE;
+ }
+
+ wpmd->data = wpc->read_buffer;
+ }
+ else
+ wpmd->data = NULL;
+
+ return TRUE;
+}
+
+int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd)
+{
+ WavpackStream *wps = &wpc->stream;
+
+ switch (wpmd->id) {
+ case ID_DUMMY:
+ return TRUE;
+
+ case ID_DECORR_TERMS:
+ return read_decorr_terms (wps, wpmd);
+
+ case ID_DECORR_WEIGHTS:
+ return read_decorr_weights (wps, wpmd);
+
+ case ID_DECORR_SAMPLES:
+ return read_decorr_samples (wps, wpmd);
+
+ case ID_ENTROPY_VARS:
+ return read_entropy_vars (wps, wpmd);
+
+ case ID_HYBRID_PROFILE:
+ return read_hybrid_profile (wps, wpmd);
+
+ case ID_FLOAT_INFO:
+ return read_float_info (wps, wpmd);
+
+ case ID_INT32_INFO:
+ return read_int32_info (wps, wpmd);
+
+ case ID_CHANNEL_INFO:
+ return read_channel_info (wpc, wpmd);
+
+ case ID_CONFIG_BLOCK:
+ return read_config_info (wpc, wpmd);
+
+ case ID_WV_BITSTREAM:
+ return init_wv_bitstream (wpc, wpmd);
+
+ case ID_SHAPING_WEIGHTS:
+ case ID_WVC_BITSTREAM:
+ case ID_WVX_BITSTREAM:
+ return TRUE;
+
+ default:
+ return (wpmd->id & ID_OPTIONAL_DATA) ? TRUE : FALSE;
+ }
+}
|
