summaryrefslogtreecommitdiffstats
path: root/audio/filter/af_scaletempo.c
Commit message (Collapse)AuthorAgeFilesLines
* af_scaletempo: output minimally sized audio framewm42018-02-031-57/+76
| | | | | | | | | | | | | | | | | | | | This helps the filter to adapt much faster to speed changes. Before this commit, the filter just converted and output the full input frame, which could cause problems with large input frames. This was made worse by certain filters like dynaudnorm or loudnorm outputting pretty large frames. This commit changes the filter from trying to convert all input at once to only outputting a single internally filtered frame. Internally, this filter already output data in units of 60ms by default (controlled by the "stride" sub-option), and concatenated as many output frames as necessary to consume all input. Behavior is still kind of bad when inserting the filter. This is because the large frames can be buffered up after the insertion point, so the speed change will be performed with a larger latency. The scaletempo filter can't do anything against this, although it can be fixed by inserting scaletempo as user filter as part of --af.
* audio: rewrite filtering glue codewm42018-01-301-233/+344
| | | | Use the new filtering code for audio too.
* af_scaletempo: change license to LGPLwm42017-05-091-7/+7
| | | | | | | | | | | | All authors have agreed. The initial commit d33703496c as well as the current code contain this line: * inspired by SoundTouch library by Olli Parviainen We assume this is about the algorithm (not the code), and the author of the original patch actually wrote all code himself.
* audio: do not require full audio chain reinit for speed changeswm42015-11-041-3/+0
| | | | | | | | | | | | | | | Actually, it didn't really require that before (most work was avoided), but some bits had to be run anyway. Separate the speed change into a light-weight function, which merely updates already created filters, and a heavy-weight one which messes with filter insertion. This also happens to fix the case where the filters would "forget" the current speed (force resampling, change speed, hit a volume control to force af_volume insertion - it will reset speed and desync). Since we now always run the light-weight function, remove the af_scaletempo verbose message that is printed on speed setting. Other than that, all setters are cheap.
* Update license headersMarcin Kurczewski2015-04-131-5/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* audio: automatically deatch filters if spdif prevents their usewm42015-04-071-5/+0
| | | | Fixes #1743 and partially #1780.
* audio: refuse to change playback speed with spdifwm42015-03-071-1/+1
| | | | | | | | | | | | Handle the failure gracefully, instead of exploding and disabling audio. Just set the speed back to 1.0. Also remove the AF_DETACH from af_scaletempo. This actually created a dangling pointer in af_add(), a tricky consequence of af_add() reconfiguring the filter chain and the newly added filter using AF_DETACH. Fortunately the AF_DETACH is not needed (and probably never worked - it comes from MPlayer times, and MPlayer also disables audio when trying to change speed with spdif).
* af_scaletempo: minor simplificationwm42015-03-061-15/+6
|
* af_scaletempo: restore confusing mplayer behaviorwm42015-03-061-3/+9
| | | | | | | | | This matters only when setting obscure scaletempo suboptions. See #1653. (But what we really should do is figuring out how to do this in a sane way.)
* af_scaletempo: allow changing speed at runtime without reinitwm42015-02-101-18/+21
| | | | | | | | | | | | | | | | Staring at the code a bit, it turns out that changing speed without losing state is quite easy. The initialization code is big and complicated, but most of it is specific only to the configured audio format, not the speed. Refactor the code so that changing speed at runtime could work. (It's not actually used yet - the player code still does a complete reinit. This will be fixed in the next commit.) The "if (s->speed_tempo == s->speed_pitch)" looks a bit strange, but does the same thing as the code did before: speed can be changed only if exactly one flag is set. If both are set or none, speed can't be changed.
* af_scaletempo: drop detaching or skipping init on speed=1wm42015-02-101-7/+5
| | | | | | | | | | | | | | | | | | This code skipped initialization if no speed/pitch change was to be applied. It also didn't force conversion of the audio to a supported format, which is probably the most important case in context of compatibility. With this change applied, af_scaletempo will always force format conversion. To make the change less disruptive, make the filter detach if unconvertable formats are used. Some users use spdif and also have "af=scaletempo" in their config, so better not completely break this. In the case the filter was added with the "speed=both" suboption, the filter also detached itself in this case; but it's an obscure case, so I don't care about that.
* af_scaletempo: use refcounted frameswm42015-01-141-11/+23
|
* audio/filter: remove unused af_calc_filter_multiplier()wm42015-01-131-2/+0
| | | | | | | | | | | | The purpose of this function was to filter only as much audio input as needed to produce a certain amount of audio output. This could (in theory) avoid excessive buffering when e.g. changing playback speed with resampling. Use of this was already removed in commit 5fd8a1e0. No problems were experienced, so let's assume this feature is practically worthless. (Though it's possible that it was quite useful over a decade ago, or in some cornercases with evil files.)
* af_scaletempo: use float division for ratewm42014-11-211-1/+1
| | | | | | | | From what I understand the division is to align the dimension of the value from seconds to milliseconds. Hard to tell whether the "rounding" was intentional or not; I'm tipping on "not". Found by Coverity.
* Add more constwm42014-06-111-1/+1
| | | | | | | 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.
* audio/filter: remove redundant log message prefixeswm42014-01-241-6/+6
| | | | | These are now appended automatically, so you'd get them twice before this commit.
* audio: mp_msg conversionswm42013-12-211-8/+6
|
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-1/+1
|
* Move options/config related files from mpvcore/ to options/wm42013-12-171-1/+1
| | | | | | | | | 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.
* audio/filter: change filter callback signaturewm42013-12-051-4/+4
| | | | | | | | | 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.
* audio: drop buffered filter data when seekingwm42013-11-181-0/+5
| | | | | This could lead to (barely) audible artifacts with --af=scaletempo and modified playback speed.
* audio/filter: remove unneeded AF_CONTROLs, convert to enumwm42013-11-181-9/+1
| | | | | | | | The AF control commands used an elaborate and unnecessary organization for the command constants. Get rid of all that and convert the definitions to a simple enum. Also remove the control commands that were not really needed, because they were not used outside of the filters that implemented them.
* audio: drop "_NE"/"ne" suffix from audio formatswm42013-11-151-2/+2
| | | | | | You get the native format by not appending any suffix to the format. This change includes user-facing names, e.g. for the --format option.
* audio/filter: fix mul/delay scale and valueswm42013-11-121-4/+3
| | | | | | | | | | | | | Before this commit, the af_instance->mul/delay values were in bytes. Using bytes is confusing for non-interleaved audio, so switch mul to samples, and delay to seconds. For delay, seconds are more intuitive than bytes or samples, because it's used for the latency calculation. We also might want to replace the delay mechanism with real PTS tracking inside the filter chain some time in the future, and PTS will also require time-adjustments to be done in seconds. For most filters, we just remove the redundant mul=1 initialization. (Setting this used to be required, but not anymore.)
* af: don't require filters to allocate af_instance->data, redo bufferswm42013-11-121-29/+11
| | | | | | | | | | | | | Allocate af_instance->data in generic code before filter initialization. Every filter needs af->data (since it contains the output configuration), so there's no reason why every filter should allocate and free it. Remove RESIZE_LOCAL_BUFFER(), and replace it with mp_audio_realloc_min(). Interestingly, most code becomes simpler, because the new function takes the size in samples, and not in bytes. There are larger change in af_scaletempo.c and af_lavcac3enc.c, because these had copied and modified versions of the RESIZE_LOCAL_BUFFER macro/function.
* audio/filter: prepare filter chain for non-interleaved audiowm42013-11-121-13/+14
| | | | | | | | | | | | | | | | | | 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.
* af_scaletempo: uncrustifywm42013-11-091-404/+388
| | | | | | | | | Also do some cosmetic changes, like merging definition and initialization of local variables. Remove an annoying debug mp_msg() from af_open(). It just printed the command line parameters; if this is really needed, it could be added to af.c instead (similar as to what vf.c does).
* audio/filter: remove useless af_info fieldswm42013-10-231-6/+3
| | | | | | | Drop the author and comment fields. They were completely unused - not even printed in verbose mode, just dead weight. Also use designated initializers and drop redundant flags.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-2/+2
| | | | Followup commit. Fixes all the files references.
* core: change speed option/property to doublewm42013-08-051-2/+2
| | | | | | | | | | | | | The --speed option and the speed property used float. Change them to double. Change the commands that manipulate the property (speed_mult/add) to double as well. Since the cycle command shares code with the add command, we change that as well. The reason for this change is that this allows better control over speed, such as stepping by semitones. Using floats is also just plain unnecessary.
* af_scaletempo: use new option APIwm42013-07-221-84/+44
|
* audio: add some setters for mp_audio, and require filters to use themwm42013-05-121-12/+5
| | | | | | | | | | | | | | | | 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.
* audio/filter: replace pointless memcpys with assignmentswm42013-04-131-1/+4
| | | | | | The change in af_scaletempo actually fixes a memory leak. af->data contained a pointer to an allocated buffer, which was overwritten during format negotiation. Set the format explicitly instead.
* Rename directories, move files (step 2 of 2)wm42012-11-121-1/+1
| | | | | | | | | | | | Finish renaming directories and moving files. Adjust all include statements to make the previous commit compile. The two commits are separate, because git is bad at tracking renames and content changes at the same time. Also take this as an opportunity to remove the separation between "common" and "mplayer" sources in the Makefile. ("common" used to be shared between mplayer and mencoder.)
* Rename directories, move files (step 1 of 2) (does not compile)wm42012-11-121-0/+581
Tis drops the silly lib prefixes, and attempts to organize the tree in a more logical way. Make the top-level directory less cluttered as well. Renames the following directories: libaf -> audio/filter libao2 -> audio/out libvo -> video/out libmpdemux -> demux Split libmpcodecs: vf* -> video/filter vd*, dec_video.* -> video/decode mp_image*, img_format*, ... -> video/ ad*, dec_audio.* -> audio/decode libaf/format.* is moved to audio/ - this is similar to how mp_image.* is located in video/. Move most top-level .c/.h files to core. (talloc.c/.h is left on top- level, because it's external.) Park some of the more annoying files in compat/. Some of these are relicts from the time mplayer used ffmpeg internals. sub/ is not split, because it's too much of a mess (subtitle code is mixed with OSD display and rendering). Maybe the organization of core is not ideal: it mixes playback core (like mplayer.c) and utility helpers (like bstr.c/h). Should the need arise, the playback core will be moved somewhere else, while core contains all helper and common code.