summaryrefslogtreecommitdiff
path: root/wmadec_filter.c (follow)
Commit message (Collapse)AuthorAge
* doxygen: Hide user_data variables.Andre Noll2025-10-08
| | | | | These just clutter the generated documentation, particularly the list of global variables.
* Merge topic branch t/wmadec into masterAndre Noll2025-06-02
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few patches which remove unused code from the wma decoder and audio format handler. Notably, noise coding was removed completely since it was only used for unusual bit rates. Most likely, it never worked in the first place. * refs/heads/t/wmadec: wmadec: Fix typo in comment. wmadec: Remove a stale comment in wma_init(). wmadec: Kill pointless start/end computations. wmadec: Remove noise coding. wmadec: Simplify wma_init(). wmadec: Remove fft().
| * wmadec: Fix typo in comment.Andre Noll2025-05-21
| |
| * wmadec: Remove a stale comment in wma_init().Andre Noll2025-05-21
| | | | | | | | | | | | Noise coding has been removed. Fixes: 9fe8a674535a00c6011f86b4ece3344200d00aa2
| * wmadec: Kill pointless start/end computations.Andre Noll2025-05-20
| | | | | | | | | | | | | | Neither start nor end are used. The loop simply adds up the entries of one line of the exponent_bands matrix. Found by the clang analyzer.
| * wmadec: Remove noise coding.Andre Noll2025-04-27
| | | | | | | | | | It is not used anyway in most cases, and it complicates the code considerably.
| * wmadec: Simplify wma_init().Andre Noll2025-04-27
| | | | | | | | | | This equivalent transformation saves a few lines and one level of indentation.
* | Include regex.h from para.h.Andre Noll2025-05-19
|/ | | | Every .c file includes it anyway.
* Constify buffer tree API.Andre Noll2024-05-08
| | | | | | A lot of functions of the buffer tree API don't modify the memory referenced by the pointers passed. This patch marks these pointer arguments as constant.
* Consolidate EOF error codes.Andre Noll2023-03-11
| | | | | | Currently we have ~15 error codes which indicate an EOF condition. One should suffice, so drop all codes except the generic E_EOF and use that everywhere.
* Merge topic branch t/overflow into masterAndre Noll2022-10-03
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This series implements a new memory allocation API which checks for overflows. The first part of the series just renames the main allocation functions. Later patches in the series implement allocators which take two size_t arguments (like calloc(3)) and check whether the multiplication overflows by employing the __builtin_mul_overflow() primitive supported by gcc and clang. This requires us to bump the lowest supported gcc and clang version. * refs/heads/t/overflow: build: Compile with -ftrapv. string: Introduce arr_zalloc(). string: Introduce arr_alloc(). string: Introduce arr_realloc() and check for integer overflow. string: Rename para_calloc() -> zalloc(). string: Rename para_malloc() -> alloc(). string: Overhaul para_strdup().
| * string: Introduce arr_alloc().Andre Noll2022-07-29
| | | | | | | | | | | | | | | | Change all callers of alloc() which pass a product of two integers as the allocation size to call the new function instead. This function aborts if the multiplication overflows. With arr_alloc() in place, alloc() reduces to a trivial wrapper which calls new arr_alloc() with the first argument equal to one.
| * string: Rename para_calloc() -> zalloc().Andre Noll2022-07-29
| | | | | | | | | | Reword the documentation a bit since the function has never been a wrapper for calloc(3). No code changes.
| * string: Rename para_malloc() -> alloc().Andre Noll2022-07-29
| | | | | | | | | | | | | | Just because it's shorter and matches the naming of the new allocators we are about to introduce. The bulk of this patch was created with sed -i 's/para_malloc/alloc/g' *.c *.h yy/mp.y
* | Switch from select(2) to poll(2).Andre Noll2022-08-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The select(2) API is kind of obsolete because it does not work for file descriptors greater or equal than 1024, The general advice is to switch to poll(2), which offers equivalent functionality and does not suffer from this restriction. This patch implements this switch. The fd sets of select(2) have one nice feature: One can determine in O(1) time whether the bit for a given fd is turned on in an fd set. For poll(2), the monitored file descriptors are organized in an array of struct pollfd. Without information about the given fd's index in the pollfd array, one can only perform a linear search which requires O(n) time, with n being the number of fds being watched. Since this would have to be done for each fd, the running time becomes quadratic in the number of monitored fds, which is bad. Keeping the pollfd array sorted would reduce that to n * log(n) at the cost of additional work at insert time. This patch implements a different approach. The scheduler now maintains an additional array of unsigned integers which map fds to indices into the pollfd array. This new index array is transparent to the individual tasks, which still simply pass one or more fds from their ->pre_monitor() method to the scheduler. The length of the index array equals the highest fd given. This might become prohibitive in theory, but should not be an issue for the time being. Care needs to be taken in order to deal with callers which ask for the readiness of an fd without having called sched_monitor_readfd() or sched_monitor_writefd() in the ->pre_monitor() step. Before the patch, thanks to the FD_ZERO() call at the beginning of each iteration of the scheduler's main loop, both sched_read_ok() and sched_write_ok() returned false for fds which were not asked to be watched. We need to keep it this way for a seamless transition. We achieve this by replacing the FD_ZERO() call by a memset(3) call which fills the index array with 0xff bytes. Both sched_read_ok() and sched_write_ok() call the new get_revents() helper, where we check the fd argument against the allocation sizes of the two arrays. If either function is called with an fd that was not asked to be monitored in the ->pre_monitor() step, the checks notice that the index of this fd, 0xffffffff, is larger than the highest open fd and we return "not ready for I/O". Another issue is the case where the same file descriptor is submitted twice in ->pre_monitor() to check for readiness with respect to both reading and writing. The code in client_comon.c currently does that. To keep it working, the scheduler needs to detect this case and re-use the existing slot in both arrays.
* | Rename ->{pre,post}_select methods to ->{pre,post}_monitor.Andre Noll2022-08-25
|/ | | | | | | The word "monitor" is neutral and continues to be correct after the switch from select(2) to poll(2). Pure rename, nothing to see here.
* Shorten copyright notice.Andre Noll2017-09-22
| | | | | | | | | | | | | | | | | | | | | The GPLv2 line does not add any additional information, so drop it. This leaves a single line of legalese text for most files, which is about the amount of screen real estate it deserves. This patch was created with the following script (plus some manual fixups): awk '{ if (NR <= 5) { gs = gensub(/.*Copyright.* ([0-9]+).*Andre Noll.*/, "\\1", "g") if (gs != $0) year = gs next } if (NR == 6 && year != "") printf("/* Copyright (C) %s Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */\n", year) print }'
* wma: Remove _XOPEN_SOURCE define from wmadec_filter.c.Andre Noll2017-07-06
| | | | | | It has been there since day one of the wma decoder with no indication why it is needed. The code compiles fine without it on all supported platforms, so get rid of it.
* wma: make ->ms_stereo local to wma_decode_block().Andre Noll2017-07-06
| | | | | mid/side stereo mode is a per-block property and thus does not need to be stored in the private_wmadec_data structure.
* wma: Simplify init_coef_vlc().Andre Noll2017-07-06
| | | | | | | | This function of wmadec_filter.c was unnecessarily convoluted. The patched version should be equivalent, and easier to understand. This also allows to get rid of ->coef_vlcs of struct private_wmadec_data, which was utterly confusing since we also have ->coef_vlc.
* wma: Rename input/output buffer variables.Andre Noll2017-07-06
| | | | | The naming was confusing. With the new names it is clear which buffer is used for input and which for output.
* wma: Drop unused argument from wma_decode_superframe().Andre Noll2017-07-06
| | | | | | The function depends on the caller not passing a smaller value than the packet size - WMA_FRAME_SKIP, and only uses this many input bytes anyway. So we may get rid of the input size argument.
* wma: Remove pointless/incorrect sanity checks.Andre Noll2017-07-06
| | | | | | | | In wma_decode_superframe() we check the size of the input buffer twice. Both checks are redundant because the input queue size of the wmadec filter node already makes sure we never pass a smaller value. The second check is in fact wrong, because pwd->ahi.packet_size - WMA_FRAME_SKIP would be the correct limit to check.
* wma: Combine wmadec_cleanup() and wmadec_close().Andre Noll2017-07-06
| | | | Both functions are short, and the former is only called by the latter.
* wma: Simplify get_vlc().Andre Noll2017-07-06
| | | | | | | The "bits" argument of the function is implicitly given by the vlc structure and may thus be omitted from the call. For this to work we must pass a pointer to struct vlc instead of only the table, which further simplifies wmadec_filter.c.
* Merge branch 'refs/heads/t/lopsub'Andre Noll2017-04-27
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of the changes in this release is the conversion of all command line parsers from gengetopt to lopsub. The series also contains a few cleanups that have become possible due to the switch from gengetopt to lopsub. The patches towards the end of the series rename para_fade to para_mixer. Naturally, the merge conflicted rather heavily against the other topic branches that have been merged since the lopsub branch was started. Conflicting files: Makefile.real afh.c afh_recv.c configure.ac osx_write.c write.c The resolutions for these conflicts were recorded with git rerere and have been tested for quite some time. Cooking for three weeks. * refs/heads/t/lopsub: (74 commits) audioc: Avoid double free in audioc_i9e_line_handler(). audiod: Avoid uninitialized memory access. Simplify mixer setup. mixer: Implement non-linear time scale for fading. mixer: Allow arbitrary relative time for sleep subcommand. Convert para_fade to subcommands, rename it to para_mixer. build: Create .dep files only during compilation. build: Simplify definition of $m4_lls_deps. build: Rename command list variables. build: Combine $(CFLAGS) and $(STRICT_CFLAGS). build: Let .d files depend only on .c. build: Don't create phony targets for dependencies. build: Remove duplicate dependency. build: Remove cmdline_dir and friends. build: Remove some unused variables from Makefile.real. build: Remove m4/gengetopt. Remove gengetopt and help2man checks from configure.ac. Remove man_util.bash. Remove ggo.c and ggo.h. manual: Do not mention gengetopt and help2man any more. ...
| * Convert filters to lopsub.Andre Noll2017-03-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces the *_filter.m4 gengetopt files by the filter_cmd lopsub suite, where each filter is realized as a subcommand. Due to this change, para_filter needs to be linked with -llopsub. The filter structure is now stored in the user_data pointer provided by lopsub, allowing to get rid of the global filters[] array, the FILTER_ENUM macro and the corresponding enumeration constants. The removal of the ->goo_help member of struct filter makes this structure constant. Hence ->init() of struct filter can also go away. We still can tell whether a filter is supported by checking the user_data pointer: if it is NULL, the filter is unsupported. The new filter_supported() helper in filter_common.c is provided for convenience. Parsing of the filter command line options is now performed generically, and the ->parse_config() method is renamed to ->setup(), an optional function which is supposed to perform semantic checks and the one-time setup of the filter, if any. It is accompanied by ->teardown() which replaces ->free_config(). The conversion of the individual filters is easy since most filters have a simple syntax or take no arguments at all. The resample_filter, however, needs a different way to copy the wav parameters from the lopsub parse result to the wav parms structure. A suitable macro, LLS_COPY_WAV_PARMS is added to check_wav.h for this purpose. The old COPY_WAV_PARMS needs to stay until para_write, the only other user of the macro, has been converted as well. The section heading of the manual page has changed slightly, causing t0005 to fail. Hence this test needs a slight adjustment.
* | wmadec: Use read_u32_be().Andre Noll2017-03-25
|/ | | | | | | | | | The shift operation in show_bits() was buggy because p[0] is promoted to int, and the shift p[0] << 24 results in undefined behavior, causing the sanitizer of gcc to complain: bitstream.h:40:21: runtime error: left shift of 230 by 24 places cannot be represented in type 'int' read_u32_be() gets this right.
* Merge branch 'refs/heads/t/format-signedness'Andre Noll2016-12-28
|\ | | | | | | | | | | | | | | | | | | | | This series fixes all warnings produced by compiling with -Wformat-signedness and adds the flag to CFLAGS if the compiler supports it. * refs/heads/t/format-signedness (cooking for ~2 weeks): gcrypt: Fix a few format-signedness issues. Compile with -Wformat-signedness if possible. Fix signedness issues in format strings.
| * Fix signedness issues in format strings.Andre Noll2016-12-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Compiling with -Wformat-signedness (not enabled so far) causes many warnings because of format strings which specify an unsigned type but correspond to an argument of signed type, or vice versa. This commit fixes all these mismatches. For "%u", "%d", "%lu", "%ld" we let the format string match the type of the argument, but for "%x" we need to cast the argument to a suitable unsigned type. After this patch the tree compiles cleanly with -Wformat-signedness given. The warning will be enabled in a subsequent commit.
* | wmadec: Remove two pointless variables.Andre Noll2016-12-11
| | | | | | | | | | | | | | The local variables n and incr of wma_decode_frame() shadow the values of their counterparts in struct private_wmadec_data, and they remain constant within the function. Referring directly to the private structure instead makes the code shorter and improves readability.
* | wmadec: Remove a pointless cast.Andre Noll2016-12-11
| | | | | | | | The address of "in" is already of type char **.
* | wmadec: Set data size to 0 if nothing was decoded.Andre Noll2016-12-11
| | | | | | | | Without this, we might feed uninitialized data into the output stream.
* | wma: Fix packet size calculation.Andre Noll2016-12-11
| | | | | | | | | | | | | | | | | | | | | | Usually the (fixed) packet size of a wma file equals the block align value plus WMA_FRAME_SKIP. However, this is not true in general, and if the two values differ, we fail to decode the file and bail out with an "incoherent block length" error. This patch adds code to read the correct packet size from the file properties object and uses this value in the decoder and the audio format handler.
* | wmadec: Properly handle empty outputs.Andre Noll2016-12-08
|/ | | | | | | | If out_size is zero we try to shrink the buffer to size zero. POSIX says that the behavior is implementation-defined in this case, and para_realloc() aborts due to an assert() statement that checks for size zero. This patch makes sure the wma decoder never calls realloc() with a zero size argument.
* wmadec: Fix left shift of negative value.Andre Noll2016-05-15
| | | | | | | | | | | | gcc-6.1 complains about this: wmadec_filter.c:819:33: warning: left shift of negative value [-Wshift-negative-value] mult1 = mult * exponents[((-1 << bsize)) >> esize]; The new code still looks wrong because we now shift a negative value to the right. Moreover, it is not clear that the resulting value is within array bounds. On the other hand, ffmpeg has the same fix (commit a48b24e5 in the ffmpeg repository), so..
* wmadec: Simplify wma_lsp_to_curve_init().Andre Noll2016-03-06
| | | | | | There's only one caller, and it passes pwd->frame_len as the second argument to the function. Since we pass pwd as well, the second argument of the function can be removed.
* wmadec: Make pwd->reset_block_lengths a boolean.Andre Noll2016-03-06
| | | | This field is already used as such. Improve the documentation while at it.
* wmadec: Simplify get_vlc().Andre Noll2016-03-06
| | | | | | The last parameter is always bigger than 2, which is all the function needs to know. Hence we may remove the parameter and get rid of some macros that were only used to compute it.
* Remove unnecessary system header includes.Andre Noll2015-01-12
| | | | All these headers get included from para.h.
* Merge branch 't/sched_improvements'Andre Noll2014-07-23
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cooking for two months. This merge required to also patch gui.c due to semantic conflics against the changes introduced by the gui_sched branch which was merged to master in commit d15d8509 two weeks ago. Also a small fix for server.c is needed to squelch a compiler warning since the global "now" variable has become a const pointer. * t/sched_improvements: (36 commits) audiod: Fix use after free on exit. sched: Mark global now pointer as const. sched: Directly pass context pointer to pre/post_select(). sched: kill task->dead. sched: Do not shadow task_info in struct task. sched: Dont use fixed-size buffer for task names. sched: Rename task->error to tast->status. sched: Rename task->status to task->name. sched: Make struct task private to sched.c. sched: Introduce task_status(). sched: Remove ->owned_by_sched. sched: Remove register_task(). task_register() conversion: grab client task task_register() conversion: audiod status task task_register() conversion: audiod command task task_register() conversion: client task task_register() conversion: client supervisor task task_register() conversion: client exec task task_register() conversion: afs command task task_register() conversion: vss task ...
| * sched: Directly pass context pointer to pre/post_select().Andre Noll2014-05-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch is large, but it's fairly straight forward: Instead of a task pointer all ->pre_select() and ->post_select() methods now receive the context pointer that was passed to the scheduler when the task was registered. This allows to kill the public task_context(). Two pre_select/post_select functions are not directly called by the scheduler: session_post_select(), generic_recv_pre_select(). These are changed to receive a proper struct rather than a void pointer. Note that generic_filter_pre_select() is not changed in this manner because some filters do not provide a pre_select wrapper but set task->pre_select to generic_filter_pre_select().
| * task_register() conversion: filter tasksAndre Noll2014-05-25
| |
* | wma: Store ASF header info in afhi->techinfo.Andre Noll2014-04-22
|/ | | | | | | | | | This changes the wma audio format handler and decoder to store the ASF header bits we care about (exp_vlc, bit reservoir, and variable block length) in struct asf_header_info instead of struct private_wmadec_data. This way the wma audio format handler can print this information in its ->techinfo string for the audio file.
* doxygen: Expand all macros, in particular config.h.Andre Noll2014-02-22
| | | | | This improves the generated documentation web pages since now all HAVE_XXX macros of config.h are taken into account.
* sched: Rename new_post_select back to post_select.Andre Noll2013-04-30
|
* sched: Kill old ->post_select variant.Andre Noll2013-04-30
| | | | It has no more users.
* wmadec: Switch to the alternative post select method.Andre Noll2013-04-30
|
* Replace gettimeofday() by clock_gettime().Andre Noll2013-04-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX.1-2008 marks gettimeofday() as obsolete, so let's switch to clock_gettime(). clock_gettime() operates on timespecs rather than on timevals like gettimeofday() does. Since timevals are extensively used in all parts of paraslash, and select() takes a timeval pointer as the timeout parameter, it seems to be easiest to add a new wrapper, clock_get_realtime(). It calls clock_gettime(), performs error checking (all errors are treated fatal and abort the program), and converts the result to a timeval. Another difference between gettimeofday() and clock_gettime() is that sys/time.h needs to be included for gettimeofday(), while clock_gettime() is declared in time.h which gets included from para.h. Hence we can remove the include statement for sys/time.h everywhere. Programs which call clock_gettime need to be linked against librt on glibc versions before 2.17 while BSD and newer glibc-based systems have no such requirement. To make matters more interesting, MacOS lacks clock_gettime() completely although this function conforms to SUSv2 and POSIX.1-2001. We'd like to avoid the unnecessary dependence on librt on systems that have clock_gettime() in -lc, and we must fall back to gettimeofday() on MacOS. Hence this commit also introduces a check in configure.ac which determines whether clock_gettime() is available and, if it is, whether -lrt is needed. Executables are only linked with -lrt if configure found that this is necessary.
* Merge branch 't/btr_improvements'Andre Noll2012-07-19
|\ | | | | | | | | | | | | | | 146316 btr_exec_up(): Also ask given node. 6d9c35 btr: Introduce btr_add_output_dont_free(). 4ac313 btr: Remove btr_free_node(). Has been cooking in next for a week.