]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - wma_common.c
wma: Clean up compute_high_band_values().
[paraslash.git] / wma_common.c
index 0df19ae9e0599707338b6c0e2273e4bd69b6d3d1..dab96257d09876916240817811508c31c45b29d6 100644 (file)
 #include "imdct.h"
 #include "wma.h"
 
-const char *search_pattern(const char *pattern, int pattern_len, const char *buf, int buf_size)
+/**
+ * Find the first occurrence of the given pattern.
+ *
+ * \param pattern The pattern to search for.
+ * \param pattern_len The length of the pattern in bytes.
+ * \param buf The buffer to search for the pattern.
+ * \param buf_size The number of bytes in \a buf.
+ */
+const char *search_pattern(const char *pattern, int pattern_len,
+               const char *buf, int buf_size)
 {
        const char *p, *end = buf + buf_size;
 
+       /* TODO: Use suffix arrays to speed up the search. */
        for (p = buf; p + pattern_len < end; p++) {
                if (memcmp(p, pattern, pattern_len))
                        continue;
-               PARA_DEBUG_LOG("found %d byte pattern@%d\n",
+               PARA_DEBUG_LOG("found %d byte pattern@%zd\n",
                        pattern_len, p - buf);
                return p;
        }
@@ -125,6 +135,13 @@ const uint8_t log2_tab[256] = {
        7, 7, 7, 7, 7, 7, 7, 7
 };
 
+/**
+ * Compute the base-2 logarithm.
+ *
+ * \param v The value to compute the logarithm of.
+ *
+ * \return An integer approximation of log2(v).
+ */
 int wma_log2(unsigned int v)
 {
        int n = 0;