summaryrefslogtreecommitdiffstats
path: root/audio/filter/af_lavcac3enc.c
Commit message (Collapse)AuthorAgeFilesLines
* various: make filter internal function names more descriptivenanahi2024-04-101-7/+7
| | | | | | | | | Lots of filters have generic internal function names like "process". On a stack trace, all of the different filters use this name, which causes confusion of the actual filter being processed. This renames these internal function names to carry the filter names. This matches what had already been done for some filters.
* af_lavcac3enc: fix memory leak on 2ch audiomistraid1212024-03-191-3/+3
| | | | If processing is not required, the frame would be leaked as it is not used.
* various: fix -Wold-style-declaration warningnanahi2024-03-191-1/+1
| | | | warning: `static' is not at beginning of declaration
* af_lavcac3enc: don't use deprecated `avcodec_close`llyyr2024-02-191-1/+9
| | | | | | | | Deprecated upstream https://github.com/FFmpeg/FFmpeg/commit/1cc24d749569a42510399a29b034f7a77bdec34e We need to reallocate the context here because `avcodec_free_context` also frees the context, and we want to reuse the context with some reconfig.
* options: transition options from OPT_FLAG to OPT_BOOLChristoph Heinrich2023-02-211-3/+3
| | | | | | c78482045444c488bb7948305d583a55d17cd236 introduced a bool option type as a replacement for the flag type, but didn't actually transition and remove the flag type because it would have been too much mundane work.
* af_lavcac3enc: switch to AVChannelLayout when availableJan Ekström2022-06-141-3/+36
|
* af_lavcac3enc: refactor chmap adding into its own functionJan Ekström2022-06-141-7/+13
| | | | This simplifies ifdeffery with AVChannelLayouts.
* af_lavcac3enc: fix some minor thingssfan52022-01-101-2/+3
| | | | mark an array as static, a typo and a missing free
* af_lavcac3enc: replace deprecated av_init_packet()sfan52022-01-101-11/+17
|
* af_lavcac3enc: fix memory leak on no-opNiklas Haas2021-12-141-16/+19
| | | | | | | | | Simply returning out of this function leaks avpkt, need to always "goto done". Rewrite the logic a bit to make it more clear what's going on (IMO). Fixes #9593
* build: address AVCodec, AVInputFormat, AVOutputFormat const warningssfan52021-05-011-1/+1
| | | | FFmpeg recently changed these to be const on their side.
* options: change option macros and all option declarationswm42020-03-181-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change all OPT_* macros such that they don't define the entire m_option initializer, and instead expand only to a part of it, which sets certain fields. This requires changing almost every option declaration, because they all use these macros. A declaration now always starts with {"name", ... followed by designated initializers only (possibly wrapped in macros). The OPT_* macros now initialize the .offset and .type fields only, sometimes also .priv and others. I think this change makes the option macros less tricky. The old code had to stuff everything into macro arguments (and attempted to allow setting arbitrary fields by letting the user pass designated initializers in the vararg parts). Some of this was made messy due to C99 and C11 not allowing 0-sized varargs with ',' removal. It's also possible that this change is pointless, other than cosmetic preferences. Not too happy about some things. For example, the OPT_CHOICE() indentation I applied looks a bit ugly. Much of this change was done with regex search&replace, but some places required manual editing. In particular, code in "obscure" areas (which I didn't include in compilation) might be broken now. In wayland_common.c the author of some option declarations confused the flags parameter with the default value (though the default value was also properly set below). I fixed this with this change.
* audio: rewrite filtering glue codewm42018-01-301-275/+229
| | | | Use the new filtering code for audio too.
* Fix various typos in log messagesNicolas F2017-12-031-1/+1
|
* Replace remaining avcodec_close() callswm42017-07-161-4/+1
| | | | | | | | This API isn't deprecated (yet?), but it's still inferior and harder to use than avcodec_free_context(). Leave the call only in 1 case in af_lavcac3enc.c, where we apparently seriously close and reopen the encoder for whatever reason.
* af_lavcac3enc: change license to LGPLwm42017-05-091-7/+7
| | | | | | | All authors have agreed. As usual with these things, this probably does not include residues from the libaf framework.
* Remove compatibility thingswm42016-12-071-16/+0
| | | | | | Possible with bumped FFmpeg/Libav. These are just the simple cases.
* af_lavcac3enc: allow passing options to libavcodecwm42016-08-091-0/+7
|
* af_lavcac3enc: skip output if there was no input framewm42016-08-021-0/+3
| | | | Unrealistic corner case: drainning was initiated right after a seek.
* af_lavcac3enc: fix buffering timestamps calculationswm42016-08-011-3/+9
| | | | In theory, an encoder could buffer some data.
* af_lavcac3enc: fix memory leakwm42016-08-011-1/+1
| | | | A major one. Oops.
* af_lavcac3enc: fix a debug messagewm42016-07-311-1/+1
|
* af_lavcac3enc: error out properly if encoding failswm42016-07-311-0/+4
|
* af_lavcac3enc: fix aspects of AVFrame handlingwm42016-07-311-0/+3
| | | | | | | | | | We send a refcounted frame to the encoder, but then disrespect refcounting rules and write to the frame data without making sure the buffer is really writeable. In theory this can lead to reallocation on every frame is the encoder really keeps a reference. If we really cared, we could fix this by providing a buffer pool. But then again, we don't care.
* af_lavcac3enc: use common code for AVFrame setupwm42016-07-241-11/+2
|
* af_lavcac3enc: use av_err2str() call (fixes Libav build)wm42016-06-231-2/+1
| | | | | I added this call because I thought it'd be nice, but Libav doesn't have this function (macro, actually).
* af_lavcac3enc: make encoder configurablewm42016-06-231-2/+5
|
* af_lavcac3enc: implement flushing on seekwm42016-06-231-0/+7
| | | | | There's a lot of data that could have been buffered, and which has to be discarded.
* af_lavcac3enc: port to new encode APIwm42016-06-231-9/+57
|
* af_lavcac3enc: automatically configure most encoder parameterswm42016-06-231-29/+57
| | | | | | | | | | | Instead of hardcoding what the libavcodec ac3 encoder expects, configure it based on the AVCodec fields. Unfortunately, it doesn't export the list of sample rates, so that is done manually. This commit actually fixes the rate always to 48Khz. I don't even know whether the other rates worked. (Possibly did, but they'd still change the spdif parameters, and would work differently from ad_spdif.c.)
* af_lavcac3enc: drop log message prefixeswm42016-06-231-9/+7
| | | | MPlayer leftover. They're already added by the logging code.
* af_lavcac3enc: fix custom bitrateswm42016-06-231-2/+3
| | | | | | Probably has been broken for ages. (Not sure why anyone would use this feature, though.)
* af_lavcac3enc: simplify/fix AVPacket handlingwm42015-11-041-16/+21
| | | | | | For some reason, the encoder didn't like that the AVPacket already had fields set. I'm not quite sure, but this might just be invalid API usage. Do it as it's recommended.
* Replace deprecated av_free_packet() callswm42015-10-281-1/+1
| | | | | | av_free_packet() got finally deprecated. Use av_packet_unref() instead, which has almost the same semantics, has existed for a while, and is available in all FFmpeg and Libav versions we support.
* audio: remove unused legacy libavutil headerwm42015-08-071-1/+0
| | | | It was never used, but is a leftover from old times.
* 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".
* af_lavcac3enc: fix A/V syncwm42015-06-151-3/+17
| | | | | | The filter can buffer singificant amounts of audio. (The proper fix is making the filter chain PTS-aware.)
* Update license headersMarcin Kurczewski2015-04-131-5/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* af_lavcac3enc: use refcounted frameswm42015-01-141-89/+95
|
* audio/filter: remove unused af_calc_filter_multiplier()wm42015-01-131-3/+2
| | | | | | | | | | | | 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_lavcac3enc: fix byte orderwm42014-10-121-2/+2
| | | | | | | | Oops. Fixes #1172. CC: @mpv-player/stable
* audio: cleanup spdif format definitionswm42014-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: 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_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).
* 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.
* af_lavcac3enc: detach on any passthrough format, not just ac3wm42014-04-161-1/+1
|
* af_lavcac3enc: use new AVFrame APIwm42014-03-161-3/+3
|
* audio/filter: remove redundant log message prefixeswm42014-01-241-2/+2
| | | | | These are now appended automatically, so you'd get them twice before this commit.
* audio: mp_msg conversionswm42013-12-211-11/+11
|
* Reduce recursive config.h inclusions in headerswm42013-12-181-1/+1
| | | | | | 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.
* Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsgwm42013-12-161-3/+3
| | | | | | | | | 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/filter: change filter callback signaturewm42013-12-051-5/+5
| | | | | | | | | 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-041-4/+3
| | | | Used to be used by filters that didn't use the option parser.
* af_lavcac3enc: use option parserwm42013-11-151-35/+37
| | | | | | | This changes option parsing as well as filter defaults slightly. The default is now to encode to spdif (this is way more useful than writing raw AC3 - what was this even useful for, other than writing broken ac3 -in-wav files?). The bitrate parameter is now always in kbps.
* af_lavcac3enc: use planar formatswm42013-11-121-134/+82
| | | | | | | | | | | Remove the awkward planarization. It had to be done because the AC3 encoder requires planar formats, but now we support them natively. Try to simplify buffer management with mp_audio_buffer. Improve checking for buffer overflows and out of bound writes. In theory, these shouldn't happen due to AC3 fixed frame sizes, but being paranoid is better.
* af_lavcac3enc: simplify format negotiationwm42013-11-121-28/+33
| | | | | | | | | | | | | The format negotiation is the same, except don't confusingly copy the input format into af->data, just to overwrite it later. af->data should alwass contain the output format, and the existing code was just a very misguided use of the af_test_output() helper function. Just set af->data to the output format immediately, and modify the input format properly. Also, if format negotiation fails (and needs another iteration), don't initialize the libavcodec encoder.
* audio/filter: fix mul/delay scale and valueswm42013-11-121-4/+4
| | | | | | | | | | | | | 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-16/+2
| | | | | | | | | | | | | 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-15/+15
| | | | | | | | | | | | | | | | | | 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: replace af_fmt2str_short -> af_fmt_to_strwm42013-11-071-2/+1
| | | | Also, remove all af_fmt2str usages.
* 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.
* Fix some -Wshadow warningswm42013-07-231-3/+3
| | | | | | In general, this warning can hint to actual bugs. We don't enable it yet, because it would conflict with some unmerged code, and we should check with clang too (this commit was done by testing with gcc).
* reorder_ch: remove old channel reorder functionswm42013-05-121-9/+0
| | | | | | | This is done in af_lavrresample now, and as part of format negotiation. Also remove the remaining reorder_channel calls. They were redundant and did nothing.
* af: use mp_chmap for mp_audio, include channel map in format negotiationwm42013-05-121-3/+3
| | | | | 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-9/+7
| | | |