summaryrefslogtreecommitdiff
path: root/apps/codecs/libwavpack/metadata.c
diff options
context:
space:
mode:
authorChristian Gmeiner <christian.gmeiner@gmail.com>2005-02-25 17:05:30 +0000
committerChristian Gmeiner <christian.gmeiner@gmail.com>2005-02-25 17:05:30 +0000
commite449d88b3e6b584998f8f38ed61467c35ca74466 (patch)
tree307e87242fd5fbf45d7424bb5afad17b9dd34429 /apps/codecs/libwavpack/metadata.c
parent234489a449e13d99b76daff61ff7774226d21a5b (diff)
downloadrockbox-e449d88b3e6b584998f8f38ed61467c35ca74466.tar.gz
rockbox-e449d88b3e6b584998f8f38ed61467c35ca74466.zip
Initial import of libwavpack
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6056 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libwavpack/metadata.c')
-rw-r--r--apps/codecs/libwavpack/metadata.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/apps/codecs/libwavpack/metadata.c b/apps/codecs/libwavpack/metadata.c
new file mode 100644
index 0000000000..40ede99cd4
--- /dev/null
+++ b/apps/codecs/libwavpack/metadata.c
@@ -0,0 +1,105 @@
1////////////////////////////////////////////////////////////////////////////
2// **** WAVPACK **** //
3// Hybrid Lossless Wavefile Compressor //
4// Copyright (c) 1998 - 2003 Conifer Software. //
5// All Rights Reserved. //
6// Distributed under the BSD Software License (see license.txt) //
7////////////////////////////////////////////////////////////////////////////
8
9// metadata.c
10
11// This module handles the metadata structure introduced in WavPack 4.0
12
13#include "wavpack.h"
14
15int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd)
16{
17 uchar tchar;
18
19 if (!wpc->infile (&wpmd->id, 1) || !wpc->infile (&tchar, 1))
20 return FALSE;
21
22 wpmd->byte_length = tchar << 1;
23
24 if (wpmd->id & ID_LARGE) {
25 wpmd->id &= ~ID_LARGE;
26
27 if (!wpc->infile (&tchar, 1))
28 return FALSE;
29
30 wpmd->byte_length += (long) tchar << 9;
31
32 if (!wpc->infile (&tchar, 1))
33 return FALSE;
34
35 wpmd->byte_length += (long) tchar << 17;
36 }
37
38 if (wpmd->id & ID_ODD_SIZE) {
39 wpmd->id &= ~ID_ODD_SIZE;
40 wpmd->byte_length--;
41 }
42
43 if (wpmd->byte_length && wpmd->byte_length <= sizeof (wpc->read_buffer)) {
44 ulong bytes_to_read = wpmd->byte_length + (wpmd->byte_length & 1);
45
46 if (wpc->infile (wpc->read_buffer, bytes_to_read) != (long) bytes_to_read) {
47 wpmd->data = NULL;
48 return FALSE;
49 }
50
51 wpmd->data = wpc->read_buffer;
52 }
53 else
54 wpmd->data = NULL;
55
56 return TRUE;
57}
58
59int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd)
60{
61 WavpackStream *wps = &wpc->stream;
62
63 switch (wpmd->id) {
64 case ID_DUMMY:
65 return TRUE;
66
67 case ID_DECORR_TERMS:
68 return read_decorr_terms (wps, wpmd);
69
70 case ID_DECORR_WEIGHTS:
71 return read_decorr_weights (wps, wpmd);
72
73 case ID_DECORR_SAMPLES:
74 return read_decorr_samples (wps, wpmd);
75
76 case ID_ENTROPY_VARS:
77 return read_entropy_vars (wps, wpmd);
78
79 case ID_HYBRID_PROFILE:
80 return read_hybrid_profile (wps, wpmd);
81
82 case ID_FLOAT_INFO:
83 return read_float_info (wps, wpmd);
84
85 case ID_INT32_INFO:
86 return read_int32_info (wps, wpmd);
87
88 case ID_CHANNEL_INFO:
89 return read_channel_info (wpc, wpmd);
90
91 case ID_CONFIG_BLOCK:
92 return read_config_info (wpc, wpmd);
93
94 case ID_WV_BITSTREAM:
95 return init_wv_bitstream (wpc, wpmd);
96
97 case ID_SHAPING_WEIGHTS:
98 case ID_WVC_BITSTREAM:
99 case ID_WVX_BITSTREAM:
100 return TRUE;
101
102 default:
103 return (wpmd->id & ID_OPTIONAL_DATA) ? TRUE : FALSE;
104 }
105}