summaryrefslogtreecommitdiff
path: root/libavfilter/af_hdcd.c
Commit message (Collapse)AuthorAge
* avfilter: Replace query_formats callback with union of list and callbackAndreas Rheinhardt2021-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If one looks at the many query_formats callbacks in existence, one will immediately recognize that there is one type of default callback for video and a slightly different default callback for audio: It is "return ff_set_common_formats_from_list(ctx, pix_fmts);" for video with a filter-specific pix_fmts list. For audio, it is the same with a filter-specific sample_fmts list together with ff_set_common_all_samplerates() and ff_set_common_all_channel_counts(). This commit allows to remove the boilerplate query_formats callbacks by replacing said callback with a union consisting the old callback and pointers for pixel and sample format arrays. For the not uncommon case in which these lists only contain a single entry (besides the sentinel) enum AVPixelFormat and enum AVSampleFormat fields are also added to the union to store them directly in the AVFilter, thereby avoiding a relocation. The state of said union will be contained in a new, dedicated AVFilter field (the nb_inputs and nb_outputs fields have been shrunk to uint8_t in order to create a hole for this new field; this is no problem, as the maximum of all the nb_inputs is four; for nb_outputs it is only two). The state's default value coincides with the earlier default of query_formats being unset, namely that the filter accepts all formats (and also sample rates and channel counts/layouts for audio) provided that these properties agree coincide for all inputs and outputs. By using different union members for audio and video filters the type-unsafety of using the same functions for audio and video lists will furthermore be more confined to formats.c than before. When the new fields are used, they will also avoid allocations: Currently something nearly equivalent to ff_default_query_formats() is called after every successful call to a query_formats callback; yet in the common case that the newly allocated AVFilterFormats are not used at all (namely if there are no free links) these newly allocated AVFilterFormats are freed again without ever being used. Filters no longer using the callback will not exhibit this any more. Reviewed-by: Paul B Mahol <onemda@gmail.com> Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfilter: Add numbers of (in|out)pads directly to AVFilterAndreas Rheinhardt2021-08-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, an AVFilter's lists of input and output AVFilterPads were terminated by a sentinel and the only way to get the length of these lists was by using avfilter_pad_count(). This has two drawbacks: first, sizeof(AVFilterPad) is not negligible (i.e. 64B on 64bit systems); second, getting the size involves a function call instead of just reading the data. This commit therefore changes this. The sentinels are removed and new private fields nb_inputs and nb_outputs are added to AVFilter that contain the number of elements of the respective AVFilterPad array. Given that AVFilter.(in|out)puts are the only arrays of zero-terminated AVFilterPads an API user has access to (AVFilterContext.(in|out)put_pads are not zero-terminated and they already have a size field) the argument to avfilter_pad_count() is always one of these lists, so it just has to find the filter the list belongs to and read said number. This is slower than before, but a replacement function that just reads the internal numbers that users are expected to switch to will be added soon; and furthermore, avfilter_pad_count() is probably never called in hot loops anyway. This saves about 49KiB from the binary; notice that these sentinels are not in .bss despite being zeroed: they are in .data.rel.ro due to the non-sentinels. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/formats: Factor common function combinations outAndreas Rheinhardt2021-08-13
| | | | | | | | | | | Several combinations of functions happen quite often in query_format functions; e.g. ff_set_common_formats(ctx, ff_make_format_list(sample_fmts)) is very common. This commit therefore adds functions that are equivalent to commonly used function combinations in order to reduce code duplication. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/avcodec: Stop including channel_layout.h in avcodec.hAndreas Rheinhardt2021-07-22
| | | | | | Also include channel_layout.h directly wherever used. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter: Constify all AVFiltersAndreas Rheinhardt2021-04-27
| | | | | | | This is possible now that the next-API is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avfilter/af_hdcd: Fix undefined shiftsAndreas Rheinhardt2021-04-01
| | | | | | Affected the filter-hdcd-* FATE tests. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavfi: regroup formats lists in a single structure.Nicolas George2020-09-08
| | | | | | | | | | | | | | | It will allow to refernce it as a whole without clunky macros. Most of the changes have been automatically made with sed: sed -i ' s/-> *in_formats/->incfg.formats/g; s/-> *out_formats/->outcfg.formats/g; s/-> *in_channel_layouts/->incfg.channel_layouts/g; s/-> *out_channel_layouts/->outcfg.channel_layouts/g; s/-> *in_samplerates/->incfg.samplerates/g; s/-> *out_samplerates/->outcfg.samplerates/g; ' src/libavfilter/*(.)
* avfilter: don't anonymously typedef structsPaul B Mahol2017-05-13
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* Fix all -Wformat warnings raised by DJGPPClément Bœsch2017-03-29
|
* avfilter/af_hdcd: Fix leak of memory allocated by ff_make_format_list()Michael Niedermayer2017-01-22
| | | | | | Fixes CID1396265 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* doc: fix spelling errorsAndreas Cadhalpun2016-10-21
| | | | | | | | Thanks to Mathieu Malaterre <malat@debian.org> for reporting the Que/Queue typo. (https://bugs.debian.org/839542) Reviewed-by: Lou Logan <lou@lrcd.com> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* af_hdcd: disable auto-convert by defaultBurt P2016-10-05
| | | | | | | | | | As all known valid HDCD sample formats and sample rates are now handled by the filter, remove the scan that "invades the privacy" of the filter graph and turn off autoconvert by default as requested by Nicolas George. http://ffmpeg.org/pipermail/ffmpeg-devel/2016-August/197571.html Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: add experimental 20 and 24-bit decoding supportBurt P2016-10-05
| | | | | | | | | | I don't have any legitimate 20 or 24-bit HDCD to test. It is known that the PM Model Two would insert packets into 20 and 24-bit output, but I have no idea what differences in behavior existed when decoding 20 or 24-bit. For now, as with 16-bit, PE (if enabled) will expand the top 3dB into 9dB and LLE (gain adjust) will be applied if signaled. Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: hdcd_scan() and hdcd_integrate() handle stereo and single channelBurt P2016-10-05
| | | | | | | | | | | New versions of hdcd_scan() and hdcd_integrate() that also do the work of hdcd_scan_stereo() and hdcd_integrate_stereo(). Some code split into previously separate functions to remove duplication is now merged back into each function in the single place where it is used. Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: support s16p (WavPack) directlyBurt P2016-10-05
| | | | | | | The buffer is already being copied anyway, so interlace the planar format during the copy and remove one use of auto-convert. Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: allow all HDCD sample ratesBurt P2016-10-05
| | | | | | | | The PM Model Two could output HDCD-encoded audio in CD and all DVD-Audio sample rates. (44100, 48000, 88200, 96000, 176400, and 192000 Hz) Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: add mono as a supported channel layoutBurt P2016-10-05
| | | | Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: fix bounds check in hdcd_envelope()Burt P2016-09-08
| | | | | | | From Sebastian Ramacher. https://github.com/bp0/libhdcd/pull/11 Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: hdcd_analyze_gen() using int instead of floatBurt P2016-09-07
| | | | Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: tweak hdcd_analyze_prepare() a bitBurt P2016-09-07
| | | | | | | | * use the actual sample rate * use a more sensible frequency for the tone * update fate test result Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: move decoding setup from init to config_inputBurt P2016-09-07
| | | | Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: fix possible integer overflowBurt P2016-09-07
| | | | Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: some types renamed to remove _tBurt P2016-09-07
| | | | | | | Following a suggestion by Diego Biurrun. _t is reserved for POSIX, apparently. Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: av_frame_free(out) if av_frame_copy_props() failsBurt P2016-08-25
| | | | Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: for easier maintenance alongside libhdcdBurt P2016-08-25
| | | | | | | | | | | | | | Mostly just re-arranges some code to make it easier to update this filter and libhdcd together. filter_frame() is much simpler as a result. * use the HDCD detection data structure and functions from libhdcd, moved detection code out of filter_frame() * moved analyze_mode preparation out of filter_frame() into hdcd_analyze_prepare(), from libhdcd * moved some macro definitions to the top so they are all together Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: check return value of av_frame_copy_props()Burt P2016-08-24
| | | | | | | | Anton Khirnov: "[av_frame_copy_props()] potentially contains memory allocation, so the return value needs to be checked." Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: PE table limitsBurt P2016-08-21
| | | | Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: add AVOption to disable autoconversion in the filter graphBurt P2016-08-21
| | | | Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: add AVOption to set the CDT periodBurt P2016-08-21
| | | | Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: Code comments updateBurt P2016-08-21
| | | | Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: Don't warn if converting from AV_SAMPLE_FMT_S16PBurt P2016-08-08
| | | | | | | Also checking AVFilterLink->type is AVMEDIA_TYPE_AUDIO before calling av_get_sample_fmt_name() on AVFilterLink->format. Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: Add analyze modeBurt P2016-08-08
| | | | | | | | | | A new mode, selected by filter option, to aid in analysis of HDCD encoded audio. In this mode the audio is replaced by a solid tone and the amplitude is adjusted to signal some specified aspect of the process. The output file can be loaded in an audio editor alongside the original, where the user can see where different features or states are present. Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: convert AVOptions from INT to BOOLBurt P2016-08-06
| | | | | | As suggested by Timothy Gu. Signed-off-by: Burt P <pburt0@gmail.com>
* af_hdcd: add flags to AVOption defsBurt P2016-08-02
| | | | | Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Timothy Gu <timothygu99@gmail.com>
* af_hdcd: Warn if there is any resampling or format conversion in the link chainBurt P2016-08-01
| | | | | | | | | HDCD is only encoded in s16@44100Hz. Scan the chain of AVFilterLinks for any resampling or format conversion/truncation that might cause problems for the filter and issue warnings. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: Process stereo channels together, fix #5727Burt P2016-08-01
| | | | | | | | | | | | | | | Issue #5727: gain adjustment should only be applied if matching gain value from a valid packet in both channels. The existing functions process each channel separately, so it was not possible. * New versions of hdcd_process(), hdcd_scan(), hdcd_integrate() named hdcd_*_stereo() that process both channels together. * target_gain applied will be the last matching target_gain. * The old single channel functions remain as an option. They can be used by: -af hdcd=process_stereo=0. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: Move code detect/check into own functionBurt P2016-08-01
| | | | | Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: add force_pe filter optionBurt P2016-08-01
| | | | | | | | | Used to attempt replication of some results from http://www.audiomisc.co.uk/HFN/HDCD/Examined.html May not be generally useful, defaults to off. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: Improve error detection loggingBurt P2016-08-01
| | | | | | | | | * Moves the filter context member out of state and into HDCDContext * More useful information when an error is detected * Gives a location near where the error was detected Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: give cdt expired counter a value for never setBurt P2016-07-31
| | | | | | | | The counter is now -1 if the code detect timer was never set, and 0 if it was set but never expired. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: fix a minor cosmetic annoyanceBurt P2016-07-31
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavfi/hdcd: fix styleClément Bœsch2016-07-28
|
* lavfi/hdcd: mark pe_str as static and constClément Bœsch2016-07-28
|
* af_hdcd: Report PE as being intermittent or permanentBurt P2016-07-28
| | | | | | | | The Peak Extend feature could be enabled permanently or only when needed. This is now reported. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: Add counter for cdt expirationsBurt P2016-07-27
| | | | | | | | Adds a counter for when the "code detect timer" expired without finding a valid packet. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: more comments in state structBurt P2016-07-27
| | | | | | | Add some comments describing the fields in hdcd_state_t. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: Improve HDCD detectionBurt P2016-07-27
| | | | | | | | HDCD is now only considered detected if a valid packet is active in both channels simultaneously. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: detect and report encoding errors and odditiesBurt P2016-07-14
| | | | | | | | Count and report when a code is signaled but fails to match a known pattern. For example try Līve - Secret Samadhi. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: only hdcd_update_info() when something changesBurt P2016-07-14
| | | | | | | | Only call hdcd_update_info() when the control code changes instead of every frame, so the counters are more meaningful. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* af_hdcd: fewer false positives by ignoring code_counterC in HDCD detectionBurt P2016-07-14
| | | | | Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>