summaryrefslogtreecommitdiffstats
path: root/audio/audio.h
Commit message (Collapse)AuthorAgeFilesLines
* audio: rewrite filtering glue codewm42018-01-301-102/+0
| | | | Use the new filtering code for audio too.
* audio: make libaf derived code optionalwm42017-09-211-0/+2
| | | | | | | | | | | | | | | This code could not be relicensed. The intention was to write new filter code (which could handle both audio and video), but that's a bit of work. Write some code that can do audio conversion (resampling, downmixing, etc.) without the old audio filter chain code in order to speed up the LGPL relicensing. If you build with --disable-libaf, nothing in audio/filter/* is compiled in. It breaks a few features, such as --volume, --af, pitch correction on speed changes, replaygain. Most likely this adds some bugs, even if --disable-libaf is not used. (How the fuck does EOF notification work again anyway?)
* audio: move libswresample wrapper out of audio filter codewm42017-09-211-0/+1
| | | | | | | | | Move it from af_lavrresample.c to a new aconverter.c file, which is independent from the filter chain code. It also doesn't use mp_audio, and thus has no GPL dependencies. Preparation for later commits. Not particularly well tested, so have fun.
* audio: introduce a new type to hold audio frameswm42017-08-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is pretty pointless, but I believe it allows us to claim that the new code is not affected by the copyright of the old code. This is needed, because the original mp_audio struct was written by someone who has disagreed with LGPL relicensing (it was called af_data at the time, and was defined in af.h). The "GPL'ed" struct contents that surive are pretty trivial: just the data pointer, and some metadata like the format, samplerate, etc. - but at least in this case, any new code would be extremely similar anyway, and I'm not really sure whether it's OK to claim different copyright. So what we do is we just use AVFrame (which of course is LGPL with 100% certainty), and add some accessors around it to adapt it to mpv conventions. Also, this gets rid of some annoying conventions of mp_audio, like the struct fields that require using an accessor to write to them anyway. For the most part, this change is only dumb replacements of mp_audio related functions and fields. One minor actual change is that you can't allocate the new type on the stack anymore. Some code still uses mp_audio. All audio filter code will be deleted, so it makes no sense to convert this code. (Audio filters which are LGPL and which we keep will have to be ported to a new filter infrastructure anyway.) player/audio.c uses it because it interacts with the old filter code. push.c has some complex use of mp_audio and mp_audio_buffer, but this and pull.c will most likely be rewritten to do something else.
* af_lavcac3enc: use common code for AVFrame setupwm42016-07-241-0/+1
|
* audio: add a helper for getting frame end PTSwm42016-06-271-0/+1
| | | | Although I don't see any use for it yet, why not.
* audio: move frame clipping to a generic functionwm42016-02-211-0/+1
|
* audio: move mp_audio->AVFrame conversion to a functionwm42016-01-291-0/+1
| | | | | | | | | This also makes it refcounted, i.e. the new AVFrame will reference the mp_audio buffers, instead of potentially forcing the consumer of the AVFrame to copy the data. All the extra code is for handling the >8 channels case, which requires very messy dealing with the extended_ fields (not our fault).
* audio: move PTS setting out of the decoderwm42015-11-081-0/+2
| | | | | | | Instead of requiring the decoder to set the PTS directly on the dec_audio context (including handling absence of PTS etc.), transfer the packet PTS to the decoded audio frame. Marginally simpler, and gives more control to the generic code.
* audio/filter: remove some useless filterswm42015-09-031-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | All of these filters are considered not useful anymore by us. Some have replacements in libavfilter (useable through af_lavfi). af_center, af_extrastereo, af_karaoke, af_sinesuppress, af_sub, af_surround, af_sweep: pretty simple and useless filters which probably nobody ever wants. af_ladspa: has a replacement in libavfilter. af_hrtf: the algorithm doesn't work properly on most sources, and the implementation was buggy and complicated. (The filter was inherited from MPlayer; but even in mpv times we had to apply fixes that fixed major issues with added noise.) There is a ladspa filter if you still want to use it. af_export: I'm not even sure what this is supposed to do. Possibly it was meant for GUIs rendering audio visualizations, but it couldn't really work well. For example, the size of the audio depended on the samplerate (fixed number of samples only), and it couldn't retrieve the complete audio, only fragments. If this is really needed for GUIs, mpv should add native visualization, or a proper API for it.
* audio: fix format function consistency issueswm42015-06-261-1/+1
| | | | | | | | | | | Replace all the check macros with function calls. Give them all the same case and naming schema. Drop af_fmt2bits(). Only af_fmt2bps() survives as af_fmt_to_bytes(). Introduce af_fmt_is_pcm(), and use it in situations that used !AF_FORMAT_IS_SPECIAL. Nobody really knew what a "special" format was. It simply meant "not PCM".
* audio: remove unused readonly fieldwm42015-06-151-1/+0
| | | | Its last use was removed in 433402b5.
* audio: deal with AVFrame-style buffer assignmentswm42015-06-121-1/+4
| | | | | | | | | | | | | | | | In the AVFrame-style system (which we inreasingly map our internal data stuctures on), buffers and plane pointers don't necessarily have a 1:1 correspondence. For example, a single buffer could cover 2 or more planes, all while other planes are covered by a second buffer, and so on. They don't need to be ordered in the same way. Change mp_audio_get_allocated_size() to retrieve the maximum size all planes provide. This also considers the case of planes not pointing to buffer start. Change mp_audio_realloc() to reset all planes, even if corresponding buffers are not reallocated. (The caller has to be careful anyway if it wants to be sure the contents are preserved on realloc calls.)
* audio: introduce mp_audio readonly bitwm42015-05-041-0/+1
| | | | Convenience for the following commit.
* audio: add missing declarationwm42015-01-141-0/+1
|
* audio: add some utility functions for refcounted frameswm42015-01-131-0/+6
| | | | Used in the following commits.
* audio: make mp_audio_config_to_str return a stack-allocated stringwm42014-11-251-2/+2
| | | | Simpler overall.
* audio: add mp_audio_make_writeable()wm42014-11-101-0/+2
|
* audio: add function to convert AVFrame to mp_audio referenceswm42014-11-101-0/+3
| | | | | This is somewhat duplicated from ad_lavc.c and af_lavfi.c, but will eventually be used by both.
* audio: add mp_audio_poolwm42014-11-101-0/+4
| | | | | | A helper to allocate refcounted audio frames from a pool. This will replace the static buffer many audio filters use (af->data), because such static buffers are incompatible with refcounting.
* audio: use AVBufferRef to allocate audio frameswm42014-11-101-1/+1
| | | | | | | A first step towards refcounted audio frames. Amazingly, the API just does what we want, and the code becomes simpler. We will need to NIH allocation from a pool, though.
* af_fmt2bits: change to af_fmt2bps (bytes/sample) where appropriateMarcoen Hirschberg2014-05-281-1/+1
| | | | | | In most places where af_fmt2bits is called to get the bits/sample, the result is immediately converted to bytes/sample. Avoid this by getting bytes/sample directly by introducing af_fmt2bps.
* audio: better rejection of invalid formatswm42013-11-271-0/+1
| | | | | | | | | This includes the case when lavc decodes audio with more than 8 channels, which our audio chain currently does not support. the changes in ad_lavc.c are just simplifications. The code tried to avoid overriding global parameters if it found something invalid, but that is not needed anymore.
* mp_audio: use av_malloc (cargo cult for libav*)wm42013-11-121-0/+3
| | | | | | | | | | | | | | | libav* is generally freaking horrible, and might do bad things if the data pointer passed to it are not aligned. One way to be sure that the alignment is correct is allocating all pointers using av_malloc(). It's possible that this is not needed at all, though. For now it might be better to keep this, since the mp_audio code is intended to replace another buffer in dec_audio.c, which is currently av_malloc() allocated. The original reason why this uses av_malloc() is apparently because libavcodec used to directly encode into mplayer buffers, which is not the case anymore, and thus (probably) doesn't make sense anymore. (The commit subject uses the word "cargo cult", after all.)
* audio/filter: prepare filter chain for non-interleaved audiowm42013-11-121-5/+26
| | | | | | | | | | | | | | | | | | Based on earlier work by Stefano Pigozzi. There are 2 changes: 1. Instead of mp_audio.audio, mp_audio.planes[0] must be used. 2. mp_audio.len used to contain the size of the audio in bytes. Now mp_audio.samples must be used. (Where 1 sample is the smallest unit of audio that covers all channels.) Also, some filters need changes to reject non-interleaved formats properly. Nothing uses the non-interleaved features yet, but this is needed so that things don't just break when doing so.
* audio/filters: add af_forcewm42013-05-121-0/+1
| | | | | Its main purpose is for testing in case channel layout stuff breaks, in particular in connection with old audio filters.
* audio: print channel map additionally to channel count on terminalwm42013-05-121-0/+3
|
* af: use mp_chmap for mp_audio, include channel map in format negotiationwm42013-05-121-1/+5
| | | | | Now af_lavrresample pretends to reorder the channels, although it doesn't yet, and nothing sets non-standard layouts either.
* audio: add some setters for mp_audio, and require filters to use themwm42013-05-121-0/+38
mp_audio has some redundant fields. Setters like mp_audio_set_format() initialize these properly. Also move the mp_audio struct to a the file audio.c. We can remove a mysterious line of code from af.c: in.format |= af_bits2fmt(in.bps * 8); I'm not sure if this was ever actually needed, or if it was some kind of "make it work" quick-fix that works against the way things were supposed to work. All filters etc. now set the format correctly, so if there ever was a need for this code, it's definitely gone.