X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=wma_common.c;h=10633b5b7e46f5193782ecb5e13b1a57e2991459;hp=0df19ae9e0599707338b6c0e2273e4bd69b6d3d1;hb=fae6ed3cc6d240eefcc111bdd04f637e3cda5dd0;hpb=84c3f9183674c561772dc4064e1b32a1e76ea8a3 diff --git a/wma_common.c b/wma_common.c index 0df19ae9..10633b5b 100644 --- a/wma_common.c +++ b/wma_common.c @@ -21,10 +21,20 @@ #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; @@ -46,7 +56,7 @@ static int find_audio_stream_info(const char *buf, int len) if (!p) return -E_WMA_NO_GUID; - PARA_DEBUG_LOG("found audio stream guid@%0zx\n", p - buf); + PARA_DEBUG_LOG("found audio stream guid@%0x\n", p - buf); return p - buf + 16; } @@ -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;