summaryrefslogtreecommitdiffstats
path: root/audio/filter
Commit message (Collapse)AuthorAgeFilesLines
* af: remove redundant functionwm42014-11-121-9/+2
|
* af: check audio params for validitywm42014-11-121-0/+5
| | | | Normally, these should be valid anyway, so this is just being cautious.
* audio: make decoders output refcounted frameswm42014-11-102-10/+38
| | | | | | | | | | | | | | This rewrites the audio decode loop to some degree. Audio filters don't do refcounted frames yet, so af.c contains a hacky "emulation". Remove some of the weird heuristic-heavy code in dec_audio.c. Instead of estimating how much audio we need to filter, we always filter full frames. Maybe this should be adjusted later: in case filtering increases the volume of the audio data, we should try not to buffer too much filter output by reducing the input that is fed at once. For ad_spdif.c and ad_mpg123.c, we don't avoid extra copying yet - it doesn't seem worth the trouble.
* audio: change how filters are inserted on playback speed changeswm42014-11-103-0/+72
| | | | | | | | | | Use a pseudo-filter when changing speed with resampling, instead of somehow changing a samplerate somewhere. This uses the same underlying mechanism, but is a bit more structured and cleaner. It also makes some of the following changes easier. Since we now always use filters to change audio speed, move most of the work set_playback_speed() does to recreate_audio_filters().
* af_format: remove redundant message prefixeswm42014-11-101-2/+2
|
* af_lavcac3enc: fix byte orderwm42014-10-121-2/+2
| | | | | | | | Oops. Fixes #1172. CC: @mpv-player/stable
* audio/filter: allow removing filters by labelwm42014-10-022-1/+33
| | | | | | | | Although the "af" command already could do this, it seems it's better to introduce a lower level mechanism for now. This avoids some messy issues, since that code would recursive call reinit_audio_chain(). To be used by the next commit.
* audio: refactor some aspects of filter chain setupwm42014-10-022-13/+15
| | | | | | | | | | | There's no real reason why audio_init_filter() should exist. Just use af_init or af_reinit directly. (We lose a useless message; the same information is printed in a quite close place with more details.) Requires less code, and the way the filter chain is marked as having failed to initialize allows just switching off audio instead of crashing if trying to insert a volume filter in mixer.c fails, and recreating the old filter chain fails too.
* audio/filter: don't wipe full filter chain if adding a filter failswm42014-10-021-2/+5
| | | | | There's no need for that, and in fact makes it more likely that it recovers normally.
* audio: cleanup spdif format definitionswm42014-09-232-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, there was AF_FORMAT_AC3 (the original spdif format, used for AC3 and DTS core), and AF_FORMAT_IEC61937 (used for AC3, DTS and DTS-HD), which was handled as some sort of superset for AF_FORMAT_AC3. There also was AF_FORMAT_MPEG2, which used IEC61937-framing, but still was handled as something "separate". Technically, all of them are pretty similar, but may use different bitrates. Since digital passthrough pretends to be PCM (just with special headers that wrap digital packets), this is easily detectable by the higher samplerate or higher number of channels, so I don't know why you'd need a separate "class" of sample formats (AF_FORMAT_AC3 vs. AF_FORMAT_IEC61937) to distinguish them. Actually, this whole thing is just a mess. Simplify this by handling all these formats the same way. AF_FORMAT_IS_IEC61937() now returns 1 for all spdif formats (even MP3). All AOs just accept all spdif formats now - whether that works or not is not really clear (seems inconsistent due to earlier attempts to make DTS-HD work). But on the other hand, enabling spdif requires manual user interaction, so it doesn't matter much if initialization fails in slightly less graceful ways if it can't work at all. At a later point, we will support passthrough with ao_pulse. It seems the PulseAudio API wants to know the codec type (or maybe not - feeding it DTS while telling it it's AC3 works), add separate formats for each codecs. While this reminds of the earlier chaos, it's stricter, and most code just uses AF_FORMAT_IS_IEC61937(). Also, modify AF_FORMAT_TYPE_MASK (renamed from AF_FORMAT_POINT_MASK) to include special formats, so that it always describes the fundamental sample format type. This also ensures valid AF formats are never 0 (this was probably broken in one of the earlier commits from today).
* audio: drop swapped-endian audio formatswm42014-09-233-90/+30
| | | | | | | | | | | | | | | | | | | | Until now, the audio chain could handle both little endian and big endian formats. This actually doesn't make much sense, since the audio API and the HW will most likely prefer native formats. Or at the very least, it should be trivial for audio drivers to do the byte swapping themselves. From now on, the audio chain contains native-endian formats only. All AOs and some filters are adjusted. af_convertsignendian.c is now wrongly named, but the filter name is adjusted. In some cases, the audio infrastructure was reused on the demuxer side, but that is relatively easy to rectify. This is a quite intrusive and radical change. It's possible that it will break some things (especially if they're obscure or not Linux), so watch out for regressions. It's probably still better to do it the bulldozer way, since slow transition and researching foreign platforms would take a lot of time and effort.
* audio: remove swapped-endian spdif formatswm42014-09-231-4/+12
| | | | | | | | | | | | | | | | | | | | | | IEC 61937 frames should always be little endian (little endian 16 bit words). I don't see any apparent need why the audio chain should handle swapped-endian formats. It could be that some audio outputs might want them (especially on big endian architectures). On the other hand, it's not clear how that works on these architectures, and it's not even known whether the current code works on big endian at all. If something should break, and it should turn out that swapped-endian spdif is needed on any platform/AO, swapping still could be done in-place within the affected AO, and there's no need for the additional complexity in the rest of the player. Note that af_lavcac3enc outputs big endian spdif frames for unknown reasons. Normally, the resulting data is just pulled through an auto- inserted conversion filter and turned into little endian. Maybe this was done as a trick so that the code didn't have to byte-swap the actual audio frame. In any case, just make it output little endian frames. All of this is untested, because I have no receiver hardware.
* af_hrtf: initialize coefficient arrayswm42014-09-191-0/+25
| | | | | | | | | | | | | | | Sometimes, --af=hrtf produces heavy artifacts or silence. It's possible that this commit fixes these issues. My theory is that usually, the uninitialized coefficients quickly converge to sane values as more audio is filtered, which would explain why there are often artifacts on init, with normal playback after that. It's also possible that sometimes, the uninitialized values were NaN or inf, so that the artifacts (or silence) would never go away. Fix this by initializing the coefficients to 0. I'm not sure if this is correct, but certainly better than before. See issue #1104.
* af_lavrresample: fix crash with size 0wm42014-09-151-2/+3
| | | | | | | | | | | | | | The filter output size can be 0. Due to how filtering works, this is nothing unusual, but avresample_convert() will return 0. The same case is already handling with "normal" resampling (this commit fixes the reordering code). Additionally, don't use an assert(). avresample_convert() failing is unusual, but might also happen due to e.g. internal out of memory conditions, so we shouldn't just crash on it. Curiously observed with --ao=oss --audio-channels=5.1 when changing speed.
* af_hrtf: request required samplerate, instead of erroring outwm42014-09-051-8/+1
| | | | | | | | It seems hrtf works in 48khz only - and if that wasn't the input, the filter just exited with an error. Make it request the 48khz instead. The player will insert a resampling filter. Not sure why it wasn't done like this in the first place.
* af_hrtf: cosmetics: reindent misaligned code blockwm42014-09-051-8/+8
|
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-291-1/+1
| | | | | | | | | bstr.c doesn't really deserve its own directory, and compat had just a few files, most of which may as well be in osdep. There isn't really any justification for these extra directories, so get rid of them. The compat/libav.h was empty - just delete it. We changed our approach to API compatibility, and will likely not need it anymore.
* af_lavrresample: minor cosmeticswm42014-08-171-4/+2
|
* af_lavcac3enc: lower minimum channel number to 3wm42014-08-121-1/+1
| | | | It seems only stereo PCM should be passed through.
* af_lavcac3enc: change default bitrate to 640wm42014-08-121-1/+2
| | | | | | | No reason to use less. Since the name "default" is misleading now, replace it with "auto" (still recognize the old name).
* Improve setting AVOptionswm42014-08-022-13/+9
| | | | | | | | Use OPT_KEYVALUELIST() for all places where AVOptions are directly set from mpv command line options. This allows escaping values, better diagnostics (also no more "pal"), and somehow reduces code size. Remove the old crappy option parser (av_opts.c).
* audio: remove unused metadata fieldwm42014-07-212-3/+0
| | | | | This was used for replaygain at some point, until replaygain info was passed through explicitly.
* Remove some mp_msg calls with no trailing \nwm42014-07-131-6/+6
| | | | | | | The final goal is all mp_msg calls produce complete lines. We want this because otherwise, race conditions could corrupt the terminal output, and it's inconvenient for the client API too. This commit works towards this goal. There's still code that has this not fixed yet, though.
* af_volume: fix calculations including replay-gainMohammad Alsaleh2014-06-281-2/+2
| | | | | | | | | | | | | rgain is not an additive value. It's a multiplier/gain. Previous behaviour produced negative level values in some cases (when rgain < 1.0) which caused volume to be louder when its value was lowered. CC: @mpv-player/stable Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com> Signed-off-by: wm4 <wm4@nowhere>
* Add more constwm42014-06-1126-60/+60
| | | | | | | While I'm not very fond of "const", it's important for declarations (it decides whether a symbol is emitted in a read-only or read/write section). Fix all these cases, so we have writeable global data only when we really need.
* af_lavcac3enc: detach on any passthrough format, not just ac3wm42014-04-161-1/+1
|
* Kill all tabswm42014-04-1321-524/+524
| | | | | | | | | | | I hate tabs. This replaces all tabs in all source files with spaces. The only exception is old-makefile. The replacement was made by running the GNU coreutils "expand" command on every file. Since the replacement was automatic, it's possible that some formatting was destroyed (but perhaps only if it was assuming that the end of a tab does not correspond to aligning the end to multiples of 8 spaces).
* af_volume: fix clang -Wsometimes-uninitializedKevin Mitchell2014-04-131-1/+1
|
* af_lavfi: fix graph parse deprecation warningKevin Mitchell2014-04-131-1/+1
|
* demux: move metadata-based replaygain decoding out of af_volumeAlessandro Ghedini2014-04-041-80/+9
|
* af_volume: use replaygain side dataAlessandro Ghedini2014-04-041-7/+19
|
* af: add replaygain_data field to af_stream and af_instanceAlessandro Ghedini2014-04-042-0/+3
| | | | Closes #664
* af_volume: fix replaygainwm42014-03-271-2/+3
| | | | | | | | This was accidentally broken in commit b72ba3f7. I somehow made the wild assumption that replaygain adjusted the volume relative to 0% instead of 100%. The detach suboption was similarly broken.
* af_lavcac3enc: use new AVFrame APIwm42014-03-161-3/+3
|
* build: simplify libavfilter configure checkswm42014-03-161-1/+1
| | | | | This is all not needed anymore. In particular, remove all configure switches except --enable-libavfilter.
* Remove some more unneeded version checkswm42014-03-161-13/+3
| | | | | All of these check against things that happened before the latest supported FFmpeg/Libav release.
* af_lavrresample: remove avresample_set_channel_mapping() fallbackswm42014-03-161-24/+0
| | | | | | | This function is now always available. Also remove includes of reorder_ch.h from some AOs (these are just old relicts).
* af_volume: don't print missing replaygain tags as errorwm42014-03-141-1/+1
| | | | There's no reason to. Audio files often lack them.
* af_volume: add detach optionwm42014-03-141-0/+4
| | | | | | Maybe this should be default. On the other hand, this filter does something even if the volume is neutral: it clips samples against the allowed range, should the decoder or a previous filter output garbage.
* af_volume: separate softvol volume control from replaygain levelwm42014-03-141-5/+8
| | | | | | | | | Currently, both replaygain adjustment and user volume control (if softvol is enabled) share the same variable. Sharing the variable would cause especially if --volume is used; then the replaygain volume would always be overwritten. Now both gain values are simple added right before doing filtering.
* af_volume: remove double-negated suboptionwm42014-03-141-3/+3
| | | | | You had to use "no-replaygain-noclip" to set this option. Rename it, so that only one negation is needed.
* af_volume: add support for replaygain pre-amp and clipping preventionAlessandro Ghedini2014-03-131-11/+74
|
* af_volume: add replaygain supportAlessandro Ghedini2014-03-131-0/+22
| | | | | | | | | This adds the options replaygain-track and replaygain-album. If either is set, the replaygain track or album gain will be automatically read from the track metadata and the volume adjusted accordingly. This only supports reading REPLAYGAIN_(TRACK|ALBUM)_GAIN tags. Other formats like LAME's info header would probably require support from libav.
* af: add metadata field to af_stream and af_instanceAlessandro Ghedini2014-03-132-0/+3
| | | | | | This allows to propagate metadata information to audio filters. Closes #632
* af_lavfi: beat it into working with Libavwm42014-03-131-23/+39
| | | | | | | | | | | | | | | | | | | The main incompatibility was that Libav didn't have av_opt_set_int_list. But since that function is excessively ugly and idiotic (look how it handles types), I'm not missing it much. Use an aformat filter instead to handle the functionality that was indirectly provided by it. This is similar to how vf_lavfi works. The other incompatibility was channel handling. Libav consistently uses channel layouts only, why ffmpeg still requires messing with channel counts to some degree. Get rid of most channel count uses (and hope channel layouts are "exact" enough). Only in one case FFmpeg fails with a runtime check if we feed it AVFrames with channel count unset. Another issue were AVFrame accessor functions. FFmpeg introduced these for ABI compatibility with Libav. I refuse to use them, and it's not my problem if FFmpeg doesn't manage to provide a stable ABI for fields provided both by FFmpeg and Libav.
* audio/filter: remove redundant log message prefixeswm42014-01-2413-44/+44
| | | | | These are now appended automatically, so you'd get them twice before this commit.
* audio: fix balance controlwm42014-01-231-2/+2
| | | | | | | | Balance controls as used by mixer.c was broken, because af_pan.c stopped accepting its arguments. We have to allow 0 channels explicitly. Also, fix null pointer access if the matrix parameter is not used. Regression from commit 82983970.
* af: fixed out-of-bounds accesses caused by NUM_FMT and co.11rcombs2014-01-191-18/+18
| | | | | | | | | Signed-off-by: wm4 <wm4@nowhere> This merges pull request #496. The problem was that at least the initialization of the distance[] array accessed af_fmtstr_table[] entries that were out of bounds. Small cosmetic changes applied to the original pull request.
* af_export: require filename argumentwm42013-12-211-4/+3
| | | | | | Since mp_find_user_config_file() is going to get a context argument, which would be annoying to do in the audio chain (actually I'm just lazy).
* m_option, m_config: mp_msg conversionswm42013-12-211-1/+1
| | | | | | | | Always pass around mp_log contexts in the option parser code. This of course affects all users of this API as well. In stream.c, pass a mp_null_log, because we can't do it properly yet. This will be fixed later.
* audio/fmt-conversion.c: remove unknown audio format messageswm42013-12-211-0/+3
| | | | Same deal as with video/fmt-conversion.c.
* audio: mp_msg conversionswm42013-12-2118-145/+136
|
* Reduce recursive config.h inclusions in headerswm42013-12-183-3/+3
| | | | | | In my opinion, config.h inclusions should be kept to a minimum. MPlayer code really liked including config.h everywhere, though, even in often used header files. Try to reduce this.
* Remove the _ macrowm42013-12-181-0/+2
| | | | | This was a gettext-style macro to mark strings that should be translated.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-1714-15/+15
|
* Move options/config related files from mpvcore/ to options/wm42013-12-178-9/+9
| | | | | | | | | Since m_option.h and options.h are extremely often included, a lot of files have to be changed. Moving path.c/h to options/ is a bit questionable, but since this is mainly about access to config files (which are also handled in options/), it's probably ok.
* Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsgwm42013-12-163-6/+6
| | | | | | | | | The tmsg stuff was for the internal gettext() based translation system, which nobody ever attempted to use and thus was removed. mp_gtext() and set_osd_tmsg() were also for this. mp_dbg was once enabled in debug mode only, but since we have log level for enabling debug messages, it seems utterly useless.
* audio: flush remaining data from the filter chain on EOFwm42013-12-051-2/+2
| | | | | | | | | | | | | | | | | This can be reproduced with: mpv short.wav -af 'lavfi="aecho=0.8:0.9:5000|6800:0.3|0.25"' An audio file that is just 1-2 seconds long should play for 8-9 seconds, which audible echo towards the end. The code assumes that when playing with AF_FILTER_FLAG_EOF, the filter will either produce output, or has all remaining data flushed. I'm not really sure whether this really works if there are multiple filters with EOF handling in the chain. To handle it correctly, af_lavfi should retry filtering if 1. EOF flag is set, 2. there were input samples, and 3. no output samples were produced. But currently it seems to work well enough anyway.
* audio/filter: change filter callback signaturewm42013-12-0527-143/+144
| | | | | | | | | The new signature is actually closer to how it actually works, and someone who is not familiar to the API and how it works might make fewer fatal mistakes with the new signature than the old one. Pretty weird. Do this to sneak in a flags parameter, which will later be used to flush remaining data of at least vf_lavfi.
* af: remove af->setup fieldwm42013-12-043-9/+7
| | | | Used to be used by filters that didn't use the option parser.
* af: remove legacy option parsing hackswm42013-12-042-10/+2
|
* af_pan: change options, use option parserwm42013-12-041-42/+38
| | | | Similar to af_channels etc...
* af_ladspa: change options, use option parserwm42013-12-041-158/+103
|